| | |
| | | JSONObject jsonObject2 = (JSONObject) o; |
| | | String routeID = jsonObject2.getString("routeID"); |
| | | String points = jsonObject2.getString("points"); |
| | | String label = jsonObject2.getString("label"); |
| | | if(label.contains("大众常选")){ |
| | | String[] split = points.split(";"); |
| | | List<LonLatDto> pointsArray = new ArrayList<>(); |
| | | for (int i = 0; i < split.length; i++) { |
| | | if((i % 2) == 0){ |
| | | String[] split1 = split[i].split(","); |
| | | LonLatDto lonLatDto = new LonLatDto(Double.parseDouble(split1[0]), Double.parseDouble(split1[1])); |
| | | pointsArray.add(lonLatDto); |
| | | } |
| | | } |
| | | ForkJoinPool pool = new ForkJoinPool(); // 创建ForkJoinPool对象(默认使用处理器的核心数作为线程池大小) |
| | | ArrayPointsTask arrayPointsTask = new ArrayPointsTask(pointsArray, fenceId); // 创建求和任务对象并传入数组作为参数(这里也可以传入数组的一部分作为参数来实现更细粒度的拆分) |
| | | Long temp = pool.invoke(arrayPointsTask); // 提交任务并等待处理完成(也可以使用submit方法提交任务并获取一个Future对象来异步获取结果) |
| | | pool.shutdown(); // 关闭ForkJoinPool(释放资源) |
| | | if(temp==0){ |
| | | Integer costTime = jsonObject2.getInteger("costTime"); |
| | | Integer distance = jsonObject2.getInteger("distance"); |
| | | routeVo.setDistance(distance); |
| | | routeVo.setDuration(costTime); |
| | | ArrayList<LonLatDto> lonLatDtos = new ArrayList<>(split.length); |
| | | for (String s : split) { |
| | | String[] split1 = s.split(","); |
| | | LonLatDto lonLatDto = new LonLatDto(Double.parseDouble(split1[0]), Double.parseDouble(split1[1])); |
| | | lonLatDtos.add(lonLatDto); |
| | | } |
| | | routeVo.setPolyline(lonLatDtos); |
| | | routeVo.setRouteID(routeID); |
| | | log.info("导航 {} 在 {} 运营区域内", routeVo.getRouteID(), fenceId); |
| | | return routeVo; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | for (Object o : path) { |
| | | JSONObject jsonObject2 = (JSONObject) o; |
| | | String routeID = jsonObject2.getString("routeID"); |
| | | String points = jsonObject2.getString("points"); |
| | | String[] split = points.split(";"); |
| | | List<LonLatDto> pointsArray = new ArrayList<>(); |
| | | for (int i = 0; i < split.length; i++) { |