|
@@ -132,28 +132,28 @@ def main():
|
|
|
include_header = flags['c']
|
|
|
|
|
|
# check for cs2cs
|
|
|
- if not grass.find_program('cs2cs'):
|
|
|
- grass.fatal(_(
|
|
|
+ if not gcore.find_program('cs2cs'):
|
|
|
+ gcore.fatal(_(
|
|
|
"cs2cs program not found, install PROJ.4 first: \
|
|
|
http://proj.maptools.org"))
|
|
|
|
|
|
# check for overenthusiasm
|
|
|
if proj_in and ll_in:
|
|
|
- grass.fatal(_("Choose only one input parameter method"))
|
|
|
+ gcore.fatal(_("Choose only one input parameter method"))
|
|
|
|
|
|
if proj_out and ll_out:
|
|
|
- grass.fatal(_("Choose only one output parameter method"))
|
|
|
+ gcore.fatal(_("Choose only one output parameter method"))
|
|
|
|
|
|
if ll_in and ll_out:
|
|
|
- grass.fatal(_("Choise only one auto-projection parameter method"))
|
|
|
+ gcore.fatal(_("Choise only one auto-projection parameter method"))
|
|
|
|
|
|
- if output and not grass.overwrite() and os.path.exists(output):
|
|
|
- grass.fatal(_("Output file already exists"))
|
|
|
+ if output and not gcore.overwrite() and os.path.exists(output):
|
|
|
+ gcore.fatal(_("Output file already exists"))
|
|
|
|
|
|
if not coords and not input:
|
|
|
gcore.fatal(_("One of <coordinates> and <input> must be given"))
|
|
|
if coords and input:
|
|
|
- grass.fatal(_(
|
|
|
+ gcore.fatal(_(
|
|
|
"Options <coordinates> and <input> are mutually exclusive"))
|
|
|
|
|
|
# parse field separator
|
|
@@ -170,30 +170,30 @@ def main():
|
|
|
ofs = separator(ofs)
|
|
|
|
|
|
# set up projection params
|
|
|
- s = grass.read_command("g.proj", flags='j')
|
|
|
+ s = gcore.read_command("g.proj", flags='j')
|
|
|
kv = parse_key_val(s)
|
|
|
if "XY location" in kv['+proj'] and (ll_in or ll_out):
|
|
|
- grass.fatal(_("Unable to project to or from a XY location"))
|
|
|
+ gcore.fatal(_("Unable to project to or from a XY location"))
|
|
|
|
|
|
in_proj = None
|
|
|
|
|
|
if ll_in:
|
|
|
in_proj = "+proj=longlat +datum=WGS84"
|
|
|
- grass.verbose(
|
|
|
+ gcore.verbose(
|
|
|
"Assuming LL WGS84 as input, current projection as output ")
|
|
|
|
|
|
if ll_out:
|
|
|
- in_proj = grass.read_command('g.proj', flags='jf')
|
|
|
+ in_proj = gcore.read_command('g.proj', flags='jf')
|
|
|
|
|
|
if proj_in:
|
|
|
if '+' in proj_in:
|
|
|
in_proj = proj_in
|
|
|
else:
|
|
|
- grass.fatal(_("Invalid PROJ.4 input specification"))
|
|
|
+ gcore.fatal(_("Invalid PROJ.4 input specification"))
|
|
|
|
|
|
if not in_proj:
|
|
|
- grass.verbose("Assuming current location as input")
|
|
|
- in_proj = grass.read_command('g.proj', flags='jf')
|
|
|
+ gcore.verbose("Assuming current location as input")
|
|
|
+ in_proj = gcore.read_command('g.proj', flags='jf')
|
|
|
|
|
|
in_proj = in_proj.strip()
|
|
|
gcore.verbose("Input parameters: '%s'" % in_proj)
|
|
@@ -202,20 +202,20 @@ def main():
|
|
|
|
|
|
if ll_out:
|
|
|
out_proj = "+proj=longlat +datum=WGS84"
|
|
|
- grass.verbose(
|
|
|
+ gcore.verbose(
|
|
|
"Assuming current projection as input, LL WGS84 as output ")
|
|
|
|
|
|
if ll_in:
|
|
|
- out_proj = grass.read_command('g.proj', flags='jf')
|
|
|
+ out_proj = gcore.read_command('g.proj', flags='jf')
|
|
|
|
|
|
if proj_out:
|
|
|
if '+' in proj_out:
|
|
|
out_proj = proj_out
|
|
|
else:
|
|
|
- grass.fatal(_("Invalid PROJ.4 output specification"))
|
|
|
+ gcore.fatal(_("Invalid PROJ.4 output specification"))
|
|
|
|
|
|
if not out_proj:
|
|
|
- grass.fatal(_("Missing output projection parameters "))
|
|
|
+ gcore.fatal(_("Missing output projection parameters "))
|
|
|
out_proj = out_proj.strip()
|
|
|
gcore.verbose("Output parameters: '%s'" % out_proj)
|
|
|
|
|
@@ -236,7 +236,7 @@ def main():
|
|
|
if not os.path.exists(infile):
|
|
|
gcore.fatal(_("Unable to read input data"))
|
|
|
inf = file(infile)
|
|
|
- grass.debug("input file=[%s]" % infile)
|
|
|
+ gcore.debug("input file=[%s]" % infile)
|
|
|
|
|
|
# set up output file
|
|
|
if not output:
|
|
@@ -245,7 +245,7 @@ def main():
|
|
|
else:
|
|
|
outfile = output
|
|
|
outf = open(outfile, 'w')
|
|
|
- grass.debug("output file=[%s]" % outfile)
|
|
|
+ gcore.debug("output file=[%s]" % outfile)
|
|
|
|
|
|
# set up output style
|
|
|
if not decimal:
|
|
@@ -264,7 +264,7 @@ def main():
|
|
|
cmd = ['cs2cs'] + copyinp + outfmt + \
|
|
|
in_proj.split() + ['+to'] + out_proj.split()
|
|
|
|
|
|
- p = grass.Popen(cmd, stdin=grass.PIPE, stdout=grass.PIPE)
|
|
|
+ p = gcore.Popen(cmd, stdin=gcore.PIPE, stdout=gcore.PIPE)
|
|
|
|
|
|
tr = TrThread(ifs, inf, p.stdin)
|
|
|
tr.start()
|
|
@@ -277,7 +277,7 @@ def main():
|
|
|
xy, z = line.split(' ', 1)
|
|
|
x, y = xy.split('\t')
|
|
|
except ValueError:
|
|
|
- grass.fatal(line)
|
|
|
+ gcore.fatal(line)
|
|
|
|
|
|
outf.write('%s%s%s%s%s\n' %
|
|
|
(x.strip(), ofs, y.strip(), ofs, z.strip()))
|
|
@@ -295,7 +295,7 @@ def main():
|
|
|
p.wait()
|
|
|
|
|
|
if p.returncode != 0:
|
|
|
- grass.warning(_(
|
|
|
+ gcore.warning(_(
|
|
|
"Projection transform probably failed, please investigate"))
|
|
|
|
|
|
if __name__ == "__main__":
|