{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"🧠 Routing Optimization Tutorial","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"name":"routing_optimized_tutorial"},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"-routing-optimization-tutorial","__idx":0},"children":["🧠 Routing Optimization Tutorial"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This tutorial explains how to use ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["routing optimization options"]}," to compute smarter, more efficient routes."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["OPTIMIZED_*"]}," options allow you to:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Reorder waypoints automatically for shortest/fastest trip"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Close a route (circular trips)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Return to start (round trips)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Find charging stations when battery is insufficient"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["End the trip at the most optimal destination"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Each section includes a use case, a description of the result, and a JSON example."]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"-how-to-enable-optimization","__idx":1},"children":["🔧 How to enable Optimization"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To activate optimization, include ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\"OPTIMIZED_TRIP\""]}," in the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["options"]}," array, along with any desired sub-options:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"\"options\": [ \"OPTIMIZED_TRIP\", \"OPTIMIZED_TRIP_CLOSE\" ]\n"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"name":"optimized_route_for_charging_station"},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"-optimized_route_for_charging_station--ev-smart-routing-with-charging-stops","__idx":2},"children":["⚡ ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["OPTIMIZED_ROUTE_FOR_CHARGING_STATION"]}," – EV smart routing with charging stops"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["✅ ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Use case"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Optimize electric vehicle routing by automatically adding charging stops when the trip is not feasible with the current battery and vehicle parameters."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["📦 ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Example"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"{\n  \"destinations\": [\n    { \"coordinateSat\": { \"lon\": 4.8357, \"lat\": 45.7640 } },\n    { \"coordinateSat\": { \"lon\": 5.0470, \"lat\": 43.6045 } }\n  ],\n  \"routingVehicleProfile\": {\n    \"transportMode\": \"CAR\",\n    \"routingEnergyVehicleFeature\": {\n      \"initBatLvl\": 60,\n      \"batCapacity\": 64,\n      \"payload\": 200,\n      \"scx\": 0.6,\n      \"crr\": 0.01,\n      \"dryWeight\": 2000,\n      \"engineEfficiency\": 0.5,\n      \"maxAccel\": 130,\n      \"maxDecel\": -100\n    }\n  },\n  \"smartRouting\": {\n    \"chargingMode\": \"FASTEST\"\n  },\n  \"routingChargeFeature\": {\n    \"socAlert\": 10,\n    \"socAtArrival\": 20,\n    \"reachChargePointAtArrival\": true,\n    \"connectorTypeIdFilters\": [1, 2, 3],\n    \"providers\": [\"chargemap\", \"totalenergies\"]\n  },\n  \"options\": [ \"OPTIMIZED_ROUTE_FOR_CHARGING_STATION\", \"POLYLINE\" ]\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["💡 What it does"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Checks route feasibility with EV parameters (initial battery level, vehicle consumption, etc.)."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["If the trip can't be completed, inserts optimal charging station stops along the route."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Takes into account criteria like ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["fastest time"]},", ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["shortest distance"]},", or ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["least energy"]}," depending on the route profile."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["⚠️ Requires a valid routingEnergyVehicleFeature block and a smartRouting configuration."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["📨 ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Response"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"{\n  \"usedDestinations\": [\n    {\n      \"inputOrder\": 0,\n      \"used\": true,\n      \"usedOrder\": 0,\n      \"matchedCoordinateGps\": {\n        \"lon\": 4.83554,\n        \"lat\": 45.76412\n      },\n      \"confidenceValue\": 0.33438985736925514,\n      \"distanceFromRequest\": 18.24,\n      \"polylineIndex\": -1,\n      \"duration\": -1,\n      \"length\": -1\n    },\n    {\n      \"inputOrder\": 1,\n      \"used\": true,\n      \"usedOrder\": 1,\n      \"matchedCoordinateGps\": {\n        \"lon\": 5.045916592146761,\n        \"lat\": 43.6039025\n      },\n      \"confidenceValue\": 0.04951623367054404,\n      \"distanceFromRequest\": 109.78,\n      \"polylineIndex\": -1,\n      \"duration\": 9907,\n      \"length\": 276724\n    }\n  ],\n  \"routingRoutes\": [\n    {\n      \"length\": 276724,\n      \"duration\": 9907,\n      \"trafficDelay\": 0,\n      \"averageSpeed\": 100.55581,\n      \"maximumSpeed\": 0,\n      \"startUTurnThreshold\": 3000,\n      \"boundingBox\": {\n        \"minLon\": 4.70685,\n        \"minLat\": 43.60067,\n        \"maxLon\": 5.12559,\n        \"maxLat\": 45.76617\n      },\n      \"startStopInfo\": {\n        \"start\": {\n          \"lon\": 4.83554,\n          \"lat\": 45.76412\n        },\n        \"stop\": {\n          \"lon\": 5.04592,\n          \"lat\": 43.6039\n        },\n        \"distanceFirstMatched\": 0,\n        \"distanceLastMatched\": 0.28,\n        \"interDests\": null\n      },\n      \"polyline\": [\n        {\n          \"lon\": 4.83554,\n          \"lat\": 45.76412\n        },\n        {\n          \"lon\": 4.83422,\n          \"lat\": 45.76421\n        },\n"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"name":"optimized_trip"},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"-optimized_trip--optimized-itinerary-between-fixed-start-and-end-points","__idx":3},"children":["🧭 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["OPTIMIZED_TRIP"]}," – Optimized itinerary between fixed start and end points"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["✅ ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Use case"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Reorder a list of waypoints to find the most optimal travel path, ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["keeping the first and last points fixed"]},".",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"Useful for delivery or service routes with a flexible order of intermediate stops."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["📦 ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Example"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"{\n  \"destinations\": [\n    { \"coordinateSat\": { \"lon\": 4.8357, \"lat\": 45.7640 } },\n    { \"coordinateSat\": { \"lon\": 4.8923, \"lat\": 45.7700 } },\n    { \"coordinateSat\": { \"lon\": 4.9000, \"lat\": 45.7400 } },\n    { \"coordinateSat\": { \"lon\": 5.0470, \"lat\": 43.6045 } }\n  ],\n  \"routingVehicleProfile\": {\n    \"transportMode\": \"CAR\"\n  },\n  \"departureTime\": \"2025-07-02T09:00:00\",\n  \"options\": [ \"OPTIMIZED_TRIP\", \"POLYLINE\" ]\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["💡 What it does"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Keeps start and end points fixed."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Reorders intermediate destinations to minimize travel time, distance, or energy."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Can consider departure time to factor in time-based traffic or restrictions."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["📝 You can combine this with EVENT or energy options for enhanced routing context."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["📨 ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Response"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"{\n  \"usedDestinations\": [\n    {\n      \"inputOrder\": 0,\n      \"used\": true,\n      \"usedOrder\": 0,\n      \"matchedCoordinateGps\": {\n        \"lon\": 4.83554,\n        \"lat\": 45.76412\n      },\n      \"confidenceValue\": 0.33438985736925514,\n      \"distanceFromRequest\": 18.24,\n      \"polylineIndex\": -1,\n      \"duration\": -1,\n      \"length\": -1\n    },\n    {\n      \"inputOrder\": 1,\n      \"used\": true,\n      \"usedOrder\": 1,\n      \"matchedCoordinateGps\": {\n        \"lon\": 4.892257988197541,\n        \"lat\": 45.7697075\n      },\n      \"confidenceValue\": 0.20329411764705882,\n      \"distanceFromRequest\": 32.72,\n      \"polylineIndex\": -1,\n      \"duration\": 1160,\n      \"length\": 10992\n    },\n    {\n      \"inputOrder\": 2,\n      \"used\": true,\n      \"usedOrder\": 2,\n      \"matchedCoordinateGps\": {\n        \"lon\": 4.90009,\n        \"lat\": 45.73994\n      },\n      \"confidenceValue\": 0.34147334147334146,\n      \"distanceFromRequest\": 9.67,\n      \"polylineIndex\": -1,\n      \"duration\": 1896,\n      \"length\": 15938\n    },\n    {\n      \"inputOrder\": 3,\n      \"used\": true,\n      \"usedOrder\": 3,\n      \"matchedCoordinateGps\": {\n        \"lon\": 5.045916592146761,\n        \"lat\": 43.6039025\n      },\n      \"confidenceValue\": 0.04951623367054404,\n      \"distanceFromRequest\": 109.78,\n      \"polylineIndex\": -1,\n      \"duration\": 11677,\n      \"length\": 293138\n    }\n  ],\n  \"routingRoutes\": [\n    {\n      \"length\": 293138,\n      \"duration\": 11677,\n      \"trafficDelay\": 0,\n      \"averageSpeed\": 90.37396,\n      \"maximumSpeed\": 0,\n      \"startUTurnThreshold\": 3000,\n      \"boundingBox\": {\n        \"minLon\": 4.70685,\n        \"minLat\": 43.60067,\n        \"maxLon\": 5.12559,\n        \"maxLat\": 45.79358\n      },\n      \"startStopInfo\": {\n        \"start\": {\n          \"lon\": 4.83554,\n          \"lat\": 45.76412\n        },\n        \"stop\": {\n          \"lon\": 5.04592,\n          \"lat\": 43.6039\n        },\n        \"distanceFirstMatched\": 0,\n        \"distanceLastMatched\": 0.28,\n        \"interDests\": null\n      },\n      \"polyline\": [\n        {\n          \"lon\": 4.83554,\n          \"lat\": 45.76412\n        },\n        {\n          \"lon\": 4.83422,\n          \"lat\": 45.76421\n        },\n"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"name":"optimized_trip_close"},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"-optimized_trip_close--optimize-and-return-to-start-point","__idx":4},"children":["🔁 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["OPTIMIZED_TRIP_CLOSE"]}," – Optimize and return to start point"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["✅ ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Use case"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Reorder waypoints for the best itinerary ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["and automatically close the loop"]}," by adding a leg from the last point back to the first one.",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"Useful for logistics tours or delivery loops."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["📦 ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Example"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"{\n  \"destinations\": [\n    { \"coordinateSat\": { \"lon\": 4.8357, \"lat\": 45.7640 } },\n    { \"coordinateSat\": { \"lon\": 4.8923, \"lat\": 45.7700 } },\n    { \"coordinateSat\": { \"lon\": 4.9000, \"lat\": 45.7400 } },\n    { \"coordinateSat\": { \"lon\": 5.0470, \"lat\": 43.6045 } }\n  ],\n  \"routingVehicleProfile\": {\n    \"transportMode\": \"CAR\"\n  },\n  \"options\": [ \"OPTIMIZED_TRIP\", \"OPTIMIZED_TRIP_CLOSE\", \"POLYLINE\" ]\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["💡 What it does"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Optimizes the trip order (like ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["OPTIMIZED_TRIP"]},")"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Adds an extra leg back to the starting point, turning the itinerary into a loop"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Keeps start and end points fixed"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["📎 Combine with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["departureTime"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["EVENT"]}," for time-aware or segment-detailed optimization."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["📨 ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Response"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"{\n  \"usedDestinations\": [\n    {\n      \"inputOrder\": 0,\n      \"used\": true,\n      \"usedOrder\": 0,\n      \"matchedCoordinateGps\": {\n        \"lon\": 4.83554,\n        \"lat\": 45.76412\n      },\n      \"confidenceValue\": 0.33438985736925514,\n      \"distanceFromRequest\": 18.24,\n      \"polylineIndex\": -1,\n      \"duration\": -1,\n      \"length\": -1\n    },\n    {\n      \"inputOrder\": 1,\n      \"used\": true,\n      \"usedOrder\": 1,\n      \"matchedCoordinateGps\": {\n        \"lon\": 4.892257988197541,\n        \"lat\": 45.7697075\n      },\n      \"confidenceValue\": 0.20329411764705882,\n      \"distanceFromRequest\": 32.72,\n      \"polylineIndex\": -1,\n      \"duration\": 1160,\n      \"length\": 10992\n    },\n    {\n      \"inputOrder\": 2,\n      \"used\": true,\n      \"usedOrder\": 2,\n      \"matchedCoordinateGps\": {\n        \"lon\": 4.90009,\n        \"lat\": 45.73994\n      },\n      \"confidenceValue\": 0.34147334147334146,\n      \"distanceFromRequest\": 9.67,\n      \"polylineIndex\": -1,\n      \"duration\": 1896,\n      \"length\": 15938\n    },\n    {\n      \"inputOrder\": 3,\n      \"used\": true,\n      \"usedOrder\": 3,\n      \"matchedCoordinateGps\": {\n        \"lon\": 5.045916592146761,\n        \"lat\": 43.6039025\n      },\n      \"confidenceValue\": 0.04951623367054404,\n      \"distanceFromRequest\": 109.78,\n      \"polylineIndex\": -1,\n      \"duration\": 21545,\n      \"length\": 570336\n    }\n  ],\n  \"routingRoutes\": [\n    {\n      \"length\": 570336,\n      \"duration\": 21545,\n      \"trafficDelay\": 0,\n      \"averageSpeed\": 95.29866,\n      \"maximumSpeed\": 0,\n      \"startUTurnThreshold\": 3000,\n      \"boundingBox\": {\n        \"minLon\": 4.70685,\n        \"minLat\": 43.60067,\n        \"maxLon\": 5.13023,\n        \"maxLat\": 45.79358\n      },\n      \"startStopInfo\": {\n        \"start\": {\n          \"lon\": 4.83554,\n          \"lat\": 45.76412\n        },\n        \"stop\": {\n          \"lon\": 4.83554,\n          \"lat\": 45.76412\n        },\n        \"distanceFirstMatched\": 0,\n        \"distanceLastMatched\": 241049.82,\n        \"interDests\": null\n      },\n      \"polyline\": [\n        {\n          \"lon\": 4.83554,\n          \"lat\": 45.76412\n        },\n        {\n          \"lon\": 4.83422,\n          \"lat\": 45.76421\n        },\n"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"name":"optimized_trip_round"},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"-optimized_trip_round--round-trip-with-return-to-origin","__idx":5},"children":["🔄 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["OPTIMIZED_TRIP_ROUND"]}," – Round trip with return to origin"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["✅ ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Use case"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Compute an optimized route that ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["starts and ends at the same location"]},", but does ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["not explicitly close the loop"]}," by recalculating the last leg.",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"Useful when you want to return to the start point without forcing a final optimization step."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["📦 ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Example"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"{\n  \"destinations\": [\n    { \"coordinateSat\": { \"lon\": 4.8357, \"lat\": 45.7640 } },\n    { \"coordinateSat\": { \"lon\": 4.8923, \"lat\": 45.7700 } },\n    { \"coordinateSat\": { \"lon\": 4.9000, \"lat\": 45.7400 } },\n    { \"coordinateSat\": { \"lon\": 5.0470, \"lat\": 43.6045 } }\n  ],\n  \"routingVehicleProfile\": {\n    \"transportMode\": \"CAR\"\n  },\n  \"options\": [ \"OPTIMIZED_TRIP\", \"OPTIMIZED_TRIP_ROUND\", \"POLYLINE\" ]\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["💡 What it does"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Optimizes the trip while ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["keeping the first point as both start and end"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The route ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["comes back to the starting point"]},", but the last segment is not recalculated like with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["OPTIMIZED_TRIP_CLOSE"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Use this when the return is known or not important to recalculate"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["📌 To close the route explicitly with recalculation, add ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["OPTIMIZED_TRIP_CLOSE"]}," as well."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["📨 ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Response"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"{\n  \"usedDestinations\": [\n    {\n      \"inputOrder\": 0,\n      \"used\": true,\n      \"usedOrder\": 0,\n      \"matchedCoordinateGps\": {\n        \"lon\": 4.83554,\n        \"lat\": 45.76412\n      },\n      \"confidenceValue\": 0.33438985736925514,\n      \"distanceFromRequest\": 18.24,\n      \"polylineIndex\": -1,\n      \"duration\": -1,\n      \"length\": -1\n    },\n    {\n      \"inputOrder\": 1,\n      \"used\": true,\n      \"usedOrder\": 1,\n      \"matchedCoordinateGps\": {\n        \"lon\": 4.892257988197541,\n        \"lat\": 45.7697075\n      },\n      \"confidenceValue\": 0.20329411764705882,\n      \"distanceFromRequest\": 32.72,\n      \"polylineIndex\": -1,\n      \"duration\": 1160,\n      \"length\": 10992\n    },\n    {\n      \"inputOrder\": 2,\n      \"used\": true,\n      \"usedOrder\": 2,\n      \"matchedCoordinateGps\": {\n        \"lon\": 4.90009,\n        \"lat\": 45.73994\n      },\n      \"confidenceValue\": 0.34147334147334146,\n      \"distanceFromRequest\": 9.67,\n      \"polylineIndex\": -1,\n      \"duration\": 1896,\n      \"length\": 15938\n    },\n    {\n      \"inputOrder\": 3,\n      \"used\": true,\n      \"usedOrder\": 3,\n      \"matchedCoordinateGps\": {\n        \"lon\": 5.045916592146761,\n        \"lat\": 43.6039025\n      },\n      \"confidenceValue\": 0.04951623367054404,\n      \"distanceFromRequest\": 109.78,\n      \"polylineIndex\": -1,\n      \"duration\": 11677,\n      \"length\": 293138\n    }\n  ],\n  \"routingRoutes\": [\n    {\n      \"length\": 293138,\n      \"duration\": 11677,\n      \"trafficDelay\": 0,\n      \"averageSpeed\": 90.37396,\n      \"maximumSpeed\": 0,\n      \"startUTurnThreshold\": 3000,\n      \"boundingBox\": {\n        \"minLon\": 4.70685,\n        \"minLat\": 43.60067,\n        \"maxLon\": 5.12559,\n        \"maxLat\": 45.79358\n      },\n      \"startStopInfo\": {\n        \"start\": {\n          \"lon\": 4.83554,\n          \"lat\": 45.76412\n        },\n        \"stop\": {\n          \"lon\": 5.04592,\n          \"lat\": 43.6039\n        },\n        \"distanceFirstMatched\": 0,\n        \"distanceLastMatched\": 0.28,\n        \"interDests\": null\n      },\n      \"polyline\": [\n        {\n          \"lon\": 4.83554,\n          \"lat\": 45.76412\n        },\n        {\n          \"lon\": 4.83422,\n          \"lat\": 45.76421\n        },\n"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"name":"optimized_trip_undefstop"},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"-optimized_trip_undefstop--open-ended-optimized-trip","__idx":6},"children":["❓ ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["OPTIMIZED_TRIP_UNDEFSTOP"]}," – Open-ended optimized trip"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["✅ ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Use case"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Compute an optimized trip that starts at a ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["defined point"]}," but ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["ends at any of the waypoints"]},", choosing the one that produces the best overall path.",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"This is useful when the final destination is flexible (e.g. logistics scenarios, open deliveries)."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["📦 ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Example"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"{\n  \"destinations\": [\n    { \"coordinateSat\": { \"lon\": 4.8357, \"lat\": 45.7640 } },\n    { \"coordinateSat\": { \"lon\": 5.0470, \"lat\": 43.6045 } },\n    { \"coordinateSat\": { \"lon\": 4.8923, \"lat\": 45.7700 } },\n    { \"coordinateSat\": { \"lon\": 4.9000, \"lat\": 45.7400 } }\n  ],\n  \"routingVehicleProfile\": {\n    \"transportMode\": \"CAR\"\n  },\n  \"options\": [ \"OPTIMIZED_TRIP\", \"OPTIMIZED_TRIP_UNDEFSTOP\", \"POLYLINE\" ]\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["💡 What it does"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Keeps the first coordinate fixed as the start"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Selects the most optimal final stop among the remaining waypoints"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Skips the need to manually define a final destination in advance"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["📎 Useful when the route can end at any stop to minimize time, distance, or cost."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["📨 ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Response"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"{\n  \"usedDestinations\": [\n    {\n      \"inputOrder\": 0,\n      \"used\": true,\n      \"usedOrder\": 0,\n      \"matchedCoordinateGps\": {\n        \"lon\": 4.83554,\n        \"lat\": 45.76412\n      },\n      \"confidenceValue\": 0.33438985736925514,\n      \"distanceFromRequest\": 18.24,\n      \"polylineIndex\": -1,\n      \"duration\": -1,\n      \"length\": -1\n    },\n    {\n      \"inputOrder\": 1,\n      \"used\": true,\n      \"usedOrder\": 3,\n      \"matchedCoordinateGps\": {\n        \"lon\": 5.045916592146761,\n        \"lat\": 43.6039025\n      },\n      \"confidenceValue\": 0.04951623367054404,\n      \"distanceFromRequest\": 109.78,\n      \"polylineIndex\": -1,\n      \"duration\": 11677,\n      \"length\": 293138\n    },\n    {\n      \"inputOrder\": 2,\n      \"used\": true,\n      \"usedOrder\": 1,\n      \"matchedCoordinateGps\": {\n        \"lon\": 4.892257988197541,\n        \"lat\": 45.7697075\n      },\n      \"confidenceValue\": 0.20329411764705882,\n      \"distanceFromRequest\": 32.72,\n      \"polylineIndex\": -1,\n      \"duration\": 1160,\n      \"length\": 10992\n    },\n    {\n      \"inputOrder\": 3,\n      \"used\": true,\n      \"usedOrder\": 2,\n      \"matchedCoordinateGps\": {\n        \"lon\": 4.90009,\n        \"lat\": 45.73994\n      },\n      \"confidenceValue\": 0.34147334147334146,\n      \"distanceFromRequest\": 9.67,\n      \"polylineIndex\": -1,\n      \"duration\": 1896,\n      \"length\": 15938\n    }\n  ],\n  \"routingRoutes\": [\n    {\n      \"length\": 293138,\n      \"duration\": 11677,\n      \"trafficDelay\": 0,\n      \"averageSpeed\": 90.37396,\n      \"maximumSpeed\": 0,\n      \"startUTurnThreshold\": 3000,\n      \"boundingBox\": {\n        \"minLon\": 4.70685,\n        \"minLat\": 43.60067,\n        \"maxLon\": 5.12559,\n        \"maxLat\": 45.79358\n      },\n      \"startStopInfo\": {\n        \"start\": {\n          \"lon\": 4.83554,\n          \"lat\": 45.76412\n        },\n        \"stop\": {\n          \"lon\": 5.04592,\n          \"lat\": 43.6039\n        },\n        \"distanceFirstMatched\": 0,\n        \"distanceLastMatched\": 238062.84,\n        \"interDests\": null\n      },\n      \"polyline\": [\n        {\n          \"lon\": 4.83554,\n          \"lat\": 45.76412\n        },\n        {\n          \"lon\": 4.83422,\n          \"lat\": 45.76421\n        },\n"},"children":[]}]},"headings":[{"value":"🧠 Routing Optimization Tutorial","id":"-routing-optimization-tutorial","depth":1},{"value":"🔧 How to enable Optimization","id":"-how-to-enable-optimization","depth":2},{"value":"⚡ OPTIMIZED_ROUTE_FOR_CHARGING_STATION – EV smart routing with charging stops","id":"-optimized_route_for_charging_station--ev-smart-routing-with-charging-stops","depth":2},{"value":"🧭 OPTIMIZED_TRIP – Optimized itinerary between fixed start and end points","id":"-optimized_trip--optimized-itinerary-between-fixed-start-and-end-points","depth":2},{"value":"🔁 OPTIMIZED_TRIP_CLOSE – Optimize and return to start point","id":"-optimized_trip_close--optimize-and-return-to-start-point","depth":2},{"value":"🔄 OPTIMIZED_TRIP_ROUND – Round trip with return to origin","id":"-optimized_trip_round--round-trip-with-return-to-origin","depth":2},{"value":"❓ OPTIMIZED_TRIP_UNDEFSTOP – Open-ended optimized trip","id":"-optimized_trip_undefstop--open-ended-optimized-trip","depth":2}],"frontmatter":{"seo":{"title":"🧠 Routing Optimization Tutorial"}},"lastModified":"2025-08-26T09:03:13.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/api-reference/routing/tutorial/routing_optimized","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}