/// <summary> /// /// </summary> /// <param name="p"></param> /// <param name="geom"></param> /// <returns></returns> private static bool ContainsPoint(ICoordinate p, IGeometry geom) { if (geom is IPolygon) return ContainsPointInPolygon(p, (IPolygon) geom); else if(geom is IGeometryCollection) { IEnumerator geomi = new GeometryCollectionEnumerator((IGeometryCollection) geom); while (geomi.MoveNext()) { IGeometry g2 = (IGeometry) geomi.Current; // if(g2 != geom) --- Diego Guidi say's: Java code tests reference equality: in C# with operator overloads we tests the object.equals()... more slower! if (!Object.ReferenceEquals(g2, geom)) if (ContainsPoint(p, g2)) return true; } } return false; }
/// <summary> /// /// </summary> /// <returns></returns> public bool MoveNext() { if (atStart) return true; if (subcollectionEnumerator != null) { if (subcollectionEnumerator.MoveNext()) return true; subcollectionEnumerator = null; } if (index >= max) return false; return true; }
/// <summary> /// /// </summary> /// <param name="p"></param> /// <param name="geom"></param> private void ComputeLocation(ICoordinate p, IGeometry geom) { if (geom is ILineString) UpdateLocationInfo(Locate(p, (ILineString) geom)); else if(geom is Polygon) UpdateLocationInfo(Locate(p, (IPolygon) geom)); else if(geom is IMultiLineString) { IMultiLineString ml = (IMultiLineString) geom; foreach (ILineString l in ml.Geometries) UpdateLocationInfo(Locate(p, l)); } else if(geom is IMultiPolygon) { IMultiPolygon mpoly = (IMultiPolygon) geom; foreach (IPolygon poly in mpoly.Geometries) UpdateLocationInfo(Locate(p, poly)); } else if (geom is IGeometryCollection) { IEnumerator geomi = new GeometryCollectionEnumerator((IGeometryCollection) geom); while(geomi.MoveNext()) { IGeometry g2 = (IGeometry) geomi.Current; if (g2 != geom) ComputeLocation(p, g2); } } }