pktools  2.6.7
Processing Kernel for geospatial data
Egcs.h
1 /**********************************************************************
2 Egcs.h: Conversions from and to european grid coding system
3 Copyright (C) 2008-2012 Pieter Kempeneers
4 
5 This file is part of pktools
6 
7 pktools is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 pktools is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with pktools. If not, see <http://www.gnu.org/licenses/>.
19 ***********************************************************************/
20 #include <math.h>
21 #include <string>
22 
23 #ifndef _EGCS_H_
24 #define _EGCS_H_
25 
26 class Egcs
27 {
28 public:
29  Egcs();
30  Egcs(unsigned short level);
31  /* Egcs(unsigned short level); */
32  ~Egcs();
33  unsigned short cell2level(const std::string& cellCode) const;
34  std::string geo2cell(double x, double y) const;
35  double getSize() const {return getBaseSize()*pow(2.0,(m_level-19)%3);};
36  void setLevel(unsigned short level){m_level=level;};
37  unsigned short getLevel() const{return m_level;};
38  unsigned short res2level(double resolution) const;
39  double getResolution() const;
40  void force2grid(double& ulx, double& uly, double& lrx, double &lry) const;
41  void cell2bb(const std::string& cellCode, int &ulx, int &uly, int &lrx, int &lry) const;
42  void cell2mid(const std::string& cellCode, double& midX, double& midY) const;
43 private:
44  int getBaseSize() const {return pow(10.0,(m_level+1)/3);};
45  unsigned short m_level;
46 // level square scheme example
47 // 19 1000km xy 32
48 // 18 500km xy-q 32-A
49 // 17 250km xy-qq 32-AB
50 // 16 100km xxyy 3320
51 // 5 25m xxxxxyyyyy-qq 3346720658-DC
52 // 1 1m xxxxxxxyyyyyyy 33467652065889
53 };
54 #endif // _EGCS_H_
55 
Definition: Egcs.h:26