polylines icon indicating copy to clipboard operation
polylines copied to clipboard

Street polygon duplicate

Open ambrusadrianz opened this issue 5 years ago • 12 comments

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?

ambrusadrianz avatar Mar 11 '20 11:03 ambrusadrianz

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.

missinglink avatar Mar 11 '20 18:03 missinglink

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

ambrusadrianz avatar Mar 11 '20 18:03 ambrusadrianz

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.

missinglink avatar Mar 11 '20 19:03 missinglink

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:

  • qmjqpBux~na@~m@j{@~HxPjB`OnAnZ
  • qurxoBi`xcb@pQ_^

ambrusadrianz avatar Mar 12 '20 08:03 ambrusadrianz

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 avatar Mar 13 '20 19:03 missinglink

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

missinglink avatar Mar 13 '20 19:03 missinglink

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 avatar Mar 13 '20 19:03 missinglink

These are the two points from your original report:

Screenshot 2020-03-15 at 11 26 19

Please provide more information.

missinglink avatar Mar 15 '20 10:03 missinglink

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.

ambrusadrianz avatar Mar 16 '20 18:03 ambrusadrianz

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 avatar Mar 16 '20 18:03 missinglink

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

missinglink avatar Mar 16 '20 18:03 missinglink

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

missinglink avatar Mar 16 '20 18:03 missinglink