public void CanGetLinePolygonCrossesIntersection() { var matrix = new IntersectionMatrix("T*T******"); IPolyline g1 = GeometryFactory.CreatePolyline(5, 5, 1000, 15, 5, 1000); 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(3, 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 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 }
private static IGeometry CreateErrorGeometry([NotNull] IPoint p0, [NotNull] IPoint p1) { return(GeometryUtils.AreEqualInXY(p0, p1) ? (IGeometry)GeometryFactory.Clone(p0) : GeometryFactory.CreatePolyline(p0, p1)); }
public static IPolyline GetPreprocessedGeometryForExtent( IGeometry geometry, [CanBeNull] IEnvelope clipExtent) { IPolyline processedGeometry; if (geometry.GeometryType == esriGeometryType.esriGeometryMultiPatch) { geometry = GeometryFactory.CreatePolygon(geometry); } if (clipExtent != null) { // NOTE: convert polygons to polylines first otherwise clipped target lines intersect the // clipped polygon on the display boundary processedGeometry = GetClippedOutline(geometry, clipExtent); } else { processedGeometry = GeometryFactory.CreatePolyline(geometry); // For symmetry with clipped case: merge adjacent lines to avoid non-matching difference/target parts // in ReshapableSubcurveCalculator.GetTargetSegmentsAlong() used for minimum tolerance GeometryUtils.Simplify(processedGeometry, true, true); } return(processedGeometry); }
public void CanTestEmptyGeometrySdePolyline() { IWorkspace workspace = TestUtils.OpenUserWorkspaceOracle(); //IWorkspace workspace = ProSuite.Commons.AO.Test.TestUtils.OpenSDEWorkspaceOracle(); IPolyline normalGeometry = GeometryFactory.CreatePolyline( GeometryFactory.CreatePath(new PointClass { X = 2600000, Y = 1200000, Z = 400 }, new PointClass { X = 2600000, Y = 1200100, Z = 400 }, new PointClass { X = 2600100, Y = 1200000, Z = 400 }, new PointClass { X = 2600000, Y = 1200000, Z = 400 })); GeometryUtils.MakeZAware(normalGeometry); IFeature feature = CreateEmptyGeometryFeature((IFeatureWorkspace)workspace, esriGeometryType.esriGeometryPolyline, normalGeometry); AssertOneErrorEmptyGeometry((IFeatureClass)feature.Class); }
private static bool PathRunsAlongTwoPolygons([NotNull] IPath path, [NotNull] IList <IGeometry> polygons) { // For a potential performance improvement, see StickyIntersections var touchCount = 0; IGeometry highLevelPath = GeometryUtils.GetHighLevelGeometry(path, true); // it's a bag of polygons foreach (IGeometry polygon in polygons) { if (GeometryUtils.Touches(highLevelPath, polygon)) { // filter out those that only touch in the start point and do not run along the boundary IPolyline outline = GeometryFactory.CreatePolyline(polygon); IPolyline lineAlongBoundary = IntersectionUtils.GetIntersectionLines( outline, (IPolycurve)highLevelPath, true, true); if (!lineAlongBoundary.IsEmpty) { touchCount++; if (touchCount == 2) { return(true); } } } } return(false); }
private static IPolyline CreatePolyline(params IPoint[] vertices) { IPath path = GeometryFactory.CreatePath(vertices); IPolyline polyline = GeometryFactory.CreatePolyline(path); return(polyline); }
public void CanDetermineNodeDegreeAtAreaOfInterestBoundaryOneEdgeFullyOutside() { // General idea: The southernmost edge can be traversed from the inside to the // outside, but not vice versa. Degree 3 should be determined correctly // _______________________ // | | // | \ / | // |_____\___/___________| // \ / // | // | // | ISpatialReference sr = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV95, WellKnownVerticalCS.LHN95); IEnvelope aoi = GeometryFactory.CreateEnvelope(2600000, 1200000, 2600100, 1200100, sr); FeatureClassMock edgeClass = new FeatureClassMock(1, "ROADS", esriGeometryType.esriGeometryPolyline); PolylineGraphConnectivity connectivity = new PolylineGraphConnectivity(sr, aoi); // Create node with degree 3 where one feature is partially outside the AOI IPoint junction = GeometryFactory.CreatePoint(2600050, 1199900, sr); FeatureMock feature1 = new FeatureMock(11, edgeClass) { Shape = GeometryFactory.CreatePolyline( GeometryFactory.CreatePoint(2600050, 1199800, sr), junction) }; FeatureMock feature2 = new FeatureMock(12, edgeClass) { Shape = GeometryFactory.CreatePolyline( junction, GeometryFactory.CreatePoint(2600030, 1200050, sr)) }; FeatureMock feature3 = new FeatureMock(13, edgeClass) { Shape = GeometryFactory.CreatePolyline( junction, GeometryFactory.CreatePoint(2600070, 1200050, sr)) }; connectivity.AddConnectivity(feature1, false); connectivity.AddConnectivity(feature2, false); connectivity.AddConnectivity(feature3, false); var edges = connectivity.GetIncidentEdges(junction).ToList(); Assert.AreEqual(0, edges.Count); }
public void CanGetOpenJawReshapeLineReplaceEndPoint() { var fClass = new GdbFeatureClass(123, "TestFC", esriGeometryType.esriGeometryPolyline); var sr = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV95, WellKnownVerticalCS.LN02); fClass.SpatialReference = sr; IPath sourcePath = GeometryFactory.CreatePath( GeometryFactory.CreatePoint(2600500, 1200000, sr), GeometryFactory.CreatePoint(2600500, 1200500, sr), GeometryFactory.CreatePoint(2601000, 1200500, sr)); sourcePath.SpatialReference = sr; IPolyline sourcePolyline = GeometryFactory.CreatePolyline(sourcePath); GdbFeature sourceFeature = new GdbFeature(42, fClass) { Shape = sourcePolyline }; IPath reshapePath = GeometryFactory.CreatePath( GeometryFactory.CreatePoint(2600500, 1200500, sr), GeometryFactory.CreatePoint(2600500, 1201000, sr)); reshapePath.SpatialReference = sr; IPolyline reshapePolyline = GeometryFactory.CreatePolyline(reshapePath); var sourceFeatureMsg = ProtobufGdbUtils.ToGdbObjectMsg(sourceFeature); var reshapePathMsg = ProtobufGeometryUtils.ToShapeMsg(reshapePolyline); var request = new OpenJawReshapeLineReplacementRequest { Feature = sourceFeatureMsg, ReshapePath = reshapePathMsg }; ShapeMsg response = AdvancedReshapeServiceUtils.GetOpenJawReshapeReplaceEndPoint(request); IPoint resultPoint = (IPoint)ProtobufGeometryUtils.FromShapeMsg(response); Assert.IsTrue(GeometryUtils.AreEqual(sourcePolyline.ToPoint, resultPoint)); // Non-default side: request.UseNonDefaultReshapeSide = true; response = AdvancedReshapeServiceUtils.GetOpenJawReshapeReplaceEndPoint(request); resultPoint = (IPoint)ProtobufGeometryUtils.FromShapeMsg(response); Assert.IsTrue(GeometryUtils.AreEqual(sourcePolyline.FromPoint, resultPoint)); }
public void CanSplitEdgeOnNodeInsertion() { ISpatialReference sr = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV95, WellKnownVerticalCS.LHN95); FeatureClassMock edgeClass, junctionClass; LinearNetworkDef networkDef = CreateSimpleNetworkDef(out edgeClass, out junctionClass); var networkFeatureFinder = new NetworkFeatureFinderMock(); LinearNetworkEditAgent observer = new LinearNetworkEditAgent( networkDef, networkFeatureFinder); observer.NoCaching = true; // Existing feature: IPolyline edge1Polyline = GeometryFactory.CreatePolyline( GeometryFactory.CreatePoint(2600000, 1200000, 450, double.NaN, sr), GeometryFactory.CreatePoint(2600020, 1200010, 452, double.NaN, sr)); IFeature existingFeature = CreateInOperation( () => CreateFeature(edgeClass, edge1Polyline), observer); Assert.AreEqual(1, observer.GetCreatedInLastOperation().Count()); Assert.IsTrue(existingFeature == observer.GetCreatedInLastOperation().First()); // New features get added to the feature finder's cache: 1 edge + 2 junctions Assert.AreEqual(3, networkFeatureFinder.TargetFeatureCandidates.Count); // Create edge snapped onto interior (Z actually does not matter): IPolyline edge2Polyline = GeometryFactory.CreatePolyline( GeometryFactory.CreatePoint(2600010, 1200010, 450, double.NaN, sr), GeometryFactory.CreatePoint(2600010, 1200005, 451, double.NaN, sr)); IFeature snappedFeature = CreateInOperation( () => CreateFeature(edgeClass, edge2Polyline), observer); Assert.NotNull(snappedFeature); Assert.AreEqual(1, observer.GetCreatedInLastOperation().Count()); // 3 original features + 1 new edge + 2 junctions + 1 new split-edge Assert.AreEqual(7, networkFeatureFinder.TargetFeatureCandidates.Count); // Now just add a junction feature IPoint junctionPoint = GeometryFactory.CreatePoint(2600002, 1200001, 450, double.NaN, sr); IFeature insertedJunction = CreateInOperation( () => CreateFeature(junctionClass, junctionPoint), observer); Assert.NotNull(insertedJunction); Assert.AreEqual(1, observer.GetCreatedInLastOperation().Count()); // 7 original features + 1 new junction + 1 new split-edge Assert.AreEqual(9, networkFeatureFinder.TargetFeatureCandidates.Count); }
private static IFeature CreateEdge(IFeatureClass edgeClass, IPoint fromPoint, IPoint toPoint) { IFeature edge1 = edgeClass.CreateFeature(); edge1.Shape = GeometryFactory.CreatePolyline(fromPoint, toPoint); edge1.Store(); return(edge1); }
public void TestSegmentsBothInside() { var expectedErrorGeometries = new List <IPolyline>(); IPolyline segment = GeometryFactory.CreatePolyline(2000000, 1000000, 200, 2000000, 1001000, 200); TestPolycurve(segment, expectedErrorGeometries, 100, 300); }
public void TestSegmentsWholeAbove() { var expectedErrorGeometries = new List <IPolyline>(); IPolyline segment = GeometryFactory.CreatePolyline(2000000, 1000000, 400, 2000000, 1001000, 400); expectedErrorGeometries.Add(segment); TestPolycurve(segment, expectedErrorGeometries, 100, 300); }
private void ResetCorruptFlatEndEnvironment() { if (_dummyLine == null) { _dummyLine = GeometryFactory.CreatePolyline(0, 0, 10, 0); } // buffering any LINE resets whatever is the problem for flat end buffers, // even when using the simple Buffer() method _construction.Buffer(_dummyLine, 1); }
private static IPolyline BufferTargetLine([NotNull] IPolyline targetLine, [NotNull] TargetBufferOptions options, [CanBeNull] IEnvelope envelopeScope, [CanBeNull] NotificationCollection bufferNotifications, [CanBeNull] ITrackCancel trackCancel) { Assert.ArgumentNotNull(targetLine, nameof(targetLine)); Assert.ArgumentCondition(!targetLine.IsEmpty, "BufferTargetLine: Target line is empty."); IPolyline result = null; IPolygon targetBuffer; if (AdjustUtils.TryBuffer(targetLine, options.BufferDistance, options.LogInfoPointThreshold, "Buffering target geometry...", bufferNotifications, out targetBuffer)) { Assert.NotNull(targetBuffer, "targetBuffer"); if (trackCancel != null && !trackCancel.Continue()) { return(targetLine); } if (options.EnforceMinimumBufferSegmentLength) { // TODO: removing short segments is slow if many adjacent segments // need to be removed. if (trackCancel != null && !trackCancel.Continue()) { return(targetLine); } if (((IPointCollection)targetLine).PointCount > options.LogInfoPointThreshold) { _msg.Info("Removing short segments from buffer..."); } EnforceMinimumSegmentLength(targetBuffer, options.BufferMinimumSegmentLength, envelopeScope); } result = GeometryFactory.CreatePolyline(targetBuffer); Marshal.ReleaseComObject(targetBuffer); } return(result); }
public void CanKeepConnectedStableOnMerge() { ISpatialReference sr = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV95, WellKnownVerticalCS.LHN95); FeatureClassMock edgeClass, junctionClass; LinearNetworkDef networkDef = CreateSimpleNetworkDef(out edgeClass, out junctionClass); var networkFeatureFinder = new NetworkFeatureFinderMock(); LinearNetworkEditAgent observer = new LinearNetworkEditAgent( networkDef, networkFeatureFinder) { NoCaching = true }; // Existing feature: IPolyline edge1Polyline = GeometryFactory.CreatePolyline( GeometryFactory.CreatePoint(2600000, 1200000, 450, double.NaN, sr), GeometryFactory.CreatePoint(2600020, 1200010, 452, double.NaN, sr)); IFeature existingFeature = CreateInOperation( () => CreateFeature(edgeClass, edge1Polyline), observer); // Add a connected edge feature: IPolyline edge2Polyline = GeometryFactory.CreatePolyline( GeometryFactory.CreatePoint(2600020, 1200010, 452, double.NaN, sr), GeometryFactory.CreatePoint(2600030, 1200005, 450, double.NaN, sr)); IPolyline edge2PolylineOrig = GeometryFactory.Clone(edge2Polyline); IFeature secondEdge = CreateInOperation( () => CreateFeature(edgeClass, edge2Polyline), observer); Assert.NotNull(secondEdge); Assert.AreEqual(1, observer.GetCreatedInLastOperation().Count()); IPolyline edge3Polyline = GeometryFactory.CreatePolyline( GeometryFactory.CreatePoint(2600020, 1200010, 452, double.NaN, sr), GeometryFactory.CreatePoint(2600030, 1200015, 450, double.NaN, sr)); IFeature thirdEdge = CreateInOperation( () => CreateFeature(edgeClass, edge3Polyline), observer); // Now merge features 1 and 2: MergeInOperation(existingFeature, thirdEdge, observer); Assert.AreEqual(1, observer.GetUpdatedInLastOperation().Count()); // Make sure the second edge has not changed: Assert.IsTrue(GeometryUtils.AreEqual(edge2PolylineOrig, secondEdge.Shape)); }
public void CanReadWriteSinglePartPolylineXy() { 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 }; IPolyline polyline = GeometryFactory.CreatePolyline(points, null); GeometryUtils.MakeNonZAware(polyline); GeometryUtils.Simplify(polyline); WkbGeometryWriter writer = new WkbGeometryWriter(); byte[] wkb = writer.WritePolyline(polyline); // ArcObjects byte[] arcObjectsWkb = GeometryUtils.ToWkb(polyline); Assert.AreEqual(wkb, arcObjectsWkb); // Wkx byte[] wkx = ToChristianSchwarzWkb(ToWkxLineString(points, Ordinates.Xy)); Assert.AreEqual(wkx, wkb); // Bonus test: Geom WkbGeomWriter geomWriter = new WkbGeomWriter(); MultiPolycurve multiPlycurve = GeometryConversionUtils.CreateMultiPolycurve(polyline); byte[] wkbGeom = geomWriter.WriteMultiLinestring(multiPlycurve, Ordinates.Xy); Assert.AreEqual(wkb, wkbGeom); WkbGeometryReader reader = new WkbGeometryReader(); IPolyline restored = reader.ReadPolyline(new MemoryStream(wkb)); Assert.IsTrue(GeometryUtils.AreEqual(polyline, restored)); // Geom WkbGeomReader geomReader = new WkbGeomReader(); Assert.IsTrue( multiPlycurve.Equals(geomReader.ReadMultiPolycurve(new MemoryStream(wkbGeom)))); }
private static void AddLineFeature([NotNull] IFeatureClass featureClass, double x1, double y1, double x2, double y2, [CanBeNull] string stateId = null, [CanBeNull] string textFieldValue = null, double?doubleValue = null, DateTime?dateValue = null) { AddFeature(featureClass, GeometryFactory.CreatePolyline(x1, y1, x2, y2), stateId, textFieldValue, doubleValue, dateValue); }
public void CanCutPolygonWithCorrectZ_Top4666() { // Tests the work-around for TOP-4666 // TODO: Report ArcObjects bug to Esri Inc. IFeature polygonFeature = TestUtils.CreateMockFeature("PolygonTop4666.xml"); var cutLine = (IPolyline) TestUtils.ReadGeometryFromXml( TestUtils.GetGeometryTestDataPath("CutLineTop4666.xml")); GeometryUtils.EnsureSpatialReference( cutLine, polygonFeature.Shape.SpatialReference); var cutter = new FeatureCutter(new[] { polygonFeature }); Stopwatch watch = Stopwatch.StartNew(); cutter.Cut(cutLine); watch.Stop(); Console.WriteLine("Cut large feature: {0}ms", watch.ElapsedMilliseconds); Assert.AreEqual(5, cutter.ResultGeometriesByFeature[polygonFeature].Count); foreach (IGeometry geometry in cutter.ResultGeometriesByFeature[ polygonFeature]) { var polygon = (IPolygon)geometry; Assert.False(GeometryUtils.HasUndefinedZValues(polygon)); GeometryUtils.Simplify(polygon); Assert.False(GeometryUtils.HasUndefinedZValues(polygon)); foreach (IPoint point in GeometryUtils.GetPoints( (IPointCollection)polygon)) { Assert.AreNotEqual(0, point.Z); } IPolyline resultAsPolyline = GeometryFactory.CreatePolyline(polygon); IPolyline zDifference = ReshapeUtils.GetZOnlyDifference(resultAsPolyline, cutLine); // ArcObjects uses the cutLine's Z also at the intersection points. // Do the same in CustomIntersect? Assert.IsNull(zDifference); } }
private IPolyline GetAdvancingTileBoundary([NotNull] IEnvelope tileEnvelope) { IPolyline result = GeometryFactory.CreatePolyline( tileEnvelope.SpatialReference, GeometryFactory.CreatePoint(_allBox.Min.X, tileEnvelope.YMax), GeometryFactory.CreatePoint(tileEnvelope.XMax, tileEnvelope.YMax), GeometryFactory.CreatePoint(tileEnvelope.XMax, tileEnvelope.YMin)); GeometryUtils.AllowIndexing(result); return(result); }
public void TestSegmentsOneBelow() { var expectedErrorGeometries = new List <IPolyline>(); IPolyline segment = GeometryFactory.CreatePolyline(2000000, 1000000, 200, 2000200, 1001000, 75); IPolyline errorSegment1 = GeometryFactory.CreatePolyline(2000160, 1000800, 100, 2000200, 1001000, 75); expectedErrorGeometries.Add(errorSegment1); TestPolycurve(segment, expectedErrorGeometries, 100, 300); }
public void CanReplaceSegmentsWithNonZAwareReplacement() { ISpatialReference lv95 = SpatialReferenceUtils.CreateSpatialReference(WellKnownHorizontalCS.LV95, WellKnownVerticalCS.LHN95); IPolyline originalPolyline = GeometryFactory.CreatePolyline( GeometryFactory.CreatePath( GeometryFactory.CreatePoint(2600000, 1200000, 400, double.NaN, lv95), GeometryFactory.CreatePoint(2600010, 1200000, 410, double.NaN, lv95), GeometryFactory.CreatePoint(2600020, 1200000, 410, double.NaN, lv95), GeometryFactory.CreatePoint(2600030, 1200000, 420, double.NaN, lv95))); IPath replacement = GeometryFactory.CreatePath( GeometryFactory.CreatePoint(2600010, 1200000, 0, double.NaN, lv95), GeometryFactory.CreatePoint(2600015, 1200010, 500, double.NaN, lv95), GeometryFactory.CreatePoint(2600020, 1200000, 900, double.NaN, lv95)); // NOTE: The Z value of the first point of the replacement is used, however, the envelope of the resulting pathToReshape is not updated! // Hence it is crucial to insert the exact replacement end points into the geometry to reshape! IPolyline polyline = GeometryFactory.Clone(originalPolyline); var pathToReshape = (ISegmentCollection)((IGeometryCollection)polyline).Geometry[0]; GeometryUtils.MakeNonZAware(replacement); SegmentReplacementUtils.ReplaceSegments((IPath)pathToReshape, replacement, replacement.FromPoint, replacement.ToPoint); Assert.AreEqual(410, ((IPointCollection)pathToReshape).Point[1].Z); Assert.AreEqual(400, polyline.Envelope.ZMin, "Envelope is not inconsistent any more after segment replacment!"); // Now connect within a segment: IPoint firstPoint = replacement.FromPoint; firstPoint.X = 2600007; ((IPointCollection)replacement).UpdatePoint(0, firstPoint); polyline = GeometryFactory.Clone(originalPolyline); pathToReshape = (ISegmentCollection)((IGeometryCollection)polyline).Geometry[0]; GeometryUtils.MakeNonZAware(replacement); SegmentReplacementUtils.ReplaceSegments((IPath)pathToReshape, replacement, replacement.FromPoint, replacement.ToPoint); Assert.AreEqual(407, ((IPointCollection)pathToReshape).Point[1].Z); Assert.AreEqual(400, polyline.Envelope.ZMin, "Envelope is not inconsistent any more after segment replacment!"); }
public void CanUseZMinMaxAliasEvenIfNotZAware() { IFeatureClass featureClass = CreateFeatureClass( "CanUseZMinMaxAliasEvenIfNotZAware", esriGeometryType.esriGeometryPolyline); IFeature feature = featureClass.CreateFeature(); feature.Shape = GeometryFactory.CreatePolyline(0, 0, 5, 5); feature.Store(); AssertFilteredRowCount(1, "$ShapeZMin IS NULL AND $ShapeZMax IS NULL", feature); }
public void CanUseMMinMaxAliasInMultiTableView() { IFeatureClass featureClass = CreateFeatureClass( "CanUseMMinMaxAliasInMultiTableView", esriGeometryType.esriGeometryPolyline, zAware: true, mAware: true); ITable table = CreateTable("CanUseMMinMaxAliasInMultiTableView_table", FieldUtils.CreateOIDField(), FieldUtils.CreateIntegerField("NUMBER")); IFeature f1 = featureClass.CreateFeature(); f1.Shape = GeometryFactory.CreatePolyline( GeometryFactory.CreatePoint(0, 0, 1000, 100), GeometryFactory.CreatePoint(5, 5, 1000, 200)); f1.Store(); IFeature f2 = featureClass.CreateFeature(); f2.Shape = GeometryFactory.CreatePolyline( GeometryFactory.CreatePoint(0, 0, 1000, 300), GeometryFactory.CreatePoint(5, 5, 1000, 400)); f2.Store(); int fieldIndexNumber = table.FindField("NUMBER"); IRow r1 = table.CreateRow(); r1.Value[fieldIndexNumber] = 100; r1.Store(); IRow r2 = table.CreateRow(); r2.Value[fieldIndexNumber] = 200; r2.Store(); AssertFilteredMultiViewRowCount(1, "F.$ShapeMMin = 100 AND F.$ShapeMMax = 200 AND T.NUMBER = 100", featureClass, f1, table, r1); AssertFilteredMultiViewRowCount(0, "F.$ShapeMMin = 100 AND F.$ShapeMMax = 200 AND T.NUMBER = 10000", featureClass, f1, table, r1); AssertFilteredMultiViewRowCount(1, "F.$ShapeMMin = 300 AND F.$ShapeMMax = 400 AND T.NUMBER = 200", featureClass, f2, table, r2); AssertFilteredMultiViewRowCount(0, "F.$ShapeMMin = 300 AND F.$ShapeMMax = 400 AND T.NUMBER = 10000", featureClass, f2, table, r2); }
public void CanDeterminePolygonReshapeSideInsideAndOutsideOnePartWithBoundaryLoop() { // _ // / \ // / \ //--/--\--\----- // \__\ // The original polygon is below the horizontal dashed-line: --- ISpatialReference spatialReference = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV95, WellKnownVerticalCS.LHN95); IGeometry geometryToReshape = GeometryFactory.CreatePolygon(100, 100, 200, 200, spatialReference); IGeometry reshapeLine = GeometryFactory.CreatePolyline(spatialReference, GeometryFactory.CreatePoint(125, 200), GeometryFactory.CreatePoint(125, 250), GeometryFactory.CreatePoint(175, 250), GeometryFactory.CreatePoint(175, 150), GeometryFactory.CreatePoint(150, 150), GeometryFactory.CreatePoint(150, 200)); // plus one quarter minus 50 * 25 = 12500 - 1250 = 11250 ReshapeInfo reshapeInfo = Reshape(GeometryFactory.Clone(geometryToReshape), reshapeLine, false); ExpectResult(reshapeInfo, RingReshapeSideOfLine.Right, 11250, 1, 1); // has boundary loop: MakeInnerRing(reshapeInfo.GeometryToReshape); GeometryUtils.Simplify(reshapeInfo.GeometryToReshape); Assert.AreEqual(3, ((IGeometryCollection)reshapeInfo.GeometryToReshape).GeometryCount); Assert.AreEqual(2, ((IPolygon)reshapeInfo.GeometryToReshape).ExteriorRingCount); const bool useNonDefaultSide = true; reshapeInfo = Reshape(GeometryFactory.Clone(geometryToReshape), reshapeLine, useNonDefaultSide); // non-boundary loop variant: ExpectResult(reshapeInfo, RingReshapeSideOfLine.Left, 3750, 1, 1); MakeInnerRing(reshapeInfo.GeometryToReshape); GeometryUtils.Simplify(reshapeInfo.GeometryToReshape); Assert.AreEqual(2, ((IGeometryCollection)reshapeInfo.GeometryToReshape).GeometryCount); Assert.AreEqual(1, ((IPolygon)reshapeInfo.GeometryToReshape).ExteriorRingCount); }
public void CanCalculateDifferenceInLargeGeometry() { const int manyPointsPerPart = 123456; const int holes = 3; IPolygon poly2a = CreatePunchedSquarePolygon("2a", manyPointsPerPart, holes, 1); GeometryUtils.Simplify(poly2a, true, true); IPolygon poly2b = GeometryFactory.Clone(poly2a); var watch = new Stopwatch(); watch.Start(); IPolyline line2a = GeometryFactory.CreatePolyline(poly2a); IPolyline line2b = GeometryFactory.CreatePolyline(poly2b); watch.Stop(); Console.WriteLine(@"Created polylines in {0} ms", watch.ElapsedMilliseconds); watch.Reset(); watch.Start(); IPolyline result = ReshapeUtils.GetZOnlyDifference(line2a, line2b); watch.Stop(); Assert.IsNull(result); Console.WriteLine(@"Calculate Z-only difference (no changes) in {0} ms", watch.ElapsedMilliseconds); var comparison = new GeometryComparison(line2a, line2b); watch.Reset(); watch.Start(); IDictionary <WKSPointZ, VertexIndex> differences = comparison.GetDifference(true); watch.Stop(); Console.WriteLine(@"Calculate Difference (no changes) in {0} ms", watch.ElapsedMilliseconds); Assert.AreEqual(0, differences.Count); }
public void CanCheckPolyline() { IPolyline line = GeometryFactory.CreatePolyline(0, 100, 1000, 10, 100, 1010); line.SpatialReference = CreateSpatialReference(); line.SnapToSpatialReference(); // to allow check for double equality AssertFulfilled("NOT $ISCLOSED", line); AssertFulfilled("$CIRCULARARCCOUNT = 0", line); AssertFulfilled("$ELLIPTICARCCOUNT = 0", line); AssertFulfilled("$BEZIERCOUNT = 0", line); AssertFulfilled("$SEGMENTCOUNT = 1", line); AssertFulfilled("$LINEARSEGMENTCOUNT = 1", line); AssertFulfilled("$NONLINEARSEGMENTCOUNT = 0", line); AssertFulfilled("$PARTCOUNT = 1", line); AssertFulfilled("$VERTEXCOUNT = 2", line); AssertFulfilled("NOT $ISMULTIPART", line); AssertFulfilled("$AREA = 0", line); AssertFulfilled("$LENGTH = 10", line); AssertFulfilled("$SLIVERRATIO IS NULL", line); AssertFulfilled("$DIMENSION = 1", line); AssertFulfilled("$INTERIORRINGCOUNT = 0", line); AssertFulfilled("$EXTERIORRINGCOUNT = 0", line); AssertFulfilled("$RINGCOUNT = 0", line); AssertFulfilled("$TRIANGLEFANCOUNT = 0", line); AssertFulfilled("$TRIANGLESTRIPCOUNT = 0", line); AssertFulfilled("$TRIANGLESPATCHCOUNT = 0", line); AssertFulfilled("NOT $ISEXTERIORRING", line); AssertFulfilled("NOT $ISINTERIORRING", line); AssertFulfilled("$XMIN = 0", line); AssertFulfilled("$YMIN = 100", line); AssertFulfilled("$XMAX = 10", line); AssertFulfilled("$YMAX = 100", line); AssertFulfilled("$ZMIN = 1000", line); AssertFulfilled("$ZMAX = 1010", line); AssertFulfilled("$MMIN IS NULL", line); AssertFulfilled("$MMAX IS NULL", line); AssertFulfilled("$UNDEFINEDMVALUECOUNT = 2", line); AssertFulfilled("$CONTROLPOINTCOUNT = 0", line); AssertFulfilled("1 = 1", line); AssertFulfilled(" ", line); AssertNotFulfilled("1 = 2", line); AssertNotFulfilled("$AREA > 200 AND $LENGTH > 30", line); AssertNotFulfilled("$SLIVERRATIO > 100", line); AssertFulfilled("NOT ($ISCLOSED AND $CIRCULARARCCOUNT = 1 AND $SEGMENTCOUNT = 1)", line); }
private static List <IPolyline> GetPaths( [NotNull] IGeometryCollection pathCollection) { int pathCount = pathCollection.GeometryCount; var result = new List <IPolyline>(pathCount); for (var i = 0; i < pathCount; i++) { result.Add(GeometryFactory.CreatePolyline(pathCollection.get_Geometry(i))); } return(result); }
private static IPolyline GetClippedOutline(IGeometry geometry, IEnvelope clipEnvelope) { IPolyline geometryAsLine = GeometryFactory.CreatePolyline(geometry); IPolyline result = GeometryUtils.GetClippedPolyline(geometryAsLine, clipEnvelope); // in case of cut polygon boundaries: merge the lines at poly start/end point: GeometryUtils.Simplify(result, true, true); Marshal.ReleaseComObject(geometryAsLine); return(result); }
private static IPolyline CreatePolyline( [NotNull] IPoint fromPoint, [NotNull] IPoint secondPoint, params IPoint[] additionalPoints) { ISpatialReference spatialReference = CreateSpatialReference(); IPolyline result = GeometryFactory.CreatePolyline(spatialReference, fromPoint, secondPoint, additionalPoints); GeometryUtils.Simplify(result); GeometryUtils.AllowIndexing(result); return(result); }