Pu Zhibing
2025-08-01 1976e320c3ba2f3bb875ed4a1d01aa3945aeb442
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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);
    }
}