コード例 #1
0
 public static void TestPointInPolygonBugCR181840()
 {
     com.epl.geometry.PolygonUtils.PiPResult res;
     {
         // pointInPolygonBugCR181840 - point in polygon bug
         com.epl.geometry.Polygon polygon = new com.epl.geometry.Polygon();
         // outer ring1
         polygon.StartPath(0, 0);
         polygon.LineTo(10, 10);
         polygon.LineTo(20, 0);
         res = com.epl.geometry.PolygonUtils.IsPointInPolygon2D(polygon, com.epl.geometry.Point2D.Construct(15, 10), 0);
         NUnit.Framework.Assert.IsTrue(res == com.epl.geometry.PolygonUtils.PiPResult.PiPOutside);
         res = com.epl.geometry.PolygonUtils.IsPointInPolygon2D(polygon, com.epl.geometry.Point2D.Construct(2, 10), 0);
         NUnit.Framework.Assert.IsTrue(res == com.epl.geometry.PolygonUtils.PiPResult.PiPOutside);
         res = com.epl.geometry.PolygonUtils.IsPointInPolygon2D(polygon, com.epl.geometry.Point2D.Construct(5, 5), 0);
         NUnit.Framework.Assert.IsTrue(res == com.epl.geometry.PolygonUtils.PiPResult.PiPInside);
     }
     {
         // CR181840 - point in polygon bug
         com.epl.geometry.Polygon polygon = new com.epl.geometry.Polygon();
         // outer ring1
         polygon.StartPath(10, 10);
         polygon.LineTo(20, 0);
         polygon.LineTo(0, 0);
         res = com.epl.geometry.PolygonUtils.IsPointInPolygon2D(polygon, com.epl.geometry.Point2D.Construct(15, 10), 0);
         NUnit.Framework.Assert.IsTrue(res == com.epl.geometry.PolygonUtils.PiPResult.PiPOutside);
         res = com.epl.geometry.PolygonUtils.IsPointInPolygon2D(polygon, com.epl.geometry.Point2D.Construct(2, 10), 0);
         NUnit.Framework.Assert.IsTrue(res == com.epl.geometry.PolygonUtils.PiPResult.PiPOutside);
         res = com.epl.geometry.PolygonUtils.IsPointInPolygon2D(polygon, com.epl.geometry.Point2D.Construct(5, 5), 0);
         NUnit.Framework.Assert.IsTrue(res == com.epl.geometry.PolygonUtils.PiPResult.PiPInside);
     }
 }
コード例 #2
0
        internal static com.epl.geometry.Geometry PolylineMinusArea_(com.epl.geometry.Geometry geometry, com.epl.geometry.Geometry area, int area_type, com.epl.geometry.SpatialReference sr, com.epl.geometry.ProgressTracker progress_tracker)
        {
            // construct the complement of the Polygon (or Envelope)
            com.epl.geometry.Envelope envelope = new com.epl.geometry.Envelope();
            geometry.QueryEnvelope(envelope);
            com.epl.geometry.Envelope2D env_2D = new com.epl.geometry.Envelope2D();
            area.QueryEnvelope2D(env_2D);
            envelope.Merge(env_2D);
            double dw = 0.1 * envelope.GetWidth();
            double dh = 0.1 * envelope.GetHeight();

            envelope.Inflate(dw, dh);
            com.epl.geometry.Polygon complement = new com.epl.geometry.Polygon();
            complement.AddEnvelope(envelope, false);
            com.epl.geometry.MultiPathImpl complementImpl = (com.epl.geometry.MultiPathImpl)(complement._getImpl());
            if (area_type == com.epl.geometry.Geometry.GeometryType.Polygon)
            {
                com.epl.geometry.MultiPathImpl polygonImpl = (com.epl.geometry.MultiPathImpl)(area._getImpl());
                complementImpl.Add(polygonImpl, true);
            }
            else
            {
                complementImpl.AddEnvelope((com.epl.geometry.Envelope)(area), true);
            }
            com.epl.geometry.OperatorFactoryLocal projEnv = com.epl.geometry.OperatorFactoryLocal.GetInstance();
            com.epl.geometry.OperatorIntersection operatorIntersection = (com.epl.geometry.OperatorIntersection)projEnv.GetOperator(com.epl.geometry.Operator.Type.Intersection);
            com.epl.geometry.Geometry             difference           = operatorIntersection.Execute(geometry, complement, sr, progress_tracker);
            return(difference);
        }
