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:
authorIlya Zverev <zverik@textual.ru>2016-06-15 11:41:26 +0300
committerIlya Zverev <zverik@textual.ru>2016-06-15 11:41:26 +0300
commit609aac42f4d37dda1ce823f1415d3c9bc4d9e322 (patch)
tree7d9a921a3ad588bb18cfe2293748aa2f5003edca /tools
parent3dfaae720ad6f2c18497880743a8d6dc96076553 (diff)
[mwm.py] Find feature by id
Diffstat (limited to 'tools')
-rwxr-xr-xtools/python/mwm/find_feature.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/python/mwm/find_feature.py b/tools/python/mwm/find_feature.py
index 2115848f4b..3149a6e0b2 100755
--- a/tools/python/mwm/find_feature.py
+++ b/tools/python/mwm/find_feature.py
@@ -11,6 +11,7 @@ if len(sys.argv) < 4:
print(' et for exact type ("et shop" won\'t find shop-chemist)')
print(' n for names, case-sensitive ("n Starbucks" for all starbucks)')
print(' m for metadata keys ("m flats" for features with flats)')
+ print(' id for feature id ("id 1234" for feature #1234)')
sys.exit(1)
typ = sys.argv[2].lower()
@@ -19,7 +20,7 @@ find = sys.argv[3].decode('utf-8')
mwm = MWM(open(sys.argv[1], 'rb'))
mwm.read_header()
mwm.read_types(os.path.join(os.path.dirname(sys.argv[0]), '..', '..', '..', 'data', 'types.txt'))
-for feature in mwm.iter_features(metadata=True):
+for i, feature in enumerate(mwm.iter_features(metadata=True)):
found = False
if typ == 'n' and 'name' in feature['header']:
for value in feature['header']['name'].values():
@@ -34,5 +35,7 @@ for feature in mwm.iter_features(metadata=True):
elif typ == 'm' and 'metadata' in feature:
if find in feature['metadata']:
found = True
+ elif typ == 'id' and i == int(find):
+ found = True
if found:
print(json.dumps(feature, ensure_ascii=False).encode('utf-8'))