public void CanCreateBagWithCopies() { ISpatialReference sref = SpatialReferenceUtils.CreateSpatialReference(WellKnownHorizontalCS.LV95); IGeometry pt1 = GeometryFactory.CreatePoint(100, 200, 0); IGeometry pt2 = GeometryFactory.CreatePoint(100, 200, 0); pt1.SpatialReference = sref; IGeometryBag bag = GeometryFactory.CreateBag(pt1, pt2); var collection = (IGeometryCollection)bag; Assert.AreEqual(2, collection.GeometryCount); IGeometry bagPt1 = collection.get_Geometry(0); IGeometry bagPt2 = collection.get_Geometry(1); // expect copies in the bag Assert.AreNotEqual(pt1, bagPt1); Assert.AreNotEqual(pt2, bagPt2); Assert.IsTrue( SpatialReferenceUtils.AreEqual(sref, bag.SpatialReference, true, true)); Assert.IsTrue( SpatialReferenceUtils.AreEqual(sref, bagPt1.SpatialReference, true, true)); Assert.IsTrue( SpatialReferenceUtils.AreEqual(sref, bagPt2.SpatialReference, true, true)); }
public void CantCreateBagWithOriginalsIfSpatialReferenceDifferent() { ISpatialReference sref = SpatialReferenceUtils.CreateSpatialReference(WellKnownHorizontalCS.LV95); IGeometry pt1 = GeometryFactory.CreatePoint(100, 200, 0); IGeometry pt2 = GeometryFactory.CreatePoint(100, 200, 0); pt1.SpatialReference = sref; var list = new List <IGeometry> { pt1, pt2 }; Assert.Throws <ArgumentException>( () => GeometryFactory.CreateBag(list, CloneGeometry.Never)); }
private static IPolygon UnionPolygons([NotNull] IEnumerable <IGeometry> polygons, [CanBeNull] ISpatialReference spatialReference) { const bool allowProjectingInput = true; IGeometryBag bag = GeometryFactory.CreateBag(polygons, CloneGeometry.IfChangeNeeded, spatialReference, allowProjectingInput); var result = new PolygonClass { SpatialReference = spatialReference }; result.ConstructUnion((IEnumGeometry)bag); return(result); }