case(gmt_projection::XY):// x Parameter height (by default equal width)
{
BaseM2Nonnegheight(input,"height","h");
if(height.Exist())
{
boolsuc=true;
p.x.height=height(&suc);
if(!suc)gotofail;// Parsing error
}
else
{
BaseM2Nonnegwidth(input,"width","w");
if(!width.Exist()&&changetype)p.x.height=gmt_projection::default_width;// We ignore case when parameter width exists but have wrong type. It will be handled later.
else
{
boolsuc=true;
p.x.height=width(&suc);
if(!suc)gotofail;// Parsing error
}
}
// Width is processing later
if(height.Exist())p.x.height=height;
elseif(changetype)p.x.height=width;// By default, height equal width
break;
}
case(gmt_projection::CYL_EQU):// q Parameters: central meridian (cmer, default is center of region), standart parallel (stpar, default is center of region)
{ParseNamedParametersapar(input,cmer,stpar);if(!apar){err=apar.Error();gotofail;}}// Fail to parse additional parameters
if(cmer.Exist()||changetype)p.q.cmer=cmer;
if(stpar.Exist()||changetype)p.q.stpar=stpar;
break;
}
case(gmt_projection::MERCATOR):// m Parameters: central meridian (cmer, default is center of region), standart parallel (stpar, default is center of region)
{ParseNamedParametersapar(input,cmer,stpar);if(!apar){err=apar.Error();gotofail;}}// Fail to parse additional parameters
if(cmer.Exist()||changetype)p.m.cmer=cmer;
if(stpar.Exist()||changetype)p.m.stpar=stpar;
break;
}
case(gmt_projection::TRANSMERCATOR):// t Parameters: central meridian (cmer, default is center of region), latitude of origin (orlat, default is 0.0), scale factor (scale, default is 1.0)
{ParseNamedParametersapar(input,cmer,scale,orlat);if(!apar){err=apar.Error();gotofail;}}// Fail to parse additional parameters
if(cmer.Exist()||changetype)p.t.cmer=cmer;
if(orlat.Exist()||changetype)p.t.orlat=orlat;
if(scale.Exist()||changetype)p.t.scale=scale;
break;
}
case(gmt_projection::OBLIQMERCATOR):// o Parameters: longitude of projection center (clon, default is center of region), latitude of projection center (clat, default is center of region). Other parameters may form one of three combinations and doesn't have default values. 1) Azimuth of the oblique equator (azimuth). 2) Longitude and latitude of second point on oblique equator (eqlon, eqlat). 3) Longitude and latitude of projection pole (polelon, polelat).
err="Conflict in parameters for oblique Mercator projection, must specify only one variant: 1) azimuth of oblique equator, or 2) longitude and latitude of point on oblique equator, or 3) longitude and latitude of projection pole";
boolsuc=(gmt_projection::OType::NOTDEF==p.o.type);// If projection subtype already defined, this is an error
p.o.type=gmt_projection::OType::A;
p.o.azimuth=azimuth(&suc);
if(!suc)gotofail;// Parsing error
p.o.azimuth=azimuth;
}
if(eqlon&&eqlat)
// Variant 2
if(eqlon.Exist()&&eqlat.Exist())
{
boolsuc=(gmt_projection::OType::NOTDEF==p.o.type);// If projection subtype already defined, this is an error
p.o.type=gmt_projection::OType::B;
p.o.eqlon=eqlon(&suc);
p.o.eqlat=eqlat(&suc);
if(!suc)gotofail;// Parsing error
p.o.eqlon=eqlon;
p.o.eqlat=eqlat;
}
if(polelon&&polelat)
// Variant 3
if(polelon.Exist()&&polelat.Exist())
{
boolsuc=(gmt_projection::OType::NOTDEF==p.o.type);// If projection subtype already defined, this is an error
p.o.type=gmt_projection::OType::C;
p.o.polelon=polelon(&suc);
p.o.polelat=polelat(&suc);
if(!suc)gotofail;// Parsing error
}
if(gmt_projection::OType::NOTDEF==p.o.type)gotofail;// Insufficient data for this projection
break;
p.o.polelon=polelon;
p.o.polelat=polelat;
}
case(gmt_projection::CASSINI):// c Parameters: longitude (clon, default is center of region) and latitude (clat, default is center of region) of central point.
// Special processing of update case
if(!changetype)
{
Base2Coordclon(input,"clon"),clat(input,"clat");
if(clon.Exist())
if(eqlon.Exist()&&!eqlat.Exist())
{
boolsuc=true;
p.c.clon=clon(&suc);
if(!suc)gotofail;// Parsing error
if(gmt_projection::OType::B!=p.o.type){err="Insufficient parameters for oblique Mercator projection, must specify latitude of point on oblique equator";gotofail;}
if(gmt_projection::OType::B!=p.o.type){err="Insufficient parameters for oblique Mercator projection, must specify longitude of point on oblique equator";gotofail;}
elsep.o.eqlat=eqlat;
}
case(gmt_projection::CYL_EQA):// y Parameters: central meridian (cmer, default is center of region), standart parallel (stpar, default is center of region)
if(gmt_projection::OType::C!=p.o.type){err="Insufficient parameters for oblique Mercator projection, must specify latitude of projection pole";gotofail;}
if(gmt_projection::OType::C!=p.o.type){err="Insufficient parameters for oblique Mercator projection, must specify longitude of projection pole";gotofail;}
case(gmt_projection::MILLER):// j Parameters: central meridian (cmer, default is center of region)
if(gmt_projection::OType::NOTDEF==p.o.type)
{
Base2Coordcmer(input,"cmer");
if(cmer.Exist())
{
boolsuc=true;
p.j.cmer=cmer(&suc);
if(!suc)gotofail;// Parsing error
err="Insufficient parameters for oblique Mercator projection, must specify azimuth of oblique equator, or longitude and latitude of point on oblique equator, or longitude and latitude of projection pole";
case(gmt_projection::CYL_STERE):// cyl_stere Parameters: central meridian (cmer, default is center of region), standart parallel (stpar, default is center of region)
case(gmt_projection::CASSINI):// c Parameters: longitude (clon, default is center of region) and latitude (clat, default is center of region) of central point.
{ParseNamedParametersapar(input,clon,clat);if(!apar){err=apar.Error();gotofail;}}// Fail to parse additional parameters
if(clon.Exist()||changetype)p.c.clon=clon;
if(clat.Exist()||changetype)p.c.clat=clat;
break;
}
case(gmt_projection::CYL_EQA):// y Parameters: central meridian (cmer, default is center of region), standart parallel (stpar, default is center of region)
{
boolsuc=true;
p.cyl_stere.cmer=cmer(&suc);
if(!suc)gotofail;// Parsing error
{ParseNamedParametersapar(input,cmer,stpar);if(!apar){err=apar.Error();gotofail;}}// Fail to parse additional parameters
case(gmt_projection::CYL_STERE):// cyl_stere Parameters: central meridian (cmer, default is center of region), standart parallel (stpar, default is center of region)
{
{ParseNamedParametersapar(input,cmer,stpar);if(!apar){err=apar.Error();gotofail;}}// Fail to parse additional parameters
else// No width, no height, using default or old width
if(!ProjectionRealSize(p))gotofail;// Something go wrong with determining real dimensions
if(!ProjectionRealSize(p))gotofailrealsize;// Something go wrong with determining real dimensions
}
returnp;// All parameters setted
failrealsize:
err="Can't determine real size of projection "+p.Value();
gotofail;
}
case4:
// Case 4
if(size>=3)
{
// First argument, try to set type of projection
{
Base2Stringtype(input,0);
boolsuc=true;
std::stringtypestr;
typestr=type(&suc);
if(!suc)gotofail;// No type - no projection
if(!p.SetType(typestr))gotofail;// Unknown type - no projection
}
// Second argument, set up width
{
Base2Doublew(input,1);
boolsuc=true;
p.width=w(&suc);
if(!suc)gotofail;// Conversion failed, no width
}
// Third argument, set up region
{
Base2Regionreg(input,2);
boolsuc=true;
p.region=reg(&suc);
if(!suc)gotofail;// Conversion failed, no region
}
RPosPar<Base2String>type("projection type");
RPosPar<Base2NonNeg>width("width");
RPosPar<Base2Region>region("region");
{ParsePositionalParametersparams(input,0,3,type,width,region);if(!params){err=params.Error();gotofail;}}// Fail to parse by variant 4
if(!p.SetType(type,err))gotofail;// Incorrect projection type
p.width=width;
p.region=region;
// Projection specific parameters
switch(p.proj)
{
case(gmt_projection::XY):// x Parameter 4 is height (by default equal width)
{
Base2Doubleheight(input,3);
if(height.Exist())
{
boolsuc=true;
p.x.height=height(&suc);
if(!suc)gotofail;// Parsing error
}
elsep.x.height=p.width;
if(size>4)gotofail;// Unknown parameter(s)
OPosPar<Base2NonNegD>height("height",p.width);
{ParsePositionalParametersparams(input,3,input->Size(),height);if(!params){err=params.Error();gotofail;}}// Fail to parse additional parameters
p.x.height=height;
break;
}
case(gmt_projection::CYL_EQU):// q Parameters: 4 is central meridian (default is center of region), 5 is standart parallel (default is center of region)
{ParsePositionalParametersparams(input,3,input->Size(),cmer,stpar);if(!params){err=params.Error();gotofail;}}// Fail to parse additional parameters
p.q.cmer=cmer;p.q.stpar=stpar;
break;
}
case(gmt_projection::MERCATOR):// m Parameters: 4 is central meridian (default is center of region), 5 is standart parallel (default is center of region)
{ParsePositionalParametersparams(input,3,input->Size(),cmer,stpar);if(!params){err=params.Error();gotofail;}}// Fail to parse additional parameters
p.m.cmer=cmer;p.m.stpar=stpar;
break;
}
case(gmt_projection::TRANSMERCATOR):// t Parameters: 4 is central meridian (default is center of region), 5 is latitude of origin (default is 0.0), 6 is scale factor (default is 1.0)
OPosPar<Base2CoordD>orlat("latitude of origin",0.0);
OPosPar<Base2NonNegD>scale("scale",1.0);
{ParsePositionalParametersparams(input,3,input->Size(),cmer,orlat,scale);if(!params){err=params.Error();gotofail;}}// Fail to parse additional parameters
p.t.cmer=cmer;p.t.orlat=orlat;p.t.scale=scale;
break;
}
case(gmt_projection::OBLIQMERCATOR):// o There is no default values for this projection. Parameters: 4 is subtype ("a" or "azimuth", "b" or "equator", "c" or "pole"), 5 is longitude of projection center, 6 is latitude of projection center. Other parameters may form one of three combinations. 1) 7 is azimuth of the oblique equator. 2) Longitude and latitude of second point on oblique equator (7, 8). 3) Longitude and latitude of projection pole (7, 8).
{
if(size<4)gotofail;// Insufficient data for this projection
{ParsePositionalParametersparams(input,6,input->Size(),azimuth);if(!params){err=params.Error();gotofail;}}// Fail to parse additional parameters
p.o.type=gmt_projection::OType::A;
boolsuc=true;
p.o.azimuth=azimuth(&suc);
if(!suc)gotofail;// Parsing error
if(size>7)gotofail;// Unknown parameter(s)
p.o.azimuth=azimuth;
}
if("b"==subtype||"equator"==subtype)
if(b.Compare(stype))
{
RPosPar<Base2Coord>eqlon("longitude of equator");
RPosPar<Base2Coord>eqlat("latitude of equator");
{ParsePositionalParametersparams(input,6,input->Size(),eqlon,eqlat);if(!params){err=params.Error();gotofail;}}// Fail to parse additional parameters
p.o.type=gmt_projection::OType::B;
boolsuc=true;
p.o.eqlon=eqlon(&suc);
p.o.eqlat=eqlat(&suc);
if(!suc)gotofail;// Parsing error
if(size>8)gotofail;// Unknown parameter(s)
p.o.eqlon=eqlon;
p.o.eqlat=eqlat;
}
if("c"==subtype||"pole"==subtype)
if(c.Compare(stype))
{
RPosPar<Base2Coord>polelon("longitude of pole");
RPosPar<Base2Coord>polelat("latitude of pole");
{ParsePositionalParametersparams(input,6,input->Size(),polelon,polelat);if(!params){err=params.Error();gotofail;}}// Fail to parse additional parameters
p.o.type=gmt_projection::OType::C;
boolsuc=true;
p.o.polelon=polelon(&suc);
p.o.polelat=polelat(&suc);
if(!suc)gotofail;// Parsing error
if(size>8)gotofail;// Unknown parameter(s)
p.o.polelon=polelon;
p.o.polelat=polelat;
}
if(gmt_projection::OType::NOTDEF==p.o.type)gotofail;// Insufficient data for this projection
if(gmt_projection::OType::NOTDEF==p.o.type){err="String "+pstype.Value()+" is invalid subtype for oblique Mercator projection. The valid subtypes are azimuth, equator or pole";gotofail;}
break;
}
case(gmt_projection::CASSINI):// c Parameters: longitude (4, default is center of region) and latitude (5, default is center of region) of central point.
{ParsePositionalParametersparams(input,3,input->Size(),cmer);if(!params){err=params.Error();gotofail;}}// Fail to parse additional parameters
p.j.cmer=cmer;
break;
}
case(gmt_projection::CYL_STERE):// cyl_stere Parameters: central meridian (3, default is center of region), standart parallel (4, default is center of region)