Select to view content in your preferred language

Polygon isSelfIntersecting

2965
2
Jump to solution
12-17-2013 05:07 AM
AxelSchaefer
Emerging Contributor
Hi.

I'm working on a redlining function, where I want to check if the polygon is selfIntersecting. I check the geometry, but it says that it's always self-intersecting, even if it isn't.

The code is really simple. Here are the snippets.

        initDraw: function() {             this._tb = new Draw(this.map);              // I DRAW A POLYGON             this._tb.activate(Draw.POLYGON);              this._tb.on("draw-end", lang.hitch(this, this.addToMap));          },          addToMap: function(evt) {             // some stuff              this._tb.deactivate();              var symbol = new SimpleFillSymbol(config.geometryStyles.geofencePolygon);              // MY GEOMETRY == MY POLYGON             var geometry = evt.geometry;              var graphic = new Graphic(geometry, symbol);             this.geofenceGraphicsLayer.add(graphic);              // MY CHECK. Is always alerting, shouldn't do that. :(             if (geometry.isSelfIntersecting) {                 alert("Is Self Intersecting");             } else {                 // do something...             }         },



This is the polygon as JSON that I send to the console. It's a simple triangle.

{"type":"polygon","rings":[[[2343355.197916185,6843378.9380211625],[2343591.077808191,6843221.286650303],[2343284.7325307247,6843149.029771992],[2343355.197916185,6843378.9380211625]]],"_ring":0,"spatialReference":{"wkid":102100},"_centroid":null,"_extent":{"xmin":2343284.7325307247,"ymin":6843149.029771992,"xmax":2343591.077808191,"ymax":6843378.9380211625,"spatialReference":{"wkid":102100}},"_partwise":null}


What's wrong with the check? Why is "isSelfIntersecting" always true, even if I draw some simple polygon?

The geometry seems to be a Polygon. Firebug says:
- declaredClass: "esri.geometry.Polygon"
- type: "polygon"

Does the method not work on a drawn geometry? Am I missing something?

System: JS-API 3.7, Firefox 25.0 with Firebug.

I appreciate any help. Thanks in advance.
Axel
0 Kudos
1 Solution

Accepted Solutions
JianHuang
Deactivated User
Cannot reproduce the issue.
I tried exact same polygon you had:
var polygon = new esri.geometry.Polygon({"type":"polygon","rings":[[[2343355.197916185,6843378.9380211625],[2343591.077808191,6843221.286650303],[2343284.7325307247,6843149.029771992],[2343355.197916185,6843378.9380211625]]],"_ring":0,"spatialReference":{"wkid":102100},"_centroid":null,"_extent":{"xmin":2343284.7325307247,"ymin":6843149.029771992,"xmax":2343591.077808191,"ymax":6843378.9380211625,"spatialReference":{"wkid":102100}},"_partwise":null}); polygon.isSelfIntersecting();//returns false;

I noticed you missed the parentheses at the end of the function isSelfIntersecting(), which means it checks if the function exists or not. If so, it returns the code of the function.

View solution in original post

0 Kudos
2 Replies
JianHuang
Deactivated User
Cannot reproduce the issue.
I tried exact same polygon you had:
var polygon = new esri.geometry.Polygon({"type":"polygon","rings":[[[2343355.197916185,6843378.9380211625],[2343591.077808191,6843221.286650303],[2343284.7325307247,6843149.029771992],[2343355.197916185,6843378.9380211625]]],"_ring":0,"spatialReference":{"wkid":102100},"_centroid":null,"_extent":{"xmin":2343284.7325307247,"ymin":6843149.029771992,"xmax":2343591.077808191,"ymax":6843378.9380211625,"spatialReference":{"wkid":102100}},"_partwise":null}); polygon.isSelfIntersecting();//returns false;

I noticed you missed the parentheses at the end of the function isSelfIntersecting(), which means it checks if the function exists or not. If so, it returns the code of the function.
0 Kudos
AxelSchaefer
Emerging Contributor
I noticed you missed the parentheses at the end of the function isSelfIntersecting(), which means it checks if the function exists or not. If so, it returns the code of the function.


Yeah, that's it.

I missed the parantheses. Doh! I send a comment to js_feedback, because it's also without the parantheses the API-documentation and I simply copy&pasted the code-snippet. 🙂

Thank you very much for your quick and valueable reply.

Axel
0 Kudos