-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Look For new Destination based on provided Route IDs
- Loading branch information
Showing
4 changed files
with
88 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
.../sdk/examples/routes/dynamic/insert/DynamicInsertStopOptimalAfterLastVisitedRouteIDs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright 2022 Route4Me. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package com.route4me.sdk.examples.routes.dynamic.insert; | ||
|
||
import com.route4me.sdk.exception.APIException; | ||
import com.route4me.sdk.services.routing.Address; | ||
import com.route4me.sdk.services.routing.RoutingManager; | ||
import com.route4me.sdk.services.routing.dynamic.insert.DynamicInsertManager; | ||
import com.route4me.sdk.services.routing.dynamic.insert.InsertMode; | ||
import com.route4me.sdk.services.routing.dynamic.insert.MatchedRoute; | ||
import com.route4me.sdk.services.routing.dynamic.insert.RecommendedBy; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
/** | ||
* | ||
* @author route4me | ||
*/ | ||
public class DynamicInsertStopOptimalAfterLastVisitedRouteIDs { | ||
|
||
public static void main(String[] args) { | ||
String apiKey = System.getenv("R4M_API_KEY"); | ||
|
||
DynamicInsertManager dynamicManager = new DynamicInsertManager(apiKey); | ||
RoutingManager routeManager = new RoutingManager(apiKey); | ||
|
||
Address address = new Address("Address 1", 43.103865, -79.093727); | ||
List<String> routeIDs = Arrays.asList("A42056A8120AF6EEDFAE3886B9909780", "724E95A9A4773F83B7236E8CA20E8F96"); | ||
|
||
try { | ||
List<MatchedRoute> matchedRoutes = dynamicManager.lookForNewDestination(address.getLatitude(), address.getLongitude(), InsertMode.OPTIMAL_AFTER_LAST_VISITED, RecommendedBy.DISTANCE, 5, routeIDs); | ||
for (MatchedRoute matchedRoute : matchedRoutes) { | ||
System.out.println(matchedRoute); | ||
} | ||
System.out.println("Inserting Stop into first Route from the List"); | ||
|
||
MatchedRoute matchedRoute = matchedRoutes.get(0); | ||
address.setSequenceNo(matchedRoute.getRecommendedInsertionStopNumber()); | ||
|
||
List<Address> addresses = Arrays.asList(address); | ||
|
||
routeManager.addAddressesToRoute(matchedRoute.getRouteID(), addresses); | ||
|
||
} catch (APIException ex) { | ||
Logger.getLogger(DynamicInsertStopOptimalAfterLastVisitedRouteIDs.class.getName()).log(Level.SEVERE, null, ex); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters