public void WriteToArray_WritesAllGeometryTypes(string wkt, byte[] expectedWkb) { IGeometry geometry = this.ParseWKT(wkt); byte[] wkb = WkbWriter.WriteToArray(geometry); this.CompareBytes(wkb, expectedWkb); }
public void If_input_an_invalid_geometry_then_should_throw_exception() { var point = new Point(); Should.Throw <ArgumentException>(() => WkbWriter.Write(point)) .Message.ShouldBe("Invalid geometry"); }
public void Construcotor_PathSettings_SetsSettingsAndMakeThemReadOnly() { WkbWriterSettings settings = new WkbWriterSettings(); using (WkbWriter target = new WkbWriter(new MemoryStream(), settings)) { Assert.Same(settings, target.Settings); Assert.True(settings.IsReadOnly); } }
public void Dispose_ClosesOutputStreamIfWritingToStream() { MemoryStream stream = new MemoryStream(); WkbWriter target = new WkbWriter(stream, new WkbWriterSettings()); target.Dispose(); Assert.False(stream.CanRead); }
public void Write_Writes3DMeasuredLineString() { string wkt = "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)"; LineString linestring = (LineString)this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(linestring); this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-3DM.wkb")); } }
public void Constructor_PathSettings_CreatesOutputFile() { string filename = PathHelper.GetTempFilePath("wkbwriter-constructor-creates-output-test.bin"); WkbWriterSettings settings = new WkbWriterSettings(); using (WkbWriter target = new WkbWriter(filename, settings)) { ; } Assert.True(File.Exists(filename)); }
public void Write_Writes3DMultiPoint() { string wkt = "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))"; MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipoint); this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-3D.wkb")); } }
public void Write_Writes3DMeasuredPolygonOnlyExteriorRing() { string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; Polygon polygon = (Polygon)this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(polygon); this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-3DM.wkb")); } }
public void Write_Writes3DLineString() { string wkt = "linestring z (-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)"; LineString linestring = (LineString)this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(linestring); this.CompareBytes(stream.ToArray(), IOTestData.linestring_3D); } }
public void Write_Writes3DMeasuredPoint() { string wkt = "point zm (-10.1 15.5 100.5 1000.5)"; Point point = (Point)this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(point); this.CompareBytes(stream.ToArray(), TestDataReader.Read("point-3DM.wkb")); } }
public void Write_Writes3DMeasuredMultiPoint() { string wkt = "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))"; MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipoint); this.CompareBytes(stream.ToArray(), IOTestData.multipoint_3DM); } }
public void Write_WritesEmptyMultiPolygon() { string wkt = "multipolygon empty"; MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipolygon); this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-empty.wkb")); } }
public void Write_Writes3DMeasuredMultiPolygon() { string wkt = "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))"; MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipolygon); this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-3DM.wkb")); } }
public void Write_Writes3DMeasuredGeometryCollection() { string wkt = "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))"; GeometryCollection <Geometry> collection = (GeometryCollection <Geometry>) this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(collection); this.CompareBytes(stream.ToArray(), IOTestData.collection_3DM); } }
public void Write_WritesEmptyGeometryCollection() { string wkt = "geometrycollection empty"; GeometryCollection <Geometry> collection = (GeometryCollection <Geometry>) this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(collection); this.CompareBytes(stream.ToArray(), IOTestData.collection_empty); } }
public void Write_Writes2DMultiPolygon() { string wkt = "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipolygon); this.CompareBytes(stream.ToArray(), IOTestData.multipolygon_2D); } }
public void Write_Writes2DMeasuredMultiLineString() { string wkt = "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multilinestring); this.CompareBytes(stream.ToArray(), IOTestData.multilinestring_2DM); } }
public void Write_WritesEmptyMultiLineString() { string wkt = "multilinestring empty"; MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multilinestring); this.CompareBytes(stream.ToArray(), IOTestData.multilinestring_empty); } }
public void Write_WritesEmptyPolygon() { string wkt = "polygon empty"; Polygon polygon = (Polygon)this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(polygon); this.CompareBytes(stream.ToArray(), IOTestData.polygon_empty); } }
public void Write_Writes3DMultiLineString() { string wkt = "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multilinestring); this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-3D.wkb")); } }
public void Write_WritesCollectionWithMultiGeometries() { string wkt = "geometrycollection (multipoint empty,multilinestring empty,multipolygon empty)"; GeometryCollection <Geometry> collection = (GeometryCollection <Geometry>) this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(collection); this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-multi.wkb")); } }
public void Write_Writes3DPolygonOnlyExteriorRing() { string wkt = "polygon z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; Polygon polygon = (Polygon)this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(polygon); this.CompareBytes(stream.ToArray(), IOTestData.polygon_ext_3D); } }
public void Write_Writes3DMeasuredPolygon() { string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; Polygon polygon = (Polygon)this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(polygon); this.CompareBytes(stream.ToArray(), IOTestData.polygon_3DM); } }
public void Write_WritesCollectionWithPointLineStringAndPolygon() { string wkt = "geometrycollection (point (-10.1 15.5),linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5),polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; GeometryCollection <Geometry> collection = (GeometryCollection <Geometry>) this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(collection); this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-pt-ls-poly.wkb")); } }
public void WkbWriter_Write_WritesLittleEndianEncodingByte() { MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings() { Encoding = BinaryEncoding.LittleEndian })) { target.Write(new Point()); CompareBytes(stream.ToArray(), 0, new byte[] { (byte)BinaryEncoding.LittleEndian }); } }
public void Write_WritesNestedCollection() { string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; GeometryCollection <Geometry> collection = (GeometryCollection <Geometry>) this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(collection); this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-nested.wkb")); } }
public void Write_WritesEmptyPointAsEmptyGeoemtryCollection() { string wkt = "point empty"; Point point = (Point)this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(point); this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-empty.wkb")); } }
public void Write_WritesEmptyLineString() { string wkt = "linestring empty"; LineString linestring = (LineString)this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(linestring); this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-empty.wkb")); } }
public void Write_Writes3DPoint() { string wkt = "point z (-10.1 15.5 100.5)"; Point point = (Point)this.ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(point); this.CompareBytes(stream.ToArray(), IOTestData.point_3D); } }
public void Dispose_ClosesOutputStreamIfWritingToFiles() { string filename = PathHelper.GetTempFilePath("wkbwriter-closes-output-filestream-test.bin"); WkbWriterSettings settings = new WkbWriterSettings(); WkbWriter target = new WkbWriter(filename, settings); target.Dispose(); FileStream testStream = null; testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); testStream.Dispose(); }