Skip to content

Commit

Permalink
handle unreachable routes during VRP searches.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbasa committed Apr 5, 2021
1 parent c29cbb0 commit 7721dac
Showing 1 changed file with 34 additions and 11 deletions.
45 changes: 34 additions & 11 deletions src/main/java/org/pgrserver/repository/CustomRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,23 @@ public String createJsonCollectionResponse(List<List<Integer>> list) {

if( !list.isEmpty() ) {
for(int i=0;i<list.size()-1;i++) {
retVal.append((String)createJsonRouteResponse(list.get(i),i+1));
retVal.append(",");
if( !list.get(i).isEmpty()) {

if(retVal.length() > 0 )
retVal.append(",");

retVal.append((String)createJsonRouteResponse(
list.get(i),i+1));
}
}
if( !list.get(list.size()-1).isEmpty() ) {

if(retVal.length() > 0 )
retVal.append(",");

retVal.append((String)createJsonRouteResponse(list.get(
list.size()-1),list.size()));
}
retVal.append((String)createJsonRouteResponse(list.get(
list.size()-1),list.size()));
}
retVal.append("]}");

Expand All @@ -174,20 +186,31 @@ public String createJsonCollectionResponse(List<List<Integer>> list,

if( !list.isEmpty() ) {
for(int i=0;i<list.size()-1;i++) {
fidCounter++;
retVal.append((String)createJsonRouteResponse(
list.get(i),fidCounter,additionalAttrib.get(i)));
retVal.append(",");
if( !list.get(i).isEmpty()) {
fidCounter++;

if(retVal.length() > 0 )
retVal.append(",");

retVal.append((String)createJsonRouteResponse(
list.get(i),fidCounter,additionalAttrib.get(i)));
}
}
fidCounter++;
retVal.append((String)createJsonRouteResponse(list.get(
if( !list.get(list.size()-1).isEmpty() ) {
fidCounter++;

if(retVal.length() > 0 )
retVal.append(",");

retVal.append((String)createJsonRouteResponse(list.get(
list.size()-1),fidCounter,
additionalAttrib.get(list.size()-1)));
}
}
if( withHeader ) {
retVal.append("]}");
}

return retVal.toString();
}
}

0 comments on commit 7721dac

Please sign in to comment.