diff --git a/Mapbox.VectorTile.1.0.2-alpha1.nupkg b/Mapbox.VectorTile.1.0.2-alpha1.nupkg new file mode 100644 index 0000000..52be64c Binary files /dev/null and b/Mapbox.VectorTile.1.0.2-alpha1.nupkg differ diff --git a/Mapbox.VectorTile.1.0.2-alpha2.nupkg b/Mapbox.VectorTile.1.0.2-alpha2.nupkg new file mode 100644 index 0000000..08fc051 Binary files /dev/null and b/Mapbox.VectorTile.1.0.2-alpha2.nupkg differ diff --git a/Mapbox.VectorTile.nuspec b/Mapbox.VectorTile.nuspec index e91bc6f..ae3c341 100644 --- a/Mapbox.VectorTile.nuspec +++ b/Mapbox.VectorTile.nuspec @@ -2,16 +2,19 @@ Mapbox.VectorTile - 1.0.1-alpha3 + 1.0.2-alpha2 Mapbox Mapbox https://github.com/mapbox/vector-tile-cs https://github.com/mapbox/vector-tile-cs false Mapbox VectorTileReader CSharp - Updates to VectorTileFeature. + Lazy loading. Copyright 2016 vector tiles c# mapbox + + + diff --git a/src/AssemblyInfoVersion.cs b/src/AssemblyInfoVersion.cs new file mode 100644 index 0000000..0df494b --- /dev/null +++ b/src/AssemblyInfoVersion.cs @@ -0,0 +1,5 @@ +using System.Reflection; + +[assembly: AssemblyVersion( "1.0.2" )] +[assembly: AssemblyFileVersion( "1.0.2" )] +[assembly: AssemblyInformationalVersion( "1.0.2" )] diff --git a/src/Bench/Bench.csproj b/src/Bench/Bench.csproj index fc38081..ba77ad6 100644 --- a/src/Bench/Bench.csproj +++ b/src/Bench/Bench.csproj @@ -43,6 +43,9 @@ + + Properties\AssemblyInfoVersion.cs + diff --git a/src/Bench/Program.cs b/src/Bench/Program.cs index a96ccd5..96b2919 100644 --- a/src/Bench/Program.cs +++ b/src/Bench/Program.cs @@ -2,12 +2,13 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using System.IO; using System.Linq; using System.Net; using System.Text; -namespace ProfileDecoding +namespace Bench { class Program { @@ -47,7 +48,8 @@ static int Main(string[] args) return 1; } else { - tiles.Add(new TileData() { + tiles.Add(new TileData() + { zoom = zoom, col = col, row = row, @@ -67,7 +69,14 @@ static int Main(string[] args) stopWatch.Start(); foreach (var tile in tiles) { - VectorTileReader.Decode(tile.zoom, tile.col, tile.row, tile.pbf); + VectorTile vt = VectorTile.DecodeFully(tile.pbf); + foreach (var lyr in vt.Layers) + { + foreach (var feat in lyr.Features) + { + var props = feat.GetProperties(); + } + } } stopWatch.Stop(); //skip first run @@ -76,6 +85,7 @@ static int Main(string[] args) elapsed.Add(stopWatch.ElapsedMilliseconds); } stopWatch.Reset(); + elapsed.Add(stopWatch.ElapsedMilliseconds); } diff --git a/src/Bench/Properties/AssemblyInfo.cs b/src/Bench/Properties/AssemblyInfo.cs index c5341ea..4f85afb 100644 --- a/src/Bench/Properties/AssemblyInfo.cs +++ b/src/Bench/Properties/AssemblyInfo.cs @@ -22,15 +22,3 @@ // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("5fa56c72-348a-4b52-980c-ea8287e66422")] -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/DemoConsoleApp/DemoConsoleApp.csproj b/src/DemoConsoleApp/DemoConsoleApp.csproj index 2b9d1c8..54fe1f2 100644 --- a/src/DemoConsoleApp/DemoConsoleApp.csproj +++ b/src/DemoConsoleApp/DemoConsoleApp.csproj @@ -78,6 +78,9 @@ + + Properties\AssemblyInfoVersion.cs + diff --git a/src/DemoConsoleApp/Properties/AssemblyInfo.cs b/src/DemoConsoleApp/Properties/AssemblyInfo.cs index e1b94c6..4fb8d0a 100644 --- a/src/DemoConsoleApp/Properties/AssemblyInfo.cs +++ b/src/DemoConsoleApp/Properties/AssemblyInfo.cs @@ -24,15 +24,3 @@ // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("d01ba6cb-9a2b-4aa5-95e1-085d9b569309")] -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/DemoConsoleApp/program.cs b/src/DemoConsoleApp/program.cs index 02d348f..fb2ac01 100644 --- a/src/DemoConsoleApp/program.cs +++ b/src/DemoConsoleApp/program.cs @@ -22,6 +22,26 @@ public static int Main(string[] args) return 1; } + + var bufferedData = File.ReadAllBytes(vtIn); + + VectorTileReader vtr = new VectorTileReader(bufferedData); + foreach (var lyrName in vtr.LayerNames()) + { + Console.WriteLine(lyrName); + VectorTileLayer layer = vtr.GetLayer(lyrName); + Console.WriteLine("features: {0}", layer.FeatureCount()); + for (int i = 0; i < layer.FeatureCount(); i++) + { + VectorTileFeature feat = layer.GetFeature(i); + Console.WriteLine(feat.Id); + foreach (var prop in feat.GetProperties()) + { + Console.WriteLine("{0}: {1}", prop.Key, prop.Value); + } + } + } + ulong zoom; ulong tileCol; ulong tileRow; @@ -31,16 +51,10 @@ public static int Main(string[] args) return 1; } - var bufferedData = File.ReadAllBytes(vtIn); - VectorTile tile = VectorTileReader.Decode( -(ulong)zoom - , (ulong)tileCol - , (ulong)tileRow - , (byte[])bufferedData - ); + VectorTile tile = VectorTile.DecodeFully(bufferedData); - Console.WriteLine(tile.ToGeoJson()); + Console.WriteLine(tile.ToGeoJson(zoom, tileCol, tileRow)); return 0; } diff --git a/src/Geometry/DecodeGeometry.cs b/src/Geometry/DecodeGeometry.cs index 3949907..599bfc9 100644 --- a/src/Geometry/DecodeGeometry.cs +++ b/src/Geometry/DecodeGeometry.cs @@ -1,7 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; +using Mapbox.Geometry; namespace Mapbox.VectorTile.Geometry { @@ -25,19 +23,14 @@ public static class DecodeGeometry /// Each child list contains the corrdinates of this part. /// /// Tile extent - /// Zoom level - /// Tile column - /// Tile row /// Geometry type - /// + /// /// List> public static List> GetGeometry( ulong extent - , ulong zoom - , ulong tileColumn - , ulong tileRow , GeomType geomType - , List geometry + , List geometryCommands + , float scale = 1.0f ) { @@ -46,10 +39,10 @@ ulong extent long cursorX = 0; long cursorY = 0; - for (int i = 0; i < geometry.Count; i++) + for (int i = 0; i < geometryCommands.Count; i++) { - uint g = geometry[i]; + uint g = geometryCommands[i]; Commands cmd = (Commands)(g & 0x7); uint cmdCount = g >> 3; @@ -57,7 +50,7 @@ ulong extent { for (int j = 0; j < cmdCount; j++) { - Point2d delta = zigzagDecode(geometry[i + 1], geometry[i + 2]); + Point2d delta = zigzagDecode(geometryCommands[i + 1], geometryCommands[i + 2]); cursorX += delta.X; cursorY += delta.Y; i += 2; @@ -85,6 +78,35 @@ ulong extent geomOut.Add(geomTmp); } + //IGeometryBase geomOut2; + //switch (geomType) + //{ + // case GeomType.UNKNOWN: + // throw new System.Exception("Geometry type unknown"); + // case GeomType.POINT: + // if (geomOut.Count == 1) + // { + // geomOut2 = new Point(geomOut[0][0].X, geomOut[0][0].Y); + // } else + // { + // geomOut2 = new MultiPoint(); + // foreach (var part in geomOut) + // { + // ((MultiPoint)geomOut2).Add(new Point(part[0].X, part[0].Y)); + // } + // } + // break; + // case GeomType.LINESTRING: + // geomOut2 = new LinearRing(); + // break; + // case GeomType.POLYGON: + // geomOut2 = new Polygon(); + // break; + // default: + // throw new System.Exception("Geometry type invalid"); + //} + + return geomOut; } diff --git a/src/Geometry/Geometry.csproj b/src/Geometry/Geometry.csproj index 9d39de1..1457991 100644 --- a/src/Geometry/Geometry.csproj +++ b/src/Geometry/Geometry.csproj @@ -54,6 +54,10 @@ false + + ..\..\packages\Mapbox.Geometry.1.0.0-alpha1\lib\net35\Mapbox.Geometry.dll + True + @@ -62,6 +66,9 @@ + + Properties\AssemblyInfoVersion.cs + @@ -76,6 +83,9 @@ Util + + +