コード例 #1
0
ファイル: Form1.cs プロジェクト: XYT1033/csdn_download
        //构造切线点
        private void button5_Click(object sender, EventArgs e)
        {
            delFeature("point");
            IPoint[] points = new IPoint[4];
            for (int i = 0; i < 4; i++)
            {
                points[i] = new PointClass();
            }

            points[0].PutCoords(15, 10);
            points[1].PutCoords(20, 60);
            points[2].PutCoords(40, 60);
            points[3].PutCoords(45, 10);
            addFeature("point", points[0]);
            addFeature("point", points[1]);
            addFeature("point", points[2]);
            addFeature("point", points[3]);

            IBezierCurveGEN bezierCurve = new BezierCurveClass();

            bezierCurve.PutCoords(ref points);
            IConstructMultipoint constructMultipoint = new MultipointClass();

            constructMultipoint.ConstructTangent(bezierCurve as ICurve, points[1]);
            IMultipoint      multipoint      = constructMultipoint as IMultipoint;
            IPointCollection pointCollection = multipoint as IPointCollection;

            for (int i = 0; i < pointCollection.PointCount; i++)
            {
                addFeature("point", pointCollection.get_Point(i));
            }
            axMapControl1.Refresh();
        }
コード例 #2
0
        public void LearningTestCantSubtractMultipointFromPoint()
        {
            IPoint      g1 = GeometryFactory.CreatePoint(10, 5, 1000);
            IMultipoint g2 = GeometryFactory.CreateMultipoint(
                GeometryFactory.CreatePoint(10, 5, 1000),
                GeometryFactory.CreatePoint(10, 6, 1000));

            ((ITopologicalOperator2)g2).IsKnownSimple_2 = false;
            ((ITopologicalOperator)g2).Simplify();

            try
            {
                IGeometry result = ((ITopologicalOperator)g1).Difference(g2);
                if (RuntimeUtils.Is10_4orHigher)
                {
                    Assert.True(result.IsEmpty, "empty result expected");
                }
                else
                {
                    Assert.Fail("expected: AccessViolationException");
                }
            }
            catch (AccessViolationException)
            {
                if (RuntimeUtils.Is10_4orHigher)
                {
                    // no longer expected >= 10.4
                    throw;
                }

                // else: expected
            }
        }
コード例 #3
0
        public void CanGetMultipointPolygonCrossesIntersection()
        {
            var matrix = new IntersectionMatrix("T*T******");

            IMultipoint g1 = GeometryFactory.CreateMultipoint(
                GeometryFactory.CreatePoint(5, 5, 0),
                GeometryFactory.CreatePoint(10, 5, 0),
                GeometryFactory.CreatePoint(15, 5, 0));
            IPolygon g2 = GeometryFactory.CreatePolygon(0, 0, 10, 10, 0);

            g1.SpatialReference = _spatialReference;
            g2.SpatialReference = _spatialReference;

            IList <IGeometry> result12 = matrix.GetIntersections(g1, g2);

            Assert.AreEqual(1, result12.Count);
            Console.WriteLine(GeometryUtils.ToString(result12[0]));
            Assert.AreEqual(2, GeometryUtils.GetPointCount(result12));
            Assert.IsTrue(SpatialReferenceUtils.AreEqual(_spatialReference,
                                                         result12[0].SpatialReference));

            IList <IGeometry> result21 = matrix.GetIntersections(g2, g1);

            Assert.AreEqual(1, result21.Count);
            Console.WriteLine(GeometryUtils.ToString(result21[0]));
            Assert.IsTrue(
                GeometryUtils.AreEqualInXY(result21[0],
                                           g2));                 // can't subtract, same as g2
        }
コード例 #4
0
        public void CanDetectEndPointSegmentIntersection()
        {
            IPolyline polyline1 = CreatePolyline(
                CreatePoint(0, 0),
                CreatePoint(100, 100));
            IPolyline polyline2 = CreatePolyline(
                CreatePoint(100, 0),
                CreatePoint(50.001, 50));

            const bool reportOverlaps = false;

            Assert.IsTrue(HasInvalidIntersection(polyline1, polyline2,
                                                 AllowedEndpointInteriorIntersections.None,
                                                 reportOverlaps,
                                                 _tolerance));

            IMultipoint intersections = LineIntersectionUtils.GetInvalidIntersections(
                polyline1, polyline2,
                AllowedEndpointInteriorIntersections.None,
                AllowedLineInteriorIntersections.None,
                reportOverlaps,
                _tolerance);

            Assert.AreEqual(1, GeometryUtils.GetPointCount(intersections));
            AssertPoint(intersections, 0, CreatePoint(50.001, 50));
        }
