Commit 24f7efabdb218d2c87edf65f81061d30279d0255

Authored by 王通
1 parent 1eb15613

1.

src/main/java/com/bsth/service/impl/LsStationRouteServiceImpl.java
... ... @@ -374,8 +374,8 @@ public class LsStationRouteServiceImpl extends BaseServiceImpl<LsStationRoute, I
374 374 if ("r".equals(stationRoute.getShapedType())) {
375 375 org.geolatte.geom.Point center = stationRoute.getStation().getCenterPointWgs();
376 376 if (GeoUtils.getDistance(p, new Point(center.getPositionN(0).getCoordinate(0), center.getPositionN(0).getCoordinate(1))) <= stationRoute.getRadius()) {
377   - if (indexes.size() == 0 || !indexes.get(indexes.size() - 1).endsWith("-" + j)) {
378   - indexes.add(stationRoute.getStationCode() + "-" + j);
  377 + if (indexes.size() == 0 || !indexes.get(indexes.size() - 1).endsWith(String.format("-%d", j))) {
  378 + indexes.add(String.format("%s-%d", stationRoute.getStationCode(), j));
379 379 }
380 380 break;
381 381 }
... ... @@ -387,8 +387,8 @@ public class LsStationRouteServiceImpl extends BaseServiceImpl&lt;LsStationRoute, I
387 387 }
388 388 com.bsth.util.Geo.Polygon polygon1 = new com.bsth.util.Geo.Polygon(polygonPoint);
389 389 if (GeoUtils.isPointInPolygon(p, polygon1)) {
390   - if (indexes.size() == 0 || !indexes.get(indexes.size() - 1).endsWith("-" + j)) {
391   - indexes.add(stationRoute.getStationCode() + "-" + j);
  390 + if (indexes.size() == 0 || !indexes.get(indexes.size() - 1).endsWith(String.format("-%d", j))) {
  391 + indexes.add(String.format("%s-%d", stationRoute.getStationCode(), j));
392 392 }
393 393 break;
394 394 }
... ... @@ -400,8 +400,12 @@ public class LsStationRouteServiceImpl extends BaseServiceImpl&lt;LsStationRoute, I
400 400 List<String> specialStations = new ArrayList<>();
401 401 result.put("data", specialStations);
402 402 for (int i = 0;i < stationRoutes.size();) {
  403 + if (indexes.size() == 0) {
  404 + break;
  405 + }
403 406 String lastMatch = null;
404   - for (int j = 0;j < indexes.size();j++) {
  407 + int j = 0;
  408 + for (;j < indexes.size();j++) {
405 409 String index = indexes.get(j), suffix = String.format("-%d", i);
406 410 if (index.endsWith(suffix) || isCircularRoute && i == stationRoutes.size() - 1 && index.endsWith("-0")) {
407 411 lastMatch = index;
... ... @@ -410,6 +414,9 @@ public class LsStationRouteServiceImpl extends BaseServiceImpl&lt;LsStationRoute, I
410 414 specialStations.add(String.format("%s, %s", index, lastMatch));
411 415 }
412 416 }
  417 + if (j == indexes.size()) {
  418 + break;
  419 + }
413 420 }
414 421  
415 422 return result;
... ...