| pktools 2.6.7 Processing Kernel for geospatial data

Public Member Functions | List of all members
Egcs Class Reference

## Public Member Functions
| Egcs (unsigned short level)
unsigned short | cell2level (const std::string &cellCode) const
std::string | geo2cell (double x, double y) const
double | getSize () const
void | setLevel (unsigned short level)
unsigned short | getLevel () const
unsigned short | res2level (double resolution) const
double | getResolution () const
void | force2grid (double &ulx, double &uly, double &lrx, double &lry) const
void | cell2bb (const std::string &cellCode, int &ulx, int &uly, int &lrx, int &lry) const
void | cell2mid (const std::string &cellCode, double &midX, double &midY) const

## Detailed Description

Definition at line 26 of file Egcs.h.

## Constructor & Destructor Documentation

## ◆ Egcs() [1/2]

Egcs::Egcs | ( |  | ) |

Definition at line 26 of file Egcs.cc.

26 {
27}

## ◆ Egcs() [2/2]

Egcs::Egcs | ( | unsigned short | level | ) |

Definition at line 34 of file Egcs.cc.

35{
36 m_level=level;
37}

## ◆ ~Egcs()

Egcs::~Egcs | ( |  | ) |

Definition at line 56 of file Egcs.cc.

56 {
57}

## Member Function Documentation

## ◆ cell2bb()

void Egcs::cell2bb | ( | const std::string & | cellCode,
|  | int & | ulx,
|  | int & | uly,
|  | int & | lrx,
|  | int & | lry
| ) |  | const

Definition at line 97 of file Egcs.cc.

97 {
98 size_t pos=cellCode.find("-");
99 std::string TILE=cellCode.substr(0,pos);
100 std::string TILEX=TILE.substr(0,TILE.size()/2);
101 std::string TILEY=TILE.substr(TILE.size()/2);
102 std::string QUAD;
103 char QUAD1,QUAD2;
104 std::istringstream stilex(TILEX);
105 std::istringstream stiley(TILEY);
106 int llx,lly;
107 stilex >> llx;
108 stiley >> lly;
109 llx*=getBaseSize();
110 lly*=getBaseSize();
111 switch((19-m_level)%3){
112 case(0)://there should be no QUAD
113 assert(pos==std::string::npos);
114 break;
115 case(2)://there is a QUAD2
116 assert(pos+1!=std::string::npos);
117 QUAD=cellCode.substr(pos+1);
118 QUAD2=QUAD.substr(1,1).c_str()[0];
119 switch(QUAD2){
120 case('A'):
121 break;
122 case('C'):
123 lly+=getBaseSize()/4;
124 break;
125 case('D'):
126 lly+=getBaseSize()/4;
127 case('B'):
128 llx+=getBaseSize()/4;
129 break;
130 }
131 case(1)://QUAD1: deliberate fall through from case(2)!
132 if(!QUAD.size()){
133 assert(pos+1!=std::string::npos);
134 QUAD=cellCode.substr(pos+1);
135 }
136 QUAD1=QUAD.substr(0,1).c_str()[0];
137 switch(QUAD1){
138 case('A'):
139 break;
140 case('C'):
141 lly+=getBaseSize()/2;
142 break;
143 case('D'):
144 lly+=getBaseSize()/2;
145 case('B'):
146 llx+=getBaseSize()/2;
147 break;
148 }
149 break;
150 }
151 ulx=llx;
152 uly=static_cast<int>(lly+getSize());
153 lrx=static_cast<int>(llx+getSize());
154 lry=lly;
155}

## ◆ cell2level()

unsigned short Egcs::cell2level | ( | const std::string & | cellCode | ) | const

Definition at line 39 of file Egcs.cc.

39 {
40 size_t pos=cellCode.find("-");
41 std::string TILE=cellCode.substr(0,pos);
42 unsigned short level=0;
43 int base_level=19-(TILE.size()/2-1)*3;
44 int quad_level=0;
45 if(pos!=std::string::npos)
46 quad_level=cellCode.size()-pos-1;
47 if(quad_level>1)
48 level=base_level-2;
49 else if(quad_level>0)
50 level=base_level-1;
51 else
52 level=base_level;
53 return level;
54}

## ◆ cell2mid()

void Egcs::cell2mid | ( | const std::string & | cellCode,
|  | double & | midX,
|  | double & | midY
| ) |  | const

Definition at line 157 of file Egcs.cc.

157 {
158 int ulx,uly,lrx,lry;
159 cell2bb(cellCode,ulx,uly,lrx,lry);
160 midX=(ulx+lrx)/2.0;
161 midY=(lry+uly)/2.0;
162}

