燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2023-07-14 33b0919883649a0be826e0ac897f6bbbaf8d3f63
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package com.yssh.service;
 
import com.yssh.entity.Location;
import com.yssh.mapper.LocationMapper;
import com.yssh.utils.CalculateUtils;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
 
/**
 * @author wMeng
 * @date 2022/10/30 13:25
 * @version 1.0
 */
@Service
public class LocationService {
    @Resource
    private LocationMapper mapper;
 
    private static List<Location> vocAddrs = null;
 
    public List<Location> query(String name, String type) {
        return mapper.query(name, type);
    }
 
    public List<Location> getAll() {
        return mapper.getAll();
    }
 
    public int insertLocation(Location location) {
        return mapper.insertLocation(location);
    }
 
    public int deleteLocation(String id) {
        return mapper.deleteLocation(id);
    }
 
    public List<Location> selectVocAddrs(double x, double y) {
        if (null == vocAddrs) {
            vocAddrs = mapper.selectVocAddrs();
 
            for (Location loc : vocAddrs) {
                double X = CalculateUtils.getLon((int) loc.getLon(), (int) loc.getLat());
                double Y = CalculateUtils.getLat((int) loc.getLon(), (int) loc.getLat());
                loc.setLon(X);
                loc.setLat(Y);
            }
        }
 
        List<Location> list = new ArrayList<>();
        // 1米=0.0000089932
        for (Location loc : vocAddrs) {
            if (Math.abs(loc.getLon() - x) <= 0.0009 && Math.abs(loc.getLat() - y) <= 0.0009) {
                list.add(loc);
            }
        }
 
        return list;
    }
}