| | |
| | | //package com.stylefeng.guns; |
| | | // |
| | | //import org.junit.runner.RunWith; |
| | | //import org.springframework.boot.test.context.SpringBootTest; |
| | | //import org.springframework.test.context.junit4.SpringRunner; |
| | | // |
| | | //@RunWith(SpringRunner.class) |
| | | //@SpringBootTest |
| | | //public class GunsApplicationTest { |
| | | // |
| | | //} |
| | | package com.stylefeng.guns; |
| | | |
| | | import org.junit.Test; |
| | | import org.junit.runner.RunWith; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.test.context.junit4.SpringRunner; |
| | | |
| | | @RunWith(SpringRunner.class) |
| | | @SpringBootTest |
| | | public class GunsApplicationTest { |
| | | |
| | | @Autowired |
| | | private MongoTemplate mongoTemplate; |
| | | |
| | | |
| | | @Test |
| | | public void test(){ |
| | | // GeoJsonPoint point = new GeoJsonPoint(new Point(Double.parseDouble("104.043149"), |
| | | // Double.parseDouble("30.642483"))); |
| | | // DriverPosition position = mongoTemplate.findOne(Query.query(Criteria.where("driverId") |
| | | // .is(14)), DriverPosition.class); |
| | | // if(null == position){ |
| | | // position = new DriverPosition(); |
| | | // } |
| | | // position.setDriverId(14); |
| | | // position.setPoint(point); |
| | | // mongoTemplate.save(position); |
| | | |
| | | |
| | | // Query query = Query.query(Criteria.where("point").nearSphere(new Point(Double.parseDouble("104.043149"), Double.parseDouble("30.642483"))).maxDistance(5000)); |
| | | // List<DriverPosition> driverPositions = mongoTemplate.find(query, DriverPosition.class); |
| | | // System.err.println(driverPositions); |
| | | } |
| | | } |