コード例 #5
0
        public void CanDetectLinearIntersectionAndCrossing()
        {
            IPolyline polyline1 = CreatePolyline(
                CreatePoint(0, 0),
                CreatePoint(100, 100));
            IPolyline polyline2 = CreatePolyline(
                CreatePoint(100, 0),
                CreatePoint(49, 49),
                CreatePoint(51, 51),
                CreatePoint(0, 100),
                CreatePoint(10, 0));

            const bool reportOverlaps = true;

            Assert.IsTrue(HasInvalidIntersection(polyline1, polyline2,
                                                 AllowedEndpointInteriorIntersections.None,
                                                 reportOverlaps,
                                                 _tolerance));

            IMultipoint intersections = LineIntersectionUtils.GetInvalidIntersections(
                polyline1, polyline2,
                AllowedEndpointInteriorIntersections.None,
                AllowedLineInteriorIntersections.None,
                reportOverlaps,
                _tolerance);

            Assert.AreEqual(3, GeometryUtils.GetPointCount(intersections));
            AssertPoint(intersections, 0, CreatePoint(9.0918, 9.0916));
            AssertPoint(intersections, 1, CreatePoint(49, 49));
            AssertPoint(intersections, 2, CreatePoint(51, 51));
        }
        public void EmptyPointsAreRemoved(GeometryGeoJsonConverter sut, IMultipoint multiPoint, IPoint point1, IPoint point2, IPoint emptyPoint)
        {
            emptyPoint.SetEmpty();
            multiPoint.SetEmpty();
            ((IPointCollection)multiPoint).AddPoint(emptyPoint);
            ((IPointCollection)multiPoint).AddPoint(point1);
            ((IPointCollection)multiPoint).AddPoint(emptyPoint);
            ((IPointCollection)multiPoint).AddPoint(point2);
            ((IPointCollection)multiPoint).AddPoint(emptyPoint);

            var actual   = JsonConvert.SerializeObject(multiPoint, sut);
            var expected = $@"{{
  ""type"": ""MultiPoint"",
  ""coordinates"": [
    [
      {point1.X.ToJsonString()},
      {point1.Y.ToJsonString()}
    ],
    [
      {point2.X.ToJsonString()},
      {point2.Y.ToJsonString()}
    ]
  ]
}}";

            JsonAssert.Equal(expected, actual);
        }
コード例 #7
0
        private IEnumerable <KeyValuePair <IPoint, IPoint> > CalculateSourceTargetPairs(
            [NotNull] IList <IPolycurve> sourceGeometries,
            [NotNull] IPointCollection targetIntersectionPoints)
        {
            // for all tuples -> calculate standard intersection points (possibly clip first and only use original shapes if none found?)

            if (sourceGeometries.Count <= 1)
            {
                return(new List <KeyValuePair <IPoint, IPoint> >(0));
            }

            IMultipoint sourceIntersectionPoints =
                CalculateSourceIntersections(sourceGeometries);

            // TODO: re-use SourceIntersections if selected features have not changed

            IPointCollection             unpairedSourcePoints;
            IDictionary <IPoint, IPoint> sourceTargetPairs =
                ReshapeUtils.PairByDistance((IPointCollection)sourceIntersectionPoints,
                                            targetIntersectionPoints, out unpairedSourcePoints);

            _unpairedSourceIntersectionPoints = unpairedSourcePoints;

            return(sourceTargetPairs);
        }
