Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
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
        }
 public void CanSearchSingleMultipoint()
 {
     AssertCanFindGeometry(GeometryFactory.CreateMultipoint(
                               GeometryFactory.CreatePoint(1000, 1000),
                               GeometryFactory.CreatePoint(2000, 1000),
                               GeometryFactory.CreatePoint(3000, 1000)));
 }
Ejemplo n.º 4
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
            }
        }
Ejemplo n.º 5
0
        private static IGeometry CreateGeometryToStore(
            [NotNull] IGeometry geometry,
            [NotNull] ICollection <esriGeometryType> storedGeometryTypes)
        {
            Assert.ArgumentNotNull(geometry, nameof(geometry));
            Assert.ArgumentNotNull(storedGeometryTypes, nameof(storedGeometryTypes));

            esriGeometryType geometryType = geometry.GeometryType;

            if (storedGeometryTypes.Contains(geometryType))
            {
                return(GeometryFactory.Clone(geometry));
            }

            switch (geometry.GeometryType)
            {
            case esriGeometryType.esriGeometryPoint:
                return(storedGeometryTypes.Contains(esriGeometryType.esriGeometryMultipoint)
                                                       ? GeometryFactory.CreateMultipoint((IPoint)geometry)
                                                       : null);

            case esriGeometryType.esriGeometryMultiPatch:
                return(storedGeometryTypes.Contains(esriGeometryType.esriGeometryPolygon)
                                                       ? GeometryFactory.CreatePolygon((IMultiPatch)geometry)
                                                       : null);

            case esriGeometryType.esriGeometryEnvelope:
                return(storedGeometryTypes.Contains(esriGeometryType.esriGeometryPolygon)
                                                       ? GeometryFactory.CreatePolygon((IEnvelope)geometry)
                                                       : null);

            default:
                return(null);
            }
        }
Ejemplo n.º 6
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
        }
Ejemplo n.º 7
0
        private static IGeometry CreateMultipointFromEnvelopeCentroid(
            [NotNull] IEnvelope envelope, bool zAware)
        {
            double xmin;
            double ymin;
            double xmax;
            double ymax;

            envelope.QueryCoords(out xmin, out ymin,
                                 out xmax, out ymax);

            IPoint point;

            if (zAware)
            {
                point = GeometryFactory.CreatePoint((xmax + xmin) / 2,
                                                    (ymax + ymin) / 2,
                                                    (envelope.ZMax + envelope.ZMin) / 2);
            }
            else
            {
                point = GeometryFactory.CreatePoint((xmax + xmin) / 2,
                                                    (ymax + ymin) / 2);
            }

            point.SpatialReference = envelope.SpatialReference;

            return(GeometryFactory.CreateMultipoint(point));
        }
        public void CanReportMultiPointErrorInSameTile()
        {
            const string testName = "CanReportMultiPointErrorInSameTile";

            IFeatureClass vertexClass = CreateFeatureClass(
                $"{testName}_vertex", esriGeometryType.esriGeometryMultipoint);

            IFeature multiPointClass = vertexClass.CreateFeature();

            multiPointClass.Shape =
                GeometryFactory.CreateMultipoint(GeometryFactory.CreatePoint(201, 199));
            multiPointClass.Store();
            IFeature vertexRow1 = vertexClass.CreateFeature();

            vertexRow1.Shape =
                GeometryFactory.CreateMultipoint(GeometryFactory.CreatePoint(199, 199));
            vertexRow1.Store();

            IEnvelope verificationEnvelope =
                GeometryFactory.CreateEnvelope(0, 0, 500, 500);

            var test = new QaVertexCoincidenceSelf(vertexClass)
            {
                PointTolerance = 3
            };

            var runner = new QaContainerTestRunner(500, test);

            runner.Execute(verificationEnvelope);

            Assert.AreEqual(2, runner.Errors.Count);
        }
