Skip to content

Commit

Permalink
Merge pull request #50 from IGNF/v2.4.1
Browse files Browse the repository at this point in the history
Ajout nouvelles fonctionnalités module er
  • Loading branch information
vinsag authored Oct 22, 2021
2 parents ef46c2f + 53be9be commit 31a136f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
13 changes: 7 additions & 6 deletions controllers/er/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ function createErProxy(featureTypeName,typeSearch){
});
}
}
//For _propertyNames, we need to transform the string in Array
if(params._propertyNames) {
params._propertyNames = params._propertyNames.split(';');
}

if((params.has_geometry) &&(!((params.field_date) || (params._limit)))) {
params.has_geometry =true;
}

}

//For _propertyNames, we need to transform the string in Array
if(params._propertyNames) {
params._propertyNames = params._propertyNames.split(';');
}
// For module Category Gestion du parametre name
if (typeSearch == 'category') {
if (params.name && params.type) {
Expand Down Expand Up @@ -162,7 +162,8 @@ var productValidators = erValidators.concat([
check('type').optional().isString(),
check('publication_date').optional().isString(),
check('date_maj_deb').optional().isString(), // Param ne servant que pour admin
check('date_maj_fin').optional().isString() // Param ne servant que pour admin
check('date_maj_fin').optional().isString(), // Param ne servant que pour admin
check('has_geometry').optional().isBoolean(),


]);
Expand Down
6 changes: 6 additions & 0 deletions doc/er.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ paths:
type: string
require: false

- name: has_geometry
in: query
description: Recherche uniquement valeur avec géométrie ou non
type: boolean
require: false

- name: _limit
in: query
description: Limite de résultats à afficher(chiffre entre 1 et 1000)
Expand Down
18 changes: 18 additions & 0 deletions lib/buildErCqlFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,24 @@ function bboxToFilter(bbox){
} else if (name == 'namepr') { //Traiter le cas du produit avec le parametre name
parts.push(' name ILIKE \'%'+ params[name] + '%\' OR name_complement ILIKE \'%'+ params[name] + '%\'');

} else if((name == 'has_geometry') && (params[name] =='false')){
continue; //We do nothing when value has geometry = false to get all results.

// Search in category
} else if (name == 'category_id') {
var valueCat = params[name].split(';');
if(valueCat.length < 2) {
parts.push(name+'=\''+ params[name]+'\'');
} else {
var chaineCategoryId = '';
var chaineConnector = '';
for (let i = 0; i < valueCat.length; i++) {
if(i == 0) { chaineConnector =''; } else { chaineConnector = ' OR '}
chaineCategoryId = chaineCategoryId + chaineConnector + ' category_id='+valueCat[i];
}
parts.push(chaineCategoryId);
}

} else {
parts.push(name+'=\''+ params[name]+'\'');
}
Expand Down
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 31a136f

Please sign in to comment.