} // private int Locate( Coordinate p, LinearRing ring ) private int Locate( Coordinate p, Polygon poly ) { if ( poly.IsEmpty() ) { return Location.Exterior; } LinearRing shell = (LinearRing) poly.GetExteriorRing(); int shellLoc = Locate( p, shell ); if ( shellLoc == Location.Exterior ) { return Location.Exterior; } if ( shellLoc == Location.Boundary ) { return Location.Boundary; } // now test if the point lies in or on the holes for ( int i = 0; i < poly.GetNumInteriorRing(); i++ ) { int holeLoc = Locate( p, poly.GetInteriorRingN( i ) ); if ( holeLoc == Location.Interior ) { return Location.Exterior; } if ( holeLoc == Location.Boundary ) { return Location.Boundary; } } // for ( int i = 0; i < poly.NumInteriorRings; i++ ) return Location.Interior; } // private int Locate( Coordinate p, Polygon poly )
/// <summary> /// Converts a Polygon to <Polygon Text> format, then /// Appends it to the writer. /// </summary> /// <param name="polygon">The Polygon to process.</param> /// <param name="level"></param> /// <param name="indentFirst"></param> /// <param name="writer"></param> protected void AppendPolygonText(Polygon polygon, int level, bool indentFirst, StringWriter writer) { if ( polygon.IsEmpty() ) { writer.Write("EMPTY"); } else { if (indentFirst) Indent(level, writer); writer.Write("("); AppendLineStringText(polygon.Shell, level, false, writer); for (int i = 0; i < polygon.GetNumInteriorRing(); i++) { writer.Write(", "); AppendLineStringText(polygon.Holes[i], level + 1, true, writer); } writer.Write(")"); } }
/// <summary> /// Converts a Polygon to <Polygon Text> format, then /// Appends it to the writer. /// </summary> /// <param name="polygon">The Polygon to process.</param> /// <param name="writer"></param> protected void AppendPolygonText(Polygon polygon, TextWriter writer) { if (polygon.IsEmpty()) { //writer.Write("EMPTY"); } else { AppendLineStringText(polygon.Shell,writer); for (int i = 0; i < polygon.GetNumInteriorRing(); i++) { AppendLineStringText(polygon.Holes[i], writer); } writer.Write(" Z "); } }
} // private static bool ContainsPoint(Coordinate p, Geometry geom) private static bool ContainsPointInPolygon(Coordinate p, Polygon poly) { if ( poly.IsEmpty() ) return false; LinearRing shell = (LinearRing) poly.GetExteriorRing(); if ( ! _cga.IsPointInRing( p, shell.GetCoordinates() ) ) { return false; } // now test if the point lies in or on the holes for (int i = 0; i < poly.GetNumInteriorRing(); i++) { LinearRing lr = poly.GetInteriorRingN( i ); if ( _cga.IsPointInRing( p, lr.GetCoordinates() ) ) { return false; } } return true; } // private static bool ContainsPointInPolygon(Coordinate p, Polygon poly)