## ◆ force2grid()

void Egcs::force2grid | ( | double & | ulx,
|  | double & | uly,
|  | double & | lrx,
|  | double & | lry
| ) |  | const

Definition at line 76 of file Egcs.cc.

76 {
77 double dx=getResolution();
78 double dy=dx;
79 //ulx
80 ulx=floor(ulx);
81 ulx-=static_cast<int>(ulx)%(static_cast<int>(dx));
82 //uly
83 uly=ceil(uly);
84 if(static_cast<int>(uly)%static_cast<int>(dy))
85 uly+=dy;
86 uly-=static_cast<int>(uly)%(static_cast<int>(dy));
87 //lrx
88 lrx=ceil(lrx);
89 if(static_cast<int>(lrx)%static_cast<int>(dx))
90 lrx+=dx;
91 lrx-=static_cast<int>(lrx)%(static_cast<int>(dx));
92 //lry
93 lry=floor(lry);
94 lry-=static_cast<int>(lry)%(static_cast<int>(dy));
95}

## ◆ geo2cell()

std::string Egcs::geo2cell | ( | double | x,
|  | double | y
| ) |  | const

Definition at line 164 of file Egcs.cc.

164 {
165 int ndgts=7-(m_level+1)/3;
166 double xcel=static_cast<int>(geoX)/getBaseSize();
167 double ycel=static_cast<int>(geoY)/getBaseSize();
168 std::ostringstream osx;
169 std::ostringstream osy, osxy;
170 // osx << setprecision(ndgts) << xcel;
171 // osy << setprecision(ndgts) << ycel;
172 // osx << setprecision(0) << fixed << geoX;
173 // osy << setprecision(0) << fixed << geoY;
174 osx << std::fixed << geoX;
175 osy << std::fixed << geoY;
176 std::string quad1="";
177 std::string quad2="";
178 switch((19-m_level)%3){
179 case(2):
180 if(static_cast<int>(geoX)%(getBaseSize()/2)>=getBaseSize()/2.0){
181 if(static_cast<int>(geoY)%(getBaseSize()/2)>=getBaseSize()/2.0)
182 quad2="D";
183 else
184 quad2="B";
185 }
186 else if(static_cast<int>(geoY)%getBaseSize()>=getBaseSize()/4.0)
187 quad2="C";
188 else
189 quad2="A";
190 case(1)://deliberate fall through!
191 if(static_cast<int>(geoX)%getBaseSize()>=getBaseSize()/2.0){
192 if(static_cast<int>(geoY)%getBaseSize()>=getBaseSize()/2.0)
193 quad1="-D";
194 else
195 quad1="-B";
196 }
197 else if(static_cast<int>(geoY)%getBaseSize()>=getBaseSize()/2.0)
198 quad1="-C";
199 else
200 quad1="-A";
201 break;
202 default:
203 break;
204 }
205 osxy << osx.str().substr(0,ndgts) << osy.str().substr(0,ndgts) << quad1 << quad2;
206 return osxy.str();
207}

## ◆ getLevel()

unsigned short Egcs::getLevel | ( |  | ) | const
| inline

Definition at line 37 of file Egcs.h.

37{return m_level;};

## ◆ getResolution()

double Egcs::getResolution | ( |  | ) | const

Definition at line 65 of file Egcs.cc.

65 {
66 unsigned short exponent=(m_level+1)/3;
67 double base=pow(10.0,exponent);
68 if((m_level)%3==2)
69 return(base/4);
70 else if((m_level)%3==0)
71 return(base/2);
72 else
73 return(base);
74}

## ◆ getSize()

double Egcs::getSize | ( |  | ) | const
| inline

Definition at line 35 of file Egcs.h.

35{return getBaseSize()*pow(2.0,(m_level-19)%3);};

## ◆ res2level()

unsigned short Egcs::res2level | ( | double | resolution | ) | const

Definition at line 59 of file Egcs.cc.

59 {
60 double base=pow(10,log(resolution*4.0)/log(10.0));
61 double diff=base/(2*resolution);
62 return 0.5+(log(base)/log(10.0)*3+1-diff);
63}

## ◆ setLevel()

void Egcs::setLevel | ( | unsigned short | level | ) |
| inline

Definition at line 36 of file Egcs.h.

36{m_level=level;};

The documentation for this class was generated from the following files:

- /tmp/slackdce/slackrepo.NvCr9x/build_pktools/PKTOOLS-2.6.7.6/src/algorithms/Egcs.h
- /tmp/slackdce/slackrepo.NvCr9x/build_pktools/PKTOOLS-2.6.7.6/src/algorithms/Egcs.cc