예제 #1
0
        public void CanWriteMultiPoint()
        {
            Pnt3D point1 = new Pnt3D(2600001.123, 1200000.987, 432.1);
            Pnt3D point2 = new Pnt3D(2600002.234, 1200002.876, 321.98);

            IList <IPnt> multipoint = new IPnt[]
            {
                point1,
                point2
            };

            WkbGeomWriter writer = new WkbGeomWriter();

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

            WkbGeomReader reader = new WkbGeomReader();

            List <IPnt> deserizalized = reader.ReadMultiPoint(new MemoryStream(bytes)).ToList();

            Assert.AreEqual(multipoint.Count, deserizalized.Count);

            for (int i = 0; i < multipoint.Count; i++)
            {
                Assert.IsTrue(deserizalized[i].Equals(multipoint[i]));
            }
        }
예제 #2
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));
        }
예제 #3
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));
        }
예제 #4
0
        public void CanWriteMultiPoint()
        {
            Pnt3D point1 = new Pnt3D(2600001.123, 1200000.987, 432.1);
            Pnt3D point2 = new Pnt3D(2600002.234, 1200002.876, 321.98);

            var multipoint = new Multipoint <IPnt>(new[]
            {
                point1,
                point2
            });

            WkbGeomWriter writer = new WkbGeomWriter();

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

            WkbGeomReader reader = new WkbGeomReader();

            Multipoint <IPnt> deserizalized = reader.ReadMultiPoint(new MemoryStream(bytes));

            Assert.AreEqual(multipoint.PointCount, deserizalized.PointCount);

            Assert.IsTrue(deserizalized.Equals(multipoint));
        }