This is an automated email from the git hooks/post-receive script.

kapouer pushed a commit to branch master
in repository mapnik-vector-tile.

commit 20d677b5461d843d2e59d56b40503238703f060a
Author: Jérémy Lal <kapo...@melix.org>
Date:   Sun Feb 9 19:21:35 2014 +0100

    Imported Upstream version 0.3.3+dfsg
---
 .travis.yml                     |  31 ++++++++++
 CHANGELOG.md                    |   6 ++
 README.md                       |   8 ++-
 examples/c++/Makefile           |   7 ++-
 examples/c++/tileinfo.cpp       | 123 ++++++++++++++++++++++++++++++++--------
 package.json                    |   2 +-
 src/vector_tile_backend_pbf.hpp |   2 +
 src/vector_tile_compression.hpp |  65 +++++++++++++++++++++
 src/vector_tile_util.hpp        |   7 ++-
 test/vector_tile.cpp            |   2 +-
 10 files changed, 223 insertions(+), 30 deletions(-)

diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..a422bfc
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,31 @@
+language: cpp
+
+compiler:
+ - clang
+ - gcc
+
+before_install:
+ - sudo apt-add-repository --yes ppa:mapnik/v2.2.0
+ - sudo apt-add-repository --yes ppa:mapnik/nightly-2.3
+ - sudo apt-get update -qq
+
+install:
+ - sudo apt-get -qq install libprotobuf7 libprotobuf-dev protobuf-compiler
+
+before_script:
+ - sudo apt-get -qq install libmapnik=2.2.0* mapnik-utils=2.2.0* 
libmapnik-dev=2.2.0*
+ - make clean
+ - make test
+ - sudo apt-get purge libmapnik=2.2.0* mapnik-utils=2.2.0* libmapnik-dev=2.2.0*
+
+script:
+ - sudo apt-get -qq install libmapnik=2.3.0* mapnik-utils=2.3.0* 
libmapnik-dev=2.3.0*
+ - make clean
+ - make test
+ - sudo apt-get purge libmapnik=2.3.0* mapnik-utils=2.3.0* libmapnik-dev=2.3.0*
+
+notifications:
+  irc:
+    channels:
+      - "irc.freenode.org#mapnik"
+    use_notice: true
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e0ce235..2c3b8c7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
 # Changlog
 
+## 0.3.3
+
+ - Added support in tileinfo demo program for reading zlib compressed tiles
+ - Removed dependence on clipper.hp unless `-DCONV_CLIPPER` is defined in 
`CXXFLAGS`
+ - Upgraded bundled cache.hpp test framework to `1.0 build 8` (kapouer)
+
 ## 0.3.2
 
  - Fixed `mapnik::vector::tile_datasource` to respect the feature id if known
diff --git a/README.md b/README.md
index 6e713a8..dcb0bbc 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,8 @@
 ## mapnik-vector-tile
 
