tyrasd / overpass-turbo

A web based data mining tool for OpenStreetMap using the Overpass API.
https://overpass-turbo.eu
Other
950 stars 135 forks source link

Scientific notation in export causes invalid GPX export #588

Open BitScout opened 2 years ago

BitScout commented 2 years ago

Possibly needs to be forwarded to https://github.com/drolbr/Overpass-API but I'm not sure:

When doing an export of the borders of France I got invalid GPX code as one coordinate was so close to latitude 0 that it was exported in scientific notation:

<trkpt lat="49.3267136" lon="0.0005797"/>
<trkpt lat="49.3264086" lon="-2e-7"/>
<trkpt lat="49.3261744" lon="-0.0005312"/>

My query:

[out:json];

area["name"="France"]->.country;
rel["name"="France"]["type"="boundary"]["admin_level"="2"];
(
way(r)["maritime" != "yes"]({{bbox}});
way(area.country)["natural"="coastline"]({{bbox}});
);

out body;
>;
out skel qt;

Edit for context: I was trying to import the file into Maperitive v2.4.3

BitScout commented 2 years ago

Possibly relevant Overpass ticket: https://github.com/drolbr/Overpass-API/issues/514

drolbr commented 2 years ago

Possibly relevant Overpass ticket: drolbr/Overpass-API#514

While I appreciate the initiative, it is unrelated.The issue there tell you that the Overpass API neither accepts nor emits scientific notation, and the issue here is about too much scientific notation.

drolbr commented 2 years ago

There must be a step missing. The query produces ways and nodes, not XML elements of type trkpt.

BitScout commented 2 years ago

Ah, sorry, I should have included I'm going through https://overpass-turbo.eu/

Now the question is if that site's export function introduces the error or if it receives incorrect data from the API.

mmd-osm commented 2 years ago

I’m pretty sure it’s caused by the overpass turbo gpx export function.

Overpass API has no code in place to return scientific notation for lat/lons.

mmd-osm commented 2 years ago

By the way, you can easily reproduce the issue:

Query:

way(34386671);out geom;

Overpass API returns:

    <nd ref="1904237890" lat="49.3267136" lon="0.0005797"/>
    <nd ref="1904237751" lat="49.3264086" lon="-0.0000002"/>
    <nd ref="1904237701" lat="49.3261744" lon="-0.0005312"/>

GPX export returns:

<trkpt lat="49.3267136" lon="0.0005797"/>
<trkpt lat="49.3264086" lon="-2e-7"/>

-> overpass turbo creates invalid GPX data.

BitScout commented 2 years ago

Ah, sorry! And thank you for checking, I'll take this to https://overpass-turbo.eu/

mmd-osm commented 2 years ago

You're already on the overpass turbo repo. No need to go anywhere else.

BitScout commented 2 years ago

Oh. Yeah, I wasn't really sure if this repo was for the API and the website or both. I guess I'll stop writing that email then. :)

mmd-osm commented 2 years ago

The API is over at https://github.com/drolbr/Overpass-API ... this repo is for the web frontend only.

BitScout commented 2 years ago

Oh! I was reading this the wrong way round and understanding that the API returned correct results but the website was doing the GPX conversion.

mmd-osm commented 2 years ago

That's correct, the API returns correct results, the GPX conversion is done by the website. The website code introduces the error.

mmd-osm commented 2 years ago

Oh dude, you're messing it all up. Can you please close the Overpass API issue again?

BitScout commented 2 years ago

Sorry, didn't see your comment while writing the other ticket.

mmd-osm commented 2 years ago

So the issue is really in one of the libraries used by overpass turbo: https://github.com/tyrasd/togpx/blob/master/togpx.js

That's ok, just leave this issue open, and as it is right now.