<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Does ignoreInvalidLocations work for Non-traversable network element? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/does-ignoreinvalidlocations-work-for-non/m-p/1330503#M82255</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; When solving the route problem with ArcGIS Map SDKs for JavaScript 4.27, I got an&amp;nbsp;unexplained result. There are 3 stops on the map and the 2nd stop should be a&amp;nbsp;non-traversable network element position. However, the api returns the response with a route which curb approach is incorrect for 2nd stop.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;!DOCTYPE html lang="en"&amp;gt;
  &amp;lt;head&amp;gt;
  &amp;lt;meta charset="utf-8" /&amp;gt;
  &amp;lt;meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" /&amp;gt;
  &amp;lt;title&amp;gt;Network Invalid Location&amp;lt;/title&amp;gt;
  
  &amp;lt;style&amp;gt;
    html,
    body,
    #viewDiv { padding: 0; margin: 0; height: 100%; width: 100%; };
  &amp;lt;/style&amp;gt;
  &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/4.27/esri/themes/light/main.css"&amp;gt;
  &amp;lt;style&amp;gt;
    /* overwrite esri default css */
    .esri-view .esri-view-surface--inset-outline:focus::after {
      outline: none;
    };
  &amp;lt;/style&amp;gt;
  &amp;lt;script src="https://js.arcgis.com/4.27/"&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;script&amp;gt;
    require([
      "esri/config", "esri/intl", "esri/Map", "esri/views/MapView", "esri/geometry/Point", "esri/geometry/Polyline",
      "esri/symbols/SimpleLineSymbol", "esri/Graphic", "esri/layers/GraphicsLayer", "esri/rest/support/FeatureSet",
      "esri/symbols/PictureMarkerSymbol", "esri/rest/route", "esri/rest/support/RouteParameters"],
    function(
      esriConfig, esriIntl, Map, MapView, Point, Polyline,
      SimpleLineSymbol, Graphic, GraphicsLayer, FeatureSet,
      PictureMarkerSymbol, route, RouteParameters) {

      esriConfig.apiKey = "&amp;lt;YOUR_API_KEY&amp;gt;";

      esriIntl.setLocale("en");

      let _map, _stopLayer, _routeLayer;
      let _stop1, _stop2, _stop3;

      const CURB_APPROACH = {
        EITHER_SIDE: 0,
        RIGHT_SIDE: 1,
        LEFT_SIDE: 2,
        NO_U_TURN: 3
      };

      const initMap = () =&amp;gt;
      {
        _map = new Map({
          basemap: "arcgis-streets" // Basemap layer service
        });

        const CREEK_VIEW_PLZ = [-77.519510, 39.042121];
        const CONSTRAINT_EXTENT = {
          type: "extent",
          xmin: -180,
          ymin: -70,
          xmax: 180,
          ymax: 70
        };

        const view = new MapView({
          map: _map,
          center: CREEK_VIEW_PLZ,
          constraints: {
            geometry: CONSTRAINT_EXTENT,
            minZoom: 3,
            maxZoom: 18
          },
          zoom: 16, // Zoom level
          container: "viewDiv" // Div element
        });

        _stopLayer = new GraphicsLayer({ id: "stop-layer" });
        _routeLayer = new GraphicsLayer({ id: "route-layer" });

        _map.addMany([_routeLayer, _stopLayer]);
      };

      const stopSymbol = (sequence) =&amp;gt;
      {
        const svgString = '&amp;lt;svg xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" width="28" height="28"&amp;gt;' +
          '&amp;lt;g&amp;gt;' +
          '&amp;lt;circle r="12" cy="14" cx="14" stroke-linecap="butt" stroke="#000000" stroke-width="2" fill="#0000FF" /&amp;gt;' +
          `&amp;lt;text text-anchor="middle" font-size="12" x="50%" y="50%" dy=".3em" stroke-width="0" fill="#FFFFFF" &amp;gt;${sequence}&amp;lt;/text&amp;gt;` +
          '&amp;lt;/g&amp;gt;' +
          '&amp;lt;/svg &amp;gt;';
        const svg = `data&amp;amp;colon;image/svg+xml;charset=UTF-8;base64,${btoa(svgString)}`;
        return new PictureMarkerSymbol({ url: svg, height: 28, width: 28 });
      };

      const createStopGraphic = (location, sequence, curbApproach) =&amp;gt;
      {
        const { longitude, latitude } = location;
        const geometry = new Point({
          type: "point",
          x: longitude,
          y: latitude
        });
        const symbol = stopSymbol(sequence);
        const attributes = {
          CurbApproach: curbApproach,
          Name: sequence,
          Sequence: sequence
        };

        const graphic = new Graphic({ geometry, symbol, attributes });
        return graphic;
      };

      const addStops = () =&amp;gt;
      {
        const location1 = { longitude: -77.520401, latitude: 39.043210 };
        const location2 = { longitude: -77.5201, latitude: 39.0411 };
        const location3 = { longitude: -77.518320, latitude: 39.042180 };

        _stop1 = createStopGraphic(location1, 1, CURB_APPROACH.RIGHT_SIDE);

        // curb approach is left side. This should be a non-traversable network element position.
        _stop2 = createStopGraphic(location2, 2, CURB_APPROACH.LEFT_SIDE);
        
        _stop3 = createStopGraphic(location3, 3, CURB_APPROACH.RIGHT_SIDE);

        _stopLayer.addMany([_stop1, _stop2, _stop3]);
      };

      const calculateRoute = async () =&amp;gt;
      {
        const url = "https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World";
        const defaultParameters = {
          directionsLengthUnits: "kilometers",
          findBestSequence: false,
          ignoreInvalidLocations: false,  // expectation: get errors when there are invalid stops.
          impedanceAttribute: null,
          outputGeometryPrecision: 0,
          outputGeometryPrecisionUnits: "feet",
          outputLines: "true-shape",
          outSpatialReference: "102100",
          pointBarriers: null,
          polylineBarriers: null,
          polygonBarriers: null,
          preserveFirstStop: true,
          preserveLastStop: true,
          restrictionAttributes: [],
          restrictUTurns: "at-dead-ends-only",
          returnBarriers: false,
          returnDirections: true,
          returnPolygonBarriers: false,
          returnPolylineBarriers: false,
          returnPointBarriers: false,
          returnTraversedEdges: false,
          returnTraversedJunctions: false,
          returnTraversedTurns: false,
          returnRoutes: true,
          returnStops: true,
          returnZ: false,
          startTime: new Date()
        };

        const featureSet = new FeatureSet({ features: [_stop1, _stop2, _stop3]});
        const parameters = {
          stops: featureSet
        };

        const params = Object.assign({}, defaultParameters, parameters);
        const routeParameters = new RouteParameters(params);

        return route.solve(url, routeParameters).then((response) =&amp;gt; {
          results = response?.routeResults[0];
          return results;
        }).catch((error) =&amp;gt; {
          console.log(error);
        });
      };

      const addRoutes = (routeResults) =&amp;gt;
      {
        const route = routeResults.route;
        route.symbol = {
          type: "simple-line",
          style: "solid",
          color: "#0000FF",
          width: 5
        };

        _routeLayer.add(route);
      };


      initMap();
      addStops();

      calculateRoute().then((routeResults) =&amp;gt;
      {
        addRoutes(routeResults);
      });
  
    });
  &amp;lt;/script&amp;gt;

  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
  &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;attention: the curb approach for 2nd stop is 2 (left-side).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LeoDeng_1-1695194303689.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/81175i58F3F4209B11E2A2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LeoDeng_1-1695194303689.png" alt="LeoDeng_1-1695194303689.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;This is the result shows in ArcMap 10.8.1&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LeoDeng_0-1695193368742.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/81173iD1FA1FEF73241301/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LeoDeng_0-1695193368742.png" alt="LeoDeng_0-1695193368742.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Is there any missing parameters in solving the problem?&lt;/P&gt;&lt;P&gt;Addition Information:&lt;BR /&gt;The response from&amp;nbsp;&lt;STRONG&gt;&lt;A href="https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve" target="_blank"&gt;https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve&lt;/A&gt;&amp;nbsp;&lt;/STRONG&gt;shows the curb approach is 2 (Left side)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LeoDeng_0-1695198265630.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/81176iB00BDF46C94AC93F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LeoDeng_0-1695198265630.png" alt="LeoDeng_0-1695198265630.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Does it make sense?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Leo&lt;/P&gt;</description>
    <pubDate>Wed, 20 Sep 2023 08:26:33 GMT</pubDate>
    <dc:creator>LeoDeng</dc:creator>
    <dc:date>2023-09-20T08:26:33Z</dc:date>
    <item>
      <title>Does ignoreInvalidLocations work for Non-traversable network element?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/does-ignoreinvalidlocations-work-for-non/m-p/1330503#M82255</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; When solving the route problem with ArcGIS Map SDKs for JavaScript 4.27, I got an&amp;nbsp;unexplained result. There are 3 stops on the map and the 2nd stop should be a&amp;nbsp;non-traversable network element position. However, the api returns the response with a route which curb approach is incorrect for 2nd stop.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;!DOCTYPE html lang="en"&amp;gt;
  &amp;lt;head&amp;gt;
  &amp;lt;meta charset="utf-8" /&amp;gt;
  &amp;lt;meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" /&amp;gt;
  &amp;lt;title&amp;gt;Network Invalid Location&amp;lt;/title&amp;gt;
  
  &amp;lt;style&amp;gt;
    html,
    body,
    #viewDiv { padding: 0; margin: 0; height: 100%; width: 100%; };
  &amp;lt;/style&amp;gt;
  &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/4.27/esri/themes/light/main.css"&amp;gt;
  &amp;lt;style&amp;gt;
    /* overwrite esri default css */
    .esri-view .esri-view-surface--inset-outline:focus::after {
      outline: none;
    };
  &amp;lt;/style&amp;gt;
  &amp;lt;script src="https://js.arcgis.com/4.27/"&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;script&amp;gt;
    require([
      "esri/config", "esri/intl", "esri/Map", "esri/views/MapView", "esri/geometry/Point", "esri/geometry/Polyline",
      "esri/symbols/SimpleLineSymbol", "esri/Graphic", "esri/layers/GraphicsLayer", "esri/rest/support/FeatureSet",
      "esri/symbols/PictureMarkerSymbol", "esri/rest/route", "esri/rest/support/RouteParameters"],
    function(
      esriConfig, esriIntl, Map, MapView, Point, Polyline,
      SimpleLineSymbol, Graphic, GraphicsLayer, FeatureSet,
      PictureMarkerSymbol, route, RouteParameters) {

      esriConfig.apiKey = "&amp;lt;YOUR_API_KEY&amp;gt;";

      esriIntl.setLocale("en");

      let _map, _stopLayer, _routeLayer;
      let _stop1, _stop2, _stop3;

      const CURB_APPROACH = {
        EITHER_SIDE: 0,
        RIGHT_SIDE: 1,
        LEFT_SIDE: 2,
        NO_U_TURN: 3
      };

      const initMap = () =&amp;gt;
      {
        _map = new Map({
          basemap: "arcgis-streets" // Basemap layer service
        });

        const CREEK_VIEW_PLZ = [-77.519510, 39.042121];
        const CONSTRAINT_EXTENT = {
          type: "extent",
          xmin: -180,
          ymin: -70,
          xmax: 180,
          ymax: 70
        };

        const view = new MapView({
          map: _map,
          center: CREEK_VIEW_PLZ,
          constraints: {
            geometry: CONSTRAINT_EXTENT,
            minZoom: 3,
            maxZoom: 18
          },
          zoom: 16, // Zoom level
          container: "viewDiv" // Div element
        });

        _stopLayer = new GraphicsLayer({ id: "stop-layer" });
        _routeLayer = new GraphicsLayer({ id: "route-layer" });

        _map.addMany([_routeLayer, _stopLayer]);
      };

      const stopSymbol = (sequence) =&amp;gt;
      {
        const svgString = '&amp;lt;svg xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" width="28" height="28"&amp;gt;' +
          '&amp;lt;g&amp;gt;' +
          '&amp;lt;circle r="12" cy="14" cx="14" stroke-linecap="butt" stroke="#000000" stroke-width="2" fill="#0000FF" /&amp;gt;' +
          `&amp;lt;text text-anchor="middle" font-size="12" x="50%" y="50%" dy=".3em" stroke-width="0" fill="#FFFFFF" &amp;gt;${sequence}&amp;lt;/text&amp;gt;` +
          '&amp;lt;/g&amp;gt;' +
          '&amp;lt;/svg &amp;gt;';
        const svg = `data&amp;amp;colon;image/svg+xml;charset=UTF-8;base64,${btoa(svgString)}`;
        return new PictureMarkerSymbol({ url: svg, height: 28, width: 28 });
      };

      const createStopGraphic = (location, sequence, curbApproach) =&amp;gt;
      {
        const { longitude, latitude } = location;
        const geometry = new Point({
          type: "point",
          x: longitude,
          y: latitude
        });
        const symbol = stopSymbol(sequence);
        const attributes = {
          CurbApproach: curbApproach,
          Name: sequence,
          Sequence: sequence
        };

        const graphic = new Graphic({ geometry, symbol, attributes });
        return graphic;
      };

      const addStops = () =&amp;gt;
      {
        const location1 = { longitude: -77.520401, latitude: 39.043210 };
        const location2 = { longitude: -77.5201, latitude: 39.0411 };
        const location3 = { longitude: -77.518320, latitude: 39.042180 };

        _stop1 = createStopGraphic(location1, 1, CURB_APPROACH.RIGHT_SIDE);

        // curb approach is left side. This should be a non-traversable network element position.
        _stop2 = createStopGraphic(location2, 2, CURB_APPROACH.LEFT_SIDE);
        
        _stop3 = createStopGraphic(location3, 3, CURB_APPROACH.RIGHT_SIDE);

        _stopLayer.addMany([_stop1, _stop2, _stop3]);
      };

      const calculateRoute = async () =&amp;gt;
      {
        const url = "https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World";
        const defaultParameters = {
          directionsLengthUnits: "kilometers",
          findBestSequence: false,
          ignoreInvalidLocations: false,  // expectation: get errors when there are invalid stops.
          impedanceAttribute: null,
          outputGeometryPrecision: 0,
          outputGeometryPrecisionUnits: "feet",
          outputLines: "true-shape",
          outSpatialReference: "102100",
          pointBarriers: null,
          polylineBarriers: null,
          polygonBarriers: null,
          preserveFirstStop: true,
          preserveLastStop: true,
          restrictionAttributes: [],
          restrictUTurns: "at-dead-ends-only",
          returnBarriers: false,
          returnDirections: true,
          returnPolygonBarriers: false,
          returnPolylineBarriers: false,
          returnPointBarriers: false,
          returnTraversedEdges: false,
          returnTraversedJunctions: false,
          returnTraversedTurns: false,
          returnRoutes: true,
          returnStops: true,
          returnZ: false,
          startTime: new Date()
        };

        const featureSet = new FeatureSet({ features: [_stop1, _stop2, _stop3]});
        const parameters = {
          stops: featureSet
        };

        const params = Object.assign({}, defaultParameters, parameters);
        const routeParameters = new RouteParameters(params);

        return route.solve(url, routeParameters).then((response) =&amp;gt; {
          results = response?.routeResults[0];
          return results;
        }).catch((error) =&amp;gt; {
          console.log(error);
        });
      };

      const addRoutes = (routeResults) =&amp;gt;
      {
        const route = routeResults.route;
        route.symbol = {
          type: "simple-line",
          style: "solid",
          color: "#0000FF",
          width: 5
        };

        _routeLayer.add(route);
      };


      initMap();
      addStops();

      calculateRoute().then((routeResults) =&amp;gt;
      {
        addRoutes(routeResults);
      });
  
    });
  &amp;lt;/script&amp;gt;

  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
  &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;attention: the curb approach for 2nd stop is 2 (left-side).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LeoDeng_1-1695194303689.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/81175i58F3F4209B11E2A2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LeoDeng_1-1695194303689.png" alt="LeoDeng_1-1695194303689.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;This is the result shows in ArcMap 10.8.1&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LeoDeng_0-1695193368742.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/81173iD1FA1FEF73241301/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LeoDeng_0-1695193368742.png" alt="LeoDeng_0-1695193368742.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Is there any missing parameters in solving the problem?&lt;/P&gt;&lt;P&gt;Addition Information:&lt;BR /&gt;The response from&amp;nbsp;&lt;STRONG&gt;&lt;A href="https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve" target="_blank"&gt;https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve&lt;/A&gt;&amp;nbsp;&lt;/STRONG&gt;shows the curb approach is 2 (Left side)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LeoDeng_0-1695198265630.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/81176iB00BDF46C94AC93F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LeoDeng_0-1695198265630.png" alt="LeoDeng_0-1695198265630.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Does it make sense?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Leo&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2023 08:26:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/does-ignoreinvalidlocations-work-for-non/m-p/1330503#M82255</guid>
      <dc:creator>LeoDeng</dc:creator>
      <dc:date>2023-09-20T08:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: Does ignoreInvalidLocations work for Non-traversable network element?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/does-ignoreinvalidlocations-work-for-non/m-p/1334481#M82381</link>
      <description>&lt;P&gt;Is there any information for this issue?&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2023 12:25:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/does-ignoreinvalidlocations-work-for-non/m-p/1334481#M82381</guid>
      <dc:creator>LeoDeng</dc:creator>
      <dc:date>2023-10-03T12:25:37Z</dc:date>
    </item>
  </channel>
</rss>

