Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Example fails with error #53

Open
grischard opened this issue Aug 14, 2019 · 9 comments
Open

Example fails with error #53

grischard opened this issue Aug 14, 2019 · 9 comments

Comments

@grischard
Copy link

On a Debian 9 VM, using https://github.com/mapbox/route-annotator/archive/0.2.4.tar.gz and geofabrik's ‘monaco-latest.osm.pbf’, running curl "http://localhost:5000/coordlist/7.422155,43.7368838;7.4230139,43.7369751" prints "Bad Request". An error is produced on the server side.

$ npm install
npm WARN deprecated [email protected]: This module is no longer maintained, try this instead:
npm WARN deprecated   npm i nyc
npm WARN deprecated Visit https://istanbul.js.org/integrations for other alternatives.

> @mapbox/[email protected] install /home/stereo/route-annotator-0.2.4
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download
[@mapbox/route-annotator] Success: "/home/stereo/route-annotator-0.2.4/lib/binding/route_annotator.node" is installed via remote
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN @mapbox/[email protected] license should be a valid SPDX license expression

added 254 packages from 316 contributors in 12.491s
$ node example-server.js monaco-latest.osm.pbf
Parsing monaco-latest.osm.pbf ... done
Number of node pairs indexed: 5479
Number of ways indexed: 865
done
String data is 0 Used: 0
way_tag_ranges = Allocated 6920  Used: 6920
keyvalue = Allocated 0  Used: 0
stringoffset = Allocated 0  Used: 0
pair_way_map = Allocated 109580  Load factor: 0.728881 Buckets: 7517
Listening on 0.0.0.0:5000
GET  /coordlist/7.422155,43.7368838;7.4230139,43.7369751  curl/7.52.1
Error: Annotator not created with coordinates support
@joshjconlin
Copy link

I also have this error

@grischard
Copy link
Author

grischard commented Oct 3, 2019

@joshjconlin I ended up running route-annotator in docker. See my commits 2625763 and 94bf391 and adjust for your osm file name.

@joshjconlin
Copy link

joshjconlin commented Oct 3, 2019

@grischard thanks for the response. I tried your dockerfile but I still have the same issue. String data is 0 Used: 0 way_tag_ranges = Allocated 4048032 Used: 4048032 keyvalue = Allocated 0 Used: 0 stringoffset = Allocated 0 Used: 0 pair_way_map = Allocated 84002700 Load factor: 0.964283 Buckets: 4355707 err Error: Annotator not created with coordinates support

Dockerfile

FROM node:8

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install --unsafe-perm
COPY . .

ENV ANNOTATOR_PORT=5050

EXPOSE 5050
CMD [ "node", "index.js"]``` 

and the actual code I'm trying to run 

```const taglookup = new (require('@mapbox/route-annotator')).Annotator();
const path = require('path');

const data = "47.46284,-122.25853 47.4631,-122.25928 47.46323,-122.25973 47.46334,-122.26012 47.46338,-122.26033 47.46341,-122.26045 47.46351,-122.26101 47.46355,-122.26145 47.46356,-122.2619 47.46355,-122.26235 47.4635,-122.26287 47.46346,-122.26313 47.46344,-122.26325 47.46337,-122.26358 47.46329,-122.26387 47.46317,-122.26425 "

const parsedCoordinates = data.split(' ').filter(val => val && val !== ' ').map((val => [...(val.split(',').map(v => parseFloat(v)))]));

const results = [];

//// Do the same thing, but this time use coordinates instead
// // of node ids.  Internally, a radius search finds the closest
// // node within 5m
taglookup.loadOSMExtract(path.join(__dirname,'./washington-latest.osm.pbf'), (err) => {
  if (err) throw err;
    taglookup.annotateRouteFromLonLats(parsedCoordinates, (err, wayIds) => {
        if (err) {
            console.warn('err', err);
        } else {
            taglookup.getAllTagsForWayId(wayIds[0], (err, tags) => {
                if (err) {
                    console.warn(('second err'))
                } else {
                    results.push(tags);
                    console.warn(results, 'results');
                }
            })
        }
    })
});``` 

Any help would be much appreciated, thanks again for your previous response

@grischard
Copy link
Author

Can you get the example server to work, then call that with your coordinates over http?

@arminus
Copy link

arminus commented Jul 3, 2020

I have the same issue. Built from the git clone with npm install --unsafe-perm as in that docker file, don't observe any errors during the build, all tests pass, but when calling the example server with a set of coordinates, I get

Error: Annotator not created with coordinates support

@StephanGeorg
Copy link

StephanGeorg commented May 13, 2021

You have to pass { coordinates: true } to the Annotator constructor:

const taglookup = new (require('@mapbox/route-annotator')).Annotator({ coordinates: true });

I also had to npm install --unsafe-perm the module itself.

@arminus
Copy link

arminus commented May 13, 2021

Ok, that gets me one error further:

arminus@ub14vm:~/osm/route-annotator$ node my_test.js 
Parsing /home/amueller/osm/route-annotator/monaco-latest.osm.pbf ... done
Number of node pairs indexed: 5717
Number of ways indexed: 949
Constructing RTree ... done
String data is 0 Used: 0
way_tag_ranges = Allocated 7592  Used: 7592
keyvalue = Allocated 0  Used: 0
stringoffset = Allocated 0  Used: 0
pair_way_map = Allocated 114340  Load factor: 0.760543 Buckets: 7517
/home/arminus/osm/route-annotator/my_test.js:13
    taglookup.getAllTagsForWayId(wayIds[0], (err, tags) => {
              ^

TypeError: A numeric way ID and a callback expected
    at taglookup.annotateRouteFromLonLats (/home/arminus/osm/route-annotator/my_test.js:13:15)

@StephanGeorg
Copy link

Had the same problem and opened a new issue: #62

@arminus
Copy link

arminus commented May 13, 2021

That's right, finally got it working now. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants