decision-labs / node-mapnik

merge carto and official node-mapnik
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Migrate NAN to NAPI #5

Open sabman opened 2 years ago

sabman commented 2 years ago

Migrate the code from the carto branch which used NAN to NAPI.

@2021-12-30 21:03:23 +01:00 working branch: v4.5.0-mapnik-v3.6.2-carto

sabman commented 2 years ago
  1. install mapnik
git checkout mapnik-v3.0.24-v3.0.15-carto
PYTHON=python2 ./configure CXX=g++ CC=gcc
# in Makefile change PYTHON=python to PYTHON=python2
  1. install node-mapnik
git checkout v4.5.0-mapnik-v3.6.2-carto
make 

Getting the following error right now

../src/mapnik_vector_tile_query.cpp:493:57: note: candidate function not viable: no known conversion from 'query_hit' to 'int &' for 1st argument
        std::sort(hit.second.begin(), hit.second.end(), [](auto const& a, auto const& b) {
                                                        ^
../src/mapnik_vector_tile_query.cpp:493:57: note: conversion candidate of type 'void (*)(int &, int &)'
11 errors generated.
make[2]: *** [mapnik.target.mk:264: Release/obj.target/mapnik/src/mapnik_vector_tile_query.o] Error 1
make[2]: Leaving directory '/app/node-mapnik/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
gyp ERR! System Linux 5.4.0-91-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--ENABLE_GLIBC_WORKAROUND=true" "--enable_sse=true" "--loglevel=error" "--clang" "--module=/app/node-mapnik/lib/binding/mapnik.node" "--module_name=mapnik" "--module_path=/app/node-mapnik/lib/binding" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72"
gyp ERR! cwd /app/node-mapnik
gyp ERR! node -v v12.22.8
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --ENABLE_GLIBC_WORKAROUND=true --enable_sse=true --loglevel=error --clang --module=/app/node-mapnik/lib/binding/mapnik.node --module_name=mapnik --module_path=/app/node-mapnik/lib/binding --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/app/node-mapnik/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1022:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
node-pre-gyp ERR! System Linux 5.4.0-91-generic
node-pre-gyp ERR! command "/usr/bin/node" "/app/node-mapnik/node_modules/.bin/node-pre-gyp" "configure" "build" "--ENABLE_GLIBC_WORKAROUND=true" "--enable_sse=true" "--loglevel=error" "--clang"
node-pre-gyp ERR! cwd /app/node-mapnik
node-pre-gyp ERR! node -v v12.22.8
node-pre-gyp ERR! node-pre-gyp -v v0.13.0
node-pre-gyp ERR! not ok
Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --ENABLE_GLIBC_WORKAROUND=true --enable_sse=true --loglevel=error --clang --module=/app/node-mapnik/lib/binding/mapnik.node --module_name=mapnik --module_path=/app/node-mapnik/lib/binding --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
make[1]: *** [Makefile:36: release_base] Error 1
make[1]: Leaving directory '/app/node-mapnik'
make: *** [Makefile:44: release] Error 2
sabman commented 2 years ago

Applied fix

std::sort(
  hit.second.begin(), hit.second.end(), [](query_hit const &a, query_hit const &b
) 
  { return a.distance < b.distance; });

Now hitting this compile error:

../src/mapnik_vector_tile_query.cpp: In member function ‘detail::p2p_result detail::p2p_distance::operator()(const mapnik::geometry::polygon<double, mapnik::geometry::rings_container>&) const’:
../src/mapnik_vector_tile_query.cpp:106:38: error: ‘const struct mapnik::geometry::polygon<double, mapnik::geometry::rings_container>’ has no member named ‘size’
  106 |         std::size_t num_rings = poly.size();
      |                                      ^~~~
../src/mapnik_vector_tile_query.cpp:110:36: error: no match for ‘operator[]’ (operand types are ‘const mapnik::geometry::polygon<double, mapnik::geometry::rings_container>’ and ‘std::size_t’ {aka ‘long unsigned int’})
  110 |             auto const& ring = poly[ring_index];
      |                                    ^
make[1]: *** [mapnik.target.mk:264: Release/obj.target/mapnik/src/mapnik_vector_tile_query.o] Error 1
make[1]: Leaving directory '/app/node-mapnik/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
gyp ERR! System Linux 5.4.0-92-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--ENABLE_GLIBC_WORKAROUND=true" "--enable_sse=true" "--loglevel=error" "--clang" "--module=/app/node-mapnik/lib/binding/mapnik.node" "--module_name=mapnik" "--module_path=/app/node-mapnik/lib/binding" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72"
artemp commented 2 years ago

@sabman you need to upgrade dependencies to later versions, see below -

image

image

sabman commented 2 years ago

@artemp updated dependencies (51aa691a062b0d5f9a07a11946026e68c8f66567) but still running into the following error. Odd. Any ideas.

../src/mapnik_vector_tile_query.cpp:106:38: error: ‘const struct mapnik::geometry::polygon<double, mapnik::geometry::rings_container>’ has no member named ‘size’
  106 |         std::size_t num_rings = poly.size();
      |                                      ^~~~
../src/mapnik_vector_tile_query.cpp:110:36: error: no match for ‘operator[]’ (operand types are ‘const mapnik::geometry::polygon<double, mapnik::geometry::rings_container>’ and ‘std::size_t’ {aka ‘long unsigned int’})
  110 |             auto const& ring = poly[ring_index];