public virtual void TestBufferPoint()
        {
            com.epl.geometry.SpatialReference sr        = com.epl.geometry.SpatialReference.Create(4326);
            com.epl.geometry.Point            inputGeom = new com.epl.geometry.Point(12, 120);
            com.epl.geometry.OperatorBuffer   buffer    = (com.epl.geometry.OperatorBuffer)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Buffer);
            com.epl.geometry.OperatorSimplify simplify  = (com.epl.geometry.OperatorSimplify)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Simplify);
            com.epl.geometry.Geometry         result    = buffer.Execute(inputGeom, sr, 40.0, null);
            NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
            com.epl.geometry.Polygon poly = (com.epl.geometry.Polygon)result;
            int pathCount = poly.GetPathCount();

            NUnit.Framework.Assert.IsTrue(pathCount == 1);
            int pointCount = poly.GetPointCount();

            NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 100.0) < 10);
            com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
            result.QueryEnvelope2D(env2D);
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - 80) < 0.01 && System.Math.Abs(env2D.GetHeight() - 80) < 0.01);
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 12) < 0.001 && System.Math.Abs(env2D.GetCenterY() - 120) < 0.001);
            com.epl.geometry.NonSimpleResult nsr = new com.epl.geometry.NonSimpleResult();
            bool is_simple = simplify.IsSimpleAsFeature(result, sr, true, nsr, null);

            NUnit.Framework.Assert.IsTrue(is_simple);
            {
                result = buffer.Execute(inputGeom, sr, 0, null);
                NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
                NUnit.Framework.Assert.IsTrue(result.IsEmpty());
            }
            {
                result = buffer.Execute(inputGeom, sr, -1, null);
                NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
                NUnit.Framework.Assert.IsTrue(result.IsEmpty());
            }
        }
Example #2
0
 /// <exception cref="java.io.ObjectStreamException"/>
 internal object ReadResolve()
 {
     com.epl.geometry.Geometry geometry = null;
     try
     {
         geometry = com.epl.geometry.GeometryEngine.GeometryFromEsriShape(geometryData.esriShape, geometryData.geometryType);
         if (com.epl.geometry.Geometry.IsMultiVertex(geometry.GetType().Value()))
         {
             com.epl.geometry.GeometrySerializer.MultiVertexData mvd    = (com.epl.geometry.GeometrySerializer.MultiVertexData)geometryData;
             com.epl.geometry.MultiVertexGeometryImpl            mvImpl = (com.epl.geometry.MultiVertexGeometryImpl)geometry._getImpl();
             if (!geometry.IsEmpty() && com.epl.geometry.Geometry.IsMultiPath(geometry.GetType().Value()))
             {
                 com.epl.geometry.GeometrySerializer.MultiPathData mpd = (com.epl.geometry.GeometrySerializer.MultiPathData)geometryData;
                 com.epl.geometry.MultiPathImpl         mpImpl         = (com.epl.geometry.MultiPathImpl)geometry._getImpl();
                 com.epl.geometry.AttributeStreamOfInt8 pathFlags      = mpImpl.GetPathFlagsStreamRef();
                 for (int i = 0, n = mpImpl.GetPathCount(); i < n; i++)
                 {
                     if (mpd.ogcFlags[i])
                     {
                         pathFlags.SetBits(i, unchecked ((byte)com.epl.geometry.PathFlags.enumOGCStartPolygon));
                     }
                 }
             }
             mvImpl.SetIsSimple(mvd.simpleFlag, mvd.tolerance, false);
         }
     }
     catch (System.Exception)
     {
         throw new System.IO.InvalidDataException("Cannot read geometry from stream");
     }
     return(geometry);
 }
