Skip to content

Commit

Permalink
Merge pull request #55 from JeromeMBourgeois/GEO
Browse files Browse the repository at this point in the history
FIX: Improvement of the Sparql query for the " commune" list service.
  • Loading branch information
JeromeMBourgeois authored Feb 3, 2022
2 parents 3b87b28 + 2d6a89c commit cb7b6d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/java/fr/insee/rmes/queries/geo/GeoQueries.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ private static String getPreviousOrNextQuery(
}

private static String getTerritoire(String code, String date, EnumTypeGeographie typeGeo) {
return getTerritoireFiltre(code,date,Constants.ABSENT,typeGeo,false);
return getTerritoireFiltre(code,date,Constants.ABSENT,typeGeo,true);
}

private static Map<String, Object> buildCodeAndDateParams(String code, String date) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@ FROM <http://rdf.insee.fr/graphes/geo/cog>

?uri a igeo:${territoire} ;
igeo:codeArticle ?typeArticle ;
igeo:nom ?intitule ;
igeo:nomSansArticle ?intituleSansArticle .

<#if com != "true">
?uri (igeo:subdivisionDirecteDe)+ <http://id.insee.fr/geo/pays/france> .
(igeo:subdivisionDirecteDe/a) ?parent;
</#if>

igeo:nom ?intitule ;
igeo:nomSansArticle ?intituleSansArticle .
<#if code != "none">
?uri igeo:codeINSEE '${code}' .
BIND('${code}' as ?code)
<#else>
?uri igeo:codeINSEE ?code .
</#if>

OPTIONAL {
?evenementCreation igeo:creation ?uri ;
igeo:date ?dateCreation .
Expand Down Expand Up @@ -54,13 +51,14 @@ FROM <http://rdf.insee.fr/graphes/geo/cog>
BIND (CONCAT("^", REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(LCASE(?query), "[àáâãäåaaa]", "a"), "ç", "c"), "[èééêë]", "e"), "[ìíîïì]", "i"), "[óôõö]", "o"), "[ùúûü]", "u"), "ÿ", "y"), "[œ]", "oe"), "([^/]+)[/]", "$1-sur-"),"([^\\\\]+)[\\\\]", "$1-sous-"), "[-_']", " "),"[^a-z0-9() ]", ""), "[ ]{2,}", " "), "^st(e)? ", "saint$1 "), "") AS ?formattedQuery) .
FILTER (REGEX(?formattedNom, ?formattedQuery) || REGEX(?formattedNomSansArticle, ?formattedQuery))
</#if>

<#if com != "true">
FILTER(REGEX(STR(?parent), "(Departement|Arrondissement)$"))
</#if>
<#if date != "*">
FILTER(!BOUND(?dateCreation) || ?dateCreation <= '${date}'^^xsd:date)
FILTER(!BOUND(?dateSuppression) || ?dateSuppression > '${date}'^^xsd:date)
</#if>


}
ORDER BY ?code

0 comments on commit cb7b6d1

Please sign in to comment.