Is it customary to require GeometryService.simplify() when using New Circle ? Why would geometry of New Circle require "correcting" ?
I have an array of features returned from executeQuery. In a loop I test an attribute and then either push the original geometry into an array or push a New Circle() into that array. When done I invoke GeometryService.union(array)
and add that to my graphics layer. The result looks odd as though some circles are cut out of some original polygons or original polygons are cut out of circles. With desperation, I tried
geometryArray.push(
GeometryService.simplify(
New Circle(features.geometry.getExtent().getCenter,{"radius":150,"numberOfPoints":8})
))
and then GeometryService.union returned results I had originally expected.
Solved! Go to Solution.
Thanks again, Robert.
Based on your response I added test code to my loop:
var c = new Circle( featuresArray.geometry.getExtent().getCenter(),{"radius":250,"numberOfPoints":8});
console.log( "c.isClockwise(c.rings[0])= " + c.isClockwise(c.rings[0]) );
and sure enough, all the circle rings[0] show false; New Circle makes a hole. I did not see this behavior in the documentation for New Circle.
Good health!
Blair
Blair,
The only thing I can think of is if a polygons ring orientation is counter-clockwise the the union will subtract the geometry that has a counter-clockwise ring orientation from the clockwise one(s). The simplify makes sure that all ring orientations are clockwise.
Thanks Robert,
There is no mention in the documentation for a parameter that controls ring direction. Just another API quirk that takes hours of time to figure out. At least by adding "simplify" my code works the way I want. Seems odd that New Circle would not always create a "forward" ring.
Blair,
it is actually documented:
Polygon | API Reference | ArcGIS API for JavaScript 3.17 | addRing
add points counter-clockwise to create a hole
and there is the isClockwise method:
Polygon | API Reference | ArcGIS API for JavaScript 3.17 | isClockwise
It could be that your other polygon is counter clockwise and not the circle.
Thanks again, Robert.
Based on your response I added test code to my loop:
var c = new Circle( featuresArray.geometry.getExtent().getCenter(),{"radius":250,"numberOfPoints":8});
console.log( "c.isClockwise(c.rings[0])= " + c.isClockwise(c.rings[0]) );
and sure enough, all the circle rings[0] show false; New Circle makes a hole. I did not see this behavior in the documentation for New Circle.
Good health!
Blair
Blair,
Don't forget to mark this question as answered by clicking on the "Correct Answer" link on the reply that answered your question.