-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'RpcOptim' into 'master'
RpcOptim - shareloc optimisé avec bindings c++ See merge request 3d/shareloc!143
- Loading branch information
Showing
15 changed files
with
953 additions
and
17 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
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
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
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
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
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,54 @@ | ||
/* | ||
Copyright (c) 2023 Centre National d'Etudes Spatiales (CNES). | ||
This file is part of shareloc | ||
(see https://github.com/CNES/shareloc). | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
/** | ||
Cpp copy of GeoModelTemplate.py | ||
*/ | ||
|
||
|
||
GeoModelTemplate::GeoModelTemplate() { | ||
epsg = 0; | ||
} | ||
GeoModelTemplate::~GeoModelTemplate() { | ||
} | ||
|
||
vector<vector<double>> GeoModelTemplate::direct_loc_h( | ||
vector<double> row, | ||
vector<double> col, | ||
double alt, | ||
bool fill_nan){ | ||
vector<vector<double>> vect; | ||
return vect; | ||
} | ||
|
||
vector<vector<double>> GeoModelTemplate::direct_loc_dtm( | ||
vector<double> row, | ||
vector<double> col, | ||
string dtm){ | ||
vector<vector<double>> vect; | ||
return vect; | ||
} | ||
|
||
tuple<vector<double>,vector<double>,vector<double>> GeoModelTemplate::inverse_loc( | ||
vector<double> lon, | ||
vector<double> lat, | ||
double alt){ | ||
tuple<vector<double>,vector<double>,vector<double>> res; | ||
return res; | ||
} |
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,71 @@ | ||
/* | ||
Copyright (c) 2023 Centre National d'Etudes Spatiales (CNES). | ||
This file is part of shareloc | ||
(see https://github.com/CNES/shareloc). | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
/** | ||
Cpp copy of GeoModelTemplate.py | ||
Abstract class GeoModelTemplate. | ||
Child class: RPC | ||
*/ | ||
|
||
#include <iostream> | ||
#include <vector> | ||
#include <string> | ||
#include <tuple> | ||
#include <array> | ||
#include <map> | ||
|
||
using std::cout; | ||
using std::endl; | ||
using std::vector; | ||
using std::string; | ||
using std::tuple; | ||
using std::array; | ||
using std::map; | ||
|
||
/** | ||
Abstract class GeoModelTemplate: | ||
Child: RPC | ||
*/ | ||
class GeoModelTemplate { | ||
|
||
private: | ||
string type; | ||
int epsg; | ||
public: | ||
/**Constructor*/ | ||
GeoModelTemplate(); | ||
/**Destructor*/ | ||
~GeoModelTemplate(); | ||
/**direct_loc_h*/ | ||
vector<vector<double>> direct_loc_h( | ||
vector<double> row, | ||
vector<double> col, | ||
double alt, | ||
bool fill_nan=false); | ||
/**direct_loc_dtm*/ | ||
vector<vector<double>> direct_loc_dtm( | ||
vector<double> row, | ||
vector<double> col, | ||
string dtm); | ||
/**inverse_loc*/ | ||
tuple<vector<double>,vector<double>,vector<double>> inverse_loc( | ||
vector<double> lon, | ||
vector<double> lat, | ||
double alt); | ||
}; |
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,88 @@ | ||
/* | ||
coding: utf8 | ||
Copyright (c) 2023 Centre National d'Etudes Spatiales (CNES). | ||
This file is part of shareloc | ||
(see https://github.com/CNES/shareloc). | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
/** | ||
Thes purpose of this module is only to "bind" cpp code. | ||
It gives to the compiler the instructions to compile the usefull cpp code into an .so file | ||
which is callable in a python code as a python module. | ||
*/ | ||
|
||
#include <pybind11/pybind11.h> | ||
#include <pybind11/stl.h> | ||
#include "rpc.cpp" | ||
|
||
namespace py = pybind11; | ||
|
||
|
||
PYBIND11_MODULE(rpc_c, m) { | ||
|
||
py::class_<GeoModelTemplate>(m, "GeoModelTemplate") | ||
.def(py::init<>()) | ||
.def("direct_loc_h", &GeoModelTemplate::direct_loc_h) | ||
.def("direct_loc_dtm", &GeoModelTemplate::direct_loc_dtm) | ||
.def("inverse_loc", &GeoModelTemplate::inverse_loc); | ||
|
||
py::class_<RPC,GeoModelTemplate>(m, "RPC") | ||
.def(py::init<array<double, 20>, | ||
array<double, 20>, | ||
array<double, 20>, | ||
array<double, 20>, | ||
array<double, 10>>()) | ||
.def("direct_loc_h", &RPC::direct_loc_h) | ||
.def("direct_loc_grid_h", &RPC::direct_loc_grid_h) | ||
.def("direct_loc_dtm", &RPC::direct_loc_dtm) | ||
.def("filter_coordinates", &RPC::filter_coordinates) | ||
.def("compute_loc_inverse_derivates", &RPC::compute_loc_inverse_derivates) | ||
.def("direct_loc_inverse_iterative", &RPC::direct_loc_inverse_iterative) | ||
.def("get_alt_min_max", &RPC::get_alt_min_max) | ||
.def("los_extrema", &RPC::los_extrema) | ||
.def("get_num_col", &RPC::get_num_col) | ||
.def("get_den_col", &RPC::get_den_col) | ||
.def("get_num_row", &RPC::get_num_row) | ||
.def("get_den_row", &RPC::get_den_row) | ||
.def("get_num_lon", &RPC::get_num_lon) | ||
.def("get_den_lon", &RPC::get_den_lon) | ||
.def("get_num_lat", &RPC::get_num_lat) | ||
.def("get_den_lat", &RPC::get_den_lat) | ||
.def("get_offset_row", &RPC::get_offset_row) | ||
.def("get_scale_row", &RPC::get_scale_row) | ||
.def("get_offset_col", &RPC::get_offset_col) | ||
.def("get_scale_col", &RPC::get_scale_col) | ||
.def("get_offset_alt", &RPC::get_offset_alt) | ||
.def("get_scale_alt", &RPC::get_scale_alt) | ||
.def("get_offset_lon", &RPC::get_offset_lon) | ||
.def("get_scale_lon", &RPC::get_scale_lon) | ||
.def("get_offset_lat", &RPC::get_offset_lat) | ||
.def("get_scale_lat", &RPC::get_scale_lat); | ||
|
||
//m.doc() = "Pybind hello world"; // optional module docstring | ||
m.def("polynomial_equation", &polynomial_equation, "TODO: doc"); | ||
m.def("compute_rational_function_polynomial", &compute_rational_function_polynomial, | ||
"TODO: doc"); | ||
m.def("derivative_polynomial_latitude", &derivative_polynomial_latitude, "TODO: doc"); | ||
m.def("derivative_polynomial_longitude", &derivative_polynomial_longitude, "TODO: doc"); | ||
m.def("compute_loc_inverse_derivates_optimized", | ||
&compute_loc_inverse_derivates_optimized, | ||
"TODO: doc"); | ||
} | ||
|
||
//c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) | ||
//bind.cpp -o pbrpc$(python3-config --extension-suffix) |
Oops, something went wrong.