Browse Source

Gmt module: Use ToString instead of std::to_string

ObjPtr
Michael Uleysky 9 years ago
parent
commit
78e9176d0b
  1. 2
      modules/gmt/modgmt_objects.h
  2. 42
      modules/gmt/modgmt_structs.h

2
modules/gmt/modgmt_objects.h

@ -133,7 +133,7 @@ class ObjectGMTLayer: public ObjectBase
{
if(Shifted())
{
std::string b="V "+std::to_string(cm2GMT(shiftx))+" "+std::to_string(cm2GMT(shifty))+" T\n";
std::string b="V "+ToString(cm2GMT(shiftx))+" "+ToString(cm2GMT(shifty))+" T\n";
std::string e="U\n";
int8_t* p=new int8_t[b.size()+data->size()+e.size()];
memcpy(p,b.data(),b.size());

42
modules/gmt/modgmt_structs.h

@ -98,8 +98,8 @@ struct gmt_coord: public gmt_struct
std::string Value() const
{
if(!isdeg) return std::to_string(r);
else return (sign?"":"-")+std::to_string(d)+":"+std::to_string(m)+(s==0?"":":"+std::to_string(s));
if(!isdeg) return ToString(r);
else return (sign?"":"-")+ToString(d)+":"+ToString(m)+(s==0?"":":"+ToString(s));
}
operator double() const
{
@ -254,24 +254,24 @@ struct gmt_projection: public gmt_struct
std::string ret;
switch(proj)
{
case(XY): {ret="-JX"+std::to_string(width)+"c/"+std::to_string(x.height)+"c"; break;}
case(CYL_EQU): {ret="-JQ"+q.cmer.Value()+"/"+q.stpar.Value()+"/"+std::to_string(width)+"c"; break;}
case(MERCATOR): {ret="-JM"+m.cmer.Value()+"/"+m.stpar.Value()+"/"+std::to_string(width)+"c"; break;}
case(TRANSMERCATOR): {ret="-JT"+t.cmer.Value()+"/"+t.orlat.Value()+"/"+std::to_string(width)+"c --PROJ_SCALE_FACTOR="+std::to_string(t.scale); break;}
case(XY): {ret="-JX"+ToString(width)+"c/"+ToString(x.height)+"c"; break;}
case(CYL_EQU): {ret="-JQ"+q.cmer.Value()+"/"+q.stpar.Value()+"/"+ToString(width)+"c"; break;}
case(MERCATOR): {ret="-JM"+m.cmer.Value()+"/"+m.stpar.Value()+"/"+ToString(width)+"c"; break;}
case(TRANSMERCATOR): {ret="-JT"+t.cmer.Value()+"/"+t.orlat.Value()+"/"+ToString(width)+"c --PROJ_SCALE_FACTOR="+ToString(t.scale); break;}
case(OBLIQMERCATOR):
{
switch(o.type)
{
case(OType::A): {ret="-JOa"+o.clon.Value()+"/"+o.clat.Value()+"/"+o.azimuth.Value()+"/"+std::to_string(width)+"c"; break;}
case(OType::B): {ret="-JOb"+o.clon.Value()+"/"+o.clat.Value()+"/"+o.eqlon.Value()+"/"+o.eqlat.Value()+"/"+std::to_string(width)+"c"; break;}
case(OType::C): {ret="-JOb"+o.clon.Value()+"/"+o.clat.Value()+"/"+o.polelon.Value()+"/"+o.polelat.Value()+"/"+std::to_string(width)+"c"; break;}
case(OType::A): {ret="-JOa"+o.clon.Value()+"/"+o.clat.Value()+"/"+o.azimuth.Value()+"/"+ToString(width)+"c"; break;}
case(OType::B): {ret="-JOb"+o.clon.Value()+"/"+o.clat.Value()+"/"+o.eqlon.Value()+"/"+o.eqlat.Value()+"/"+ToString(width)+"c"; break;}
case(OType::C): {ret="-JOb"+o.clon.Value()+"/"+o.clat.Value()+"/"+o.polelon.Value()+"/"+o.polelat.Value()+"/"+ToString(width)+"c"; break;}
default: return "";
}
}
case(CASSINI): {ret="-JC"+c.clon.Value()+"/"+c.clat.Value()+"/"+std::to_string(width)+"c"; break;}
case(CYL_EQA): {ret="-JY"+y.stpar.Value()+"/"+y.cmer.Value()+"/"+std::to_string(width)+"c"; break;}
case(MILLER): {ret="-JJ"+j.cmer.Value()+"/"+std::to_string(width)+"c"; break;}
case(CYL_STERE): {ret="-JCyl_stere"+cyl_stere.stpar.Value()+"/"+cyl_stere.cmer.Value()+"/"+std::to_string(width)+"c"; 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(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;}
default: return "";
}
ret+=" "+region.Value();
@ -310,13 +310,13 @@ struct gmt_color: public gmt_struct
double transparency;
std::string Value() const
{
std::string trans=(transparency!=0)?("@"+std::to_string(transparency)):"";
std::string trans=(transparency!=0)?("@"+ToString(transparency)):"";
switch(model)
{
case(RGB): return std::to_string(r)+"/"+std::to_string(g)+"/"+std::to_string(b)+trans;
case(GRAY): return std::to_string(gray)+trans;
case(HSV): return std::to_string(hue)+"-"+std::to_string(saturation)+"-"+std::to_string(value)+trans;
case(CMYK): return std::to_string(cyan)+"/"+std::to_string(magenta)+"/"+std::to_string(yellow)+"/"+std::to_string(black)+trans;
case(RGB): return ToString(r)+"/"+ToString(g)+"/"+ToString(b)+trans;
case(GRAY): return ToString(gray)+trans;
case(HSV): return ToString(hue)+"-"+ToString(saturation)+"-"+ToString(value)+trans;
case(CMYK): return ToString(cyan)+"/"+ToString(magenta)+"/"+ToString(yellow)+"/"+ToString(black)+trans;
}
return "";
}
@ -620,9 +620,9 @@ struct gmt_dash: public gmt_struct
{
std::string ret;
if(dash.empty()) return ret;
for(auto i:dash) ret+=std::to_string((wisrel?width:1.0)*i/10.0)+"_";
for(auto i:dash) ret+=ToString((wisrel?width:1.0)*i/10.0)+"_";
ret.back()=':';
ret+=std::to_string(shift)+"c";
ret+=ToString(shift)+"c";
return ret;
}
operator bool() const {return !dash.empty();}
@ -679,7 +679,7 @@ struct gmt_pen: public gmt_struct
struct gmt_color color;
struct gmt_dash dash;
static const double default_width;
std::string Value() const {return std::to_string(width/10.0)+"c,"+color.Value()+(dash?(","+dash.Value()):"");}
std::string Value() const {return ToString(width/10.0)+"c,"+color.Value()+(dash?(","+dash.Value()):"");}
// Interpret one numeric argument as width value
bool Convert(double in)

Loading…
Cancel
Save