-A high performance library for working with vector tiles from the
-team at [MapBox](http://mapbox.com/about/team/).
+[![Build 
Status](https://secure.travis-ci.org/mapbox/mapnik-vector-tile.png)](http://travis-ci.org/mapbox/mapnik-vector-tile)
+
+A high performance library for working with vector tiles with Mapnik.
 
 Provides C++ headers that support rendering geodata into vector tiles
 and rendering vector tiles into images.
@@ -89,6 +90,7 @@ See examples in examples/c++
 These require the protobuf python bindings and the `rtree` library
 which can be installed like:
 
+    sudo apt-get install libspatialindex-dev
     pip install protobuf rtree
 
 To build and test the python example code do:
@@ -109,4 +111,4 @@ Run the example code:
 
 - http://mike.teczno.com/notes/postgreslessness-mapnik-vectiles.html
 - https://github.com/mdaines/ceramic
-- https://github.com/opensciencemap/VectorTileMap
\ No newline at end of file
+- https://github.com/opensciencemap/VectorTileMap
diff --git a/examples/c++/Makefile b/examples/c++/Makefile
index e3f1353..d2870c9 100755
--- a/examples/c++/Makefile
+++ b/examples/c++/Makefile
@@ -6,10 +6,15 @@ LDFLAGS := $(LDFLAGS) # inherit from env
 all: tileinfo
 
 tileinfo: tileinfo.cpp ../../src/vector_tile.pb.cc
-       $(CXX) tileinfo.cpp ../../src/vector_tile.pb.cc -o tileinfo 
-lprotobuf-lite
+       $(CXX) tileinfo.cpp ../../src/vector_tile.pb.cc -o tileinfo 
-lprotobuf-lite -lz
 
 test:
        ./tileinfo ../data/14_8716_8015.vector.pbf
+       ./tileinfo ../data/14_2620_6331.vector.pbf.z
+
+install:
+       cp ./tileinfo /usr/local/bin/tileinfo
+       chmod +x /usr/local/bin/tileinfo
 
 clean:
        @rm -f ./tileinfo
diff --git a/examples/c++/tileinfo.cpp b/examples/c++/tileinfo.cpp
index d8b17e0..65b90c2 100644
--- a/examples/c++/tileinfo.cpp
+++ b/examples/c++/tileinfo.cpp
@@ -1,25 +1,30 @@
 #include "../../src/vector_tile.pb.h"
+#include "../../src/vector_tile_compression.hpp"
 #include <vector>
 #include <iostream>
 #include <fstream>
 #include <stdexcept>
 
-
 int main(int argc, char** argv)
 {
     GOOGLE_PROTOBUF_VERIFY_VERSION;
     std::vector<std::string> args;
+    bool verbose = false;
     for (int i=1;i<argc;++i)
     {
-        args.push_back(argv[i]);
+        if (strcmp(argv[i], "--verbose") == 0) {
+            verbose = true;
+        } else {
+            args.push_back(argv[i]);
+        }
     }
     
     if (args.empty())
     {
-        std::clog << "please pass the path to an uncompressed protobuf tile 
(.vector.pbf)\n";
+        std::clog << "please pass the path to an uncompressed or 
zlib-compressed protobuf tile\n";
         return -1;
     }
-
+    
     try
     {
         std::string filename = args[0];
@@ -35,30 +40,102 @@ int main(int argc, char** argv)
 
         // now attemp to open protobuf
         mapnik::vector::tile tile;
-        if (!tile.ParseFromString(message))
+        if (mapnik::vector::is_compressed(message))
         {
-            std::clog << "failed to parse protobuf\n";
+            std::string uncompressed;
+            mapnik::vector::decompress(message,uncompressed);
+            if (!tile.ParseFromString(uncompressed))
+            {
+                std::clog << "failed to parse compressed protobuf\n";
+            }
         }
-        
-        std::cout << "number of layers: " << tile.layers_size() << "\n";
-
-        for (unsigned i=0;i<tile.layers_size();++i)
+        else
         {
-            mapnik::vector::tile_layer const& layer = tile.layers(i);
-            std::cout << "  layer: " << i << "\n";
-            std::cout << "  layer name: " << layer.name() << "\n";
-            std::cout << "  layer extent: " << layer.extent() << "\n";
-            std::cout << "  layer features: " << layer.features_size() << "\n";
-            for (unsigned j=0;j<layer.features_size();++j)
+            if (!tile.ParseFromString(message))
             {
-                mapnik::vector::tile_feature const& feature = 
layer.features(j);
-                std::cout << "    feature: " << j << "\n";
-                std::cout << "    feature id: " << feature.id() << "\n";
-                std::cout << "    feature type: " << feature.type() << "\n";
-                // TODO - dump tags and geometries
+                std::clog << "failed to parse protobuf\n";
+            }
+        }
+        if (!verbose) {
+            std::cout << "layers: " << tile.layers_size() << "\n";
+            for (unsigned i=0;i<tile.layers_size();++i)
+            {
+                mapnik::vector::tile_layer const& layer = tile.layers(i);
+                std::cout << layer.name() << ":\n";
+                std::cout << "  version: " << layer.version() << "\n";
+                std::cout << "  extent: " << layer.extent() << "\n";
+                std::cout << "  features: " << layer.features_size() << "\n";
+                std::cout << "  keys: " << layer.keys_size() << "\n";
+                std::cout << "  values: " << layer.values_size() << "\n";
+            }
+        } else {
+            for (unsigned i=0;i<tile.layers_size();++i)
+            {
+                mapnik::vector::tile_layer const& layer = tile.layers(i);
+                std::cout << "layer: " << layer.name() << "\n";
+                std::cout << "  version: " << layer.version() << "\n";
+                std::cout << "  extent: " << layer.extent() << "\n";
+                std::cout << "  keys: ";
+                for (unsigned i=0;i<layer.keys_size();++i)
+                {
+                     std::string const& key = layer.keys(i);
+                     std::cout << key << ",";
+                }
+                std::cout << "\n";
+                std::cout << "  values: ";
+                for (unsigned i=0;i<layer.values_size();++i)
+                {
+                     mapnik::vector::tile_value const & value = 
layer.values(i);
+                     if (value.has_string_value()) {
+                          std::cout << "'" << value.string_value();
+                     } else if (value.has_int_value()) {
+                          std::cout << value.int_value();
+                     } else if (value.has_double_value()) {
+                          std::cout << value.double_value();
+                     } else if (value.has_float_value()) {
+                          std::cout << value.float_value();
+                     } else if (value.has_bool_value()) {
+                          std::cout << value.bool_value();
+                     } else if (value.has_sint_value()) {
+                          std::cout << value.sint_value();
+                     } else if (value.has_uint_value()) {
+                          std::cout << value.uint_value();
+                     } else {
+                          std::cout << "null";
+                     }
+                     if (i<layer.values_size()-1) {
+                        std::cout << ",";
+                     }
+                 }
+                 std::cout << "\n";
+                 for (unsigned i=0;i<layer.features_size();++i)
+                 {
+                     mapnik::vector::tile_feature const & feat = 
layer.features(i);
+                     std::cout << "  feature: " << feat.id() << " " << 
feat.type() << "\n";
+                     std::cout << "    tags: ";
+                     for (unsigned j=0;j<feat.tags_size();++j)
+                     {
+                          uint32_t tag = feat.tags(j);
+                          std::cout << tag;
+                          if (j<feat.tags_size()-1) {
+                            std::cout << ",";
+                          }
+                     }
+                     std::cout << "\n";
+                     std::cout << "    geometries: ";
+                     for (unsigned j=0;j<feat.geometry_size();++j)
+                     {
+                          uint32_t geom = feat.geometry(j);
+                          std::cout << geom;
+                          if (j<feat.geometry_size()-1) {
+                            std::cout << ",";
+                          }
+                     }
+                     std::cout << "\n";
+                 }
+                 std::cout << "\n";
             }
         }
-
     }
     catch (std::exception const& ex)
     {
@@ -67,4 +144,4 @@ int main(int argc, char** argv)
     }
     google::protobuf::ShutdownProtobufLibrary();
 
-}
\ No newline at end of file
+}
diff --git a/package.json b/package.json
index e949c37..65c3553 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
     "name": "mapnik-vector-tile",
-    "version": "0.3.2",
+    "version": "0.3.3",
     "description": "Mapnik vector tile API",
     "main": "./package.json",
     "repository"   :  {
diff --git a/src/vector_tile_backend_pbf.hpp b/src/vector_tile_backend_pbf.hpp
index d67f3db..717c9be 100644
--- a/src/vector_tile_backend_pbf.hpp
+++ b/src/vector_tile_backend_pbf.hpp
@@ -91,6 +91,8 @@ namespace mapnik { namespace vector {
             current_feature_ = current_layer_->add_features();
             x_ = y_ = 0;
 
+            // TODO - encode as sint64: (n << 1) ^ ( n >> 63)
+            // test current behavior with negative numbers
             current_feature_->set_id(feature.id());
 
             feature_kv_iterator itr = feature.begin();
diff --git a/src/vector_tile_compression.hpp b/src/vector_tile_compression.hpp
new file mode 100644
index 0000000..1afd618
--- /dev/null
+++ b/src/vector_tile_compression.hpp
@@ -0,0 +1,65 @@
+#include <stdexcept>
+#include <zlib.h>
+
+namespace mapnik { namespace vector {
+
+inline bool is_compressed(std::string const& data)
+{
+    return data.size() > 2 && (uint8_t)data[0] == 0x78 && (uint8_t)data[1] == 
0x9C;
+}
+
+inline void decompress(std::string const& input, std::string & output)
+{
+    z_stream inflate_s;
+    inflate_s.zalloc = Z_NULL;
+    inflate_s.zfree = Z_NULL;
+    inflate_s.opaque = Z_NULL;
+    inflate_s.avail_in = 0;
+    inflate_s.next_in = Z_NULL;
+    inflateInit(&inflate_s);
+    inflate_s.next_in = (Bytef *)input.data();
+    inflate_s.avail_in = input.size();
+    size_t length = 0;
+    do {
+        output.resize(length + 2 * input.size());
+        inflate_s.avail_out = 2 * input.size();
+        inflate_s.next_out = (Bytef *)(output.data() + length);
+        int ret = inflate(&inflate_s, Z_FINISH);
+        if (ret != Z_STREAM_END && ret != Z_OK && ret != Z_BUF_ERROR) {
+            throw std::runtime_error(inflate_s.msg);
+        }
+
+        length += (2 * input.size() - inflate_s.avail_out);
+    } while (inflate_s.avail_out == 0);
+    inflateEnd(&inflate_s);
+    output.resize(length);
+}
+
+inline void compress(std::string const& input, std::string & output)
+{
+    z_stream deflate_s;
+    deflate_s.zalloc = Z_NULL;
+    deflate_s.zfree = Z_NULL;
+    deflate_s.opaque = Z_NULL;
+    deflate_s.avail_in = 0;
+    deflate_s.next_in = Z_NULL;
+    deflateInit(&deflate_s, Z_DEFAULT_COMPRESSION);
+    deflate_s.next_in = (Bytef *)input.data();
+    deflate_s.avail_in = input.size();
+    size_t length = 0;
+    do {
+        size_t increase = input.size() / 2 + 1024;
+        output.resize(length + increase);
+        deflate_s.avail_out = increase;
+        deflate_s.next_out = (Bytef *)(output.data() + length);
+        int ret = deflate(&deflate_s, Z_FINISH);
+        if (ret != Z_STREAM_END && ret != Z_OK && ret != Z_BUF_ERROR) {
+            throw std::runtime_error(deflate_s.msg);
+        }
+        length += (increase - deflate_s.avail_out);
+    } while (deflate_s.avail_out == 0);
+    deflateEnd(&deflate_s);
+    output.resize(length);
+}
+
+}}
diff --git a/src/vector_tile_util.hpp b/src/vector_tile_util.hpp
index 06e8d55..25611f7 100644
--- a/src/vector_tile_util.hpp
+++ b/src/vector_tile_util.hpp
@@ -1,7 +1,6 @@
 #ifndef __MAPNIK_VECTOR_TILE_UTIL_H__
 #define __MAPNIK_VECTOR_TILE_UTIL_H__
 
-#include "clipper.hpp"
 #include "vector_tile.pb.h"
 #include <mapnik/vertex.hpp>
 #include <mapnik/box2d.hpp>
@@ -9,8 +8,13 @@
 #include <stdexcept>
 #include <string>
 
+#ifdef CONV_CLIPPER
+#include "clipper.hpp"
+#endif
+
 namespace mapnik { namespace vector {
 
+#ifdef CONV_CLIPPER
     bool is_solid_clipper(mapnik::vector::tile const& tile, std::string & key)
     {
         ClipperLib::Clipper clipper;
@@ -119,6 +123,7 @@ namespace mapnik { namespace vector {
         // not on the border of the bbox.
         return true;
     }
+#endif
 
     bool is_solid_extent(mapnik::vector::tile const& tile, std::string & key)
     {
diff --git a/test/vector_tile.cpp b/test/vector_tile.cpp
index 66b6aac..8b4d8a6 100644
--- a/test/vector_tile.cpp
+++ b/test/vector_tile.cpp
@@ -219,7 +219,7 @@ int main (int argc, char* const argv[])
     mapnik::vector::spherical_mercator merc(256);
     merc.xyz(x,y,z,minx,miny,maxx,maxy);
     bbox.init(minx,miny,maxx,maxy);
-    int result = Catch::Main( argc, argv );
+    int result = Catch::Session().run( argc, argv );
     if (!result) printf("\x1b[1;32m ✓ \x1b[0m\n");
     google::protobuf::ShutdownProtobufLibrary();
     return result;

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-grass/mapnik-vector-tile.git

_______________________________________________
Pkg-grass-devel mailing list
Pkg-grass-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel

Reply via email to