Example #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);
 }
        private static int Get_vertex_count_(com.epl.geometry.Geometry geom)
        {
            int gt = geom.GetType().Value();

            if (com.epl.geometry.Geometry.IsMultiVertex(gt))
            {
                return(((com.epl.geometry.MultiVertexGeometry)geom).GetPointCount());
            }
            else
            {
                if (gt == com.epl.geometry.Geometry.GeometryType.Point)
                {
                    return(1);
                }
                else
                {
                    if (gt == com.epl.geometry.Geometry.GeometryType.Envelope)
                    {
                        return(4);
                    }
                    else
                    {
                        if (com.epl.geometry.Geometry.IsSegment(gt))
                        {
                            return(2);
                        }
                        else
                        {
                            throw com.epl.geometry.GeometryException.GeometryInternalError();
                        }
                    }
                }
            }
        }
        public virtual void TestMultiPointAndMultiPoint2()
        {
            com.epl.geometry.MultiPoint basePl = new com.epl.geometry.MultiPoint();
            basePl.Add(new com.epl.geometry.Point(-116, 20));
            basePl.Add(new com.epl.geometry.Point(-118, 21));
            com.epl.geometry.MultiPoint compPl = new com.epl.geometry.MultiPoint();
            compPl.Add(new com.epl.geometry.Point(-116, 20));
            compPl.Add(new com.epl.geometry.Point(-118, 21));
            int noException = 1;

            // no exception
            com.epl.geometry.Geometry intersectGeom = null;
            try
            {
                intersectGeom = com.epl.geometry.GeometryEngine.Intersect(basePl, compPl, com.epl.geometry.SpatialReference.Create(4326));
            }
            catch (System.Exception)
            {
                noException = 0;
            }
            NUnit.Framework.Assert.AreEqual(noException, 1);
            NUnit.Framework.Assert.IsNotNull(intersectGeom);
            NUnit.Framework.Assert.IsTrue(intersectGeom.GetType() == com.epl.geometry.Geometry.Type.MultiPoint);
            com.epl.geometry.MultiPoint ip = (com.epl.geometry.MultiPoint)intersectGeom;
            NUnit.Framework.Assert.AreEqual(ip.GetPoint(0).GetX(), -116, 0.1E7);
            NUnit.Framework.Assert.AreEqual(ip.GetPoint(0).GetY(), 20, 0.1E7);
            NUnit.Framework.Assert.AreEqual(ip.GetPoint(0).GetX(), -118, 0.1E7);
            NUnit.Framework.Assert.AreEqual(ip.GetPoint(0).GetY(), 21, 0.1E7);
        }
        public virtual void TestPointAndPolyline1()
        {
            com.epl.geometry.Point    basePl = new com.epl.geometry.Point(-116, 20);
            com.epl.geometry.Polyline compPl = new com.epl.geometry.Polyline();
            compPl.StartPath(new com.epl.geometry.Point(-116, 20));
            compPl.LineTo(new com.epl.geometry.Point(-131, 10));
            compPl.LineTo(new com.epl.geometry.Point(-121, 50));
            int noException = 1;

            // no exception
            com.epl.geometry.Geometry intersectGeom = null;
            try
            {
                intersectGeom = com.epl.geometry.GeometryEngine.Intersect(basePl, compPl, com.epl.geometry.SpatialReference.Create(4326));
            }
            catch (System.Exception)
            {
                noException = 0;
            }
            NUnit.Framework.Assert.AreEqual(noException, 1);
            NUnit.Framework.Assert.IsNotNull(intersectGeom);
            NUnit.Framework.Assert.IsTrue(intersectGeom.GetType() == com.epl.geometry.Geometry.Type.Point);
            com.epl.geometry.Point ip = (com.epl.geometry.Point)intersectGeom;
            NUnit.Framework.Assert.AreEqual(ip.GetX(), -116, 0.1E7);
            NUnit.Framework.Assert.AreEqual(ip.GetY(), 20, 0.1E7);
        }
        /// <summary>Adds a geometry to the current bounding geometry using an incremental algorithm for dynamic insertion.</summary>
        /// <remarks>
        /// Adds a geometry to the current bounding geometry using an incremental algorithm for dynamic insertion.
        /// \param geometry The geometry to add to the bounding geometry.
        /// </remarks>
        internal virtual void AddGeometry(com.epl.geometry.Geometry geometry)
        {
            int type = geometry.GetType().Value();

            if (com.epl.geometry.MultiVertexGeometry.IsMultiVertex(type))
            {
                AddMultiVertexGeometry_((com.epl.geometry.MultiVertexGeometry)geometry);
            }
            else
            {
                if (com.epl.geometry.MultiPath.IsSegment(type))
                {
                    AddSegment_((com.epl.geometry.Segment)geometry);
                }
                else
                {
                    if (type == com.epl.geometry.Geometry.GeometryType.Envelope)
                    {
                        AddEnvelope_((com.epl.geometry.Envelope)geometry);
                    }
                    else
                    {
                        if (type == com.epl.geometry.Geometry.GeometryType.Point)
                        {
                            AddPoint_((com.epl.geometry.Point)geometry);
                        }
                        else
                        {
                            throw new System.ArgumentException("invalid shape type");
                        }
                    }
                }
            }
        }
