Extent.contains(geometry) Issue

1873
5
06-25-2013 11:16 AM
tonylife
New Contributor III
I have a case one big polygon includes a polyline, but the code extent.contains(geometry) returns false.
I checked Xmin, Xmax, Ymin, Ymax for both object. polyline is inside of the polygon.
I do notice that the polygon's Spatial Reference wkid is 102100, the polyline has two SR, wkid 102100 and latestwkid 3857.
Does extent.contains(geometry) check the SR?
If so, what should I do for the case?

Thanks,
Tony
0 Kudos
5 Replies
JeffJacobson
Occasional Contributor III
The IDs 102100 and 3857 both represent the same spatial reference: WGS84 Web Mercator (Auxiliary Sphere), so it would seem unlikely that the cause of the issue is due to a spatial reference system mismatch.
0 Kudos
tonylife
New Contributor III
The IDs 102100 and 3857 both represent the same spatial reference: WGS84 Web Mercator (Auxiliary Sphere), so it would seem unlikely that the cause of the issue is due to a spatial reference system mismatch.


The polygon geometry (xmin -9789042, xmax -9788311, ymin 5311122, ymax 5311413)
The polyline geometry (xmin -9788713, xmax -9788712, ymin 5311291, ymax 5311317)
It seems to me polyline is inside of polygon, am I missing somthing?

Thanks,
Tony
0 Kudos
derekswingley1
Frequent Contributor
esri/geometry/Extent::contains take a point or extent. Per the docs:


Input Parameters:
<Geometry> geometry Required Can be a Point or Extent.


https://developers.arcgis.com/en/javascript/jsapi/extent.html#contains

You could use the extent of your line but not the line itself.
0 Kudos
JeffJacobson
Occasional Contributor III
esri/geometry/Extent::contains take a point or extent. Per the docs:



https://developers.arcgis.com/en/javascript/jsapi/extent.html#contains

You could use the extent of your line but not the line itself.


Does this work?


  • Loop through each point in the polyline and check to see if it is contained in the extent.


    • If one of the points is outside of the extent, you can break out of the loop. You know the answer is false.

    • If all of the points are contained in the extent, then the answer is true.


0 Kudos
tonylife
New Contributor III
esri/geometry/Extent::contains take a point or extent. Per the docs:



https://developers.arcgis.com/en/javascript/jsapi/extent.html#contains

You could use the extent of your line but not the line itself.


Thanks for your information.

I do try the following area._extent.contains(graphic.geometry._extent).
The area's extent is xmin: -9788742, ymin: 5311210, xmax: -9788670, ymax: 5311361
The graphic is a polyline, it's extent is  xmin: -9788713, ymin: 5311291, xmax: -9788712, ymax: 5311317
The result is still FALSE. not sure why

Thanks,
Tony
0 Kudos