Geography: Add support for OSM node ids

This commit is contained in:
Valentin Lorentz 2023-10-27 11:30:57 +02:00
parent 1fb0bbd1c0
commit faa6474271
2 changed files with 15 additions and 2 deletions

View File

@ -187,7 +187,7 @@ class GeographyLocaltimeTestCase(PluginTestCase):
class GeographyWikidataTestCase(SupyTestCase): class GeographyWikidataTestCase(SupyTestCase):
@skipIf(not network, "Network test") @skipIf(not network, "Network test")
def testOsmidToTimezone(self): def testRelationOsmidToTimezone(self):
self.assertEqual( self.assertEqual(
wikidata.uri_from_osmid(450381), wikidata.uri_from_osmid(450381),
"http://www.wikidata.org/entity/Q22690", "http://www.wikidata.org/entity/Q22690",
@ -196,6 +196,12 @@ class GeographyWikidataTestCase(SupyTestCase):
wikidata.uri_from_osmid(192468), wikidata.uri_from_osmid(192468),
"http://www.wikidata.org/entity/Q47045", "http://www.wikidata.org/entity/Q47045",
) )
@skipIf(not network, "Network test")
def testNodeOsmidToTimezone(self):
self.assertEqual(
wikidata.uri_from_osmid(436012592),
"http://www.wikidata.org/entity/Q933",
)
@skipIf(not network, "Network test") @skipIf(not network, "Network test")
def testDirect(self): def testDirect(self):

View File

@ -115,7 +115,14 @@ LIMIT 1
OSMID_QUERY = string.Template( OSMID_QUERY = string.Template(
""" """
SELECT ?item WHERE { SELECT ?item WHERE {
?item wdt:P402 "$osmid". {
?item wdt:P402 "$osmid". # OSM relation ID
}
UNION
{
?item wdt:P11693 "$osmid". # OSM node ID
}
} }
LIMIT 1 LIMIT 1
""" """