コード例 #3
0
        public virtual void TestPointAndPolygon3()
        {
            com.epl.geometry.Point   basePl = new com.epl.geometry.Point(-121, 20);
            com.epl.geometry.Polygon compPl = new com.epl.geometry.Polygon();
            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(), -121, 0.1E7);
            NUnit.Framework.Assert.AreEqual(ip.GetY(), 20, 0.1E7);
        }
コード例 #4
0
        public virtual void TestIntersectBetweenPolylineAndPolygon()
        {
            com.epl.geometry.Polyline basePl = new com.epl.geometry.Polyline();
            basePl.StartPath(new com.epl.geometry.Point(-117, 20));
            basePl.LineTo(new com.epl.geometry.Point(-117, 10));
            basePl.LineTo(new com.epl.geometry.Point(-130, 10));
            basePl.LineTo(new com.epl.geometry.Point(-130, 20));
            basePl.LineTo(new com.epl.geometry.Point(-117, 20));
            com.epl.geometry.Polygon compPl = new com.epl.geometry.Polygon();
            compPl.StartPath(-116, 20);
            compPl.LineTo(-131, 10);
            compPl.LineTo(-121, 50);
            com.epl.geometry.Geometry intersectGeom = null;
            int noException = 1;

            // no exception
            try
            {
                intersectGeom = com.epl.geometry.GeometryEngine.Intersect(basePl, compPl, com.epl.geometry.SpatialReference.Create(4326));
            }
            catch (System.Exception)
            {
                noException = 0;
            }
            NUnit.Framework.Assert.IsNotNull(intersectGeom);
        }
コード例 #5
0
        public virtual void TestGeometryCollection()
        {
            com.epl.geometry.SpatialReference sr         = com.epl.geometry.SpatialReference.Create(4326);
            System.Text.StringBuilder         geometrySb = new System.Text.StringBuilder();
            geometrySb.Append("{\"type\" : \"GeometryCollection\", \"geometries\" : [");
            com.epl.geometry.ogc.OGCPoint point = new com.epl.geometry.ogc.OGCPoint(new com.epl.geometry.Point(1.0, 1.0), sr);
            NUnit.Framework.Assert.AreEqual("{\"x\":1,\"y\":1,\"spatialReference\":{\"wkid\":4326}}", point.AsJson());
            NUnit.Framework.Assert.AreEqual("{\"type\":\"Point\",\"coordinates\":[1,1],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", point.AsGeoJson());
            geometrySb.Append(point.AsGeoJson()).Append(", ");
            com.epl.geometry.ogc.OGCLineString line = new com.epl.geometry.ogc.OGCLineString(new com.epl.geometry.Polyline(new com.epl.geometry.Point(1.0, 1.0), new com.epl.geometry.Point(2.0, 2.0)), 0, sr);
            NUnit.Framework.Assert.AreEqual("{\"paths\":[[[1,1],[2,2]]],\"spatialReference\":{\"wkid\":4326}}", line.AsJson());
            NUnit.Framework.Assert.AreEqual("{\"type\":\"LineString\",\"coordinates\":[[1,1],[2,2]],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", line.AsGeoJson());
            geometrySb.Append(line.AsGeoJson()).Append(", ");
            com.epl.geometry.Polygon p = new com.epl.geometry.Polygon();
            p.StartPath(1.0, 1.0);
            p.LineTo(2.0, 2.0);
            p.LineTo(3.0, 1.0);
            p.LineTo(2.0, 0.0);
            com.epl.geometry.ogc.OGCPolygon polygon = new com.epl.geometry.ogc.OGCPolygon(p, sr);
            NUnit.Framework.Assert.AreEqual("{\"rings\":[[[1,1],[2,2],[3,1],[2,0],[1,1]]],\"spatialReference\":{\"wkid\":4326}}", polygon.AsJson());
            NUnit.Framework.Assert.AreEqual("{\"type\":\"Polygon\",\"coordinates\":[[[1,1],[2,0],[3,1],[2,2],[1,1]]],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", polygon.AsGeoJson());
            geometrySb.Append(polygon.AsGeoJson()).Append("]}");
            System.Collections.Generic.IList <com.epl.geometry.ogc.OGCGeometry> geoms = new System.Collections.Generic.List <com.epl.geometry.ogc.OGCGeometry>(3);
            geoms.Add(point);
            geoms.Add(line);
            geoms.Add(polygon);
            com.epl.geometry.ogc.OGCConcreteGeometryCollection collection = new com.epl.geometry.ogc.OGCConcreteGeometryCollection(geoms, sr);
            string s2 = collection.AsGeoJson();

            NUnit.Framework.Assert.AreEqual("{\"type\":\"GeometryCollection\",\"geometries\":[{\"type\":\"Point\",\"coordinates\":[1,1]},{\"type\":\"LineString\",\"coordinates\":[[1,1],[2,2]]},{\"type\":\"Polygon\",\"coordinates\":[[[1,1],[2,0],[3,1],[2,2],[1,1]]]}],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}"
                                            , collection.AsGeoJson());
        }