コード例 #8
0
        private static IMultipoint RemoveVertexIntersections(
            [NotNull] IMultipoint intersectionPoints,
            [NotNull] IPolyline polyline1,
            [NotNull] IPolyline polyline2,
            double vertexSearchDistance)
        {
            var remainingPoints = new List <IPoint>();

            foreach (IPoint intersectionPoint in
                     QueryPoints(intersectionPoints, TemplatePoint1))
            {
                if (IntersectsVertex(intersectionPoint, polyline2, TemplatePoint2,
                                     vertexSearchDistance) &&
                    IntersectsVertex(intersectionPoint, polyline1, TemplatePoint2,
                                     vertexSearchDistance))
                {
                    // intersection point intersects vertex on both polylines
                    // -> skip
                    continue;
                }

                remainingPoints.Add(GeometryFactory.Clone(intersectionPoint));
            }

            return(GeometryFactory.CreateMultipoint(remainingPoints));
        }
コード例 #9
0
        private static string processMultiPointBuffer(IMultipoint buffer)
        {
            try
            {
                StringBuilder    retval = new StringBuilder("{\"type\":\"MultiPoint\", \"coordinates\": [");
                bool             hasZ   = false;
                IPointCollection points = (IPointCollection)buffer;

                List <string> coords = new List <string>();
                for (int i = 0; i < points.PointCount; i++)
                {
                    string coord = hasZ ? getCoordinate(points.Point[i].X, points.Point[i].Y, points.Point[i].Z) : getCoordinate(points.Point[i].X, points.Point[i].Y);
                    coords.Add(coord);
                }
                string[] coordArray = coords.ToArray();
                string   coordList  = string.Join(",", coordArray);
                retval.Append(coordList);
                retval.Append("]}");
                return(retval.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("Error processing multipoint buffer", ex);
            }
        }
コード例 #10
0
ファイル: QueryIntersectionUI.cs プロジェクト: secondii/Yutai
 private void Worker_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         e.Result = false;
         int[] oids = e.Argument as int[];
         if (oids == null || oids.Length < 2)
         {
             return;
         }
         IFeatureClass        featureClass        = this.m_pFtLayer.FeatureClass;
         IFeature             feature             = featureClass.GetFeature(oids[0]);
         IFeature             feature2            = featureClass.GetFeature(oids[1]);
         IPolyline            polyline            = feature.Shape as IPolyline;
         ITopologicalOperator topologicalOperator = polyline as ITopologicalOperator;
         IGeometry            geometry            = null;
         if (topologicalOperator != null)
         {
             geometry = topologicalOperator.Intersect(feature2.Shape, (esriGeometryDimension)1);
         }
         if (!geometry.IsEmpty)
         {
             IMultipoint      multipoint      = geometry as IMultipoint;
             IPointCollection pointCollection = multipoint as IPointCollection;
             this.m_pGeoFlash = pointCollection.get_Point(0);
             e.Result         = true;
         }
     }
     catch (Exception exception)
     {
         e.Result = false;
     }
 }
コード例 #11
0
        public byte[] WriteMultipoint(IMultipoint multipoint)
        {
            MemoryStream memoryStream = InitializeWriter();

            Ordinates ordinates = GetOrdinatesDimension(multipoint);

            WriteWkbType(WkbGeometryType.MultiPoint, ordinates);

            var pointCollection = ((IPointCollection4)multipoint);

            int pointCount = pointCollection.PointCount;

            Writer.Write(pointCount);

            WKSPointZ[] pointArray = GetWksPointArray(pointCollection.PointCount);

            GeometryUtils.QueryWKSPointZs(pointCollection, pointArray);

            var pointList = new WksPointZPointList(pointArray, 0, pointCount);

            for (int i = 0; i < pointCount; i++)
            {
                WriteWkbType(WkbGeometryType.Point, ordinates);

                WritePointCore(pointList, i, ordinates);
            }

            return(memoryStream.ToArray());
        }
