From 0610ee802890dcddffc5437e9fd521ab5245b59d Mon Sep 17 00:00:00 2001 From: Theo Satabin Date: Tue, 30 Jan 2024 13:50:25 +0100 Subject: [PATCH 1/8] Gestion du versionnement de la documentation avec mike --- .github/workflows/build-and-release.yaml | 84 ++++++++---------------- .github/workflows/build-docs.yaml | 67 ------------------- .gitignore | 3 +- CMakeLists.txt | 2 +- docs/CHANGELOG.hdr.md | 4 ++ docs/CONTRIBUTING.hdr.md | 4 ++ docs/README.hdr.md | 4 ++ docs/documentation.md | 9 +++ docs/mkdocs.yml | 30 +++++++++ docs/openapi.md | 9 +++ docs/overrides/main.html | 8 +++ docs/requirements.txt | 4 ++ 12 files changed, 103 insertions(+), 125 deletions(-) delete mode 100644 .github/workflows/build-docs.yaml create mode 100644 docs/CHANGELOG.hdr.md create mode 100644 docs/CONTRIBUTING.hdr.md create mode 100644 docs/README.hdr.md create mode 100644 docs/documentation.md create mode 100644 docs/mkdocs.yml create mode 100644 docs/openapi.md create mode 100644 docs/overrides/main.html create mode 100644 docs/requirements.txt diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index f317280..891c56d 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -85,69 +85,41 @@ jobs: cd build make doc cd .. - cp -r README.md CHANGELOG.md docs/openapi.yaml docs/images config/*.schema.json dist/ - - name: Upload documentation - if: "matrix.os == 'ubuntu-20.04'" - uses: actions/upload-artifact@v3 - with: - name: dist-py3 - path: dist/ - if-no-files-found: error - retention-days: 1 - - commit_documentation: - name: Add documentation into gh-pages branch - needs: build_and_test - if: "always()&&(needs.create_release.outputs.job_status=='success')&&(needs.build_and_test.outputs.job_status=='success')" - runs-on: ubuntu-latest - - steps: - - - name: Checkout project on gh-pages - uses: actions/checkout@v3 - with: - ref: 'gh-pages' - token: ${{ secrets.GITHUB_TOKEN }} - - - uses: actions/download-artifact@v3 + cp docs/mkdocs.yml target/mkdocs.yml + cp -r docs/overrides target/ + cp -r docs/images target/docs/ + cp -r config/ target/docs/ + cp docs/documentation.md target/docs/documentation.md + cp docs/openapi.md target/docs/openapi.md + cp docs/README.hdr.md target/docs/README.md + cp docs/CHANGELOG.hdr.md target/docs/CHANGELOG.md + cp docs/CONTRIBUTING.hdr.md target/docs/CONTRIBUTING.md + sed "s#__version__#${{ github.ref_name }}#g" docs/openapi.yaml >>target/docs/openapi.yaml + sed "s#x.y.z#${{ github.ref_name }}#g" README.md >>target/docs/README.md + sed -i "s#](./docs/images/#](./images/#g" target/docs/README.md + cat CHANGELOG.md >>target/docs/CHANGELOG.md + cat CONTRIBUTING.md >>target/docs/CONTRIBUTING.md + + + - name: Setup python + uses: actions/setup-python@v4 with: - name: dist-py3 - path: artifact/ - - - name: Copy version elements to final location - run: | - mkdir -p docs/versions/${{ github.ref_name }}/docs docs/versions/${{ github.ref_name }}/config - cp -r artifact/html docs/versions/${{ github.ref_name }}/ - cp -r artifact/images docs/versions/${{ github.ref_name }}/docs/ - cp -r artifact/*.schema.json docs/versions/${{ github.ref_name }}/config/ - - - name: Add pages from templates - run: | - sed "s#__version__#${{ github.ref_name }}#" templates/mkdocs.template.yml >mkdocs.yml - - sed "s#__version__#${{ github.ref_name }}#" templates/documentation.template.md >docs/versions/${{ github.ref_name }}/documentation.md + python-version: "3.10" + cache: 'pip' - sed "s#__version__#${{ github.ref_name }}#" templates/index-version.template.md >docs/versions/${{ github.ref_name }}/index.md - cat artifact/README.md >>docs/versions/${{ github.ref_name }}/index.md - sed -i "s#x.y.z#${{ github.ref_name }}#g" docs/versions/${{ github.ref_name }}/index.md + - name: Install Mkdocs + run: pip install -r docs/requirements.txt - sed "s#__version__#${{ github.ref_name }}#" templates/openapi.template.md >docs/versions/${{ github.ref_name }}/openapi.md - sed "s#__version__#${{ github.ref_name }}#" artifact/openapi.yaml >docs/versions/${{ github.ref_name }}/openapi.yaml - - cp templates/index-versions.template.md docs/versions/index.md - sed "s/^## \(.*\)$/## \1 \n\n[➔ Lien vers la documentation](\1\/index.md) /" artifact/CHANGELOG.md >>docs/versions/index.md - - sed "s#__version__#${{ github.ref_name }}#" templates/latest.template.html >docs/versions/latest/index.html - rm -r artifact - - - name: Publish on gh-pages branch + - name: Publish documentation + if: "matrix.os == 'ubuntu-20.04'" run: | git config user.name github-actions git config user.email github-actions@github.com - git add -v docs/versions/${{ github.ref_name }}/ docs/versions/latest/ docs/index.md docs/versions.md - git commit -m "Add documentation for version ${{ github.ref_name }}" - git push + cd target/ + mike deploy --push --update-aliases --branch gh-pages -t "Version ${{ github.ref_name }}" ${{ github.ref_name }} latest + mike set-default --push --branch gh-pages ${{ github.ref_name }} + delete_version: name: Remove release and tag if error occured diff --git a/.github/workflows/build-docs.yaml b/.github/workflows/build-docs.yaml deleted file mode 100644 index 459496b..0000000 --- a/.github/workflows/build-docs.yaml +++ /dev/null @@ -1,67 +0,0 @@ -name: Build doc site with mkdocs and deploy - -on: - workflow_dispatch: - -jobs: - - build: - - name: Build doc site with mkdocs - - runs-on: ubuntu-latest - - steps: - - name: Checkout project - uses: actions/checkout@v3 - with: - ref: 'gh-pages' - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Setup python - uses: actions/setup-python@v4 - with: - python-version: "3.10" - cache: 'pip' - - - name: Install Mkdocs - run: pip install -r requirements.txt - - - name: Run mkdocs and archive - run : | - mkdocs build - tar \ - --dereference --hard-dereference \ - --directory "site" \ - -cvf "${{ runner.temp }}/site.tar" \ - --exclude=.git \ - --exclude=.github \ - . - - - name: Upload pages - uses: actions/upload-artifact@main - with: - name: github-pages - path: ${{ runner.temp }}/site.tar - retention-days: 1 - - deploy: - - name: Deploy site to github pages - - needs: build - - permissions: - pages: write # to deploy to Pages - id-token: write # to verify the deployment originates from an appropriate source - - # Deploy to the github-pages environment - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - - runs-on: ubuntu-latest - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v1 diff --git a/.gitignore b/.gitignore index d402e2d..e0ca0ba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build .vscode -dist \ No newline at end of file +dist +target \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 519ecae..7753d8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,7 +93,7 @@ endif(UNITTEST_ENABLED) if(DOC_ENABLED) set(DOXYGEN_DOXYFILE_ENCODING UTF-8) - set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/dist) + set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/target/docs) set(DOXYGEN_OUTPUT_LANGUAGE french) set(DOXYGEN_INPUT_ENCODING UTF-8) set(DOXYGEN_IMAGE_PATH docs/images) diff --git a/docs/CHANGELOG.hdr.md b/docs/CHANGELOG.hdr.md new file mode 100644 index 0000000..e0257d2 --- /dev/null +++ b/docs/CHANGELOG.hdr.md @@ -0,0 +1,4 @@ +--- +hide: + - navigation +--- diff --git a/docs/CONTRIBUTING.hdr.md b/docs/CONTRIBUTING.hdr.md new file mode 100644 index 0000000..e0257d2 --- /dev/null +++ b/docs/CONTRIBUTING.hdr.md @@ -0,0 +1,4 @@ +--- +hide: + - navigation +--- diff --git a/docs/README.hdr.md b/docs/README.hdr.md new file mode 100644 index 0000000..e0257d2 --- /dev/null +++ b/docs/README.hdr.md @@ -0,0 +1,4 @@ +--- +hide: + - navigation +--- diff --git a/docs/documentation.md b/docs/documentation.md new file mode 100644 index 0000000..9131259 --- /dev/null +++ b/docs/documentation.md @@ -0,0 +1,9 @@ +--- +hide: + - navigation + - toc +--- + +# Documentation technique + + \ No newline at end of file diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml new file mode 100644 index 0000000..ad7b0b3 --- /dev/null +++ b/docs/mkdocs.yml @@ -0,0 +1,30 @@ +site_name: "Projet ROK4 - Serveur de diffusion WMS, WMTS et TMS" +site_url: https://rok4.github.io/server +nav: + - Accueil: README.md + - Spécification de l'API: openapi.md + - Documentation technique: documentation.md + - Historique des versions: CHANGELOG.md + - Contribuer: CONTRIBUTING.md + +theme: + logo: https://rok4.github.io/assets/images/rok4-carre.png + favicon: https://rok4.github.io/assets/images/rok4-carre.png + name: material + features: + - navigation.tabs + - navigation.tabs.sticky + language: fr + custom_dir: overrides + +extra_css: + - https://rok4.github.io/assets/css/commun.css + +extra: + homepage: https://rok4.github.io + version: + provider: mike + default: latest + +plugins: + - render_swagger \ No newline at end of file diff --git a/docs/openapi.md b/docs/openapi.md new file mode 100644 index 0000000..183f9fe --- /dev/null +++ b/docs/openapi.md @@ -0,0 +1,9 @@ +--- +hide: + - navigation + - toc +--- + +# Spécifications de l'API + +!!swagger openapi.yaml!! \ No newline at end of file diff --git a/docs/overrides/main.html b/docs/overrides/main.html new file mode 100644 index 0000000..7d3b2f9 --- /dev/null +++ b/docs/overrides/main.html @@ -0,0 +1,8 @@ +{% extends "base.html" %} + +{% block outdated %} + 🚨 Vous êtes sur la documentation d'une ancienne version. 🚨 + + Cliquez ici pour aller sur la dernière version. + +{% endblock %} \ No newline at end of file diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..71722a5 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,4 @@ +mkdocs +mkdocs-material +mike +mkdocs-render-swagger-plugin \ No newline at end of file From 143759208bc89f232b431d0d7a958e6e1b7b2cd0 Mon Sep 17 00:00:00 2001 From: Theo Satabin Date: Wed, 31 Jan 2024 14:10:10 +0100 Subject: [PATCH 2/8] Correction du workflow (publication de la doc) --- .github/workflows/build-and-release.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index 891c56d..a27b461 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -46,7 +46,9 @@ jobs: steps: - name: Checkout project - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Install system dependencies run: | From 1ceb54e64828a33e056eb3b5cd01260e5c2c2314 Mon Sep 17 00:00:00 2001 From: Theo Satabin Date: Mon, 12 Feb 2024 15:45:04 +0100 Subject: [PATCH 3/8] =?UTF-8?q?Ajout=20d'un=20m=C3=A9canisme=20d'activatio?= =?UTF-8?q?n/d=C3=A9sactivation=20des=20services?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### [Added] * Possbilité d'activer / désactiver les routes de consultation * La configuration serveur permet de dire si les services sont activés à la fin du chargement (oui par défaut) * Toutes les routes globales, WMS, WMTS, TMS et OGC API Tiles répondent en 503 si le serveur est désactiver * 2 routes admin permettent d'activer (`PUT /admin/on`) ou désactiver (`PUT /admin/off`) les services --- config/server.schema.json | 5 +++++ docs/openapi.yaml | 43 +++++++++++++++++++++++++++++++-------- src/Request.cpp | 14 +++++++++++++ src/Request.h | 2 ++ src/Rok4Server.cpp | 17 ++++++++++++++-- src/ServerConf.cpp | 10 +++++++++ src/ServerConf.h | 7 +++++++ src/ServiceException.cpp | 8 ++++++++ src/ServiceException.h | 7 ++++++- 9 files changed, 102 insertions(+), 11 deletions(-) diff --git a/config/server.schema.json b/config/server.schema.json index 5f2e670..1fff277 100644 --- a/config/server.schema.json +++ b/config/server.schema.json @@ -15,6 +15,11 @@ "type": "integer", "description": "Taille de la file d'attente du socket" }, + "enabled": { + "type": "boolean", + "description": "Active-t-on les API de consultation automatiquement à la fin du chargement ?", + "default": true + }, "api": { "type": "boolean", "description": "Active-t-on l'API d'administration" diff --git a/docs/openapi.yaml b/docs/openapi.yaml index d94c07e..c0a5b91 100644 --- a/docs/openapi.yaml +++ b/docs/openapi.yaml @@ -47,10 +47,10 @@ paths: get: tags: - Santé du serveur - summary: ... + summary: Récupère les informations générales du serveur responses: 200: - description: ... + description: Statut, version, identifiant de processus et date de lancement content: application/json: schema: @@ -60,10 +60,10 @@ paths: get: tags: - Santé du serveur - summary: ... + summary: Récupère la liste des identifiants des couches, TMS et styles chargés responses: 200: - description: ... + description: Liste des identifiants des couches, TMS et styles chargés content: application/json: schema: @@ -73,10 +73,10 @@ paths: get: tags: - Santé du serveur - summary: ... + summary: Récupère les informations sur chaque thread responses: 200: - description: ... + description: Liste des identifiants, statuts, nombre et temps de traitement des requête pour chaque thread content: application/json: schema: @@ -86,10 +86,10 @@ paths: get: tags: - Santé du serveur - summary: ... + summary: Récupère le compte des contextes de stockage utilisés responses: 200: - description: ... + description: Nombre de contexte de stockage utilisés fichier, Swift, S3 et Ceph content: application/json: schema: @@ -1378,6 +1378,32 @@ paths: ######################################### ADMIN + /admin/on: + put: + tags: + - Administration + summary: Active les services + description: On active la réponse aux appels sur les routes globales et de consultation + operationId: admin_turn_on + + responses: + 204: + description: Activation des services réussie + + /admin/off: + put: + tags: + - Administration + summary: Désactive les services + description: | + On désactive la réponse aux appels sur les routes globales et de consultation (réponse d'un 503 systématique). + On répond toujours aux API admin et de santé. + operationId: admin_turn_off + + responses: + 204: + description: Désactivation des services réussie + /admin/layers: put: tags: @@ -1658,6 +1684,7 @@ components: properties: status: type: string + enum: ['OK', 'DISABLED'] version: type: string pid: diff --git a/src/Request.cpp b/src/Request.cpp index 2377944..f16624e 100644 --- a/src/Request.cpp +++ b/src/Request.cpp @@ -76,6 +76,8 @@ namespace RequestType { "UpdateLayer", "DeleteLayer", "BuildCapabilities", + "TurnOn", + "TurnOff", "GetStatus", "GetInfos" "GetThreads", @@ -893,6 +895,18 @@ void Request::determineServiceAndRequest() { //--> DELETE /admin/layers/{layername} request = RequestType::DELETELAYER; + } + + else if (method == "PUT" && pathParts.size() == 2 && pathParts.at(1) == "on") { + //--> PUT /admin/on + request = RequestType::TURNON; + + } + + else if (method == "PUT" && pathParts.size() == 2 && pathParts.at(1) == "off") { + //--> PUT /admin/off + request = RequestType::TURNOFF; + } else { // La profondeur de requête ne permet pas de savoir l'action demandée -> ERREUR request = RequestType::REQUEST_UNKNOWN; diff --git a/src/Request.h b/src/Request.h index 1a5bb0b..70594a7 100644 --- a/src/Request.h +++ b/src/Request.h @@ -81,6 +81,8 @@ namespace RequestType { UPDATELAYER, DELETELAYER, BUILDCAPABILITIES, + TURNON, + TURNOFF, GETHEALTHSTATUS, GETINFOSTATUS, GETTHREADSTATUS, diff --git a/src/Rok4Server.cpp b/src/Rok4Server.cpp index 0d8d1b3..b7570d5 100644 --- a/src/Rok4Server.cpp +++ b/src/Rok4Server.cpp @@ -806,6 +806,12 @@ void Rok4Server::processAdmin(Request* request, FCGX_Request& fcgxRequest) { S.sendresponse(AdminUpdateLayer(request), &fcgxRequest); } else if (request->request == RequestType::DELETELAYER) { S.sendresponse(AdminDeleteLayer(request), &fcgxRequest); + } else if (request->request == RequestType::TURNON) { + serverConf->enabled = true; + S.sendresponse(new EmptyResponseDataStream (), &fcgxRequest); + } else if (request->request == RequestType::TURNOFF) { + serverConf->enabled = false; + S.sendresponse(new EmptyResponseDataStream (), &fcgxRequest); } else { S.sendresponse(new SERDataStream(new ServiceException("", OWS_OPERATION_NOT_SUPORTED, std::string("L'operation n'est pas prise en charge par ce serveur."), "admin")), &fcgxRequest); } @@ -816,7 +822,11 @@ void Rok4Server::processHealthCheck(Request *request, FCGX_Request &fcgxRequest) std::ostringstream res; if (request->request == RequestType::GETHEALTHSTATUS) { res << "{\n"; - res << " \"status\": \"OK\",\n"; + if (serverConf->enabled) { + res << " \"status\": \"OK\",\n"; + } else { + res << " \"status\": \"DISABLED\",\n"; + } res << " \"version\": \"" << VERSION << "\",\n"; res << " \"pid\": " << this->getPID() << ",\n"; res << " \"time\": " << this->getTime() << "\n"; @@ -939,7 +949,10 @@ void Rok4Server::processOGCTILES(Request* request, FCGX_Request& fcgxRequest) { } void Rok4Server::processRequest(Request* request, FCGX_Request& fcgxRequest) { - if (request->service == ServiceType::GLOBAL) { + + if (request->service != ServiceType::ADMIN && request->service != ServiceType::HEALTHCHECK && ! serverConf->enabled) { + S.sendresponse(new SERDataSource(new ServiceException("", SERVICE_UNAVAILABLE, "Consultation services are not enabled", "global")), &fcgxRequest); + } else if (request->service == ServiceType::GLOBAL) { processGlobal(request, fcgxRequest); } else if (servicesConf->supportWMTS && request->service == ServiceType::WMTS) { processWMTS(request, fcgxRequest); diff --git a/src/ServerConf.cpp b/src/ServerConf.cpp index 2af6ca6..3dec722 100644 --- a/src/ServerConf.cpp +++ b/src/ServerConf.cpp @@ -162,6 +162,16 @@ bool ServerConf::parse(json11::Json& doc) { supportAdmin = doc["api"].bool_value(); } + // api + if (doc["enabled"].is_null()) { + enabled = true; + } else if (! doc["api"].is_bool()) { + errorMessage = "enabled have to be a boolean"; + return false; + } else { + enabled = doc["enabled"].bool_value(); + } + // configurations json11::Json configurationsSection = doc["configurations"]; if (configurationsSection.is_null()) { diff --git a/src/ServerConf.h b/src/ServerConf.h index e16176a..9f4fd9e 100644 --- a/src/ServerConf.h +++ b/src/ServerConf.h @@ -129,6 +129,13 @@ class ServerConf : public Configuration */ bool supportAdmin; + + /** + * \~french \brief Définit si le serveur doit honorer les requêtes de consultation + * \~english \brief Define whether broadcast request should be honored + */ + bool enabled; + private: bool parse(json11::Json& doc); diff --git a/src/ServiceException.cpp b/src/ServiceException.cpp index 07ecfce..bff5351 100644 --- a/src/ServiceException.cpp +++ b/src/ServiceException.cpp @@ -91,6 +91,10 @@ std::string ServiceException::getCodeAsString ( ExceptionCode code ) { return "ConfigurationConflict"; case ADMIN_BAD_REQUEST: return "ConfigurationIssue"; + case INTERNAL_SERVER_ERROR: + return "InternalServerError"; + case SERVICE_UNAVAILABLE: + return "ServiceUnavailable"; default: return "" ; } @@ -121,6 +125,8 @@ int ServiceException::getCodeAsStatusCode ( ExceptionCode code ) { return 500 ; case OWS_OPERATION_NOT_SUPORTED: return 501 ; + case SERVICE_UNAVAILABLE: + return 503 ; case HTTP_NOT_FOUND: return 404 ; case GFI_PYRAMID_VALUES: @@ -146,6 +152,8 @@ std::string ServiceException::getStatusCodeAsReasonPhrase ( int statusCode ) { return "Internal server error" ; case 501 : return "Not implemented" ; + case 503 : + return "Service unavailable" ; default : return "No reason"; } diff --git a/src/ServiceException.h b/src/ServiceException.h index 0d82758..5f3f233 100644 --- a/src/ServiceException.h +++ b/src/ServiceException.h @@ -161,7 +161,12 @@ typedef enum { * \~french Erreur interne * \~english Internal issue */ - INTERNAL_SERVER_ERROR = 20 + INTERNAL_SERVER_ERROR = 20, + /** + * \~french Erreur interne + * \~english Internal issue + */ + SERVICE_UNAVAILABLE = 21 } ExceptionCode; From d340e941838a59e55f9a11fbf22e0caf964a886e Mon Sep 17 00:00:00 2001 From: Theo Satabin Date: Tue, 13 Feb 2024 17:02:08 +0100 Subject: [PATCH 4/8] Correction passage labeler v4 -> v5 --- .github/workflows/pr-auto-labeler.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-auto-labeler.yml b/.github/workflows/pr-auto-labeler.yml index 42ec571..cc5272e 100644 --- a/.github/workflows/pr-auto-labeler.yml +++ b/.github/workflows/pr-auto-labeler.yml @@ -1,6 +1,6 @@ name: "🏷 PR Labeler" on: - - pull_request_target + - pull_request permissions: contents: read @@ -10,6 +10,6 @@ jobs: triage: runs-on: ubuntu-latest steps: - - uses: actions/labeler@v4 + - uses: actions/labeler@v5 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" From b4f57b3a45f9c3c91169f844d64337a4bd7388ca Mon Sep 17 00:00:00 2001 From: Theo Satabin Date: Mon, 18 Mar 2024 20:32:42 +0100 Subject: [PATCH 5/8] Ajout des TMS de base dans le getcapabilities WMTS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### [Changed] * WMTS : * On ajoute à la liste des TMS au niveau du getcapabilities les TMS "de base" en entier --- src/Layer.cpp | 2 +- src/UtilsWMTS.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Layer.cpp b/src/Layer.cpp index 02ff269..07a7f1c 100644 --- a/src/Layer.cpp +++ b/src/Layer.cpp @@ -510,7 +510,7 @@ void Layer::calculateTileMatrixLimits() { std::vector newList; - // Le premier TMS est ce lui natif : les tuiles limites sont déjà calculée et stockées dans les niveaux + // Le premier TMS est celui natif : les tuiles limites sont déjà calculée et stockées dans les niveaux WmtsTmsInfos infos = WMTSTMSList.at(0); infos.limits = std::vector(); diff --git a/src/UtilsWMTS.cpp b/src/UtilsWMTS.cpp index 84203c9..6ffebaf 100644 --- a/src/UtilsWMTS.cpp +++ b/src/UtilsWMTS.cpp @@ -502,6 +502,14 @@ void Rok4Server::buildWMTSCapabilities() { layerEl->LinkEndChild ( tmsLinkEl ); usedTMSList.insert ( std::pair ( layer->getWMTSTMSList().at(i).wmts_id , layer->getWMTSTMSList().at(i)) ); + + + WmtsTmsInfos origin_infos; + origin_infos.tms = layer->getWMTSTMSList().at(i).tms; + origin_infos.top_level = ""; + origin_infos.bottom_level = ""; + origin_infos.wmts_id = origin_infos.tms->getId(); + usedTMSList.insert ( std::pair ( origin_infos.wmts_id, origin_infos) ); } contentsEl->LinkEndChild ( layerEl ); @@ -541,6 +549,10 @@ void Rok4Server::buildWMTSCapabilities() { // TileMatrix std::set, ComparatorTileMatrix> orderedTM = tms->getOrderedTileMatrix(false); bool keep = false; + if (itTms->second.top_level == "") { + // On est sur un TMS d'origine, on l'exporte en entier + keep = true; + } for (std::pair element : orderedTM) { TileMatrix* tm = element.second; From 87687cbbf65b1ea887bcbb5c2525f69a3088a5cf Mon Sep 17 00:00:00 2001 From: Theo Satabin Date: Mon, 18 Mar 2024 21:02:58 +0100 Subject: [PATCH 6/8] =?UTF-8?q?Compl=C3=A9tion=20du=20changelog=20pour=20l?= =?UTF-8?q?a=20version=205.4.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20c532c..2693348 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 5.4.2 + +### [Changed] + +* WMTS : + * On ajoute à la liste des TMS au niveau du getcapabilities les TMS "de base" en entier + ## 5.4.1 ### [Added] From e534302d9a9f9045f377b044c705f66c0d58a24a Mon Sep 17 00:00:00 2001 From: Theo Satabin Date: Wed, 10 Apr 2024 10:38:05 +0200 Subject: [PATCH 7/8] =?UTF-8?q?Possibilit=C3=A9=20de=20fournir=20des=20par?= =?UTF-8?q?am=C3=A8tres=20additionnelsn=20pour=20le=20getFeatureInfo=20ave?= =?UTF-8?q?c=20WMS=20source?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### [Added] * Layer : lors de la configuration du get feature info de type EXTERNALWMS, il est possible de fournir des paramètres additionnels à ajouter à la requête vers le WMS source avec le champ "extra_query_params" --- docs/openapi.yaml | 2 ++ src/Layer.cpp | 4 ++++ src/Layer.h | 16 +++++++++++++++- src/Rok4Server.cpp | 10 ++++++---- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/docs/openapi.yaml b/docs/openapi.yaml index c0a5b91..1b6a764 100644 --- a/docs/openapi.yaml +++ b/docs/openapi.yaml @@ -1872,6 +1872,8 @@ components: type: string service: type: string + extra_query_params: + type: string force_epsg: type: boolean required: diff --git a/src/Layer.cpp b/src/Layer.cpp index 07a7f1c..e129ebe 100644 --- a/src/Layer.cpp +++ b/src/Layer.cpp @@ -298,6 +298,9 @@ bool Layer::parse(json11::Json& doc, ServicesConf* servicesConf) { if(doc["get_feature_info"]["force_epsg"].is_bool()) { GFIForceEPSG = doc["get_feature_info"]["force_epsg"].bool_value(); } + if(doc["get_feature_info"]["extra_query_params"].is_string()) { + GFIExtraParams = doc["get_feature_info"]["extra_query_params"].string_value(); + } } else { @@ -804,6 +807,7 @@ std::vector Layer::getMetadataURLs() { return metadataURLs; } bool Layer::isGetFeatureInfoAvailable() { return getFeatureInfoAvailability; } std::string Layer::getGFIType() { return getFeatureInfoType; } std::string Layer::getGFIBaseUrl() { return getFeatureInfoBaseURL; } +std::string Layer::getGFIExtraParams() { return GFIExtraParams; } std::string Layer::getGFILayers() { return GFILayers; } std::string Layer::getGFIQueryLayers() { return GFIQueryLayers; } std::string Layer::getGFIService() { return GFIService; } diff --git a/src/Layer.h b/src/Layer.h index 9e258d6..3f9d009 100644 --- a/src/Layer.h +++ b/src/Layer.h @@ -196,7 +196,7 @@ class Layer : public Configuration { */ std::string getFeatureInfoType; /** - * \~french \brief URL du service WMS-V à utiliser pour le GetFeatureInfo + * \~french \brief URL du service WMS à utiliser pour le GetFeatureInfo * \~english \brief WMS-V service URL to use for getFeatureInfo */ std::string getFeatureInfoBaseURL; @@ -220,6 +220,11 @@ class Layer : public Configuration { * \~english \brief Parameter layers for the service */ std::string GFILayers; + /** + * \~french \brief Paramètres de requête additionnels à fournir au service + * \~english \brief Additionnal query parameters for the service + */ + std::string GFIExtraParams; /** * \~french \brief Modification des EPSG autorisé (pour Geoserver) * \~english \brief Modification of EPSG is authorized (for Geoserver) @@ -590,6 +595,15 @@ class Layer : public Configuration { * \return version of service used for GFI */ std::string getGFIVersion() ; + /** + * \~french + * \brief Retourne les paramètres de requête additionnels de la requête de GFI + * \return paramètres additionnels + * \~english + * \brief Return the extra query parameters of GFI request + * \return extra parameters + */ + std::string getGFIExtraParams() ; /** * \~french * \brief diff --git a/src/Rok4Server.cpp b/src/Rok4Server.cpp index b7570d5..0e31be3 100644 --- a/src/Rok4Server.cpp +++ b/src/Rok4Server.cpp @@ -664,6 +664,7 @@ DataStream* Rok4Server::CommonGetFeatureInfo(std::string service, Layer* layer, ss << (int)intbuffer[i]; strData.push_back(ss.str()); } + delete[] intbuffer; break; } case Rok4Format::TIFF_RAW_FLOAT32: @@ -694,7 +695,7 @@ DataStream* Rok4Server::CommonGetFeatureInfo(std::string service, Layer* layer, } else if (getFeatureInfoType.compare("EXTERNALWMS") == 0) { BOOST_LOG_TRIVIAL(debug) << "GFI sur WMS externe"; - WebService* myWMSV = new WebService(layer->getGFIBaseUrl(), 1, 1, 10); + WebService* myWMS = new WebService(layer->getGFIBaseUrl(), 1, 1, 10); std::stringstream vectorRequest; std::string crsstring = crs->getRequestCode(); if (layer->getGFIForceEPSG()) { @@ -718,6 +719,7 @@ DataStream* Rok4Server::CommonGetFeatureInfo(std::string service, Layer* layer, << "&HEIGHT=" << height << "&I=" << X << "&J=" << Y + << "&" << layer->getGFIExtraParams() // compatibilité 1.1.1 << "&SRS=" << crsstring << "&X=" << X @@ -740,13 +742,13 @@ DataStream* Rok4Server::CommonGetFeatureInfo(std::string service, Layer* layer, } BOOST_LOG_TRIVIAL(debug) << "REQUETE = " << vectorRequest.str(); - RawDataStream* response = myWMSV->performRequestStream(vectorRequest.str()); + RawDataStream* response = myWMS->performRequestStream(vectorRequest.str()); if (response == NULL) { - delete myWMSV; + delete myWMS; return new SERDataStream(new ServiceException("", OWS_NOAPPLICABLE_CODE, "Internal server error", "wms")); } - delete myWMSV; + delete myWMS; return response; } else if (getFeatureInfoType.compare("SQL") == 0) { BOOST_LOG_TRIVIAL(debug) << "GFI sur SQL"; From 5e75647bb6b0082c297c38cc37d6237d328c74ea Mon Sep 17 00:00:00 2001 From: Theo Satabin Date: Wed, 10 Apr 2024 10:44:41 +0200 Subject: [PATCH 8/8] =?UTF-8?q?Compl=C3=A9tion=20du=20changelog=20pour=20l?= =?UTF-8?q?a=20version=205.5.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2693348..57789e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 5.5.0 + +### [Added] + +* `Layer` : lors de la configuration du get feature info de type EXTERNALWMS, il est possible de fournir des paramètres additionnels à ajouter à la requête vers le WMS source avec le champ "extra_query_params" + ## 5.4.2 ### [Changed]