public void ReadT_ReadsGeometry() { using (WktReader target = new WktReader(new MemoryStream(Data.IOTestData.wkt_point_3DM))) { Point read = target.Read <Point>(); Assert.NotNull(read); } }
public static void LoadRestaurants(string csvFile, BulkInsertOperation bulkInsert) { var wktReader = new WktReader(); using (var reader = new StreamReader(csvFile)) using (var csv = new CsvReader(reader, new CsvConfiguration { UseInvariantCulture = true })) { var restaurantCsvRows = csv.GetRecords <RestaurantCsvRow>(); foreach (var row in restaurantCsvRows) { Polygon deliveryArea = null; if (!string.IsNullOrEmpty(row.DeliveryArea)) { deliveryArea = (Polygon)wktReader.Read(row.DeliveryArea); } var restaurant = new Restaurant { Name = row.Name, Street = row.Street, City = row.City, PostCode = row.PostCode, Phone = row.Phone, Location = new Point(row.Latitude, row.Longitude), DeliveryArea = deliveryArea, DriveThruArea = string.IsNullOrEmpty(row.DriveThruArea) ? null : row.DriveThruArea }; bulkInsert.Store(restaurant); } } }
public void NoPrjFileThenSetCoordinateSystemGivesSpatialRefToGeometries() { //Layer name: BCROADSWithoutDbf //Geometry: Line String //Feature Count: 7291 //Extent: (7332083.212797, 236823.718672) - (7538428.618000, 405610.346926) ShapeFileProvider shapeFile = new ShapeFileProvider( BcRoadsWithOutDbfShapeFile, _geoFactory); shapeFile.Open(); ICoordinateSystemFactory <BufferedCoordinate2D> coordSysFactory = _coordSysFactory; String wkt = File.ReadAllText(BcRoadsPrjFile); IProjectedCoordinateSystem cs = WktReader <BufferedCoordinate2D> .ToCoordinateSystemInfo(wkt, coordSysFactory) as IProjectedCoordinateSystem; shapeFile.SpatialReference = cs; Assert.IsNotNull(shapeFile.SpatialReference); IGeometry g = shapeFile.GetGeometryByOid(0); Assert.IsTrue(g.SpatialReference.EqualParams(createExpectedCoordinateSystem())); shapeFile.Close(); }
public void Point() { var reader = new WktReader(); var xy = reader.Read("POINT (0.0 65.9)"); Assert.AreEqual(new Point(65.9, 0), xy); var xyz = reader.Read("POINT Z (0.0 65.9 5)"); Assert.AreEqual(new Point(65.9, 0, 5), xyz); var xyz2 = reader.Read("POINT (0.0 65.9 5)"); Assert.AreEqual(new Point(65.9, 0, 5), xyz2); var xym = reader.Read("POINT M (0.0 65.9 5)"); Assert.AreEqual(new Point(new CoordinateM(65.9, 0, 5)), xym); var xyzm = reader.Read("POINT ZM (0.0 65.9 4 5)"); Assert.AreEqual(new Point(65.9, 0, 4, 5), xyzm); var xyzm2 = reader.Read("POINT (0.0 65.9 4 5)"); Assert.AreEqual(new Point(65.9, 0, 4, 5), xyzm2); var empty = reader.Read("POINT ZM EMPTY"); Assert.AreEqual(global::Geo.Geometries.Point.Empty, empty); }
public void Read_ReadsAllGeometryTypes(byte[] data) { using (WktReader target = new WktReader(new MemoryStream(data))) { IGeometry readGeometry = target.Read(); Assert.NotNull(readGeometry); } }
public void ReadT_ReadsGeometry() { using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-3DM.wkt"))) { Point read = target.Read <Point>(); Assert.NotNull(read); } }
public void Execute(IVectorImageProvider imageProvider) { WktLoaderDialog wktDlg = new WktLoaderDialog(); if (wktDlg.ShowDialog() == DialogResult.OK) { string filename = wktDlg.WktFileName; if (File.Exists(filename)) { if (filename.ToLower().EndsWith("wkb")) { WkbReader wkb = new WkbReader(File.ReadAllText(filename)); wkb.LoadIntoImage(imageProvider.CurrImage, wktDlg.FlipYAxis); } else { WktReader.ReadFile(imageProvider.LayeredVectorImage, filename, wktDlg.ScaleDivider, wktDlg.FlipYAxis, wktDlg.IncermentalCoordinates); } } if (wktDlg.WktFreeText.Length > 1) { if (IsHexString(wktDlg.WktFreeText)) { WkbReader wkb = new WkbReader(wktDlg.WktFreeText); wkb.LoadIntoImage(imageProvider.CurrImage, wktDlg.FlipYAxis); } else { WktReader.ReadText(imageProvider.LayeredVectorImage, wktDlg.WktFreeText, wktDlg.ScaleDivider, wktDlg.FlipYAxis, wktDlg.IncermentalCoordinates); } } } wktDlg.Dispose(); }
public void ReadT_ReturnsNullIfStreamIsEmpty() { using (WktReader target = new WktReader(new MemoryStream())) { IGeometry readGeometry = target.Read <Point>(); Assert.Null(readGeometry); } }
public void Parse_ParsesEmptyPoint() { string wkt = "point empty"; Point parsed = WktReader.Parse <Point>(wkt); this.CompareCoordinate(Coordinate.Empty, parsed.Position); }
public void ExponentialNumber() { var reader = new WktReader(); var xyWithE = reader.Read("POINT (5.5980439826435563E-06 -71.4920233210601)"); Assert.AreEqual(new Point(-71.4920233210601, 5.5980439826435563E-06), xyWithE); }
public void Null() { var reader = new WktReader(); var nothing = reader.Read(""); Assert.AreEqual(null, nothing); }
public void If_wkt_is_valid_multipoint_then_should_return_correct_multipoint(string wkt) { var expectedMultiPoint = new MultiPoint(new[] { new Point(10, 40), new Point(40, 30), new Point(20, 20), new Point(30, 10) }); var resultMultiPoint = WktReader.Read(wkt); resultMultiPoint.ShouldBe(expectedMultiPoint); }
public void Read_ReturnsNullIfNoMoreGeometriesAreAvailableInInputStream() { using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-3DM.wkt"))) { target.Read(); IGeometry readGeometry = target.Read(); Assert.Null(readGeometry); } }
/// <summary> /// Parse WKT entities from the <paramref name="reader"/>. /// </summary> /// <param name="reader">The reader.</param> /// <returns>A WKT entity.</returns> public object Parse(TextReader reader) { if(reader == null) throw new ArgumentNullException("reader"); Contract.EndContractBlock(); var wktReader = new WktReader(reader, Options); return wktReader.MoveNext() ? wktReader.ReadEntity() : null; }
public void Parse_Parses3DMeasuredPoint() { string wkt = "point zm (-10.1 15.5 100.5 1000.5)"; Point parsed = WktReader.Parse <Point>(wkt); Assert.NotNull(parsed); this.CompareCoordinate(_coordinatesXYZM[0], parsed.Position); }
public void Parse_ParsesMultiPoint() { string wkt = "multipoint empty"; MultiPoint parsed = (MultiPoint)WktReader.Parse(wkt); Assert.NotNull(parsed); Assert.Empty(parsed.Geometries); }
public void If_wkt_is_valid_linestring_then_should_return_correct_linestring() { const string wkt = "LINESTRING (30 10, 10 30, 40 40)"; var expectedLineString = new LineString(new[] { new Point(30, 10), new Point(10, 30), new Point(40, 40) }); var resultLineString = WktReader.Read(wkt); resultLineString.ShouldBe(expectedLineString); }
public void Read_ReturnsNullIfNoMoreGeometriesAreAvailableInInputStream() { using (WktReader target = new WktReader(new MemoryStream(Data.IOTestData.wkt_point_3DM))) { target.Read(); IGeometry readGeometry = target.Read(); Assert.Null(readGeometry); } }
public void Parse_ParsesEmptyMultiLineString() { string wkt = "multilinestring empty"; MultiLineString parsed = WktReader.Parse <MultiLineString>(wkt); Assert.NotNull(parsed); Assert.Empty(parsed.Geometries); }
public void Parse_ParsesEmptyMultiPolygon() { string wkt = "multipolygon empty"; MultiPolygon parsed = WktReader.Parse <MultiPolygon>(wkt); Assert.NotNull(parsed); Assert.Empty(parsed.Geometries); }
public void Parse_Parses3DMeasuredLineString() { 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 parsed = WktReader.Parse <LineString>(wkt); Assert.NotNull(parsed); this.CompareCoordinates(_coordinatesXYZM, parsed.Coordinates); }
public void Parse_Parses2DLineString() { string wkt = "linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5)"; LineString parsed = WktReader.Parse <LineString>(wkt); Assert.NotNull(parsed); this.CompareCoordinates(_coordinatesXY, parsed.Coordinates); }
public void Parse_ParsesEmptyLineString() { string wkt = "linestring empty"; LineString parsed = WktReader.Parse <LineString>(wkt); Assert.NotNull(parsed); Assert.Empty(parsed.Coordinates); }
public void Parse_ParsesEmptyGeometryCollection() { string wkt = "geometrycollection empty"; GeometryCollection <Geometry> parsed = WktReader.Parse <GeometryCollection <Geometry> >(wkt); Assert.NotNull(parsed); Assert.Empty(parsed.Geometries); }
public void If_wkt_is_valid_polygon_then_should_return_correct_polygon() { const string wkt = "POLYGON ((30 10, 40 40, 20 40, 5E-03 20, 30 10))"; var expectedPolygon = new Polygon(new[] { new Point(30, 10), new Point(40, 40), new Point(20, 40), new Point(0.005, 20), new Point(30, 10) }); var resultPolygon = WktReader.Read(wkt); resultPolygon.ShouldBe(expectedPolygon); }
public void If_wkt_is_valid_point_then_should_return_correct_point() { const string wkt = "POINT (10 20)"; var expectedPoint = new Point(10, 20); var resultPoint = WktReader.Read(wkt); resultPoint.ShouldBe(expectedPoint); }
public void Parse_ParsesPolygon() { string wkt = "polygon empty"; Polygon parsed = (Polygon)WktReader.Parse(wkt); Assert.NotNull(parsed); Assert.Empty(parsed.ExteriorRing); }
public void IsInRing_ReturnsFalseIfPointIsInRingAndCYCoordinateIsSameAsVertexYCoordinate() { string wktRing = "linestring (-1 -1, 1 -1, 1 0.5, 1 1, -1 1, -1 -1)"; LineString ring = WktReader.Parse <LineString>(wktRing); Coordinate c = new Coordinate(-2, 0.5); Euclidean2DLocator target = new Euclidean2DLocator(); Assert.False(target.IsInRing(c, ring.Coordinates)); }
public void IsInRing_ReturnsTrueIfPointIsInConcaveRing() { string wktRing = "linestring (0 0, 2 0, 1 1, 1 2, 0 0)"; LineString ring = WktReader.Parse <LineString>(wktRing); Coordinate c = new Coordinate(1, 0.5); Euclidean2DLocator target = new Euclidean2DLocator(); Assert.True(target.IsInRing(c, ring.Coordinates)); }
public void IsInRing_ReturnsFalseIfPointIsOutsideRing() { string wktRing = "linestring (0 0, 2 0, 1 1, 1 2, 0 0)"; LineString ring = WktReader.Parse <LineString>(wktRing); Coordinate c = new Coordinate(3, 0); Euclidean2DLocator target = new Euclidean2DLocator(); Assert.False(target.IsInRing(c, ring.Coordinates)); }
public void IsInRing_ReturnsTrueIfPointIsInSimpleRing() { string wktRing = "linestring (-1 -1, 1 -1, 1 1, -1 1, -1 -1)"; LineString ring = WktReader.Parse <LineString>(wktRing); Coordinate c = new Coordinate(0.5, 0.5); Euclidean2DLocator target = new Euclidean2DLocator(); Assert.True(target.IsInRing(c, ring.Coordinates)); }
public void Dispose_ClosesOutputStreamIfWritingToFiles() { string filename = "../../src/Tests.SpatialLite.Core/Data/IO/wkt-point-3DM.wkt"; WktReader target = new WktReader(filename); target.Dispose(); FileStream testStream = null; Assert.DoesNotThrow(() => testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite)); testStream.Dispose(); }
public void ReadT_ReadsGeometry() { using (WktReader target = new WktReader(new MemoryStream(Data.IOTestData.wkt_point_3DM))) { Point read = target.Read<Point>(); Assert.NotNull(read); } }
public void ReadT_ThrowsExceptionIfWKTDoesNotRepresentGeometryOfSpecificType() { using (WktReader target = new WktReader(new MemoryStream(Data.IOTestData.wkt_point_3DM))) { Assert.Throws<WktParseException>(() => target.Read<LineString>()); } }
public void Read_ReadsMultipleGeometries() { using (WktReader target = new WktReader(new MemoryStream(Data.IOTestData.wkt_point_and_linestring_3DM))) { IGeometry readGeometry = target.Read(); Assert.True(readGeometry is Point); readGeometry = target.Read(); Assert.True(readGeometry is LineString); } }
public void Read_ReturnsNullIfStreamIsEmpty() { using (WktReader target = new WktReader(new MemoryStream())) { IGeometry readGeometry = target.Read(); Assert.Null(readGeometry); } }
public void Dispose_ClosesOutputStreamIfWritingToStream() { MemoryStream stream = new MemoryStream(Data.IOTestData.wkt_point_3DM); WktReader target = new WktReader(stream); target.Dispose(); Assert.False(stream.CanRead); }