コード例 #12
0
        public void CanGetMultipointPolylineCrossesIntersection()
        {
            var matrix = new IntersectionMatrix("T*T******");

            IMultipoint g1 = GeometryFactory.CreateMultipoint(
                GeometryFactory.CreatePoint(0, 5, 0),
                GeometryFactory.CreatePoint(15, 5, 0));
            IPolyline g2 = GeometryFactory.CreatePolyline(5, 5, 1000, 15, 5, 1000);

            // TODO with the spatial reference assigned, the intersection contains only one point (0,5)
            // without spatial reference, it contains two points (0,5 and 15,5)
            //g1.SpatialReference = _spatialReference;
            //g2.SpatialReference = _spatialReference;

            IList <IGeometry> result12 = matrix.GetIntersections(g1, g2);

            Assert.AreEqual(1, result12.Count);
            Console.WriteLine(GeometryUtils.ToString(result12[0]));
            Assert.AreEqual(2, GeometryUtils.GetPointCount(result12));
            //Assert.IsTrue(SpatialReferenceUtils.AreEqual(_spatialReference,
            //                                             result12[0].SpatialReference));

            IList <IGeometry> result21 = matrix.GetIntersections(g2, g1);

            Assert.AreEqual(1, result21.Count);
            Console.WriteLine(GeometryUtils.ToString(result21[0]));
            Assert.IsTrue(
                GeometryUtils.AreEqualInXY(result21[0],
                                           g2));                 // can't subtract, same as g2
        }
コード例 #13
0
        public void CanReadWriteMultipointXy()
        {
            var points = new WKSPointZ[4];

            points[0] = new WKSPointZ {
                X = 2600000, Y = 1200000, Z = double.NaN
            };
            points[1] = new WKSPointZ {
                X = 2600030, Y = 1200020, Z = double.NaN
            };
            points[2] = new WKSPointZ {
                X = 2600020, Y = 1200030, Z = double.NaN
            };
            points[3] = new WKSPointZ {
                X = 2600040, Y = 1200040, Z = double.NaN
            };

            ISpatialReference sr =
                SpatialReferenceUtils.CreateSpatialReference(WellKnownHorizontalCS.LV95);

            IMultipoint multipoint = GeometryFactory.CreateMultipoint(points, sr);

            GeometryUtils.MakeNonZAware(multipoint);

            WkbGeometryWriter writer = new WkbGeometryWriter();

            byte[] wkb = writer.WriteMultipoint(multipoint);

            // ArcObjects
            byte[] arcObjectsWkb = GeometryUtils.ToWkb(multipoint);
            Assert.AreEqual(wkb, arcObjectsWkb);

            // Wkx
            byte[] wkx = ToChristianSchwarzWkb(ToWkxMultipoint(points, Ordinates.Xy));
            Assert.AreEqual(wkx, wkb);

            // Bonus test: Geom
            WkbGeomWriter     geomWriter = new WkbGeomWriter();
            Multipoint <IPnt> multipnt   = GeometryConversionUtils.CreateMultipoint(multipoint);

            byte[] wkbGeom = geomWriter.WriteMultipoint(multipnt, Ordinates.Xy);
            Assert.AreEqual(wkb, wkbGeom);

            WkbGeometryReader reader = new WkbGeometryReader();

            IMultipoint restored = reader.ReadMultipoint(new MemoryStream(wkb));

            Assert.IsTrue(GeometryUtils.AreEqual(multipoint, restored));

            // Geom
            WkbGeomReader geomReader = new WkbGeomReader();

            Multipoint <IPnt> deserializedPnts =
                geomReader.ReadMultiPoint(new MemoryStream(wkbGeom));

            Assert.IsTrue(
                GeomRelationUtils.AreMultipointsEqualXY(multipnt, deserializedPnts,
                                                        double.Epsilon));
        }
コード例 #14
0
        public void EmptyReturnsNull(IMultipoint multiPoint, GeometryGeoJsonConverter sut)
        {
            multiPoint.SetEmpty();

            var actual = JsonConvert.SerializeObject(multiPoint, sut);

            Assert.Equal("null", actual);
        }
コード例 #15
0
ファイル: XiangMapClass.cs プロジェクト: secondii/Yutai
        private IPointCollection method_4(IPolyline ipolyline_0, IPolygon ipolygon_0)
        {
            IMultipoint          multipoint = null;
            ITopologicalOperator @operator  = ipolygon_0 as ITopologicalOperator;

            @operator.Simplify();
            multipoint = @operator.Intersect(ipolyline_0, esriGeometryDimension.esriGeometry0Dimension) as IMultipoint;
            return(multipoint as IPointCollection);
        }
