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

[REVIEW] Code review for initial check-in #7

Merged
merged 115 commits into from
Sep 4, 2019
Merged
Changes from 1 commit
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
1b716b1
init check-in (cpp/python)
zhangjianting Aug 14, 2019
ebe73bc
for code review
zhangjianting Aug 22, 2019
3c3295e
add paths for custring libs
zhangjianting Aug 23, 2019
1b49472
update on documentating python test/demo code
zhangjianting Aug 23, 2019
ae6fe28
Update README.md
zhangjianting Aug 23, 2019
378de35
Update README.md
zhangjianting Aug 23, 2019
675d719
Update README.md
zhangjianting Aug 23, 2019
6563b38
Update README.md
zhangjianting Aug 23, 2019
9d42ab2
Update README.md
zhangjianting Aug 23, 2019
9d5c761
Update cpp/include/cuspatial/hausdorff.hpp
zhangjianting Aug 23, 2019
73a2f05
Update cpp/include/cuspatial/hausdorff.hpp
zhangjianting Aug 23, 2019
5f97192
Update cpp/include/cuspatial/hausdorff.hpp
zhangjianting Aug 23, 2019
0eb5670
Update README.md
zhangjianting Aug 23, 2019
1c187a8
Update cpp/include/cuspatial/hausdorff.hpp
zhangjianting Aug 23, 2019
1022c8d
Update cpp/include/cuspatial/hausdorff.hpp
zhangjianting Aug 23, 2019
f0fc3a8
Update README.md
zhangjianting Aug 23, 2019
d9e7fca
Update README.md
zhangjianting Aug 23, 2019
4a67a78
Update README.md
zhangjianting Aug 23, 2019
1dc84b1
Update README.md
zhangjianting Aug 23, 2019
79b5b1f
Update README.md
zhangjianting Aug 23, 2019
cf6b51a
Update README.md
zhangjianting Aug 23, 2019
db4d6fc
Update README.md
zhangjianting Aug 23, 2019
afac815
Update README.md
zhangjianting Aug 23, 2019
111149c
Update cpp/include/cuspatial/coord_trans.hpp
zhangjianting Aug 23, 2019
0d5fd7d
Update cpp/include/cuspatial/coord_trans.hpp
zhangjianting Aug 23, 2019
6f3b2e2
Update cpp/include/cuspatial/coord_trans.hpp
zhangjianting Aug 23, 2019
67f3356
Update cpp/include/cuspatial/coord_trans.hpp
zhangjianting Aug 23, 2019
227d187
Update cpp/include/cuspatial/coord_trans.hpp
zhangjianting Aug 23, 2019
4d73d59
Update cpp/include/cuspatial/coord_trans.hpp
zhangjianting Aug 23, 2019
8dd7f5f
Update cpp/include/cuspatial/coord_trans.hpp
zhangjianting Aug 23, 2019
4bf2c66
Update cpp/include/cuspatial/coord_trans.hpp
zhangjianting Aug 23, 2019
fed0b48
Update cpp/include/cuspatial/coord_trans.hpp
zhangjianting Aug 23, 2019
f150a05
Update cpp/include/cuspatial/coord_trans.hpp
zhangjianting Aug 23, 2019
81cc626
Update cpp/include/cuspatial/cuspatial.h
zhangjianting Aug 23, 2019
c70cc57
Update cpp/include/cuspatial/cuspatial.h
zhangjianting Aug 23, 2019
05a3f9a
Update cpp/include/cuspatial/cuspatial.h
zhangjianting Aug 23, 2019
fc86a09
Update cpp/include/cuspatial/cuspatial.h
zhangjianting Aug 23, 2019
0e12651
Update cpp/include/cuspatial/cuspatial.h
zhangjianting Aug 23, 2019
0acd63a
Update cpp/include/cuspatial/cuspatial.h
zhangjianting Aug 23, 2019
ca85b2a
formatting
zhangjianting Aug 24, 2019
b3018bd
2nd round revision for code review
zhangjianting Aug 24, 2019
f1e4788
Update cpp/include/cuspatial/haversine.hpp
zhangjianting Aug 28, 2019
645479f
for 3rd round code review
zhangjianting Aug 28, 2019
3b5e989
Merge branch 'fea-initial-code' of github.com:zhangjianting/cuspatial…
zhangjianting Aug 28, 2019
b48b61c
Update cpp/include/cuspatial/trajectory.hpp
zhangjianting Aug 28, 2019
80faf5a
for 3rd round code review
zhangjianting Aug 28, 2019
645e606
Merge branch 'fea-initial-code' of github.com:zhangjianting/cuspatial…
zhangjianting Aug 28, 2019
28ac08a
Update cpp/include/cuspatial/soa_readers.hpp
zhangjianting Aug 28, 2019
1a880f9
for 3rd code review
zhangjianting Aug 28, 2019
0722277
Merge branch 'fea-initial-code' of github.com:zhangjianting/cuspatial…
zhangjianting Aug 28, 2019
b194258
Update cpp/include/cuspatial/soa_readers.hpp
zhangjianting Aug 28, 2019
ff18076
Add .gitignore
harrism Aug 28, 2019
9838cb3
Update version no. and make finding cudf more flexible
harrism Aug 28, 2019
8296a83
Merge branch 'fea-initial-code' of github.com:zhangjianting/cuspatial…
harrism Aug 28, 2019
02551e9
for 3rd round code review: making location3d and coord_2d templated
zhangjianting Aug 28, 2019
34cd979
Merge branch 'fea-initial-code' of github.com:zhangjianting/cuspatial…
zhangjianting Aug 28, 2019
5bd8913
Update cpp/include/cuspatial/soa_readers.hpp
zhangjianting Aug 28, 2019
e2b2de3
Update cpp/include/cuspatial/trajectory.hpp
zhangjianting Aug 28, 2019
ed23bfa
for 3rd round code review
zhangjianting Aug 28, 2019
20cc9b1
Merge branch 'fea-initial-code' of github.com:zhangjianting/cuspatial…
zhangjianting Aug 28, 2019
4b966bd
for 3rd round code review (continued)
zhangjianting Aug 29, 2019
71fcf3e
for 3rd round code review (amendment)
zhangjianting Aug 29, 2019
9809b9c
Update .gitignore cudf->cuspatial
harrism Aug 29, 2019
8646847
Fix URL in setup.py
harrism Aug 29, 2019
f625d93
for 3rd code review (amendment)
zhangjianting Aug 29, 2019
f1b7e2b
Merge branch 'fea-initial-code' of github.com:zhangjianting/cuspatial…
zhangjianting Aug 29, 2019
6da406a
adding typename
zhangjianting Aug 29, 2019
82d4ff4
Clean up and fix Cython bindings and trajectory APIs
harrism Aug 30, 2019
5982544
Merge branch 'fea-initial-code' of github.com:zhangjianting/cuspatial…
harrism Aug 30, 2019
4b729d9
Rename traj.p** to trajectory.p**
harrism Aug 30, 2019
2b7b8ed
Test cleanup and disabling failing tests for now.
harrism Aug 30, 2019
cdc4039
coord_to_traj --> derive_trajectories, plus cleanup
harrism Aug 30, 2019
2bd6371
Clean up README.md
harrism Aug 30, 2019
4f9c9ee
Clean up data README.md
harrism Aug 30, 2019
ce36d37
simplify pip_test for test on GPU only; add pip_compare to compare CP…
zhangjianting Aug 31, 2019
9b256bd
uint-->uint32_t;adding hausdorff_toy test; grouping tests
zhangjianting Aug 31, 2019
7b7bfb6
add hausdorff_compare test
zhangjianting Aug 31, 2019
d1c9db6
pip_test: comparing two rounds GPU results
zhangjianting Aug 31, 2019
a03f82a
Add haversine_toy test; remove uncessary header files
zhangjianting Sep 1, 2019
c71fc5b
remove unused code; remove __host__
zhangjianting Sep 1, 2019
2039056
Fix pip_test crash.
harrism Sep 2, 2019
c1cce54
Readme markdown fixes.
harrism Sep 2, 2019
9c395be
Merge branch 'fea-initial-code' of github.com:zhangjianting/cuspatial…
harrism Sep 2, 2019
a96d5b7
Fix merge error.
harrism Sep 2, 2019
13cbd63
cuspatial.h renamed to cuspatial/types.hpp
harrism Sep 2, 2019
2fc09b3
Header style and documentation cleanup
harrism Sep 2, 2019
02e4e0d
Point in polygon API cleanup
harrism Sep 2, 2019
99d894f
Reorganize / rename utilities
harrism Sep 2, 2019
cbf84fb
pip.hpp --> point_in_polygon.hpp
harrism Sep 2, 2019
fd7740b
Refactor query naming; cleanup
harrism Sep 2, 2019
c71c65c
More pip renaming
harrism Sep 2, 2019
99d5385
add subset_trajectory and its test on toy data
zhangjianting Sep 2, 2019
c489053
add two toy tests for derive_trajectories and trajectory_distance_and…
zhangjianting Sep 2, 2019
6058cbe
Eliminate global `using namespace ...` declarations.
harrism Sep 3, 2019
a8cc7ad
Merge branch 'fea-initial-code' of github.com:zhangjianting/cuspatial…
harrism Sep 3, 2019
e46e4c0
add three test (spaital_window, coordinate_transform, trajectory_spat…
zhangjianting Sep 3, 2019
dad03ce
trajectory cleanup
harrism Sep 3, 2019
c5724bf
Merge branch 'fea-initial-code' of github.com:zhangjianting/cuspatial…
harrism Sep 3, 2019
0a8c1f0
Fix forward declarations.
harrism Sep 3, 2019
63165f3
Remove more global using namespace decls
harrism Sep 3, 2019
3f5a931
Clean up polygon_soa_reader
harrism Sep 3, 2019
a137faf
clean-up: indentation, simplification
zhangjianting Sep 3, 2019
69cf890
code clean-up: indentation, using T* instead of thrust::device_ptr an…
zhangjianting Sep 3, 2019
7a3c36f
code clean-up: indentation, using T* instead of thrust::device_ptr an…
zhangjianting Sep 3, 2019
afc19b0
code clean-up: use anonymous namespace, remove output and timing code
zhangjianting Sep 3, 2019
d52a80b
code clean-up: use anonymous namespace, remove output and timing code
zhangjianting Sep 3, 2019
2e155bd
code clean-up: remove output, using anonymous namespace etc.
zhangjianting Sep 3, 2019
d20d7df
Remove C-style casts.
harrism Sep 3, 2019
452c56f
Merge branch 'fea-initial-code' of github.com:zhangjianting/cuspatial…
harrism Sep 3, 2019
ed953e9
code clean-up: remove debug output and timing code, using anonymous n…
zhangjianting Sep 3, 2019
c6608a1
Merge branch 'fea-initial-code' of https://github.com/zhangjianting/c…
zhangjianting Sep 3, 2019
60999ce
replace count_if with count
harrism Sep 4, 2019
7b472a0
Safely copy gdf_scalar values.
harrism Sep 4, 2019
4624e57
Changelog for PR #7
harrism Sep 4, 2019
07e68b9
Clearer window parameters for spatial_window_points
harrism Sep 4, 2019
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
8 changes: 3 additions & 5 deletions cpp/tests/trajectory/traj_util.cpp
Original file line number Diff line number Diff line change
@@ -3,15 +3,13 @@
#include <utility/utility.hpp>
#include "traj_util.h"

using namespace cuspatial;

/**
* @brief retrive camera origin at a particular intersection from a configuration file
*
* @brief retrieve camera origin at a particular intersection from a
* configuration file
*
* @todo: don't return inscrutable error codes; throw helpful exceptions
* @return negative error code; 0 for success
*/

int get_camera_origin(const char *df_fn, const char * inter_name, location_3d<double> & camera_origin)
{
const int num_col=39;
158 changes: 78 additions & 80 deletions cpp/tests/trajectory/trajectory_derive_toy.cu
Original file line number Diff line number Diff line change
@@ -32,93 +32,91 @@
#include <tests/utilities/cudf_test_utils.cuh>
#include <tests/utilities/cudf_test_fixtures.h>

using namespace cuspatial;

struct TrajectoryDeriveToy : public GdfTest
{
};

TEST_F(TrajectoryDeriveToy, trajectoryderivetest)
{
//three sorted trajectories with 5,4,3 points, respectively
std::cout<<"in TrajectoryDeriveToy"<<std::endl;
double point_x[]={1.0,2.0,3.0,5.0,7.0,1.0,2.0,3.0,6.0,0.0,3.0,6.0};
double point_y[]={0.0,1.0,2.0,3.0,1.0,3.0,5.0,6.0,5.0,4.0,7.0,4.0};
uint32_t point_id[]={0,0,0,0,0,1,1,1,1,2,2,2};

//handling timestamps - use millsecond field only for now
int point_ms[]={1,2,3,4,5,1,2,3,4,1,2,3};
size_t num_point=sizeof(point_x)/sizeof(double);
std::cout<<"num_point="<<num_point<<std::endl;

std::vector<its_timestamp> point_ts;
for(size_t i=0;i<num_point;i++)
{
its_timestamp ts;
memset(&ts,0,sizeof(its_timestamp));
ts.ms=point_ms[i];
point_ts.push_back(ts);
}

//randomize points
uint32_t seq[]={11,9,4,5,2,7,10,1,3,8,0,6};
std::vector<double> rand_x;
std::vector<double> rand_y;
std::vector<uint32_t> rand_id;
std::vector<its_timestamp> rand_ts;

//three sorted trajectories with 5,4,3 points, respectively
std::cout<<"in TrajectoryDeriveToy"<<std::endl;
double point_x[]={1.0,2.0,3.0,5.0,7.0,1.0,2.0,3.0,6.0,0.0,3.0,6.0};
double point_y[]={0.0,1.0,2.0,3.0,1.0,3.0,5.0,6.0,5.0,4.0,7.0,4.0};
uint32_t point_id[]={0,0,0,0,0,1,1,1,1,2,2,2};

for(size_t i=0;i<num_point;i++)
{
rand_x.push_back(point_x[seq[i]]);
rand_y.push_back(point_y[seq[i]]);
rand_id.push_back(point_id[seq[i]]);
rand_ts.push_back(point_ts[seq[i]]);
}
//std::copy(rand_ts.begin(),rand_ts.end(),std::ostream_iterator<its_timestamp>(std::cout, " "));std::cout<<std::endl;

cudf::test::column_wrapper<double> point_x_wrapp{rand_x};
cudf::test::column_wrapper<double> point_y_wrapp{rand_y};
cudf::test::column_wrapper<uint32_t> point_id_wrapp{rand_id};
cudf::test::column_wrapper<its_timestamp> point_ts_wrapp{rand_ts};
//handling timestamps - use millsecond field only for now
int point_ms[]={1,2,3,4,5,1,2,3,4,1,2,3};
size_t num_point=sizeof(point_x)/sizeof(double);
std::cout<<"num_point="<<num_point<<std::endl;

gdf_column traj_id,traj_len,traj_offset;
memset(&traj_id,0,sizeof(gdf_column));
memset(&traj_len,0,sizeof(gdf_column));
memset(&traj_offset,0,sizeof(gdf_column));
gdf_column pnt_x=*(point_x_wrapp.get());
gdf_column pnt_y=*(point_y_wrapp.get());
gdf_column pnt_id=*(point_id_wrapp.get());
gdf_column pnt_ts=*(point_ts_wrapp.get());

std::cout<<"calling cuspatial::derive_trajectory"<<std::endl;
uint32_t num_traj=cuspatial::derive_trajectories(pnt_x,pnt_y,pnt_id,pnt_ts,traj_id,traj_len,traj_offset);

std::cout<<"point data after sorting"<<std::endl;
thrust::device_ptr<double> pnt_x_ptr=thrust::device_pointer_cast(static_cast<double*>(pnt_x.data));
thrust::device_ptr<double> pnt_y_ptr=thrust::device_pointer_cast(static_cast<double*>(pnt_y.data));
thrust::device_ptr<uint32_t> pnt_id_ptr=thrust::device_pointer_cast(static_cast<uint32_t*>(pnt_id.data));
thrust::device_ptr<its_timestamp> pnt_ts_ptr=thrust::device_pointer_cast(static_cast<its_timestamp*>(pnt_ts.data));

int num_print = (pnt_x.size<20)?pnt_x.size:20;
std::cout<<"x"<<std::endl;
thrust::copy(pnt_x_ptr,pnt_x_ptr+num_print,std::ostream_iterator<double>(std::cout, " "));std::cout<<std::endl;
std::cout<<"y"<<std::endl;
thrust::copy(pnt_y_ptr,pnt_y_ptr+num_print,std::ostream_iterator<double>(std::cout, " "));std::cout<<std::endl;
std::cout<<"id"<<std::endl;
thrust::copy(pnt_id_ptr,pnt_id_ptr+num_print,std::ostream_iterator<uint32_t>(std::cout, " "));std::cout<<std::endl;
std::cout<<"timestamp"<<std::endl;
thrust::copy(pnt_ts_ptr,pnt_ts_ptr+num_print,std::ostream_iterator<its_timestamp>(std::cout, " "));std::cout<<std::endl;
std::vector<cuspatial::its_timestamp> point_ts;
for(size_t i=0;i<num_point;i++)
{
cuspatial::its_timestamp ts;
memset(&ts,0,sizeof(cuspatial::its_timestamp));
ts.ms=point_ms[i];
point_ts.push_back(ts);
}

//randomize points
uint32_t seq[]={11,9,4,5,2,7,10,1,3,8,0,6};
std::vector<double> rand_x;
std::vector<double> rand_y;
std::vector<uint32_t> rand_id;
std::vector<cuspatial::its_timestamp> rand_ts;

for(size_t i=0;i<num_point;i++)
{
rand_x.push_back(point_x[seq[i]]);
rand_y.push_back(point_y[seq[i]]);
rand_id.push_back(point_id[seq[i]]);
rand_ts.push_back(point_ts[seq[i]]);
}
//std::copy(rand_ts.begin(),rand_ts.end(),std::ostream_iterator<its_timestamp>(std::cout, " "));std::cout<<std::endl;

std::cout<<"derived trajectories"<<std::endl;
num_print = (num_traj<10)?num_traj:10;
thrust::device_ptr<uint32_t> traj_id_ptr=thrust::device_pointer_cast(static_cast<uint32_t*>(traj_id.data));
thrust::device_ptr<uint32_t> traj_len_ptr=thrust::device_pointer_cast(static_cast<uint32_t*>(traj_len.data));
thrust::device_ptr<uint32_t> traj_offset_ptr=thrust::device_pointer_cast(static_cast<uint32_t*>(traj_offset.data));
std::cout<<"ids of trajectories"<<std::endl;
thrust::copy(traj_id_ptr,traj_id_ptr+num_print,std::ostream_iterator<uint32_t>(std::cout, " "));std::cout<<std::endl;
std::cout<<"#of points of trajectories"<<std::endl;
thrust::copy(traj_len_ptr,traj_len_ptr+num_print,std::ostream_iterator<uint32_t>(std::cout, " "));std::cout<<std::endl;
std::cout<<"poisition indices on sorted point x/y array of trajectories"<<std::endl;
thrust::copy(traj_offset_ptr,traj_offset_ptr+num_print,std::ostream_iterator<uint32_t>(std::cout, " "));std::cout<<std::endl;
cudf::test::column_wrapper<double> point_x_wrapp{rand_x};
cudf::test::column_wrapper<double> point_y_wrapp{rand_y};
cudf::test::column_wrapper<uint32_t> point_id_wrapp{rand_id};
cudf::test::column_wrapper<cuspatial::its_timestamp> point_ts_wrapp{rand_ts};

gdf_column traj_id,traj_len,traj_offset;
memset(&traj_id,0,sizeof(gdf_column));
memset(&traj_len,0,sizeof(gdf_column));
memset(&traj_offset,0,sizeof(gdf_column));
gdf_column pnt_x=*(point_x_wrapp.get());
gdf_column pnt_y=*(point_y_wrapp.get());
gdf_column pnt_id=*(point_id_wrapp.get());
gdf_column pnt_ts=*(point_ts_wrapp.get());

std::cout<<"calling cuspatial::derive_trajectory"<<std::endl;
uint32_t num_traj=cuspatial::derive_trajectories(pnt_x,pnt_y,pnt_id,pnt_ts,traj_id,traj_len,traj_offset);

std::cout<<"point data after sorting"<<std::endl;
thrust::device_ptr<double> pnt_x_ptr=thrust::device_pointer_cast(static_cast<double*>(pnt_x.data));
thrust::device_ptr<double> pnt_y_ptr=thrust::device_pointer_cast(static_cast<double*>(pnt_y.data));
thrust::device_ptr<uint32_t> pnt_id_ptr=thrust::device_pointer_cast(static_cast<uint32_t*>(pnt_id.data));
thrust::device_ptr<cuspatial::its_timestamp> pnt_ts_ptr =
thrust::device_pointer_cast(static_cast<cuspatial::its_timestamp*>(pnt_ts.data));

int num_print = (pnt_x.size<20)?pnt_x.size:20;
std::cout<<"x"<<std::endl;
thrust::copy(pnt_x_ptr,pnt_x_ptr+num_print,std::ostream_iterator<double>(std::cout, " "));std::cout<<std::endl;
std::cout<<"y"<<std::endl;
thrust::copy(pnt_y_ptr,pnt_y_ptr+num_print,std::ostream_iterator<double>(std::cout, " "));std::cout<<std::endl;
std::cout<<"id"<<std::endl;
thrust::copy(pnt_id_ptr,pnt_id_ptr+num_print,std::ostream_iterator<uint32_t>(std::cout, " "));std::cout<<std::endl;
std::cout<<"timestamp"<<std::endl;
thrust::copy(pnt_ts_ptr,pnt_ts_ptr+num_print,std::ostream_iterator<cuspatial::its_timestamp>(std::cout, " "));std::cout<<std::endl;

std::cout<<"derived trajectories"<<std::endl;
num_print = (num_traj<10)?num_traj:10;
thrust::device_ptr<uint32_t> traj_id_ptr=thrust::device_pointer_cast(static_cast<uint32_t*>(traj_id.data));
thrust::device_ptr<uint32_t> traj_len_ptr=thrust::device_pointer_cast(static_cast<uint32_t*>(traj_len.data));
thrust::device_ptr<uint32_t> traj_offset_ptr=thrust::device_pointer_cast(static_cast<uint32_t*>(traj_offset.data));
std::cout<<"ids of trajectories"<<std::endl;
thrust::copy(traj_id_ptr,traj_id_ptr+num_print,std::ostream_iterator<uint32_t>(std::cout, " "));std::cout<<std::endl;
std::cout<<"#of points of trajectories"<<std::endl;
thrust::copy(traj_len_ptr,traj_len_ptr+num_print,std::ostream_iterator<uint32_t>(std::cout, " "));std::cout<<std::endl;
std::cout<<"poisition indices on sorted point x/y array of trajectories"<<std::endl;
thrust::copy(traj_offset_ptr,traj_offset_ptr+num_print,std::ostream_iterator<uint32_t>(std::cout, " "));std::cout<<std::endl;
}
100 changes: 49 additions & 51 deletions cpp/tests/trajectory/trajectory_distance_speed_toy.cu
Original file line number Diff line number Diff line change
@@ -32,63 +32,61 @@
#include <tests/utilities/cudf_test_utils.cuh>
#include <tests/utilities/cudf_test_fixtures.h>

using namespace cuspatial;

struct TrajectoryDeriveToy : public GdfTest
{
};

TEST_F(TrajectoryDeriveToy, trajectoryderivetest)
{
//three sorted trajectories with 5,4,3 points, respectively
std::cout<<"in TrajectoryDeriveToy"<<std::endl;
//assuming x/y are in the unit of killometers (km);
//computed distance and speed are in the units of meters and m/s, respectively
double point_x[]={1.0,2.0,3.0,5.0,7.0,1.0,2.0,3.0,6.0,0.0,3.0,6.0};
double point_y[]={0.0,1.0,2.0,3.0,1.0,3.0,5.0,6.0,5.0,4.0,7.0,4.0};
uint32_t traj_len[]={5,4,3};
uint32_t traj_offset[]={5,9,12};

//handling timestamps - use millsecond field only for now
int point_hh[]={0,1,2,3,4,0,1,2,3,0,1,2};
int point_ms[]={1,2,3,4,5,1,2,3,4,1,2,3};
int num_point=sizeof(point_x)/sizeof(double);
int num_traj=sizeof(traj_len)/sizeof(uint32_t);
std::cout<<"num_point="<<num_point<<" num_traj="<<num_traj<<std::endl;

std::vector<its_timestamp> point_ts;
for(int i=0;i<num_point;i++)
{
its_timestamp ts;
memset(&ts,0,sizeof(its_timestamp));
ts.hh=point_hh[i];
ts.ms=point_ms[i];
point_ts.push_back(ts);
}

cudf::test::column_wrapper<double> point_x_wrapp{std::vector<double>(point_x,point_x+num_point)};
cudf::test::column_wrapper<double> point_y_wrapp{std::vector<double>(point_y,point_y+num_point)};
cudf::test::column_wrapper<its_timestamp> point_ts_wrapp{point_ts};
cudf::test::column_wrapper<uint32_t> traj_len_wrapp{std::vector<uint32_t>(traj_len,traj_len+num_traj)};
cudf::test::column_wrapper<uint32_t> traj_pos_wrapp{std::vector<uint32_t>(traj_offset,traj_offset+num_traj)};
//three sorted trajectories with 5,4,3 points, respectively
std::cout<<"in TrajectoryDeriveToy"<<std::endl;
//assuming x/y are in the unit of killometers (km);
//computed distance and speed are in the units of meters and m/s, respectively
double point_x[]={1.0,2.0,3.0,5.0,7.0,1.0,2.0,3.0,6.0,0.0,3.0,6.0};
double point_y[]={0.0,1.0,2.0,3.0,1.0,3.0,5.0,6.0,5.0,4.0,7.0,4.0};
uint32_t traj_len[]={5,4,3};
uint32_t traj_offset[]={5,9,12};

//handling timestamps - use millsecond field only for now
int point_hh[]={0,1,2,3,4,0,1,2,3,0,1,2};
int point_ms[]={1,2,3,4,5,1,2,3,4,1,2,3};
int num_point=sizeof(point_x)/sizeof(double);
int num_traj=sizeof(traj_len)/sizeof(uint32_t);
std::cout<<"num_point="<<num_point<<" num_traj="<<num_traj<<std::endl;

std::vector<cuspatial::its_timestamp> point_ts;
for(int i=0;i<num_point;i++)
{
cuspatial::its_timestamp ts;
memset(&ts,0,sizeof(cuspatial::its_timestamp));
ts.hh=point_hh[i];
ts.ms=point_ms[i];
point_ts.push_back(ts);
}

cudf::test::column_wrapper<double> point_x_wrapp{std::vector<double>(point_x,point_x+num_point)};
cudf::test::column_wrapper<double> point_y_wrapp{std::vector<double>(point_y,point_y+num_point)};
cudf::test::column_wrapper<cuspatial::its_timestamp> point_ts_wrapp{point_ts};
cudf::test::column_wrapper<uint32_t> traj_len_wrapp{std::vector<uint32_t>(traj_len,traj_len+num_traj)};
cudf::test::column_wrapper<uint32_t> traj_pos_wrapp{std::vector<uint32_t>(traj_offset,traj_offset+num_traj)};

std::cout<<"calling cuspatial::trajectory_distance_and_speed"<<std::endl;
std::pair<gdf_column,gdf_column> dist_speed_pair=
cuspatial::trajectory_distance_and_speed(*(point_x_wrapp.get()),*(point_y_wrapp.get()),
*(point_ts_wrapp.get()),*(traj_len_wrapp.get()),*(traj_pos_wrapp.get()));

CUDF_EXPECTS(num_traj==dist_speed_pair.first.size && num_traj==dist_speed_pair.second.size,
"size of output dist/speed columns should be the same as the number of the input trajectories");

std::cout<<"calling cuspatial::trajectory_distance_and_speed"<<std::endl;
std::pair<gdf_column,gdf_column> dist_speed_pair=
cuspatial::trajectory_distance_and_speed(*(point_x_wrapp.get()),*(point_y_wrapp.get()),
*(point_ts_wrapp.get()),*(traj_len_wrapp.get()),*(traj_pos_wrapp.get()));

CUDF_EXPECTS(num_traj==dist_speed_pair.first.size && num_traj==dist_speed_pair.second.size,
"size of output dist/speed columns should be the same as the number of the input trajectories");

std::cout<<"computed distance/speed"<<std::endl;
int num_print = (num_traj<10)?num_traj:10;
thrust::device_ptr<double> traj_distance_ptr=
thrust::device_pointer_cast(static_cast<double*>(dist_speed_pair.first.data));
thrust::device_ptr<double> traj_speed_ptr=
thrust::device_pointer_cast(static_cast<double*>(dist_speed_pair.second.data));
std::cout<<"computed distance/speed"<<std::endl;
int num_print = (num_traj<10)?num_traj:10;
thrust::device_ptr<double> traj_distance_ptr=
thrust::device_pointer_cast(static_cast<double*>(dist_speed_pair.first.data));
thrust::device_ptr<double> traj_speed_ptr=
thrust::device_pointer_cast(static_cast<double*>(dist_speed_pair.second.data));

std::cout<<"computed distance (in meters):"<<std::endl;
thrust::copy(traj_distance_ptr,traj_distance_ptr+num_print,std::ostream_iterator<double>(std::cout, " "));std::cout<<std::endl;
std::cout<<"computed speed (in m/s):"<<std::endl;
thrust::copy(traj_speed_ptr,traj_speed_ptr+num_print,std::ostream_iterator<double>(std::cout, " "));std::cout<<std::endl;
std::cout<<"computed distance (in meters):"<<std::endl;
thrust::copy(traj_distance_ptr,traj_distance_ptr+num_print,std::ostream_iterator<double>(std::cout, " "));std::cout<<std::endl;
std::cout<<"computed speed (in m/s):"<<std::endl;
thrust::copy(traj_speed_ptr,traj_speed_ptr+num_print,std::ostream_iterator<double>(std::cout, " "));std::cout<<std::endl;
}
2 changes: 0 additions & 2 deletions cpp/tests/trajectory/trajectory_spatial_bounds_toy.cu
Original file line number Diff line number Diff line change
@@ -32,8 +32,6 @@
#include <tests/utilities/cudf_test_utils.cuh>
#include <tests/utilities/cudf_test_fixtures.h>

using namespace cuspatial;

struct TrajectoryDeriveToy : public GdfTest
{
};
Loading