Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The browser version of osmtogeojson produces different values than the node CLI #109

Open
backspaces opened this issue May 6, 2019 · 0 comments

Comments

@backspaces
Copy link

TLDR: I performed the following experiment which creates an osmtogeojson installation and uses it to create both a node and browser based osm to geojson transform.

They differ with the browser version apparently not placing the osm tags directly into the feature properties object.

Details:
The methodology proceeds like this, using the overpass api to create a osm file for part of santa fe new mexico, and then use osmtogeojson to create the associated geojson.

mkdir osm; cd osm
npm init -y
npm install osmtogeojson
curl "https://overpass-api.de/api/interpreter?data=%5Bout%3Ajson%5D%5Btimeout%3A180%5D%5Bbbox%3A35.67514743608467%2C-105.9521484375%2C35.6929946320988%2C-105.93017578125%5D%3B%0Away%5Bhighway%5D%3B%0A(._%3B%3E%3B)%3B%0Aout%3B" > santafe.osm
./node_modules/osmtogeojson/osmtogeojson < santafe.osm > santafe.json

At this point we have an osm file and the associated node based json.

Next I run the osm.html file included in the attached zip. It uses a script tag for osmtogeojson.js (I used two version, one from ./node_modules, the other from unpkg.com CDN).

The html mainly runs code to import the node geojson, and to create a browser version of the geojson.

async function run() {
    window.osm = await xhrPromise('./santafe.osm', 'json')
    window.chrome = osmtogeojson(osm)
    window.node = await xhrPromise('./santafe.json', 'json')

    console.log('osm', osm)
    console.log('chrome', chrome)
    console.log('node', node)

    console.log('chrome', sample(chrome))
    console.log('node', sample(node))
}

Opening the console gives access to the two geojson objects, "chrome" and "node", in the window global object. Two "samples" are printed out to show the same feature, showing how they differ. Primarily the properties objects differ.

I've made the files available on:
http://backspaces.net/temp/osm/
and
http://backspaces.net/temp/osm.zip
and the osm.html can be run by
http://backspaces.net/temp/osm/osm.html

Whew! I hope this is not too complicated. I'm loving osmtogeojson, it's superb! I discovered the issue via #108 so hope to see a lot of osmtogeojson in browsers!

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

No branches or pull requests

1 participant