|
@@ -67,6 +67,21 @@
|
|
|
#% answer: 1e-13
|
|
|
#% guisection: Output
|
|
|
#%end
|
|
|
+#%option
|
|
|
+#% key: epsg
|
|
|
+#% type: integer
|
|
|
+#% options: 1-1000000
|
|
|
+#% guisection: Input SRS
|
|
|
+#% description: EPSG projection code
|
|
|
+#%end
|
|
|
+#%option
|
|
|
+#% key: datum_trans
|
|
|
+#% type: integer
|
|
|
+#% options: -1-100
|
|
|
+#% guisection: Input SRS
|
|
|
+#% label: Index number of datum transform parameters
|
|
|
+#% description: -1 to list available datum transform parameters
|
|
|
+#%end
|
|
|
#%flag
|
|
|
#% key: f
|
|
|
#% description: List supported OGR formats and exit
|
|
@@ -126,6 +141,14 @@ def main():
|
|
|
if options['encoding']:
|
|
|
vopts['encoding'] = options['encoding']
|
|
|
|
|
|
+ if options['datum_trans'] and options['datum_trans'] == '-1':
|
|
|
+ # list datum transform parameters
|
|
|
+ if not options['epsg']:
|
|
|
+ grass.fatal(_("Missing value for parameter <%s>") % 'epsg')
|
|
|
+
|
|
|
+ return grass.run_command('g.proj', epsg=options['epsg'],
|
|
|
+ datum_trans=options['datum_trans'])
|
|
|
+
|
|
|
grassenv = grass.gisenv()
|
|
|
tgtloc = grassenv['LOCATION_NAME']
|
|
|
tgtmapset = grassenv['MAPSET']
|
|
@@ -160,6 +183,12 @@ def main():
|
|
|
# switch to temp location
|
|
|
os.environ['GISRC'] = str(SRCGISRC)
|
|
|
|
|
|
+ if options['epsg']: # force given EPSG
|
|
|
+ kwargs = {}
|
|
|
+ if options['datum_trans']:
|
|
|
+ kwargs['datum_trans'] = options['datum_trans']
|
|
|
+ grass.run_command('g.proj', flags='c', epsg=options['epsg'], **kwargs)
|
|
|
+
|
|
|
# switch to target location
|
|
|
os.environ['GISRC'] = str(tgtgisrc)
|
|
|
|
|
@@ -181,6 +210,9 @@ def main():
|
|
|
# switch to temp location
|
|
|
os.environ['GISRC'] = str(SRCGISRC)
|
|
|
|
|
|
+ # print projection at verbose level
|
|
|
+ grass.verbose(grass.read_command('g.proj', flags='p').rstrip(os.linesep))
|
|
|
+
|
|
|
# make sure input is not xy
|
|
|
if grass.parse_command('g.proj', flags='g')['name'] == 'xy_location_unprojected':
|
|
|
grass.fatal(_("Coordinate reference system not available for input <%s>") % OGRdatasource)
|