Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix libcuproj doc example and make tests consistent. #1503

Open
wants to merge 2 commits into
base: branch-25.02
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions cpp/cuproj/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,15 @@ The C++ API also supports transforming coordinate in CUDA device code. Create a
be passed to a kernel launch. Here's an example kernel.

```cpp
template <typename T>
using coordinate = typename cuproj::vec_2d<T>;
using device_projection = cuproj::device_projection<cuproj::vec_2d<float>>;

template <typename T>
using device_projection = cuproj::device_projection<coordinate<T>>;

__global__
void example_kernel(device_projection const d_proj,
cuproj::vec_2d<float> const* in,
cuproj::vec_2d<float>* out,
size_t n)
__global__ void example_kernel(device_projection const d_proj,
cuproj::vec_2d<float> const* in,
cuproj::vec_2d<float>* out,
size_t n)
{
for (size_t i = blockIdx.x * blockDim.x + threadIdx.x;
i < n;
i < n;
i += gridDim.x * blockDim.x) {
out[i] = d_proj.transform(in[i]);
}
Expand Down
22 changes: 3 additions & 19 deletions cpp/cuproj/doxygen/main_page.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,10 @@ transformations are supported:

- WGS84 to/from UTM

## Example

The C++ API is designed to be easy to use. The following example shows how to transform a point in
Sydney, Australia from WGS84 (lat, lon) coordinates to UTM zone 56S (x, y) coordinates.

```cpp
#include <cuproj/projection_factories.cuh>
#include <cuproj/vec_2d.hpp>

// Make a projection to convert WGS84 (lat, lon) coordinates to UTM zone 56S (x, y) coordinates
auto proj = cuproj::make_projection<cuproj::vec_2d<T>>("EPSG:4326", "EPSG:32756");

cuproj::vec_2d<T> sydney{-33.858700, 151.214000}; // Sydney, NSW, Australia
thrust::device_vector<cuproj::vec_2d<T>> d_in{1, sydney};
thrust::device_vector<cuproj::vec_2d<T>> d_out(d_in.size());

// Convert the coordinates. Works the same with a vector of many coordinates.
proj.transform(d_in.begin(), d_in.end(), d_out.begin(), cuproj::direction::FORWARD);
```
There are some basic examples of using the libcuproj C++ API in the
[cuProj README](https://github.com/rapidsai/cuspatial/cpp/cuproj/README.md).

## Useful Links

- [RAPIDS Home Page](https://rapids.ai)
- [cuSpatial Github](https://github.com/rapidsai/cuspatial)
4 changes: 3 additions & 1 deletion cpp/cuproj/tests/wgs_to_utm_test.cu
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,9 @@ TYPED_TEST(ProjectionTest, readme_example)
proj->transform(d_in.begin(), d_in.end(), d_out.begin(), cuproj::direction::FORWARD);
}

__global__ void example_kernel(cuproj::device_projection<cuproj::vec_2d<float>> const d_proj,
using device_projection = cuproj::device_projection<cuproj::vec_2d<float>>;

__global__ void example_kernel(device_projection const d_proj,
cuproj::vec_2d<float> const* in,
cuproj::vec_2d<float>* out,
size_t n)
Expand Down
Loading