case(gmt_projection::XY):// x Parameter height (by default equal width)
case(gmt_projection::XY):// x Parameter height (by default equal width)
{
{
BaseM2Nonnegheight(input,"height","h");
// Width is processing later
if(height.Exist())
if(height.Exist())p.x.height=height;
{
elseif(changetype)p.x.height=width;// By default, height equal width
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
}
}
break;
break;
}
}
case(gmt_projection::CYL_EQU):// q Parameters: central meridian (cmer, default is center of region), standart parallel (stpar, default is center of region)
case(gmt_projection::CYL_EQU):// q Parameters: central meridian (cmer, default is center of region), standart parallel (stpar, default is center of region)
case(gmt_projection::MERCATOR):// m Parameters: central meridian (cmer, default is center of region), standart parallel (stpar, default is center of region)
case(gmt_projection::MERCATOR):// m Parameters: central meridian (cmer, default is center of region), standart parallel (stpar, default is center of region)
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)
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)
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).
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.type=gmt_projection::OType::A;
p.o.azimuth=azimuth(&suc);
p.o.azimuth=azimuth;
if(!suc)gotofail;// Parsing error
}
}
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.type=gmt_projection::OType::B;
p.o.eqlon=eqlon(&suc);
p.o.eqlon=eqlon;
p.o.eqlat=eqlat(&suc);
p.o.eqlat=eqlat;
if(!suc)gotofail;// Parsing error
}
}
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.type=gmt_projection::OType::C;
p.o.polelon=polelon(&suc);
p.o.polelon=polelon;
p.o.polelat=polelat(&suc);
p.o.polelat=polelat;
if(!suc)gotofail;// Parsing error
}
if(gmt_projection::OType::NOTDEF==p.o.type)gotofail;// Insufficient data for this projection
break;
}
}
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(eqlon.Exist()&&!eqlat.Exist())
if(clon.Exist())
{
{
boolsuc=true;
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;}
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");
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(cmer.Exist())
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;
{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
if(gmt_projection::XY==p.proj)p.width=hval;// For decart projection we use height as width if width is not specified
if(!ProjectionRealSize(p,hval))gotofail;// Something go wrong with determining real dimensions
}
}
else// No width, no height, using default or old width
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
returnp;// All parameters setted
failrealsize:
err="Can't determine real size of projection "+p.Value();
gotofail;
}
}
case4:
case4:
// Case 4
// 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);
RPosPar<Base2String>type("projection type");
boolsuc=true;
RPosPar<Base2NonNeg>width("width");
p.region=reg(&suc);
RPosPar<Base2Region>region("region");
if(!suc)gotofail;// Conversion failed, no 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
// Projection specific parameters
switch(p.proj)
switch(p.proj)
{
{
case(gmt_projection::XY):// x Parameter 4 is height (by default equal width)
case(gmt_projection::XY):// x Parameter 4 is height (by default equal width)
{
{
Base2Doubleheight(input,3);
OPosPar<Base2NonNegD>height("height",p.width);
if(height.Exist())
{ParsePositionalParametersparams(input,3,input->Size(),height);if(!params){err=params.Error();gotofail;}}// Fail to parse additional parameters
{
p.x.height=height;
boolsuc=true;
p.x.height=height(&suc);
if(!suc)gotofail;// Parsing error
}
elsep.x.height=p.width;
if(size>4)gotofail;// Unknown parameter(s)
break;
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)
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)
case(gmt_projection::MERCATOR):// m Parameters: 4 is central meridian (default is center of region), 5 is standart parallel (default is center of region)
case(gmt_projection::MERCATOR):// m Parameters: 4 is central meridian (default is center of region), 5 is standart parallel (default is center of region)
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)
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)
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).
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
RPosPar<Base2String>pstype("subtype");
OBType<ObjectString>stype(input->At(3));
RPosPar<Base2Coord>clon("longitude of center");
if(!stype)gotofail;// Incorrect parameter type
RPosPar<Base2Coord>clat("latitude of center");
std::stringsubtype=stype->Value();
tolower(subtype);
{ParsePositionalParametersparams(input,3,6,pstype,clon,clat);if(!params){err=params.Error();gotofail;}}// Fail to parse additional parameters
{ParsePositionalParametersparams(input,6,input->Size(),azimuth);if(!params){err=params.Error();gotofail;}}// Fail to parse additional parameters
p.o.type=gmt_projection::OType::A;
p.o.type=gmt_projection::OType::A;
boolsuc=true;
p.o.azimuth=azimuth;
p.o.azimuth=azimuth(&suc);
if(!suc)gotofail;// Parsing error
if(size>7)gotofail;// Unknown parameter(s)
}
}
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;
p.o.type=gmt_projection::OType::B;
boolsuc=true;
p.o.eqlon=eqlon;
p.o.eqlon=eqlon(&suc);
p.o.eqlat=eqlat;
p.o.eqlat=eqlat(&suc);
if(!suc)gotofail;// Parsing error
if(size>8)gotofail;// Unknown parameter(s)
}
}
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;
p.o.type=gmt_projection::OType::C;
boolsuc=true;
p.o.polelon=polelon;
p.o.polelon=polelon(&suc);
p.o.polelat=polelat;
p.o.polelat=polelat(&suc);
if(!suc)gotofail;// Parsing error
if(size>8)gotofail;// Unknown parameter(s)
}
}
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;
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.
case(gmt_projection::CASSINI):// c Parameters: longitude (4, default is center of region) and latitude (5, default is center of region) of central point.
{
{
Base2Coordclon(input,3),clat(input,4);
OPosPar<Base2CoordD>clon("longitude of center",(p.region.xb+p.region.xe)*0.5);
if(clon.Exist())
OPosPar<Base2CoordD>clat("latitude of center",(p.region.yb+p.region.ye)*0.5);
{
{ParsePositionalParametersparams(input,3,input->Size(),clon,clat);if(!params){err=params.Error();gotofail;}}// Fail to parse additional parameters
case(gmt_projection::CYL_STERE):// cyl_stere Parameters: central meridian (3, default is center of region), standart parallel (4, default is center of region)
case(gmt_projection::CYL_STERE):// cyl_stere Parameters: central meridian (3, default is center of region), standart parallel (4, default is center of region)