-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
1,427 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from .mwm import MWM, Osm2Ft, __version__ | ||
from .mwmfile import MWMFile | ||
from .mwmfile import MWMFile, OsmIdCode | ||
from .mwm import MWM, __version__ | ||
from .osm2ft import Osm2Ft |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# OSM2FT Reader | ||
from .mwmfile import MWMFile | ||
|
||
|
||
class Osm2Ft(MWMFile): | ||
def __init__(self, f, ft2osm=False, tuples=True): | ||
MWMFile.__init__(self, f) | ||
self.read(ft2osm, tuples) | ||
|
||
def read(self, ft2osm=False, tuples=True): | ||
"""Reads mwm.osm2ft file, returning a dict of feature id <-> osm way id.""" | ||
count = self.read_varuint() | ||
self.data = {} | ||
self.ft2osm = ft2osm | ||
for i in range(count): | ||
osmid = self.read_osmid(tuples) | ||
fid = self.read_uint(4) | ||
self.read_uint(4) # filler | ||
if osmid is not None: | ||
if ft2osm: | ||
self.data[fid] = osmid | ||
else: | ||
self.data[osmid] = fid | ||
|
||
def __getitem__(self, k): | ||
return self.data.get(k) | ||
|
||
def __repr__(self): | ||
return '{} with {} items'.format('ft2osm' if self.ft2osm else 'osm2ft', len(self.data)) | ||
|
||
def __len__(self): | ||
return len(self.data) | ||
|
||
def __contains__(self, k): | ||
return k in self.data | ||
|
||
def __iter__(self): | ||
return iter(self.data) |
Oops, something went wrong.