Compare commits

...

6 commits

Author SHA1 Message Date
Ilya Zverev
345da7d16d 0.10.1 2018-06-20 17:11:53 +03:00
Ilya Zverev
9967d94a80 Allow short form for mwmtool id 2018-06-20 17:09:49 +03:00
Ilya Zverev
0dbf9c6442 Support parsing and making negative ids 2018-06-19 11:27:54 +03:00
Ilya Zverev
6dc6b49d02 Extend OsmIdCode from object 2018-06-18 19:42:58 +03:00
Ilya Zverev
35a262b477 Support python 2.6 still 2018-06-18 19:21:28 +03:00
Ilya Zverev
87bffa173c Remove shebang from mwmtool 2018-06-18 19:19:53 +03:00
5 changed files with 20 additions and 8 deletions

View file

@ -2,6 +2,14 @@
## master branch
## 0.10.1
_Released 2018-06-20_
* Better support for Python 2.7.
* Encoding and decoding int64 negative ids.
* Allow short form for id: `mwmtool id way/123456`.
## 0.10.0
_Released 2018-06-18_

View file

@ -1,3 +1,5 @@
from .mwmfile import MWMFile, OsmIdCode
from .mwm import MWM, __version__
from .mwm import MWM
from .osm2ft import Osm2Ft
__version__ = '0.10.1'

View file

@ -3,8 +3,6 @@ from .mwmfile import MWMFile
from datetime import datetime
import os
__version__ = '0.10.0'
# Unprocessed sections: geomN, trgN, idx, sdx (search index),
# addr (search address), offs (feature offsets - succinct)

View file

@ -3,7 +3,7 @@ import struct
import math
class OsmIdCode:
class OsmIdCode(object):
NODE = 0x4000000000000000
WAY = 0x8000000000000000
RELATION = 0xC000000000000000
@ -37,6 +37,8 @@ class OsmIdCode:
@staticmethod
def unpack(num):
if num < 0:
num = (-1 - num) ^ (2**64 - 1)
typ = OsmIdCode.get_type(num)
if typ is None:
return None

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
from __future__ import print_function
import sys
import random
import json
@ -106,7 +106,7 @@ def ft2osm(args):
def decode_id(args):
if args.id.isdigit():
if args.id.isdigit() or args.id.startswith('-'):
osm_id = OsmIdCode.unpack(int(args.id))
if osm_id is None:
print('That is not a valid identifier')
@ -116,9 +116,9 @@ def decode_id(args):
print('https://www.openstreetmap.org/{}/{}'.format(
type_abbr[osm_id[0]], osm_id[1]))
else:
m = re.search(r'/(node|way|relation)/(\d+)', args.id)
m = re.search(r'(node|way|relation)/(\d+)', args.id)
if m:
print(OsmIdCode.pack(m.group(1), int(m.group(2))))
print(OsmIdCode.pack(m.group(1), int(m.group(2)), args.int64))
else:
print('Please specify an URL to OSM object on its website')
return 2
@ -170,6 +170,8 @@ def main():
parser_id = subparsers.add_parser('id', help='Decode or encode OSM ID')
parser_id.add_argument('id', help='MWM internal OSM ID, or a link to OSM website')
parser_id.add_argument('-i', '--int64', action='store_true',
help='Use int64 instead of uint64')
parser_id.set_defaults(func=decode_id)
parser_dump = subparsers.add_parser('gpx', help='Convert gps_track.dat to GPX')