Select to view content in your preferred language

Using esri.tasks.geometry to get a polygon with holes and a set of points

2023
4
Jump to solution
06-11-2012 08:21 AM
NaderChouman
Deactivated User
The idea is simple. Given a hollow polygon as geometry A and an array of point geometries, we would like to figure out the proper intersection between the two. Below is the code used:


var geometryService = new esri.tasks.GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
var relationParams = new esri.tasks.RelationParameters();

relationParams.geometries1 = [hollowPolygonGeom];
relationParams.geometries2 = [point1geom, point2geom, ..., pointXgeom];
relationParams.relation = esri.tasks.RelationParameters.SPATIAL_REL_WITHIN;

geometryService.relation(relationParams, onSuccess, onErr);

The results returned by the service include the intersection between the "hollow" are of the polygon and the points. We also noticed that the orientation of the inner ring (the hollow shape) affects the returned results. Either way, the results are not what we wanted. Is this behavior expected? What are we missing? Is there another way to get the results we need?

Thanks in advance!
0 Kudos
1 Solution

Accepted Solutions
NaderChouman
Deactivated User
Heming,

Using esri.geometry.isClockwise, we validate and adjust the geometry to be a proper hollow polygon: the outer ring(s) intended to be included are clockwise and the inner rings intended to be excluded are counter clockwise. Sending a polygon with properly oriented rings to the geometry service returned the expected results. Thanks for your help!

View solution in original post

0 Kudos
4 Replies
HemingZhu
Frequent Contributor
The idea is simple. Given a hollow polygon as geometry A and an array of point geometries, we would like to figure out the proper intersection between the two. Below is the code used:


var geometryService = new esri.tasks.GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
var relationParams = new esri.tasks.RelationParameters();

relationParams.geometries1 = [hollowPolygonGeom];
relationParams.geometries2 = [point1geom, point2geom, ..., pointXgeom];
relationParams.relation = esri.tasks.RelationParameters.SPATIAL_REL_WITHIN;

geometryService.relation(relationParams, onSuccess, onErr);

The results returned by the service include the intersection between the "hollow" are of the polygon and the points. We also noticed that the orientation of the inner ring (the hollow shape) affects the returned results. Either way, the results are not what we wanted. Is this behavior expected? What are we missing? Is there another way to get the results we need?

Thanks in advance!


In ArcObjects, counter clockwise ring is an interor ring -hollow. In JSAP, you could use esri.geometry.isClockwise(ring) to validate if it is a hollow ring (hole). It is useful when you do intersection. For example, if the hollow ring contains the array of the points, then the polygon is not intersect with the points !!
0 Kudos
NaderChouman
Deactivated User
Thanks for the prompt response. Regarding what the geometry service (called using esri.tasks.GeometryService) should return: if passed a single geometry with the proper inner ring orientation (1st input) and an array of geometries (2nd input), the returned result is NOT expected to exclude the points that appear within the hollow area? It would be great if we can get some sample code that returns the proper intersection result instead of excessive validation and proceesing client-side to do the same.
0 Kudos
HemingZhu
Frequent Contributor
Thanks for the prompt response. Regarding what the geometry service (called using esri.tasks.GeometryService) should return: if passed a single geometry with the proper inner ring orientation (1st input) and an array of geometries (2nd input), the returned result is NOT expected to exclude the points that appear within the hollow area? It would be great if we can get some sample code that returns the proper intersection result instead of excessive validation and proceesing client-side to do the same.


what you can do is create a geometry out of the interior ring and do the interaction with the point...
0 Kudos
NaderChouman
Deactivated User
Heming,

Using esri.geometry.isClockwise, we validate and adjust the geometry to be a proper hollow polygon: the outer ring(s) intended to be included are clockwise and the inner rings intended to be excluded are counter clockwise. Sending a polygon with properly oriented rings to the geometry service returned the expected results. Thanks for your help!
0 Kudos