コード例 #6
0
 public virtual void TestPolygon()
 {
     com.epl.geometry.Polygon polygon = new com.epl.geometry.Polygon();
     polygon.StartPath(-97.06138, 32.837);
     polygon.LineTo(-97.06133, 32.836);
     polygon.LineTo(-97.06124, 32.834);
     polygon.LineTo(-97.06127, 32.832);
     polygon.StartPath(-97.06326, 32.759);
     polygon.LineTo(-97.06298, 32.755);
     {
         com.fasterxml.jackson.core.JsonParser polygonPathsWgs84Parser = factory.CreateJsonParser(com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWGS84, polygon));
         com.epl.geometry.MapGeometry          mPolygonWGS84MP         = com.epl.geometry.GeometryEngine.JsonToGeometry(polygonPathsWgs84Parser);
         NUnit.Framework.Assert.IsTrue(polygon.GetPointCount() + 1 == ((com.epl.geometry.Polygon)mPolygonWGS84MP.GetGeometry()).GetPointCount());
         NUnit.Framework.Assert.IsTrue(polygon.GetPoint(0).GetX() == ((com.epl.geometry.Polygon)mPolygonWGS84MP.GetGeometry()).GetPoint(0).GetX());
         NUnit.Framework.Assert.IsTrue(polygon.GetPoint(0).GetY() == ((com.epl.geometry.Polygon)mPolygonWGS84MP.GetGeometry()).GetPoint(0).GetY());
         NUnit.Framework.Assert.IsTrue(polygon.GetPathCount() == ((com.epl.geometry.Polygon)mPolygonWGS84MP.GetGeometry()).GetPathCount());
         NUnit.Framework.Assert.IsTrue(polygon.GetSegmentCount() + 1 == ((com.epl.geometry.Polygon)mPolygonWGS84MP.GetGeometry()).GetSegmentCount());
         NUnit.Framework.Assert.IsTrue(polygon.GetSegmentCount(0) == ((com.epl.geometry.Polygon)mPolygonWGS84MP.GetGeometry()).GetSegmentCount(0));
         NUnit.Framework.Assert.IsTrue(polygon.GetSegmentCount(1) + 1 == ((com.epl.geometry.Polygon)mPolygonWGS84MP.GetGeometry()).GetSegmentCount(1));
         int lastIndex = polygon.GetPointCount() - 1;
         NUnit.Framework.Assert.IsTrue(polygon.GetPoint(lastIndex).GetX() == ((com.epl.geometry.Polygon)mPolygonWGS84MP.GetGeometry()).GetPoint(lastIndex).GetX());
         NUnit.Framework.Assert.IsTrue(polygon.GetPoint(lastIndex).GetY() == ((com.epl.geometry.Polygon)mPolygonWGS84MP.GetGeometry()).GetPoint(lastIndex).GetY());
         NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.GetID() == mPolygonWGS84MP.GetSpatialReference().GetID());
         com.epl.geometry.Polygon emptyPolygon = new com.epl.geometry.Polygon();
         string emptyPolygonString             = com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWGS84, emptyPolygon);
         polygonPathsWgs84Parser = factory.CreateJsonParser(emptyPolygonString);
         mPolygonWGS84MP         = com.epl.geometry.GeometryEngine.JsonToGeometry(polygonPathsWgs84Parser);
         NUnit.Framework.Assert.IsTrue(mPolygonWGS84MP.GetGeometry().IsEmpty());
         NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.GetID() == mPolygonWGS84MP.GetSpatialReference().GetID());
     }
 }
