-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ocsge): adapt code to handle ocsge from drom com
- Loading branch information
Showing
17 changed files
with
148 additions
and
41 deletions.
There are no files selected for viewing
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
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
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
59 changes: 59 additions & 0 deletions
59
airflow/include/sql/sparte/macros/gpu/zonage_urbanisme.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
{% macro zonage_urbanisme(srid, extent_table) %} | ||
{{ config(materialized='table') }} | ||
|
||
with extent as ( | ||
SELECT ST_transform(ST_Envelope(ST_Union(geom)), 4326) as geom FROM {{ ref(extent_table) }} | ||
) | ||
SELECT | ||
gpu_doc_id, | ||
gpu_status, | ||
gpu_timestamp, | ||
partition, | ||
libelle, | ||
libelle_long, | ||
type_zone, | ||
destination_dominante, | ||
nom_fichier, | ||
url_fichier, | ||
commune_code, | ||
date_approbation, | ||
date_validation, | ||
id_document_urbanisme, | ||
checksum, | ||
new_geom as geom, | ||
srid_source, | ||
ST_Area(new_geom) as surface | ||
FROM ( | ||
SELECT | ||
gpu_doc_id, | ||
gpu_status, | ||
gpu_timestamp::timestamptz as gpu_timestamp, | ||
partition, | ||
libelle, | ||
NULLIF(libelong, '') as libelle_long, | ||
typezone as type_zone, | ||
NULLIF(destdomi, '') as destination_dominante, | ||
nomfic as nom_fichier, | ||
NULLIF(urlfic, '') as url_fichier, | ||
NULLIF(insee, '') as commune_code, | ||
TO_DATE(NULLIF(datappro, ''), 'YYYYMMDD') as date_approbation, | ||
TO_DATE(NULLIF(datvalid, ''), 'YYYYMMDD') as date_validation, | ||
NULLIF(idurba, '') as id_document_urbanisme, | ||
checksum, | ||
row_number() OVER (PARTITION BY checksum ORDER BY gpu_timestamp), | ||
{{ make_valid_multipolygon('ST_transform(geom, ' + srid|string + ')') }} as new_geom, | ||
{{ srid }} as srid_source | ||
FROM | ||
{{ source('public', 'gpu_zone_urba') }} | ||
WHERE | ||
{{ raw_date_starts_with_yyyy('datappro') }} AND | ||
{{ raw_date_starts_with_yyyy('datvalid') }} AND | ||
NOT ST_IsEmpty(geom) AND | ||
ST_Intersects(geom, ( | ||
SELECT geom FROM extent | ||
)) | ||
) as foo | ||
WHERE row_number = 1 | ||
AND NOT ST_IsEmpty(new_geom) | ||
{% endmacro %} |
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
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
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
42 changes: 11 additions & 31 deletions
42
airflow/include/sql/sparte/models/gpu/zonage_urbanisme.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,21 @@ | ||
|
||
{{ | ||
config( | ||
materialized='table', | ||
indexes=[ | ||
{'columns': ['geom'], 'type': 'gist'}, | ||
{'columns': ['libelle'], 'type': 'btree'}, | ||
{'columns': ['type_zone'], 'type': 'btree'}, | ||
{'columns': ['checksum'], 'type': 'btree'} | ||
{'columns': ['checksum'], 'type': 'btree'}, | ||
{'columns': ['srid_source'], 'type': 'btree'} | ||
]) | ||
}} | ||
|
||
SELECT *, ST_Area(geom) as surface FROM ( | ||
SELECT | ||
gpu_doc_id, | ||
gpu_status, | ||
gpu_timestamp::timestamptz as gpu_timestamp, | ||
partition, | ||
libelle, | ||
NULLIF(libelong, '') as libelle_long, | ||
typezone as type_zone, | ||
NULLIF(destdomi, '') as destination_dominante, | ||
nomfic as nom_fichier, | ||
NULLIF(urlfic, '') as url_fichier, | ||
NULLIF(insee, '') as commune_code, | ||
TO_DATE(NULLIF(datappro, ''), 'YYYYMMDD') as date_approbation, | ||
TO_DATE(NULLIF(datvalid, ''), 'YYYYMMDD') as date_validation, | ||
NULLIF(idurba, '') as id_document_urbanisme, | ||
checksum, | ||
row_number() OVER (PARTITION BY checksum ORDER BY gpu_timestamp), | ||
{{ make_valid_multipolygon('ST_transform(geom, 2154)') }} as geom, | ||
2154 as srid_source | ||
FROM | ||
{{ source('public', 'gpu_zone_urba') }} | ||
WHERE | ||
{{ raw_date_starts_with_yyyy('datappro') }} AND | ||
{{ raw_date_starts_with_yyyy('datvalid') }} AND | ||
NOT ST_IsEmpty(geom) | ||
) as foo | ||
WHERE row_number = 1 | ||
AND NOT ST_IsEmpty(geom) | ||
SELECT * FROM {{ ref('zonage_urbanisme_guadeloupe') }} | ||
UNION ALL | ||
SELECT * FROM {{ ref('zonage_urbanisme_martinique') }} | ||
UNION ALL | ||
SELECT * FROM {{ ref('zonage_urbanisme_guyane') }} | ||
UNION ALL | ||
SELECT * FROM {{ ref('zonage_urbanisme_reunion') }} | ||
UNION ALL | ||
SELECT * FROM {{ ref('zonage_urbanisme_metropole') }} |
6 changes: 6 additions & 0 deletions
6
airflow/include/sql/sparte/models/gpu/zonage_urbanisme_guadeloupe.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{{ | ||
zonage_urbanisme( | ||
32620, | ||
"region_guadeloupe" | ||
) | ||
}} |
6 changes: 6 additions & 0 deletions
6
airflow/include/sql/sparte/models/gpu/zonage_urbanisme_guyane.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{{ | ||
zonage_urbanisme( | ||
2972, | ||
"region_guyane" | ||
) | ||
}} |
6 changes: 6 additions & 0 deletions
6
airflow/include/sql/sparte/models/gpu/zonage_urbanisme_martinique.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{{ | ||
zonage_urbanisme( | ||
32620, | ||
"region_martinique" | ||
) | ||
}} |
6 changes: 6 additions & 0 deletions
6
airflow/include/sql/sparte/models/gpu/zonage_urbanisme_metropole.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{{ | ||
zonage_urbanisme( | ||
2154, | ||
"region_metropole" | ||
) | ||
}} |
6 changes: 6 additions & 0 deletions
6
airflow/include/sql/sparte/models/gpu/zonage_urbanisme_reunion.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{{ | ||
zonage_urbanisme( | ||
2975, | ||
"region_reunion" | ||
) | ||
}} |
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
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
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
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