Select to view content in your preferred language

Draw Polygon between longitude ranges error

937
3
Jump to solution
02-10-2022 01:48 AM
ialixandroae
New Contributor

I have a problem with creating and drawing a polygon geometry that is located between the longitude margins (basically starts from East of Japan and ends in Alaska)

 

The way the API is drawing the polygon is basically in the reverse order.

I used the SketchViewModel to draw the desired polygon on a map (see print screen below), and  I got the rings in long, lat coordinates as:

[
[
150.50951046729438,
83.60281202131557
],
[
-151.3277526400206,
83.90137770480938
],
[
-147.58991198755575,
-83.28282929241126
],
[
-151.7627425692197,
-84.13966376019715
],
[
177.9052071073019,
-83.43080587654312
],
[
154.09088177466649,
-83.43080587654312
],
[
137.0340923764776,
-80.80424221760879
],
[
146.74253029609173,
-33.83792786815416
],
[
150.50951046729438,
83.60281202131557
]
]

Screen Shot 2022-02-10 at 10.45.03.png

 

If then I use the same rings to create a polygon geometry, add it to a graphic layer and plot the layer in the map, the entire map is filled besides the original shape

Screen Shot 2022-02-10 at 10.46.42.png



Isn't the API able to draw the polygon in between the longitudes margins (+180/-180) or is this a bug with the coordinates order?

Thanks!

0 Kudos
1 Solution

Accepted Solutions
ialixandroae
New Contributor

Oh, I see. That's interesting.

Other APIs do that automatically for you, you just put in the coordinates and that's it.

Your answer helped me find these examples: https://codepen.io/andygup/pen/QeyerP  and https://community.esri.com/t5/arcgis-api-for-javascript-questions/polyline-not-crossing-the-internat... (https://jsbin.com/xegicih/2/edit?html,output ), and it seems that getting a new geometry using geodesicUtils.geodesicDensify() + normalizeUtils.normalizeCentralMeridian() does the trick.

 

Thanks!

View solution in original post

0 Kudos
3 Replies
DanPatterson
MVP Esteemed Contributor

You have to correct for the traversal of the dateline, then it should be fixed when defining the coordinate system.  You can't from -150 to +150 without going through 0, hence make -150, -210 or +150 into +210 the delta being the appropriate difference from +/-180

Solved: Programmatically creating polygon from points on b... - Esri Community

 


... sort of retired...
ialixandroae
New Contributor

Oh, I see. That's interesting.

Other APIs do that automatically for you, you just put in the coordinates and that's it.

Your answer helped me find these examples: https://codepen.io/andygup/pen/QeyerP  and https://community.esri.com/t5/arcgis-api-for-javascript-questions/polyline-not-crossing-the-internat... (https://jsbin.com/xegicih/2/edit?html,output ), and it seems that getting a new geometry using geodesicUtils.geodesicDensify() + normalizeUtils.normalizeCentralMeridian() does the trick.

 

Thanks!

0 Kudos
DanPatterson
MVP Esteemed Contributor

One of the downside of things  "automagically" happening... the helpers that get the job done are often forgotten 😉


... sort of retired...
0 Kudos