pktools 2.6.7
Processing Kernel for geospatial data
Egcs.h
1/**********************************************************************
2Egcs.h: Conversions from and to european grid coding system
3Copyright (C) 2008-2012 Pieter Kempeneers
4
5This file is part of pktools
6
7pktools is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation, either version 3 of the License, or
10(at your option) any later version.
11
12pktools is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along 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
26class Egcs
27{
28public:
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;
43private:
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:27