mapnik / node-mapnik

Bindings to mapnik for node.js
http://mapnik.org/documentation/node-mapnik
BSD 3-Clause "New" or "Revised" License
532 stars 165 forks source link

node-mapnik 3.7.2 fails to build with geometry.hpp 1.0.0 & mapnik-vector-tile 1.6.1 #901

Open sebastic opened 5 years ago

sebastic commented 5 years ago

As reported by Matthias Klose in Debian Bug #913708:

node-mapnik ftbfs in unstable, with

/usr/include/vector_tile_geometry_encoder_pbf.ipp:305:48:   required from here
/usr/include/vector_tile_geometry_encoder_pbf.ipp:70:35: error: call of
overloaded 'encode_geometry_pbf(const mapbox::geometry::empty&,
protozero::pbf_writer&, int32_t&, int32_t&)' is ambiguous
         return encode_geometry_pbf(geom, feature_, x_, y_);
                ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/vector_tile_geometry_encoder_pbf.ipp:204:27: note: candidate: 'bool
mapnik::vector_tile_impl::encode_geometry_pbf(const
mapbox::geometry::multi_point<long int>&, protozero::pbf_writer&, int32_t&,
int32_t&)'
 MAPNIK_VECTOR_INLINE bool
encode_geometry_pbf(mapbox::geometry::multi_point<std::int64_t> const& geom,
                           ^~~~~~~~~~~~~~~~~~~
/usr/include/vector_tile_geometry_encoder_pbf.ipp:232:27: note: candidate: 'bool
mapnik::vector_tile_impl::encode_geometry_pbf(const
mapbox::geometry::line_string<long int>&, protozero::pbf_writer&, int32_t&,
int32_t&)'
 MAPNIK_VECTOR_INLINE bool
encode_geometry_pbf(mapbox::geometry::line_string<std::int64_t> const& line,
                           ^~~~~~~~~~~~~~~~~~~
/usr/include/vector_tile_geometry_encoder_pbf.ipp:246:27: note: candidate: 'bool
mapnik::vector_tile_impl::encode_geometry_pbf(const
mapbox::geometry::multi_line_string<long int>&, protozero::pbf_writer&,
int32_t&, int32_t&)'
 MAPNIK_VECTOR_INLINE bool
encode_geometry_pbf(mapbox::geometry::multi_line_string<std::int64_t> const& geom,
                           ^~~~~~~~~~~~~~~~~~~
/usr/include/vector_tile_geometry_encoder_pbf.ipp:265:27: note: candidate: 'bool
mapnik::vector_tile_impl::encode_geometry_pbf(const
mapbox::geometry::polygon<long int>&, protozero::pbf_writer&, int32_t&, int32_t&)'
 MAPNIK_VECTOR_INLINE bool
encode_geometry_pbf(mapbox::geometry::polygon<std::int64_t> const& poly,
                           ^~~~~~~~~~~~~~~~~~~
/usr/include/vector_tile_geometry_encoder_pbf.ipp:279:27: note: candidate: 'bool
mapnik::vector_tile_impl::encode_geometry_pbf(const
mapbox::geometry::multi_polygon<long int>&, protozero::pbf_writer&, int32_t&,
int32_t&)'
 MAPNIK_VECTOR_INLINE bool
encode_geometry_pbf(mapbox::geometry::multi_polygon<std::int64_t> const& geom,
                           ^~~~~~~~~~~~~~~~~~~
/usr/include/vector_tile_geometry_encoder_pbf.ipp:299:27: note: candidate: 'bool
mapnik::vector_tile_impl::encode_geometry_pbf(const
mapbox::geometry::geometry<long int, std::vector>&, protozero::pbf_writer&,
int32_t&, int32_t&)'
 MAPNIK_VECTOR_INLINE bool
encode_geometry_pbf(mapbox::geometry::geometry<std::int64_t> const& geom,
                           ^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/vector_tile_processor.ipp:3,
                 from /usr/include/vector_tile_processor.hpp:210,
                 from ../src/mapnik_map.cpp:15:
/usr/include/vector_tile_geometry_feature.hpp: In instantiation of 'void
mapnik::vector_tile_impl::geometry_to_feature_pbf_visitor::operator()(const T&)
[with T = mapbox::geometry::empty]':

It looks like geometry.hpp 1.0.0 caused this issue.

plugwash commented 5 years ago

I am far from an expert (just a maintainer of a Debian derivative who ran into this build failure) but here is my interpretation of what is going on.

mapbox::geometry::geometry is a "variant" type which can be one of a variety of subtypes.

There is an implementation of encode_geometry_pbf that takes said variant and uses some template magic to look up the type stored in the variant and dispatch it to the correct implementation.

It looks like a new type "empty" was added to the list of types supported by the variant. When the template magic trys to generate the dispatch for the variant the compiler fails to find the routine to dispatch to, for reasons I don't fully understand it considers this as "ambiguous" rather than "no match".

The fix would seem to be to add an implementation of encode_geometry_pbf for mapbox::geometry::empty . From reading the existing "multi point" implementation I belive this implementation should simply return false, but I am far from an expert.

akx commented 5 years ago

Hmm, since Travis passes mostly fine (and it builds using clang), I think this might be a gcc-only problem?

plugwash commented 5 years ago

what version of mapnik-vector-tile are you testing with? It looks like this has been fixed (with a more aggressive patch than the one I used) in the master branch of mapnik-vector-tile ( https://github.com/mapbox/mapnik-vector-tile/commit/29fae7a166861e74d03d8e23a5622c70db14ab95 ) , though there don't seem to have been any releases since.

akx commented 5 years ago

Actually, no, clang++ fails the same way. :(

I'm building 3fecdfa88189ba00d4ac6a2600822c5ad3f3f5d5 from source in a Docker container.

I just wonder how Travis seems to pass alright with the current master...

akx commented 5 years ago

Ah, this might be the thing:

If building against an external Mapnik please know that Mapnik Vector Tile does not currently support Mapnik 3.1.x.

I'm currently on Mapnik master too, which identifies itself as 4.x.