How to implement 'return to start' for routing problem?

496
1
08-02-2017 02:01 AM
LeoDeng
Occasional Contributor II

Environment:

ArcGIS Server 10.4.1.

ArcGIS JavaScript API 3.21.

In first case, a) I create 3 stops and request a route analysis. To make the route 'return to start', b) I append the first stop to the last and request again. The result shows that the route geometry vertices (begin point) is difference for the two cases (a and b).

How to make it same ?

------------------------------------------------------------------------------

Test data and results:

For route analysis, I get 3 stops with address:

1) 1865 W Chase St, Pensacola, Florida, 32502

2) 112 N J St, Pensacola, Florida, 32502

3) 1620 W Gregory St, Pensacola, Florida, 32502

The Curb Approach is Right Side and U-turn policy is ALLOW_BACKTRACK

The stops used in REST API parameters is 

{
  "features": [
    {
      "geometry": {
        "type": "point",
        "x": -87.23800305981302,
        "y": 30.413010532315898,
        "spatialReference": {
          "wkid": 4326
        }
      },
      "symbol": null,
      "attributes": {
        "Sequence": 1,
        "Name": "1865 W Chase St, Pensacola, Florida, 32502",
        "CurbApproach": 1
      }
    },
    {
      "geometry": {
        "type": "point",
        "x": -87.2360596698311,
        "y": 30.413493188729877,
        "spatialReference": {
          "wkid": 4326
        }
      },
      "symbol": null,
      "attributes": {
        "Sequence": 2,
        "Name": "112 N J St, Pensacola, Florida, 32502",
        "CurbApproach": 1
      }
    },
    {
      "geometry": {
        "type": "point",
        "x": -87.23703175714124,
        "y": 30.414276511541182,
        "spatialReference": {
          "wkid": 4326
        }
      },
      "symbol": null,
      "attributes": {
        "Sequence": 3,
        "Name": "1620 W Gregory St, Pensacola, Florida, 32502",
        "CurbApproach": 1
      }
    }
  ]
}

And the route analysis result is

{
 "messages": [],
 "routes": {
  "fieldAliases": {
   "ObjectID": "ObjectID",
   "Name": "Name",
   "FirstStopID": "FirstStopID",
   "LastStopID": "LastStopID",
   "StopCount": "StopCount",
   "Total_TravelTime": "Total_TravelTime",
   "StartTime": "StartTime",
   "EndTime": "EndTime",
   "Shape_Length": "Shape_Length"
  },
  "geometryType": "esriGeometryPolyline",
  "spatialReference": {
   "wkid": 4326,
   "latestWkid": 4326
  },
  "features": [{
   "attributes": {
    "ObjectID": 1,
    "Name": "1865 W Chase St, Pensacola, Florida, 32502 - 1620 W Gregory St, Pensacola, Florida, 32502",
    "FirstStopID": 1,
    "LastStopID": 3,
    "StopCount": 3,
    "Total_TravelTime": 0.9289405265924089,
    "StartTime": 0,
    "EndTime": 55736,
    "Shape_Length": 0.00414338501260787
   },
   "geometry": {"paths": [[
    [
     -87.23800182899998,
     30.413034469000024
    ],
    [
     -87.23724419999996,
     30.41299550000008
    ],
    [
     -87.23648799999995,
     30.412951000000078
    ],
    [
     -87.23613939999996,
     30.412940400000025
    ],
    [
     -87.23608623399997,
     30.413495732000058
    ],
    [
     -87.23601899999994,
     30.414198000000056
    ],
    [
     -87.23703326899994,
     30.414239919000067
    ]
   ]]}
  }]
 }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Then I tried to make the route 'return to first stop' by add the last stop same as first stop.

I pass the stop parameters as:

{
  "features": [
    {
      "geometry": {
        "type": "point",
        "x": -87.23800305981302,
        "y": 30.413010532315898,
        "spatialReference": {
          "wkid": 4326
        }
      },
      "symbol": null,
      "attributes": {
        "Sequence": 1,
        "Name": "1865 W Chase St, Pensacola, Florida, 32502",
        "CurbApproach": 1
      }
    },
    {
      "geometry": {
        "type": "point",
        "x": -87.2360596698311,
        "y": 30.413493188729877,
        "spatialReference": {
          "wkid": 4326
        }
      },
      "symbol": null,
      "attributes": {
        "Sequence": 2,
        "Name": "112 N J St, Pensacola, Florida, 32502",
        "CurbApproach": 1
      }
    },
    {
      "geometry": {
        "type": "point",
        "x": -87.23703175714124,
        "y": 30.414276511541182,
        "spatialReference": {
          "wkid": 4326
        }
      },
      "symbol": null,
      "attributes": {
        "Sequence": 3,
        "Name": "1620 W Gregory St, Pensacola, Florida, 32502",
        "CurbApproach": 1
      }
    },
    {
      "geometry": {
        "type": "point",
        "x": -87.23800305981302,
        "y": 30.413010532315898,
        "spatialReference": {
          "wkid": 4326
        }
      },
      "symbol": null,
      "attributes": {
        "Sequence": 4,
        "Name": "1865 W Chase St, Pensacola, Florida, 32502",
        "CurbApproach": 1
      }
    }
  ]
}

However, the result geometry (polyline) is not start at first stop (-87.23800182899998, 30.413034469000024)!

{
 "messages": [],
 "routes": {
  "fieldAliases": {
   "ObjectID": "ObjectID",
   "Name": "Name",
   "FirstStopID": "FirstStopID",
   "LastStopID": "LastStopID",
   "StopCount": "StopCount",
   "Total_TravelTime": "Total_TravelTime",
   "StartTime": "StartTime",
   "EndTime": "EndTime",
   "Shape_Length": "Shape_Length"
  },
  "geometryType": "esriGeometryPolyline",
  "spatialReference": {
   "wkid": 4326,
   "latestWkid": 4326
  },
  "features": [{
   "attributes": {
    "ObjectID": 1,
    "Name": "1865 W Chase St, Pensacola, Florida, 32502 - 1865 W Chase St, Pensacola, Florida, 32502",
    "FirstStopID": 1,
    "LastStopID": 4,
    "StopCount": 4,
    "Total_TravelTime": 1.517613758327038,
    "StartTime": 0,
    "EndTime": 91057,
    "Shape_Length": 0.006975291053161718
   },
   "geometry": {"paths": [[
    [
     -87.23608623399997,
     30.413495732000058
    ],
    [
     -87.23601899999994,
     30.414198000000056
    ],
    [
     -87.23703326899994,
     30.414239919000067
    ],
    [
     -87.23713199999997,
     30.414244000000053
    ],
    [
     -87.23825899999997,
     30.414293000000043
    ],
    [
     -87.23836209999996,
     30.413053000000048
    ],
    [
     -87.23800182899998,
     30.413034469000024
    ],
    [
     -87.23724419999996,
     30.41299550000008
    ],
    [
     -87.23648799999995,
     30.412951000000078
    ],
    [
     -87.23613939999996,
     30.412940400000025
    ],
    [
     -87.23608623399997,
     30.413495732000058
    ]
   ]]}
  }]
 }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

What's wrong with the server result?

0 Kudos
1 Reply
LeoDeng
Occasional Contributor II

I tried the cases with arcmap, the route geometry also changed in 'return to first'.

Please take a look at How to make 'return to first stop' with route analysis in arcmap?  for details.

0 Kudos