コード例 #7
0
        public virtual void TestGeometryToJSONOldID()
        {
            // CR
            com.epl.geometry.Polygon geom = new com.epl.geometry.Polygon();
            geom.StartPath(new com.epl.geometry.Point(-113, 34));
            geom.LineTo(new com.epl.geometry.Point(-105, 34));
            geom.LineTo(new com.epl.geometry.Point(-108, 40));
            string outputPolygon = com.epl.geometry.GeometryEngine.GeometryToJson(com.epl.geometry.SpatialReference.Create(3857), geom);
            // Test
            // WKID
            // ==
            // -1
            string correctPolygon = "{\"rings\":[[[-113,34],[-105,34],[-108,40],[-113,34]]],\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}";

            NUnit.Framework.Assert.IsTrue(outputPolygon.Equals(correctPolygon));
            com.fasterxml.jackson.core.JsonFactory jf = new com.fasterxml.jackson.core.JsonFactory();
            com.fasterxml.jackson.core.JsonParser  jp = jf.CreateJsonParser(outputPolygon);
            jp.NextToken();
            com.epl.geometry.MapGeometry mg = com.epl.geometry.GeometryEngine.JsonToGeometry(jp);
            int srId    = mg.GetSpatialReference().GetID();
            int srOldId = mg.GetSpatialReference().GetOldID();

            NUnit.Framework.Assert.IsTrue(mg.GetSpatialReference().GetID() == 3857);
            NUnit.Framework.Assert.IsTrue(mg.GetSpatialReference().GetLatestID() == 3857);
            NUnit.Framework.Assert.IsTrue(mg.GetSpatialReference().GetOldID() == 102100);
        }
コード例 #8
0
        private static int _isPointInPolygonInternalWithQuadTree(com.epl.geometry.Polygon inputPolygon, com.epl.geometry.QuadTreeImpl quadTree, com.epl.geometry.Point2D inputPoint, double tolerance)
        {
            com.epl.geometry.Envelope2D envPoly = new com.epl.geometry.Envelope2D();
            inputPolygon.QueryLooseEnvelope(envPoly);
            envPoly.Inflate(tolerance, tolerance);
            bool bAltenate = inputPolygon.GetFillRule() == com.epl.geometry.Polygon.FillRule.enumFillRuleOddEven;

            com.epl.geometry.PointInPolygonHelper helper   = new com.epl.geometry.PointInPolygonHelper(bAltenate, inputPoint, tolerance);
            com.epl.geometry.MultiPathImpl        mpImpl   = (com.epl.geometry.MultiPathImpl)inputPolygon._getImpl();
            com.epl.geometry.SegmentIteratorImpl  iter     = mpImpl.QuerySegmentIterator();
            com.epl.geometry.Envelope2D           queryEnv = new com.epl.geometry.Envelope2D();
            queryEnv.SetCoords(envPoly);
            queryEnv.xmax = inputPoint.x + tolerance;
            // no need to query segments to
            // the right of the point.
            // Only segments to the left
            // matter.
            queryEnv.ymin = inputPoint.y - tolerance;
            queryEnv.ymax = inputPoint.y + tolerance;
            com.epl.geometry.QuadTreeImpl.QuadTreeIteratorImpl qiter = quadTree.GetIterator(queryEnv, tolerance);
            for (int qhandle = qiter.Next(); qhandle != -1; qhandle = qiter.Next())
            {
                iter.ResetToVertex(quadTree.GetElement(qhandle));
                if (iter.HasNextSegment())
                {
                    com.epl.geometry.Segment segment = iter.NextSegment();
                    if (helper.ProcessSegment(segment))
                    {
                        return(-1);
                    }
                }
            }
            // point on boundary
            return(helper.Result());
        }
コード例 #9
0
 internal static com.epl.geometry.Polygon MakePolygon()
 {
     com.epl.geometry.Polygon poly = new com.epl.geometry.Polygon();
     poly.StartPath(0, 0);
     poly.LineTo(10, 10);
     poly.LineTo(20, 0);
     return(poly);
 }