Example #9
0
 /// <exception cref="java.io.ObjectStreamException"/>
 public virtual void SetGeometryByValue(com.epl.geometry.Geometry geometry)
 {
     try
     {
         esriShape    = com.epl.geometry.GeometryEngine.GeometryToEsriShape(geometry);
         geometryType = geometry.GetType().Value();
         if (com.epl.geometry.Geometry.IsMultiVertex(geometryType))
         {
             com.epl.geometry.MultiVertexGeometryImpl mvImpl = (com.epl.geometry.MultiVertexGeometryImpl)geometry._getImpl();
             tolerance  = mvImpl.m_simpleTolerance;
             simpleFlag = mvImpl.GetIsSimple(0);
             if (!geometry.IsEmpty() && com.epl.geometry.Geometry.IsMultiPath(geometryType))
             {
                 com.epl.geometry.MultiPathImpl mpImpl = (com.epl.geometry.MultiPathImpl)geometry._getImpl();
                 ogcFlags = new bool[mpImpl.GetPathCount()];
                 com.epl.geometry.AttributeStreamOfInt8 pathFlags = mpImpl.GetPathFlagsStreamRef();
                 for (int i = 0, n = mpImpl.GetPathCount(); i < n; i++)
                 {
                     ogcFlags[i] = (pathFlags.Read(i) & unchecked ((byte)com.epl.geometry.PathFlags.enumOGCStartPolygon)) != 0;
                 }
             }
         }
     }
     catch (System.Exception)
     {
         throw new System.IO.InvalidDataException("Cannot serialize this geometry");
     }
 }
Example #10
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");
        }
 /// <summary>
 /// Checks whether the RasterizedGeometry2D accelerator can be used with the
 /// given geometry.
 /// </summary>
 internal static bool CanUseAccelerator(com.epl.geometry.Geometry geom)
 {
     if (geom.IsEmpty() || !(geom.GetType() == com.epl.geometry.Geometry.Type.Polyline || geom.GetType() == com.epl.geometry.Geometry.Type.Polygon))
     {
         return(false);
     }
     return(true);
 }
Example #12
0
 public override void CopyTo(com.epl.geometry.Geometry dst)
 {
     if (GetType() != dst.GetType())
     {
         throw new System.ArgumentException();
     }
     m_impl.CopyTo((com.epl.geometry.Geometry)dst._getImpl());
 }
