public void ClipHardAtTileBoundary(string fileName) { string fullFileName = Path.Combine(fixturesPath, fileName); Assert.True(File.Exists(fullFileName), "Vector tile exists"); byte[] data = File.ReadAllBytes(fullFileName); VectorTile vt = new VectorTile(data); Assert.GreaterOrEqual(vt.LayerNames().Count, 1, "At least one layer"); string geojson = vt.ToGeoJson(0, 0, 0); Assert.GreaterOrEqual(geojson.Length, 30, "geojson >= 30 chars"); foreach (var lyrName in vt.LayerNames()) { VectorTileLayer lyr = vt.GetLayer(lyrName); for (int i = 0; i < lyr.FeatureCount(); i++) { Debug.WriteLine("{0} lyr:{1} feat:{2}", fileName, lyr.Name, i); VectorTileFeature feat = lyr.GetFeature(i, 0); long extent = (long)lyr.Extent; foreach (var part in feat.Geometry <int>()) { foreach (var geom in part) { Assert.GreaterOrEqual(geom.X, 0, "geom.X equal or greater 0"); Assert.GreaterOrEqual(geom.Y, 0, "geom.Y eqaul or greater 0"); Assert.LessOrEqual(geom.X, extent, "geom.X less or equal extent"); Assert.LessOrEqual(geom.Y, extent, "geom.Y less or equal extent"); } } } } }
public void LazyDecoding(string fileName) { string fullFileName = Path.Combine(fixturesPath, fileName); Assert.True(File.Exists(fullFileName), "Vector tile exists"); byte[] data = File.ReadAllBytes(fullFileName); VectorTile vt = new VectorTile(data); foreach (var layerName in vt.LayerNames()) { VectorTileLayer layer = vt.GetLayer(layerName); for (int i = 0; i < layer.FeatureCount(); i++) { VectorTileFeature feat = layer.GetFeature(i); var properties = feat.GetProperties(); foreach (var prop in properties) { Assert.AreEqual(prop.Value, feat.GetValue(prop.Key), "Property values match"); } foreach (var geomPart in feat.Geometry <int>()) { foreach (var coord in geomPart) { //TODO add Assert } } } } string geojson = vt.ToGeoJson(0, 0, 0); Assert.GreaterOrEqual(geojson.Length, 30, "geojson >= 30 chars"); }
public void AtLeastOneLayer(string fileName) { string fullFileName = Path.Combine(fixturesPath, fileName); Assert.True(File.Exists(fullFileName), "Vector tile exists"); byte[] data = File.ReadAllBytes(fullFileName); VectorTile vt = new VectorTile(data); Assert.GreaterOrEqual(vt.LayerNames().Count, 1, "At least one layer"); string geojson = vt.ToGeoJson(0, 0, 0); Assert.GreaterOrEqual(geojson.Length, 30, "geojson >= 30 chars"); foreach (var lyrName in vt.LayerNames()) { VectorTileLayer lyr = vt.GetLayer(lyrName); for (int i = 0; i < lyr.FeatureCount(); i++) { Debug.WriteLine("{0} lyr:{1} feat:{2}", fileName, lyr.Name, i); VectorTileFeature feat = lyr.GetFeature(i); long extent = (long)lyr.Extent; foreach (var part in feat.Geometry <long>()) { foreach (var geom in part) { if (geom.X < 0 || geom.Y < 0 || geom.X > extent || geom.Y > extent) { Debug.WriteLine("{0} lyr:{1} feat:{2} x:{3} y:{4}", fileName, lyr.Name, i, geom.X, geom.Y); } } } } } }
public void DifferentPoint2dTypesAndScaling() { string fullFileName = Path.Combine(fixturesPath, "Feature-single-linestring.mvt"); byte[] data = File.ReadAllBytes(fullFileName); VectorTile vt = new VectorTile(data); foreach (var layerName in vt.LayerNames()) { VectorTileLayer layer = vt.GetLayer(layerName); for (int i = 0; i < layer.FeatureCount(); i++) { VectorTileFeature featLong = layer.GetFeature(i); foreach (var geomPart in featLong.Geometry <long>()) { foreach (var coord in geomPart) { Debug.WriteLine("long: {0}/{1}", coord.X, coord.Y); } Assert.AreEqual(2L, geomPart[0].X); Assert.AreEqual(2L, geomPart[0].Y); Assert.AreEqual(2L, geomPart[1].X); Assert.AreEqual(10L, geomPart[1].Y); Assert.AreEqual(10L, geomPart[2].X); Assert.AreEqual(10L, geomPart[2].Y); } // don't clip, as this might change order of vertices // test 'scale' on the VectorTileFeature constructor VectorTileFeature featInt = layer.GetFeature(i, null, 1.5f); foreach (var geomPart in featInt.Geometry <int>()) { foreach (var coord in geomPart) { Debug.WriteLine("integer: {0}/{1}", coord.X, coord.Y); } Assert.AreEqual(3, geomPart[0].X); Assert.AreEqual(3, geomPart[0].Y); Assert.AreEqual(3, geomPart[1].X); Assert.AreEqual(15, geomPart[1].Y); Assert.AreEqual(15, geomPart[2].X); Assert.AreEqual(15, geomPart[2].Y); } // don't clip, as this might change order of vertices VectorTileFeature featFloat = layer.GetFeature(i); // test 'scale' on the Geometry method foreach (var geomPart in featFloat.Geometry <float>(null, 2.0f)) { foreach (var coord in geomPart) { Debug.WriteLine("float: {0}/{1}", coord.X, coord.Y); } Assert.AreEqual(4f, geomPart[0].X); Assert.AreEqual(4f, geomPart[0].Y); Assert.AreEqual(4f, geomPart[1].X); Assert.AreEqual(20f, geomPart[1].Y); Assert.AreEqual(20f, geomPart[2].X); Assert.AreEqual(20f, geomPart[2].Y); } } } string geojson = vt.ToGeoJson(0, 0, 0); Assert.GreaterOrEqual(geojson.Length, 30, "geojson >= 30 chars"); }