Added --boundary config, boundary module (WIP)

pull/1355/head
Piero Toffanin 2021-10-11 16:19:53 -04:00
rodzic 4dadb53a49
commit 8791b74b73
2 zmienionych plików z 32 dodań i 0 usunięć

22
opendm/boundary.py 100644
Wyświetl plik

@ -0,0 +1,22 @@
import fiona
import os
def load_boundary(boundary_json, reproject_to_crs=None):
if not os.path.isfile(boundary_json):
raise IOError("Cannot load boundary file: %s does not exist" % boundary_json)
with fiona.open(boundary_json, 'r') as src:
if len(src) != 1:
raise IOError("Boundary file must have a single polygon (found: %s)" % len(src))
geom = src[0]['geometry']
if geom['type'] != 'Polygon':
raise IOError("Boundary file must have a polygon feature (found: %s)" % geom['type'])
coords = geom['coordinates']
if reproject_to_crs is not None:
pass
return coords

Wyświetl plik

@ -303,6 +303,16 @@ def config(argv=None, parser=None):
'Use 0 to disable cropping. '
'Default: %(default)s'))
parser.add_argument('--boundary',
default='',
metavar='<json>',
action=StoreValue,
type=path_or_json_string,
help='GeoJSON polygon defining the boundary of the reconstruction. '
'Can be specified either as path to a GeoJSON file or as a '
'JSON string representing the contents of a '
'GeoJSON file. Default: %(default)s')
parser.add_argument('--pc-quality',
metavar='<string>',
action=StoreValue,