コード例 #10
0
 public virtual com.epl.geometry.ogc.OGCGeometry Envelope()
 {
     com.epl.geometry.Envelope env = new com.epl.geometry.Envelope();
     GetEsriGeometry().QueryEnvelope(env);
     com.epl.geometry.Polygon polygon = new com.epl.geometry.Polygon();
     polygon.AddEnvelope(env, false);
     return(new com.epl.geometry.ogc.OGCPolygon(polygon, esriSR));
 }
コード例 #11
0
 public static int IsPointInPolygon(com.epl.geometry.Polygon inputPolygon, com.epl.geometry.Point inputPoint, double tolerance)
 {
     if (inputPoint.IsEmpty())
     {
         return(0);
     }
     return(IsPointInPolygon(inputPolygon, inputPoint.GetXY(), tolerance));
 }
コード例 #12
0
 public OGCPolygon(com.epl.geometry.Polygon geom, com.epl.geometry.SpatialReference sr)
 {
     polygon = geom;
     if (geom.GetExteriorRingCount() > 1)
     {
         throw new System.ArgumentException("Polygon has to have one exterior ring. Simplify geom with OperatorSimplify.");
     }
     esriSR = sr;
 }
コード例 #13
0
 public static com.epl.geometry.Polygon MakePolygon2()
 {
     com.epl.geometry.Polygon poly = new com.epl.geometry.Polygon();
     poly.StartPath(5, 5);
     poly.LineTo(5, 15);
     poly.LineTo(15, 15);
     poly.LineTo(15, 5);
     return(poly);
 }
コード例 #14
0
 public static com.epl.geometry.Polygon MakePolygon8()
 {
     com.epl.geometry.Polygon poly = new com.epl.geometry.Polygon();
     poly.StartPath(0, 0);
     poly.LineTo(0, 30);
     poly.LineTo(30, 30);
     poly.LineTo(30, 0);
     return(poly);
 }
コード例 #15
0
 internal virtual com.epl.geometry.Polygon MakePolygon2()
 {
     com.epl.geometry.Polygon poly = new com.epl.geometry.Polygon();
     poly.StartPath(0, 0);
     poly.LineTo(0, 10);
     poly.LineTo(10, 10);
     poly.LineTo(10, 0);
     return(poly);
 }
コード例 #16
0
        private static int QuickTest2DPolygonPolygon(com.epl.geometry.Polygon geomA, com.epl.geometry.Polygon geomB, double tolerance)
        {
            int res = QuickTest2DMVMVRasterOnly(geomA, geomB, tolerance);

            if (res > 0)
            {
                return(res);
            }
            // TODO: implement me
            return(0);
        }
コード例 #17
0
        public virtual void TestEmptyPolygon()
        {
            com.epl.geometry.Polygon p = new com.epl.geometry.Polygon();
            com.epl.geometry.OperatorExportToGeoJson exporter = (com.epl.geometry.OperatorExportToGeoJson)factory.GetOperator(com.epl.geometry.Operator.Type.ExportToGeoJson);
            string result = exporter.Execute(p);

            NUnit.Framework.Assert.AreEqual("{\"type\":\"Polygon\",\"coordinates\":[]}", result);
            com.epl.geometry.MapGeometry imported = com.epl.geometry.OperatorImportFromGeoJson.Local().Execute(0, com.epl.geometry.Geometry.Type.Unknown, result, null);
            NUnit.Framework.Assert.IsTrue(imported.GetGeometry().IsEmpty());
            NUnit.Framework.Assert.IsTrue(imported.GetGeometry().GetType() == com.epl.geometry.Geometry.Type.Polygon);
        }
コード例 #18
0
        private static int QuickTest2DPolygonEnvelope(com.epl.geometry.Polygon geomA, com.epl.geometry.Envelope2D geomBEnv, double tolerance)
        {
            int res = QuickTest2DMVEnvelopeRasterOnly(geomA, geomBEnv, tolerance);

            if (res > 0)
            {
                return(res);
            }
            // TODO: implement me
            return(0);
        }
