Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/python/mwm/decode_id.py12
-rw-r--r--tools/python/mwm/mwm.py8
2 files changed, 16 insertions, 4 deletions
diff --git a/tools/python/mwm/decode_id.py b/tools/python/mwm/decode_id.py
new file mode 100755
index 0000000000..376c91295f
--- /dev/null
+++ b/tools/python/mwm/decode_id.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python3
+import sys
+import mwm
+
+if len(sys.argv) < 2:
+ print('This script unpacks maps.me OSM id to an OSM object link.')
+ print('Usage: {} <id>'.format(sys.argv[0]))
+
+osm_id = mwm.unpack_osmid(int(sys.argv[1]))
+type_abbr = {'n': 'node', 'w': 'way', 'r': 'relation'}
+print('https://www.openstreetmap.org/{}/{}'.format(
+ type_abbr[osm_id[0]], osm_id[1]))
diff --git a/tools/python/mwm/mwm.py b/tools/python/mwm/mwm.py
index 4784f98b67..3259a518d1 100644
--- a/tools/python/mwm/mwm.py
+++ b/tools/python/mwm/mwm.py
@@ -496,12 +496,12 @@ RESET = ~(NODE | WAY | RELATION)
def unpack_osmid(num):
- if num & NODE == NODE:
- typ = 'n'
+ if num & RELATION == RELATION:
+ typ = 'r'
elif num & WAY == WAY:
typ = 'w'
- elif num & RELATION == RELATION:
- typ = 'r'
+ elif num & NODE == NODE:
+ typ = 'n'
else:
return None
return typ, num & RESET