/// <summary> /// /// </summary> /// <param name="p"></param> /// <param name="geom"></param> /// <returns></returns> private static bool ContainsPoint(Coordinate p, IGeometry geom) { if(geom is Polygon) return ContainsPointInPolygon(p, (Polygon)geom); else if(geom is GeometryCollection) { IEnumerator geomi = new GeometryCollectionEnumerator((GeometryCollection)geom); while(geomi.MoveNext()) { Geometry g2 = (Geometry)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> /// <param name="p"></param> /// <param name="geom"></param> private void ComputeLocation(Coordinate p, IGeometry geom) { if(geom is ILineString) UpdateLocationInfo(Locate(p, (ILineString)geom)); else if(geom is IPolygon) 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); } } }