コード例 #19
0
 internal static void TestPointsInPolygon2D(com.epl.geometry.Polygon polygon, double[] xyStreamBuffer, int pointCount, double tolerance, com.epl.geometry.PolygonUtils.PiPResult[] testResults)
 {
     if (xyStreamBuffer.Length / 2 < pointCount || testResults.Length < pointCount)
     {
         throw new System.ArgumentException();
     }
     // GEOMTHROW(invalid_argument);
     for (int i = 0; i < pointCount; i++)
     {
         testResults[i] = IsPointInPolygon2D(polygon, xyStreamBuffer[i * 2], xyStreamBuffer[i * 2 + 1], tolerance);
     }
 }
コード例 #20
0
 // we do not return PiPBoundary. Overwise,
 // we would have to do more complex
 // calculations to differentiat between
 // internal and external boundaries.
 /// <summary>Tests point is inside the Polygon for an array of points.</summary>
 /// <remarks>
 /// Tests point is inside the Polygon for an array of points. Returns
 /// PiPOutside if not in polygon, PiPInside if in the polygon, PiPBoundary is
 /// if on the border. It tests border only if the tolerance is greater than 0, otherwise
 /// PiPBoundary cannot be returned. Note: If the tolerance is not 0, the test
 /// is more expensive.
 /// O(n*m) complexity, where n is the number of polygon segments, m is the
 /// number of input points.
 /// </remarks>
 public static void TestPointsInPolygon2D(com.epl.geometry.Polygon polygon, com.epl.geometry.Point2D[] inputPoints, int count, double tolerance, com.epl.geometry.PolygonUtils.PiPResult[] testResults)
 {
     if (inputPoints.Length < count || testResults.Length < count)
     {
         throw new System.ArgumentException();
     }
     // GEOMTHROW(invalid_argument);
     for (int i = 0; i < count; i++)
     {
         testResults[i] = IsPointInPolygon2D(polygon, inputPoints[i], tolerance);
     }
 }
コード例 #21
0
        public virtual void TestPolygonGeometryEngine()
        {
            com.epl.geometry.Polygon p = new com.epl.geometry.Polygon();
            p.StartPath(100.0, 0.0);
            p.LineTo(101.0, 0.0);
            p.LineTo(101.0, 1.0);
            p.LineTo(100.0, 1.0);
            p.ClosePathWithLine();
            string result = com.epl.geometry.GeometryEngine.GeometryToGeoJson(p);

            NUnit.Framework.Assert.AreEqual("{\"type\":\"Polygon\",\"coordinates\":[[[100,0],[100,1],[101,1],[101,0],[100,0]]]}", result);
        }
コード例 #22
0
 public OGCPolygon(com.epl.geometry.Polygon src, int exteriorRing, com.epl.geometry.SpatialReference sr)
 {
     polygon = new com.epl.geometry.Polygon();
     for (int i = exteriorRing, n = src.GetPathCount(); i < n; i++)
     {
         if (i > exteriorRing && src.IsExteriorRing(i))
         {
             break;
         }
         polygon.AddPath(src, i, true);
     }
     esriSR = sr;
 }
コード例 #23
0
 private static com.epl.geometry.Polygon MakePolygon()
 {
     com.epl.geometry.Polygon poly = new com.epl.geometry.Polygon();
     poly.StartPath(0, 0);
     poly.LineTo(0, 10);
     poly.LineTo(10, 10);
     poly.LineTo(10, 0);
     poly.StartPath(3, 3);
     poly.LineTo(7, 3);
     poly.LineTo(7, 7);
     poly.LineTo(3, 7);
     return(poly);
 }
コード例 #24
0
        public virtual void TestOGCPolygon()
        {
            com.epl.geometry.Polygon p = new com.epl.geometry.Polygon();
            p.StartPath(100.0, 0.0);
            p.LineTo(101.0, 0.0);
            p.LineTo(101.0, 1.0);
            p.LineTo(100.0, 1.0);
            p.ClosePathWithLine();
            com.epl.geometry.ogc.OGCPolygon ogcPolygon = new com.epl.geometry.ogc.OGCPolygon(p, null);
            string result = ogcPolygon.AsGeoJson();

            NUnit.Framework.Assert.AreEqual("{\"type\":\"Polygon\",\"coordinates\":[[[100,0],[100,1],[101,1],[101,0],[100,0]]],\"crs\":null}", result);
        }