コード例 #16
0
            public MultipointNearFeatureCoincidence([NotNull] IFeature feature,
                                                    IMultipoint multipoint)
                : base(feature)
            {
                var points = (IPointCollection4)multipoint;

                _wksPoints = new WKSPointZ[points.PointCount];
                GeometryUtils.QueryWKSPointZs(points, _wksPoints);
            }
コード例 #17
0
        public static IPoint ToPoint(IMultipoint multipoint)
        {
            IPointCollection pointCollection = multipoint as IPointCollection;

            if (pointCollection != null && pointCollection.PointCount >= 0)
            {
                return(pointCollection.Point[0]);
            }
            return(null);
        }
コード例 #18
0
        public static Multipoint <IPnt> CreateMultipoint([NotNull] IMultipoint multipoint)
        {
            bool zAware = GeometryUtils.IsZAware(multipoint);

            Multipoint <IPnt> result = new Multipoint <IPnt>(
                GeometryUtils.GetPoints(multipoint).Select(p => CreatePnt(p, zAware)),
                GeometryUtils.GetPointCount(multipoint));

            return(result);
        }
コード例 #19
0
        public MainForm()
        {
            InitializeComponent();

            pMulPoint = new MultipointClass();

            pPointC = pMulPoint as IPointCollection;

            pClickedCount = 0;
        }
コード例 #20
0
        private IMultipoint CalculateSourceIntersections(
            [NotNull] IEnumerable <IPolycurve> sourceGeometries)
        {
            IMultipoint sourceIntersectionPoints = null;
            IPolyline   sourceIntersectionLines  = null;

            foreach (
                KeyValuePair <IPolycurve, IPolycurve> pair in
                CollectionUtils.GetAllTuples(sourceGeometries))
            {
                IPolycurve polycurve1 = pair.Key;
                IPolycurve polycurve2 = pair.Value;

                IPolyline intersectionLines =
                    GeometryFactory.CreateEmptyPolyline(polycurve1);

                IMultipoint intersectionPoints =
                    IntersectionUtils.GetIntersectionPoints(
                        polycurve1, polycurve2, false,
                        IntersectionPointOptions.IncludeLinearIntersectionEndpoints,
                        intersectionLines);

                if (sourceIntersectionPoints == null)
                {
                    sourceIntersectionPoints = intersectionPoints;
                }
                else
                {
                    ((IPointCollection)sourceIntersectionPoints).AddPointCollection(
                        (IPointCollection)intersectionPoints);
                }

                if (intersectionLines != null && !intersectionLines.IsEmpty)
                {
                    if (sourceIntersectionLines == null)
                    {
                        sourceIntersectionLines = intersectionLines;
                    }
                    else
                    {
                        ((IGeometryCollection)sourceIntersectionLines).AddGeometryCollection(
                            (IGeometryCollection)intersectionLines);
                    }
                }
            }

            Assert.NotNull(sourceIntersectionPoints);

            GeometryUtils.Simplify(sourceIntersectionPoints);

            // un-simplified!
            _sourceIntersectionLines = sourceIntersectionLines;

            return(sourceIntersectionPoints);
        }
コード例 #21
0
        private static void AssertPoint(IMultipoint points, int index, IPoint expectedPoint)
        {
            expectedPoint.SpatialReference = CreateSpatialReference();
            expectedPoint.SnapToSpatialReference();

            IPoint point = ((IPointCollection)points).get_Point(index);

            point.SnapToSpatialReference();
            Assert.AreEqual(expectedPoint.X, point.X, "point {0}, X", index);
            Assert.AreEqual(expectedPoint.Y, point.Y, "point {0}, Y", index);
        }
