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