JOSM / geojson

Allows reading GeoJSON using different projections – NOW PART OF JOSM CORE
Apache License 2.0
13 stars 10 forks source link

JOSM can't read GeoJSON saved from JOSM! #14

Closed antifa-ev closed 6 years ago

antifa-ev commented 6 years ago

I use geojson 84 with JOSM 14026 (JRE 9) and can't open any GeoJSON again which I just saved from JOSM. Here is a basic non-working example:

{
    "type": "FeatureCollection",
    "generator": "JOSM",
    "features": [
        {
            "type": "Feature",
            "properties": null,
            "geometry": {
                "type": "LineString",
                "coordinates": [
                    [
                        -116.09484157521,
                        30.70279722039
                    ],
                    [
                        -116.07013790490,
                        30.70333789611
                    ]
                ]
            }
        }
    ]
}

I assume that it's because the line "properties": null, in the json.

Anyone else with this problem?

simonpoole commented 6 years ago

See https://help.openstreetmap.org/questions/64197/geojson-not-working-in-josm-but-at-geojsonio

csytsma commented 6 years ago

I've had mixed results with changing the extension to just ".json". Sometimes it works. But after a few times, it then appears to stop working. I can't figure out the randomness, which is weird.

I'm able to open an externally created .json file. Save it as .geojson. But then I can't open the re-saved file.

I agree with Antifa. I removed the "properties": null, and the file now works.

I looked at old .geojson files I have from prior saves, and they don't have the null. So that must have been introduced with latest JOSM version.

ovruni commented 6 years ago

I had the same problem, remove '"properties": null,' allows me to open the file.

don-vip commented 6 years ago

@jreijn with latest changes the example described in this ticket results in following exception:

java.lang.ClassCastException: javax.json.JsonValueImpl cannot be cast to javax.json.JsonObject
java.lang.ClassCastException: javax.json.JsonValueImpl cannot be cast to javax.json.JsonObject
        at org.glassfish.json.JsonObjectBuilderImpl$JsonObjectImpl.getJsonObject(JsonObjectBuilderImpl.java:242)
        at org.openstreetmap.josm.plugins.geojson.GeoJsonReader.getTags(GeoJsonReader.java:228)
        at org.openstreetmap.josm.plugins.geojson.GeoJsonReader.fillTagsFromFeature(GeoJsonReader.java:217)
        at org.openstreetmap.josm.plugins.geojson.GeoJsonReader.parseLineString(GeoJsonReader.java:145)
        at org.openstreetmap.josm.plugins.geojson.GeoJsonReader.parseGeometry(GeoJsonReader.java:107)
        at org.openstreetmap.josm.plugins.geojson.GeoJsonReader.parseFeature(GeoJsonReader.java:88)
        at org.openstreetmap.josm.plugins.geojson.GeoJsonReader.parseFeatureCollection(GeoJsonReader.java:81)
        at org.openstreetmap.josm.plugins.geojson.GeoJsonReader.parseRoot(GeoJsonReader.java:64)
        at org.openstreetmap.josm.plugins.geojson.GeoJsonReader.parse(GeoJsonReader.java:55)
        at org.openstreetmap.josm.plugins.geojson.GeoJsonReader.doParseDataSet(GeoJsonReader.java:240)
        at org.openstreetmap.josm.plugins.geojson.GeoJsonFileImporter.importData(GeoJsonFileImporter.java:46)
        at org.openstreetmap.josm.gui.io.importexport.FileImporter.importDataHandleExceptions(FileImporter.java:95)
don-vip commented 6 years ago

Thanks guys!