Created
November 10, 2015 13:38
-
-
Save jdesboeufs/59442fc1621b8abe11ae to your computer and use it in GitHub Desktop.
Requêtes Appellations APICarto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
ST_AsGeoJSON(appellation.geom) AS geom, | |
ST_AREA(ST_INTERSECTION(input_geom, appellation.geom)::geography) / 10000 AS area, | |
appellation, | |
id_uni, | |
ST_CONTAINS(input_geom, appellation.geom) AS contains | |
FROM | |
( | |
SELECT | |
communes.insee, | |
input.geom AS input_geom | |
FROM | |
communes, | |
(SELECT ST_SetSRID(ST_GeomFromGeoJSON('%s'), 4326) geom) input | |
WHERE ST_Intersects(communes.geom, input.geom) | |
) AS matching_communes, | |
appellation | |
WHERE matching_communes.insee = appellation.insee; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment