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

Geometries incorrectly formatted when using the changesets api #738

Open
atiannicelli opened this issue Jun 26, 2024 · 2 comments
Open

Geometries incorrectly formatted when using the changesets api #738

atiannicelli opened this issue Jun 26, 2024 · 2 comments

Comments

@atiannicelli
Copy link

When I download changesets using the changesets api the geometry of changesets is not correct. It seems that the lat and lon have been swapped. If I use the singular changeset api it works fine.

When I download all the changesets that have been created from 2024-06-10 to 2024-06-11 I get a large json file with all the changesets. Here is an example of the command I use to download the changesets.
Note: This command is repeated with different pages until I get them all for the day:

curl https://osmcha.org/api/v1/changesets/?date__gte=2024-06-10&date__lte=2024-06-11&format=json&page=101&page_size=400 

Here is an example of a changeset that I see in the output json file

{
    "id": 152519532,
    "type": "Feature",
    "geometry": {
        "type": "Polygon",
        "coordinates": [
            [
                [
                    14.6120371,
                    121.0590157
                ],
                [
                    14.6120371,
                    121.0590157
                ],
                [
                    14.6120371,
                    121.0590157
                ],
                [
                    14.6120371,
                    121.0590157
                ],
                [
                    14.6120371,
                    121.0590157
                ]
            ]
        ]
    },
    "properties": {
        "check_user": "mikko_tamura",
        "reasons": [],
        "tags": [],
        "features": [],
        "user": "PCeej",
        "uid": "15083934",
        "editor": "iD 2.29.0",
        "comment": "#APHub #OMGuru #tt_event #CCC2024 #CCCPOI added money lending POI",
        "comments_count": 0,
        "source": "Not reported",
        "imagery_used": "Esri World Imagery",
        "date": "2024-06-10T23: 58: 26Z",
        "reviewed_features": [],
        "tag_changes": {
            "shop": [
                "money_lender"
            ]
        },
        "create": 1,
        "modify": 0,
        "delete": 0,
        "area": 0.0,
        "is_suspect": false,
        "harmful": false,
        "checked": true,
        "check_date": "2024-06-16T04: 44: 32.319055Z",
        "metadata": {
            "host": "https: //www.openstreetmap.org/edit",
            "locale": "en-US",
            "hashtags": "#APHub;#OMGuru;#tt_event;#CCC2024;#CCCPOI",
            "changesets_count": 1209
        }
    }
}

Notice the coordinates
[[
[14.6120371,121.0590157],
[14.6120371,121.0590157],
[14.6120371,121.0590157],
[14.6120371,121.0590157],
[14.6120371,121.0590157]
]]

this would indicate that 14 is the longitude and 121 is latitude, but 121 is not a valid latitude as latitude goes from -90 to 90.

Now let's say that I request this specific changeset using the changeset API
I get the following:

$ curl "https://www.openstreetmap.org/api/0.6/changeset/152519532/?format=json" 
{
    "version": "0.6",
    "generator": "OpenStreetMap server",
    "copyright": "OpenStreetMap and contributors",
    "attribution": "http://www.openstreetmap.org/copyright",
    "license": "http://opendatacommons.org/licenses/odbl/1-0/",
    "changeset": {
        "id": 152519532,
        "created_at": "2024-06-10T23:58:26Z",
        "open": false,
        "comments_count": 0,
        "changes_count": 1,
        "closed_at": "2024-06-10T23:58:28Z",
        "min_lat": 14.6120371,
        "min_lon": 121.0590157,
        "max_lat": 14.6120371,
        "max_lon": 121.0590157,
        "uid": 15083934,
        "user": "PCeej",
        "tags": {
            "changesets_count": "1209",
            "comment": "#APHub #OMGuru #tt_event #CCC2024 #CCCPOI added money lending POI",
            "created_by": "iD 2.29.0",
            "hashtags": "#APHub;#OMGuru;#tt_event;#CCC2024;#CCCPOI",
            "host": "https://www.openstreetmap.org/edit",
            "imagery_used": "Esri World Imagery",
            "locale": "en-US"
        }
    }
}

This API response is correct and tells me that the min lat is 14 and min lon is 121.

I believe that the changesets api or the utilities that it uses to produce the GEOJson coordinates must have a bug and have the lat and lon reversed.

@willemarcel
Copy link
Collaborator

It seems there is a problem with changesets that contain only a point and that the min and max values of the coordinates are the same.

In the Django shell the wkt returns ther correct value, but the geojson returns the inverted values:

>>> a.bbox.wkt
'POLYGON ((121.0590157 14.6120371, 121.0590157 14.6120371, 121.0590157 14.6120371, 121.0590157 14.6120371, 121.0590157 14.6120371))'
>>> a.bbox.geojson
'{ "type": "Polygon", "coordinates": [ [ [ 14.6120371, 121.0590157 ], [ 14.6120371, 121.0590157 ], [ 14.6120371, 121.0590157 ], [ 14.6120371, 121.0590157 ], [ 14.6120371, 121.0590157 ] ] ] }'

@atiannicelli
Copy link
Author

I believe that I saw this same issue with bboxes that were not just one point. Are you sure it is only with changesets with a single point? Maybe multiple points would give you the same result?

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

2 participants