|
|
|
@ -6,6 +6,7 @@
|
|
|
|
|
#include <vector> |
|
|
|
|
#include "common.h" |
|
|
|
|
#include "modgmt_colornames.h" |
|
|
|
|
#include "modgmt_strcomp.h" |
|
|
|
|
|
|
|
|
|
// Centimeters to GMT points scale factor
|
|
|
|
|
// 1 inch = 72 pt = 2.54 cm --> 1 cm = 72/2.54 pt
|
|
|
|
@ -277,24 +278,58 @@ struct gmt_projection: public gmt_struct
|
|
|
|
|
case(OType::C): {ret="-JOb"+o.clon.Value()+"/"+o.clat.Value()+"/"+o.polelon.Value()+"/"+o.polelat.Value()+"/"+ToString(width)+"c"; break;} |
|
|
|
|
default: return ""; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case(CASSINI): {ret="-JC"+c.clon.Value()+"/"+c.clat.Value()+"/"+ToString(width)+"c"; break;} |
|
|
|
|
case(CYL_EQA): {ret="-JY"+y.stpar.Value()+"/"+y.cmer.Value()+"/"+ToString(width)+"c"; break;} |
|
|
|
|
case(CYL_EQA): {ret="-JY"+y.cmer.Value()+"/"+y.stpar.Value()+"/"+ToString(width)+"c"; break;} |
|
|
|
|
case(MILLER): {ret="-JJ"+j.cmer.Value()+"/"+ToString(width)+"c"; break;} |
|
|
|
|
case(CYL_STERE): {ret="-JCyl_stere"+cyl_stere.stpar.Value()+"/"+cyl_stere.cmer.Value()+"/"+ToString(width)+"c"; break;} |
|
|
|
|
case(CYL_STERE): {ret="-JCyl_stere/"+cyl_stere.stpar.Value()+"/"+cyl_stere.cmer.Value()+"/"+ToString(width)+"c"; break;} |
|
|
|
|
default: return ""; |
|
|
|
|
} |
|
|
|
|
ret+=" "+region.Value(); |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
bool SetType(const std::string& s) |
|
|
|
|
bool SetType(const std::string& s, std::string& err) |
|
|
|
|
{ |
|
|
|
|
proj=NOTDEF; |
|
|
|
|
std::string str=s; |
|
|
|
|
tolower(str); |
|
|
|
|
if(projnames.end()==projnames.find(str)) return false; |
|
|
|
|
proj=projnames[str]; |
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
// Handle one symbol cases
|
|
|
|
|
if(str.size()==1) switch(str[0]) |
|
|
|
|
{ |
|
|
|
|
case('c'): {proj=CASSINI; return true;} |
|
|
|
|
case('j'): {proj=MILLER; return true;} |
|
|
|
|
case('m'): {proj=MERCATOR; return true;} |
|
|
|
|
case('o'): {proj=OBLIQMERCATOR; return true;} |
|
|
|
|
case('q'): {proj=CYL_EQU; return true;} |
|
|
|
|
case('t'): {proj=TRANSMERCATOR; return true;} |
|
|
|
|
case('x'): {proj=XY; return true;} |
|
|
|
|
case('y'): {proj=CYL_EQA; return true;} |
|
|
|
|
default: break; |
|
|
|
|
} |
|
|
|
|
// Handle long GMT names
|
|
|
|
|
if("cyl_stere"==str) {proj=CYL_STERE; return true;} |
|
|
|
|
// Handle common names
|
|
|
|
|
std::string t1; |
|
|
|
|
for(const auto& m: projnames) |
|
|
|
|
{ |
|
|
|
|
TemplateComparator cmp(m.first); |
|
|
|
|
bool res=cmp.Compare(str); |
|
|
|
|
if(!res) continue; |
|
|
|
|
if(NOTDEF!=proj) // Ambiguos string
|
|
|
|
|
{ |
|
|
|
|
err="Ambiguous projection definition: did you mean \""+t1+"\" or \""+cmp.Template2Name()+"\"?"; |
|
|
|
|
proj=NOTDEF; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
t1=cmp.Template2Name(); |
|
|
|
|
proj=m.second; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(NOTDEF!=proj) return true; // All Ok
|
|
|
|
|
err="Unknown projection: "+s; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void FillProjNames(); |
|
|
|
|