コード例 #25
0
        public virtual void TestPolygon()
        {
            com.epl.geometry.Polygon p = new com.epl.geometry.Polygon();
            p.StartPath(100.0, 0.0);
            p.LineTo(101.0, 0.0);
            p.LineTo(101.0, 1.0);
            p.LineTo(100.0, 1.0);
            p.ClosePathWithLine();
            com.epl.geometry.OperatorExportToGeoJson exporter = (com.epl.geometry.OperatorExportToGeoJson)factory.GetOperator(com.epl.geometry.Operator.Type.ExportToGeoJson);
            string result = exporter.Execute(p);

            NUnit.Framework.Assert.AreEqual("{\"type\":\"Polygon\",\"coordinates\":[[[100,0],[100,1],[101,1],[101,0],[100,0]]]}", result);
        }
コード例 #26
0
 public static void TestClipIssue258243()
 {
     com.epl.geometry.Polygon poly1 = new com.epl.geometry.Polygon();
     poly1.StartPath(21.476191371901479, 41.267022001907215);
     poly1.LineTo(59.669186665158051, 36.62700518555863);
     poly1.LineTo(20.498578117352313, 30.363180148246094);
     poly1.LineTo(18.342565836615044, 46.303295352085627);
     poly1.LineTo(17.869569458621626, 23.886816966894159);
     poly1.LineTo(19.835465558090434, 20);
     poly1.LineTo(18.83911285048551, 43.515995498114791);
     poly1.LineTo(20.864485260298004, 20.235921201027757);
     poly1.LineTo(18.976127544787012, 20);
     poly1.LineTo(34.290201277718218, 61.801369014954794);
     poly1.LineTo(20.734727419368866, 20);
     poly1.LineTo(18.545865698148113, 20);
     poly1.LineTo(19.730260558565515, 20);
     poly1.LineTo(19.924806216827005, 23.780315893949187);
     poly1.LineTo(21.675168105421452, 36.699924873001258);
     poly1.LineTo(22.500527828912158, 43.703424859922983);
     poly1.LineTo(42.009527116514818, 36.995486982256089);
     poly1.LineTo(24.469729873835782, 58.365871758247039);
     poly1.LineTo(24.573736036545878, 36.268390409195824);
     poly1.LineTo(22.726502169802746, 20);
     poly1.LineTo(23.925834885228145, 20);
     poly1.LineTo(25.495346880936729, 20);
     poly1.LineTo(23.320941499288317, 20);
     poly1.LineTo(24.05655665646276, 28.659578774758632);
     poly1.LineTo(23.205940789341135, 38.491506888710504);
     poly1.LineTo(21.472847203385509, 53.057228182018044);
     poly1.LineTo(25.04257681654104, 20);
     poly1.LineTo(25.880572351149542, 25.16102863979474);
     poly1.LineTo(26.756283333879658, 20);
     poly1.LineTo(21.476191371901479, 41.267022001907215);
     com.epl.geometry.Envelope2D env = new com.epl.geometry.Envelope2D();
     env.SetCoords(24.269517325186033, 19.999998900000001, 57.305574253225409, 61.801370114954793);
     try
     {
         com.epl.geometry.Geometry output_geom = com.epl.geometry.OperatorClip.Local().Execute(poly1, env, com.epl.geometry.SpatialReference.Create(4326), null);
         com.epl.geometry.Envelope envPoly     = new com.epl.geometry.Envelope();
         poly1.QueryEnvelope(envPoly);
         com.epl.geometry.Envelope e = new com.epl.geometry.Envelope(env);
         e.Intersect(envPoly);
         com.epl.geometry.Envelope clippedEnv = new com.epl.geometry.Envelope();
         output_geom.QueryEnvelope(clippedEnv);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(clippedEnv.GetXMin() - e.GetXMin()) < 1e-10 && System.Math.Abs(clippedEnv.GetYMin() - e.GetYMin()) < 1e-10 && System.Math.Abs(clippedEnv.GetXMax() - e.GetXMax()) < 1e-10 && System.Math.Abs(clippedEnv.GetYMax() - e.GetYMax()) < 1e-10);
     }
     catch (System.Exception)
     {
         NUnit.Framework.Assert.IsTrue(false);
     }
 }
