Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
- uses: actions/checkout@v2

- name: "Set up Python"
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.12'

- name: "python backend - install requirements"
working-directory: srv/python
Expand Down
17 changes: 6 additions & 11 deletions config-php-sample.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"app_conf": {
"studio_title": "GéoBretagne mviewer studio",
"mviewer_version": "3.13",
"mviewerstudio_version": "4.2",
"mviewer_version": "4",
"mviewerstudio_version": "4.2.1",
"is_php": "true",
"php": {
"upload_service": "srv/php/store.php",
Expand Down Expand Up @@ -83,7 +83,7 @@
"type": "OSM",
"url": "https://{a-c}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png",
"maxzoom": "20",
"attribution": "Map tiles by <a href=\"https://cartodb.com/attributions\">CartoDb</a>, under <a href=\"https://creativecommons.org/licenses/by/3.0/\">CC BY 3.0 </a>"
"attribution": "Map tiles by <a href=\"https://cartodb.com/attributions\" target='_blank'>CartoDb</a>, under <a href=\"https://creativecommons.org/licenses/by/3.0/\">CC BY 3.0 </a>"
},
"esriworldimagery": {
"id": "esriworldimagery",
Expand Down Expand Up @@ -142,14 +142,14 @@
"osm_grey": {
"id": "osm_grey",
"thumbgallery": "img/basemap/osm_grey.png",
"title": "GéoBretagne - GéoGrandEst",
"title": "GéoBretagne - DataGrandEst",
"label": "OpenStreetMap style noir et blanc",
"type": "WMTS",
"url": "https://tile.geobretagne.fr/osm/service",
"layers": "osm:grey",
"format": "image/png",
"fromcapacity": "false",
"attribution": "GéoBretagne - GéoGrandEst. Données : les contributeurs d'<a href=\"https://www.openstreetmap.org/\" target=\"_blank\">OpenStreetMap </a>, <a href=\"https://www.openstreetmap.org/copyright\" target=\"_blank\">ODbL </a>",
"attribution": "GéoBretagne - DataGrandEst. Données : les contributeurs d'<a href=\"https://www.openstreetmap.org/\" target=\"_blank\">OpenStreetMap </a>, <a href=\"https://www.openstreetmap.org/copyright\" target=\"_blank\">ODbL </a>",
"style": "normal",
"matrixset": "PM",
"maxzoom": "22"
Expand Down Expand Up @@ -181,12 +181,7 @@
"baseref": "https://geobretagne.fr/geonetwork/srv/eng/catalog.search?node=srv#/metadata/"
},
{
"title": "Catalogue Région Bretagne",
"url": "https://kartenn.region-bretagne.fr/geonetwork/srv/fre/csw",
"baseref": "https://kartenn.region-bretagne.fr/geonetwork/srv/fre/catalog.search#/metadata/"
},
{
"title": "Catalogue de la Région Grand Est",
"title": "Catalogue DataGrandEst",
"url": "https://datagrandest.fr/geonetwork/srv/fre/csw",
"baseref": "https://datagrandest.fr/geonetwork/srv/eng/catalog.search?node=srv#/metadata/"
}
Expand Down
21 changes: 8 additions & 13 deletions config-python-sample.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"app_conf": {
"studio_title": "Mviewer Studio",
"mviewer_version": "3.13",
"mviewerstudio_version": "4.2",
"mviewer_version": "4",
"mviewerstudio_version": "4.2.1",
"api": "api/app",
"store_style_service": "api/style",
"mviewer_instance": "/mviewer/",
"publish_url": "/mviewer/?config=apps/public/{{config}}.xml",
"conf_path_from_mviewer": "apps/store/",
"mviewer_short_url": {
"used": true,
"used": false,
"apps_folder": "store",
"public_folder": "public"
},
Expand Down Expand Up @@ -77,7 +77,7 @@
"type": "OSM",
"url": "https://{a-c}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png",
"maxzoom": "20",
"attribution": "Map tiles by <a href=\"https://cartodb.com/attributions\">CartoDb</a>, under <a href=\"https://creativecommons.org/licenses/by/3.0/\">CC BY 3.0 </a>"
"attribution": "Map tiles by <a href=\"https://cartodb.com/attributions\" target='_blank'>CartoDb</a>, under <a href=\"https://creativecommons.org/licenses/by/3.0/\">CC BY 3.0 </a>"
},
"esriworldimagery": {
"id": "esriworldimagery",
Expand Down Expand Up @@ -136,14 +136,14 @@
"osm_grey": {
"id": "osm_grey",
"thumbgallery": "img/basemap/osm_grey.png",
"title": "GéoBretagne - GéoGrandEst",
"title": "GéoBretagne - DataGrandEst",
"label": "OpenStreetMap style noir et blanc",
"type": "WMTS",
"url": "https://tile.geobretagne.fr/osm/service",
"layers": "osm:grey",
"format": "image/png",
"fromcapacity": "false",
"attribution": "GéoBretagne - GéoGrandEst. Données : les contributeurs d'<a href=\"https://www.openstreetmap.org/\" target=\"_blank\">OpenStreetMap </a>, <a href=\"https://www.openstreetmap.org/copyright\" target=\"_blank\">ODbL </a>",
"attribution": "GéoBretagne - DataGrandEst. Données : les contributeurs d'<a href=\"https://www.openstreetmap.org/\" target=\"_blank\">OpenStreetMap </a>, <a href=\"https://www.openstreetmap.org/copyright\" target=\"_blank\">ODbL </a>",
"style": "normal",
"matrixset": "PM",
"maxzoom": "22"
Expand Down Expand Up @@ -175,15 +175,10 @@
"baseref": "https://geobretagne.fr/geonetwork/srv/eng/catalog.search?node=srv#/metadata/"
},
{
"title": "Catalogue Région Bretagne",
"url": "https://kartenn.region-bretagne.fr/geonetwork/srv/fre/csw",
"baseref": "https://kartenn.region-bretagne.fr/geonetwork/srv/fre/catalog.search#/metadata/"
},
{
"title": "Catalogue de la Région Grand Est",
"title": "Catalogue DataGrandEst",
"url": "https://datagrandest.fr/geonetwork/srv/fre/csw",
"baseref": "https://datagrandest.fr/geonetwork/srv/eng/catalog.search?node=srv#/metadata/"
}
}
],
"wms": [{
"title": "Serveur WMS de la Région",
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile-python-backend
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ ENV EXPORT_CONF_FOLDER=/home/apprunner/apps/store \
# You will probably have to override this one on runtime with your custom config
COPY config-python-sample.json mviewerstudio_backend/static/apps/config.json

CMD ["gunicorn", "-w 4", "-b 0.0.0.0:8000", "mviewerstudio_backend.app:app"]
CMD ["gunicorn", "-w 1", "-b 0.0.0.0:8000", "mviewerstudio_backend.app:app"]
2 changes: 1 addition & 1 deletion docker/nginx/default.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ server {
server_name ${NGINX_HOST};

location /mviewer/ {
proxy_pass http://mviewer:80/;
proxy_pass http://mviewer:8080/;
}

location /${MVIEWERSTUDIO_URL_PATH_PREFIX}/ {
Expand Down
36 changes: 29 additions & 7 deletions docs/doc_tech/dev_corner.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Prérequis
- Disposer des droits d'exécution en local (via Flask)
- Mviewer doit être installé et accessible en local (avec droit d'écriture)

Généralités
-----------
Généralités
-----------

Le debugger VS Code permet d'utiliser le virtualenv (répertoire .venv) installé dans le répertoire `srv/python`.

Expand All @@ -33,11 +33,33 @@ https://docs.posit.co/ide/server-pro/user/vs-code/guide/python-environments.html

Vous pouvez également consultez cette documentation sur le debugger Python dans VS code :

https://code.visualstudio.com/docs/python/tutorial-flask


Configuration du debugger VS Code
---------------------------------
https://code.visualstudio.com/docs/python/tutorial-flask


Synchronisation API / Swagger
-----------------------------

Toute modification des routes backend (fichier ``srv/python/mviewerstudio_backend/route.py``)
doit être synchronisée dans la spécification Swagger/OpenAPI
(``srv/python/mviewerstudio_backend/swagger.yaml``).

Accès à Swagger
---------------

Une fois le backend démarré, vous pouvez accéder à la documentation API :

- Swagger UI : ``http://localhost:5007/swagger`` (ou ``/swagger/``)
- Spécification OpenAPI : ``http://localhost:5007/swagger.yaml``

Si un préfixe d'URL est configuré (ex: ``MVIEWERSTUDIO_URL_PATH_PREFIX=mviewerstudio``),
les URLs deviennent :

- Swagger UI : ``http://localhost:5007/mviewerstudio/swagger``
- Spécification OpenAPI : ``http://localhost:5007/mviewerstudio/swagger.yaml``


Configuration du debugger VS Code
---------------------------------

1. Ouvrir le répertoire /srv/python/ dans VS Code.
2. Ouvrir le fichier .vscode/launch.json (voir la section suivante si non existant)
Expand Down
24 changes: 23 additions & 1 deletion docs/doc_tech/install_python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Vous aurez besoin :
sudo apt install libxslt1-dev libxml2-dev python3 python3-pip python3-venv
pip install virtualenv

- d'une version Python >= 3.9
- d'une version Python >= 3.11
- d'une instance mviewer fonctionnelle (/mviewer)

Procédures d'installation
Expand Down Expand Up @@ -150,6 +150,24 @@ Lancement de l'application avec Flask
flask run -p 5007


Documentation Swagger (API)
===========================

Le backend Python expose une interface Swagger UI ainsi que le fichier OpenAPI :

- Swagger UI : ``/swagger`` (ou ``/swagger/``)
- Spécification OpenAPI : ``/swagger.yaml``

Exemples :

- sans préfixe d'URL : ``http://localhost:5007/swagger``
- avec ``MVIEWERSTUDIO_URL_PATH_PREFIX=mviewerstudio`` : ``http://localhost:5007/mviewerstudio/swagger``

.. note::
Ces routes sont servies directement par Flask via ``mviewerstudio_backend/route.py``.
Le fichier de spécification est ``srv/python/mviewerstudio_backend/swagger.yaml``.



Mise en production
******************
Expand Down Expand Up @@ -208,6 +226,9 @@ Ajoutez ensuite ce contenu en adaptant les valeurs (chemin, user...) selon votre

fichier `mviewerstudio.service`

.. warning::
Nous conseillons de laisser la valeur du worker à 1 (voir issue #389)

.. code-block:: sh

[Unit]
Expand All @@ -225,6 +246,7 @@ fichier `mviewerstudio.service`
WorkingDirectory=/home/monuser/mviewerstudio/srv/python
ExecStart=/home/monuser/mviewerstudio/srv/python/.venv/bin/gunicorn \
-b 127.0.0.1:5007 \
--workers=1 \
--access-logfile /var/log/mviewerstudio/gunicorn-access.log \
--log-level info \
--error-logfile /var/log/mviewerstudio/gunicorn-error.log \
Expand Down
27 changes: 23 additions & 4 deletions lib/mv.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var mv = (function () {
function uuid() {
var dt = new Date().getTime();
var uuid = "xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
var r = (dt + Math.random() * 16) % 16 | 0;
var r = ((dt + Math.random() * 16) % 16) | 0;
dt = Math.floor(dt / 16);
return (c == "x" ? r : (r & 0x3) | 0x8).toString(16);
});
Expand Down Expand Up @@ -321,12 +321,31 @@ var mv = (function () {
$("#frm-bl").append(html);
$("#frm-bl-visible").append(html2);
$(".bl." + classe + " input").bind("change", function (e) {
var checkbox = $(e.currentTarget);
var allChecked = $(".bl." + classe + " input:checked");
if (!checkbox.prop("checked") && allChecked.length === 0) {
checkbox.prop("checked", true);
return;
}
var id = $(this).parent().parent().attr("data-layerid");
var value = $(e.currentTarget).prop("checked");
var select = $("#frm-bl-visible");
var currentValue = select.val();
if (value === true) {
$("#frm-bl-visible option[value='" + id + "']").removeAttr("disabled");
select.find("option[value='" + id + "']").removeAttr("disabled");
if (!currentValue) {
select.val(id).trigger("change");
}
} else {
$("#frm-bl-visible option[value='" + id + "']").attr("disabled", "disabled");
select.find("option[value='" + id + "']").attr("disabled", "disabled");
if (id === currentValue) {
var first = select.find("option:not(:disabled)").first();
if (first.length) {
select.val(first.val()).trigger("change");
} else {
select.val(null).trigger("change");
}
}
}
});
},
Expand Down Expand Up @@ -1311,7 +1330,7 @@ var mv = (function () {
$("#opt-searchl-attribution").show();
$("#opt-searchl-inputlabel").show();
// TODO : need to get values from config
$("#opt-searchlocalities-url").val("https://api-adresse.data.gouv.fr/search/");
$("#opt-searchlocalities-url").val("https://data.geopf.fr/geocodage/search/");
$("#opt-searchlocalities-attribution").val("Base adresse nationale (BAN)");
$("#opt-searchlocalities-inputlabel").val("");
$("#search-querymaponclick").show();
Expand Down
Loading
Loading