Ejemplo n.º 9
0
        public void CanCreateUnionWithIntersectingPointsMultipointsPolylinesAndPolygons()
        {
            var input = new List <IGeometry>
            {
                GeometryFactory.CreatePoint(100, 100),
                GeometryFactory.CreatePoint(200, 200),
                GeometryFactory.CreatePolyline(500, 100, 600, 100),
                GeometryFactory.CreatePolyline(550, 100, 650, 100),
                GeometryFactory.CreateMultipoint(
                    GeometryFactory.CreatePoint(1000, 2000),
                    GeometryFactory.CreatePoint(2000, 3000)),
                GeometryFactory.CreateMultipoint(
                    GeometryFactory.CreatePoint(2000, 3000),
                    GeometryFactory.CreatePoint(3000, 4000)),
                GeometryFactory.CreatePolygon(100, 100, 200, 200)
            };

            const double expansionDistance = 10;
            IGeometry    union             = GeometryFactory.CreateUnion(input, expansionDistance);

            Console.WriteLine(GeometryUtils.ToString(union));

            Assert.AreEqual(esriGeometryType.esriGeometryPolygon, union.GeometryType);
            Assert.AreEqual(5, GeometryUtils.GetPartCount(union));
        }
Ejemplo n.º 10
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));
        }
        private static IGeometry GetErrorGeometry(
            int vertexIndex,
            [NotNull] ICollection <int> ignoredVertices,
            [NotNull] IPointCollection transformedPoints,
            [NotNull] IsClosedEvaluator isClosedEvaluator,
            IList <double> sourceAngles,
            double ignoredAngleValue)
        {
            if (ignoredVertices.Count <= 0)
            {
                return(transformedPoints.Point[vertexIndex]);
            }

            List <IPoint> points = ignoredVertices.Select(
                index => transformedPoints.Point[index])
                                   .ToList();

            if (ignoredVertices.Contains(0) && isClosedEvaluator.IsClosed)
            {
                // the first vertex is ignored, and the path is closed
                // --> check if there are ignored vertices at the end of the path which should be added

                int lastVertexIndexBeforeEndpoint = transformedPoints.PointCount - 2;

                if (Math.Abs(sourceAngles[lastVertexIndexBeforeEndpoint] - ignoredAngleValue) <
                    double.Epsilon)
                {
                    // the vertex before the end vertex is also ignored

                    // --> add the ending sequence of ignored vertices to the list
                    for (int vertexIndexFromEnd = lastVertexIndexBeforeEndpoint;
                         vertexIndexFromEnd >= 0;
                         vertexIndexFromEnd--)
                    {
                        if (Math.Abs(sourceAngles[vertexIndexFromEnd] - ignoredAngleValue) >
                            double.Epsilon)
                        {
                            // the vertex is not ignored --> stop here
                            break;
                        }

                        if (ignoredVertices.Contains(vertexIndexFromEnd))
                        {
                            // the end sequence overlaps the start sequence
                            // --> apparently all vertices are ignored
                            break;
                        }

                        // add the ignored vertex from the end sequence
                        points.Add(transformedPoints.Point[vertexIndexFromEnd]);
                    }
                }
            }

            points.Add(transformedPoints.Point[vertexIndex]);

            return(GeometryFactory.CreateMultipoint(points));
        }
Ejemplo n.º 12
0
 public GeometryComparison([NotNull] WKSPointZ[] baseCoords,
                           [NotNull] WKSPointZ[] compareCoords,
                           ISpatialReference spatialReference,
                           double xyTolerance, double zTolerance)
     : this(
         GeometryFactory.CreateMultipoint(baseCoords, spatialReference),
         GeometryFactory.CreateMultipoint(compareCoords, spatialReference),
         xyTolerance, zTolerance)
 {
 }
Ejemplo n.º 13
0
 private void AddNonCrackPoint(IPoint point)
 {
     if (NonCrackablePoints == null)
     {
         NonCrackablePoints = (IPointCollection)GeometryFactory.CreateMultipoint(point);
     }
     else
     {
         AddPoint(point, NonCrackablePoints);
     }
 }
Ejemplo n.º 14
0
 private void AddCrackPoint(IPoint point)
 {
     if (CrackPointCollection == null)
     {
         CrackPointCollection =
             (IPointCollection)GeometryFactory.CreateMultipoint(point);
     }
     else
     {
         AddPoint(point, CrackPointCollection);
     }
 }
Ejemplo n.º 15
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));
        }
Ejemplo n.º 16
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));
        }
Ejemplo n.º 17
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);
        }