コード例 #22
0
ファイル: Form1.cs プロジェクト: XYT1033/csdn_download
        //构造交点
        private void button4_Click(object sender, EventArgs e)
        {
            delFeature("point");
            IPoint[] points = new IPoint[4];
            for (int i = 0; i < 4; i++)
            {
                points[i] = new PointClass();
            }

            points[0].PutCoords(15, 10);
            points[1].PutCoords(20, 60);
            points[2].PutCoords(40, 60);
            points[3].PutCoords(45, 10);
            addFeature("point", points[0]);
            addFeature("point", points[1]);
            addFeature("point", points[2]);
            addFeature("point", points[3]);
            //构造Bezier曲线
            IBezierCurveGEN bezierCurve = new BezierCurveClass();

            bezierCurve.PutCoords(ref points);
            IPoint centerPoint = new PointClass();

            centerPoint.PutCoords(30, 30);
            IPoint fromPoint = new PointClass();

            fromPoint.PutCoords(10, 10);
            IPoint toPoint = new PointClass();

            toPoint.PutCoords(50, 10);
            //构造圆弧
            IConstructCircularArc circularArcConstruction = new CircularArcClass();

            circularArcConstruction.ConstructThreePoints(fromPoint, centerPoint, toPoint, false);


            object param0;
            object param1;
            object isTangentPoint;
            IConstructMultipoint constructMultipoint = new MultipointClass();

            constructMultipoint.ConstructIntersection(circularArcConstruction as ISegment, esriSegmentExtension.esriNoExtension, bezierCurve as ISegment, esriSegmentExtension.esriNoExtension, out param0, out param1, out isTangentPoint);
            IMultipoint      multipoint      = constructMultipoint as IMultipoint;
            IPointCollection pointCollection = multipoint as IPointCollection;

            for (int i = 0; i < pointCollection.PointCount; i++)
            {
                addFeature("point", pointCollection.get_Point(i));
            }

            axMapControl1.Extent = multipoint.Envelope;
            axMapControl1.Refresh();
        }
コード例 #23
0
        public void CanGetTwoDuplicateMultipointPointsInSequence()
        {
            const double xyTolerance = 0.1;
            const double zTolerance  = 0.1;

            // the second duplicate is NOT the last one in the sorted coordinate list...
            IMultipoint original = GeometryFactory.CreateMultipoint(
                GeometryFactory.CreatePoint(100, 1000, 5000),                 // duplicate 1
                GeometryFactory.CreatePoint(100, 1000, 5000),                 // duplicate 1
                GeometryFactory.CreatePoint(150, 1000, 5000),                 // duplicate 2
                GeometryFactory.CreatePoint(150, 1000, 5000),                 // duplicate 2
                GeometryFactory.CreatePoint(200, 1000, 5000),
                GeometryFactory.CreatePoint(100, 2000, 5000),
                GeometryFactory.CreatePoint(100, 3000, 5000)
                );

            original.SpatialReference = CreateSpatialReference(xyTolerance, zTolerance);

            IMultipoint clone = GeometryFactory.Clone(original);

            GeometryUtils.Simplify(clone);

            var vertexComparer = new GeometryComparison(original, clone,
                                                        xyTolerance, zTolerance);

            IList <WKSPointZ> result = vertexComparer.GetDifferentVertices(true);

            Assert.AreEqual(2, result.Count);
            Assert.AreEqual(100, result[0].X);
            Assert.AreEqual(1000, result[0].Y);
            Assert.AreEqual(5000, result[0].Z);
            Assert.AreEqual(150, result[1].X);
            Assert.AreEqual(1000, result[1].Y);
            Assert.AreEqual(5000, result[1].Z);

            // Flip geometries:
            vertexComparer = new GeometryComparison(clone, original,
                                                    xyTolerance, zTolerance);

            result = vertexComparer.GetDifferentVertices(true);

            Assert.AreEqual(2, result.Count);
            Assert.AreEqual(100, result[0].X);
            Assert.AreEqual(1000, result[0].Y);
            Assert.AreEqual(5000, result[0].Z);
            Assert.AreEqual(150, result[1].X);
            Assert.AreEqual(1000, result[1].Y);
            Assert.AreEqual(5000, result[1].Z);

            Assert.True(vertexComparer.HaveSameVertices());
            Assert.False(vertexComparer.HaveSameVertices(false));
        }
コード例 #24
0
        private static IMultipoint RemoveAnyEndpoints(
            [NotNull] IMultipoint intersections,
            [NotNull] IGeometry shape1Endpoints,
            [NotNull] IGeometry shape2Endpoints)
        {
            var remainder = (IMultipoint)
                            ((ITopologicalOperator)intersections).Difference(shape1Endpoints);

            return(remainder.IsEmpty
                                       ? remainder
                                       : (IMultipoint)
                   ((ITopologicalOperator)remainder).Difference(shape2Endpoints));
        }
