Reputation: 3
I have a list of GIS point that creates a route network.
My goal is to let agents move from a point to another using ONLY the network I provided. I don't want to use all the possible routes from a point A to a point B, just the ones that I can follow based on my own network.
I know that it should be possible by implementing a custom RouteProvider, but I was not able to figure out how to do it.
Thank you very much for your help!
Upvotes: 0
Views: 254
Reputation: 972
I assume you have a collection "locations" of type ArrayList containing all your GISPoints, here is what you do:
//create a new GIS network and attach it to your map element
GISNetwork network = new GISNetwork(map,"myNetwork");
//add all GISPoints to this network
for(GISPoint p:locations){
network.add(p);
}
//somehow iterate through your points to create Routes between them (here just connect one after another, no cross connections)
for(int i=0;i<locations.size()-1;i++){
//create segment (neccessary for Curve)
GISMarkupSegment segment = new GISMarkupSegmentLine(locations.get(i).getLatitude(), locations.get(i).getLongitude(), locations.get(i+1).getLatitude(), locations.get(i+1).getLongitude());
//create curves (neccessary for the GISRoutes)
Curve<GISMarkupSegment> curve = new Curve<>();
curve.addSegment(segment);
curve.initialize();
network.add(new GISRoute(map,curve,locations.get(i), locations.get(i+1), true));
}
network.initialize();
Upvotes: 1