Example #13
0
        internal static com.epl.geometry.Geometry Calculate(com.epl.geometry.Geometry geom, com.epl.geometry.ProgressTracker progress_tracker)
        {
            int gt = geom.GetType().Value();

            if (gt == com.epl.geometry.Geometry.GeometryType.Polygon)
            {
                com.epl.geometry.Polyline dst = new com.epl.geometry.Polyline(geom.GetDescription());
                if (!geom.IsEmpty())
                {
                    ((com.epl.geometry.MultiPathImpl)geom._getImpl())._copyToUnsafe((com.epl.geometry.MultiPathImpl)dst._getImpl());
                }
                return(dst);
            }
            else
            {
                if (gt == com.epl.geometry.Geometry.GeometryType.Polyline)
                {
                    return(CalculatePolylineBoundary_(geom._getImpl(), progress_tracker, false, null));
                }
                else
                {
                    if (gt == com.epl.geometry.Geometry.GeometryType.Envelope)
                    {
                        com.epl.geometry.Polyline dst = new com.epl.geometry.Polyline(geom.GetDescription());
                        if (!geom.IsEmpty())
                        {
                            dst.AddEnvelope((com.epl.geometry.Envelope)geom, false);
                        }
                        return(dst);
                    }
                    else
                    {
                        if (com.epl.geometry.Geometry.IsSegment(gt))
                        {
                            com.epl.geometry.MultiPoint mp = new com.epl.geometry.MultiPoint(geom.GetDescription());
                            if (!geom.IsEmpty() && !((com.epl.geometry.Segment)geom).IsClosed())
                            {
                                com.epl.geometry.Point pt = new com.epl.geometry.Point();
                                ((com.epl.geometry.Segment)geom).QueryStart(pt);
                                mp.Add(pt);
                                ((com.epl.geometry.Segment)geom).QueryEnd(pt);
                                mp.Add(pt);
                            }
                            return(mp);
                        }
                        else
                        {
                            if (com.epl.geometry.Geometry.IsPoint(gt))
                            {
                                // returns empty point for points and multipoints.
                                return(null);
                            }
                        }
                    }
                }
            }
            throw new System.ArgumentException();
        }
Example #14
0
 // GEOMTHROW(invalid_call);
 public static void TestPointsInArea2D(com.epl.geometry.Geometry polygon, double[] xyStreamBuffer, int count, double tolerance, com.epl.geometry.PolygonUtils.PiPResult[] testResults)
 {
     if (polygon.GetType() == com.epl.geometry.Geometry.Type.Polygon)
     {
         TestPointsInPolygon2D((com.epl.geometry.Polygon)polygon, xyStreamBuffer, count, tolerance, testResults);
     }
     else
     {
         if (polygon.GetType() == com.epl.geometry.Geometry.Type.Envelope)
         {
             com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
             ((com.epl.geometry.Envelope)polygon).QueryEnvelope2D(env2D);
             _testPointsInEnvelope2D(env2D, xyStreamBuffer, count, tolerance, testResults);
         }
         else
         {
             throw new com.epl.geometry.GeometryException("invalid_call");
         }
     }
 }
Example #15
0
		internal virtual com.epl.geometry.Geometry NormalizeIntersectionOutput(com.epl.geometry.Geometry geom, int GT_1, int GT_2)
		{
			if (GT_1 == com.epl.geometry.Geometry.GeometryType.Point || GT_2 == com.epl.geometry.Geometry.GeometryType.Point)
			{
				System.Diagnostics.Debug.Assert((geom.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Point));
			}
			if (GT_1 == com.epl.geometry.Geometry.GeometryType.MultiPoint)
			{
				if (geom.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Point)
				{
					com.epl.geometry.MultiPoint mp = new com.epl.geometry.MultiPoint(geom.GetDescription());
					if (!geom.IsEmpty())
					{
						mp.Add((com.epl.geometry.Point)geom);
					}
					return mp;
				}
			}
			return geom;
		}
Example #16
0
 internal static bool CanUseQuadTreeForPaths(com.epl.geometry.Geometry geom)
 {
     if (geom.IsEmpty() || !(geom.GetType() == com.epl.geometry.Geometry.Type.Polyline || geom.GetType() == com.epl.geometry.Geometry.Type.Polygon))
     {
         return(false);
     }
     if (((com.epl.geometry.MultiVertexGeometry)geom).GetPointCount() < 20)
     {
         return(false);
     }
     return(true);
 }
