MCPcopy Create free account
hub / github.com/comaps/comaps / FeaturePython

Class FeaturePython

tools/python/mwm/mwm_python.py:172–294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170
171
172class FeaturePython(mi.Feature):
173 def __init__(self, mwm: MwmPython, index: int):
174 self.mwm = mwm
175 self._index = index
176
177 header_bits = read_uint(self.mwm.file, 1)
178 types_count = (header_bits & 0x07) + 1
179 has_name = header_bits & 0x08 > 0
180 has_layer = header_bits & 0x10 > 0
181 has_addinfo = header_bits & 0x80 > 0
182 geom_type = header_bits & 0x60
183
184 self._types = [read_varuint(self.mwm.file) for _ in range(types_count)]
185 self._names = read_multilang(self.mwm.file) if has_name else {}
186 self._layer = read_uint(self.mwm.file, 1) if has_layer else 0
187
188 self._rank = 0
189 self._road_number = ""
190 self._house_number = ""
191
192 if has_addinfo:
193 if geom_type == GeomType.POINT:
194 self._rank = read_uint(self.mwm.file, 1)
195 elif geom_type == GeomType.LINE:
196 self._road_number = read_string(self.mwm.file)
197 elif geom_type == GeomType.AREA or geom_type == GeomType.POINT_EX:
198 self._house_number = read_numeric_string(self.mwm.file)
199
200 self._geom_type = mi.GeomType.undefined
201 self._geometry = []
202
203 if geom_type == GeomType.POINT or geom_type == GeomType.POINT_EX:
204 self._geometry = mi.GeomType.point
205 geometry = [
206 read_coord(self.mwm.file, self.mwm.base_point, self.mwm.coord_size)
207 ]
208 elif geom_type == GeomType.LINE:
209 self._geometry = mi.GeomType.line
210 elif geom_type == GeomType.AREA:
211 self._geometry = mi.GeomType.area
212
213 def readable_name(self) -> str:
214 if "default" in self._names:
215 return self._names["default"]
216 elif "en" in self._names:
217 return self._names["en"]
218 elif self._names:
219 k = next(iter(self._names))
220 return self._names[k]
221 return ""
222
223 def population(self) -> int:
224 logger.warn("Method population() does not have an implementation.")
225
226 def center(self) -> mi.Point:
227 logger.warn("Method center() does not have an implementation.")
228
229 def limit_rect(self) -> mi.Rect:

Callers 1

__next__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected