-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
77 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
cdef extern from "cuproj/ellipsoid.hpp" namespace "cuproj" nogil: | ||
cdef cppclass ellipsoid[T]: | ||
ellipsoid() except+ | ||
ellipsoid(T, T) except+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
cdef extern from "cuproj/operation/operation.cuh" namespace "cuproj" nogil: | ||
cdef enum operation_type: | ||
AXIS_SWAP = 0 | ||
DEGREES_TO_RADIANS = 1 | ||
CLAMP_ANGULAR_COORDINATES = 2 | ||
OFFSET_SCALE_CARTESIAN_COORDINATES = 3 | ||
TRANSVERSE_MERCATOR = 4 | ||
|
||
cdef enum direction: | ||
FORWARD = 0 | ||
INVERSE = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
from cuproj._lib.cpp.operation cimport operation_type, direction | ||
from cuproj._lib.cpp.projection_parameters cimport projection_parameters | ||
|
||
from libcpp.vector cimport vector | ||
|
||
cdef extern from "cuproj/projection.cuh" namespace "cuproj" nogil: | ||
cdef cppclass projection[Coordinate]: | ||
projection(# vector of operation_type | ||
# projection parameters | ||
# constructed direction) | ||
cdef cppclass projection[Coordinate, T=*]: | ||
projection() | ||
projection(vector[operation_type], | ||
projection_parameters[T], | ||
direction=direction.FORWARD) | ||
|
||
void transform[CoordIter](CoordIter, CoordIter, CoordIter, direction) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from cuproj._lib.cpp.projection cimport projection | ||
|
||
from libcpp.string cimport string | ||
|
||
cdef extern from "cuproj/projection_factories.hpp" namespace "cuproj" nogil: | ||
projection[Coordinate] make_projection[Coordinate]( | ||
string, string | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from cuproj._lib.cpp.ellipsoid cimport ellipsoid | ||
|
||
cdef extern from "cuproj/projection_parameters.hpp" namespace "cuproj" nogil: | ||
cdef enum hemisphere: | ||
NORTH = 0 | ||
SOUTH = 1 | ||
|
||
cdef cppclass projection_parameters[T]: | ||
projection_parameters( | ||
ellipsoid[T], | ||
int, | ||
hemisphere, | ||
T, | ||
T | ||
) except+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import cupy as cp | ||
|
||
from cuproj._lib.cpp.projection cimport projection | ||
from cuproj._lib.cpp.projection_factories cimport make_projection | ||
from cuproj._lib.cpp.operation cimport direction | ||
|
||
def wgs84_to_utm(srcarr): | ||
result = cp.array(srcarr.shape, dtype=cp.float64) | ||
cdef projection[double] proj = make_projection[double]( | ||
b"epsg:4326", b"epsg:32633" | ||
) | ||
|
||
srcarr_data = cp.ascontiguousarray(srcarr, dtype=cp.float64) | ||
result_data = cp.ascontiguousarray(result, dtype=cp.float64) | ||
|
||
cdef double[::1] srcarr_arr_memview = srcarr_data | ||
cdef int size = srcarr_data.shape[0] | ||
cdef double[::1] result_arr_memview = result_data | ||
|
||
with nogil: | ||
proj.transform( | ||
&srcarr_arr_memview[0], | ||
&srcarr_arr_memview[0] + size, | ||
&result_arr_memview[0], | ||
direction.FORWARD | ||
) | ||
|
||
return result |