public void CanReadWritePoint() { IPoint pointXy = GeometryFactory.CreatePoint(2600000, 1200000); IPoint pointXyz = GeometryFactory.CreatePoint(2600000, 1200000, 400); WkbGeometryWriter writer = new WkbGeometryWriter(); byte[] wkb2D = writer.WritePoint(pointXy); byte[] wkb3D = writer.WritePoint(pointXyz); // Compare with AO (2D only) byte[] arcObjectsWkb = GeometryUtils.ToWkb(pointXy); Assert.AreEqual(arcObjectsWkb, wkb2D); // Compare with Wkx byte[] wkx2D = ToChristianSchwarzWkb(pointXy); Assert.AreEqual(wkx2D, wkb2D); byte[] wkx3D = ToChristianSchwarzWkb(pointXyz); Assert.AreEqual(wkx3D, wkb3D); // Bonus test: Geom WkbGeomWriter geomWriter = new WkbGeomWriter(); Pnt3D pnt2D = new Pnt3D(pointXy.X, pointXy.Y, double.NaN); byte[] bytesGeom2D = geomWriter.WritePoint(pnt2D, Ordinates.Xy); Assert.AreEqual(wkb2D, bytesGeom2D); Pnt3D pnt3D = new Pnt3D(pointXyz.X, pointXyz.Y, pointXyz.Z); byte[] bytesGeom3D = geomWriter.WritePoint(pnt3D); Assert.AreEqual(wkb3D, bytesGeom3D); // NOTE: Comparison with ST_Geometry SDE.ST_AsBinary(SHAPE) using nHibernate // connection is performed in StGeometryPerimeterRepositoryTest // Read back: WkbGeometryReader reader = new WkbGeometryReader(); IPoint restored = reader.ReadPoint(new MemoryStream(wkb2D)); Assert.IsTrue(GeometryUtils.AreEqual(pointXy, restored)); restored = reader.ReadPoint(new MemoryStream(wkb3D)); Assert.IsTrue(GeometryUtils.AreEqual(pointXyz, restored)); // Geom: WkbGeomReader geomReader = new WkbGeomReader(); Assert.IsTrue(pnt2D.Equals(geomReader.ReadPoint(new MemoryStream(bytesGeom2D)))); Assert.IsTrue(pnt3D.Equals(geomReader.ReadPoint(new MemoryStream(bytesGeom3D)))); }
public void CanWritePoint() { Pnt3D point = new Pnt3D(2600001.123, 1200000.987, 432.1); WkbGeomWriter writer = new WkbGeomWriter(); byte[] bytes = writer.WritePoint(point); WkbGeomReader reader = new WkbGeomReader(); IPnt deserializedPoint = reader.ReadPoint(new MemoryStream(bytes)); Assert.IsTrue(deserializedPoint.Equals(point)); }