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 f7af37347e112e080cda1913fc1496f8e45360ea
Author: Jérémy Lal <kapo...@melix.org>
Date:   Sun Feb 9 21:03:03 2014 +0100

    Imported Upstream version 0.3.4+dfsg
---
 CHANGELOG.md                   |  4 ++++
 README.md                      |  2 +-
 package.json                   |  2 +-
 proto/vector_tile.proto        |  4 ++--
 src/vector_tile_datasource.hpp | 37 ++++++++++++++++++++++++-------------
 5 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2c3b8c7..60593b4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Changlog
 
+## 0.3.4
+
+ - Fixed tile_datasource geometry decoding such that it respects multipart 
geometries (#19)
+
 ## 0.3.3
 
  - Added support in tileinfo demo program for reading zlib compressed tiles
diff --git a/README.md b/README.md
index dcb0bbc..445fbf5 100644
--- a/README.md
+++ b/README.md
@@ -36,7 +36,7 @@ as multiple features, each storing a single geometry part.
 Geometries are stored as an x,y,command stream (where `command` is a rendering 
command
 like move_to or line_to). Geometries are clipped, reprojected into the map srs,
 converted to screen coordinates, and 
[delta](http://en.wikipedia.org/wiki/Delta_encoding)
-and [zigzag](http://en.wikipedia.org/wiki/Delta_encoding) encoded.
+and 
[zigzag](https://developers.google.com/protocol-buffers/docs/encoding#types) 
encoded.
 
 Feature attributes are encoded as key:value pairs which are dictionary encoded
 at the layer level for compact storage of any repeated keys or values. Values 
use variant
diff --git a/package.json b/package.json
index 65c3553..41602ee 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
     "name": "mapnik-vector-tile",
-    "version": "0.3.3",
+    "version": "0.3.4",
     "description": "Mapnik vector tile API",
     "main": "./package.json",
     "repository"   :  {
diff --git a/proto/vector_tile.proto b/proto/vector_tile.proto
index e25ac3b..110f37c 100644
--- a/proto/vector_tile.proto
+++ b/proto/vector_tile.proto
@@ -48,8 +48,8 @@ message tile {
                 // - ClosePath: 7   (no parameters follow)
                 //
                 // Ex.: MoveTo(3, 6), LineTo(8, 12), LineTo(20, 34), ClosePath
-                // Encoded as: [ 9 3 6 18 5 6 12 22 7 ]
-                //                                  == command type 7 
(ClosePath)
+                // Encoded as: [ 9 3 6 18 5 6 12 22 15 ]
+                //                                  == command type 7 
(ClosePath), length 1
                 //                             ===== relative LineTo(+12, +22) 
== LineTo(20, 34)
                 //                         === relative LineTo(+5, +6) == 
LineTo(8, 12)
                 //                      == [00010 010] = command type 2 
(LineTo), length 2
diff --git a/src/vector_tile_datasource.hpp b/src/vector_tile_datasource.hpp
index 7105a3d..362e8e9 100644
--- a/src/vector_tile_datasource.hpp
+++ b/src/vector_tile_datasource.hpp
@@ -77,15 +77,26 @@ namespace mapnik { namespace vector {
             {
                 mapnik::vector::tile_feature const& f = layer_.features(itr_);
                 mapnik::value_integer feature_id = itr_++;
-                std::auto_ptr<mapnik::geometry_type> geom(
-                    new mapnik::geometry_type(
+                // if encoded feature was given an id, respect it
+                // https://github.com/mapbox/mapnik-vector-tile/issues/17
+                // https://github.com/mapbox/mapnik-vector-tile/issues/18
+                if (f.has_id())
+                {
+                    feature_id = f.id();
+                }
+                mapnik::feature_ptr feature(
+                    mapnik::feature_factory::create(ctx_,feature_id));
+                feature->paths().push_back(new mapnik::geometry_type(
                         mapnik::eGeomType(f.type())));
+                mapnik::geometry_type * geom = &feature->paths().front();
                 int cmd = -1;
                 const int cmd_bits = 3;
                 unsigned length = 0;
                 double x = tile_x_, y = tile_y_;
                 bool first = true;
                 mapnik::box2d<double> envelope;
+                double first_x=0;
+                double first_y=0;
                 for (int k = 0; k < f.geometry_size();)
                 {
                     if (!length) {
@@ -103,6 +114,16 @@ namespace mapnik { namespace vector {
                             dy = ((dy >> 1) ^ (-(dy & 1)));
                             x += (static_cast<double>(dx) / scale_);
                             y -= (static_cast<double>(dy) / scale_);
+                            if (cmd == mapnik::SEG_MOVETO)
+                            {
+                                if (!first) {
+                                    feature->paths().push_back(new 
mapnik::geometry_type(
+                                        mapnik::eGeomType(f.type())));
+                                    geom = &feature->paths().back();
+                                }
+                                first_x = x;
+                                first_y = y;
+                            }
                             if (first)
                             {
                                 envelope.init(x,y,x,y);
@@ -116,6 +137,7 @@ namespace mapnik { namespace vector {
                         }
                         else if (cmd == (mapnik::SEG_CLOSE & ((1 << cmd_bits) 
- 1)))
                         {
+                            geom->push_vertex(first_x, first_y, 
mapnik::SEG_LINETO);
                             geom->push_vertex(0, 0, mapnik::SEG_CLOSE);
                         }
                         else
@@ -128,17 +150,6 @@ namespace mapnik { namespace vector {
                 {
                     continue;
                 }
-                // if encoded feature was given an id, respect it
-                // TODO: id should not be optional!
-                // https://github.com/mapbox/mapnik-vector-tile/issues/17
-                // https://github.com/mapbox/mapnik-vector-tile/issues/18
-                if (f.has_id())
-                {
-                    feature_id = f.id();
-                }
-                mapnik::feature_ptr feature(
-                    mapnik::feature_factory::create(ctx_,feature_id));
-                feature->paths().push_back(geom);
 
                 // attributes
                 for (int m = 0; m < f.tags_size(); m += 2)

-- 
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