Ejemplo n.º 1
0
//		/// <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");
        }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
        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;
            }
            }
        }
 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);
 }
Ejemplo n.º 5
0
 /// <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);
         }
     }
 }
Ejemplo n.º 6
0
 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.");
         }
     }
 }
 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 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));
 }
 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);
 }
 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));
 }
 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));
 }