Route Optimization Engine re-sequences a crew's stops with Haversine distance, a Nearest-Neighbor seed tour, and 2-Opt local search — then hands back a shorter route and a ready-to-render map, in one call.
Every "Optimize Route" click runs the same three-step heuristic: measure real-world distance between every stop, build a fast greedy tour, then locally refine it until no swap shortens it further.
The optimized tour comes back pre-packaged in AnyChart connector-map format — numbered points plus a flat lat/lng connector series — so the client never has to transform anything before drawing it.
map.points — origin + every stop, each with an order index for numbered pinsmap.connector — a flat [lat,lng,lat,lng,...] array plus short/full tooltip textA single POST /api/en/crew-routing/optimize takes the route's stops and returns the re-sequenced list, the new total distance, and the ready-to-draw map — no side effects, no partial writes.
routeId, stops[], and an optional origin lat/lngoptimizedStops, totalDistanceKm, and map in one responseCrew Routing (Energy & Utilities → Field & Dispatch Operations) is the one screen that calls this engine. One "Optimize Route" click per route row does the rest.