OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Transforms.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, 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 #pragma once
18 
19 #include <cmath>
20 #include <string>
21 
22 inline std::pair<double, double> geotransform_4326_to_900913(const double lon,
23  const double lat) {
24  static const double e_circ = 40075016.68; // Earth's circumference, meters
25  static const double e_circ_360 = e_circ / 360;
26  static const double pi = std::acos(-1);
27 
28  std::pair<double, double> ll;
29  ll.first = lon * e_circ_360;
30  ll.second = e_circ_360 * std::log(std::tan((90 + lat) * pi / 360)) / (pi / 180);
31  return ll;
32 }
33 
34 inline std::pair<double, double> geotransform(const std::string& src_proj,
35  const std::string& dst_proj,
36  const double x,
37  const double y) {
38  return geotransform_4326_to_900913(x, y);
39 }
std::pair< double, double > geotransform(const std::string &src_proj, const std::string &dst_proj, const double x, const double y)
Definition: Transforms.h:34
std::pair< double, double > geotransform_4326_to_900913(const double lon, const double lat)
Definition: Transforms.h:22
EXTENSION_NOINLINE double pi()