Example #17
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);
 }
Example #18
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);
         }
     }
 }
        private static void ExportToJson_(com.epl.geometry.Geometry geometry, com.epl.geometry.SpatialReference spatialReference, com.epl.geometry.JsonWriter jsonWriter, System.Collections.Generic.IDictionary <string, object> exportProperties)
        {
            try
            {
                int type = geometry.GetType().Value();
                switch (type)
                {
                case com.epl.geometry.Geometry.GeometryType.Point:
                {
                    ExportPointToJson((com.epl.geometry.Point)geometry, spatialReference, jsonWriter, exportProperties);
                    break;
                }

                case com.epl.geometry.Geometry.GeometryType.MultiPoint:
                {
                    ExportMultiPointToJson((com.epl.geometry.MultiPoint)geometry, spatialReference, jsonWriter, exportProperties);
                    break;
                }

                case com.epl.geometry.Geometry.GeometryType.Polyline:
                {
                    ExportPolylineToJson((com.epl.geometry.Polyline)geometry, spatialReference, jsonWriter, exportProperties);
                    break;
                }

                case com.epl.geometry.Geometry.GeometryType.Polygon:
                {
                    ExportPolygonToJson((com.epl.geometry.Polygon)geometry, spatialReference, jsonWriter, exportProperties);
                    break;
                }

                case com.epl.geometry.Geometry.GeometryType.Envelope:
                {
                    ExportEnvelopeToJson((com.epl.geometry.Envelope)geometry, spatialReference, jsonWriter, exportProperties);
                    break;
                }

                default:
                {
                    throw new System.Exception("not implemented for this geometry type");
                }
                }
            }
            catch (System.Exception)
            {
            }
        }
        internal static com.epl.geometry.Geometry SymmetricDifference(com.epl.geometry.Geometry geometry_a, com.epl.geometry.Geometry geometry_b, com.epl.geometry.SpatialReference spatial_reference, com.epl.geometry.ProgressTracker progress_tracker)
        {
            int dim_a = geometry_a.GetDimension();
            int dim_b = geometry_b.GetDimension();

            if (geometry_a.IsEmpty() && geometry_b.IsEmpty())
            {
                return(dim_a > dim_b ? geometry_a : geometry_b);
            }
            if (geometry_a.IsEmpty())
            {
                return(geometry_b);
            }
            if (geometry_b.IsEmpty())
            {
                return(geometry_a);
            }
            com.epl.geometry.Envelope2D env_a      = new com.epl.geometry.Envelope2D();
            com.epl.geometry.Envelope2D env_b      = new com.epl.geometry.Envelope2D();
            com.epl.geometry.Envelope2D env_merged = new com.epl.geometry.Envelope2D();
            geometry_a.QueryEnvelope2D(env_a);
            geometry_b.QueryEnvelope2D(env_b);
            env_merged.SetCoords(env_a);
            env_merged.Merge(env_b);
            double tolerance = com.epl.geometry.InternalUtils.CalculateToleranceFromGeometry(spatial_reference, env_merged, false);
            int    type_a    = geometry_a.GetType().Value();
            int    type_b    = geometry_b.GetType().Value();

            if (type_a == com.epl.geometry.Geometry.GeometryType.Point && type_b == com.epl.geometry.Geometry.GeometryType.Point)
            {
                return(PointSymDiffPoint_((com.epl.geometry.Point)(geometry_a), (com.epl.geometry.Point)(geometry_b), tolerance, progress_tracker));
            }
            if (type_a != type_b)
            {
                if (dim_a > 0 || dim_b > 0)
                {
                    return(dim_a > dim_b ? geometry_a : geometry_b);
                }
                // Multi_point/Point case
                if (type_a == com.epl.geometry.Geometry.GeometryType.MultiPoint)
                {
                    return(MultiPointSymDiffPoint_((com.epl.geometry.MultiPoint)(geometry_a), (com.epl.geometry.Point)(geometry_b), tolerance, progress_tracker));
                }
                return(MultiPointSymDiffPoint_((com.epl.geometry.MultiPoint)(geometry_b), (com.epl.geometry.Point)(geometry_a), tolerance, progress_tracker));
            }
            return(com.epl.geometry.TopologicalOperations.SymmetricDifference(geometry_a, geometry_b, spatial_reference, progress_tracker));
        }
