pelias / polylines

Pelias import pipeline for polyline (road network) data.
MIT License
17 stars 24 forks source link

Street polygon duplicate #244

Open ambrusadrianz opened 4 years ago

ambrusadrianz commented 4 years ago

Hey team!

I was using your awesome geocoding engine when I noticed something interesting. Let me tell you more about it.


Here's what I did :innocent:

pelias.github.io/compare


Here's what I got :scream_cat:

{
    "geocoding": ⊖{
        "version": "0.2",
        "attribution": "http://api.yourpelias.com/attribution",
        "query": ⊖{
            "enableDebug": false,
            "text": "dalagatan",
            "parser": "pelias",
            "parsed_text": ⊖{
                "subject": "dalagatan"
            },
            "size": 10,
            "layers": ⊖[
                "street"
            ],
            "private": false,
            "focus.point.lat": 59.4391,
            "focus.point.lon": 17.9415,
            "lang": ⊖{
                "name": "English",
                "iso6391": "en",
                "iso6393": "eng",
                "defaulted": false
            }
        },
        "engine": ⊖{
            "name": "Pelias",
            "author": "Mapzen",
            "version": "1.0"
        },
        "timestamp": 1583925036740
    },
    "type": "FeatureCollection",
    "features": ⊖[
       ⊖{
            "type": "Feature",
            "geometry": ⊖{
                "type": "Point",
                "coordinates": ⊖[
                    18.039446,
                    59.347814
                ]
            },
            "properties": ⊖{
                "id": "polyline:480661",
                "gid": "openstreetmap:street:polyline:480661",
                "layer": "street",
                "source": "openstreetmap",
                "source_id": "polyline:480661",
                "name": "Dalagatan",
                "street": "Dalagatan",
                "distance": 11.579,
                "accuracy": "centroid",
                "country": "Sweden",
                "country_gid": ⊖{
                    "0": "whosonfirst:country:85633789",
                },
                "country_a": "SWE",
                "region": "Stockholm",
                "region_gid": ⊖{
                    "0": "whosonfirst:region:85688429",
                },
                "region_a": "ST",
                "county": "Stockholm",
                "county_gid": ⊖{
                    "0": "whosonfirst:county:1159303035",
                },
                "localadmin": "Vantor",
                "localadmin_gid": ⊖{
                    "0": "whosonfirst:localadmin:1125362217",
                },
                "locality": "Stockholm",
                "locality_gid": ⊖{
                    "0": "whosonfirst:locality:101752307",
                },
                "neighbourhood": "Vasastaden",
                "neighbourhood_gid": ⊖{
                    "0": "whosonfirst:neighbourhood:85902593",
                },
                "continent": "Europe",
                "continent_gid": ⊖{
                    "0": "whosonfirst:continent:102191581",
                },
                "label": "Dalagatan, Stockholm, Sweden"
            },
            "bbox": ⊖[
                18.039043,
                59.347412,
                18.03985,
                59.348217
            ]
        },
       ⊖{
            "type": "Feature",
            "geometry": ⊖{
                "type": "Point",
                "coordinates": ⊖[
                    18.041739,
                    59.34523
                ]
            },
            "properties": ⊖{
                "id": "polyline:480353",
                "gid": "openstreetmap:street:polyline:480353",
                "layer": "street",
                "source": "openstreetmap",
                "source_id": "polyline:480353",
                "name": "Dalagatan",
                "street": "Dalagatan",
                "distance": 11.894,
                "accuracy": "centroid",
                "country": "Sweden",
                "country_gid": ⊖{
                    "0": "whosonfirst:country:85633789",
                },
                "country_a": "SWE",
                "region": "Stockholm",
                "region_gid": ⊖{
                    "0": "whosonfirst:region:85688429",
                },
                "region_a": "ST",
                "county": "Stockholm",
                "county_gid": ⊖{
                    "0": "whosonfirst:county:1159303035",
                },
                "localadmin": "Vantor",
                "localadmin_gid": ⊖{
                    "0": "whosonfirst:localadmin:1125362217",
                },
                "locality": "Stockholm",
                "locality_gid": ⊖{
                    "0": "whosonfirst:locality:101752307",
                },
                "neighbourhood": "Vasastaden",
                "neighbourhood_gid": ⊖{
                    "0": "whosonfirst:neighbourhood:85905583",
                },
                "continent": "Europe",
                "continent_gid": ⊖{
                    "0": "whosonfirst:continent:102191581",
                },
                "label": "Dalagatan, Stockholm, Sweden"
            },
            "bbox": ⊖[
                18.041603,
                59.345142,
                18.04191,
                59.345375
            ]
        }
    ],
    "bbox": ⊖[
        18.039043,
        59.345142,
        18.04191,
        59.348217
    ]
}

Here's what I was expecting :sparkles:

I was expecting the Dalagatan street to be merged by polylines into a single polygon.


Here's what I think could be improved :trophy:

Is this a polylines issue? Or there is some problem with the underlying OpenStreetMap data?

missinglink commented 4 years ago

Hi @ambrusadrianz, you should have a database called street.db within the interpolation subdirectory of your data dir.

Could you please query the database for the IDs 480661 and 480353 from the polyline table.

That will help me understand better why they weren't joined.

ambrusadrianz commented 4 years ago

It doesn't seem to contain any of the ids. Should I try to prepare the data again?

missinglink commented 4 years ago

Ok so another way is to get the data directly from the polylines file which was used at import time.

It will be in your data dir and likely end with .0sv or .polylines, the IDs are simply the line numbers in the file.

ambrusadrianz commented 4 years ago

Found the issue, since I have only a Sweden import, the ids are not the same as in the global pelias index. (duh)

The two polylines are:

missinglink commented 4 years ago

Hmm.. something weird is going on, my calculations of the polylines show them as ~50km apart.

However, the two results you posted are only 316 m apart!?

> var p = require('@mapbox/polyline');
undefined

> p.toGeoJSON('qmjqpBux~na@~m@j{@~HxPjB`OnAnZ', 6)
{ type: 'LineString',
  coordinates:
   [ [ 18.087835, 59.545321 ],
     [ 18.086869, 59.544569 ],
     [ 18.086584, 59.544409 ],
     [ 18.086327, 59.544355 ],
     [ 18.085887, 59.544315 ] ] }

> p.toGeoJSON('qurxoBi`xcb@pQ_^', 6)
{ type: 'LineString',
  coordinates: [ [ 18.428437, 59.139945 ], [ 18.428933, 59.139648 ] ] }
missinglink commented 4 years ago

So I suspect that it is correct to consider them disjoined but the centroids appear to be incorrect.

missinglink commented 4 years ago

Are you sure it's not these two disjoined streets with the same name? (the highlighted one is 'qurxoBi`xcb@pQ_^')

Screenshot 2020-03-13 at 20 46 33
missinglink commented 4 years ago

These are the two points from your original report:

Screenshot 2020-03-15 at 11 26 19

Please provide more information.

ambrusadrianz commented 4 years ago

I did a reimport of the swedish data, something seems to be off.

The polygon ids don't seem to refer to the correct polyline entries. They're much further away than the position of the pelias location.

Do you have any suggestion? What am I doing wrong? Tried with the sqlite database and the plain polylines extract as well.

missinglink commented 4 years ago

The IDs should map to line numbers in the file, maybe you're looking at the lines either one before or one after the target line?

missinglink commented 4 years ago

Also worth noting that the point Pelias provides for a street is 50% along the linestring at its midpoint.

missinglink commented 4 years ago

What does grep -ni Dalagatan /path/to/polylines.0sv return?