Loading...
Searching...
No Matches
offset_scale_cartesian_coordinates.cuh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023, NVIDIA CORPORATION.
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 <cuproj/detail/utility/cuda.hpp>
20#include <cuproj/ellipsoid.hpp>
23
24#include <thrust/iterator/transform_iterator.h>
25
26#include <algorithm>
27
28namespace cuproj {
29
42template <typename Coordinate, typename T = typename Coordinate::value_type>
44 public:
52 : a_(params.ellipsoid_.a), ra_(T{1.0} / a_), x0_(params.x0), y0_(params.y0)
53 {
54 }
55
63 CUPROJ_HOST_DEVICE Coordinate operator()(Coordinate const& coord, direction dir) const
64 {
65 if (dir == direction::FORWARD)
66 return forward(coord);
67 else
68 return inverse(coord);
69 }
70
71 private:
79 CUPROJ_HOST_DEVICE Coordinate forward(Coordinate const& coord) const
80 {
81 return coord * a_ + Coordinate{x0_, y0_};
82 };
83
91 CUPROJ_HOST_DEVICE Coordinate inverse(Coordinate const& coord) const
92 {
93 return (coord - Coordinate{x0_, y0_}) * ra_;
94 };
95
96 T a_; // ellipsoid semi-major axis
97 T ra_; // inverse of ellipsoid semi-major axis
98 T x0_; // projection origin x
99 T y0_; // projection origin y
100};
101
106} // namespace cuproj
Given Cartesian coordinates (x, y) in meters, offset and scale them to the projection's origin and sc...
CUPROJ_HOST_DEVICE Coordinate operator()(Coordinate const &coord, direction dir) const
Offset and scale a single coordinate.
CUPROJ_HOST_DEVICE offset_scale_cartesian_coordinates(projection_parameters< T > const &params)
Constructor.
Base class for all transform operations.
Definition operation.cuh:63
direction
Enumerates the direction of a transform operation.
Definition operation.cuh:44