Example #21
0
 public override void CopyTo(com.epl.geometry.Geometry dst)
 {
     if (dst.GetType() != GetType())
     {
         throw new System.ArgumentException();
     }
     com.epl.geometry.Segment segDst = (com.epl.geometry.Segment)dst;
     segDst.m_description = m_description;
     segDst._resizeAttributes(m_description.GetTotalComponentCount() - 2);
     _attributeCopy(m_attributes, 0, segDst.m_attributes, 0, (m_description.GetTotalComponentCount() - 2) * 2);
     segDst.m_xStart = m_xStart;
     segDst.m_yStart = m_yStart;
     segDst.m_xEnd   = m_xEnd;
     segDst.m_yEnd   = m_yEnd;
     dst._touch();
     _copyToImpl(segDst);
 }
Example #22
0
 public override void CopyTo(com.epl.geometry.Geometry dst)
 {
     if (dst.GetType() != GetType())
     {
         throw new System.ArgumentException();
     }
     com.epl.geometry.Envelope envDst = (com.epl.geometry.Envelope)dst;
     dst._touch();
     envDst.m_description = m_description;
     envDst.m_envelope.SetCoords(m_envelope);
     envDst.m_attributes = null;
     if (m_attributes != null)
     {
         envDst._ensureAttributes();
         System.Array.Copy(m_attributes, 0, envDst.m_attributes, 0, (m_description.GetTotalComponentCount() - 2) * 2);
     }
 }
        internal static int ExportToESRIShape(int exportFlags, com.epl.geometry.Geometry geometry, System.IO.BinaryWriter shapeBuffer)
        {
            if (geometry == null)
            {
                if (shapeBuffer != null)
                {
                    shapeBuffer.Write(com.epl.geometry.ShapeType.ShapeNull);
                }
                return(4);
            }
            int type = geometry.GetType().Value();

            switch (type)
            {
            case com.epl.geometry.Geometry.GeometryType.Polygon:
            {
                return(ExportMultiPathToESRIShape(true, exportFlags, (com.epl.geometry.MultiPath)geometry, shapeBuffer));
            }

            case com.epl.geometry.Geometry.GeometryType.Polyline:
            {
                return(ExportMultiPathToESRIShape(false, exportFlags, (com.epl.geometry.MultiPath)geometry, shapeBuffer));
            }

            case com.epl.geometry.Geometry.GeometryType.MultiPoint:
            {
                return(ExportMultiPointToESRIShape(exportFlags, (com.epl.geometry.MultiPoint)geometry, shapeBuffer));
            }

            case com.epl.geometry.Geometry.GeometryType.Point:
            {
                return(ExportPointToESRIShape(exportFlags, (com.epl.geometry.Point)geometry, shapeBuffer));
            }

            case com.epl.geometry.Geometry.GeometryType.Envelope:
            {
                return(ExportEnvelopeToESRIShape(exportFlags, (com.epl.geometry.Envelope)geometry, shapeBuffer));
            }

            default:
            {
                throw com.epl.geometry.GeometryException.GeometryInternalError();
            }
            }
        }