コード例 #25
0
        public void CanReadWriteMultipointXyz()
        {
            var points = new WKSPointZ[4];

            points[0] = new WKSPointZ {
                X = 2600000, Y = 1200000, Z = 456
            };
            points[1] = new WKSPointZ {
                X = 2600030, Y = 1200020, Z = 457
            };
            points[2] = new WKSPointZ {
                X = 2600020, Y = 1200030, Z = 459
            };
            points[3] = new WKSPointZ {
                X = 2600010, Y = 1200010, Z = 416
            };

            ISpatialReference sr =
                SpatialReferenceUtils.CreateSpatialReference(WellKnownHorizontalCS.LV95);

            IMultipoint multipoint = GeometryFactory.CreateMultipoint(points, sr);

            WkbGeometryWriter writer = new WkbGeometryWriter();

            byte[] wkb = writer.WriteMultipoint(multipoint);

            // Wkx
            byte[] wkx = ToChristianSchwarzWkb(ToWkxMultipoint(points, Ordinates.Xyz));
            Assert.AreEqual(wkx, wkb);

            // Bonus test: Geom
            WkbGeomWriter     geomWriter = new WkbGeomWriter();
            Multipoint <IPnt> multipnt   = GeometryConversionUtils.CreateMultipoint(multipoint);

            byte[] wkbGeom = geomWriter.WriteMultipoint(multipnt, Ordinates.Xyz);
            Assert.AreEqual(wkb, wkbGeom);

            WkbGeometryReader reader = new WkbGeometryReader();

            IMultipoint restored = reader.ReadMultipoint(new MemoryStream(wkb));

            Assert.IsTrue(GeometryUtils.AreEqual(multipoint, restored));

            // Geom
            WkbGeomReader geomReader = new WkbGeomReader();

            Multipoint <IPnt> deserializedPnts =
                geomReader.ReadMultiPoint(new MemoryStream(wkbGeom));

            Assert.IsTrue(multipnt.Equals(deserializedPnts));
        }
