| | |
| | | public class XpElectronicFenceServiceImpl extends ServiceImpl<XpElectronicFenceMapper, XpElectronicFence> implements XpElectronicFenceService { |
| | | |
| | | |
| | | @Resource |
| | | private XpOpenCityMapper xpOpenCityMapper; |
| | | |
| | | @Resource |
| | | private XpElectronicFenceAreaMapper xpElectronicFenceAreaMapper; |
| | | |
| | | @Override |
| | | public List<XpElectronicFenceVo> getXpElectronicFenceList(String cityCode) { |
| | | // 通过code找到电子围栏信息 |
| | | // TODO 魔法数字 |
| | | List<XpOpenCity> xpOpenCities = xpOpenCityMapper.selectList(new LambdaQueryWrapper<XpOpenCity>().eq(XpOpenCity::getCityCode, cityCode).eq(XpOpenCity::getStatus, 1)); |
| | | if (!xpOpenCities.isEmpty()) { |
| | | List<Long> openCityIds = xpOpenCities.stream().map(XpOpenCity::getId).collect(Collectors.toList()); |
| | | |
| | | } |
| | | return Collections.emptyList(); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean isInElectronicFence(Double latitude, Double longitude,String cityCode) { |
| | | |
| | | // 获取所有可用的电子围栏信息 |
| | | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 通过一个点位 判断是否在某个电子围栏内 |
| | | */ |
| | | private static boolean isInElectronicFence(double lon, double lat,List<String> fencePoints) { |
| | | boolean contains = false; |
| | | |
| | | for (String fencePoint : fencePoints) { |
| | | ArrayList<GeoPolygonUtil.GeoPoint> geoPoints = new ArrayList<>(); |
| | | String[] split = fencePoint.split(","); |
| | | for (String lonLat : split) { |
| | | String[] split1 = lonLat.split("_"); |
| | | GeoPolygonUtil.GeoPoint geoPoint = new GeoPolygonUtil.GeoPoint(Double.parseDouble(split1[0]), Double.parseDouble(split1[1])); |
| | | geoPoints.add(geoPoint); |
| | | } |
| | | contains = GeoPolygonUtil.contains(lon, lat, geoPoints); |
| | | if(contains){ |
| | | // 一旦在范围中直接返回true |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | |
| | | } |
| | | |
| | | } |