Example #24
0
		internal OperatorIntersectionCursor(com.epl.geometry.GeometryCursor inputGeoms, com.epl.geometry.GeometryCursor geomIntersector, com.epl.geometry.SpatialReference sr, com.epl.geometry.ProgressTracker progress_tracker, int dimensionMask)
		{
			// holds empty geometry of intersector
			// type.
			m_bEmpty = geomIntersector == null;
			m_index = -1;
			m_inputGeoms = inputGeoms;
			m_spatial_reference = sr;
			m_geomIntersector = geomIntersector.Next();
			m_geomIntersectorType = m_geomIntersector.GetType().Value();
			m_currentGeomType = com.epl.geometry.Geometry.Type.Unknown.Value();
			m_progress_tracker = progress_tracker;
			m_dimensionMask = dimensionMask;
			if (m_dimensionMask != -1 && (m_dimensionMask <= 0 || m_dimensionMask > 7))
			{
				throw new System.ArgumentException("bad dimension mask");
			}
		}
Example #25
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.");
         }
     }
 }
        private com.epl.geometry.Geometry DensifyByLength(com.epl.geometry.Geometry geom)
        {
            if (geom.IsEmpty() || geom.GetDimension() < 1)
            {
                return(geom);
            }
            int geometryType = geom.GetType().Value();

            // TODO implement IsMultiPath and remove Polygon and Polyline call to
            // match Native
            // if (Geometry.IsMultiPath(geometryType))
            if (geometryType == com.epl.geometry.Geometry.GeometryType.Polygon)
            {
                return(DensifyMultiPath((com.epl.geometry.MultiPath)geom));
            }
            else
            {
                if (com.epl.geometry.Geometry.GeometryType.Polyline == geometryType)
                {
                    return(DensifyMultiPath((com.epl.geometry.MultiPath)geom));
                }
                else
                {
                    if (com.epl.geometry.Geometry.IsSegment(geometryType))
                    {
                        return(DensifySegment((com.epl.geometry.Segment)geom));
                    }
                    else
                    {
                        if (geometryType == com.epl.geometry.Geometry.GeometryType.Envelope)
                        {
                            return(DensifyEnvelope((com.epl.geometry.Envelope)geom));
                        }
                        else
                        {
                            // TODO fix geometry exception to match native implementation
                            throw com.epl.geometry.GeometryException.GeometryInternalError();
                        }
                    }
                }
            }
        }
Example #27
0
        private static void ExportGeometryToGeoJson_(int export_flags, com.epl.geometry.Geometry geometry, com.epl.geometry.JsonWriter json_writer)
        {
            int type = geometry.GetType().Value();

            switch (type)
            {
            case com.epl.geometry.Geometry.GeometryType.Polygon:
            {
                ExportPolygonToGeoJson_(export_flags, (com.epl.geometry.Polygon)geometry, json_writer);
                return;
            }

            case com.epl.geometry.Geometry.GeometryType.Polyline:
            {
                ExportPolylineToGeoJson_(export_flags, (com.epl.geometry.Polyline)geometry, json_writer);
                return;
            }

            case com.epl.geometry.Geometry.GeometryType.MultiPoint:
            {
                ExportMultiPointToGeoJson_(export_flags, (com.epl.geometry.MultiPoint)geometry, json_writer);
                return;
            }

            case com.epl.geometry.Geometry.GeometryType.Point:
            {
                ExportPointToGeoJson_(export_flags, (com.epl.geometry.Point)geometry, json_writer);
                return;
            }

            case com.epl.geometry.Geometry.GeometryType.Envelope:
            {
                ExportEnvelopeToGeoJson_(export_flags, (com.epl.geometry.Envelope)geometry, json_writer);
                return;
            }

            default:
            {
                throw new System.Exception("not implemented for this geometry type");
            }
            }
        }
