Skip to content

feat(catalog): Branchement du service de recherche pour constituer le catalogue #356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions DRAFT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ __DATE__

- ContextMenu: refacto et documentation du code du menu contextuel (#340)
- ContextMenu: Adresse : affichage du nom de commune quand il n'y a pas d'adresse (#351)
- Catalog : Ajout de plusieurs configurations thecniques avec possibilité de brancher le service de recherche de couches

* 🔥 [Deprecated]

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "geopf-extensions-openlayers",
"description": "French Geoportal Extensions for OpenLayers libraries",
"version": "1.0.0-beta.2-357",
"date": "17/02/2025",
"version": "1.0.0-beta.2-356",
"date": "19/02/2025",
"module": "src/index.js",
"directories": {},
"engines": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ <h2>Ajout du gestionnaire de catalogue avec options par defaut</h2>
Gp.Logger.enableAll();
}
var map;
var catalog;
var createMap = function() {
// on cache l'image de chargement du Géoportail.
document.getElementById('map').style.backgroundImage = 'none';
Expand All @@ -61,7 +62,7 @@ <h2>Ajout du gestionnaire de catalogue avec options par defaut</h2>
})
});

var catalog = new ol.control.Catalog({
catalog = new ol.control.Catalog({
position: "top-left",
collapsed : false
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,16 @@ <h2>Ajout du gestionnaire de catalogue avec option sur le filtrage des couches</
var catalog = new ol.control.Catalog({
position: "top-left",
layerLabel : "name",
layerFilter : [
layerFilters : [
{
field : "service",
value : "WMTS"
logical : "=",
value : ["WMTS", "WMS", "TMS"]
},
{

field : "defaultProjection",
logical : "!",
value : ["EPSG:2154", "IGNF:LAMB93", "EPSG:4326"]
}
]
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ <h2>Ajout du gestionnaire de catalogue avec option sur la configuration</h2>
}
var data = getData();
var map;
var catalog;
var createMap = function() {
// on cache l'image de chargement du Géoportail.
document.getElementById('map').style.backgroundImage = 'none';
Expand All @@ -64,26 +65,28 @@ <h2>Ajout du gestionnaire de catalogue avec option sur la configuration</h2>
})
});
data.then( data => {
var catalog = new ol.control.Catalog({
catalog = new ol.control.Catalog({
position: "top-left",
configuration : {
type : "json",
configurations : [{
type : "data",
data : data
}
}]
});
map.addControl(catalog);
})
};
Gp.Services.getConfig({
customConfigFile : "{{ resources }}/data/configuration/sample.json",
callbackSuffix : "",
// apiKey: "{{ apikey }}",
timeOut : 20000,
onSuccess : createMap,
onFailure : (e) => {
console.error(e);
}
});
createMap();
// INFO facultatif
// Gp.Services.getConfig({
// customConfigFile : "{{ resources }}/data/configuration/sample.json",
// callbackSuffix : "",
// // apiKey: "{{ apikey }}",
// timeOut : 20000,
// onSuccess : createMap,
// onFailure : (e) => {
// console.error(e);
// }
// });
</script>
{{/content}}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{{#extend "ol-sample-modules-dsfr-layout"}}

{{#content "vendor"}}

<link rel="stylesheet" href="{{ baseurl }}/dist/modules/GpfExtOlCatalog.css" />
<script src="{{ baseurl }}/dist/modules/GpfExtOlCatalog.js"></script>
{{/content}}

{{#content "head"}}
<title>Sample OpenLayers LayerCatalog</title>
{{/content}}

{{#content "style"}}
<style>
div#map {
width: 100%;
height: 500px;
background-image:url("{{ resources }}/geoportail-waiting.gif");
background-position:center center;
background-repeat:no-repeat;
}
</style>
{{/content}}

{{#content "body"}}
<h2>Ajout du gestionnaire de catalogue avec option sur la configuration (download)</h2>
<!-- map -->
<div id="map">
</div>
{{/content}}

{{#content "js"}}
<script type="text/javascript">
if (window.Gp) {
// activation des loggers
Gp.Logger.enableAll();
}
var map;
var catalog;
var createMap = function() {
// on cache l'image de chargement du Géoportail.
document.getElementById('map').style.backgroundImage = 'none';

//Création de la map
map = new ol.Map({
target : "map",
layers : [
new ol.layer.Tile({
source: new ol.source.OSM(),
opacity: 0.5
})
],
view : new ol.View({
center : [288074.8449901076, 6247982.515792289],
zoom : 8
})
});

catalog = new ol.control.Catalog({
position: "top-left",
configurations : [
{
type : "service",
default : true, // use it !
url : "https:// data.geopf.fr/recherche/api/indexes/geoplateforme/suggest",
filter :
// filtre sur le champ producer avec la valeur de texte IGN :
// {
// field : "producer",
// value : ["IGN"]
// },
// filtre sur le champ theme avec
// pour chaque valeur du texte, une valeur de la liste :
// {
// field : "theme",
// value : ["Administratif","Foncier","Agriculture","Forêt","Hydrographie, mer et littoral","Espaces protégés","Risques naturels","Tourisme et loisirs","Transports"]
// }
// champ texte :
{
field : "text",
value : "orthophoto"
}
}
]
});
catalog.on("catalog:loaded", (e) => {
console.log(e);
});
map.addControl(catalog);
};

// INFO facultatif
Gp.Services.getConfig({
customConfigFile : "{{ configurl }}",
callbackSuffix : "",
// apiKey: "{{ apikey }}",
timeOut : 20000,
onSuccess : createMap,
onFailure : (e) => {
console.error(e);
}
});
</script>
{{/content}}

{{/extend}}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ <h2>Ajout du gestionnaire de catalogue avec option sur la configuration (downloa
Gp.Logger.enableAll();
}
var map;
var catalog;
var createMap = function() {
// on cache l'image de chargement du Géoportail.
document.getElementById('map').style.backgroundImage = 'none';
Expand All @@ -55,16 +56,15 @@ <h2>Ajout du gestionnaire de catalogue avec option sur la configuration (downloa
})
});

var catalog = new ol.control.Catalog({
catalog = new ol.control.Catalog({
position: "top-left",
configuration : {
configurations : [{
type : "json",
urls : [
// INFO facultatif si la config est déjà chargée
// "https://raw.githubusercontent.com/IGNF/cartes.gouv.fr-entree-carto/main/public/data/layers.json",
"https://raw.githubusercontent.com/IGNF/cartes.gouv.fr-entree-carto/main/public/data/layers.json",
"https://raw.githubusercontent.com/IGNF/cartes.gouv.fr-entree-carto/main/public/data/edito.json"
]
}
}]
});
catalog.on("catalog:loaded", (e) => {
console.log(e);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{{#extend "ol-sample-modules-dsfr-layout"}}

{{#content "vendor"}}

<link rel="stylesheet" href="{{ baseurl }}/dist/modules/GpfExtOlCatalog.css" />
<script src="{{ baseurl }}/dist/modules/GpfExtOlCatalog.js"></script>
{{/content}}

{{#content "head"}}
<title>Sample OpenLayers LayerCatalog</title>
{{/content}}

{{#content "style"}}
<style>
div#map {
width: 100%;
height: 500px;
background-image:url("{{ resources }}/geoportail-waiting.gif");
background-position:center center;
background-repeat:no-repeat;
}
</style>
{{/content}}

{{#content "body"}}
<h2>Ajout du gestionnaire de catalogue avec option sur la configuration (download)</h2>
<!-- map -->
<div id="map">
</div>
{{/content}}

{{#content "js"}}
<script type="text/javascript">
if (window.Gp) {
// activation des loggers
Gp.Logger.enableAll();
}
async function getData () {
var response = await fetch("{{ resources }}/data/configuration/sample.json", {});
var data = await response.json();
if (response.status !== 200) {
throw new Error("Erreur de récupération du JSON !");
}
return data;
}
var data = getData();

var map;
var catalog;
var createMap = function() {
// on cache l'image de chargement du Géoportail.
document.getElementById('map').style.backgroundImage = 'none';

//Création de la map
map = new ol.Map({
target : "map",
layers : [
new ol.layer.Tile({
source: new ol.source.OSM(),
opacity: 0.5
})
],
view : new ol.View({
center : [288074.8449901076, 6247982.515792289],
zoom : 8
})
});

data.then( data => {
catalog = new ol.control.Catalog({
position: "top-left",
configurations : [
{
type : "json",
urls : [
"https://raw.githubusercontent.com/IGNF/cartes.gouv.fr-entree-carto/main/public/data/layers.json",
"https://raw.githubusercontent.com/IGNF/cartes.gouv.fr-entree-carto/main/public/data/edito.json"
]
},
{
type : "data",
data : data
},
{
type : "service",
url : "https:// data.geopf.fr/recherche/api/indexes/geoplateforme/suggest",
filter : {
field : "text",
value : "orthophoto"
}
},
]
});
catalog.on("catalog:loaded", (e) => {
console.log(e);
});
map.addControl(catalog);
});
};
// INFO facultatif
Gp.Services.getConfig({
customConfigFile : "{{ configurl }}",
callbackSuffix : "",
// apiKey: "{{ apikey }}",
timeOut : 20000,
onSuccess : createMap,
onFailure : (e) => {
console.error(e);
}
});
</script>
{{/content}}

{{/extend}}
4 changes: 4 additions & 0 deletions samples-src/resources/data/configuration/sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"layers": {
"GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2$GEOPORTAIL:OGC:WMTS": {
"name": "GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2",
"overload" : true,
"title": "Plan IGN v2",
"description": "Cartographie multi-échelles sur le territoire national, issue des bases de données vecteur de l’IGN, mis à jour régulièrement et réalisée selon un processus entièrement automatisé.",
"globalConstraint": {
Expand Down Expand Up @@ -181,6 +182,7 @@
},
"GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2$GEOPORTAIL:OGC:WMS": {
"name": "GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2",
"overload" : true,
"title": "Plan IGN v2",
"description": "Cartographie multi-échelles sur le territoire national, issue des bases de données vecteur de l’IGN, mis à jour régulièrement et réalisée selon un processus entièrement automatisé.",
"globalConstraint": {
Expand Down Expand Up @@ -241,6 +243,7 @@
"PLAN.IGN$GEOPORTAIL:GPP:TMS": {
"hidden": true,
"queryable": false,
"overload" : true,
"serviceParams": {
"id": "GPP:TMS",
"version": "1.0.0",
Expand Down Expand Up @@ -322,6 +325,7 @@
"defaultProjection": "EPSG:3857"
},
"BDTOPO_V3:batiment$GEOPORTAIL:OGC:WFS": {
"overload" : true,
"name": "BDTOPO_V3:batiment",
"title": "BDTOPO : Bâtiments",
"description": "Bâtiments - BDTOPO",
Expand Down
Loading