Select to view content in your preferred language

geometryEngine.intersect

2630
8
Jump to solution
07-29-2018 11:32 PM
LefterisKoumis
Frequent Contributor

I tested the geometryEngine.intersect with two polygons. One has the purple boundary and the other one has the blue fill. So, when you run the intersect the red line shows the results. If the intersect was working properly, since the blue fill polygon is inside the purple polygon, the intersect (red line) should run along the the contour of the blue fill. It seems that it follows some vertices. This is an issue since the area of the intersect will be miscalculated. Ideas? Thanks.

0 Kudos
1 Solution

Accepted Solutions
8 Replies
RobertScheitlin__GISP
MVP Emeritus

Lefteris,

   How are you getting the geometry objects that you are sending to the intersect method? It seems to me that the features are being generalized before you send them to the Intersect method. The query parameter has a maxAllowableOffset property.

https://developers.arcgis.com/javascript/3/jsapi/query-amd.html#maxallowableoffset 

LefterisKoumis
Frequent Contributor

I have two feature layers with multiple polygon features each. So, I ran each graphic geom from one layer against each graphic geom from the other layer, if it s true that there is intersection, then I store the geom and display it when it's done. How do I define the offset?

        var features = [];
        var instersect_geom=[];
        array.forEach(firstlayer.graphics, function (feature) {
          firstgraphics.push(feature.geometry)
        })

        var secondgraphics = [];
        array.forEach(secondlayer.graphics, function (feature1) {
          secondgraphics.push(feature1.geometry)
        })
        console.log(secondgraphics.length);
        for (j = 0; j < firstgraphics.length; j++) {
          for (i = 0; i < secondgraphics.length; i++) {
            if (geometryEngine.intersects(firstgraphics[j], secondgraphics[i], this.map.spatialReference)) {
              intersect_geom.push(geometryEngine.intersect(firstgraphics[j], secondgraphics[i], this.map.spatialReference))
              count++;
              console.log("true")
            }

          }
        }
        console.log(count + "      " + intersect_geom.length);
        for(k=0;k<intersect_geom.length;k++){
          var graphic = new esri.Graphic(intersect_geom[k], inter_symbol);
            console.log(graphic)
           //  gra_inter.push(graphic);
            theGraphicsLayer.add(graphic);
            
        }
        
        this.map.addLayer(theGraphicsLayer);
      },‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

So firstLayer.graphics or secondLayer.graphics are already generalized before you do the intersection.

You need to set the maxAlowableOffset for those FeatureLayers to 0.

https://developers.arcgis.com/javascript/3/jsapi/featurelayer-amd.html#maxallowableoffset 

0 Kudos
LefterisKoumis
Frequent Contributor

Thank you for the suggestion.

I added the maxAlowableOffset property, but it didn't seem to do anything.

firstlayer = new FeatureLayer("http://xxxx/MapServer/3");
        firstlayer.maxAllowableOffset=0
        secondlayer = new FeatureLayer("http://xxx/0")
        secondlayer.maxAllowableOffset=0

0 Kudos
RobertScheitlin__GISP
MVP Emeritus
0 Kudos
LefterisKoumis
Frequent Contributor

Bingo! Thank you.

0 Kudos
LefterisKoumis
Frequent Contributor

I realized that when I run the script from the developer wab on my workstation is very slow to get the results of the intersects but when it's done it displays the intersects correctly. However when I run the script from the website on the server, is very fast but the display is like the autogeneralize is off! There are only 58 features to intersect. Will the geometryservice have a better performance that geometryengine?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Geometry engine is client side so if should perform faster but it depends on the machine the browser is running on.

0 Kudos