| 13 | |
| 14 | |
| 15 | class Mwm: |
| 16 | def __init__(self): |
| 17 | parser = argparse.ArgumentParser( |
| 18 | description="Mwm utils", |
| 19 | usage="""mwm <command> [<args>] |
| 20 | The most commonly used mwm commands are: |
| 21 | decode_id Unpacks maps.me OSM id to an OSM object link. |
| 22 | dump_mwm Dumps some MWM structures. |
| 23 | find_feature Finds features in an mwm file based on a query. |
| 24 | ft2osm Finds an OSM object for a given feature id. |
| 25 | mwm_feature_compare Compares feature count in .mwm files. |
| 26 | """, |
| 27 | ) |
| 28 | parser.add_argument("command", help="Subcommand to run") |
| 29 | args = parser.parse_args(sys.argv[1:2]) |
| 30 | if not hasattr(self, args.command): |
| 31 | print(f"Unrecognized command {args.command}") |
| 32 | parser.print_help() |
| 33 | exit(1) |
| 34 | getattr(self, args.command)() |
| 35 | |
| 36 | @staticmethod |
| 37 | def decode_id(): |
| 38 | parser = argparse.ArgumentParser( |
| 39 | description="Unpacks maps.me OSM id to an OSM object link." |
| 40 | ) |
| 41 | parser.add_argument( |
| 42 | "--id", type=str, required=True, help="OsmId or url from osm.org." |
| 43 | ) |
| 44 | args = parser.parse_args(sys.argv[2:]) |
| 45 | id = decode_id(args.id) |
| 46 | if id is None: |
| 47 | print("Decode id error.") |
| 48 | exit(1) |
| 49 | print(id) |
| 50 | |
| 51 | @staticmethod |
| 52 | def dump_mwm(): |
| 53 | parser = argparse.ArgumentParser(description="Dumps some MWM structures.") |
| 54 | parser.add_argument("--path", type=str, required=True, help="Path to mwm.") |
| 55 | parser.add_argument( |
| 56 | "--format", |
| 57 | type=str, |
| 58 | default="str", |
| 59 | choices=("str", "json"), |
| 60 | help="Output format.", |
| 61 | ) |
| 62 | parser.add_argument( |
| 63 | "--need_features", action="store_true", help="Need to dump features." |
| 64 | ) |
| 65 | args = parser.parse_args(sys.argv[2:]) |
| 66 | dump_mwm(args.path, args.format, args.need_features) |
| 67 | |
| 68 | @staticmethod |
| 69 | def find_feature(): |
| 70 | parser = argparse.ArgumentParser( |
| 71 | description="Finds features in an mwm file based on a query." |
| 72 | ) |
no outgoing calls
no test coverage detected