OmniSciDB  2e3a973ef4
Transforms.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 #pragma once
18 
19 #include <cmath>
20 #include <string>
21 
22 const std::string OMNISCI_GEO_PREFIX{"omnisci_geo"};
23 const std::string LEGACY_GEO_PREFIX{"mapd_geo"};
24 
25 inline std::pair<double, double> geotransform_4326_to_900913(const double lon,
26  const double lat) {
27  static const double e_circ = 40075016.68; // Earth's circumference, meters
28  static const double e_circ_360 = e_circ / 360;
29  static const double pi = std::acos(-1);
30 
31  std::pair<double, double> ll;
32  ll.first = lon * e_circ_360;
33  ll.second = e_circ_360 * std::log(std::tan((90 + lat) * pi / 360)) / (pi / 180);
34  return ll;
35 }
36 
37 inline std::pair<double, double> geotransform(const std::string& src_proj,
38  const std::string& dst_proj,
39  const double x,
40  const double y) {
41  return geotransform_4326_to_900913(x, y);
42 }
const std::string OMNISCI_GEO_PREFIX
Definition: Transforms.h:22
std::pair< double, double > geotransform(const std::string &src_proj, const std::string &dst_proj, const double x, const double y)
Definition: Transforms.h:37
std::pair< double, double > geotransform_4326_to_900913(const double lon, const double lat)
Definition: Transforms.h:25
EXTENSION_NOINLINE double pi()
const std::string LEGACY_GEO_PREFIX
Definition: Transforms.h:23