Ejemplo n.º 18
0
        private static IGeometry GetLineEndPoints([NotNull] IGeometry shape,
                                                  GeometryComponent component)
        {
            var polyCurve = shape as IPolycurve;

            Assert.NotNull(polyCurve, GetNotSupportedMessage(shape, component));

            return(polyCurve.IsEmpty
                                       ? new MultipointClass {
                SpatialReference = shape.SpatialReference
            }
                                       : GeometryFactory.CreateMultipoint(
                       polyCurve.FromPoint, polyCurve.ToPoint));
        }
Ejemplo n.º 19
0
        private static IGeometry GetErrorGeometry(
            [NotNull] ICollection <WKSPointZ> changedPoints,
            [NotNull] IFeature feature)
        {
            var changedPointArray = new WKSPointZ[changedPoints.Count];

            changedPoints.CopyTo(changedPointArray, 0);

            IGeometry result = GeometryFactory.CreateMultipoint(
                changedPointArray, DatasetUtils.GetGeometryDef(feature));

            // duplicate points are returned for self-intersections -> simplify
            GeometryUtils.Simplify(result);

            return(result);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Updates the source target pairs AND the _unpairedSourceIntersectionPoints
        /// </summary>
        private void UpdateSourceTargetPairsAndUnpairedSourceIntersections()
        {
            if (_sourceFeatures.Count == 0 || _targetPoints.Count == 0)
            {
                SourceTargetPairs.Clear();
            }

            IList <IPolycurve> sourceGeometries =
                GdbObjectUtils.GetGeometries(_sourceFeatures).Cast <IPolycurve>().ToList();

            var targetPointCollection =
                (IPointCollection)GeometryFactory.CreateMultipoint(_targetPoints);

            SourceTargetPairs = CalculateSourceTargetPairs(
                sourceGeometries, targetPointCollection).ToList();
        }
Ejemplo n.º 21
0
        private void AddIntersectionPoints([CanBeNull] IPointCollection pointCollection)
        {
            if (pointCollection == null || ((IGeometry)pointCollection).IsEmpty)
            {
                return;
            }

            if (IntersectionPoints == null)
            {
                IntersectionPoints =
                    (IPointCollection)GeometryFactory.CreateMultipoint(pointCollection);
            }
            else
            {
                IntersectionPoints.AddPointCollection(pointCollection);
            }
        }
Ejemplo n.º 22
0
        public static IList <IFeature> SplitAtJunctions(
            [NotNull] IFeature edgeFeature,
            [NotNull] IEnumerable <IFeature> splittingJunctions)
        {
            const bool projectPointsOntoPathToSplit = false;
            const bool createParts = true;

            var splitPoints =
                (IPointCollection)GeometryFactory.CreateMultipoint(
                    splittingJunctions.Select(f => (IPoint)f.Shape));

            var edge = (IPolyline)edgeFeature.Shape;

            IList <IPoint> splittedAt = GeometryUtils.CrackPolycurve(
                edge, splitPoints, projectPointsOntoPathToSplit, createParts);

            var result = new List <IFeature>();

            if (splittedAt.Count > 0)
            {
                IList <IGeometry> splitGeometries = GeometryUtils.Explode(edge);

                IGeometry geometryToStoreInOriginal =
                    Assert.NotNull(GeometryUtils.GetLargestGeometry(splitGeometries));

                // store the update
                IFeature existingFeature = AssignGeometryToFeature(geometryToStoreInOriginal,
                                                                   edgeFeature,
                                                                   false);
                existingFeature.Store();

                // store other new geometries as inserts
                foreach (IGeometry modifyGeometry in
                         splitGeometries.Where(polycurve => polycurve != geometryToStoreInOriginal))
                {
                    IFeature newEdgeFeature =
                        AssignGeometryToFeature(modifyGeometry, edgeFeature, true);
                    newEdgeFeature.Store();

                    result.Add(newEdgeFeature);
                }
            }

            return(result);
        }
Ejemplo n.º 23
0
        private static IMultipoint RemoveEndPointVertexIntersections(
            [NotNull] IMultipoint intersectionPoints,
            [NotNull] IPolyline polyline1,
            [NotNull] IGeometry polyline1Endpoints,
            [NotNull] IPolyline polyline2,
            [NotNull] IGeometry polyline2Endpoints,
            double vertexSearchDistance)
        {
            var polyline1EndpointsRelOp = (IRelationalOperator)polyline1Endpoints;
            var polyline2EndpointsRelOp = (IRelationalOperator)polyline2Endpoints;

            var remainingPoints = new List <IPoint>();

            foreach (IPoint intersectionPoint in
                     QueryPoints(intersectionPoints, TemplatePoint1))
            {
                if (!polyline1EndpointsRelOp.Disjoint(intersectionPoint))
                {
                    // end point of polyline 1
                    if (IntersectsVertex(intersectionPoint, polyline2, TemplatePoint2,
                                         vertexSearchDistance))
                    {
                        // intersection of end point of polyline 1 with vertex of polyline 2
                        // -> skip
                        continue;
                    }
                }
                else if (!polyline2EndpointsRelOp.Disjoint(intersectionPoint))
                {
                    // end point of polyline 2
                    if (IntersectsVertex(intersectionPoint, polyline1, TemplatePoint2,
                                         vertexSearchDistance))
                    {
                        // intersection of end point of polyline 2 with vertex of polyline 1
                        // -> skip
                        continue;
                    }
                }

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

            return(GeometryFactory.CreateMultipoint(remainingPoints));
        }
Ejemplo n.º 24
0
        private int ReportError([NotNull] FeatureDangleCount featureDangleCount,
                                [CanBeNull] string constraintValues)
        {
            string description = string.IsNullOrEmpty(constraintValues)
                                                     ? string.Format("Invalid number of dangles: {0}",
                                                                     featureDangleCount
                                                                     .DanglingPointCount)
                                                     : string.Format(
                "Invalid number of dangles: {0} ({1})",
                featureDangleCount.DanglingPointCount,
                constraintValues);

            return(ReportError(description,
                               GeometryFactory.CreateMultipoint(
                                   featureDangleCount.DanglingPoints),
                               Codes[Code.InvalidNumberOfDangles],
                               TestUtils.GetShapeFieldName(featureDangleCount.Feature),
                               featureDangleCount.Feature));
        }
Ejemplo n.º 25
0
        public void TestMultipoint()
        {
            IFeatureClass featureClass =
                TestWorkspaceUtils.CreateSimpleFeatureClass(
                    _testWs, "multipoints",
                    null,
                    esriGeometryType.esriGeometryMultipoint,
                    esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, 0d,
                    true);

            var points = new List <IPoint>
            {
                GeometryFactory.CreatePoint(2000001, 1000000, 0),
                GeometryFactory.CreatePoint(2000002, 1000000, 100),
                GeometryFactory.CreatePoint(2000003, 1000000, 200),
                GeometryFactory.CreatePoint(2000004, 1000000, 300),
                GeometryFactory.CreatePoint(2000005, 1000000, 400)
            };

            IFeature row1 = featureClass.CreateFeature();

            row1.Shape = GeometryFactory.CreateMultipoint(points);
            row1.Store();

            IList <IGeometry> results = RunTest(featureClass, 100, 300, 2);

            var errors1 = (IMultipoint)results[0];

            Assert.AreEqual(((IPointCollection)errors1).PointCount, 1);

            var errors2 = (IMultipoint)results[1];

            Assert.AreEqual(((IPointCollection)errors2).PointCount, 1);

            IFeature row2 = featureClass.CreateFeature();

            row2.Shape = GeometryFactory.CreateMultipoint(points);
            row2.Store();

            RunTest(featureClass, 100, 300, 4);
        }
Ejemplo n.º 26
0
        private static IPolyline GetSplitReshapePath(
            [NotNull] IPath reshapePath,
            [NotNull] IEnumerable <KeyValuePair <IPoint, IPoint> > intersectingSourceTargetPoints,
            [NotNull] IPointCollection sketchOriginalIntersectionPoints)
        {
            var splitReshapeLine =
                (IPolyline)GeometryUtils.GetHighLevelGeometry(reshapePath);

            var targetIntersectionPointCollection =
                (IPointCollection)
                GeometryFactory.CreateMultipoint(
                    intersectingSourceTargetPoints.Select(sourceTargets => sourceTargets.Value));

            // additionally crack at the intersection points of the sketch with the feature
            targetIntersectionPointCollection.AddPointCollection(
                sketchOriginalIntersectionPoints);

            GeometryUtils.CrackPolycurve(splitReshapeLine,
                                         targetIntersectionPointCollection, false, true, null);
            return(splitReshapeLine);
        }
Ejemplo n.º 27
0
        public void CanUseShapeVertexCountAlias()
        {
            IFeatureClass featureClass = CreateFeatureClass(
                "CanUseShapeVertexCountAlias",
                esriGeometryType.esriGeometryMultipoint);

            IFeature f1 = featureClass.CreateFeature();

            f1.Shape = GeometryFactory.CreateMultipoint(GeometryFactory.CreatePoint(0, 0));
            f1.Store();

            IFeature f2 = featureClass.CreateFeature();

            f2.Shape = GeometryFactory.CreateMultipoint(GeometryFactory.CreatePoint(0, 0),
                                                        GeometryFactory.CreatePoint(10, 10),
                                                        GeometryFactory.CreatePoint(20, 20));
            f2.Store();

            AssertFilteredRowCount(1, "$ShapeVertexCount = 3", f1, f2);
            AssertFilteredRowCount(1, "$ShapeVertexCount = 1", f1, f2);
        }
Ejemplo n.º 28
0
        private static ReshapeLineMsg ToReshapeLineMsg([NotNull] CutSubcurve cutSubcurve)
        {
            var result = new ReshapeLineMsg();

            result.Path = ProtobufGeometryUtils.ToShapeMsg(cutSubcurve.Path);

            result.CanReshape  = cutSubcurve.CanReshape;
            result.IsCandidate = cutSubcurve.IsReshapeMemberCandidate;
            result.IsFiltered  = cutSubcurve.IsFiltered;

            result.TargetSegmentAtFrom =
                cutSubcurve.FromPointIsStitchPoint
                                        ? ProtobufGeometryUtils.ToShapeMsg(cutSubcurve.TargetSegmentAtFromPoint)
                                        : null;

            result.TargetSegmentAtTo =
                cutSubcurve.ToPointIsStitchPoint
                                        ? ProtobufGeometryUtils.ToShapeMsg(cutSubcurve.TargetSegmentAtToPoint)
                                        : null;

            if (cutSubcurve.ExtraTargetInsertPoints != null)
            {
                result.ExtraTargetInsertPoints =
                    ProtobufGeometryUtils.ToShapeMsg(
                        GeometryFactory.CreateMultipoint(cutSubcurve.ExtraTargetInsertPoints));
            }

            if (cutSubcurve.Source != null)
            {
                GdbObjectReference sourceObjRef = cutSubcurve.Source.Value;

                result.Source = new GdbObjRefMsg
                {
                    ClassHandle = sourceObjRef.ClassId,
                    ObjectId    = sourceObjRef.ObjectId
                };
            }

            return(result);
        }
Ejemplo n.º 29
0
        public void CanGetDuplicatedMultipointPoint()
        {
            const double xyTolerance = 0.1;
            const double zTolerance  = 0.1;

            IMultipoint original = GeometryFactory.CreateMultipoint(
                GeometryFactory.CreatePoint(100, 1000, 5000),                // duplicate
                GeometryFactory.CreatePoint(100, 1000, 5000)                 // duplicate
                );

            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(1, result.Count);
            Assert.AreEqual(100, result[0].X);
            Assert.AreEqual(1000, result[0].Y);
            Assert.AreEqual(5000, result[0].Z);

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

            result = vertexComparer.GetDifferentVertices(true);

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

            Assert.True(vertexComparer.HaveSameVertices());
            Assert.False(vertexComparer.HaveSameVertices(false));
        }
Ejemplo n.º 30
0
        private static IGeometry GetVertices([NotNull] IGeometry shape,
                                             GeometryComponent component)
        {
            switch (shape.GeometryType)
            {
            case esriGeometryType.esriGeometryPoint:
                return(GeometryFactory.Clone(shape));

            case esriGeometryType.esriGeometryMultipoint:
            case esriGeometryType.esriGeometryMultiPatch:
            case esriGeometryType.esriGeometryPolygon:
            case esriGeometryType.esriGeometryPolyline:
                var         points     = (IPointCollection)GeometryFactory.Clone(shape);
                IMultipoint multipoint = GeometryFactory.CreateMultipoint(points);
                GeometryUtils.Simplify(multipoint);

                return(multipoint);

            default:
                throw new ArgumentException(GetNotSupportedMessage(shape, component));
            }
        }