diff --git a/oss-internship-2020/gdal/CMakeLists.txt b/oss-internship-2020/gdal/CMakeLists.txt index ef5d028..a1959d8 100644 --- a/oss-internship-2020/gdal/CMakeLists.txt +++ b/oss-internship-2020/gdal/CMakeLists.txt @@ -1,16 +1,16 @@ -// Copyright 2020 Google LLC -// -// 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. +# Copyright 2020 Google LLC +# +# 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. cmake_minimum_required(VERSION 3.10) @@ -19,6 +19,11 @@ project(test CXX C) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED True) +find_package(PNG REQUIRED) +find_package(PkgConfig REQUIRED) +pkg_check_modules(libpcre REQUIRED IMPORTED_TARGET libpcre) +#pkg_check_modules(libproj REQUIRED IMPORTED_TARGET libproj) + set(SAPI_ROOT "${PROJECT_SOURCE_DIR}/../.." CACHE PATH "Path to the Sandboxed API source tree") # cmake .. -G Ninja -DSAPI_ROOT=$HOME/sapi_root @@ -32,12 +37,10 @@ add_subdirectory("${SAPI_ROOT}" add_library(libgdal STATIC IMPORTED) set_property(TARGET libgdal PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/lib/libgdal.a") -find_package(PNG REQUIRED) - target_link_libraries(libgdal INTERFACE crypto expat jpeg - /usr/lib/x86_64-linux-gnu/libproj.so - /usr/lib/x86_64-linux-gnu/libpcre.so + PkgConfig::libpcre + /usr/lib/libproj.so sqlite3 tiff z pthread m rt dl curl PNG::PNG) @@ -51,7 +54,7 @@ add_sapi_library(gdal_sapi INPUTS "/usr/include/gdal/gdal.h" LIBRARY libgdal - LIBRARY_NAME gdal + LIBRARY_NAME GDAL NAMESPACE "" ) diff --git a/oss-internship-2020/gdal/README.md b/oss-internship-2020/gdal/README.md index c4e1999..e0805fa 100644 --- a/oss-internship-2020/gdal/README.md +++ b/oss-internship-2020/gdal/README.md @@ -5,6 +5,26 @@ Build Tools: CMake/Ninja OS: Linux ``` +### For installing GDAL: +`sudo apt-get install python3.6-dev` + +`sudo add-apt-repository ppa:ubuntugis/ppa && sudo apt update` + +`sudo apt-get install gdal-bin` + +`sudo apt-get install libgdal-dev` + +### Dependencies: +PNG: `sudo apt-get install libpng-dev` + +PCRE: `sudo apt-get install libpcre3 libpcre3-dev` + +PROJ: `sudo apt-get install libproj-dev` + +### Initializing GDAL submodule: +`git submodule add https://github.com/OSGeo/gdal/tree/master/gdal` + + ### For testing: `mkdir build && cd build` @@ -12,13 +32,13 @@ OS: Linux `ninja` -`./raster` +`./raster ` ## About the project - GDAL is a translator library for raster and vector - geospatial data format. - The project consist in rastering a GeoTIFF file format - using GDAL functionalities and sandboxed methods. +GDAL is a translator library for raster and vector +geospatial data format. +The project consist in rastering a GeoTIFF file format +using GDAL functionalities and sandboxed methods. ## Implementation diff --git a/oss-internship-2020/gdal/raster.cc b/oss-internship-2020/gdal/raster.cc index ec790f5..2a564bb 100644 --- a/oss-internship-2020/gdal/raster.cc +++ b/oss-internship-2020/gdal/raster.cc @@ -20,15 +20,13 @@ #include #include -#include "gdal_sapi.sapi.h" +#include "gdal_sapi.sapi.h" // NOLINT(build/include) #include "sandboxed_api/sandbox2/util/fileops.h" -class GdalSapiSandbox : public gdalSandbox { +class GdalSapiSandbox : public GDALSandbox { public: - std::string filePath; - GdalSapiSandbox(std::string path) - : gdalSandbox(), filePath(std::move(path)) {} + : GDALSandbox(), file_path_(std::move(path)) {} std::unique_ptr ModifyPolicy( sandbox2::PolicyBuilder*) override { @@ -52,16 +50,20 @@ class GdalSapiSandbox : public gdalSandbox { __NR_ftruncate, __NR_unlink, }) - .AddFile(filePath) + .AddFile(file_path_) .BuildOrDie(); } + + private: + std::string file_path_; }; absl::Status GdalMain(std::string filename) { // Reading GDALDataset from a (local, specific) file. GdalSapiSandbox sandbox(filename); + SAPI_RETURN_IF_ERROR(sandbox.Init()); - gdalApi api(&sandbox); + GDALApi api(&sandbox); sapi::v::CStr s(filename.data());