From 0995a736ca1c4871e4359781aa4458c573742e68 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Mon, 22 Sep 2025 09:36:35 +0200 Subject: [PATCH 01/31] =?UTF-8?q?Cr=C3=A9ation=20du=20style=20terrain=20rg?= =?UTF-8?q?b?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rok4/style/Terrainrgb.h | 80 +++++++++++++++++++++++++++++++++ src/style/Terrainrgb.cpp | 70 +++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 include/rok4/style/Terrainrgb.h create mode 100644 src/style/Terrainrgb.cpp diff --git a/include/rok4/style/Terrainrgb.h b/include/rok4/style/Terrainrgb.h new file mode 100644 index 0000000..65bb53c --- /dev/null +++ b/include/rok4/style/Terrainrgb.h @@ -0,0 +1,80 @@ +/* + * Copyright © (2011) Institut national de l'information + * géographique et forestière + * + * Géoportail SAV + * + * This software is a computer program whose purpose is to publish geographic + * data using OGC WMS and WMTS protocol. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * + * knowledge of the CeCILL-C license and that you accept its terms. + */ + +#pragma once + +#include "rok4/utils/Configuration.h" + +#include +#include +#include +#include + +class Terrainrgb : public Configuration +{ +private: + /** \~french + * \brief min_elevation : élévation minimale à partir de laquelle est calculée la couleur + ** \~english + * \brief min_elevation : minimum elevation from which the color is calculated + */ + int min_elevation; + + /** \~french + * \brief step : écart d'altitude entre deux couleurs différentes + ** \~english + * \brief step : altitude difference between two different colors + */ + float step; + +public: + /** + * \~french + * \brief Constructeurs avec des arguments + * \~english + * \brief Constructor with arguments + */ + Terrainrgb(json11::Json doc); + + /** + * \~french + * \brief Destructeur + * \~english + * \brief Destructor + */ + virtual ~Terrainrgb(); +}; diff --git a/src/style/Terrainrgb.cpp b/src/style/Terrainrgb.cpp new file mode 100644 index 0000000..17aea32 --- /dev/null +++ b/src/style/Terrainrgb.cpp @@ -0,0 +1,70 @@ +/* + * Copyright © (2011) Institut national de l'information + * géographique et forestière + * + * Géoportail SAV + * + * This software is a computer program whose purpose is to publish geographic + * data using OGC WMS and WMTS protocol. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * + * knowledge of the CeCILL-C license and that you accept its terms. + */ + +#include "style/Terrainrgb.h" +#include +#include "zlib.h" +#include +#include "byteswap.h" +#include + +Terrainrgb::Terrainrgb(json11::Json doc) : Configuration() +{ + + if (doc["min_elevation"].is_number()) + { + min_elevation = doc["min_elevation"].number_value(); + } + else + { + BOOST_LOG_TRIVIAL(warning) << "Wrong format for terrainrgb, terrainrgb ignored"; + return; + } + if (doc["step"].is_number()) + { + min_elevation = doc["step"].number_value(); + } + else + { + BOOST_LOG_TRIVIAL(warning) << "Wrong format for terrainrgb, terrainrgb ignored"; + return; + } +} + +Terrainrgb::~Terrainrgb() +{ +} From eb4a6467f472f8c7a0f9729762d2609e58a4aa5c Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Tue, 23 Sep 2025 10:31:34 +0200 Subject: [PATCH 02/31] =?UTF-8?q?impl=C3=A9mentation=20de=20TerrainrgbImag?= =?UTF-8?q?e.h/cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rok4/image/TerrainrgbImage.h | 58 +++++++++++++ src/image/TerrainrgbImage.cpp | 123 +++++++++++++++++++++++++++ 2 files changed, 181 insertions(+) create mode 100644 include/rok4/image/TerrainrgbImage.h create mode 100644 src/image/TerrainrgbImage.cpp diff --git a/include/rok4/image/TerrainrgbImage.h b/include/rok4/image/TerrainrgbImage.h new file mode 100644 index 0000000..2a3bab7 --- /dev/null +++ b/include/rok4/image/TerrainrgbImage.h @@ -0,0 +1,58 @@ +/* + * Copyright © (2011) Institut national de l'information + * géographique et forestière + * + * Géoportail SAV + * + * This software is a computer program whose purpose is to publish geographic + * data using OGC WMS and WMTS protocol. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * + * knowledge of the CeCILL-C license and that you accept its terms. + */ + +#pragma once + +#include "rok4/image/Image.h" +#include "rok4/style/Terrainrgb.h" + +class TerrainrgbImage : public Image +{ +private: + Image *source_image; + Terrainrgb *terrainrgb; + + template + int _getline(T *buffer, int line); + +public: + virtual int get_line(float *buffer, int line); + virtual int get_line(uint16_t *buffer, int line); + virtual int get_line(uint8_t *buffer, int line); + TerrainrgbImage(Image *image, Terrainrgb *terrainrgb); + virtual ~TerrainrgbImage(); +}; diff --git a/src/image/TerrainrgbImage.cpp b/src/image/TerrainrgbImage.cpp new file mode 100644 index 0000000..3475a7b --- /dev/null +++ b/src/image/TerrainrgbImage.cpp @@ -0,0 +1,123 @@ +/* + * Copyright © (2011) Institut national de l'information + * géographique et forestière + * + * Géoportail SAV + * + * This software is a computer program whose purpose is to publish geographic + * data using OGC WMS and WMTS protocol. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * + * knowledge of the CeCILL-C license and that you accept its terms. + */ + +#include "image/TerrainrgbImage.h" + +#include +#include "TerrainrgbImage.h" + +int TerrainrgbImage::get_line(float *buffer, int line) +{ + if (source_image->get_channels() == 1) + { + return _getline(buffer, line); + } + else + { + return source_image->get_line(buffer, line); + } +} + +int TerrainrgbImage::get_line(uint16_t *buffer, int line) +{ + if (source_image->get_channels() == 1) + { + return _getline(buffer, line); + } + else + { + return source_image->get_line(buffer, line); + } +} + +int TerrainrgbImage::get_line(uint8_t *buffer, int line) +{ + if (source_image->get_channels() == 1) + { + return _getline(buffer, line); + } + else + { + return source_image->get_line(buffer, line); + } +} + +TerrainrgbImage::TerrainrgbImage(Image *image, Terrainrgb *Terrainrgb) : Image(image->get_width(), image->get_height(), 1, image->get_bbox()), source_image(image) +{ + // Il n'y aura application de la palette et modification des canaux que si + // - la palette n'est pas nulle et pas vide + // - l'image source est sur un canal + if (source_image->get_channels() == 1) + { + channels = 3; + } + else + { + channels = image->get_channels(); + } +} + +TerrainrgbImage::~TerrainrgbImage() +{ + delete source_image; +} + +template +int TerrainrgbImage::_getline(T *buffer, int line) +{ + float *source = new float[source_image->get_width() * source_image->get_channels()]; + source_image->get_line(source, line); + switch (channels) + { + + case 3: + for (int i = 0; i < source_image->get_width(); i++) + { + int base = *buffer + terrainrgb->min_elevation / terrainrgb->step; + int red = abs(base / (256 * 256)) % 256; + int green = abs((base - red * 256 * 256) / 256) % 256; + int blue = abs(base - red * 256 * 256 - green * 256); + *(buffer + i * 3) = red; + *(buffer + i * 3 + 1) = green; + *(buffer + i * 3 + 2) = blue; + } + break; + } + + delete[] source; + return width * sizeof(T) * channels; +} From f62c3688779d8964dbc91a4b06fd736e021b8a93 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Tue, 23 Sep 2025 11:05:36 +0200 Subject: [PATCH 03/31] =?UTF-8?q?D=C3=A9bug=20probl=C3=A8me=20=C3=A0=20la?= =?UTF-8?q?=20compilation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rok4/style/Terrainrgb.h | 3 +-- src/image/TerrainrgbImage.cpp | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/include/rok4/style/Terrainrgb.h b/include/rok4/style/Terrainrgb.h index 65bb53c..fbb8761 100644 --- a/include/rok4/style/Terrainrgb.h +++ b/include/rok4/style/Terrainrgb.h @@ -46,7 +46,7 @@ class Terrainrgb : public Configuration { -private: +public: /** \~french * \brief min_elevation : élévation minimale à partir de laquelle est calculée la couleur ** \~english @@ -61,7 +61,6 @@ class Terrainrgb : public Configuration */ float step; -public: /** * \~french * \brief Constructeurs avec des arguments diff --git a/src/image/TerrainrgbImage.cpp b/src/image/TerrainrgbImage.cpp index 3475a7b..948ad13 100644 --- a/src/image/TerrainrgbImage.cpp +++ b/src/image/TerrainrgbImage.cpp @@ -38,7 +38,6 @@ #include "image/TerrainrgbImage.h" #include -#include "TerrainrgbImage.h" int TerrainrgbImage::get_line(float *buffer, int line) { From bebe28dbda3923b4206c6c466d9efaa1a18d47e0 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Tue, 23 Sep 2025 11:11:43 +0200 Subject: [PATCH 04/31] =?UTF-8?q?mise=20=C3=A0=20jour=20changelog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6953392..6e9362e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ Le format est basé sur [Keep a Changelog](https://keepachangelog.com/) et ce pr ## [Unreleased] ### Added + +- `Terrainrgb` : Ajout d'un style terrainrgb pour transformer les MNT en format Terrain RGB. +- `TerrainrgbImage` : Ajout du processus de traitement du style Terrainrgb. + ### Changed ### Deprecated ### Removed From 28dc457fab02d9388c39c10d18a89c9f6d74e87c Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Tue, 23 Sep 2025 14:37:25 +0200 Subject: [PATCH 05/31] Adapt style.h/cpp to admit terrainrgb --- include/rok4/style/Style.h | 6 ++++++ src/image/TerrainrgbImage.cpp | 3 --- src/style/Style.cpp | 18 +++++++++++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/include/rok4/style/Style.h b/include/rok4/style/Style.h index 766a22d..07e5fe2 100644 --- a/include/rok4/style/Style.h +++ b/include/rok4/style/Style.h @@ -55,6 +55,7 @@ class Style; #include "rok4/style/Pente.h" #include "rok4/style/Estompage.h" #include "rok4/style/Aspect.h" +#include "rok4/style/Terrainrgb.h" #include "rok4/enums/Interpolation.h" #include "rok4/utils/Configuration.h" #include "rok4/enums/Format.h" @@ -162,6 +163,11 @@ private : * \~english \brief Define wether the server must compute a relief shadow */ Estompage* estompage; + /** + * \~french \brief Définit si un terrainrgb doit être appliqué + * \~english \brief Define wether the server must compute a RGB terrain + */ + Terrainrgb* terrainrgb; /** * \~french \brief Valeur de nodata attendue dans les données en entrée diff --git a/src/image/TerrainrgbImage.cpp b/src/image/TerrainrgbImage.cpp index 948ad13..db73f02 100644 --- a/src/image/TerrainrgbImage.cpp +++ b/src/image/TerrainrgbImage.cpp @@ -77,9 +77,6 @@ int TerrainrgbImage::get_line(uint8_t *buffer, int line) TerrainrgbImage::TerrainrgbImage(Image *image, Terrainrgb *Terrainrgb) : Image(image->get_width(), image->get_height(), 1, image->get_bbox()), source_image(image) { - // Il n'y aura application de la palette et modification des canaux que si - // - la palette n'est pas nulle et pas vide - // - l'image source est sur un canal if (source_image->get_channels() == 1) { channels = 3; diff --git a/src/style/Style.cpp b/src/style/Style.cpp index fd2c65c..9266bed 100644 --- a/src/style/Style.cpp +++ b/src/style/Style.cpp @@ -62,6 +62,7 @@ bool Style::parse(json11::Json& doc) { aspect = 0; estompage = 0; palette = 0; + terrainrgb = 0; input_nodata_value = NULL; output_nodata_value = NULL; @@ -106,10 +107,13 @@ bool Style::parse(json11::Json& doc) { legends.push_back(leg); } - palette = new Palette(doc["palette"].object_items()); - if (! palette->is_ok()) { - error_message = "Palette issue for style " + id + ": " + palette->get_error_message(); + if (doc["palette"].is_object()){ + palette = new Palette(doc["palette"].object_items()); + if (! palette->is_ok()) { + BOOST_LOG_TRIVIAL(warning) << "Palette"; + error_message = "Palette issue for style " + id + ": " + palette->get_error_message(); return false; + } } if (doc["estompage"].is_object()) { @@ -144,6 +148,14 @@ bool Style::parse(json11::Json& doc) { } } + if (doc["terrainrgb"].is_object()) { + terrainrgb = new Terrainrgb(doc["terrainrgb"].object_items()); + if (! terrainrgb->is_ok() || palette->is_ok()) { + error_message = "Terrainrgb issue for style " + id + ": " + terrainrgb->get_error_message(); + return false; + } + } + return true; } From ff85f0f62412b68940772c066625d346dcb61d6e Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Tue, 23 Sep 2025 17:37:26 +0200 Subject: [PATCH 06/31] ajout d'une valuer en cas de nodata --- include/rok4/style/Terrainrgb.h | 7 +++++++ src/style/Terrainrgb.cpp | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/rok4/style/Terrainrgb.h b/include/rok4/style/Terrainrgb.h index fbb8761..e4cb7b2 100644 --- a/include/rok4/style/Terrainrgb.h +++ b/include/rok4/style/Terrainrgb.h @@ -61,6 +61,13 @@ class Terrainrgb : public Configuration */ float step; + /** \~french + * \brief noData : valeur de nodata pour l'image source + ** \~english + * \brief noData : value of nodata for the source image + */ + float input_nodata_value; + /** * \~french * \brief Constructeurs avec des arguments diff --git a/src/style/Terrainrgb.cpp b/src/style/Terrainrgb.cpp index 17aea32..8f14d36 100644 --- a/src/style/Terrainrgb.cpp +++ b/src/style/Terrainrgb.cpp @@ -42,7 +42,7 @@ #include "byteswap.h" #include -Terrainrgb::Terrainrgb(json11::Json doc) : Configuration() +Terrainrgb::Terrainrgb(json11::Json doc) : Configuration(), input_nodata_value (-99999) { if (doc["min_elevation"].is_number()) From 84797eeb7d52102a16bbe150b15079cc6fa45478 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Wed, 24 Sep 2025 15:13:33 +0200 Subject: [PATCH 07/31] =?UTF-8?q?Ajout=20gestion=20de=20nodata=20qui=20cr?= =?UTF-8?q?=C3=A9ait=20une=20erreur=20de=20segmentation=20et=20nettoyage?= =?UTF-8?q?=20du=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rok4/style/Style.h | 23 ++++++++++++++++++++++- include/rok4/style/Terrainrgb.h | 7 +++++++ src/style/Style.cpp | 19 +++++++++++++++---- src/style/Terrainrgb.cpp | 2 +- 4 files changed, 45 insertions(+), 6 deletions(-) diff --git a/include/rok4/style/Style.h b/include/rok4/style/Style.h index 07e5fe2..387d954 100644 --- a/include/rok4/style/Style.h +++ b/include/rok4/style/Style.h @@ -298,7 +298,7 @@ private : return false; } - if (estompage_defined() || pente_defined() || aspect_defined()) { + if (estompage_defined() || pente_defined() || aspect_defined() || terrainrgb_defined()) { return false; } else { return true; @@ -427,6 +427,27 @@ private : inline Aspect* get_aspect() { return aspect; } + + /** + * \~french + * \brief Return vrai si le style est un terrainrgb + * \return bool + * \~english + * \brief Return true if the style is an rgb terrain + * \return bool + */ + inline bool terrainrgb_defined() { + return (terrainrgb != 0); + } + /** + * \~french + * \brief Retourne le terrainrgb + * \~english + * \brief Return rgb terrain + */ + inline Terrainrgb* get_terrainrgb() { + return terrainrgb; + } /** diff --git a/include/rok4/style/Terrainrgb.h b/include/rok4/style/Terrainrgb.h index e4cb7b2..cd6bcd5 100644 --- a/include/rok4/style/Terrainrgb.h +++ b/include/rok4/style/Terrainrgb.h @@ -68,6 +68,13 @@ class Terrainrgb : public Configuration */ float input_nodata_value; + /** \~french + * \brief noData : valeur de nodata pour l'image source + ** \~english + * \brief noData : value of nodata for the source image + */ + float terrainrgb_nodata_value; + /** * \~french * \brief Constructeurs avec des arguments diff --git a/src/style/Style.cpp b/src/style/Style.cpp index 9266bed..2b84428 100644 --- a/src/style/Style.cpp +++ b/src/style/Style.cpp @@ -110,7 +110,6 @@ bool Style::parse(json11::Json& doc) { if (doc["palette"].is_object()){ palette = new Palette(doc["palette"].object_items()); if (! palette->is_ok()) { - BOOST_LOG_TRIVIAL(warning) << "Palette"; error_message = "Palette issue for style " + id + ": " + palette->get_error_message(); return false; } @@ -150,12 +149,11 @@ bool Style::parse(json11::Json& doc) { if (doc["terrainrgb"].is_object()) { terrainrgb = new Terrainrgb(doc["terrainrgb"].object_items()); - if (! terrainrgb->is_ok() || palette->is_ok()) { + if (! terrainrgb->is_ok()) { error_message = "Terrainrgb issue for style " + id + ": " + terrainrgb->get_error_message(); return false; } } - return true; } @@ -165,6 +163,7 @@ Style::Style ( std::string path ) : Configuration(path) { estompage = 0; palette = 0; aspect = 0; + terrainrgb = 0; input_nodata_value = NULL; output_nodata_value = NULL; @@ -231,7 +230,12 @@ Style::Style ( std::string path ) : Configuration(path) { else if (pente_defined()) { input_nodata_value = new int[1]; input_nodata_value[0] = (int) pente->input_nodata_value; - } + } + else if (terrainrgb_defined()) { + input_nodata_value = new int[1]; + input_nodata_value[0] = (int) terrainrgb->input_nodata_value; + return; + } else if (palette && ! palette->is_empty()) { input_nodata_value = new int[1]; input_nodata_value[0] = (int) palette->get_colours_map()->begin()->first; @@ -265,6 +269,10 @@ Style::Style ( std::string path ) : Configuration(path) { output_nodata_value = new int[1]; output_nodata_value[0] = (int) pente->slope_nodata_value; } + else if (terrainrgb_defined()) { + output_nodata_value = new int[1]; + output_nodata_value[0] = (int) terrainrgb->terrainrgb_nodata_value; + } } Style::~Style() { @@ -280,6 +288,9 @@ Style::~Style() { if (aspect != 0) { delete aspect; } + if (terrainrgb != 0) { + delete terrainrgb; + } if (input_nodata_value != NULL) { delete[] input_nodata_value; } diff --git a/src/style/Terrainrgb.cpp b/src/style/Terrainrgb.cpp index 8f14d36..25e4e33 100644 --- a/src/style/Terrainrgb.cpp +++ b/src/style/Terrainrgb.cpp @@ -42,7 +42,7 @@ #include "byteswap.h" #include -Terrainrgb::Terrainrgb(json11::Json doc) : Configuration(), input_nodata_value (-99999) +Terrainrgb::Terrainrgb(json11::Json doc) : Configuration(), input_nodata_value (-99999), terrainrgb_nodata_value(-10000) { if (doc["min_elevation"].is_number()) From 472b30875e68aea20c58b0ebe64a45ad926437b0 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Wed, 24 Sep 2025 17:41:40 +0200 Subject: [PATCH 08/31] =?UTF-8?q?Suppression=20d'un=20return=20qui=20cassa?= =?UTF-8?q?it=20le=20processus=20au=20milieu=20en=20cas=20de=20terrainrgb?= =?UTF-8?q?=20et=20retour=20en=20arri=C3=A8re=20sur=20un=20test=20inutile?= =?UTF-8?q?=20pour=20palette?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/style/Style.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/style/Style.cpp b/src/style/Style.cpp index 2b84428..5446fa8 100644 --- a/src/style/Style.cpp +++ b/src/style/Style.cpp @@ -107,12 +107,10 @@ bool Style::parse(json11::Json& doc) { legends.push_back(leg); } - if (doc["palette"].is_object()){ - palette = new Palette(doc["palette"].object_items()); - if (! palette->is_ok()) { - error_message = "Palette issue for style " + id + ": " + palette->get_error_message(); - return false; - } + palette = new Palette(doc["palette"].object_items()); + if (! palette->is_ok()) { + error_message = "Palette issue for style " + id + ": " + palette->get_error_message(); + return false; } if (doc["estompage"].is_object()) { @@ -234,7 +232,6 @@ Style::Style ( std::string path ) : Configuration(path) { else if (terrainrgb_defined()) { input_nodata_value = new int[1]; input_nodata_value[0] = (int) terrainrgb->input_nodata_value; - return; } else if (palette && ! palette->is_empty()) { input_nodata_value = new int[1]; From fb2a9d4bfc696abae673fb3c12b16f9b37140b0c Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Tue, 30 Sep 2025 10:45:47 +0200 Subject: [PATCH 09/31] traitement de l'image correct --- include/rok4/style/Style.h | 11 +++++++--- src/image/TerrainrgbImage.cpp | 39 +++++++++++++++++------------------ src/style/Style.cpp | 6 ++++-- src/style/Terrainrgb.cpp | 11 +++++----- 4 files changed, 36 insertions(+), 31 deletions(-) diff --git a/include/rok4/style/Style.h b/include/rok4/style/Style.h index 387d954..0e560dd 100644 --- a/include/rok4/style/Style.h +++ b/include/rok4/style/Style.h @@ -225,7 +225,7 @@ private : * \~english \brief Style is allowed ? */ bool handle (int spp) { - if (estompage_defined() || pente_defined() || aspect_defined()) { + if (estompage_defined() || pente_defined() || aspect_defined() || terrainrgb_defined()) { return (spp == 1); } else { return true; @@ -243,7 +243,11 @@ private : } else { return 4; } - } else { + } + else if (terrainrgb_defined()){ + return 3; + } + else { if (estompage_defined() || pente_defined() || aspect_defined()) { return 1; } else { @@ -251,6 +255,7 @@ private : return orig_channels; } } + } /** @@ -258,7 +263,7 @@ private : * \~english \brief Which sample format after style */ SampleFormat::eSampleFormat get_sample_format (SampleFormat::eSampleFormat sf) { - if (palette && ! palette->is_empty()) { + if ((palette && ! palette->is_empty()) || terrainrgb_defined()) { return SampleFormat::UINT8; } else { return sf; diff --git a/src/image/TerrainrgbImage.cpp b/src/image/TerrainrgbImage.cpp index db73f02..1d2d3a8 100644 --- a/src/image/TerrainrgbImage.cpp +++ b/src/image/TerrainrgbImage.cpp @@ -75,7 +75,7 @@ int TerrainrgbImage::get_line(uint8_t *buffer, int line) } } -TerrainrgbImage::TerrainrgbImage(Image *image, Terrainrgb *Terrainrgb) : Image(image->get_width(), image->get_height(), 1, image->get_bbox()), source_image(image) +TerrainrgbImage::TerrainrgbImage(Image *image, Terrainrgb *terrainrgb) : Image(image->get_width(), image->get_height(), 1, image->get_bbox()), source_image(image), terrainrgb(terrainrgb) { if (source_image->get_channels() == 1) { @@ -85,35 +85,34 @@ TerrainrgbImage::TerrainrgbImage(Image *image, Terrainrgb *Terrainrgb) : Image(i { channels = image->get_channels(); } -} +} TerrainrgbImage::~TerrainrgbImage() { delete source_image; } -template -int TerrainrgbImage::_getline(T *buffer, int line) -{ - float *source = new float[source_image->get_width() * source_image->get_channels()]; - source_image->get_line(source, line); - switch (channels) - { - +template +int TerrainrgbImage::_getline ( T* buffer, int line ) { + float* source = new float[source_image->get_width() * source_image->get_channels()]; + source_image->get_line ( source, line ); + switch ( channels ) { case 3: - for (int i = 0; i < source_image->get_width(); i++) - { - int base = *buffer + terrainrgb->min_elevation / terrainrgb->step; - int red = abs(base / (256 * 256)) % 256; - int green = abs((base - red * 256 * 256) / 256) % 256; - int blue = abs(base - red * 256 * 256 - green * 256); - *(buffer + i * 3) = red; - *(buffer + i * 3 + 1) = green; - *(buffer + i * 3 + 2) = blue; + for (int i = 0; i < source_image->get_width() ; i++ ) { + + int base = (std::max((T) *(source+i), (T) terrainrgb->min_elevation) - terrainrgb->min_elevation) / terrainrgb->step; + int red = (base / (256 * 256) % 256); + int green = ((base - red * 256 * 256) / 256 % 256); + int blue = (base - red * 256 * 256 - green * 256); + * ( buffer+i*3 ) = (T) red; + * ( buffer+i*3+1 ) = (T) green; + * ( buffer+i*3+2 ) = (T) blue; } break; } + + delete[] source; - return width * sizeof(T) * channels; + return width * sizeof ( T ) * channels; } diff --git a/src/style/Style.cpp b/src/style/Style.cpp index 5446fa8..2b4535a 100644 --- a/src/style/Style.cpp +++ b/src/style/Style.cpp @@ -267,8 +267,10 @@ Style::Style ( std::string path ) : Configuration(path) { output_nodata_value[0] = (int) pente->slope_nodata_value; } else if (terrainrgb_defined()) { - output_nodata_value = new int[1]; - output_nodata_value[0] = (int) terrainrgb->terrainrgb_nodata_value; + output_nodata_value = new int[3]; + output_nodata_value[0] = 0; + output_nodata_value[1] = 0; + output_nodata_value[2] = 0; } } diff --git a/src/style/Terrainrgb.cpp b/src/style/Terrainrgb.cpp index 25e4e33..1fdbff3 100644 --- a/src/style/Terrainrgb.cpp +++ b/src/style/Terrainrgb.cpp @@ -42,7 +42,7 @@ #include "byteswap.h" #include -Terrainrgb::Terrainrgb(json11::Json doc) : Configuration(), input_nodata_value (-99999), terrainrgb_nodata_value(-10000) +Terrainrgb::Terrainrgb(json11::Json doc) : Configuration() { if (doc["min_elevation"].is_number()) @@ -51,18 +51,17 @@ Terrainrgb::Terrainrgb(json11::Json doc) : Configuration(), input_nodata_value ( } else { - BOOST_LOG_TRIVIAL(warning) << "Wrong format for terrainrgb, terrainrgb ignored"; - return; + min_elevation = -10000; } if (doc["step"].is_number()) { - min_elevation = doc["step"].number_value(); + step = doc["step"].number_value(); } else { - BOOST_LOG_TRIVIAL(warning) << "Wrong format for terrainrgb, terrainrgb ignored"; - return; + step = 0.1; } + input_nodata_value=min_elevation; } Terrainrgb::~Terrainrgb() From 70a31342d5ca0efb2b1ea5cc667645eec74c1ee0 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Tue, 30 Sep 2025 13:53:45 +0200 Subject: [PATCH 10/31] =?UTF-8?q?Ajout=20de=20contrainte=20sur=20les=20con?= =?UTF-8?q?ditions=20d'un=20style=20terrainrgb=20et=20ajout=20d'un=20test?= =?UTF-8?q?=20avant=20la=20cr=C3=A9ation=20d'une=20palette?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/style/Style.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/style/Style.cpp b/src/style/Style.cpp index 2b4535a..7b6e7f5 100644 --- a/src/style/Style.cpp +++ b/src/style/Style.cpp @@ -107,10 +107,12 @@ bool Style::parse(json11::Json& doc) { legends.push_back(leg); } - palette = new Palette(doc["palette"].object_items()); - if (! palette->is_ok()) { - error_message = "Palette issue for style " + id + ": " + palette->get_error_message(); - return false; + if (doc["palette"].is_object()) { + palette = new Palette(doc["palette"].object_items()); + if (! palette->is_ok()) { + error_message = "Palette issue for style " + id + ": " + palette->get_error_message(); + return false; + } } if (doc["estompage"].is_object()) { @@ -146,6 +148,10 @@ bool Style::parse(json11::Json& doc) { } if (doc["terrainrgb"].is_object()) { + if (estompage != 0 || pente != 0 || aspect !=0 || palette !=0) { + error_message = "Style " + id + " define exposition, estompage, pente or palette rules"; + return false; + } terrainrgb = new Terrainrgb(doc["terrainrgb"].object_items()); if (! terrainrgb->is_ok()) { error_message = "Terrainrgb issue for style " + id + ": " + terrainrgb->get_error_message(); @@ -255,8 +261,8 @@ Style::Style ( std::string path ) : Configuration(path) { } } else if (estompage_defined()) { - output_nodata_value = new int[1]; - output_nodata_value[0] = (int) estompage->estompage_nodata_value; + output_nodata_value = new int[1]; + output_nodata_value[0] = (int) estompage->estompage_nodata_value; } else if (aspect_defined()) { output_nodata_value = new int[1]; @@ -268,9 +274,9 @@ Style::Style ( std::string path ) : Configuration(path) { } else if (terrainrgb_defined()) { output_nodata_value = new int[3]; - output_nodata_value[0] = 0; - output_nodata_value[1] = 0; - output_nodata_value[2] = 0; + output_nodata_value[0] = 0; + output_nodata_value[1] = 0; + output_nodata_value[2] = 0; } } From 095e1f93e7d1a8e4c0ebc99d2ee2018054d4515c Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Tue, 30 Sep 2025 13:54:05 +0200 Subject: [PATCH 11/31] Ajout fonction palette_defined() --- include/rok4/style/Style.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/rok4/style/Style.h b/include/rok4/style/Style.h index 0e560dd..2a118f2 100644 --- a/include/rok4/style/Style.h +++ b/include/rok4/style/Style.h @@ -358,6 +358,17 @@ private : return &legends; } + /** + * \~french + * \brief Détermine si le style décrit une table de correspondance + * \return true si oui + * \~english + * \brief Determine if the style describe a lookup table + * \return true if it does + */ + inline bool palette_defined() { + return (palette != 0); + } /** * \~french * \brief Retourne la table de correspondance From 5d8509f4f2bd8bf8ac91eeb513acafde1d010482 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Tue, 30 Sep 2025 14:41:30 +0200 Subject: [PATCH 12/31] Ajout de commentaire et format du code --- include/rok4/style/Style.h | 2 +- include/rok4/style/Terrainrgb.h | 8 +++--- src/image/TerrainrgbImage.cpp | 47 +++++++++++---------------------- src/style/Terrainrgb.cpp | 17 ++++-------- 4 files changed, 25 insertions(+), 49 deletions(-) diff --git a/include/rok4/style/Style.h b/include/rok4/style/Style.h index 2a118f2..f41a2a5 100644 --- a/include/rok4/style/Style.h +++ b/include/rok4/style/Style.h @@ -164,7 +164,7 @@ private : */ Estompage* estompage; /** - * \~french \brief Définit si un terrainrgb doit être appliqué + * \~french \brief Définit si un calcul de terrainrgb doit être appliqué * \~english \brief Define wether the server must compute a RGB terrain */ Terrainrgb* terrainrgb; diff --git a/include/rok4/style/Terrainrgb.h b/include/rok4/style/Terrainrgb.h index cd6bcd5..42abeba 100644 --- a/include/rok4/style/Terrainrgb.h +++ b/include/rok4/style/Terrainrgb.h @@ -55,9 +55,9 @@ class Terrainrgb : public Configuration int min_elevation; /** \~french - * \brief step : écart d'altitude entre deux couleurs différentes + * \brief step : résolution verticale ** \~english - * \brief step : altitude difference between two different colors + * \brief step : vertical resolution */ float step; @@ -69,9 +69,9 @@ class Terrainrgb : public Configuration float input_nodata_value; /** \~french - * \brief noData : valeur de nodata pour l'image source + * \brief noData : valeur de nodata pour le terrainrgb ** \~english - * \brief noData : value of nodata for the source image + * \brief noData : value of nodata for the RGB terrain */ float terrainrgb_nodata_value; diff --git a/src/image/TerrainrgbImage.cpp b/src/image/TerrainrgbImage.cpp index 1d2d3a8..fb688c7 100644 --- a/src/image/TerrainrgbImage.cpp +++ b/src/image/TerrainrgbImage.cpp @@ -39,56 +39,39 @@ #include -int TerrainrgbImage::get_line(float *buffer, int line) -{ - if (source_image->get_channels() == 1) - { +int TerrainrgbImage::get_line(float *buffer, int line) { + if (source_image->get_channels() == 1) { return _getline(buffer, line); - } - else - { + } else { return source_image->get_line(buffer, line); } } -int TerrainrgbImage::get_line(uint16_t *buffer, int line) -{ - if (source_image->get_channels() == 1) - { +int TerrainrgbImage::get_line(uint16_t *buffer, int line) { + if (source_image->get_channels() == 1) { return _getline(buffer, line); - } - else - { + } else { return source_image->get_line(buffer, line); } } -int TerrainrgbImage::get_line(uint8_t *buffer, int line) -{ - if (source_image->get_channels() == 1) - { +int TerrainrgbImage::get_line(uint8_t *buffer, int line) { + if (source_image->get_channels() == 1) { return _getline(buffer, line); - } - else - { + } else { return source_image->get_line(buffer, line); } } -TerrainrgbImage::TerrainrgbImage(Image *image, Terrainrgb *terrainrgb) : Image(image->get_width(), image->get_height(), 1, image->get_bbox()), source_image(image), terrainrgb(terrainrgb) -{ - if (source_image->get_channels() == 1) - { +TerrainrgbImage::TerrainrgbImage(Image *image, Terrainrgb *terrainrgb) : Image(image->get_width(), image->get_height(), 1, image->get_bbox()), source_image(image), terrainrgb(terrainrgb) { + if (source_image->get_channels() == 1) { channels = 3; - } - else - { + } else { channels = image->get_channels(); } } -TerrainrgbImage::~TerrainrgbImage() -{ +TerrainrgbImage::~TerrainrgbImage() { delete source_image; } @@ -100,10 +83,12 @@ int TerrainrgbImage::_getline ( T* buffer, int line ) { case 3: for (int i = 0; i < source_image->get_width() ; i++ ) { + // découpage de l'altitude en RGB suivant la formule suivante : height = min_elevation + ((Red * 256 * 256 + Green * 256 + Blue) * step) int base = (std::max((T) *(source+i), (T) terrainrgb->min_elevation) - terrainrgb->min_elevation) / terrainrgb->step; int red = (base / (256 * 256) % 256); int green = ((base - red * 256 * 256) / 256 % 256); int blue = (base - red * 256 * 256 - green * 256); + * ( buffer+i*3 ) = (T) red; * ( buffer+i*3+1 ) = (T) green; * ( buffer+i*3+2 ) = (T) blue; @@ -111,8 +96,6 @@ int TerrainrgbImage::_getline ( T* buffer, int line ) { break; } - - delete[] source; return width * sizeof ( T ) * channels; } diff --git a/src/style/Terrainrgb.cpp b/src/style/Terrainrgb.cpp index 1fdbff3..ee64347 100644 --- a/src/style/Terrainrgb.cpp +++ b/src/style/Terrainrgb.cpp @@ -45,25 +45,18 @@ Terrainrgb::Terrainrgb(json11::Json doc) : Configuration() { - if (doc["min_elevation"].is_number()) - { + if (doc["min_elevation"].is_number()) { min_elevation = doc["min_elevation"].number_value(); - } - else - { + } else { min_elevation = -10000; } - if (doc["step"].is_number()) - { + if (doc["step"].is_number()) { step = doc["step"].number_value(); - } - else - { + } else { step = 0.1; } input_nodata_value=min_elevation; } -Terrainrgb::~Terrainrgb() -{ +Terrainrgb::~Terrainrgb() { } From 8bac916924b3a83bec143bbe5765b75edb616005 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Tue, 30 Sep 2025 14:55:49 +0200 Subject: [PATCH 13/31] =?UTF-8?q?Mise=20=C3=A0=20jour=20changelog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e9362e..d2d02f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,13 @@ Le format est basé sur [Keep a Changelog](https://keepachangelog.com/) et ce pr - `Terrainrgb` : Ajout d'un style terrainrgb pour transformer les MNT en format Terrain RGB. - `TerrainrgbImage` : Ajout du processus de traitement du style Terrainrgb. +- `Style` : Ajout d'une fonction permettant de savoir si une palette existe ou non. +- Ajout du traitement en cas de style terrainrgb. Il doit être l'unique style déclaré pour fonctionner. ### Changed + +- `Style` : Vérification de l'existance d'un bloc palette dans le json de style avant la création d'un objet palette. Ce changement nécessite la vérification de l'existance d'une palette qui n'était pas vérifié avant. + ### Deprecated ### Removed ### Fixed From 2eaf5b41e947fb6aa94eb1c3250801056b9f3fa3 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Tue, 30 Sep 2025 15:27:25 +0200 Subject: [PATCH 14/31] Documentation global des fichiers --- include/rok4/image/TerrainrgbImage.h | 8 ++++++++ include/rok4/style/Terrainrgb.h | 9 +++++++++ src/image/TerrainrgbImage.cpp | 7 +++++++ src/style/Terrainrgb.cpp | 8 ++++++++ 4 files changed, 32 insertions(+) diff --git a/include/rok4/image/TerrainrgbImage.h b/include/rok4/image/TerrainrgbImage.h index 2a3bab7..dcd333a 100644 --- a/include/rok4/image/TerrainrgbImage.h +++ b/include/rok4/image/TerrainrgbImage.h @@ -35,6 +35,14 @@ * knowledge of the CeCILL-C license and that you accept its terms. */ +/** + * \file TerrainrgbImage.h + ** \~french + * \brief D�finition de la classe TerrainrgbImage + ** \~english + * \brief Define class TerrainrgbImage + */ + #pragma once #include "rok4/image/Image.h" diff --git a/include/rok4/style/Terrainrgb.h b/include/rok4/style/Terrainrgb.h index 42abeba..e809229 100644 --- a/include/rok4/style/Terrainrgb.h +++ b/include/rok4/style/Terrainrgb.h @@ -35,6 +35,15 @@ * knowledge of the CeCILL-C license and that you accept its terms. */ + /** + * \file Terrainrgb.h + ** \~french + * \brief D�finition de la classe Terrainrgb + ** \~english + * \brief Define class Terrainrgb + */ + + #pragma once #include "rok4/utils/Configuration.h" diff --git a/src/image/TerrainrgbImage.cpp b/src/image/TerrainrgbImage.cpp index fb688c7..b1178e6 100644 --- a/src/image/TerrainrgbImage.cpp +++ b/src/image/TerrainrgbImage.cpp @@ -35,6 +35,13 @@ * knowledge of the CeCILL-C license and that you accept its terms. */ + /** + * \file TerrainrgbImage.cpp + * \~french + * \brief Implémentation de la classe TerrainrgbImage permettant l'application du terrainrgb à une image. + * \~english + * \brief Implement the TerrainrgbImage Class handling computing of Terrainrgb style to an image. + */ #include "image/TerrainrgbImage.h" #include diff --git a/src/style/Terrainrgb.cpp b/src/style/Terrainrgb.cpp index ee64347..e81eb8a 100644 --- a/src/style/Terrainrgb.cpp +++ b/src/style/Terrainrgb.cpp @@ -35,6 +35,14 @@ * knowledge of the CeCILL-C license and that you accept its terms. */ + /** + * \file Terrainrgb.cpp + * \~french + * \brief Implémentation de la classe Terrainrgb modélisant un terrainrgb. + * \~english + * \brief Implement the Terrainrgb Class handling terrainrgb definition. + */ + #include "style/Terrainrgb.h" #include #include "zlib.h" From 7558d2daee73fca94d309062e5d4e73597eda306 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Tue, 30 Sep 2025 15:34:33 +0200 Subject: [PATCH 15/31] Correction faute documentation --- src/style/Terrainrgb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/style/Terrainrgb.cpp b/src/style/Terrainrgb.cpp index e81eb8a..c0992d8 100644 --- a/src/style/Terrainrgb.cpp +++ b/src/style/Terrainrgb.cpp @@ -40,7 +40,7 @@ * \~french * \brief Implémentation de la classe Terrainrgb modélisant un terrainrgb. * \~english - * \brief Implement the Terrainrgb Class handling terrainrgb definition. + * \brief Implement the Terrainrgb Class handling RGB terrain definition. */ #include "style/Terrainrgb.h" From 90a50b5774ec2d73849f5099c67aa25d6905645c Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Tue, 30 Sep 2025 15:43:46 +0200 Subject: [PATCH 16/31] =?UTF-8?q?Mise=20=C3=A0=20jour=20du=20changelog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2d02f7..031f648 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,12 +14,12 @@ Le format est basé sur [Keep a Changelog](https://keepachangelog.com/) et ce pr - Ajout du traitement en cas de style terrainrgb. Il doit être l'unique style déclaré pour fonctionner. ### Changed - -- `Style` : Vérification de l'existance d'un bloc palette dans le json de style avant la création d'un objet palette. Ce changement nécessite la vérification de l'existance d'une palette qui n'était pas vérifié avant. - ### Deprecated ### Removed ### Fixed + +- `Style` : Vérification de l'existance d'un bloc palette dans le json de style avant la création d'un objet palette. Ce changement nécessite la vérification de l'existance d'une palette qui n'était pas vérifié avant. + ### Security ## [2.0.6] - 2025-09-11 From 978ca447408da4dc32a1451c1ab6eb5dd8ca916c Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Mon, 3 Nov 2025 11:25:34 +0100 Subject: [PATCH 17/31] =?UTF-8?q?Ajout=20v=C3=A9rification=20acc=C3=A8s=20?= =?UTF-8?q?=C3=A0=20palette=20avant=20utilisation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/image/PaletteImage.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/image/PaletteImage.cpp b/src/image/PaletteImage.cpp index 4843964..d4beba8 100644 --- a/src/image/PaletteImage.cpp +++ b/src/image/PaletteImage.cpp @@ -40,7 +40,7 @@ #include int PaletteImage::get_line ( float* buffer, int line ) { - if ( source_image->get_channels() == 1 && ! palette->is_empty() ) { + if ( source_image->get_channels() == 1 && palette != NULL && ! palette->is_empty() ) { return _getline ( buffer, line ); } else { return source_image->get_line ( buffer, line ); @@ -48,7 +48,7 @@ int PaletteImage::get_line ( float* buffer, int line ) { } int PaletteImage::get_line ( uint16_t* buffer, int line ) { - if ( source_image->get_channels() == 1 && ! palette->is_empty() ) { + if ( source_image->get_channels() == 1 && palette != NULL && ! palette->is_empty() ) { return _getline ( buffer, line ); } else { return source_image->get_line ( buffer, line ); @@ -56,7 +56,7 @@ int PaletteImage::get_line ( uint16_t* buffer, int line ) { } int PaletteImage::get_line ( uint8_t* buffer, int line ) { - if ( source_image->get_channels() == 1 && ! palette->is_empty() ) { + if ( source_image->get_channels() == 1 && palette != NULL && ! palette->is_empty() ) { return _getline ( buffer, line ); } else { return source_image->get_line ( buffer, line ); From 4ed607035b1997baa254b85ababb8ecaeef77861 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Tue, 4 Nov 2025 18:23:34 +0100 Subject: [PATCH 18/31] Correction calcul incorrect dans l'utilisation par server --- include/rok4/style/Terrainrgb.h | 2 +- src/image/TerrainrgbImage.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/rok4/style/Terrainrgb.h b/include/rok4/style/Terrainrgb.h index e809229..58f80ab 100644 --- a/include/rok4/style/Terrainrgb.h +++ b/include/rok4/style/Terrainrgb.h @@ -61,7 +61,7 @@ class Terrainrgb : public Configuration ** \~english * \brief min_elevation : minimum elevation from which the color is calculated */ - int min_elevation; + float min_elevation; /** \~french * \brief step : résolution verticale diff --git a/src/image/TerrainrgbImage.cpp b/src/image/TerrainrgbImage.cpp index b1178e6..f7f4167 100644 --- a/src/image/TerrainrgbImage.cpp +++ b/src/image/TerrainrgbImage.cpp @@ -91,7 +91,7 @@ int TerrainrgbImage::_getline ( T* buffer, int line ) { for (int i = 0; i < source_image->get_width() ; i++ ) { // découpage de l'altitude en RGB suivant la formule suivante : height = min_elevation + ((Red * 256 * 256 + Green * 256 + Blue) * step) - int base = (std::max((T) *(source+i), (T) terrainrgb->min_elevation) - terrainrgb->min_elevation) / terrainrgb->step; + int base = (std::max( *(source+i), terrainrgb->min_elevation) - terrainrgb->min_elevation) / terrainrgb->step; int red = (base / (256 * 256) % 256); int green = ((base - red * 256 * 256) / 256 % 256); int blue = (base - red * 256 * 256 - green * 256); From 9d34a09227d334993a380b18e25462c94a3b769e Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Tue, 4 Nov 2025 18:23:54 +0100 Subject: [PATCH 19/31] Ajout fonction print pour terrainrgbImage --- include/rok4/image/TerrainrgbImage.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/rok4/image/TerrainrgbImage.h b/include/rok4/image/TerrainrgbImage.h index dcd333a..1690aa9 100644 --- a/include/rok4/image/TerrainrgbImage.h +++ b/include/rok4/image/TerrainrgbImage.h @@ -63,4 +63,17 @@ class TerrainrgbImage : public Image virtual int get_line(uint8_t *buffer, int line); TerrainrgbImage(Image *image, Terrainrgb *terrainrgb); virtual ~TerrainrgbImage(); + /** \~french + * \brief Sortie des informations sur l'image reprojetée + ** \~english + * \brief Reprojected image description output + */ + void print() { + BOOST_LOG_TRIVIAL(info) << "" ; + BOOST_LOG_TRIVIAL(info) << "--------- TerrainrgbImage -----------" ; + Image::print(); + BOOST_LOG_TRIVIAL(info) << "\t- Min elevation " << terrainrgb->min_elevation ; + BOOST_LOG_TRIVIAL(info) << "\t- Step = " << terrainrgb->step ; + BOOST_LOG_TRIVIAL(info) << "" ; + } }; From 6f9983053afecff334fce6f3cf000d8b9d35196f Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Wed, 19 Nov 2025 14:32:46 +0100 Subject: [PATCH 20/31] =?UTF-8?q?Ajout=20de=20la=20classe=20StyledImage=20?= =?UTF-8?q?pour=20g=C3=A9rer=20l'application=20des=20styles=20=C3=A0=20l'i?= =?UTF-8?q?mage=20au=20sein=20de=20la=20lib=20core?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rok4/image/StyledImage.h | 78 +++++++++++++++++++++++++++ src/image/StyledImage.cpp | 93 ++++++++++++++++++++++++++++++++ 2 files changed, 171 insertions(+) create mode 100644 include/rok4/image/StyledImage.h create mode 100644 src/image/StyledImage.cpp diff --git a/include/rok4/image/StyledImage.h b/include/rok4/image/StyledImage.h new file mode 100644 index 0000000..3c48f7b --- /dev/null +++ b/include/rok4/image/StyledImage.h @@ -0,0 +1,78 @@ +/* + * Copyright © (2011) Institut national de l'information + * géographique et forestière + * + * Géoportail SAV + * + * This software is a computer program whose purpose is to publish geographic + * data using OGC WMS and WMTS protocol. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * + * knowledge of the CeCILL-C license and that you accept its terms. + */ + +/** + * \file TerrainrgbImage.h + ** \~french + * \brief D�finition de la classe TerrainrgbImage + ** \~english + * \brief Define class TerrainrgbImage + */ + +#pragma once + +#include "rok4/image/Image.h" +#include "rok4/image/EstompageImage.h" +#include "rok4/image/PaletteImage.h" +#include "rok4/image/PenteImage.h" +#include "rok4/image/AspectImage.h" +#include "rok4/image/TerrainrgbImage.h" +#include "rok4/style/Style.h" + +class StyledImage : public Image +{ +public: + Image* styled_image; + + + virtual int get_line(float *buffer, int line); + virtual int get_line(uint16_t *buffer, int line); + virtual int get_line(uint8_t *buffer, int line); + StyledImage(Image* image, Style *style); + virtual ~StyledImage(); + /** \~french + * \brief Sortie des informations sur l'image reprojetée + ** \~english + * \brief Reprojected image description output + */ + void print() { + BOOST_LOG_TRIVIAL(info) << "" ; + BOOST_LOG_TRIVIAL(info) << "--------- StyledImage -----------" ; + Image::print(); + BOOST_LOG_TRIVIAL(info) << "" ; + } +}; diff --git a/src/image/StyledImage.cpp b/src/image/StyledImage.cpp new file mode 100644 index 0000000..679be39 --- /dev/null +++ b/src/image/StyledImage.cpp @@ -0,0 +1,93 @@ +/* + * Copyright © (2011) Institut national de l'information + * géographique et forestière + * + * Géoportail SAV + * + * This software is a computer program whose purpose is to publish geographic + * data using OGC WMS and WMTS protocol. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * + * knowledge of the CeCILL-C license and that you accept its terms. + */ + + /** + * \file TerrainrgbImage.cpp + * \~french + * \brief Implémentation de la classe TerrainrgbImage permettant l'application du terrainrgb à une image. + * \~english + * \brief Implement the TerrainrgbImage Class handling computing of Terrainrgb style to an image. + */ +#include "image/StyledImage.h" +#include + +int StyledImage::get_line(float *buffer, int line) { + return styled_image->get_line(buffer, line); +} + +int StyledImage::get_line(uint16_t *buffer, int line) { + return styled_image->get_line(buffer, line); +} + +int StyledImage::get_line(uint8_t *buffer, int line) { + return styled_image->get_line(buffer, line); +} + +StyledImage::StyledImage(Image *input_images, Style *style) :Image(input_images->get_width(), input_images->get_height(), 1, input_images->get_bbox()) { + Image* mid_image = NULL; + styled_image = input_images; + + if (style->estompage_defined()) { + mid_image = new EstompageImage (input_images, style->get_estompage()); + } + else if (style->pente_defined()) { + mid_image = new PenteImage (input_images, style->get_pente()); + } + else if (style->aspect_defined()) { + mid_image = new AspectImage (input_images, style->get_aspect()) ; + } + else if (style->terrainrgb_defined()) { + mid_image = new TerrainrgbImage (input_images, style->get_terrainrgb()) ; + } + if (style->palette_defined()){ + if ( styled_image->get_channels() == 1 && ! ( style->get_palette()->is_empty() ) ) { + if (mid_image != NULL) { + styled_image = new PaletteImage ( mid_image , style->get_palette() ); + } else { + styled_image = new PaletteImage ( input_images , style->get_palette() ); + } + } + }else { + if (mid_image != NULL) { + styled_image = mid_image; + } + } +} + +StyledImage::~StyledImage() { + delete styled_image; +} From c66a55521c94693fbda887e2edaa50903d9c644c Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Wed, 19 Nov 2025 14:42:24 +0100 Subject: [PATCH 21/31] =?UTF-8?q?Mise=20=C3=A0=20jour=20changelog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a3fa64..2dc59aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Le format est basé sur [Keep a Changelog](https://keepachangelog.com/) et ce pr - `TerrainrgbImage` : Ajout du processus de traitement du style Terrainrgb. - `Style` : Ajout d'une fonction permettant de savoir si une palette existe ou non. - Ajout du traitement en cas de style terrainrgb. Il doit être l'unique style déclaré pour fonctionner. +- `StyledImage` : Récupération de l'affectation du style au sein de la lib core-cpp. ### Changed From f9b5cab186c9cfd93dd649e32de21727dd310810 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Wed, 3 Dec 2025 17:23:12 +0100 Subject: [PATCH 22/31] =?UTF-8?q?Ajout=20de=20v=C3=A9rification=20pour=20l?= =?UTF-8?q?'application=20des=20styles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rok4/style/Style.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/include/rok4/style/Style.h b/include/rok4/style/Style.h index 5f483a2..f1667c6 100644 --- a/include/rok4/style/Style.h +++ b/include/rok4/style/Style.h @@ -239,15 +239,25 @@ private : */ int get_channels (int orig_channels) { if (palette && ! palette->is_empty()) { - if (palette->is_no_alpha()) { - return 3; - } else { - return 4; + if (orig_channels ==1){ + if (palette->is_no_alpha()) { + return 3; + } else { + return 4; + } + } + else { + return orig_channels; } } else if (terrainrgb_defined()){ + if (orig_channels ==1){ return 3; } + else { + return orig_channels; + } + } else { if (estompage_defined() || pente_defined() || aspect_defined()) { return 1; From 69b02a897937a4d9074c38d53d7c2c423d4a208a Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Wed, 3 Dec 2025 17:23:42 +0100 Subject: [PATCH 23/31] =?UTF-8?q?correction=20mauvaise=20information=20ren?= =?UTF-8?q?voy=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/image/TerrainrgbImage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/image/TerrainrgbImage.cpp b/src/image/TerrainrgbImage.cpp index f7f4167..85a109b 100644 --- a/src/image/TerrainrgbImage.cpp +++ b/src/image/TerrainrgbImage.cpp @@ -74,7 +74,7 @@ TerrainrgbImage::TerrainrgbImage(Image *image, Terrainrgb *terrainrgb) : Image(i if (source_image->get_channels() == 1) { channels = 3; } else { - channels = image->get_channels(); + channels = source_image->get_channels(); } } From 4ec5d637d5236099b81d80d9a4115af8a10de381 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Wed, 3 Dec 2025 17:24:43 +0100 Subject: [PATCH 24/31] =?UTF-8?q?Modification=20de=20styledImage=20pour=20?= =?UTF-8?q?prendre=20les=20fonctionnalit=C3=A9s=20des=20autres=20images=20?= =?UTF-8?q?styles.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rok4/image/StyledImage.h | 82 +++++- src/image/StyledImage.cpp | 490 +++++++++++++++++++++++++++++-- 2 files changed, 548 insertions(+), 24 deletions(-) diff --git a/include/rok4/image/StyledImage.h b/include/rok4/image/StyledImage.h index 3c48f7b..3d87604 100644 --- a/include/rok4/image/StyledImage.h +++ b/include/rok4/image/StyledImage.h @@ -55,14 +55,90 @@ class StyledImage : public Image { -public: - Image* styled_image; +private: + template + int _getline(T *buffer, int line); + Image *source_image; + Style *style; + /** \~french + * \brief Résolution de l'image en X, en mètre + ** \~english + * \brief Resolution of the image (X), in meter + */ + float resxmeter; + + /** \~french + * \brief Résolution de l'image en Y, en mètre + ** \~english + * \brief Resolution of the image (Y), in meter + */ + float resymeter; + + /** \~french + * \brief Nombre de ligne en mémoire + ** \~english + * \brief Memorize lines number + */ + int memorized_source_lines; + + /** \~french + * \brief Buffer contenant les lignes sources + ** \~english + * \brief Source lines memory buffer + */ + float* source_lines_buffer; + + /** \~french + * \brief Numéros des lignes en mémoire + ** \~english + * \brief Memorized lines indexes + */ + int* source_lines; + + /** \~french + * \brief Matrice de convolution + ** \~english + * \brief Convolution matrix + */ + float matrix[9]; + + /** \~french + * \brief Résolution de l'image d'origine et donc finale + ** \~english + * \brief Resolution of the image + */ + float resolution; + /** \~french + * \brief Booléen précisant l'utilisation de buffer pour les traitements multi-lignes + ** \~english + * \brief Booleen that indicate if buffers are used for multi-line processes + */ + bool multi_line_buffer; + + StyledImage(Image* image, Style *style, int offset); +public: virtual int get_line(float *buffer, int line); virtual int get_line(uint16_t *buffer, int line); virtual int get_line(uint8_t *buffer, int line); - StyledImage(Image* image, Style *style); + + + /** \~french + * \brief Teste et calcule les caractéristiques d'une image stylisée et crée un objet StyledImage + * \details Largeur, hauteur, nombre de canaux et bbox sont déduits des composantes de l'image source et des paramètres. On vérifie la superposabilité des images sources. + * \param[in] input_image image source + * \param[in] input_style style source + * \return un pointeur d'objet StyledImage, NULL en cas d'erreur + ** \~english + * \brief Check and calculate styled image components and create an StyledImage object + * \details Height, width, samples' number and bbox are deduced from source image's components and parameters. We check if source images are superimpose. + * \param[in] input_image source images + * \param[in] input_style nodata value + * \return a StyledImage object pointer, NULL if error + */ + static StyledImage* create ( Image* input_image, Style* input_style ); + virtual ~StyledImage(); /** \~french * \brief Sortie des informations sur l'image reprojetée diff --git a/src/image/StyledImage.cpp b/src/image/StyledImage.cpp index 679be39..a51591b 100644 --- a/src/image/StyledImage.cpp +++ b/src/image/StyledImage.cpp @@ -35,7 +35,7 @@ * knowledge of the CeCILL-C license and that you accept its terms. */ - /** +/** * \file TerrainrgbImage.cpp * \~french * \brief Implémentation de la classe TerrainrgbImage permettant l'application du terrainrgb à une image. @@ -46,48 +46,496 @@ #include int StyledImage::get_line(float *buffer, int line) { - return styled_image->get_line(buffer, line); + if (style != NULL && !style->is_identity()) { + return _getline(buffer, line); + } + else { + return source_image->get_line(buffer, line); + } } int StyledImage::get_line(uint16_t *buffer, int line) { - return styled_image->get_line(buffer, line); + if (style != NULL && !style->is_identity()) { + return _getline(buffer, line); + } + else { + return source_image->get_line(buffer, line); + } } int StyledImage::get_line(uint8_t *buffer, int line) { - return styled_image->get_line(buffer, line); + if (style != NULL && !style->is_identity()) { + return _getline(buffer, line); + } + else { + return source_image->get_line(buffer, line); + } } -StyledImage::StyledImage(Image *input_images, Style *style) :Image(input_images->get_width(), input_images->get_height(), 1, input_images->get_bbox()) { - Image* mid_image = NULL; - styled_image = input_images; +StyledImage::StyledImage(Image *input_image, Style *input_style, int offset) : Image(input_image->get_width() - offset, input_image->get_height() - offset, input_style->get_channels(input_image->get_channels()), input_image->get_bbox()), multi_line_buffer(false) { + style = input_style; + source_image = input_image; - if (style->estompage_defined()) { - mid_image = new EstompageImage (input_images, style->get_estompage()); + if (style->estompage_defined()){ + // On réduit la bbox d'un pixel de chaque côté + BoundingBox bb = source_image->get_bbox(); + bb.xmin += source_image->get_resx(); + bb.ymin += source_image->get_resy(); + bb.xmax -= source_image->get_resx(); + bb.ymax -= source_image->get_resy(); + set_bbox(bb); + + set_crs(source_image->get_crs()); + + // On calcule une seule fois la résolution en mètre + resxmeter = get_resx(true); + resymeter = get_resy(true); + + // Buffer de lignes sources + memorized_source_lines = 3; + + source_lines = new int[memorized_source_lines]; + for (int i = 0; i < memorized_source_lines; i++) { + source_lines[i] = -1; + } + source_lines_buffer = new float[source_image->get_width() * memorized_source_lines]; } + else if (style->pente_defined()) { - mid_image = new PenteImage (input_images, style->get_pente()); + // On réduit la bbox d'un pixel de chaque côté + BoundingBox bb = source_image->get_bbox(); + bb.xmin += source_image->get_resx(); + bb.ymin += source_image->get_resy(); + bb.xmax -= source_image->get_resx(); + bb.ymax -= source_image->get_resy(); + set_bbox(bb); + + set_crs(source_image->get_crs()); + + // On calcule une seule fois la résolution en mètre + resxmeter = get_resx(true); + resymeter = get_resy(true); + + // Buffer de lignes sources + memorized_source_lines = 3; + + source_lines = new int[memorized_source_lines]; + for (int i = 0; i < memorized_source_lines; i++) { + source_lines[i] = -1; + } + source_lines_buffer = new float[source_image->get_width() * memorized_source_lines]; } + else if (style->aspect_defined()) { - mid_image = new AspectImage (input_images, style->get_aspect()) ; + resolution = (input_image->get_mean_resolution()); + + // On réduit la bbox d'un pixel de chaque côté + BoundingBox bb = source_image->get_bbox(); + bb.xmin += source_image->get_resx(); + bb.ymin += source_image->get_resy(); + bb.xmax -= source_image->get_resx(); + bb.ymax -= source_image->get_resy(); + set_bbox(bb); + + set_crs(source_image->get_crs()); + + // Buffer de lignes sources + memorized_source_lines = 3; + + source_lines = new int[memorized_source_lines]; + for (int i = 0; i < memorized_source_lines; i++) { + source_lines[i] = -1; + } + source_lines_buffer = new float[source_image->get_width() * memorized_source_lines]; + + matrix[0] = 1 / (8.0*resolution) ; + matrix[1] = 2 / (8.0*resolution) ; + matrix[2] = 1 / (8.0*resolution) ; + + matrix[3] = 2 / (8.0*resolution) ; + matrix[4] = 0 ; + matrix[5] = 2 / (8.0*resolution) ; + + matrix[6] = 1 / (8.0*resolution) ; + matrix[7] = 2 / (8.0*resolution) ; + matrix[8] = 1 / (8.0*resolution) ; } + else if (style->terrainrgb_defined()) { - mid_image = new TerrainrgbImage (input_images, style->get_terrainrgb()) ; + if (source_image->get_channels() == 1) { + channels = 3; + } else { + channels = input_image->get_channels(); + } } + if (style->palette_defined()){ - if ( styled_image->get_channels() == 1 && ! ( style->get_palette()->is_empty() ) ) { - if (mid_image != NULL) { - styled_image = new PaletteImage ( mid_image , style->get_palette() ); + // Il n'y aura application de la palette et modification des canaux que si + // - la palette n'est pas nulle et pas vide + // - l'image source est sur un canal + if ( source_image->get_channels() == 1 && style->get_palette() != NULL && ! style->get_palette()->is_empty() ) { + if (style->get_palette()->is_no_alpha()) { + channels = 3; + } else { + channels = 4; + } + } else { + channels = source_image->get_channels(); + } + } +} + +template +int StyledImage::_getline(T *buffer, int line) { + int space; + float *source = new float[source_image->get_width() * source_image->get_channels()]; + source_image->get_line(source, line); + + if (style->estompage_defined()) { + // L'image source fait une ligne de plus en haut et en bas (ligne 0 de l'image estompée = ligne 1 de l'image source) + // et une colonne de plus à gauche et à droite + // Pour obtenir la ligne 0 de l'image estompée, on a besoin des lignes 0, 1 et 2 de l'image source + // Plus généralement, pour avoir la ligne n de l'image estompée, on a besoin des lignes + // n, n+1 et n+2 de l'image source + + // On range les lignes sources dans un buffer qui peut en stocker 3 + // La ligne source n est stockée en (n % memorized_source_lines) ème position + + multi_line_buffer = true; + // calcul des emplacements dans le buffer des 3 lignes sources nécessaires + float *line1 = source_lines_buffer + (line % memorized_source_lines) * source_image->get_width(); + float *line2 = source_lines_buffer + ((line + 1) % memorized_source_lines) * source_image->get_width(); + float *line3 = source_lines_buffer + ((line + 2) % memorized_source_lines) * source_image->get_width(); + + // ligne du dessus + if (source_lines[line % memorized_source_lines] != line) { + // la ligne source 'line' n'est pas celle stockée dans le buffer, on doit la lire + source_image->get_line(line1, line); + source_lines[line % memorized_source_lines] = line; + } + // ligne du milieu + if (source_lines[(line + 1) % memorized_source_lines] != line + 1) { + // la ligne source 'line + 1' n'est pas celle stockée dans le buffer, on doit la lire + source_image->get_line(line2, line + 1); + source_lines[(line + 1) % memorized_source_lines] = line + 1; + } + // ligne du dessous + if (source_lines[(line + 2) % memorized_source_lines] != line + 2) { + // la ligne source 'line + 2' n'est pas celle stockée dans le buffer, on doit la lire + source_image->get_line(line3, line + 2); + source_lines[(line + 2) % memorized_source_lines] = line + 2; + } + + int column_orig = 1; + int column = 0; + double value; + float dzdx, dzdy, slope, aspect; + float a, b, c, d, e, f, g, h, i; + + while (column < width) { + a = (*(line1 + column_orig - 1)); + b = (*(line1 + column_orig)); + c = (*(line1 + column_orig + 1)); + d = (*(line2 + column_orig - 1)); + e = (*(line2 + column_orig)); + f = (*(line2 + column_orig + 1)); + g = (*(line3 + column_orig - 1)); + h = (*(line3 + column_orig)); + i = (*(line3 + column_orig + 1)); + + if (a == style->get_estompage()->input_nodata_value || b == style->get_estompage()->input_nodata_value || c == style->get_estompage()->input_nodata_value || d == style->get_estompage()->input_nodata_value || e == style->get_estompage()->input_nodata_value || + f == style->get_estompage()->input_nodata_value || g == style->get_estompage()->input_nodata_value || h == style->get_estompage()->input_nodata_value || i == style->get_estompage()->input_nodata_value) { + value = style->get_estompage()->estompage_nodata_value; + } + else { + + dzdx = ((c + 2 * f + i) - (a + 2 * d + g)) / (8 * resxmeter); + dzdy = ((g + 2 * h + i) - (a + 2 * b + c)) / (8 * resymeter); + + slope = atan(style->get_estompage()->z_factor * sqrt(dzdx * dzdx + dzdy * dzdy)); + + if (dzdx != 0) { + aspect = atan2(dzdy, -dzdx); + if (aspect < 0) { + aspect = 2 * M_PI + aspect; + } + } + else { + if (dzdy > 0) { + aspect = M_PI_2; + } + else { + aspect = 2 * M_PI - M_PI_2; + } + } + + value = 255.0 * ((cos(style->get_estompage()->zenith) * cos(slope)) + (sin(style->get_estompage()->zenith) * sin(slope) * cos(style->get_estompage()->azimuth - aspect))); + if (value < 0) { + value = style->get_estompage()->estompage_nodata_value; + } + } + + *(buffer + (column++)) = (T)(value); + column_orig++; + } + + space = width * sizeof(T); + } + + else if (style->pente_defined()) { + // L'image source fait une ligne de plus en haut et en bas (ligne 0 de l'image estompée = ligne 1 de l'image source) + // et une colonne de plus à gauche et à droite + // Pour obtenir la ligne 0 de l'image estompée, on a besoin des lignes 0, 1 et 2 de l'image source + // Plus généralement, pour avoir la ligne n de l'image estompée, on a besoin des lignes + // n, n+1 et n+2 de l'image source + + // On range les lignes sources dans un buffer qui peut en stocker "memorized_source_lines" + // La ligne source n est stockée en (n % memorized_source_lines) ème position + + multi_line_buffer = true; + + // calcul des emplacements dans le buffer des 3 lignes sources nécessaires + float* line1 = source_lines_buffer + (line % memorized_source_lines) * source_image->get_width(); + float* line2 = source_lines_buffer + ((line + 1) % memorized_source_lines) * source_image->get_width(); + float* line3 = source_lines_buffer + ((line + 2) % memorized_source_lines) * source_image->get_width(); + + // ligne du dessus + if (source_lines[line % memorized_source_lines] != line) { + // la ligne source 'line' n'est pas celle stockée dans le buffer, on doit la lire + source_image->get_line (line1 , line); + source_lines[line % memorized_source_lines] = line; + } + // ligne du milieu + if (source_lines[(line + 1) % memorized_source_lines] != line + 1) { + // la ligne source 'line + 1' n'est pas celle stockée dans le buffer, on doit la lire + source_image->get_line (line2 , line + 1); + source_lines[(line + 1) % memorized_source_lines] = line + 1; + } + // ligne du dessous + if (source_lines[(line + 2) % memorized_source_lines] != line + 2) { + // la ligne source 'line + 2' n'est pas celle stockée dans le buffer, on doit la lire + source_image->get_line (line3 , line + 2); + source_lines[(line + 2) % memorized_source_lines] = line + 2; + } + + //on commence a la premiere colonne + int columnOrig = 1; + int column = 0; + //creation de la variable sur laquelle on travaille pour trouver le seuil + double dzdx,dzdy,rise,slope; + float a,b,c,d,e,f,g,h,i; + float resx,resy; + + if (style->get_pente()->algo == "H") { + resx = 8.0 * resxmeter; + resy = 8.0 * resymeter; + } else if (style->get_pente()->algo == "Z") { + resx = 2.0 * resxmeter; + resy = 2.0 * resymeter; + } + + //calcul de la variable sur toutes les autres colonnes + while ( column < width ) { + + a = ( * ( line1+columnOrig-1 ) ); + b = ( * ( line1+columnOrig ) ); + c = ( * ( line1+columnOrig+1 ) ); + d = ( * ( line2+columnOrig-1 ) ); + e = ( * ( line2+columnOrig ) ); + f = ( * ( line2+columnOrig+1 ) ); + g = ( * ( line3+columnOrig-1 ) ); + h = ( * ( line3+columnOrig ) ); + i = ( * ( line3+columnOrig+1 ) ); + + if (a == style->get_pente()->input_nodata_value || b == style->get_pente()->input_nodata_value || c == style->get_pente()->input_nodata_value || d == style->get_pente()->input_nodata_value || e == style->get_pente()->input_nodata_value || + f == style->get_pente()->input_nodata_value || g == style->get_pente()->input_nodata_value || h == style->get_pente()->input_nodata_value || i == style->get_pente()->input_nodata_value) { + slope = style->get_pente()->slope_nodata_value; + } else { + + if (style->get_pente()->algo == "H") { + dzdx = (( c + 2.0 * f + i) - (a + 2.0 * d + g)) / resx; + dzdy = (( g + 2.0 * h + i) - (a + 2.0 * b + c)) / resy; + } else if (style->get_pente()->algo == "Z" ) { + dzdx = (f - d) / resx; + dzdy = (h - b) / resy; + } else { + + } + + + if (style->get_pente()->unit == "pourcent") { + slope = sqrt(pow(dzdx,2.0) + pow(dzdy,2.0)) * 100.0; + } else if (style->get_pente()->unit == "degree") { + rise = sqrt(pow(dzdx,2.0) + pow(dzdy,2.0)); + + slope = atan(rise) * 180.0 / M_PI; + if (slope>90.0){slope = 180.0-slope;} + } else { + slope = 0; + } + + if (slope > style->get_pente()->max_slope) { + slope = style->get_pente()->max_slope; + } + + } + + * ( buffer + ( column++ ) ) = ( T ) ( slope ); + columnOrig++; + + } + + space = width * sizeof(T); + } + + else if (style->aspect_defined()) { + // L'image source fait une ligne de plus en haut et en bas (ligne 0 de l'image estompée = ligne 1 de l'image source) + // et une colonne de plus à gauche et à droite + // Pour obtenir la ligne 0 de l'image aspect, on a besoin des lignes 0, 1 et 2 de l'image source + // Plus généralement, pour avoir la ligne n de l'image aspect, on a besoin des lignes + // n, n+1 et n+2 de l'image source + + // On range les lignes sources dans un buffer qui peut en stocker 3 + // La ligne source n est stockée en (n % memorized_source_lines) ème position + + multi_line_buffer = true; + + // calcul des emplacements dans le buffer des 3 lignes sources nécessaires + float* line1 = source_lines_buffer + (line % memorized_source_lines) * source_image->get_width(); + float* line2 = source_lines_buffer + ((line + 1) % memorized_source_lines) * source_image->get_width(); + float* line3 = source_lines_buffer + ((line + 2) % memorized_source_lines) * source_image->get_width(); + + // ligne du dessus + if (source_lines[line % memorized_source_lines] != line) { + // la ligne source 'line' n'est pas celle stockée dans le buffer, on doit la lire + source_image->get_line (line1 , line); + source_lines[line % memorized_source_lines] = line; + } + // ligne du milieu + if (source_lines[(line + 1) % memorized_source_lines] != line + 1) { + // la ligne source 'line + 1' n'est pas celle stockée dans le buffer, on doit la lire + source_image->get_line (line2 , line + 1); + source_lines[(line + 1) % memorized_source_lines] = line + 1; + } + // ligne du dessous + if (source_lines[(line + 2) % memorized_source_lines] != line + 2) { + // la ligne source 'line + 2' n'est pas celle stockée dans le buffer, on doit la lire + source_image->get_line (line3 , line + 2); + source_lines[(line + 2) % memorized_source_lines] = line + 2; + } + + //on commence a la premiere colonne + int columnOrig = 1; + int column = 0; + //creation de la variable sur laquelle on travaille pour trouver le seuil + double value,value1,value2,slope; + float a,b,c,d,e,f,g,h,i; + + //calcul de la variable sur toutes les autres colonnes + while ( column < width ) { + + a = ( * ( line1+columnOrig-1 ) ); + b = ( * ( line1+columnOrig ) ); + c = ( * ( line1+columnOrig+1 ) ); + d = ( * ( line2+columnOrig-1 ) ); + e = ( * ( line2+columnOrig ) ); + f = ( * ( line2+columnOrig+1 ) ); + g = ( * ( line3+columnOrig-1 ) ); + h = ( * ( line3+columnOrig ) ); + i = ( * ( line3+columnOrig+1 ) ); + + if (a == style->get_aspect()->input_nodata_value || b == style->get_aspect()->input_nodata_value || c == style->get_aspect()->input_nodata_value || d == style->get_aspect()->input_nodata_value || e == style->get_aspect()->input_nodata_value || + f == style->get_aspect()->input_nodata_value || g == style->get_aspect()->input_nodata_value || h == style->get_aspect()->input_nodata_value || i == style->get_aspect()->input_nodata_value) { + value = style->get_aspect()->aspect_nodata_value; } else { - styled_image = new PaletteImage ( input_images , style->get_palette() ); + + value1 = (matrix[2] * c + matrix[5] * f + matrix[8] * i - matrix[0] * a - matrix[3] * d - matrix[6] * g); + value2 = (matrix[0] * a + matrix[1] * b + matrix[2] * c - matrix[6] * g - matrix[7] * h - matrix[8] * i); + + //calcul de la pente pour ne pas afficher l'exposition en dessous d'une certaine valeur de pente + slope = sqrt(pow(value1,2.0)+pow(value2,2.0)); + if (slope < style->get_aspect()->min_slope) { + value = style->get_aspect()->aspect_nodata_value; + } else { + value = (atan2(value1,value2) + M_PI) * 180 / M_PI; + } } - } - }else { - if (mid_image != NULL) { - styled_image = mid_image; + + * ( buffer + ( column++ ) ) = (T) ( value ); + columnOrig++; } + + space = width * sizeof(T); + } + + else if (style->terrainrgb_defined()) { + switch ( channels ) { + case 3: + for (int i = 0; i < source_image->get_width() ; i++ ) { + + // découpage de l'altitude en RGB suivant la formule suivante : height = min_elevation + ((Red * 256 * 256 + Green * 256 + Blue) * step) + int base = (std::max( *(source+i), style->get_terrainrgb()->min_elevation) - style->get_terrainrgb()->min_elevation) / style->get_terrainrgb()->step; + int red = (base / (256 * 256) % 256); + int green = ((base - red * 256 * 256) / 256 % 256); + int blue = (base - red * 256 * 256 - green * 256); + + * ( buffer+i*3 ) = (T) red; + * ( buffer+i*3+1 ) = (T) green; + * ( buffer+i*3+2 ) = (T) blue; + } + break; + } + + space = width * sizeof ( T ) * channels; + } + + if (style->palette_defined()){ + switch ( channels ) { + case 4: + for (int i = 0; i < source_image->get_width() ; i++ ) { + Colour iColour = style->get_palette()->get_colour ( * ( source+i ) ); + * ( buffer+i*4 ) = (T) iColour.r; + * ( buffer+i*4+1 ) = (T) iColour.g; + * ( buffer+i*4+2 ) = (T) iColour.b; + * ( buffer+i*4+3 ) = (T) iColour.a; + } + break; + + case 3: + for (int i = 0; i < source_image->get_width() ; i++ ) { + Colour iColour = style->get_palette()->get_colour ( * ( source+i ) ); + * ( buffer+i*3 ) = (T) iColour.r; + * ( buffer+i*3+1 ) = (T) iColour.g; + * ( buffer+i*3+2 ) = (T) iColour.b; + } + break; + } + + space = width * sizeof ( T ) * channels; + } + + delete[] source; + return space; +} + +StyledImage *StyledImage::create(Image *input_image, Style *input_style) { + if (input_style->estompage_defined() || input_style->pente_defined() || input_style->aspect_defined()) { + return new StyledImage(input_image,input_style,2); + } + else if (input_style->terrainrgb_defined() || input_style->palette_defined()) { + return new StyledImage(input_image,input_style,0); + } + else { + return nullptr; } } StyledImage::~StyledImage() { - delete styled_image; + + + if (multi_line_buffer) { + delete[] source_lines; + delete[] source_lines_buffer; + } + delete source_image; } From 74814d609a8635fd8bc4e24399fa439863d21b46 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Thu, 4 Dec 2025 14:38:31 +0100 Subject: [PATCH 25/31] =?UTF-8?q?Mise=20=C3=A0=20jour=20du=20changelog=20a?= =?UTF-8?q?vec=20le=20regroupement=20des=20styles=20dans=20styledImage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dc59aa..0a042f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ Le format est basé sur [Keep a Changelog](https://keepachangelog.com/) et ce pr - `TerrainrgbImage` : Ajout du processus de traitement du style Terrainrgb. - `Style` : Ajout d'une fonction permettant de savoir si une palette existe ou non. - Ajout du traitement en cas de style terrainrgb. Il doit être l'unique style déclaré pour fonctionner. -- `StyledImage` : Récupération de l'affectation du style au sein de la lib core-cpp. +- `StyledImage` : Récupération de l'affectation du style au sein de la lib core-cpp. Regroupement des traitements des styles regroupés dans StyledImage. ### Changed From b2a5c6df8348fd2d55ccc82de6d75c31c074b29e Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Thu, 4 Dec 2025 16:23:21 +0100 Subject: [PATCH 26/31] =?UTF-8?q?Correction=20du=20cas=20o=C3=B9=20le=20st?= =?UTF-8?q?yle=20normal=20renvoyait=20une=20erreur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/image/StyledImage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/image/StyledImage.cpp b/src/image/StyledImage.cpp index a51591b..48b5fb6 100644 --- a/src/image/StyledImage.cpp +++ b/src/image/StyledImage.cpp @@ -526,7 +526,7 @@ StyledImage *StyledImage::create(Image *input_image, Style *input_style) { return new StyledImage(input_image,input_style,0); } else { - return nullptr; + return new StyledImage(input_image,input_style,0); } } From 54c1eea69fc107806f6efaecba2624784622a6a3 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Mon, 8 Dec 2025 16:10:07 +0100 Subject: [PATCH 27/31] =?UTF-8?q?D=C3=A9placement=20de=20la=20fonction=20p?= =?UTF-8?q?rint=20vers=20le=20cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rok4/image/StyledImage.h | 7 +------ src/image/StyledImage.cpp | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/include/rok4/image/StyledImage.h b/include/rok4/image/StyledImage.h index 3d87604..5b1b006 100644 --- a/include/rok4/image/StyledImage.h +++ b/include/rok4/image/StyledImage.h @@ -145,10 +145,5 @@ class StyledImage : public Image ** \~english * \brief Reprojected image description output */ - void print() { - BOOST_LOG_TRIVIAL(info) << "" ; - BOOST_LOG_TRIVIAL(info) << "--------- StyledImage -----------" ; - Image::print(); - BOOST_LOG_TRIVIAL(info) << "" ; - } + void print(); }; diff --git a/src/image/StyledImage.cpp b/src/image/StyledImage.cpp index 48b5fb6..6a07a16 100644 --- a/src/image/StyledImage.cpp +++ b/src/image/StyledImage.cpp @@ -539,3 +539,25 @@ StyledImage::~StyledImage() { } delete source_image; } + +void StyledImage::print() { + BOOST_LOG_TRIVIAL(info) << "" ; + BOOST_LOG_TRIVIAL(info) << "--------- StyledImage -----------" ; + if (style->aspect_defined()){ + BOOST_LOG_TRIVIAL(info) << "--------- Aspect -----------" ; + } + if (style->estompage_defined()){ + BOOST_LOG_TRIVIAL(info) << "--------- Estompage -----------" ; + } + if (style->pente_defined()){ + BOOST_LOG_TRIVIAL(info) << "--------- Pente -----------" ; + } + if (style->terrainrgb_defined()){ + BOOST_LOG_TRIVIAL(info) << "--------- Terrainrgb -----------" ; + } + if (style->palette_defined()){ + BOOST_LOG_TRIVIAL(info) << "--------- Palette -----------" ; + } + Image::print(); + BOOST_LOG_TRIVIAL(info) << "" ; +} From 85e4c9f26036f30038c6490e1a37224e4e40d0f9 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Mon, 8 Dec 2025 17:25:55 +0100 Subject: [PATCH 28/31] =?UTF-8?q?Ajout=20de=20tests=20avant=20de=20cr?= =?UTF-8?q?=C3=A9er=20la=20styledImage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/image/StyledImage.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/image/StyledImage.cpp b/src/image/StyledImage.cpp index 6a07a16..3d16ae9 100644 --- a/src/image/StyledImage.cpp +++ b/src/image/StyledImage.cpp @@ -519,15 +519,30 @@ int StyledImage::_getline(T *buffer, int line) { } StyledImage *StyledImage::create(Image *input_image, Style *input_style) { + int offset=0; if (input_style->estompage_defined() || input_style->pente_defined() || input_style->aspect_defined()) { - return new StyledImage(input_image,input_style,2); + if (input_image->get_width()<=2 && input_image->get_height()<=2){ + BOOST_LOG_TRIVIAL(error)<<"L'image source est trop petite pour appliquer ce style"; + return NULL; + } + if (input_image->get_channels()!=1){ + BOOST_LOG_TRIVIAL(error)<<"Ce style ne s'applique que sur une image source à un canal"; + return NULL; + } + offset=2; } - else if (input_style->terrainrgb_defined() || input_style->palette_defined()) { - return new StyledImage(input_image,input_style,0); + if (input_style->terrainrgb_defined() || input_style->palette_defined()) { + BOOST_LOG_TRIVIAL(error)<<"Les styles terrainrgb et palette ne sont pas compatibles"; + return NULL; } - else { - return new StyledImage(input_image,input_style,0); + if (input_style->terrainrgb_defined()){ + if (input_image->get_channels()!=1){ + BOOST_LOG_TRIVIAL(error)<<"Ce style ne s'applique que sur une image source à un canal"; + return NULL; + } } + return new StyledImage(input_image,input_style,offset); + } StyledImage::~StyledImage() { From 7c845b023b9679efc48d933d3428fbb357a202a2 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Tue, 9 Dec 2025 11:58:34 +0100 Subject: [PATCH 29/31] =?UTF-8?q?correction=20tests=20sur=20les=20mauvaise?= =?UTF-8?q?=20propri=C3=A9t=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/image/StyledImage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/image/StyledImage.cpp b/src/image/StyledImage.cpp index 3d16ae9..8c18465 100644 --- a/src/image/StyledImage.cpp +++ b/src/image/StyledImage.cpp @@ -531,7 +531,7 @@ StyledImage *StyledImage::create(Image *input_image, Style *input_style) { } offset=2; } - if (input_style->terrainrgb_defined() || input_style->palette_defined()) { + if (input_style->terrainrgb_defined() && input_style->palette_defined()) { BOOST_LOG_TRIVIAL(error)<<"Les styles terrainrgb et palette ne sont pas compatibles"; return NULL; } From 050b84fe9af1d7c633d89e7382fd873d7b15abbc Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Tue, 9 Dec 2025 11:59:13 +0100 Subject: [PATCH 30/31] =?UTF-8?q?Suppression=20des=20fichiers=20d'image=20?= =?UTF-8?q?stylis=C3=A9=20au=20profit=20de=20la=20centralisation=20dans=20?= =?UTF-8?q?StyledImage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rok4/image/AspectImage.h | 160 --------------------- include/rok4/image/EstompageImage.h | 125 ----------------- include/rok4/image/PaletteImage.h | 72 ---------- include/rok4/image/PenteImage.h | 162 --------------------- include/rok4/image/TerrainrgbImage.h | 79 ----------- src/image/AspectImage.cpp | 184 ------------------------ src/image/EstompageImage.cpp | 179 ------------------------ src/image/PaletteImage.cpp | 114 --------------- src/image/PenteImage.cpp | 202 --------------------------- src/image/TerrainrgbImage.cpp | 108 -------------- 10 files changed, 1385 deletions(-) delete mode 100644 include/rok4/image/AspectImage.h delete mode 100644 include/rok4/image/EstompageImage.h delete mode 100644 include/rok4/image/PaletteImage.h delete mode 100644 include/rok4/image/PenteImage.h delete mode 100644 include/rok4/image/TerrainrgbImage.h delete mode 100644 src/image/AspectImage.cpp delete mode 100644 src/image/EstompageImage.cpp delete mode 100644 src/image/PaletteImage.cpp delete mode 100644 src/image/PenteImage.cpp delete mode 100644 src/image/TerrainrgbImage.cpp diff --git a/include/rok4/image/AspectImage.h b/include/rok4/image/AspectImage.h deleted file mode 100644 index 8ec8c7d..0000000 --- a/include/rok4/image/AspectImage.h +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright © (2011) Institut national de l'information - * géographique et forestière - * - * Géoportail SAV - * - * This software is a computer program whose purpose is to publish geographic - * data using OGC WMS and WMTS protocol. - * - * This software is governed by the CeCILL-C license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-C - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * - * knowledge of the CeCILL-C license and that you accept its terms. - */ - -#pragma once - -#include - -#include "rok4/image/Image.h" -#include "rok4/style/Aspect.h" - - -class AspectImage : public Image { - -private: - - /** \~french - * \brief Image d'origine utilisée pour calculer l'exposition - ** \~english - * \brief Origin image used to compute the aspect - */ - Image* source_image; - - /** \~french - * \brief Nombre de ligne en mémoire - ** \~english - * \brief Memorize lines number - */ - int memorized_source_lines; - - /** \~french - * \brief Buffer contenant les lignes sources - ** \~english - * \brief Source lines memory buffer - */ - float* source_lines_buffer; - - /** \~french - * \brief Numéros des lignes en mémoire - ** \~english - * \brief Memorized lines indexes - */ - int* source_lines; - - /** \~french - * \brief Matrice de convolution - ** \~english - * \brief Convolution matrix - */ - float matrix[9]; - - /** \~french - * \brief Résolution de l'image d'origine et donc finale - ** \~english - * \brief Resolution of the image - */ - float resolution; - - /** \~french - * \brief Configuration de l'aspect - ** \~english - * \brief Aspect configuration - */ - Aspect* aspect; - - /** \~french - * \brief Récupère la ligne - ** \~english - * \brief Get line - */ - template - int _getline ( T* buffer, int line ); - -public: - - /** \~french - * \brief Récupère la ligne - ** \~english - * \brief Get line - */ - virtual int get_line ( float* buffer, int line ); - - /** \~french - * \brief Récupère la ligne - ** \~english - * \brief Get line - */ - virtual int get_line ( uint8_t* buffer, int line ); - - /** \~french - * \brief Récupère la ligne - ** \~english - * \brief Get line - */ - virtual int get_line ( uint16_t* buffer, int line ); - - /** \~french - * \brief Constructeur - ** \~english - * \brief Construtor - */ - AspectImage ( Image* image, Aspect* asp); - - /** \~french - * \brief Destructeur - ** \~english - * \brief Destructor - */ - virtual ~AspectImage(); - - /** \~french - * \brief Sortie des informations sur l'image estompée - ** \~english - * \brief Estompage image description output - */ - void print() { - BOOST_LOG_TRIVIAL(info) << "" ; - BOOST_LOG_TRIVIAL(info) << "------ AspectImage -------" ; - Image::print(); - BOOST_LOG_TRIVIAL(info) << "\t- Algo = " << aspect->algo ; - BOOST_LOG_TRIVIAL(info) << "\t- min Slope = " << aspect->min_slope ; - - BOOST_LOG_TRIVIAL(info) << "" ; - } - -}; - diff --git a/include/rok4/image/EstompageImage.h b/include/rok4/image/EstompageImage.h deleted file mode 100644 index 4d74501..0000000 --- a/include/rok4/image/EstompageImage.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright © (2011) Institut national de l'information - * géographique et forestière - * - * Géoportail SAV - * - * This software is a computer program whose purpose is to publish geographic - * data using OGC WMS and WMTS protocol. - * - * This software is governed by the CeCILL-C license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-C - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * - * knowledge of the CeCILL-C license and that you accept its terms. - */ - -#pragma once - -#include "rok4/image/Image.h" -#include "rok4/style/Estompage.h" - -class EstompageImage : public Image { -private: - /** \~french - * \brief Image d'origine utilisée pour calculer l'estompage - ** \~english - * \brief Origin image used to compute the estompage - */ - Image* source_image; - - /** \~french - * \brief Nombre de ligne en mémoire - ** \~english - * \brief Memorize lines number - */ - int memorized_source_lines; - - /** \~french - * \brief Buffer contenant les lignes sources - ** \~english - * \brief Source lines memory buffer - */ - float* source_lines_buffer; - - /** \~french - * \brief Numéros des lignes en mémoire - ** \~english - * \brief Memorized lines indexes - */ - int* source_lines; - - /** \~french - * \brief Résolution de l'image en X, en mètre - ** \~english - * \brief Resolution of the image (X), in meter - */ - float resxmeter; - - /** \~french - * \brief Résolution de l'image en Y, en mètre - ** \~english - * \brief Resolution of the image (Y), in meter - */ - float resymeter; - - /** \~french - * \brief Configuration de l'estompage - ** \~english - * \brief Estompage configuration - */ - Estompage* estompage; - - /** \~french - * \brief Calcule la ligne - ** \~english - * \brief Process line - */ - template - int _getline ( T* buffer, int line ); - -public: - virtual int get_line ( float* buffer, int line ); - virtual int get_line ( uint8_t* buffer, int line ); - virtual int get_line ( uint16_t* buffer, int line ); - EstompageImage (Image* image, Estompage* est); - virtual ~EstompageImage(); - - /** \~french - * \brief Sortie des informations sur l'image estompée - ** \~english - * \brief Estompage image description output - */ - void print() { - BOOST_LOG_TRIVIAL(info) << "" ; - BOOST_LOG_TRIVIAL(info) << "------ EstompageImage -------" ; - Image::print(); - BOOST_LOG_TRIVIAL(info) << "\t- Zenith = " << estompage->zenith ; - BOOST_LOG_TRIVIAL(info) << "\t- Azimuth = " << estompage->azimuth ; - BOOST_LOG_TRIVIAL(info) << "\t- Z factor = " << estompage->z_factor ; - - BOOST_LOG_TRIVIAL(info) << "" ; - } -}; - diff --git a/include/rok4/image/PaletteImage.h b/include/rok4/image/PaletteImage.h deleted file mode 100644 index 0df6ccc..0000000 --- a/include/rok4/image/PaletteImage.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright © (2011) Institut national de l'information - * géographique et forestière - * - * Géoportail SAV - * - * This software is a computer program whose purpose is to publish geographic - * data using OGC WMS and WMTS protocol. - * - * This software is governed by the CeCILL-C license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-C - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * - * knowledge of the CeCILL-C license and that you accept its terms. - */ - -#pragma once - -#include "rok4/image/Image.h" -#include "rok4/style/Palette.h" - -class PaletteImage : public Image { -private: - Image* source_image; - Palette* palette; - - template - int _getline ( T* buffer, int line ); - -public: - virtual int get_line ( float* buffer, int line ); - virtual int get_line ( uint16_t* buffer, int line ); - virtual int get_line ( uint8_t* buffer, int line ); - PaletteImage ( Image* image, Palette* palette ); - virtual ~PaletteImage(); - - /** \~french - * \brief Sortie des informations sur l'image estompée - ** \~english - * \brief Estompage image description output - */ - void print() { - BOOST_LOG_TRIVIAL(info) << "" ; - BOOST_LOG_TRIVIAL(info) << "------ PaletteImage -------" ; - Image::print(); - BOOST_LOG_TRIVIAL(info) << "\t- Palette colours' number = " << palette->get_colours_map()->size() ; - - BOOST_LOG_TRIVIAL(info) << "" ; - } -}; - diff --git a/include/rok4/image/PenteImage.h b/include/rok4/image/PenteImage.h deleted file mode 100644 index 1d4bf42..0000000 --- a/include/rok4/image/PenteImage.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright © (2011) Institut national de l'information - * géographique et forestière - * - * Géoportail SAV - * - * This software is a computer program whose purpose is to publish geographic - * data using OGC WMS and WMTS protocol. - * - * This software is governed by the CeCILL-C license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-C - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * - * knowledge of the CeCILL-C license and that you accept its terms. - */ - -#pragma once - -#include "rok4/image/Image.h" -#include "rok4/style/Pente.h" -#include - - -class PenteImage : public Image { - -private: - - /** \~french - * \brief Image d'origine utilisée pour calculer la pente - ** \~english - * \brief Origin image used to compute the slope - */ - Image* source_image; - - /** \~french - * \brief Nombre de ligne en mémoire - ** \~english - * \brief Memorize lines number - */ - int memorized_source_lines; - - /** \~french - * \brief Buffer contenant les lignes sources - ** \~english - * \brief Source lines memory buffer - */ - float* source_lines_buffer; - - /** \~french - * \brief Numéros des lignes en mémoire - ** \~english - * \brief Memorized lines indexes - */ - int* source_lines; - - /** \~french - * \brief Résolution de l'image en X, en mètre - ** \~english - * \brief Resolution of the image (X), in meter - */ - float resxmeter; - - /** \~french - * \brief Résolution de l'image en Y, en mètre - ** \~english - * \brief Resolution of the image (Y), in meter - */ - float resymeter; - - /** \~french - * \brief Configuration de la pente - ** \~english - * \brief Slope configuration - */ - Pente* pente; - - /** \~french - * \brief Calcule la ligne - ** \~english - * \brief Process line - */ - template - int _getline ( T* buffer, int line ); - -public: - - /** \~french - * \brief Récupère la ligne - ** \~english - * \brief Get line - */ - virtual int get_line ( float* buffer, int line ); - - /** \~french - * \brief Récupère la ligne - ** \~english - * \brief Get line - */ - virtual int get_line ( uint8_t* buffer, int line ); - - /** \~french - * \brief Récupère la ligne - ** \~english - * \brief Get line - */ - virtual int get_line ( uint16_t* buffer, int line ); - - /** \~french - * \brief Constructeur - ** \~english - * \brief Construtor - */ - PenteImage (Image* image, Pente* p); - - /** \~french - * \brief Destructeur - ** \~english - * \brief Destructor - */ - virtual ~PenteImage(); - - /** \~french - * \brief Sortie des informations sur l'image estompée - ** \~english - * \brief Estompage image description output - */ - void print() { - BOOST_LOG_TRIVIAL(info) << "" ; - BOOST_LOG_TRIVIAL(info) << "------ PenteImage -------" ; - Image::print(); - BOOST_LOG_TRIVIAL(info) << "\t- Algo = " << pente->algo ; - BOOST_LOG_TRIVIAL(info) << "\t- Unit = " << pente->unit ; - BOOST_LOG_TRIVIAL(info) << "\t- max Slope = " << pente->max_slope ; - BOOST_LOG_TRIVIAL(info) << "\t- Slope nodata = " << pente->slope_nodata_value ; - BOOST_LOG_TRIVIAL(info) << "\t- Image nodata = " << pente->input_nodata_value ; - - BOOST_LOG_TRIVIAL(info) << "" ; - } - -}; - diff --git a/include/rok4/image/TerrainrgbImage.h b/include/rok4/image/TerrainrgbImage.h deleted file mode 100644 index 1690aa9..0000000 --- a/include/rok4/image/TerrainrgbImage.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright © (2011) Institut national de l'information - * géographique et forestière - * - * Géoportail SAV - * - * This software is a computer program whose purpose is to publish geographic - * data using OGC WMS and WMTS protocol. - * - * This software is governed by the CeCILL-C license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-C - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * - * knowledge of the CeCILL-C license and that you accept its terms. - */ - -/** - * \file TerrainrgbImage.h - ** \~french - * \brief D�finition de la classe TerrainrgbImage - ** \~english - * \brief Define class TerrainrgbImage - */ - -#pragma once - -#include "rok4/image/Image.h" -#include "rok4/style/Terrainrgb.h" - -class TerrainrgbImage : public Image -{ -private: - Image *source_image; - Terrainrgb *terrainrgb; - - template - int _getline(T *buffer, int line); - -public: - virtual int get_line(float *buffer, int line); - virtual int get_line(uint16_t *buffer, int line); - virtual int get_line(uint8_t *buffer, int line); - TerrainrgbImage(Image *image, Terrainrgb *terrainrgb); - virtual ~TerrainrgbImage(); - /** \~french - * \brief Sortie des informations sur l'image reprojetée - ** \~english - * \brief Reprojected image description output - */ - void print() { - BOOST_LOG_TRIVIAL(info) << "" ; - BOOST_LOG_TRIVIAL(info) << "--------- TerrainrgbImage -----------" ; - Image::print(); - BOOST_LOG_TRIVIAL(info) << "\t- Min elevation " << terrainrgb->min_elevation ; - BOOST_LOG_TRIVIAL(info) << "\t- Step = " << terrainrgb->step ; - BOOST_LOG_TRIVIAL(info) << "" ; - } -}; diff --git a/src/image/AspectImage.cpp b/src/image/AspectImage.cpp deleted file mode 100644 index ba01edc..0000000 --- a/src/image/AspectImage.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright © (2011) Institut national de l'information - * géographique et forestière - * - * Géoportail SAV - * - * This software is a computer program whose purpose is to publish geographic - * data using OGC WMS and WMTS protocol. - * - * This software is governed by the CeCILL-C license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-C - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * - * knowledge of the CeCILL-C license and that you accept its terms. - */ - -#include "image/AspectImage.h" - -#include - -#include "utils/Utils.h" -#include -#include -#define DEG_TO_RAD .0174532925199432958 -#include - -int AspectImage::get_line ( float* buffer, int line ) { - return _getline ( buffer, line ); -} - -int AspectImage::get_line ( uint16_t* buffer, int line ) { - return _getline ( buffer, line ); -} - -int AspectImage::get_line ( uint8_t* buffer, int line ) { - return _getline ( buffer, line ); -} - -//definition des variables -AspectImage::AspectImage (Image* image, Aspect* asp) : - Image ( image->get_width() - 2, image->get_height() - 2, 1 ), - source_image ( image ), resolution (image->get_mean_resolution()), aspect(asp) - { - - // On réduit la bbox d'un pixel de chaque côté - BoundingBox bb = source_image->get_bbox(); - bb.xmin += source_image->get_resx(); - bb.ymin += source_image->get_resy(); - bb.xmax -= source_image->get_resx(); - bb.ymax -= source_image->get_resy(); - set_bbox(bb); - - set_crs(source_image->get_crs()); - - // Buffer de lignes sources - memorized_source_lines = 3; - - source_lines = new int[memorized_source_lines]; - for (int i = 0; i < memorized_source_lines; i++) { - source_lines[i] = -1; - } - source_lines_buffer = new float[source_image->get_width() * memorized_source_lines]; - - matrix[0] = 1 / (8.0*resolution) ; - matrix[1] = 2 / (8.0*resolution) ; - matrix[2] = 1 / (8.0*resolution) ; - - matrix[3] = 2 / (8.0*resolution) ; - matrix[4] = 0 ; - matrix[5] = 2 / (8.0*resolution) ; - - matrix[6] = 1 / (8.0*resolution) ; - matrix[7] = 2 / (8.0*resolution) ; - matrix[8] = 1 / (8.0*resolution) ; -} - -AspectImage::~AspectImage() { - delete source_image; - delete[] source_lines; - delete[] source_lines_buffer; -} - - -template -int AspectImage::_getline ( T* buffer, int line ) { - // L'image source fait une ligne de plus en haut et en bas (ligne 0 de l'image estompée = ligne 1 de l'image source) - // et une colonne de plus à gauche et à droite - // Pour obtenir la ligne 0 de l'image aspect, on a besoin des lignes 0, 1 et 2 de l'image source - // Plus généralement, pour avoir la ligne n de l'image aspect, on a besoin des lignes - // n, n+1 et n+2 de l'image source - - // On range les lignes sources dans un buffer qui peut en stocker 3 - // La ligne source n est stockée en (n % memorized_source_lines) ème position - - // calcul des emplacements dans le buffer des 3 lignes sources nécessaires - float* line1 = source_lines_buffer + (line % memorized_source_lines) * source_image->get_width(); - float* line2 = source_lines_buffer + ((line + 1) % memorized_source_lines) * source_image->get_width(); - float* line3 = source_lines_buffer + ((line + 2) % memorized_source_lines) * source_image->get_width(); - - // ligne du dessus - if (source_lines[line % memorized_source_lines] != line) { - // la ligne source 'line' n'est pas celle stockée dans le buffer, on doit la lire - source_image->get_line (line1 , line); - source_lines[line % memorized_source_lines] = line; - } - // ligne du milieu - if (source_lines[(line + 1) % memorized_source_lines] != line + 1) { - // la ligne source 'line + 1' n'est pas celle stockée dans le buffer, on doit la lire - source_image->get_line (line2 , line + 1); - source_lines[(line + 1) % memorized_source_lines] = line + 1; - } - // ligne du dessous - if (source_lines[(line + 2) % memorized_source_lines] != line + 2) { - // la ligne source 'line + 2' n'est pas celle stockée dans le buffer, on doit la lire - source_image->get_line (line3 , line + 2); - source_lines[(line + 2) % memorized_source_lines] = line + 2; - } - - //on commence a la premiere colonne - int columnOrig = 1; - int column = 0; - //creation de la variable sur laquelle on travaille pour trouver le seuil - double value,value1,value2,slope; - float a,b,c,d,e,f,g,h,i; - - //calcul de la variable sur toutes les autres colonnes - while ( column < width ) { - - a = ( * ( line1+columnOrig-1 ) ); - b = ( * ( line1+columnOrig ) ); - c = ( * ( line1+columnOrig+1 ) ); - d = ( * ( line2+columnOrig-1 ) ); - e = ( * ( line2+columnOrig ) ); - f = ( * ( line2+columnOrig+1 ) ); - g = ( * ( line3+columnOrig-1 ) ); - h = ( * ( line3+columnOrig ) ); - i = ( * ( line3+columnOrig+1 ) ); - - if (a == aspect->input_nodata_value || b == aspect->input_nodata_value || c == aspect->input_nodata_value || d == aspect->input_nodata_value || e == aspect->input_nodata_value || - f == aspect->input_nodata_value || g == aspect->input_nodata_value || h == aspect->input_nodata_value || i == aspect->input_nodata_value) { - value = aspect->aspect_nodata_value; - } else { - - value1 = (matrix[2] * c + matrix[5] * f + matrix[8] * i - matrix[0] * a - matrix[3] * d - matrix[6] * g); - value2 = (matrix[0] * a + matrix[1] * b + matrix[2] * c - matrix[6] * g - matrix[7] * h - matrix[8] * i); - - //calcul de la pente pour ne pas afficher l'exposition en dessous d'une certaine valeur de pente - slope = sqrt(pow(value1,2.0)+pow(value2,2.0)); - if (slope < aspect->min_slope) { - value = aspect->aspect_nodata_value; - } else { - value = (atan2(value1,value2) + M_PI) * 180 / M_PI; - } - } - - * ( buffer + ( column++ ) ) = (T) ( value ); - columnOrig++; - } - - return width * sizeof(T); - -} - diff --git a/src/image/EstompageImage.cpp b/src/image/EstompageImage.cpp deleted file mode 100644 index 524a096..0000000 --- a/src/image/EstompageImage.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright © (2011) Institut national de l'information - * géographique et forestière - * - * Géoportail SAV - * - * This software is a computer program whose purpose is to publish geographic - * data using OGC WMS and WMTS protocol. - * - * This software is governed by the CeCILL-C license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-C - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * - * knowledge of the CeCILL-C license and that you accept its terms. - */ - -#include "image/EstompageImage.h" - -#include - -#include "utils/Utils.h" -#include -#include - - -int EstompageImage::get_line ( float* buffer, int line ) { - return _getline ( buffer, line ); -} - -int EstompageImage::get_line ( uint16_t* buffer, int line ) { - return _getline ( buffer, line ); -} - -int EstompageImage::get_line ( uint8_t* buffer, int line ) { - return _getline ( buffer, line ); -} - -EstompageImage::EstompageImage (Image *image, Estompage* est) : - Image ( image->get_width() - 2, image->get_height() - 2, 1), - source_image ( image ), estompage (est) { - - // On réduit la bbox d'un pixel de chaque côté - BoundingBox bb = source_image->get_bbox(); - bb.xmin += source_image->get_resx(); - bb.ymin += source_image->get_resy(); - bb.xmax -= source_image->get_resx(); - bb.ymax -= source_image->get_resy(); - set_bbox(bb); - - set_crs(source_image->get_crs()); - - // On calcule une seule fois la résolution en mètre - resxmeter = get_resx(true); - resymeter = get_resy(true); - - // Buffer de lignes sources - memorized_source_lines = 3; - - source_lines = new int[memorized_source_lines]; - for (int i = 0; i < memorized_source_lines; i++) { - source_lines[i] = -1; - } - source_lines_buffer = new float[source_image->get_width() * memorized_source_lines]; -} - -EstompageImage::~EstompageImage() { - delete source_image; - delete[] source_lines; - delete[] source_lines_buffer; -} - - -template -int EstompageImage::_getline ( T* buffer, int line ) { - // L'image source fait une ligne de plus en haut et en bas (ligne 0 de l'image estompée = ligne 1 de l'image source) - // et une colonne de plus à gauche et à droite - // Pour obtenir la ligne 0 de l'image estompée, on a besoin des lignes 0, 1 et 2 de l'image source - // Plus généralement, pour avoir la ligne n de l'image estompée, on a besoin des lignes - // n, n+1 et n+2 de l'image source - - // On range les lignes sources dans un buffer qui peut en stocker 3 - // La ligne source n est stockée en (n % memorized_source_lines) ème position - - // calcul des emplacements dans le buffer des 3 lignes sources nécessaires - float* line1 = source_lines_buffer + (line % memorized_source_lines) * source_image->get_width(); - float* line2 = source_lines_buffer + ((line + 1) % memorized_source_lines) * source_image->get_width(); - float* line3 = source_lines_buffer + ((line + 2) % memorized_source_lines) * source_image->get_width(); - - // ligne du dessus - if (source_lines[line % memorized_source_lines] != line) { - // la ligne source 'line' n'est pas celle stockée dans le buffer, on doit la lire - source_image->get_line (line1 , line); - source_lines[line % memorized_source_lines] = line; - } - // ligne du milieu - if (source_lines[(line + 1) % memorized_source_lines] != line + 1) { - // la ligne source 'line + 1' n'est pas celle stockée dans le buffer, on doit la lire - source_image->get_line (line2 , line + 1); - source_lines[(line + 1) % memorized_source_lines] = line + 1; - } - // ligne du dessous - if (source_lines[(line + 2) % memorized_source_lines] != line + 2) { - // la ligne source 'line + 2' n'est pas celle stockée dans le buffer, on doit la lire - source_image->get_line (line3 , line + 2); - source_lines[(line + 2) % memorized_source_lines] = line + 2; - } - - int column_orig = 1; - int column = 0; - double value; - float dzdx,dzdy,slope,aspect; - float a,b,c,d,e,f,g,h,i; - - while ( column < width ) { - - a = ( * ( line1+column_orig-1 ) ); - b = ( * ( line1+column_orig ) ); - c = ( * ( line1+column_orig+1 ) ); - d = ( * ( line2+column_orig-1 ) ); - e = ( * ( line2+column_orig ) ); - f = ( * ( line2+column_orig+1 ) ); - g = ( * ( line3+column_orig-1 ) ); - h = ( * ( line3+column_orig ) ); - i = ( * ( line3+column_orig+1 ) ); - - if (a == estompage->input_nodata_value || b == estompage->input_nodata_value || c == estompage->input_nodata_value || d == estompage->input_nodata_value || e == estompage->input_nodata_value || - f == estompage->input_nodata_value || g == estompage->input_nodata_value || h == estompage->input_nodata_value || i == estompage->input_nodata_value) { - value = estompage->estompage_nodata_value; - } else { - - dzdx = ((c + 2*f + i) - (a + 2*d + g)) / (8 * resxmeter); - dzdy = ((g + 2*h + i) - (a + 2*b + c)) / (8 * resymeter); - - slope = atan(estompage->z_factor * sqrt(dzdx*dzdx+dzdy*dzdy)); - - if (dzdx != 0) { - aspect = atan2(dzdy,-dzdx); - if (aspect < 0) { - aspect = 2 * M_PI + aspect; - } - } else { - if (dzdy > 0) { - aspect = M_PI_2; - } else { - aspect = 2 * M_PI - M_PI_2; - } - } - - value = 255.0 * ((cos(estompage->zenith) * cos(slope)) + (sin(estompage->zenith) * sin(slope) * cos(estompage->azimuth - aspect))); - if (value < 0) {value = estompage->estompage_nodata_value;} - } - - * ( buffer + ( column++ ) ) = ( T ) ( value ); - column_orig++; - } - - return width * sizeof(T); -} \ No newline at end of file diff --git a/src/image/PaletteImage.cpp b/src/image/PaletteImage.cpp deleted file mode 100644 index d4beba8..0000000 --- a/src/image/PaletteImage.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright © (2011) Institut national de l'information - * géographique et forestière - * - * Géoportail SAV - * - * This software is a computer program whose purpose is to publish geographic - * data using OGC WMS and WMTS protocol. - * - * This software is governed by the CeCILL-C license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-C - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * - * knowledge of the CeCILL-C license and that you accept its terms. - */ - -#include "image/PaletteImage.h" - -#include - -int PaletteImage::get_line ( float* buffer, int line ) { - if ( source_image->get_channels() == 1 && palette != NULL && ! palette->is_empty() ) { - return _getline ( buffer, line ); - } else { - return source_image->get_line ( buffer, line ); - } -} - -int PaletteImage::get_line ( uint16_t* buffer, int line ) { - if ( source_image->get_channels() == 1 && palette != NULL && ! palette->is_empty() ) { - return _getline ( buffer, line ); - } else { - return source_image->get_line ( buffer, line ); - } -} - -int PaletteImage::get_line ( uint8_t* buffer, int line ) { - if ( source_image->get_channels() == 1 && palette != NULL && ! palette->is_empty() ) { - return _getline ( buffer, line ); - } else { - return source_image->get_line ( buffer, line ); - } -} - -PaletteImage::PaletteImage ( Image* image, Palette* palette ) : Image ( image->get_width(), image->get_height(), 1, image->get_bbox() ), source_image ( image ), palette ( palette ) { - // Il n'y aura application de la palette et modification des canaux que si - // - la palette n'est pas nulle et pas vide - // - l'image source est sur un canal - if ( source_image->get_channels() == 1 && this->palette != NULL && ! this->palette->is_empty() ) { - if (this->palette->is_no_alpha()) { - channels = 3; - } else { - channels = 4; - } - } else { - channels = image->get_channels(); - } -} - -PaletteImage::~PaletteImage() { - delete source_image; -} - -template -int PaletteImage::_getline ( T* buffer, int line ) { - float* source = new float[source_image->get_width() * source_image->get_channels()]; - source_image->get_line ( source, line ); - switch ( channels ) { - case 4: - for (int i = 0; i < source_image->get_width() ; i++ ) { - Colour iColour = palette->get_colour ( * ( source+i ) ); - * ( buffer+i*4 ) = (T) iColour.r; - * ( buffer+i*4+1 ) = (T) iColour.g; - * ( buffer+i*4+2 ) = (T) iColour.b; - * ( buffer+i*4+3 ) = (T) iColour.a; - } - break; - - case 3: - for (int i = 0; i < source_image->get_width() ; i++ ) { - Colour iColour = palette->get_colour ( * ( source+i ) ); - * ( buffer+i*3 ) = (T) iColour.r; - * ( buffer+i*3+1 ) = (T) iColour.g; - * ( buffer+i*3+2 ) = (T) iColour.b; - } - break; - } - - - - delete[] source; - return width * sizeof ( T ) * channels; -} diff --git a/src/image/PenteImage.cpp b/src/image/PenteImage.cpp deleted file mode 100644 index ea62c56..0000000 --- a/src/image/PenteImage.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright © (2011) Institut national de l'information - * géographique et forestière - * - * Géoportail SAV - * - * This software is a computer program whose purpose is to publish geographic - * data using OGC WMS and WMTS protocol. - * - * This software is governed by the CeCILL-C license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-C - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * - * knowledge of the CeCILL-C license and that you accept its terms. - */ - -#include "image/PenteImage.h" - -#include - -#include "utils/Utils.h" -#include -#include -#define DEG_TO_RAD .0174532925199432958 -#include - -int PenteImage::get_line ( float* buffer, int line ) { - return _getline ( buffer, line ); -} - -int PenteImage::get_line ( uint16_t* buffer, int line ) { - return _getline ( buffer, line ); -} - -int PenteImage::get_line ( uint8_t* buffer, int line ) { - return _getline ( buffer, line ); -} - -//definition des variables -PenteImage::PenteImage (Image* image, Pente* p) : - Image ( image->get_width() - 2, image->get_height() - 2, 1), - source_image ( image ), pente (p) - { - - // On réduit la bbox d'un pixel de chaque côté - BoundingBox bb = source_image->get_bbox(); - bb.xmin += source_image->get_resx(); - bb.ymin += source_image->get_resy(); - bb.xmax -= source_image->get_resx(); - bb.ymax -= source_image->get_resy(); - set_bbox(bb); - - set_crs(source_image->get_crs()); - - // On calcule une seule fois la résolution en mètre - resxmeter = get_resx(true); - resymeter = get_resy(true); - - // Buffer de lignes sources - memorized_source_lines = 3; - - source_lines = new int[memorized_source_lines]; - for (int i = 0; i < memorized_source_lines; i++) { - source_lines[i] = -1; - } - source_lines_buffer = new float[source_image->get_width() * memorized_source_lines]; - -} - - -PenteImage::~PenteImage() { - delete source_image; - delete[] source_lines; - delete[] source_lines_buffer; -} - - -template -int PenteImage::_getline ( T* buffer, int line ) { - // L'image source fait une ligne de plus en haut et en bas (ligne 0 de l'image estompée = ligne 1 de l'image source) - // et une colonne de plus à gauche et à droite - // Pour obtenir la ligne 0 de l'image estompée, on a besoin des lignes 0, 1 et 2 de l'image source - // Plus généralement, pour avoir la ligne n de l'image estompée, on a besoin des lignes - // n, n+1 et n+2 de l'image source - - // On range les lignes sources dans un buffer qui peut en stocker "memorized_source_lines" - // La ligne source n est stockée en (n % memorized_source_lines) ème position - - // calcul des emplacements dans le buffer des 3 lignes sources nécessaires - float* line1 = source_lines_buffer + (line % memorized_source_lines) * source_image->get_width(); - float* line2 = source_lines_buffer + ((line + 1) % memorized_source_lines) * source_image->get_width(); - float* line3 = source_lines_buffer + ((line + 2) % memorized_source_lines) * source_image->get_width(); - - // ligne du dessus - if (source_lines[line % memorized_source_lines] != line) { - // la ligne source 'line' n'est pas celle stockée dans le buffer, on doit la lire - source_image->get_line (line1 , line); - source_lines[line % memorized_source_lines] = line; - } - // ligne du milieu - if (source_lines[(line + 1) % memorized_source_lines] != line + 1) { - // la ligne source 'line + 1' n'est pas celle stockée dans le buffer, on doit la lire - source_image->get_line (line2 , line + 1); - source_lines[(line + 1) % memorized_source_lines] = line + 1; - } - // ligne du dessous - if (source_lines[(line + 2) % memorized_source_lines] != line + 2) { - // la ligne source 'line + 2' n'est pas celle stockée dans le buffer, on doit la lire - source_image->get_line (line3 , line + 2); - source_lines[(line + 2) % memorized_source_lines] = line + 2; - } - - //on commence a la premiere colonne - int columnOrig = 1; - int column = 0; - //creation de la variable sur laquelle on travaille pour trouver le seuil - double dzdx,dzdy,rise,slope; - float a,b,c,d,e,f,g,h,i; - float resx,resy; - - if (pente->algo == "H") { - resx = 8.0 * resxmeter; - resy = 8.0 * resymeter; - } else if (pente->algo == "Z") { - resx = 2.0 * resxmeter; - resy = 2.0 * resymeter; - } - - //calcul de la variable sur toutes les autres colonnes - while ( column < width ) { - - a = ( * ( line1+columnOrig-1 ) ); - b = ( * ( line1+columnOrig ) ); - c = ( * ( line1+columnOrig+1 ) ); - d = ( * ( line2+columnOrig-1 ) ); - e = ( * ( line2+columnOrig ) ); - f = ( * ( line2+columnOrig+1 ) ); - g = ( * ( line3+columnOrig-1 ) ); - h = ( * ( line3+columnOrig ) ); - i = ( * ( line3+columnOrig+1 ) ); - - if (a == pente->input_nodata_value || b == pente->input_nodata_value || c == pente->input_nodata_value || d == pente->input_nodata_value || e == pente->input_nodata_value || - f == pente->input_nodata_value || g == pente->input_nodata_value || h == pente->input_nodata_value || i == pente->input_nodata_value) { - slope = pente->slope_nodata_value; - } else { - - if (pente->algo == "H") { - dzdx = (( c + 2.0 * f + i) - (a + 2.0 * d + g)) / resx; - dzdy = (( g + 2.0 * h + i) - (a + 2.0 * b + c)) / resy; - } else if (pente->algo == "Z" ) { - dzdx = (f - d) / resx; - dzdy = (h - b) / resy; - } else { - - } - - - if (pente->unit == "pourcent") { - slope = sqrt(pow(dzdx,2.0) + pow(dzdy,2.0)) * 100.0; - } else if (pente->unit == "degree") { - rise = sqrt(pow(dzdx,2.0) + pow(dzdy,2.0)); - - slope = atan(rise) * 180.0 / M_PI; - if (slope>90.0){slope = 180.0-slope;} - } else { - slope = 0; - } - - if (slope > pente->max_slope) { - slope = pente->max_slope; - } - - } - - * ( buffer + ( column++ ) ) = ( T ) ( slope ); - columnOrig++; - - } - - return width * sizeof(T); -} \ No newline at end of file diff --git a/src/image/TerrainrgbImage.cpp b/src/image/TerrainrgbImage.cpp deleted file mode 100644 index 85a109b..0000000 --- a/src/image/TerrainrgbImage.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright © (2011) Institut national de l'information - * géographique et forestière - * - * Géoportail SAV - * - * This software is a computer program whose purpose is to publish geographic - * data using OGC WMS and WMTS protocol. - * - * This software is governed by the CeCILL-C license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-C - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * - * knowledge of the CeCILL-C license and that you accept its terms. - */ - - /** - * \file TerrainrgbImage.cpp - * \~french - * \brief Implémentation de la classe TerrainrgbImage permettant l'application du terrainrgb à une image. - * \~english - * \brief Implement the TerrainrgbImage Class handling computing of Terrainrgb style to an image. - */ -#include "image/TerrainrgbImage.h" - -#include - -int TerrainrgbImage::get_line(float *buffer, int line) { - if (source_image->get_channels() == 1) { - return _getline(buffer, line); - } else { - return source_image->get_line(buffer, line); - } -} - -int TerrainrgbImage::get_line(uint16_t *buffer, int line) { - if (source_image->get_channels() == 1) { - return _getline(buffer, line); - } else { - return source_image->get_line(buffer, line); - } -} - -int TerrainrgbImage::get_line(uint8_t *buffer, int line) { - if (source_image->get_channels() == 1) { - return _getline(buffer, line); - } else { - return source_image->get_line(buffer, line); - } -} - -TerrainrgbImage::TerrainrgbImage(Image *image, Terrainrgb *terrainrgb) : Image(image->get_width(), image->get_height(), 1, image->get_bbox()), source_image(image), terrainrgb(terrainrgb) { - if (source_image->get_channels() == 1) { - channels = 3; - } else { - channels = source_image->get_channels(); - } -} - -TerrainrgbImage::~TerrainrgbImage() { - delete source_image; -} - -template -int TerrainrgbImage::_getline ( T* buffer, int line ) { - float* source = new float[source_image->get_width() * source_image->get_channels()]; - source_image->get_line ( source, line ); - switch ( channels ) { - case 3: - for (int i = 0; i < source_image->get_width() ; i++ ) { - - // découpage de l'altitude en RGB suivant la formule suivante : height = min_elevation + ((Red * 256 * 256 + Green * 256 + Blue) * step) - int base = (std::max( *(source+i), terrainrgb->min_elevation) - terrainrgb->min_elevation) / terrainrgb->step; - int red = (base / (256 * 256) % 256); - int green = ((base - red * 256 * 256) / 256 % 256); - int blue = (base - red * 256 * 256 - green * 256); - - * ( buffer+i*3 ) = (T) red; - * ( buffer+i*3+1 ) = (T) green; - * ( buffer+i*3+2 ) = (T) blue; - } - break; - } - - delete[] source; - return width * sizeof ( T ) * channels; -} From 8effa400d7fdb6340fec941af9e0877d7158efc4 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Mon, 5 Jan 2026 09:39:03 +0100 Subject: [PATCH 31/31] =?UTF-8?q?Mise=20=C3=A0=20jour=20du=20changelog=20p?= =?UTF-8?q?our=20s'aligner=20sur=20le=20reformatage=20StyledImage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a042f9..179af2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,10 +9,10 @@ Le format est basé sur [Keep a Changelog](https://keepachangelog.com/) et ce pr ### Added - `Terrainrgb` : Ajout d'un style terrainrgb pour transformer les MNT en format Terrain RGB. -- `TerrainrgbImage` : Ajout du processus de traitement du style Terrainrgb. - `Style` : Ajout d'une fonction permettant de savoir si une palette existe ou non. - Ajout du traitement en cas de style terrainrgb. Il doit être l'unique style déclaré pour fonctionner. - `StyledImage` : Récupération de l'affectation du style au sein de la lib core-cpp. Regroupement des traitements des styles regroupés dans StyledImage. +- `StyledImage` : Ajout du traitement pour gérer le style Terrainrgb. ### Changed