From a0109c229e77372300487c31cd51e92fc59403c7 Mon Sep 17 00:00:00 2001 From: Ilya Zverev Date: Wed, 27 Jan 2016 15:41:31 +0300 Subject: [PATCH] More mwm magic --- tools/python/mwm/dump_mwm.py | 16 ++++++++++++---- tools/python/mwm/mwm.py | 9 ++++++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/tools/python/mwm/dump_mwm.py b/tools/python/mwm/dump_mwm.py index bc86ba53cd..828303d6ad 100755 --- a/tools/python/mwm/dump_mwm.py +++ b/tools/python/mwm/dump_mwm.py @@ -1,6 +1,5 @@ #!/usr/bin/python -import sys, os.path -import itertools +import sys, os.path, random from mwm import MWM if len(sys.argv) < 2: @@ -16,9 +15,18 @@ for tag, value in mwm.tags.iteritems(): print 'Version:', mwm.read_version() print 'Header:', mwm.read_header() print 'Metadata count:', len(mwm.read_metadata()) + cross = mwm.read_crossmwm() if cross: print 'Outgoing points:', len(cross['out']), 'incoming:', len(cross['in']) print 'Outgoing regions:', set(cross['neighbours']) -for feature in itertools.islice(mwm.iter_features(), 10): - print feature + +print 'Sample features:' +count = 5 +probability = 1.0 / 1000 +for feature in mwm.iter_features(): + if random.random() < probability: + print feature + count -= 1 + if count <= 0: + break diff --git a/tools/python/mwm/mwm.py b/tools/python/mwm/mwm.py index 1ad6851331..af40135add 100644 --- a/tools/python/mwm/mwm.py +++ b/tools/python/mwm/mwm.py @@ -2,10 +2,17 @@ import struct import math -# Unprocessed sections: geomN, trgN, idx, sdx (search index), addr (search address), offs (feature offsets), dat (!) +# Unprocessed sections: geomN, trgN, idx, sdx (search index), addr (search address), offs (feature offsets - succinct) # Routing sections: mercedes (matrix), daewoo (edge data), infinity (edge id), skoda (shortcuts), chrysler (cross context), ftseg, node2ftseg # (these mostly are succinct structures, except chrysler and node2ftseg, so no use trying to load them here) +# TODO: +# - Fix bounds reading in the header +# - Fix delta point encoding (coords are plausible, but incorrect) +# - Find why polygon geometry is incorrect in iter_features() +# - Multilang string reading +# - Find feature ids in the 'dat' section, or find a way to read the 'offs' section + class MWM: languages = ["default", "en", "ja", "fr", "ko_rm", "ar", "de", "int_name", "ru", "sv", "zh", "fi", "be", "ka", "ko",