Пример #1
0
 //TODO: change signature if 'VectorTile' class changes from 'sealed'
 //protected override void Dispose(bool disposeManagedResources)
 public void Dispose(bool disposeManagedResources)
 {
     if (isDisposed || !disposeManagedResources)
     {
         return;
     }
     //TODO implement IDisposable with Mapbox.VectorTile.VectorTile
     data = null;
 }
        internal override bool ParseTileData(byte[] data)
        {
            try {
                var decompressed = Compression.Decompress(data);
                this.data = new Mapbox.VectorTile.VectorTile(decompressed);

                return(true);
            }
            catch (Exception ex) {
                AddException(ex);
                return(false);
            }
        }
Пример #3
0
 //TODO: change signature if 'VectorTile' class changes from 'sealed'
 //protected override void Dispose(bool disposeManagedResources)
 public void Dispose(bool disposeManagedResources)
 {
     if (!isDisposed)
     {
         if (disposeManagedResources)
         {
             //TODO implement IDisposable with Mapbox.VectorTile.VectorTile
             if (null != data)
             {
                 data = null;
             }
         }
     }
 }
        internal override bool ParseTileData(byte[] data)
        {
            try
            {
                var decompressed = Compression.Decompress(data);
                this.data = new Mapbox.VectorTile.VectorTile(decompressed);

                return(true);
            }
            catch (Exception ex)
            {
                SetError("VectorTile parsing failed: " + ex.ToString());
                return(false);
            }
        }
Пример #5
0
        internal override bool ParseTileData(byte[] data)
        {
            try
            {
                // TODO: Move this to a threaded worker.
                var decompressed = Compression.Decompress(data);
                this.data = new Mapbox.VectorTile.VectorTile(decompressed);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #6
0
        public static int Main(string[] args)
        {
            string vtIn       = string.Empty;
            uint?  clipBuffer = null;
            bool   outGeoJson = false;
            ulong? zoom       = null;
            ulong? tileCol    = null;
            ulong? tileRow    = null;

            for (int i = 0; i < args.Length; i++)
            {
                string argLow = args[i].ToLower();
                if (argLow.Contains("vt:"))
                {
                    vtIn = argLow.Replace("vt:", "");
                }
                else if (argLow.Contains("clip:"))
                {
                    clipBuffer = Convert.ToUInt32(argLow.Replace("clip:", ""));
                }
                else if (argLow.Contains("out:"))
                {
                    outGeoJson = argLow.Replace("out:", "").Equals("geojson");
                }
                else if (argLow.Contains("tileid:"))
                {
                    parseArg(argLow.Replace("tileid:", ""), out zoom, out tileCol, out tileRow);
                }
            }

            if (!File.Exists(vtIn))
            {
                Console.WriteLine($"file [{vtIn}] not found");
                usage();
                return(1);
            }

            // z-x-y weren't passed via parameters, try to get them from file name
            if (!zoom.HasValue || !tileCol.HasValue || !tileRow.HasValue)
            {
                if (!parseArg(Path.GetFileName(vtIn), out zoom, out tileCol, out tileRow))
                {
                    usage();
                    return(1);
                }
            }

            var bufferedData = File.ReadAllBytes(vtIn);

            VectorTile tile = new VectorTile(bufferedData);

            if (outGeoJson)
            {
                Console.WriteLine(tile.ToGeoJson(zoom.Value, tileCol.Value, tileRow.Value, clipBuffer));
            }
            else
            {
                foreach (string lyrName in tile.LayerNames())
                {
                    VectorTileLayer lyr = tile.GetLayer(lyrName);
                    Console.WriteLine(string.Format("------------ {0} ---------", lyrName));
                    //if (lyrName != "building") { continue; }
                    int featCnt = lyr.FeatureCount();
                    for (int i = 0; i < featCnt; i++)
                    {
                        VectorTileFeature feat = lyr.GetFeature(i, clipBuffer);
                        Console.WriteLine(string.Format("feature {0}: {1}", i, feat.GeometryType));
                        Dictionary <string, object> props = feat.GetProperties();
                        foreach (var prop in props)
                        {
                            Console.WriteLine(string.Format("   {0}\t : ({1}) {2}", prop.Key, prop.Value.GetType(), prop.Value));
                        }
                    }
                }
            }

            return(0);
        }