OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
geosupport.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 MapD Technologies, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef _GEOSUPPORT_H_
18 #define _GEOSUPPORT_H_
19 
20 #include <cmath>
21 #include <string>
22 
23 const std::string OMNISCI_GEO_PREFIX{"omnisci_geo"};
24 const std::string LEGACY_GEO_PREFIX{"mapd_geo"};
25 
26 inline std::pair<double, double> geotransform_4326_to_900913(const double lon,
27  const double lat) {
28  static const double e_circ = 40075016.68; // Earth's circumference, meters
29  static const double e_circ_360 = e_circ / 360;
30  static const double pi = std::acos(-1);
31 
32  std::pair<double, double> ll;
33  ll.first = lon * e_circ_360;
34  ll.second = e_circ_360 * std::log(std::tan((90 + lat) * pi / 360)) / (pi / 180);
35  return ll;
36 }
37 
38 inline std::pair<double, double> geotransform(const std::string& src_proj,
39  const std::string& dst_proj,
40  const double x,
41  const double y) {
42  return geotransform_4326_to_900913(x, y);
43 }
44 
45 #endif // _GEOSUPPORT_H_
std::pair< double, double > geotransform(const std::string &src_proj, const std::string &dst_proj, const double x, const double y)
Definition: geosupport.h:38
const std::string LEGACY_GEO_PREFIX
Definition: geosupport.h:24
std::pair< double, double > geotransform_4326_to_900913(const double lon, const double lat)
Definition: geosupport.h:26
EXTENSION_NOINLINE double pi()
const std::string OMNISCI_GEO_PREFIX
Definition: geosupport.h:23