| | |
| | | import com.yssh.dao.LocationMapper; |
| | | import com.yssh.entity.Location; |
| | | import com.yssh.service.ILocationService; |
| | | import com.yssh.utils.CalculateUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | public class LocationServiceImpl implements ILocationService { |
| | | @Resource |
| | | private LocationMapper mapper; |
| | | |
| | | private static List<Location> vocAddrs = null; |
| | | |
| | | @Override |
| | | public List<Location> query(String name, String type) { |
| | |
| | | public int deleteLocation(String id) { |
| | | return mapper.deleteLocation(id); |
| | | } |
| | | |
| | | @Override |
| | | 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<>(); |
| | | for (Location loc : vocAddrs) { |
| | | if (Math.abs(loc.getLon() - x) <= 0.00009 && Math.abs(loc.getLat() - y) <= 0.00009) { |
| | | list.add(loc); |
| | | } |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | } |