mapbox / csv2geojson

magically convert csv files to geojson files
http://mapbox.github.io/csv2geojson/
MIT License
363 stars 82 forks source link

longitude with exponents are misinterpreted #25

Closed ziodave closed 9 years ago

ziodave commented 9 years ago

I have a CSV such as the following

label,latitude,longitude
House,4.7161357378478E1,1.27381324768066E1
...

The output after conversion is:

    {
        "type": "Feature",
        "properties": {
            "label": "House"
        },
        "geometry": {
            "type": "Point",
            "coordinates": [
                1.27381324768066,
                47.161357378478
            ]
        }
    }

As you can see the latitude is correctly interpreted, while the longitude sees its exponent dropped.

I traced down the issue being in lines 101-102 of csv2geojson.js:

        a = sexagesimal(lonk, 'EW');
        if (a) lonk = a;

lonk is turned from 1.27381324768066E1 to 1.27381324768066.

ziodave commented 9 years ago

In sexagesimal.js E is most probably interpreted as cardinal direction.

tmcw commented 9 years ago

What kind of system outputs numbers formatted like this?

ziodave commented 9 years ago

Not sure, this is how data is provided to me.

tmcw commented 9 years ago

I don't think it's really possible to decipher between this case and people actually wanting 'east' coordinates: the input to csv2geojson should be either decimal numbers, or sexagesimal notation. Handling alternative forms of formatting for decimals will only make it ambiguous.

If your case, you can probably just find & replace E1 with nothing in the file.