| | |
| | | List<String> operatingArea = xpGeoFencingPolygonService.findFencesContainingPoint(startPoint, "operating_area", "points"); |
| | | String fenceId = operatingArea.get(0); |
| | | |
| | | List<Document> pointsInFence = xpGeoFencingPolygonService.findPointsByParentId(fenceId, "parentId", "prohibited_area"); |
| | | List<Document> pointsInFence = xpGeoFencingPolygonService.findPointsByParentId(fenceId, "fenceId", "prohibited_area"); |
| | | |
| | | // 避让区域 |
| | | ArrayList<String> pointStrParam = new ArrayList<>(); |
| | | try { |
| | | for (Document document : pointsInFence) { |
| | | List<GeoPoint> points = document.getList("points", GeoPoint.class); |
| | | // 一个区域的点位 |
| | | ArrayList<String> pointStr = new ArrayList<>(); |
| | | for (GeoPoint point : points) { |
| | | pointStr.add( point.getLongitude()+","+point.getLatitude()); |
| | | } |
| | | if(!pointStr.isEmpty()){ |
| | | pointStrParam.add(String.join(";", pointStr)); |
| | | } |
| | | // 获取points字段(它是GeoJSON对象) |
| | | Document geoJsonDoc = document.get("points", Document.class); |
| | | |
| | | if (geoJsonDoc != null && "Polygon".equals(geoJsonDoc.getString("type"))) { |
| | | // 获取coordinates数组 |
| | | List<List<List<Double>>> coordinates = (List<List<List<Double>>>) geoJsonDoc.get("coordinates"); |
| | | |
| | | if (coordinates != null && !coordinates.isEmpty()) { |
| | | // 获取第一个多边形环(通常只有一个) |
| | | List<List<Double>> polygonPoints = coordinates.get(0); |
| | | |
| | | // 转换为经纬度字符串 |
| | | ArrayList<String> pointStr = new ArrayList<>(); |
| | | for (List<Double> point : polygonPoints) { |
| | | if (point.size() >= 2) { |
| | | pointStr.add(point.get(0) + "," + point.get(1)); |
| | | } |
| | | } |
| | | |
| | | if (!pointStr.isEmpty()) { |
| | | pointStrParam.add(String.join(";", pointStr)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | RouteVo routeVo = gdMapGeocodingUtil.getDistanceAndTime(dto.getOrigin(), dto.getDestination(), String.join("|", pointStrParam), fenceId,dto.getRoutePlanRule()); |
| | | if(routeVo==null){ |