Example #28
0
        public override com.epl.geometry.Proximity2DResult GetNearestCoordinate(com.epl.geometry.Geometry geom, com.epl.geometry.Point inputPoint, bool bTestPolygonInterior, bool bCalculateLeftRightSide)
        {
            if (geom.IsEmpty())
            {
                return(new com.epl.geometry.Proximity2DResult());
            }
            com.epl.geometry.Point2D  inputPoint2D     = inputPoint.GetXY();
            com.epl.geometry.Geometry proxmityTestGeom = geom;
            int gt = geom.GetType().Value();

            if (gt == com.epl.geometry.Geometry.GeometryType.Envelope)
            {
                com.epl.geometry.Polygon polygon = new com.epl.geometry.Polygon();
                polygon.AddEnvelope((com.epl.geometry.Envelope)geom, false);
                proxmityTestGeom = polygon;
                gt = com.epl.geometry.Geometry.GeometryType.Polygon;
            }
            switch (gt)
            {
            case com.epl.geometry.Geometry.GeometryType.Point:
            {
                return(PointGetNearestVertex((com.epl.geometry.Point)proxmityTestGeom, inputPoint2D));
            }

            case com.epl.geometry.Geometry.GeometryType.MultiPoint:
            {
                return(MultiVertexGetNearestVertex((com.epl.geometry.MultiVertexGeometry)proxmityTestGeom, inputPoint2D));
            }

            case com.epl.geometry.Geometry.GeometryType.Polyline:
            case com.epl.geometry.Geometry.GeometryType.Polygon:
            {
                return(MultiPathGetNearestCoordinate((com.epl.geometry.MultiPath)proxmityTestGeom, inputPoint2D, bTestPolygonInterior, bCalculateLeftRightSide));
            }

            default:
            {
                throw new com.epl.geometry.GeometryException("not implemented");
            }
            }
        }
Example #29
0
        public override com.epl.geometry.Proximity2DResult[] GetNearestVertices(com.epl.geometry.Geometry geom, com.epl.geometry.Point inputPoint, double searchRadius, int maxVertexCountToReturn)
        {
            if (maxVertexCountToReturn < 0)
            {
                throw new System.ArgumentException();
            }
            if (geom.IsEmpty())
            {
                return(new com.epl.geometry.Proximity2DResult[] {  });
            }
            com.epl.geometry.Point2D  inputPoint2D     = inputPoint.GetXY();
            com.epl.geometry.Geometry proxmityTestGeom = geom;
            int gt = geom.GetType().Value();

            if (gt == com.epl.geometry.Geometry.GeometryType.Envelope)
            {
                com.epl.geometry.Polygon polygon = new com.epl.geometry.Polygon();
                polygon.AddEnvelope((com.epl.geometry.Envelope)geom, false);
                proxmityTestGeom = polygon;
                gt = com.epl.geometry.Geometry.GeometryType.Polygon;
            }
            switch (gt)
            {
            case com.epl.geometry.Geometry.GeometryType.Point:
            {
                return(PointGetNearestVertices((com.epl.geometry.Point)proxmityTestGeom, inputPoint2D, searchRadius, maxVertexCountToReturn));
            }

            case com.epl.geometry.Geometry.GeometryType.MultiPoint:
            case com.epl.geometry.Geometry.GeometryType.Polyline:
            case com.epl.geometry.Geometry.GeometryType.Polygon:
            {
                return(MultiVertexGetNearestVertices((com.epl.geometry.MultiVertexGeometry)proxmityTestGeom, inputPoint2D, searchRadius, maxVertexCountToReturn));
            }

            default:
            {
                throw new com.epl.geometry.GeometryException("not implemented");
            }
            }
        }
Example #30
0
 public override void CopyTo(com.epl.geometry.Geometry dst)
 {
     if (dst.GetType() != com.epl.geometry.Geometry.Type.Point)
     {
         throw new System.ArgumentException();
     }
     com.epl.geometry.Point pointDst = (com.epl.geometry.Point)dst;
     dst._touch();
     if (m_attributes == null)
     {
         pointDst.SetEmpty();
         pointDst.m_attributes = null;
         pointDst.AssignVertexDescription(m_description);
     }
     else
     {
         pointDst.AssignVertexDescription(m_description);
         pointDst.ResizeAttributes(m_description.GetTotalComponentCount());
         AttributeCopy(m_attributes, pointDst.m_attributes, m_description.GetTotalComponentCount());
     }
 }