[pktools] 150/375: replaced empty string with empty vector in options
Bas Couwenberg
sebastic at xs4all.nl
Wed Dec 3 21:54:09 UTC 2014
This is an automated email from the git hooks/post-receive script.
sebastic-guest pushed a commit to branch upstream-master
in repository pktools.
commit b36345911bcc1c9796a97d4787ef61ad4ce4ac9b
Author: Pieter Kempeneers <kempenep at gmail.com>
Date: Sat Dec 7 12:43:12 2013 +0100
replaced empty string with empty vector in options
---
src/apps/pkcrop.cc | 11 +++++++----
src/apps/pkmosaic.cc | 11 +++++++----
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/apps/pkcrop.cc b/src/apps/pkcrop.cc
index 8d4ff0f..d6d82ef 100644
--- a/src/apps/pkcrop.cc
+++ b/src/apps/pkcrop.cc
@@ -32,7 +32,7 @@ int main(int argc, char *argv[])
{
Optionpk<string> input_opt("i", "input", "Input image file(s). If input contains multiple images, a multi-band output is created");
Optionpk<string> output_opt("o", "output", "Output image file");
- Optionpk<string> projection_opt("a_srs", "a_srs", "Override the projection for the output file (leave blank to copy from input file, use epsg:3035 to use European projection and force to European grid", "");
+ Optionpk<string> projection_opt("a_srs", "a_srs", "Override the projection for the output file (leave blank to copy from input file, use epsg:3035 to use European projection and force to European grid");
Optionpk<string> extent_opt("e", "extent", "get boundary from extent from polygons in vector file");
Optionpk<bool> mask_opt("m","mask","mask values out of polygon in extent file to flag option (tip: for better performance, use gdal_rasterize -i -burn 0 -l extent extent.shp output (with output the result of pkcrop)",false);
Optionpk<double> ulx_opt("ulx", "ulx", "Upper left x value bounding box (in geocoordinates if georef is true)", 0.0);
@@ -253,6 +253,9 @@ int main(int argc, char *argv[])
if(verbose_opt[0])
cout << "size of " << input_opt[iimg] << ": " << ncol << " cols, "<< nrow << " rows" << endl;
double uli,ulj,lri,lrj;//image coordinates
+ bool forceEUgrid=false;
+ if(projection_opt.size())
+ forceEUgrid=(!(projection_opt[0].compare("EPSG:3035"))||!(projection_opt[0].compare("EPSG:3035"))||projection_opt[0].find("ETRS-LAEA")!=string::npos);
if(ulx_opt[0]>=lrx_opt[0]){//default bounding box: no cropping
uli=0;
lri=imgReader.nrOfCol()-1;
@@ -263,7 +266,7 @@ int main(int argc, char *argv[])
imgReader.getBoundingBox(cropulx,cropuly,croplrx,croplry);
double magicX=1,magicY=1;
// imgReader.getMagicPixel(magicX,magicY);
- if(!imgReader.getProjection().compare("ETRS-LAEA")||!projection_opt[0].compare("EPSG:3035")||!projection_opt[0].compare("epsg:3035")){
+ if(forceEUgrid){
//force to LAEA grid
Egcs egcs;
egcs.setLevel(egcs.res2level(dx));
@@ -283,7 +286,7 @@ int main(int argc, char *argv[])
cropuly=uly_opt[0];
croplrx=lrx_opt[0];
croplry=lry_opt[0];
- if(!imgReader.getProjection().compare("ETRS-LAEA")||!projection_opt[0].compare("EPSG:3035")||!projection_opt[0].compare("epsg:3035")){
+ if(forceEUgrid){
//force to LAEA grid
Egcs egcs;
egcs.setLevel(egcs.res2level(dx));
@@ -349,7 +352,7 @@ int main(int argc, char *argv[])
if(description_opt.size())
imgWriter.setImageDescription(description_opt[0]);
imgWriter.setGeoTransform(cropulx,cropuly,dx,dy,0,0);
- if(projection_opt[0]!=""){
+ if(projection_opt.size()){
if(verbose_opt[0])
cout << "projection: " << projection_opt[0] << endl;
imgWriter.setProjectionProj4(projection_opt[0]);
diff --git a/src/apps/pkmosaic.cc b/src/apps/pkmosaic.cc
index 0c9d3d7..8504ae4 100644
--- a/src/apps/pkmosaic.cc
+++ b/src/apps/pkmosaic.cc
@@ -38,7 +38,7 @@ int main(int argc, char *argv[])
{
Optionpk<string> input_opt("i", "input", "Input image file(s). If input contains multiple images, a multi-band output is created", "");
Optionpk<string> output_opt("o", "output", "Output image file", "");
- Optionpk<string> projection_opt("a_srs", "a_srs", "Override the projection for the output file (leave blank to copy from input file, use epsg:3035 to use European projection and force to European grid", "");
+ Optionpk<string> projection_opt("a_srs", "a_srs", "Override the projection for the output file (leave blank to copy from input file, use epsg:3035 to use European projection and force to European grid");
Optionpk<string> extent_opt("e", "extent", "get boundary from extent from polygons in vector file", "");
Optionpk<double> ulx_opt("ulx", "ulx", "Upper left x value bounding box (in geocoordinates if georef is true)", 0.0);
Optionpk<double> uly_opt("uly", "uly", "Upper left y value bounding box (in geocoordinates if georef is true)", 0.0);
@@ -199,7 +199,7 @@ int main(int argc, char *argv[])
if(colorTable_opt[0]=="")
if(imgReader.getColorTable())
theColorTable=(imgReader.getColorTable()->Clone());
- if(projection_opt[0]=="")
+ if(projection_opt.empty())
theProjection=imgReader.getProjection();
if(option_opt.findSubstring("INTERLEAVE=")==option_opt.end()){
string theInterleave="INTERLEAVE=";
@@ -327,7 +327,10 @@ int main(int argc, char *argv[])
minLRY=lry_opt[0];
}
- if(projection_opt[0].find("ETRS-LAEA")!=string::npos||projection_opt[0].find("EPSG:3035")!=string::npos||projection_opt[0].find("epsg:3035")!=string::npos){
+ bool forceEUgrid=false;
+ if(projection_opt.size())
+ forceEUgrid=(!(projection_opt[0].compare("EPSG:3035"))||!(projection_opt[0].compare("EPSG:3035"))||projection_opt[0].find("ETRS-LAEA")!=string::npos);
+ if(forceEUgrid){
//force to LAEA grid
minULX=floor(minULX);
minULX-=static_cast<int>(minULX)%(static_cast<int>(dx));
@@ -380,7 +383,7 @@ int main(int argc, char *argv[])
if(description_opt.size())
imgWriter.setImageDescription(description_opt[0]);
imgWriter.setGeoTransform(minULX,maxULY,dx,dy,0,0);
- if(projection_opt[0]!=""){
+ if(projection_opt.size()){
if(verbose_opt[0])
cout << "projection: " << projection_opt[0] << endl;
imgWriter.setProjectionProj4(projection_opt[0]);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/pktools.git
More information about the Pkg-grass-devel
mailing list