urbica / galton

Lightweight Node.js isochrone map server
https://galton.urbica.co
MIT License
271 stars 36 forks source link

Application crush after 1st responce #196

Closed cm4ker closed 6 years ago

cm4ker commented 6 years ago

Hi! Today I was up the centos machine and npm restore all galton's packages. It works like a charme. (I'll wait help from osrm team for compiling osrm for windows)

But after 1st request the galton server responce and crush.

Look at the screenshot below: image

Blue marker I mark the values from array coordinates ([0] and [1]). In file ./node_modules/@turf/helpers/index.js, I make next modification. image

The coordinates was undefined then the point method was invoked.

Is this a bug or I made something wrong?

Steps for reproduce in my case: OS: Centos 7 1) Install galton

git clone https://github.com/urbica/galton.git
cd galton
npm install

2) Process map

wget https://s3.amazonaws.com/metro-extracts.mapzen.com/moscow_russia.osm.pbf
./node_modules/osrm/lib/binding/osrm-extract -p ./node_modules/osrm/profiles/car.lua moscow_russia.osm.pbf
./node_modules/osrm/lib/binding/osrm-contract moscow_russia.osrm
npm start -- moscow_russia.osrm

3) Run: node index.js "moscow_russia.osrm" 4) Try to request http://address:4000/?lng=37.62&lat=55.75&intervals=10&intervals=20&&intervals=30

UPDATE I fix the crush by adding row marked as --->> in code print below in file galton/src/index.js

 return (req, res) => {
    const { query } = url.parse(req.url, true);
    const options = Object.assign({}, parseQuery(query), { osrm });

    res.setHeader('Content-Type', 'application/json');
    if (config.cors) {
      res.setHeader('Access-Control-Allow-Origin', '*');
    }
 --->>   if(options.lng === undefined || options.lat === undefined) return;

    isochrone([options.lng, options.lat], options)
      .then(geojson => res.end(JSON.stringify(geojson)))
      .catch((error) => {
        res.statusCode = 500;
        res.end(JSON.stringify({ error }));
      });
  };

I don't know right it or no, but it works now.

stepankuzmin commented 6 years ago

Thanks for the report! Could you please try using the latest version from master branch?

cm4ker commented 6 years ago

Hi @stepankuzmin! Yea this was fixed for me then I pull from a master again. Thanks.