コード例 #26
0
 /// <summary>
 /// This function will return a point collection for intersections along a curve
 /// </summary>
 /// <param name="inFeature">the feature to intersect</param>
 /// <param name="inTopOp">the curve to use to intersect the feature</param>
 /// <returns>a point collection of intersecting points along the infeature</returns>
 public static IPointCollection PerformTopologicalIntersect(IFeature inFeature, ITopologicalOperator inTopOp)
 {
     try
     {
         IPolycurve  pFeatureShape = inFeature.Shape as IPolycurve;
         IMultipoint pIntersection =
             (IMultipoint)inTopOp.Intersect(pFeatureShape, esriGeometryDimension.esriGeometry0Dimension);
         return((IPointCollection)pIntersection);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
コード例 #27
0
        public void LearningTestCantSubtractMultipointFromEqualMultipoint()
        {
            IMultipoint g1 = GeometryFactory.CreateMultipoint(
                GeometryFactory.CreatePoint(10, 5, 1000),
                GeometryFactory.CreatePoint(10, 6, 1000));
            IMultipoint g2 = GeometryFactory.CreateMultipoint(
                GeometryFactory.CreatePoint(10, 5, 1000),
                GeometryFactory.CreatePoint(10, 6, 1000));

            IGeometry result = ((ITopologicalOperator)g1).Difference(g2);

            Console.WriteLine(GeometryUtils.ToString(result));
            Assert.IsTrue(result.IsEmpty);
        }
コード例 #28
0
        private IPoint GetIntersectPoint(IPolyline line1, IPolyline line2)
        {
            IPoint pnt = null;
            ITopologicalOperator topo     = line1 as ITopologicalOperator;
            IGeometry            geo      = topo.Intersect(line2, esriGeometryDimension.esriGeometry0Dimension);
            IMultipoint          mulpoint = geo as IMultipoint;
            IPointCollection     pntcol   = mulpoint as IPointCollection;

            if (pntcol != null)
            {
                pnt = pntcol.get_Point(0);
            }
            return(pnt);
        }
コード例 #29
0
        private static IMultipoint RemoveAllowedEndPointIntersections(
            [NotNull] IMultipoint intersections,
            [NotNull] IPolyline polyline1,
            [NotNull] IPolyline polyline2,
            AllowedEndpointInteriorIntersections allowedEndpointInteriorIntersections,
            double vertexSearchDistance)
        {
            if (allowedEndpointInteriorIntersections ==
                AllowedEndpointInteriorIntersections.None &&
                GeometryUtils.GetPointCount(intersections) == 1)
            {
                // NOTE this assumes that HasInvalidIntersections has returned 'true' for these lines
                // --> if there is a unique intersection point, we know it's not at two touching end points
                return(intersections);
            }

            // this fails if polylines are non-simple
            IGeometry shape1Endpoints = ((ITopologicalOperator)polyline1).Boundary;
            IGeometry shape2Endpoints = ((ITopologicalOperator)polyline2).Boundary;

            IMultipoint innerIntersections = GetIntersectionsInvolvingInterior(intersections,
                                                                               shape1Endpoints,
                                                                               shape2Endpoints);

            if (innerIntersections.IsEmpty)
            {
                return(innerIntersections);
            }

            switch (allowedEndpointInteriorIntersections)
            {
            case AllowedEndpointInteriorIntersections.All:
                // remove all intersection points that coincide with any end point
                return(RemoveAnyEndpoints(innerIntersections, shape1Endpoints, shape2Endpoints));

            case AllowedEndpointInteriorIntersections.Vertex:
                // remove intersections that coincide with an end point of one polyline and a vertex of the other
                return(RemoveEndPointVertexIntersections(innerIntersections,
                                                         polyline1, shape1Endpoints,
                                                         polyline2, shape2Endpoints,
                                                         vertexSearchDistance));

            case AllowedEndpointInteriorIntersections.None:
                return(innerIntersections);

            default:
                throw new ArgumentOutOfRangeException(
                          nameof(allowedEndpointInteriorIntersections));
            }
        }
コード例 #30
0
        public void SinglePointReturnsPoint(GeometryGeoJsonConverter sut, IMultipoint multiPoint, IPoint point)
        {
            multiPoint.SetEmpty();
            ((IPointCollection)multiPoint).AddPoint(point);

            var actual   = JsonConvert.SerializeObject(multiPoint, sut);
            var expected = $@"{{
  ""type"": ""Point"",
  ""coordinates"": [
    {point.X.ToJsonString()},
    {point.Y.ToJsonString()}
  ]
}}";

            JsonAssert.Equal(expected, actual);
        }
            public void PointReturnsMultiPoint(IMultipoint multiPoint, IPoint point)
            {
                multiPoint.SetEmpty();
                ((IPointCollection)multiPoint).AddPoint(point);

                var actual   = JsonConvert.SerializeObject(multiPoint, Formatting.Indented, _sut);
                var expected = $@"{{
  ""type"": ""MultiPoint"",
  ""coordinates"": [[
    {point.X.ToJsonString()},
    {point.Y.ToJsonString()}
  ]]
}}";

                JsonAssert.Equal(expected, actual);
            }
コード例 #32
0
 private static string BuildWellKnownText(IMultipoint points)
 {
     //Example - MULTIPOINT ((10 40), (40 30), (20 20), (30 10))
     //Example - MULTIPOINT (10 40, 40 30, 20 20, 30 10)
     return "MULTIPOINT " + BuildWellKnownText(points as IPointCollection);
 }
コード例 #33
0
        private static string processMultiPointBuffer(IMultipoint buffer)
        {
            try
            {
                StringBuilder retval = new StringBuilder("{\"type\":\"MultiPoint\", \"coordinates\": [");
                bool hasZ = false;
                IPointCollection points = (IPointCollection)buffer;

                List<string> coords = new List<string>();
                for (int i = 0; i < points.PointCount; i++)
                {
                    string coord = hasZ ? getCoordinate(points.Point[i].X, points.Point[i].Y, points.Point[i].Z) : getCoordinate(points.Point[i].X, points.Point[i].Y);
                    coords.Add(coord);
                }
                string[] coordArray = coords.ToArray();
                string coordList = string.Join(",", coordArray);
                retval.Append(coordList);
                retval.Append("]}");
                return retval.ToString();
            }
            catch (Exception ex)
            {
                throw new Exception("Error processing multipoint buffer", ex);
            }
        }