forked from organicmaps/organicmaps
Fix extract_addr generation and a small bug in mwm.py
This commit is contained in:
parent
5e0afc72c0
commit
34db723f4f
3 changed files with 19 additions and 6 deletions
|
@ -16,6 +16,7 @@
|
|||
#include <set>
|
||||
#include <string>
|
||||
|
||||
constexpr int32_t kRoundDigits = 1e6;
|
||||
std::set<std::string> const kPoiTypes = {"amenity", "shop", "tourism", "leisure", "sport",
|
||||
"craft", "man_made", "office", "historic", "building"};
|
||||
|
||||
|
@ -48,8 +49,8 @@ void PrintFeature(FeatureBuilder1 const & fb, uint64_t)
|
|||
|
||||
auto const center = MercatorBounds::ToLatLon(fb.GetKeyPoint());
|
||||
auto coordinates = my::NewJSONArray();
|
||||
ToJSONArray(*coordinates, strings::to_string_dac(center.lon, 6));
|
||||
ToJSONArray(*coordinates, strings::to_string_dac(center.lat, 6));
|
||||
ToJSONArray(*coordinates, std::round(center.lon * kRoundDigits) / kRoundDigits);
|
||||
ToJSONArray(*coordinates, std::round(center.lat * kRoundDigits) / kRoundDigits);
|
||||
auto geometry = my::NewJSONObject();
|
||||
ToJSONObject(*geometry, "type", "Point");
|
||||
ToJSONObject(*geometry, "coordinates", coordinates);
|
||||
|
|
12
tools/python/mwm/decode_id.py
Executable file
12
tools/python/mwm/decode_id.py
Executable file
|
@ -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]))
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue