Skip to content
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

Service descendants pays #143

Open
ChristopheYon opened this issue Oct 11, 2024 · 6 comments
Open

Service descendants pays #143

ChristopheYon opened this issue Oct 11, 2024 · 6 comments
Assignees

Comments

@ChristopheYon
Copy link

Services territoires descendants

Pays

Les descendants des pays sont des « territoires ». Comme pour les pays, ils n’ont pas de nom sans article et ils ont un nom en forme longue. Par contres les codes de la norme ISO 3166 ne sont pas fournis.

Requête

Méthode Requête Description
GET /pays/{code}/descendants Récupérer les informations concernant les territoires inclus dans le pays {code}

Paramètres

Paramètres Description Type
date Filtre pour utiliser le pays actif à la date donnée. Par défaut, c’est la date courante. Date
type

Filtre sur le type du ou des territoires renvoyés (par compatibilité)

- territoire

String

Exemples de requête

/geo/pays/99132/descendants

/geo/pays/99132/descendants?date=1950-01-01

/geo/pays/99132/descendants?type=departement

/geo/pays/99132/descendants?date=1950-01-01&type=departement

Champs de la réponse

Champ Description
URI URI du pays
Type « Territoire »
Code Code Insee du territoire
Intitule Nom du territoire
IntituleEntier Nom du territoire en forme longue (composition du territoire)
DateCreation Date de création du territoire
DateSuppression Date de suppression du territoire s’il a été supprimé

Exemple de réponse en XML

<Territoires>
	<Territoire code="99133" uri="http://id.insee.fr/geo/territoire/1af281f6-f58a-4197-a40c-3c1514ebd9c5">
		<Intitule>Territoires britanniques en Méditerranée</Intitule>
		<IntituleEntier>Gibraltar , Akrotiri , Dhekelia</IntituleEntier>
		<DateCreation>1964-09-21</DateCreation>
	</Territoire>
	<Territoire code="99161" uri="http://id.insee.fr/geo/territoire/f2d890cc-2d4f-4838-b9aa-50b12367d1c8">
		<Intitule>Dépendances de la Couronne britannique</Intitule>
		<IntituleEntier>Île de Man , Jersey , Guernesey</IntituleEntier>
		<DateCreation>1943-01-01</DateCreation>
	</Territoire>
...
	<Territoire code="99503" uri="http://id.insee.fr/geo/territoire/957a0eb7-3154-4c4c-aab7-761553b76754">
		<Intitule>Pitcairn</Intitule>
		<IntituleEntier>Pitcairn</IntituleEntier>
		<DateCreation>1980-07-30</DateCreation>
	</Territoire>
</Territoires>

Exemple de réponse en JSON

[
	{
		"type": "Territoire",
		"code": "99133",
		"uri": "http://id.insee.fr/geo/territoire/1af281f6-f58a-4197-a40c-3c1514ebd9c5",
		"intitule": "Territoires britanniques en Méditerranée",
		"IntituleEntier": "Gibraltar , Akrotiri , Dhekelia",
		"dateCreation": "1943-01-01"
	},
	{
		"type": "Territoire",
		"code": "99161",
		"uri": "http://id.insee.fr/geo/territoire/f2d890cc-2d4f-4838-b9aa-50b12367d1c8",
		"intitule": "Dépendances de la Couronne britannique",
		"IntituleEntier": "Île de Man , Jersey , Guernesey",
		"dateCreation": "1943-01-01"
	},
...
	{
		"type": "Territoire",
		"code": "99503",
		"uri": "http://id.insee.fr/geo/territoire/957a0eb7-3154-4c4c-aab7-761553b76754",
		"intitule": "Pitcairn",
		"IntituleEntier": "Pitcairn",
		"dateCreation": "1980-07-30"
	}
]

Exemple de requête SPARQL

PREFIX :<http://rdf.insee.fr/def/geo#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?uri ?type ?code ?nom ?nomLong ?dateCreation ?dateSuppression
WHERE {
	{
		SELECT DISTINCT ?uri ?type ?code ?nom ?nomLong ?dateCreation ?dateSuppression ?dateCreationParent ?dateSuppressionParent
		WHERE {
			?parent a :Pays ;
				:codeINSEE '99132' ;
				(^:subdivisionDirecteDe)+ ?ressource .
			?ressource a ?typeRDF;
				:codeINSEE ?code ;
				:nom ?nom .
			OPTIONAL {?ressource :nomLong ?nomLong .}
			BIND(STR(?typeRDF) AS ?type).
			BIND(STR(?ressource) AS ?uri).
			OPTIONAL {?parent (^:creation/:date) ?dateCreationParent.}
			OPTIONAL {?parent (^:suppression/:date) ?dateSuppressionParent.}
			OPTIONAL {?ressource (^:creation/:date) ?dateCreation.}
			OPTIONAL {?ressource (^:suppression/:date) ?dateSuppression.}
		}
	}
	FILTER(!BOUND(?dateCreationParent) || xsd:dateTime(?dateCreationParent) <= NOW())
	FILTER(!BOUND(?dateSuppressionParent) || xsd:dateTime(?dateSuppressionParent) > NOW())
	FILTER(!BOUND(?dateCreation) || xsd:dateTime(?dateCreation) <= NOW())
	FILTER(!BOUND(?dateSuppression) || xsd:dateTime(?dateSuppression) > NOW())
}
ORDER BY ?type ?code

Avec le paramètre date :

PREFIX :<http://rdf.insee.fr/def/geo#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?uri ?type ?code ?nom ?nomLong ?dateCreation ?dateSuppression
WHERE {
	{
		SELECT DISTINCT ?uri ?type ?code ?nom ?nomLong ?dateCreation ?dateSuppression ?dateCreationParent ?dateSuppressionParent
		WHERE {
			?parent a :Pays ;
				:codeINSEE '99132' ;
				(^:subdivisionDirecteDe)+ ?ressource .
			?ressource a ?typeRDF;
				:codeINSEE ?code ;
				:nom ?nom .
			OPTIONAL {?ressource :nomLong ?nomLong .}
			BIND(STR(?typeRDF) AS ?type).
			BIND(STR(?ressource) AS ?uri).
			OPTIONAL {?parent (^:creation/:date) ?dateCreationParent.}
			OPTIONAL {?parent (^:suppression/:date) ?dateSuppressionParent.}
			OPTIONAL {?ressource (^:creation/:date) ?dateCreation.}
			OPTIONAL {?ressource (^:suppression/:date) ?dateSuppression.}
		}
	}
	FILTER(!BOUND(?dateCreationParent) || ?dateCreationParent <= '1950-01-01'^^xsd:date)
	FILTER(!BOUND(?dateSuppressionParent) || ?dateSuppressionParent > '1950-01-01'^^xsd:date)
	FILTER(!BOUND(?dateCreation) || ?dateCreation <= '1950-01-01'^^xsd:date)
	FILTER(!BOUND(?dateSuppression) || ?dateSuppression > '1950-01-01'^^xsd:date)
}
ORDER BY ?type ?code

Avec le paramètre type :

PREFIX :<http://rdf.insee.fr/def/geo#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?uri ?type ?code ?nom ?nomLong ?dateCreation ?dateSuppression
WHERE {
	{
		SELECT DISTINCT ?uri ?type ?code ?nom ?nomLong ?dateCreation ?dateSuppression ?dateCreationParent ?dateSuppressionParent
		WHERE {
			?parent a :Pays ;
				:codeINSEE '99132' ;
				(^:subdivisionDirecteDe)+ ?ressource .
			?ressource a ?typeRDF;
				a :Territoire ;
				:codeINSEE ?code ;
				:nom ?nom .
			OPTIONAL {?ressource :nomLong ?nomLong .}
			BIND(STR(?typeRDF) AS ?type).
			BIND(STR(?ressource) AS ?uri).
			OPTIONAL {?parent (^:creation/:date) ?dateCreationParent.}
			OPTIONAL {?parent (^:suppression/:date) ?dateSuppressionParent.}
			OPTIONAL {?ressource (^:creation/:date) ?dateCreation.}
			OPTIONAL {?ressource (^:suppression/:date) ?dateSuppression.}
		}
	}
	FILTER(!BOUND(?dateCreationParent) || xsd:dateTime(?dateCreationParent) <= NOW())
	FILTER(!BOUND(?dateSuppressionParent) || xsd:dateTime(?dateSuppressionParent) > NOW())
	FILTER(!BOUND(?dateCreation) || xsd:dateTime(?dateCreation) <= NOW())
	FILTER(!BOUND(?dateSuppression) || xsd:dateTime(?dateSuppression) > NOW())
}
ORDER BY ?type ?code

Avec le paramètre type et le paramètre date :

PREFIX :<http://rdf.insee.fr/def/geo#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?uri ?type ?code ?nom ?nomLong ?dateCreation ?dateSuppression
WHERE {
	{
		SELECT DISTINCT ?uri ?type ?code ?nom ?nomLong ?dateCreation ?dateSuppression ?dateCreationParent ?dateSuppressionParent
		WHERE {
			?parent a :Pays ;
				:codeINSEE '99132' ;
				(^:subdivisionDirecteDe)+ ?ressource .
			?ressource a ?typeRDF;
				a :Territoire ;
				:codeINSEE ?code ;
				:nom ?nom .
			OPTIONAL {?ressource :nomLong ?nomLong .}
			BIND(STR(?typeRDF) AS ?type).
			BIND(STR(?ressource) AS ?uri).
			OPTIONAL {?parent (^:creation/:date) ?dateCreationParent.}
			OPTIONAL {?parent (^:suppression/:date) ?dateSuppressionParent.}
			OPTIONAL {?ressource (^:creation/:date) ?dateCreation.}
			OPTIONAL {?ressource (^:suppression/:date) ?dateSuppression.}
		}
	}
	FILTER(!BOUND(?dateCreationParent) || ?dateCreationParent <= '1950-01-01'^^xsd:date)
	FILTER(!BOUND(?dateSuppressionParent) || ?dateSuppressionParent > '1950-01-01'^^xsd:date)
	FILTER(!BOUND(?dateCreation) || ?dateCreation <= '1950-01-01'^^xsd:date)
	FILTER(!BOUND(?dateSuppression) || ?dateSuppression > '1950-01-01'^^xsd:date)
}
ORDER BY ?type ?code
@HugoBouttes
Copy link
Contributor

@ChristopheYon j'ai du mal à voir le type dans les requêtes, il faudrait avoir ça tu penses ?

<#if type != "none">
    ?ressource a igeo:${type} .
</#if>

@ChristopheYon
Copy link
Author

@ChristopheYon j'ai du mal à voir le type dans les requêtes, il faudrait avoir ça tu penses ?

<#if type != "none">
    ?ressource a igeo:${type} .
</#if>

Oui, il faut avoir ça : dans mon exemple, c'est "a :Territoire" parce que pour l'instant, le seul type possible, c'est Territoire (on met le paramètre type pour faire comme pour les autres services, et pour si on ajoute d'autre types possibles dans le futur).
Donc oui, il faut bien faire comme tu propose.

@HugoBouttes
Copy link
Contributor

En vérifiant dans la classe Territoire car j'avais une erreur j'ai vu qu'on n'avait pas défini d'attribut "intituleEntier" mais seulement "intituleSansArticle". Est ce que je dois créer un nouvel attribut ou est-ce que c'est la même chose ?

@ChristopheYon
Copy link
Author

Non, ce n'est pas la même chose : intituleSansArticle, c'est pour renvoyer "Rochelle" dans le cas de "La Rochelle" (et ça ne concerne que les communes et dérivés) alors qu'intituleEntier, c'est pour renvoyer "République française" dans le cas de "France".
(bon là tout de suite, j'ai un remord : on a un intituleComplet pour les intercommunalités, qui pourrait faire l'affaire si c'est plus simple que de créer intituleEntier)

@ChristopheYon
Copy link
Author

Le service est globalement OK mais le type renvoyé est "TerritoireNonAbstract", il faudrait "Territoire" tout court.

@ChristopheYon
Copy link
Author

Ça marche très bien json mais ça ne marche plus du tout en XML : on a bien un code retour à 200 mais la réponse est vide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants