private void GenerateCuts_() { if (m_cuts != null) { return; } m_cuts = new System.Collections.Generic.List <com.epl.geometry.MultiPath>(); com.epl.geometry.Geometry.Type type = m_cuttee.GetType(); switch (type.Value()) { case com.epl.geometry.Geometry.GeometryType.Polyline: { Generate_polyline_cuts_(); break; } case com.epl.geometry.Geometry.GeometryType.Polygon: { Generate_polygon_cuts_(); break; } default: { break; } } }
public override com.epl.geometry.Geometry Execute(int import_flags, com.epl.geometry.Geometry.Type type, string wkt_string, com.epl.geometry.ProgressTracker progress_tracker) { com.epl.geometry.WktParser wkt_parser = new com.epl.geometry.WktParser(wkt_string); int current_token = wkt_parser.NextToken(); return(ImportFromWkt(import_flags, type, wkt_parser)); }
private com.epl.geometry.Geometry Generalize(com.epl.geometry.Geometry geom) { com.epl.geometry.Geometry.Type gt = geom.GetType(); if (com.epl.geometry.Geometry.IsPoint(gt.Value())) { return(geom); } if (gt == com.epl.geometry.Geometry.Type.Envelope) { com.epl.geometry.Polygon poly = new com.epl.geometry.Polygon(geom.GetDescription()); poly.AddEnvelope((com.epl.geometry.Envelope)geom, false); return(Generalize(poly)); } if (geom.IsEmpty()) { return(geom); } com.epl.geometry.MultiPath mp = (com.epl.geometry.MultiPath)geom; com.epl.geometry.MultiPath dstmp = (com.epl.geometry.MultiPath)geom.CreateInstance(); com.epl.geometry.Line line = new com.epl.geometry.Line(); for (int ipath = 0, npath = mp.GetPathCount(); ipath < npath; ipath++) { GeneralizePath((com.epl.geometry.MultiPathImpl)mp._getImpl(), ipath, (com.epl.geometry.MultiPathImpl)dstmp._getImpl(), line); } return(dstmp); }
// /// <exception cref="java.io.ObjectStreamException"/> // internal virtual object WriteReplace() // { // com.epl.geometry.Geometry.Type gt = GetType(); // if (gt == com.epl.geometry.Geometry.Type.Point) // { // com.epl.geometry.PtSrlzr pt = new com.epl.geometry.PtSrlzr(); // pt.SetGeometryByValue((com.epl.geometry.Point)this); // return pt; // } // else // { // if (gt == com.epl.geometry.Geometry.Type.Envelope) // { // com.epl.geometry.EnvSrlzr e = new com.epl.geometry.EnvSrlzr(); // e.SetGeometryByValue((com.epl.geometry.Envelope)this); // return e; // } // else // { // if (gt == com.epl.geometry.Geometry.Type.Line) // { // com.epl.geometry.LnSrlzr ln = new com.epl.geometry.LnSrlzr(); // ln.SetGeometryByValue((com.epl.geometry.Line)this); // return ln; // } // } // } // com.epl.geometry.GenericGeometrySerializer geomSerializer = new com.epl.geometry.GenericGeometrySerializer(); // geomSerializer.SetGeometryByValue(this); // return geomSerializer; // } // // /// <summary>The output of this method can be only used for debugging.</summary> // /// <remarks>The output of this method can be only used for debugging. It is subject to change without notice.</remarks> // public override string ToString() // { // string snippet = com.epl.geometry.OperatorExportToJson.Local().Execute(null, this); // if (snippet.Length > 200) // { // return snippet.Substring(0, 197 - 0) + "... (" + snippet.Length + " characters)"; // } // else // { // return snippet; // } // } /// <summary> /// Returns count of geometry vertices: /// 1 for Point, 4 for Envelope, get_point_count for MultiVertexGeometry types, /// 2 for segment types /// Returns 0 if geometry is empty. /// </summary> public static int Vertex_count(com.epl.geometry.Geometry geom) { com.epl.geometry.Geometry.Type gt = geom.GetType(); if (com.epl.geometry.Geometry.IsMultiVertex(gt.Value())) { return(((com.epl.geometry.MultiVertexGeometry)geom).GetPointCount()); } if (geom.IsEmpty()) { return(0); } if (gt == com.epl.geometry.Geometry.Type.Envelope) { return(4); } if (gt == com.epl.geometry.Geometry.Type.Point) { return(1); } if (com.epl.geometry.Geometry.IsSegment(gt.Value())) { return(2); } throw new com.epl.geometry.GeometryException("missing type"); }
public virtual void Create(com.epl.geometry.Geometry.Type type) { if (type == com.epl.geometry.Geometry.Type.Line) { CreateLine(); } else { throw new com.epl.geometry.GeometryException("not implemented"); } }
internal static bool HasNonEmptyBoundary(com.epl.geometry.Geometry geom, com.epl.geometry.ProgressTracker progress_tracker) { if (geom.IsEmpty()) { return(false); } com.epl.geometry.Geometry.Type gt = geom.GetType(); if (gt == com.epl.geometry.Geometry.Type.Polygon) { if (geom.CalculateArea2D() == 0) { return(false); } return(true); } else { if (gt == com.epl.geometry.Geometry.Type.Polyline) { bool[] b = new bool[1]; b[0] = false; CalculatePolylineBoundary_(geom._getImpl(), progress_tracker, true, b); return(b[0]); } else { if (gt == com.epl.geometry.Geometry.Type.Envelope) { return(true); } else { if (com.epl.geometry.Geometry.IsSegment(gt.Value())) { if (!((com.epl.geometry.Segment)geom).IsClosed()) { return(true); } return(false); } else { if (com.epl.geometry.Geometry.IsPoint(gt.Value())) { return(false); } } } } } return(false); }
/// <summary>Removes accelerators from given geometry.</summary> /// <param name="geometry">The geometry instance to remove accelerators from.</param> public static void DeaccelerateGeometry(com.epl.geometry.Geometry geometry) { com.epl.geometry.Geometry.Type gt = geometry.GetType(); if (com.epl.geometry.Geometry.IsMultiVertex(gt.Value())) { com.epl.geometry.GeometryAccelerators accel = ((com.epl.geometry.MultiVertexGeometryImpl)geometry._getImpl())._getAccelerators(); if (accel != null) { accel._setRasterizedGeometry(null); accel._setQuadTree(null); } } }
internal static void TestPointsOnLine2D(com.epl.geometry.Geometry line, com.epl.geometry.Point2D[] input_points, int count, double tolerance, com.epl.geometry.PolygonUtils.PiPResult[] test_results) { com.epl.geometry.Geometry.Type gt = line.GetType(); if (gt == com.epl.geometry.Geometry.Type.Polyline) { TestPointsOnPolyline2D_((com.epl.geometry.Polyline)line, input_points, count, tolerance, test_results); } else { if (com.epl.geometry.Geometry.IsSegment(gt.Value())) { TestPointsOnSegment_((com.epl.geometry.Segment)line, input_points, count, tolerance, test_results); } else { throw new com.epl.geometry.GeometryException("Invalid call."); } } }
public override com.epl.geometry.Geometry Execute(int importFlags, com.epl.geometry.Geometry.Type type, System.IO.MemoryStream shapeBuffer) { com.epl.geometry.SimpleByteBufferCursor byteBufferCursor = new com.epl.geometry.SimpleByteBufferCursor(shapeBuffer); com.epl.geometry.GeometryCursor geometryCursor = Execute(importFlags, type, byteBufferCursor); return(geometryCursor.Next()); }
/// <summary>Performs the ImportFromESRIShape operation.</summary> /// <param name="importFlags"> /// Use the /// <see cref="ShapeImportFlags"/> /// interface. The default is 0, which means geometry comes from a trusted source and is topologically simple. /// If the geometry comes from non-trusted source (that is it can be non-simple), pass ShapeImportNonTrusted. /// </param> /// <param name="type"> /// The geometry type that you want to import. Use the /// <see cref="Type"/> /// enum. It can be Geometry.Type.Unknown if the type of geometry has to be /// figured out from the shape buffer. /// </param> /// <param name="shapeBuffer">The buffer holding the Geometry in ESRIShape format.</param> /// <returns>Returns the imported Geometry.</returns> public abstract com.epl.geometry.Geometry Execute(int importFlags, com.epl.geometry.Geometry.Type type, System.IO.MemoryStream shapeBuffer);
internal override com.epl.geometry.MapGeometryCursor Execute(com.epl.geometry.Geometry.Type type, com.epl.geometry.JsonReaderCursor jsonParserCursor) { return(new com.epl.geometry.OperatorImportFromJsonCursor(type.Value(), jsonParserCursor)); }
internal override com.epl.geometry.GeometryCursor Execute(int importFlags, com.epl.geometry.Geometry.Type type, com.epl.geometry.ByteBufferCursor shapeBuffers) { return(new com.epl.geometry.OperatorImportFromESRIShapeCursor(importFlags, type.Value(), shapeBuffers)); }
internal static com.epl.geometry.Geometry CalculateConvexHull_(com.epl.geometry.Geometry geom, com.epl.geometry.ProgressTracker progress_tracker) { if (geom.IsEmpty()) { return(geom.CreateInstance()); } com.epl.geometry.Geometry.Type type = geom.GetType(); if (com.epl.geometry.Geometry.IsSegment(type.Value())) { // Segments are always returned either as a Point or Polyline com.epl.geometry.Segment segment = (com.epl.geometry.Segment)geom; if (segment.GetStartXY().Equals(segment.GetEndXY())) { com.epl.geometry.Point point = new com.epl.geometry.Point(); segment.QueryStart(point); return(point); } else { com.epl.geometry.Point pt = new com.epl.geometry.Point(); com.epl.geometry.Polyline polyline = new com.epl.geometry.Polyline(geom.GetDescription()); segment.QueryStart(pt); polyline.StartPath(pt); segment.QueryEnd(pt); polyline.LineTo(pt); return(polyline); } } else { if (type == com.epl.geometry.Geometry.Type.Envelope) { com.epl.geometry.Envelope envelope = (com.epl.geometry.Envelope)geom; com.epl.geometry.Envelope2D env = new com.epl.geometry.Envelope2D(); envelope.QueryEnvelope2D(env); if (env.xmin == env.xmax && env.ymin == env.ymax) { com.epl.geometry.Point point = new com.epl.geometry.Point(); envelope.QueryCornerByVal(0, point); return(point); } else { if (env.xmin == env.xmax || env.ymin == env.ymax) { com.epl.geometry.Point pt = new com.epl.geometry.Point(); com.epl.geometry.Polyline polyline = new com.epl.geometry.Polyline(geom.GetDescription()); envelope.QueryCornerByVal(0, pt); polyline.StartPath(pt); envelope.QueryCornerByVal(1, pt); polyline.LineTo(pt); return(polyline); } else { com.epl.geometry.Polygon polygon = new com.epl.geometry.Polygon(geom.GetDescription()); polygon.AddEnvelope(envelope, false); return(polygon); } } } } if (IsConvex_(geom, progress_tracker)) { if (type == com.epl.geometry.Geometry.Type.MultiPoint) { // Downgrade to a Point for simplistic output com.epl.geometry.MultiPoint multi_point = (com.epl.geometry.MultiPoint)geom; com.epl.geometry.Point point = new com.epl.geometry.Point(); multi_point.GetPointByVal(0, point); return(point); } return(geom); } System.Diagnostics.Debug.Assert((com.epl.geometry.Geometry.IsMultiVertex(type.Value()))); com.epl.geometry.Geometry convex_hull = com.epl.geometry.ConvexHull.Construct((com.epl.geometry.MultiVertexGeometry)geom); return(convex_hull); }
/// <summary>Performs the ImportFromWKB operation.</summary> /// <param name="importFlags"> /// Use the /// <see cref="WkbImportFlags"/> /// interface. /// </param> /// <param name="type"> /// Use the /// <see cref="Type"/> /// enum. /// </param> /// <param name="wkbBuffer">The buffer holding the Geometry in wkb format.</param> /// <returns>Returns the imported Geometry.</returns> public abstract com.epl.geometry.Geometry Execute(int importFlags, com.epl.geometry.Geometry.Type type, System.IO.MemoryStream wkbBuffer, com.epl.geometry.ProgressTracker progress_tracker);
/// <summary>Performs the Distance operation on two geometries</summary> /// <returns>Returns a double.</returns> public override double Execute(com.epl.geometry.Geometry geom1, com.epl.geometry.Geometry geom2, com.epl.geometry.ProgressTracker progressTracker) { if (null == geom1 || null == geom2) { throw new System.ArgumentException(); } com.epl.geometry.Geometry geometryA = geom1; com.epl.geometry.Geometry geometryB = geom2; if (geometryA.IsEmpty() || geometryB.IsEmpty()) { return(com.epl.geometry.NumberUtils.TheNaN); } com.epl.geometry.Polygon polygonA; com.epl.geometry.Polygon polygonB; com.epl.geometry.MultiPoint multiPointA; com.epl.geometry.MultiPoint multiPointB; // if geometryA is an envelope use a polygon instead (if geom1 was // folded, then geometryA will already be a polygon) // if geometryA is a point use a multipoint instead com.epl.geometry.Geometry.Type gtA = geometryA.GetType(); com.epl.geometry.Geometry.Type gtB = geometryB.GetType(); if (gtA == com.epl.geometry.Geometry.Type.Point) { if (gtB == com.epl.geometry.Geometry.Type.Point) { return(com.epl.geometry.Point2D.Distance(((com.epl.geometry.Point)geometryA).GetXY(), ((com.epl.geometry.Point)geometryB).GetXY())); } else { if (gtB == com.epl.geometry.Geometry.Type.Envelope) { com.epl.geometry.Envelope2D envB = new com.epl.geometry.Envelope2D(); geometryB.QueryEnvelope2D(envB); return(envB.Distance(((com.epl.geometry.Point)geometryA).GetXY())); } } multiPointA = new com.epl.geometry.MultiPoint(); multiPointA.Add((com.epl.geometry.Point)geometryA); geometryA = multiPointA; } else { if (gtA == com.epl.geometry.Geometry.Type.Envelope) { if (gtB == com.epl.geometry.Geometry.Type.Envelope) { com.epl.geometry.Envelope2D envA = new com.epl.geometry.Envelope2D(); geometryA.QueryEnvelope2D(envA); com.epl.geometry.Envelope2D envB = new com.epl.geometry.Envelope2D(); geometryB.QueryEnvelope2D(envB); return(envB.Distance(envA)); } polygonA = new com.epl.geometry.Polygon(); polygonA.AddEnvelope((com.epl.geometry.Envelope)geometryA, false); geometryA = polygonA; } } // if geom_2 is an envelope use a polygon instead // if geom_2 is a point use a multipoint instead if (gtB == com.epl.geometry.Geometry.Type.Point) { multiPointB = new com.epl.geometry.MultiPoint(); multiPointB.Add((com.epl.geometry.Point)geometryB); geometryB = multiPointB; } else { if (gtB == com.epl.geometry.Geometry.Type.Envelope) { polygonB = new com.epl.geometry.Polygon(); polygonB.AddEnvelope((com.epl.geometry.Envelope)geometryB, false); geometryB = polygonB; } } com.epl.geometry.OperatorDistanceLocal.DistanceCalculator distanceCalculator = new com.epl.geometry.OperatorDistanceLocal.DistanceCalculator(this, progressTracker); double distance = distanceCalculator.Calculate(geometryA, geometryB); return(distance); }
/// <summary>Performs the ImportFromJson operation on a single Json string</summary> /// <returns>Returns a MapGeometry.</returns> public abstract com.epl.geometry.MapGeometry Execute(com.epl.geometry.Geometry.Type type, com.epl.geometry.JsonReader jsonReader);
public override com.epl.geometry.MapGeometry Execute(com.epl.geometry.Geometry.Type type, com.epl.geometry.JsonReader jsonParser) { return(com.epl.geometry.OperatorImportFromJsonCursor.ImportFromJsonParser(type.Value(), jsonParser)); }
public static com.epl.geometry.ogc.OGCGeometry CreateFromEsriGeometry(com.epl.geometry.Geometry geom, com.epl.geometry.SpatialReference sr, bool multiType) { if (geom == null) { return(null); } com.epl.geometry.Geometry.Type t = geom.GetType(); if (t == com.epl.geometry.Geometry.Type.Polygon) { if (!multiType && ((com.epl.geometry.Polygon)geom).GetExteriorRingCount() == 1) { return(new com.epl.geometry.ogc.OGCPolygon((com.epl.geometry.Polygon)geom, sr)); } else { return(new com.epl.geometry.ogc.OGCMultiPolygon((com.epl.geometry.Polygon)geom, sr)); } } if (t == com.epl.geometry.Geometry.Type.Polyline) { if (!multiType && ((com.epl.geometry.Polyline)geom).GetPathCount() == 1) { return(new com.epl.geometry.ogc.OGCLineString((com.epl.geometry.Polyline)geom, 0, sr)); } else { return(new com.epl.geometry.ogc.OGCMultiLineString((com.epl.geometry.Polyline)geom, sr)); } } if (t == com.epl.geometry.Geometry.Type.MultiPoint) { if (!multiType && ((com.epl.geometry.MultiPoint)geom).GetPointCount() <= 1) { if (geom.IsEmpty()) { return(new com.epl.geometry.ogc.OGCPoint(new com.epl.geometry.Point(), sr)); } else { return(new com.epl.geometry.ogc.OGCPoint(((com.epl.geometry.MultiPoint)geom).GetPoint(0), sr)); } } else { return(new com.epl.geometry.ogc.OGCMultiPoint((com.epl.geometry.MultiPoint)geom, sr)); } } if (t == com.epl.geometry.Geometry.Type.Point) { if (!multiType) { return(new com.epl.geometry.ogc.OGCPoint((com.epl.geometry.Point)geom, sr)); } else { return(new com.epl.geometry.ogc.OGCMultiPoint((com.epl.geometry.Point)geom, sr)); } } if (t == com.epl.geometry.Geometry.Type.Envelope) { com.epl.geometry.Polygon p = new com.epl.geometry.Polygon(); p.AddEnvelope((com.epl.geometry.Envelope)geom, false); return(CreateFromEsriGeometry(p, sr, multiType)); } throw new System.NotSupportedException(); }
internal static com.epl.geometry.Geometry ImportFromWkt(int import_flags, com.epl.geometry.Geometry.Type type, com.epl.geometry.WktParser wkt_parser) { int current_token = wkt_parser.CurrentToken(); switch (current_token) { case com.epl.geometry.WktParser.WktToken.multipolygon: { if (type != com.epl.geometry.Geometry.Type.Polygon && type != com.epl.geometry.Geometry.Type.Unknown) { throw new System.ArgumentException("invalid shapetype"); } return(PolygonTaggedText(true, import_flags, wkt_parser)); } case com.epl.geometry.WktParser.WktToken.multilinestring: { if (type != com.epl.geometry.Geometry.Type.Polyline && type != com.epl.geometry.Geometry.Type.Unknown) { throw new System.ArgumentException("invalid shapetype"); } return(LineStringTaggedText(true, import_flags, wkt_parser)); } case com.epl.geometry.WktParser.WktToken.multipoint: { if (type != com.epl.geometry.Geometry.Type.MultiPoint && type != com.epl.geometry.Geometry.Type.Unknown) { throw new System.ArgumentException("invalid shapetype"); } return(MultiPointTaggedText(import_flags, wkt_parser)); } case com.epl.geometry.WktParser.WktToken.polygon: { if (type != com.epl.geometry.Geometry.Type.Polygon && type != com.epl.geometry.Geometry.Type.Unknown) { throw new System.ArgumentException("invalid shapetype"); } return(PolygonTaggedText(false, import_flags, wkt_parser)); } case com.epl.geometry.WktParser.WktToken.linestring: { if (type != com.epl.geometry.Geometry.Type.Polyline && type != com.epl.geometry.Geometry.Type.Unknown) { throw new System.ArgumentException("invalid shapetype"); } return(LineStringTaggedText(false, import_flags, wkt_parser)); } case com.epl.geometry.WktParser.WktToken.point: { if (type != com.epl.geometry.Geometry.Type.Point && type != com.epl.geometry.Geometry.Type.Unknown) { throw new System.ArgumentException("invalid shapetype"); } return(PointTaggedText(import_flags, wkt_parser)); } default: { break; } } // warning fix return(null); }
public override com.epl.geometry.MapGeometry Execute(com.epl.geometry.Geometry.Type type, string @string) { return(Execute(type, com.epl.geometry.JsonParserReader.CreateFromString(@string))); }
/// <summary>Performs the ImportFromWkt operation.</summary> /// <param name="import_flags"> /// Use the /// <see cref="WktImportFlags"/> /// interface. /// </param> /// <param name="type"> /// Use the /// <see cref="Type"/> /// enum. /// </param> /// <param name="wkt_string">The string holding the Geometry in wkt format.</param> /// <returns>Returns the imported Geometry.</returns> public abstract com.epl.geometry.Geometry Execute(int import_flags, com.epl.geometry.Geometry.Type type, string wkt_string, com.epl.geometry.ProgressTracker progress_tracker);
/// <summary>Performs the ImportFromESRIShape operation on a stream of shape buffers</summary> /// <param name="importFlags"> /// Use the /// <see cref="ShapeImportFlags"/> /// interface. The default is 0, which means geometry comes from a trusted source and is topologically simple. /// If the geometry comes from non-trusted source (that is it can be non-simple), pass ShapeImportNonTrusted. /// </param> /// <param name="type"> /// The geometry type that you want to import. Use the /// <see cref="Type"/> /// enum. It can be Geometry.Type.Unknown if the type of geometry has to be /// figured out from the shape buffer. /// </param> /// <param name="shapeBuffers">The cursor over shape buffers that hold the Geometries in ESRIShape format.</param> /// <returns>Returns a GeometryCursor.</returns> internal abstract com.epl.geometry.GeometryCursor Execute(int importFlags, com.epl.geometry.Geometry.Type type, com.epl.geometry.ByteBufferCursor shapeBuffers);
// /// <summary>Imports the MapGeometry from its JSON representation.</summary> // /// <remarks> // /// Imports the MapGeometry from its JSON representation. M and Z values are // /// not imported from JSON representation. // /// See OperatorImportFromJson. // /// </remarks> // /// <param name="json"> // /// The JSON representation of the geometry (with spatial // /// reference). // /// </param> // /// <returns> // /// The MapGeometry instance containing the imported geometry and its // /// spatial reference. // /// </returns> // public static com.epl.geometry.MapGeometry JsonToGeometry(com.fasterxml.jackson.core.JsonParser json) // { // com.epl.geometry.MapGeometry geom = com.epl.geometry.OperatorImportFromJson.Local().Execute(com.epl.geometry.Geometry.Type.Unknown, new com.epl.geometry.JsonParserReader(json)); // return geom; // } // // /// <summary>Imports the MapGeometry from its JSON representation.</summary> // /// <remarks> // /// Imports the MapGeometry from its JSON representation. M and Z values are // /// not imported from JSON representation. // /// See OperatorImportFromJson. // /// </remarks> // /// <param name="json"> // /// The JSON representation of the geometry (with spatial // /// reference). // /// </param> // /// <returns> // /// The MapGeometry instance containing the imported geometry and its // /// spatial reference. // /// </returns> // public static com.epl.geometry.MapGeometry JsonToGeometry(com.epl.geometry.JsonReader json) // { // com.epl.geometry.MapGeometry geom = com.epl.geometry.OperatorImportFromJson.Local().Execute(com.epl.geometry.Geometry.Type.Unknown, json); // return geom; // } // // /// <summary>Imports the MapGeometry from its JSON representation.</summary> // /// <remarks> // /// Imports the MapGeometry from its JSON representation. M and Z values are // /// not imported from JSON representation. // /// See OperatorImportFromJson. // /// </remarks> // /// <param name="json"> // /// The JSON representation of the geometry (with spatial // /// reference). // /// </param> // /// <returns> // /// The MapGeometry instance containing the imported geometry and its // /// spatial reference. // /// </returns> // /// <exception cref="System.IO.IOException"></exception> // /// <exception cref="JsonParseException"></exception> // public static com.epl.geometry.MapGeometry JsonToGeometry(string json) // { // com.epl.geometry.MapGeometry geom = com.epl.geometry.OperatorImportFromJson.Local().Execute(com.epl.geometry.Geometry.Type.Unknown, json); // return geom; // } // // /// <summary>Exports the specified geometry instance to it's JSON representation.</summary> // /// <remarks> // /// Exports the specified geometry instance to it's JSON representation. // /// See OperatorExportToJson. // /// </remarks> // /// <seealso cref="GeometryToJson(SpatialReference, Geometry)"/> // /// <param name="wkid"> // /// The spatial reference Well Known ID to be used for the JSON // /// representation. // /// </param> // /// <param name="geometry">The geometry to be exported to JSON.</param> // /// <returns>The JSON representation of the specified Geometry.</returns> // public static string GeometryToJson(int wkid, com.epl.geometry.Geometry geometry) // { // return com.epl.geometry.GeometryEngine.GeometryToJson(wkid > 0 ? com.epl.geometry.SpatialReference.Create(wkid) : null, geometry); // } // // /// <summary>Exports the specified geometry instance to it's JSON representation.</summary> // /// <remarks> // /// Exports the specified geometry instance to it's JSON representation. M // /// and Z values are not imported from JSON representation. // /// See OperatorExportToJson. // /// </remarks> // /// <param name="spatialReference">The spatial reference of associated object.</param> // /// <param name="geometry">The geometry.</param> // /// <returns>The JSON representation of the specified geometry.</returns> // public static string GeometryToJson(com.epl.geometry.SpatialReference spatialReference, com.epl.geometry.Geometry geometry) // { // com.epl.geometry.OperatorExportToJson exporter = (com.epl.geometry.OperatorExportToJson)factory.GetOperator(com.epl.geometry.Operator.Type.ExportToJson); // return exporter.Execute(spatialReference, geometry); // } // // public static string GeometryToGeoJson(com.epl.geometry.Geometry geometry) // { // com.epl.geometry.OperatorExportToGeoJson exporter = (com.epl.geometry.OperatorExportToGeoJson)factory.GetOperator(com.epl.geometry.Operator.Type.ExportToGeoJson); // return exporter.Execute(geometry); // } // // /// <summary>Imports the MapGeometry from its JSON representation.</summary> // /// <remarks> // /// Imports the MapGeometry from its JSON representation. M and Z values are // /// not imported from JSON representation. // /// See OperatorImportFromJson. // /// </remarks> // /// <param name="json"> // /// The JSON representation of the geometry (with spatial // /// reference). // /// </param> // /// <returns> // /// The MapGeometry instance containing the imported geometry and its // /// spatial reference. // /// </returns> // /// <exception cref="System.IO.IOException"></exception> // /// <exception cref="JsonParseException"></exception> // public static com.epl.geometry.MapGeometry GeoJsonToGeometry(string json, int importFlags, com.epl.geometry.Geometry.Type type) // { // com.epl.geometry.MapGeometry geom = com.epl.geometry.OperatorImportFromGeoJson.Local().Execute(importFlags, type, json, null); // return geom; // } // // /// <summary>Exports the specified geometry instance to its GeoJSON representation.</summary> // /// <remarks> // /// Exports the specified geometry instance to its GeoJSON representation. // /// See OperatorExportToGeoJson. // /// </remarks> // /// <seealso cref="GeometryToGeoJson(SpatialReference, Geometry)"/> // /// <param name="wkid"> // /// The spatial reference Well Known ID to be used for the GeoJSON // /// representation. // /// </param> // /// <param name="geometry">The geometry to be exported to GeoJSON.</param> // /// <returns>The GeoJSON representation of the specified geometry.</returns> // public static string GeometryToGeoJson(int wkid, com.epl.geometry.Geometry geometry) // { // return com.epl.geometry.GeometryEngine.GeometryToGeoJson(wkid > 0 ? com.epl.geometry.SpatialReference.Create(wkid) : null, geometry); // } // // /// <summary>Exports the specified geometry instance to it's JSON representation.</summary> // /// <remarks> // /// Exports the specified geometry instance to it's JSON representation. // /// See OperatorImportFromGeoJson. // /// </remarks> // /// <param name="spatialReference">The spatial reference of associated object.</param> // /// <param name="geometry">The geometry.</param> // /// <returns>The GeoJSON representation of the specified geometry.</returns> // public static string GeometryToGeoJson(com.epl.geometry.SpatialReference spatialReference, com.epl.geometry.Geometry geometry) // { // com.epl.geometry.OperatorExportToGeoJson exporter = (com.epl.geometry.OperatorExportToGeoJson)factory.GetOperator(com.epl.geometry.Operator.Type.ExportToGeoJson); // return exporter.Execute(spatialReference, geometry); // } /// <summary>Imports geometry from the ESRI shape file format.</summary> /// <remarks> /// Imports geometry from the ESRI shape file format. /// See OperatorImportFromESRIShape. /// </remarks> /// <param name="esriShapeBuffer">The buffer containing geometry in the ESRI shape file format.</param> /// <param name="geometryType"> /// The required type of the Geometry to be imported. Use /// Geometry.Type.Unknown if the geometry type needs to be /// determined from the buffer content. /// </param> /// <returns>The geometry or null if the buffer contains null shape.</returns> /// <exception cref="GeometryException"> /// when the geometryType is not Geometry.Type.Unknown and the /// buffer contains geometry that cannot be converted to the /// given geometryType. or the buffer is corrupt. Another /// exception possible is IllegalArgumentsException. /// </exception> public static com.epl.geometry.Geometry GeometryFromEsriShape(byte[] esriShapeBuffer, com.epl.geometry.Geometry.Type geometryType) { com.epl.geometry.OperatorImportFromESRIShape op = (com.epl.geometry.OperatorImportFromESRIShape)factory.GetOperator(com.epl.geometry.Operator.Type.ImportFromESRIShape); return(op.Execute(com.epl.geometry.ShapeImportFlags.ShapeImportNonTrusted, geometryType, new System.IO.MemoryStream(esriShapeBuffer))); }
/// <summary>Performs the ImportFromJson operation on a number of Json Strings</summary> /// <returns>Returns a MapGeometryCursor.</returns> internal abstract com.epl.geometry.MapGeometryCursor Execute(com.epl.geometry.Geometry.Type type, com.epl.geometry.JsonReaderCursor jsonReaderCursor);
/// <summary>Imports a geometry from a WKT string.</summary> /// <remarks> /// Imports a geometry from a WKT string. /// See OperatorImportFromWkt. /// </remarks> /// <param name="wkt">The string containing the geometry in WKT format.</param> /// <param name="importFlags"> /// Use the /// <see cref="WktImportFlags"/> /// interface. /// </param> /// <param name="geometryType">The required type of the Geometry to be imported. Use Geometry.Type.Unknown if the geometry type needs to be determined from the WKT context.</param> /// <returns>The geometry.</returns> /// <exception cref="GeometryException">when the geometryType is not Geometry.Type.Unknown and the WKT contains a geometry that cannot be converted to the given geometryType.</exception> /// <exception cref="IllegalArgument">exception if an error is found while parsing the WKT string.</exception> public static com.epl.geometry.Geometry GeometryFromWkt(string wkt, int importFlags, com.epl.geometry.Geometry.Type geometryType) { com.epl.geometry.OperatorImportFromWkt op = (com.epl.geometry.OperatorImportFromWkt)factory.GetOperator(com.epl.geometry.Operator.Type.ImportFromWkt); return(op.Execute(importFlags, geometryType, wkt, null)); }
/// <summary>Performs the ImportFromJson operation on a single Json string</summary> /// <returns>Returns a MapGeometry.</returns> public abstract com.epl.geometry.MapGeometry Execute(com.epl.geometry.Geometry.Type type, string @string);
internal static bool IsConvex_(com.epl.geometry.Geometry geom, com.epl.geometry.ProgressTracker progress_tracker) { if (geom.IsEmpty()) { return(true); } // vacuously true com.epl.geometry.Geometry.Type type = geom.GetType(); if (type == com.epl.geometry.Geometry.Type.Point) { return(true); } // vacuously true if (type == com.epl.geometry.Geometry.Type.Envelope) { com.epl.geometry.Envelope envelope = (com.epl.geometry.Envelope)geom; if (envelope.GetXMin() == envelope.GetXMax() || envelope.GetYMin() == envelope.GetYMax()) { return(false); } return(true); } if (com.epl.geometry.MultiPath.IsSegment(type.Value())) { com.epl.geometry.Segment segment = (com.epl.geometry.Segment)geom; if (segment.GetStartXY().Equals(segment.GetEndXY())) { return(false); } return(true); } // true, but we will upgrade to a Polyline for the ConvexHull operation if (type == com.epl.geometry.Geometry.Type.MultiPoint) { com.epl.geometry.MultiPoint multi_point = (com.epl.geometry.MultiPoint)geom; if (multi_point.GetPointCount() == 1) { return(true); } // vacuously true, but we will downgrade to a Point for the ConvexHull operation return(false); } if (type == com.epl.geometry.Geometry.Type.Polyline) { com.epl.geometry.Polyline polyline = (com.epl.geometry.Polyline)geom; if (polyline.GetPathCount() == 1 && polyline.GetPointCount() == 2) { if (!polyline.GetXY(0).Equals(polyline.GetXY(1))) { return(true); } } // vacuously true return(false); } // create convex hull com.epl.geometry.Polygon polygon = (com.epl.geometry.Polygon)geom; if (polygon.GetPathCount() != 1 || polygon.GetPointCount() < 3) { return(false); } return(com.epl.geometry.ConvexHull.IsPathConvex(polygon, 0, progress_tracker)); }
/// <exception cref="System.IO.FileNotFoundException"/> public static com.epl.geometry.Geometry LoadFromTextFileDbg(string textFileName) { string fullPath = textFileName; // string fullCSVPathName = System.IO.Path.Combine( directoryPath , // CsvFileName); java.io.File fileInfo = new java.io.File(fullPath); java.util.Scanner scanner = new java.util.Scanner(fileInfo); com.epl.geometry.Geometry geom = null; // grab first line string line = scanner.NextLine(); string geomTypeString = Sharpen.Runtime.Substring(line, 1); if (Sharpen.Runtime.EqualsIgnoreCase(geomTypeString, "polygon")) { geom = new com.epl.geometry.Polygon(); } else { if (Sharpen.Runtime.EqualsIgnoreCase(geomTypeString, "polyline")) { geom = new com.epl.geometry.Polyline(); } else { if (Sharpen.Runtime.EqualsIgnoreCase(geomTypeString, "multipoint")) { geom = new com.epl.geometry.MultiPoint(); } else { if (Sharpen.Runtime.EqualsIgnoreCase(geomTypeString, "point")) { geom = new com.epl.geometry.Point(); } } } } while (line.StartsWith("*")) { if (scanner.HasNextLine()) { line = scanner.NextLine(); } } int j = 0; com.epl.geometry.Geometry.Type geomType = geom.GetType(); while (scanner.HasNextLine()) { string[] parsedLine = line.Split("\\s+"); double xVal = double.Parse(parsedLine[0]); double yVal = double.Parse(parsedLine[1]); if (j == 0 && (geomType == com.epl.geometry.Geometry.Type.Polygon || geomType == com.epl.geometry.Geometry.Type.Polyline)) { ((com.epl.geometry.MultiPath)geom).StartPath(xVal, yVal); } else { if (geomType == com.epl.geometry.Geometry.Type.Polygon || geomType == com.epl.geometry.Geometry.Type.Polyline) { ((com.epl.geometry.MultiPath)geom).LineTo(xVal, yVal); } else { if (geomType == com.epl.geometry.Geometry.Type.MultiPoint) { ((com.epl.geometry.MultiPoint)geom).Add(xVal, yVal); } } } // else if(geomType == Geometry.Type.Point) // Point geom = null;//new Point(xVal, yVal); j++; line = scanner.NextLine(); } scanner.Close(); return(geom); }
/// <summary>Performs the ImportFromGeoJson operation.</summary> /// <param name="type"> /// Use the /// <see cref="Type"/> /// enum. /// </param> /// <param name="jsonObject">The JSONObject holding the geometry and spatial reference.</param> /// <returns>Returns the imported MapGeometry.</returns> /// <exception cref="JsonGeometryException"/> public abstract com.epl.geometry.MapGeometry Execute(int importFlags, com.epl.geometry.Geometry.Type type, com.epl.geometry.JsonReader jsonReader, com.epl.geometry.ProgressTracker progressTracker);