コード例 #27
0
 public static void TestArcObjectsFailureCR196492()
 {
     com.epl.geometry.OperatorFactoryLocal engine = com.epl.geometry.OperatorFactoryLocal.GetInstance();
     com.epl.geometry.OperatorClip         clipOp = (com.epl.geometry.OperatorClip)engine.GetOperator(com.epl.geometry.Operator.Type.Clip);
     com.epl.geometry.Polygon polygon             = new com.epl.geometry.Polygon();
     polygon.AddEnvelope(new com.epl.geometry.Envelope2D(0, 0, 600, 600), false);
     polygon.StartPath(30, 300);
     polygon.LineTo(20, 310);
     polygon.LineTo(10, 300);
     com.epl.geometry.SpatialReference gcsWGS84       = com.epl.geometry.SpatialReference.Create(4326);
     com.epl.geometry.Envelope2D       envelopeCR     = new com.epl.geometry.Envelope2D(10, 10, 500, 500);
     com.epl.geometry.Polygon          clippedPolygon = (com.epl.geometry.Polygon)clipOp.Execute(polygon, envelopeCR, gcsWGS84, null);
     NUnit.Framework.Assert.IsTrue(clippedPolygon.GetPointCount() == 7);
 }
コード例 #28
0
 public override com.epl.geometry.ogc.OGCGeometry Envelope()
 {
     com.epl.geometry.GeometryCursor gc  = GetEsriGeometryCursor();
     com.epl.geometry.Envelope       env = new com.epl.geometry.Envelope();
     for (com.epl.geometry.Geometry g = gc.Next(); g != null; g = gc.Next())
     {
         com.epl.geometry.Envelope e = new com.epl.geometry.Envelope();
         g.QueryEnvelope(e);
         env.Merge(e);
     }
     com.epl.geometry.Polygon polygon = new com.epl.geometry.Polygon();
     polygon.AddEnvelope(env, false);
     return(new com.epl.geometry.ogc.OGCPolygon(polygon, esriSR));
 }
コード例 #29
0
        internal static com.epl.geometry.PolygonUtils.PiPResult IsPointInPolygon2D(com.epl.geometry.Polygon polygon, double inputPointXVal, double inputPointYVal, double tolerance)
        {
            int res = com.epl.geometry.PointInPolygonHelper.IsPointInPolygon(polygon, inputPointXVal, inputPointYVal, tolerance);

            if (res == 0)
            {
                return(com.epl.geometry.PolygonUtils.PiPResult.PiPOutside);
            }
            if (res == 1)
            {
                return(com.epl.geometry.PolygonUtils.PiPResult.PiPInside);
            }
            return(com.epl.geometry.PolygonUtils.PiPResult.PiPBoundary);
        }
コード例 #30
0
        public virtual void TestBufferEnvelope()
        {
            com.epl.geometry.SpatialReference sr        = com.epl.geometry.SpatialReference.Create(4326);
            com.epl.geometry.Envelope         inputGeom = new com.epl.geometry.Envelope(1, 0, 200, 400);
            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);
            com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
            result.QueryEnvelope2D(env2D);
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - (80 + 199)) < 0.001 && System.Math.Abs(env2D.GetHeight() - (80 + 400)) < 0.001);
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 201.0 / 2) < 0.001 && System.Math.Abs(env2D.GetCenterY() - 400 / 2.0) < 0.001);
            int pathCount = poly.GetPathCount();

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

            NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 104.0) < 10);
            com.epl.geometry.NonSimpleResult nsr = new com.epl.geometry.NonSimpleResult();
            NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, true, nsr, null));
            {
                result = buffer.Execute(inputGeom, sr, -200.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, -200.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, -199 / 2.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, -50.0, null);
                poly   = (com.epl.geometry.Polygon)(result);
                result.QueryEnvelope2D(env2D);
                NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - (199 - 100)) < 0.001 && System.Math.Abs(env2D.GetHeight() - (400 - 100)) < 0.001);
                NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 201.0 / 2) < 0.001 && System.Math.Abs(env2D.GetCenterY() - 400 / 2.0) < 0.001);
                pathCount = poly.GetPathCount();
                NUnit.Framework.Assert.IsTrue(pathCount == 1);
                pointCount = poly.GetPointCount();
                NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 4.0) < 10);
                NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null));
            }
        }