|
|
@ -225,96 +225,78 @@ template<> |
|
|
|
class Convert2Struct<struct gmt_region, ObjectList> |
|
|
|
class Convert2Struct<struct gmt_region, ObjectList> |
|
|
|
{ |
|
|
|
{ |
|
|
|
public: |
|
|
|
public: |
|
|
|
struct gmt_region operator()(const ObjectList* input, bool* issuc) const |
|
|
|
struct gmt_region operator()(const ObjectList* input, bool* issuc, std::string& err) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct gmt_region r; |
|
|
|
struct gmt_region r; |
|
|
|
auto size=input->Size(); |
|
|
|
|
|
|
|
bool suc=true; |
|
|
|
bool suc=true; |
|
|
|
|
|
|
|
|
|
|
|
if(1==size) // Cases 1, 2 and 3
|
|
|
|
if(1==input->Size()) // Cases 1, 2 and 3
|
|
|
|
{ |
|
|
|
{ |
|
|
|
Base2Region region(input,0); |
|
|
|
Base2Region region; |
|
|
|
r=region(&suc); |
|
|
|
r=region.Convert(input->At(0),&suc,err); |
|
|
|
if(!suc) goto fail; // Conversion failed
|
|
|
|
if(!suc) goto fail; // Conversion failed
|
|
|
|
return r; |
|
|
|
return r; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Case 4
|
|
|
|
// Case 4
|
|
|
|
{ |
|
|
|
{ |
|
|
|
std::string type; |
|
|
|
ONFPar<Base2Region,ObjectGMTRegion> region("region"); |
|
|
|
bool typeexist=false; |
|
|
|
ONPar<Base2StringD> type("type","nobbox"); |
|
|
|
{ |
|
|
|
ONPar<Base2Coord> xb("xb"),xe("xe"),yb("yb"),ye("ye"); |
|
|
|
Base2String t(input,"type"); |
|
|
|
|
|
|
|
if(t.Exist()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
type=t(&suc); |
|
|
|
|
|
|
|
tolower(type); |
|
|
|
|
|
|
|
if(!suc) goto fail; // Conversion failed
|
|
|
|
|
|
|
|
typeexist=true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else type="nobbox"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(r.Convert(type)) return r; // type is one of "global*" string, we can return, becuse upd is irrelevant
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool upd; |
|
|
|
{ParseNamedParameters params(input,type,region,xb,xe,yb,ye); if(!params) {err=params.Error(); goto fail;} } // Fail to parse by variant 4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool typeexist=type.Exist(); |
|
|
|
{ |
|
|
|
{ |
|
|
|
BaseMT2Region updarg(input,"r","region"); |
|
|
|
std::string t; |
|
|
|
r=updarg(&upd,&suc); |
|
|
|
if(r.Convert(type,t)) return r; // type is one of "global*" string, we can return, because upd is irrelevant
|
|
|
|
if(upd && !suc) goto fail; // Conversion failed or too many arguments
|
|
|
|
|
|
|
|
suc=true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Base2Coord ixb(input,"xb"), ixe(input,"xe"), iyb(input,"yb"), iye(input,"ye"); |
|
|
|
bool upd=region.Exist(); |
|
|
|
if(!(typeexist || ixb.Exist() || ixe.Exist() || iyb.Exist() || iye.Exist() || upd)) goto case5; // No named parameters, no update mode, possibly case 5
|
|
|
|
|
|
|
|
struct gmt_coord xb,yb,xe,ye; |
|
|
|
if(!(typeexist || xb.Exist() || xe.Exist() || yb.Exist() || ye.Exist() || upd)) goto case5; // No named parameters, no update mode, possibly case 5
|
|
|
|
|
|
|
|
struct gmt_coord cxb,cxe,cyb,cye; |
|
|
|
bool isbbox=upd?(gmt_region::BBOX==r.type):false; |
|
|
|
bool isbbox=upd?(gmt_region::BBOX==r.type):false; |
|
|
|
|
|
|
|
|
|
|
|
if(typeexist) |
|
|
|
if(typeexist) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if("bbox"==type) isbbox=true; |
|
|
|
if("bbox"==type.Value()) isbbox=true; |
|
|
|
if("nobbox"==type) isbbox=false; |
|
|
|
if("nobbox"==type.Value()) isbbox=false; |
|
|
|
if("bbox"!=type && "nobbox"!=type) goto fail; // Unknown type
|
|
|
|
if("bbox"!=type.Value() && "nobbox"!=type.Value()) goto fail; // Unknown type
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(upd) |
|
|
|
if(upd) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(!ixb.Exist()) xb=r.xb; |
|
|
|
cxb=xb.Exist()?xb:region->xb; |
|
|
|
if(!ixe.Exist()) xe=r.xe; |
|
|
|
cxe=xe.Exist()?xe:region->xe; |
|
|
|
if(!iyb.Exist()) yb=r.yb; |
|
|
|
cyb=yb.Exist()?yb:region->yb; |
|
|
|
if(!iye.Exist()) ye=r.ye; |
|
|
|
cye=ye.Exist()?ye:region->ye; |
|
|
|
} |
|
|
|
} |
|
|
|
else suc=suc && ixb.Exist() && ixe.Exist() && iyb.Exist() && iye.Exist(); // In "new" mode all parameters must exists
|
|
|
|
else |
|
|
|
if(ixb.Exist()) xb=ixb(&suc); |
|
|
|
{ |
|
|
|
if(ixe.Exist()) xe=ixe(&suc); |
|
|
|
suc=suc && xb.Exist() && xe.Exist() && yb.Exist() && ye.Exist(); // In "new" mode all parameters must exists
|
|
|
|
if(iyb.Exist()) yb=iyb(&suc); |
|
|
|
cxb=xb; cxe=xe; cyb=yb; cye=ye; |
|
|
|
if(iye.Exist()) ye=iye(&suc); |
|
|
|
} |
|
|
|
if(!suc) goto fail; // Something wrong
|
|
|
|
if(!suc) {err="To specify region all four coordinates must be set"; goto fail;} // Something wrong
|
|
|
|
if(!r.Convert(xb,xe,yb,ye,isbbox)) goto fail; // Conversion failed
|
|
|
|
if(!r.Convert(cxb,cxe,cyb,cye,isbbox)) {err="Error conversion of coordinates to region"; goto fail;} // Conversion failed
|
|
|
|
return r; // Case 3 with all parameters
|
|
|
|
return r; // Case 3 with all parameters
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
case5: |
|
|
|
case5: |
|
|
|
// Case 5
|
|
|
|
// Case 5
|
|
|
|
if(4==size || 5==size) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool isbbox=false; |
|
|
|
|
|
|
|
if(5==size) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
Base2String type(input,4); |
|
|
|
OPosPar<Base2StringD> type("type","nobbox"); |
|
|
|
std::string str=type(&suc); |
|
|
|
RPosPar<Base2Coord> p1("p1"),p2("p2"),p3("p3"),p4("p4"); |
|
|
|
if(!suc) goto fail; // Wrong parameter
|
|
|
|
ParsePositionalParameters params(input,p1,p2,p3,p4,type); |
|
|
|
tolower(str); |
|
|
|
|
|
|
|
if("bbox"!=str || "nobbox"!=str) goto fail; // Unknown fifth parameter
|
|
|
|
if(!params) {err=params.Error(); goto fail;} // Fail to parse by variant 5
|
|
|
|
if("bbox"==str) isbbox=true; |
|
|
|
|
|
|
|
} |
|
|
|
bool isbbox=("bbox"==type.Value()); |
|
|
|
Base2Coord ixb(input,0), ixe(input,(isbbox?2:1)), iyb(input,(isbbox?1:2)), iye(input,3); |
|
|
|
if("bbox"!=type.Value() && "nobbox"!=type.Value()) {err="Fifth parameter can be \"bbox\" or \"nobbox\" only"; goto fail;} // Unknown fifth parameter
|
|
|
|
struct gmt_coord xb=ixb(&suc),yb=iyb(&suc),xe=ixe(&suc),ye=iye(&suc); |
|
|
|
|
|
|
|
if(suc) |
|
|
|
if(!r.Convert(p1,isbbox?p3:p2,isbbox?p2:p3,p4,isbbox)) {err="Error conversion of coordinates to region"; goto fail;} // Conversion failed
|
|
|
|
{ |
|
|
|
|
|
|
|
if(!r.Convert(xb,xe,yb,ye,isbbox)) goto fail; // Conversion failed
|
|
|
|
|
|
|
|
return r; // Case 4 with all parameters
|
|
|
|
return r; // Case 4 with all parameters
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fail: |
|
|
|
fail: |
|
|
|
*issuc=false; |
|
|
|
*issuc=false; |
|
|
|