GeometryEngine value does not fall within the expected range

1278
3
Jump to solution
06-27-2018 08:06 AM
MarkCederholm
Occasional Contributor III

UPDATE: I was able to create a project that duplicates the problem [attached].  GeometryEngine at 100.2 has a problem which 10.2.7 doesn't have.  I have two different geometries with the same spatial reference, yet hydrated from different sources (one from the map, one from a feature layer).  If I try to to perform an operation such as Contains or Disjoint, I get the error "Value does not fall within the expected range".  If I project one geometry to the other's SR then the operation works fine.  The SR is defined by a WkText, and the WkText of both SRs is identical.  Has anyone else seen this?

0 Kudos
1 Solution

Accepted Solutions
JenniferNery
Esri Regular Contributor

Thank you for sharing your data and code. I'm able to reproduce the issue. SpatialReference.Equals should have been true regardless of z-value and GeometryEngine.RemoveZAndM should have been enough to clear feature geometry of z to allow GeometryEngine.Contains to work. However, SpatialReference.Equals still fail, although the wkt string matched. I have logged an issue for this. 


Meanwhile, you can use the following workaround before calling GeometryEngine.Contains or SpatialReference.Equals.

geomFeat = GeometryEngine.RemoveZAndM(geomFeat);
geomFeat = Geometry.FromJson(geomFeat.ToJson());

View solution in original post

0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor

Thank you for sharing your data and code. I'm able to reproduce the issue. SpatialReference.Equals should have been true regardless of z-value and GeometryEngine.RemoveZAndM should have been enough to clear feature geometry of z to allow GeometryEngine.Contains to work. However, SpatialReference.Equals still fail, although the wkt string matched. I have logged an issue for this. 


Meanwhile, you can use the following workaround before calling GeometryEngine.Contains or SpatialReference.Equals.

geomFeat = GeometryEngine.RemoveZAndM(geomFeat);
geomFeat = Geometry.FromJson(geomFeat.ToJson());
0 Kudos
MarkCederholm
Occasional Contributor III

This issue appears to be fixed at 100.7.

0 Kudos
MarkCederholm
Occasional Contributor III

Looks like the issue has reappeared at 100.12.0 -- now the error message is

"Invalid argument: geometry1 and geometry2 must have equivalent spatial references."

Fortunately, I've kept my workaround code.

UPDATE: I can't duplicate the error using the sample project above, so something else must be going on.

0 Kudos