surfriderfoundationeurope / etl

ETL (Extract Transform Load) Data Management process
MIT License
2 stars 0 forks source link

Fix Campagne 6ef8bf4c-8db3-4276-a42c-443660b074af qui fait bugger le script bi_pipeline #31

Open charlesollion opened 1 year ago

charlesollion commented 1 year ago

L'erreur en question est : GEOSBuffer: TopologyException: No forward edges found in buffer subgraph

En modifiant le buffer de 200 à 50 comme si dessous, l'erreur disparaît.

SELECT sub.id, sub.the_geom,
   st_union(st_buffer(the_geom_monitored, 50)) AS the_geom_monitored,
   count(id_ref_campaign_fk) nb_campaign
FROM (
    SELECT
        r.id,
        tp_river.id_ref_campaign_fk,
        ST_Simplify(st_makevalid(
            st_makeline(
                tp_river.the_geom
                ORDER BY tp_river.time
            )
        ), 1, true) AS the_geom_monitored,
        r.the_geom
    FROM bi_temp.trajectory_point_river tp_river
        INNER JOIN referential.river r ON r.id = tp_river.id_ref_river_fk
    WHERE r.id = 3264
    GROUP BY r.id, tp_river.id_ref_campaign_fk
) sub
GROUP BY sub.id, sub.the_geom

Quel est l'intérêt des polygones monitorés aujourd'hui ?

charlesollion commented 1 year ago

Une meilleure version pour conserver le comportement et le rayon de 200 découper en 2 st_buffers, un premier qui ne fail jamais puis un second qui permet d'avoir le bon rayon.

    SELECT
        r.id,
        tp_river.id_ref_campaign_fk,
        st_buffer(st_buffer(ST_Simplify(st_makevalid(
            st_makeline(
                tp_river.the_geom
                ORDER BY tp_river.time
            )
        ), 1, true), 2), 198) AS the_geom_monitored,
        r.the_geom
    FROM bi_temp.trajectory_point_river tp_river
        INNER JOIN referential.river r ON r.id = tp_river.id_ref_river_fk
    WHERE r.id = 3264-- and tp_river.id_ref_campaign_fk = '6ef8bf4c-8db3-4276-a42c-443660b074af'
    GROUP BY r.id, tp_river.id_ref_campaign_fk