forked from NicolasDEVOUCOUX/rva
-
Notifications
You must be signed in to change notification settings - Fork 0
/
voie_21_vues_xapps.sql
1737 lines (1666 loc) · 94.8 KB
/
voie_21_vues_xapps.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*VOIE V1.0*/
/*Creation des vues nécessaires à l'application web-métier */
/*voie_21_VUES_XAPPS.sql */
/*PostGIS*/
/* GeoCompiegnois - http://geo.compiegnois.fr/ */
/* Auteur : Grégory Bodet */
-- ####################################################################################################################################################
-- ### ###
-- ### DROP ###
-- ### ###
-- ####################################################################################################################################################
DROP VIEW IF EXISTS r_plan.geo_v_plan_troncon;
DROP VIEW IF EXISTS r_plan.geo_v_plan_lib_voie;
DROP VIEW IF EXISTS r_plan.geo_v_plan_lib_voie_arc;
DROP VIEW IF EXISTS r_plan.geo_v_plan_sens_uniq;
DROP VIEW IF EXISTS r_plan.geo_v_plan_cartouche;
DROP VIEW IF EXISTS x_apps.xapps_an_voie;
DROP VIEW IF EXISTS x_apps.xapps_geo_vmr_troncon_voirie;
DROP VIEW IF EXISTS x_apps.xapps_geo_vmr_voie;
DROP VIEW IF EXISTS x_apps.xapps_an_vmr_troncon;
DROP VIEW IF EXISTS xapps_an_v_troncon_h;
-- ####################################################################################################################################################
-- ### ###
-- ### VUES APPLICATIVES ###
-- ### ###
-- ####################################################################################################################################################
-- ################################################################# VUES DU PLAN DE VILLE DYNAMIQUE ###############################################
-- View: r_plan.geo_v_plan_troncon
-- DROP VIEW r_plan.geo_v_plan_troncon;
CREATE OR REPLACE VIEW r_plan.geo_v_plan_troncon AS
SELECT t.id_tronc,t.insee_g,t.insee_d,a.type_tronc,a.hierarchie,a.franchiss,a.nb_voie,a.projet,a.fictif,c.type_circu,t.pente,t.geom
FROM r_objet.geo_objet_troncon t
LEFT JOIN r_voie.an_troncon a ON a.id_tronc = t.id_tronc
LEFT JOIN m_voirie.an_voirie_circu c ON c.id_tronc = t.id_tronc
WHERE a.projet IS FALSE;
ALTER TABLE r_plan.geo_v_plan_troncon
OWNER TO create_sig;
COMMENT ON VIEW r_plan.geo_v_plan_troncon
IS 'Vue du plan dynamique destinée au dessin des tronçons';
-- View: r_plan.geo_v_plan_lib_voie
-- DROP VIEW r_plan.geo_v_plan_lib_voie;
CREATE OR REPLACE VIEW r_plan.geo_v_plan_lib_voie AS
SELECT t.id_tronc,t.id_voie_g,t.id_voie_d,vg.libvoie_c as libvoie_g,vd.libvoie_c as libvoie_c,t.insee_g,t.insee_d,t.noeud_d,t.noeud_f,a.type_tronc,a.hierarchie,a.franchiss,a.nb_voie,a.projet,g.statut_jur,g.num_statut,t.geom
FROM r_objet.geo_objet_troncon t
LEFT JOIN r_voie.an_troncon a ON a.id_tronc = t.id_tronc
LEFT JOIN r_voie.an_voie vg ON vg.id_voie = t.id_voie_g
LEFT JOIN r_voie.an_voie vd ON vd.id_voie = t.id_voie_d
LEFT JOIN m_voirie.an_voirie_gest g ON g.id_tronc = t.id_tronc
WHERE a.projet IS FALSE AND (t.id_voie_g IS NOT NULL OR t.id_voie_d IS NOT NULL);
ALTER TABLE r_plan.geo_v_plan_lib_voie
OWNER TO create_sig;
COMMENT ON VIEW r_plan.geo_v_plan_lib_voie
IS 'Vue du plan dynamique destinée à l''étiquettage des noms des tronçons existants';
-- View: r_plan.geo_v_plan_lib_voie_arc
-- DROP VIEW r_plan.geo_v_plan_lib_voie_arc;
CREATE OR REPLACE VIEW r_plan.geo_v_plan_lib_voie_arc
AS
SELECT t.id_tronc,
t.id_voie_g,
t.id_voie_d,
vg.libvoie_c AS libvoie_g,
vd.libvoie_c,
upper(vd.libvoie_c::text) AS libvoie_maj,
t.insee_g,
t.insee_d,
t.noeud_d,
t.noeud_f,
a.type_tronc,
a.hierarchie,
a.franchiss,
a.nb_voie,
a.projet,
g.statut_jur,
g.num_statut,
t.geom
FROM r_objet.geo_objet_troncon t
LEFT JOIN r_voie.an_troncon a ON a.id_tronc = t.id_tronc
LEFT JOIN r_voie.an_voie vg ON vg.id_voie = t.id_voie_g
LEFT JOIN r_voie.an_voie vd ON vd.id_voie = t.id_voie_d
LEFT JOIN m_voirie.an_voirie_gest g ON g.id_tronc = t.id_tronc
WHERE a.projet IS FALSE AND (t.id_voie_g IS NOT NULL OR t.id_voie_d IS NOT NULL OR g.num_statut IS NOT NULL) AND (t.insee_g::text = '60023'::text OR t.insee_g::text = '60067'::text OR t.insee_g::text = '60068'::text OR t.insee_g::text = '60070'::text OR t.insee_g::text = '60151'::text OR t.insee_g::text = '60156'::text OR t.insee_g::text = '60159'::text OR t.insee_g::text = '60323'::text OR t.insee_g::text = '60325'::text OR t.insee_g::text = '60326'::text OR t.insee_g::text = '60337'::text OR t.insee_g::text = '60338'::text OR t.insee_g::text = '60382'::text OR t.insee_g::text = '60402'::text OR t.insee_g::text = '60447'::text OR t.insee_g::text = '60578'::text OR t.insee_g::text = '60579'::text OR t.insee_g::text = '60597'::text OR t.insee_g::text = '60600'::text OR t.insee_g::text = '60665'::text OR t.insee_g::text = '60667'::text OR t.insee_g::text = '60674'::text OR t.insee_d::text = '60023'::text OR t.insee_d::text = '60067'::text OR t.insee_d::text = '60068'::text OR t.insee_d::text = '60070'::text OR t.insee_d::text = '60151'::text OR t.insee_d::text = '60156'::text OR t.insee_d::text = '60159'::text OR t.insee_d::text = '60323'::text OR t.insee_d::text = '60325'::text OR t.insee_d::text = '60326'::text OR t.insee_d::text = '60337'::text OR t.insee_d::text = '60338'::text OR t.insee_d::text = '60382'::text OR t.insee_d::text = '60402'::text OR t.insee_d::text = '60447'::text OR t.insee_d::text = '60578'::text OR t.insee_d::text = '60579'::text OR t.insee_d::text = '60597'::text OR t.insee_d::text = '60600'::text OR t.insee_d::text = '60665'::text OR t.insee_d::text = '60667'::text OR t.insee_d::text = '60674'::text);
ALTER TABLE r_plan.geo_v_plan_lib_voie_arc
OWNER TO create_sig;
COMMENT ON VIEW r_plan.geo_v_plan_lib_voie_arc
IS 'Vue du plan dynamique destinée à l''étiquettage des noms des tronçons existants filtré sur l''ARC';
-- View: r_plan.geo_v_plan_sens_uniq
-- DROP VIEW r_plan.geo_v_plan_sens_uniq;
CREATE OR REPLACE VIEW r_plan.geo_v_plan_sens_uniq AS
SELECT t.id_tronc,a.type_tronc,a.hierarchie,a.franchiss,a.nb_voie,a.projet,c.sens_circu,t.geom
FROM r_objet.geo_objet_troncon t
LEFT JOIN r_voie.an_troncon a ON a.id_tronc = t.id_tronc
LEFT JOIN m_voirie.an_voirie_circu c ON c.id_tronc = t.id_tronc
WHERE a.projet IS false AND (c.sens_circu = '02' OR c.sens_circu = '03');
ALTER TABLE r_plan.geo_v_plan_sens_uniq
OWNER TO create_sig;
COMMENT ON VIEW r_plan.geo_v_plan_sens_uniq
IS 'Vue du plan dynamique destinée à la matérialisation des flèches pour les sens uniques';
-- View: r_plan.geo_v_plan_cartouche
-- DROP VIEW r_plan.geo_v_plan_cartouche;
CREATE OR REPLACE VIEW r_plan.geo_v_plan_cartouche AS
SELECT t.id_tronc,a.type_tronc,a.hierarchie,a.projet,g.statut_jur,g.num_statut,t.geom
FROM r_objet.geo_objet_troncon t
LEFT JOIN r_voie.an_troncon a ON a.id_tronc = t.id_tronc
LEFT JOIN m_voirie.an_voirie_gest g ON g.id_tronc = t.id_tronc
WHERE a.projet IS false AND (g.statut_jur = '01' OR g.statut_jur = '02' OR g.statut_jur = '03');
ALTER TABLE r_plan.geo_v_plan_cartouche
OWNER TO create_sig;
COMMENT ON VIEW r_plan.geo_v_plan_cartouche
IS 'Vue du plan dynamique destinée à la matérialisation des cartouches pour les autoroutes, les routes nationales et départementales';
-- View: x_apps.xapps_an_voie
-- DROP VIEW x_apps.xapps_an_voie;
CREATE OR REPLACE VIEW x_apps.xapps_an_voie AS
SELECT v.id_voie,
v.libvoie_c,
c.commune
FROM r_voie.an_voie v,
r_osm.geo_osm_commune c
WHERE v.insee = c.insee::bpchar;
ALTER TABLE x_apps.xapps_an_voie
OWNER TO create_sig;
COMMENT ON VIEW x_apps.xapps_an_voie
IS 'Vue d''exploitation des libellés de voie par commune';
-- View: x_apps.xapps_geo_v_troncon_voirie
-- DROP MATERIALIZED VIEW x_apps.xapps_geo_vmr_troncon_voirie;
CREATE MATERIALIZED VIEW x_apps.xapps_geo_vmr_troncon_voirie
TABLESPACE pg_default
AS
WITH req_v AS (
SELECT t.id_tronc,
t.id_voie_g AS id_voie,
v_1.libvoie_c AS libvoie,
v_1.date_lib,
v_1.rivoli,
t.insee_g AS insee,
com.commune,
t.noeud_d,
t.noeud_f,
ltb.valeur AS type_tronc,
ltc.valeur AS hierarchie,
ltd.valeur AS franchiss,
a.nb_voie,
a.projet,
a.fictif,
lte.valeur AS statut_jur,
g.num_statut,
ltg.valeur AS gestion,
ltf.valeur AS doman,
lth.valeur AS proprio,
lti.valeur AS type_circu,
ltj.valeur AS sens_circu,
ltk.valeur AS v_max,
(((
CASE
WHEN c.c_circu::text ~~ '%10%'::text AND c.c_observ::text ~~ '%H:%'::text THEN ('Hauteur : '::text || "substring"(c.c_observ::text, "position"(c.c_observ::text, 'H:'::text) + 2, "position"(c.c_observ::text, 'm'::text) - "position"(c.c_observ::text, 'H:'::text) - 1)) || '<br>'::text
ELSE
CASE
WHEN c.c_circu::text ~~ '%10%'::text THEN 'Hauteur : non renseignée <br>'::text
ELSE ''::text
END
END ||
CASE
WHEN c.c_circu::text ~~ '%20%'::text AND c.c_observ::text ~~ '%L:%'::text THEN ('Largeur : '::text || "substring"(c.c_observ::text, "position"(c.c_observ::text, 'L:'::text) + 2,
CASE
WHEN ("position"(c.c_observ::text, 'm'::text) - "position"(c.c_observ::text, 'L:'::text) - 1) < 0 THEN
CASE
WHEN "substring"(c.c_observ::text, "position"(c.c_observ::text, 'L:'::text) + 2, 4) ~~ '%,%'::text THEN 4
ELSE 2
END
ELSE "position"(c.c_observ::text, 'm'::text) - "position"(c.c_observ::text, 'L:'::text) - 1
END)) || '<br>'::text
ELSE
CASE
WHEN c.c_circu::text ~~ '%20%'::text THEN 'Largeur : non renseignée <br>'::text
ELSE ''::text
END
END) ||
CASE
WHEN c.c_circu::text ~~ '%30%'::text AND c.c_observ::text ~~ '%P:%'::text THEN ('Poids : '::text || "substring"(c.c_observ::text, "position"(c.c_observ::text, 'P:'::text) + 2, "position"(c.c_observ::text, 't'::text) - "position"(c.c_observ::text, 'P:'::text) - 1)) || '<br>'::text
ELSE
CASE
WHEN c.c_circu::text ~~ '%30%'::text THEN 'Poids : non renseigné <br>'::text
ELSE ''::text
END
END) ||
CASE
WHEN c.c_circu::text ~~ '%40%'::text THEN 'Interdit aux transports de matières dangereuses'::text
ELSE ''::text
END) ||
CASE
WHEN c.c_circu::text ~~ '%50%'::text AND c.c_observ::text ~~ '%Tv:%'::text THEN ('Type de véhicule : '::text || "substring"(c.c_observ::text, "position"(c.c_observ::text, 'Tv:'::text) + 3)) || '<br>'::text
ELSE
CASE
WHEN c.c_circu::text ~~ '%50%'::text THEN 'Type de véhicule : non renseigné<br>'::text
ELSE ''::text
END
END AS c_circu,
c.c_observ,
c.date_ouv,
g.date_rem,
t.pente,
t.observ,
lta.valeur AS src_geom,
t.src_date,
t.date_sai,
t.date_maj,
t.src_tronc,
t.geom
FROM r_objet.geo_objet_troncon t
LEFT JOIN r_voie.an_troncon a ON a.id_tronc = t.id_tronc
LEFT JOIN r_voie.an_voie v_1 ON v_1.id_voie = t.id_voie_g
LEFT JOIN m_voirie.an_voirie_gest g ON g.id_tronc = t.id_tronc
LEFT JOIN m_voirie.an_voirie_circu c ON c.id_tronc = t.id_tronc
LEFT JOIN r_osm.geo_osm_commune com ON t.insee_g::text = com.insee::text
LEFT JOIN r_objet.lt_src_geom lta ON lta.code::text = t.src_geom::text
LEFT JOIN r_voie.lt_type_tronc ltb ON ltb.code::text = a.type_tronc::text
LEFT JOIN r_voie.lt_hierarchie ltc ON ltc.code::text = a.hierarchie::text
LEFT JOIN r_voie.lt_franchiss ltd ON ltd.code::text = a.franchiss::text
LEFT JOIN m_voirie.lt_statut_jur lte ON lte.code::text = g.statut_jur::text
LEFT JOIN m_voirie.lt_doman ltf ON ltf.code::text = g.doman::text
LEFT JOIN m_voirie.lt_gestion ltg ON ltg.code::text = g.gestion::text
LEFT JOIN m_voirie.lt_gestion lth ON lth.code::text = g.proprio::text
LEFT JOIN m_voirie.lt_type_circu lti ON lti.code::text = c.type_circu::text
LEFT JOIN m_voirie.lt_sens_circu ltj ON ltj.code::text = c.sens_circu::text
LEFT JOIN m_voirie.lt_v_max ltk ON ltk.code::text = c.v_max::text
WHERE t.insee_g::text = t.insee_d::text
UNION ALL
SELECT t.id_tronc,
t.id_voie_g AS id_voie,
v_1.libvoie_c AS libvoie,
v_1.date_lib,
v_1.rivoli,
t.insee_g AS insee,
com.commune,
t.noeud_d,
t.noeud_f,
ltb.valeur AS type_tronc,
ltc.valeur AS hierarchie,
ltd.valeur AS franchiss,
a.nb_voie,
a.projet,
a.fictif,
lte.valeur AS statut_jur,
g.num_statut,
ltg.valeur AS gestion,
ltf.valeur AS doman,
lth.valeur AS proprio,
lti.valeur AS type_circu,
ltj.valeur AS sens_circu,
ltk.valeur AS v_max,
(((
CASE
WHEN c.c_circu::text ~~ '%10%'::text AND c.c_observ::text ~~ '%H:%'::text THEN ('Hauteur : '::text || "substring"(c.c_observ::text, "position"(c.c_observ::text, 'H:'::text) + 2, "position"(c.c_observ::text, 'm'::text) - "position"(c.c_observ::text, 'H:'::text) - 1)) || '<br>'::text
ELSE
CASE
WHEN c.c_circu::text ~~ '%10%'::text THEN 'Hauteur : non renseignée <br>'::text
ELSE ''::text
END
END ||
CASE
WHEN c.c_circu::text ~~ '%20%'::text AND c.c_observ::text ~~ '%L:%'::text THEN ('Largeur : '::text || "substring"(c.c_observ::text, "position"(c.c_observ::text, 'L:'::text) + 2,
CASE
WHEN ("position"(c.c_observ::text, 'm'::text) - "position"(c.c_observ::text, 'L:'::text) - 1) < 0 THEN
CASE
WHEN "substring"(c.c_observ::text, "position"(c.c_observ::text, 'L:'::text) + 2, 4) ~~ '%,%'::text THEN 4
ELSE 2
END
ELSE "position"(c.c_observ::text, 'm'::text) - "position"(c.c_observ::text, 'L:'::text) - 1
END)) || '<br>'::text
ELSE
CASE
WHEN c.c_circu::text ~~ '%20%'::text THEN 'Largeur : non renseignée <br>'::text
ELSE ''::text
END
END) ||
CASE
WHEN c.c_circu::text ~~ '%30%'::text AND c.c_observ::text ~~ '%P:%'::text THEN ('Poids : '::text || "substring"(c.c_observ::text, "position"(c.c_observ::text, 'P:'::text) + 2, "position"(c.c_observ::text, 't'::text) - "position"(c.c_observ::text, 'P:'::text) - 1)) || '<br>'::text
ELSE
CASE
WHEN c.c_circu::text ~~ '%30%'::text THEN 'Poids : non renseigné <br>'::text
ELSE ''::text
END
END) ||
CASE
WHEN c.c_circu::text ~~ '%40%'::text THEN 'Interdit aux transports de matières dangereuses'::text
ELSE ''::text
END) ||
CASE
WHEN c.c_circu::text ~~ '%50%'::text AND c.c_observ::text ~~ '%Tv:%'::text THEN ('Type de véhicule : '::text || "substring"(c.c_observ::text, "position"(c.c_observ::text, 'Tv:'::text) + 3)) || '<br>'::text
ELSE
CASE
WHEN c.c_circu::text ~~ '%50%'::text THEN 'Type de véhicule : non renseigné<br>'::text
ELSE ''::text
END
END AS c_circu,
c.c_observ,
c.date_ouv,
g.date_rem,
t.pente,
t.observ,
lta.valeur AS src_geom,
t.src_date,
t.date_sai,
t.date_maj,
t.src_tronc,
t.geom
FROM r_objet.geo_objet_troncon t
LEFT JOIN r_voie.an_troncon a ON a.id_tronc = t.id_tronc
LEFT JOIN r_voie.an_voie v_1 ON v_1.id_voie = t.id_voie_g
LEFT JOIN m_voirie.an_voirie_gest g ON g.id_tronc = t.id_tronc
LEFT JOIN m_voirie.an_voirie_circu c ON c.id_tronc = t.id_tronc
LEFT JOIN r_osm.geo_osm_commune com ON t.insee_g::text = com.insee::text
LEFT JOIN r_objet.lt_src_geom lta ON lta.code::text = t.src_geom::text
LEFT JOIN r_voie.lt_type_tronc ltb ON ltb.code::text = a.type_tronc::text
LEFT JOIN r_voie.lt_hierarchie ltc ON ltc.code::text = a.hierarchie::text
LEFT JOIN r_voie.lt_franchiss ltd ON ltd.code::text = a.franchiss::text
LEFT JOIN m_voirie.lt_statut_jur lte ON lte.code::text = g.statut_jur::text
LEFT JOIN m_voirie.lt_doman ltf ON ltf.code::text = g.doman::text
LEFT JOIN m_voirie.lt_gestion ltg ON ltg.code::text = g.gestion::text
LEFT JOIN m_voirie.lt_gestion lth ON lth.code::text = g.proprio::text
LEFT JOIN m_voirie.lt_type_circu lti ON lti.code::text = c.type_circu::text
LEFT JOIN m_voirie.lt_sens_circu ltj ON ltj.code::text = c.sens_circu::text
LEFT JOIN m_voirie.lt_v_max ltk ON ltk.code::text = c.v_max::text
WHERE t.insee_g::text <> t.insee_d::text
UNION ALL
SELECT t.id_tronc,
t.id_voie_d AS id_voie,
v_1.libvoie_c AS libvoie,
v_1.date_lib,
v_1.rivoli,
t.insee_d AS insee,
com.commune,
t.noeud_d,
t.noeud_f,
ltb.valeur AS type_tronc,
ltc.valeur AS hierarchie,
ltd.valeur AS franchiss,
a.nb_voie,
a.projet,
a.fictif,
lte.valeur AS statut_jur,
g.num_statut,
ltg.valeur AS gestion,
ltf.valeur AS doman,
lth.valeur AS proprio,
lti.valeur AS type_circu,
ltj.valeur AS sens_circu,
ltk.valeur AS v_max,
(((
CASE
WHEN c.c_circu::text ~~ '%10%'::text AND c.c_observ::text ~~ '%H:%'::text THEN ('Hauteur : '::text || "substring"(c.c_observ::text, "position"(c.c_observ::text, 'H:'::text) + 2, "position"(c.c_observ::text, 'm'::text) - "position"(c.c_observ::text, 'H:'::text) - 1)) || '<br>'::text
ELSE
CASE
WHEN c.c_circu::text ~~ '%10%'::text THEN 'Hauteur : non renseignée <br>'::text
ELSE ''::text
END
END ||
CASE
WHEN c.c_circu::text ~~ '%20%'::text AND c.c_observ::text ~~ '%L:%'::text THEN ('Largeur : '::text || "substring"(c.c_observ::text, "position"(c.c_observ::text, 'L:'::text) + 2,
CASE
WHEN ("position"(c.c_observ::text, 'm'::text) - "position"(c.c_observ::text, 'L:'::text) - 1) < 0 THEN
CASE
WHEN "substring"(c.c_observ::text, "position"(c.c_observ::text, 'L:'::text) + 2, 4) ~~ '%,%'::text THEN 4
ELSE 2
END
ELSE "position"(c.c_observ::text, 'm'::text) - "position"(c.c_observ::text, 'L:'::text) - 1
END)) || '<br>'::text
ELSE
CASE
WHEN c.c_circu::text ~~ '%20%'::text THEN 'Largeur : non renseignée <br>'::text
ELSE ''::text
END
END) ||
CASE
WHEN c.c_circu::text ~~ '%30%'::text AND c.c_observ::text ~~ '%P:%'::text THEN ('Poids : '::text || "substring"(c.c_observ::text, "position"(c.c_observ::text, 'P:'::text) + 2, "position"(c.c_observ::text, 't'::text) - "position"(c.c_observ::text, 'P:'::text) - 1)) || '<br>'::text
ELSE
CASE
WHEN c.c_circu::text ~~ '%30%'::text THEN 'Poids : non renseigné <br>'::text
ELSE ''::text
END
END) ||
CASE
WHEN c.c_circu::text ~~ '%40%'::text THEN 'Interdit aux transports de matières dangereuses'::text
ELSE ''::text
END) ||
CASE
WHEN c.c_circu::text ~~ '%50%'::text AND c.c_observ::text ~~ '%Tv:%'::text THEN ('Type de véhicule : '::text || "substring"(c.c_observ::text, "position"(c.c_observ::text, 'Tv:'::text) + 3)) || '<br>'::text
ELSE
CASE
WHEN c.c_circu::text ~~ '%50%'::text THEN 'Type de véhicule : non renseigné<br>'::text
ELSE ''::text
END
END AS c_circu,
c.c_observ,
c.date_ouv,
g.date_rem,
t.pente,
t.observ,
lta.valeur AS src_geom,
t.src_date,
t.date_sai,
t.date_maj,
t.src_tronc,
t.geom
FROM r_objet.geo_objet_troncon t
LEFT JOIN r_voie.an_troncon a ON a.id_tronc = t.id_tronc
LEFT JOIN r_voie.an_voie v_1 ON v_1.id_voie = t.id_voie_d
LEFT JOIN m_voirie.an_voirie_gest g ON g.id_tronc = t.id_tronc
LEFT JOIN m_voirie.an_voirie_circu c ON c.id_tronc = t.id_tronc
LEFT JOIN r_osm.geo_osm_commune com ON t.insee_d::text = com.insee::text
LEFT JOIN r_objet.lt_src_geom lta ON lta.code::text = t.src_geom::text
LEFT JOIN r_voie.lt_type_tronc ltb ON ltb.code::text = a.type_tronc::text
LEFT JOIN r_voie.lt_hierarchie ltc ON ltc.code::text = a.hierarchie::text
LEFT JOIN r_voie.lt_franchiss ltd ON ltd.code::text = a.franchiss::text
LEFT JOIN m_voirie.lt_statut_jur lte ON lte.code::text = g.statut_jur::text
LEFT JOIN m_voirie.lt_doman ltf ON ltf.code::text = g.doman::text
LEFT JOIN m_voirie.lt_gestion ltg ON ltg.code::text = g.gestion::text
LEFT JOIN m_voirie.lt_gestion lth ON lth.code::text = g.proprio::text
LEFT JOIN m_voirie.lt_type_circu lti ON lti.code::text = c.type_circu::text
LEFT JOIN m_voirie.lt_sens_circu ltj ON ltj.code::text = c.sens_circu::text
LEFT JOIN m_voirie.lt_v_max ltk ON ltk.code::text = c.v_max::text
WHERE t.insee_g::text <> t.insee_d::text
), req_lv AS (
SELECT xapps_geo_v_voie.gid,
xapps_geo_v_voie.id_voie,
xapps_geo_v_voie.long,
xapps_geo_v_voie.libvoie_c
FROM x_apps.xapps_geo_v_voie
)
SELECT row_number() OVER () AS gid,
now() AS date_extract,
req_v.id_tronc,
req_v.id_voie,
req_v.libvoie,
req_v.date_lib,
req_v.rivoli,
req_v.insee,
req_v.commune,
req_v.noeud_d,
req_v.noeud_f,
req_v.type_tronc,
req_v.hierarchie,
req_v.franchiss,
req_v.nb_voie,
req_v.projet,
req_v.fictif,
req_v.statut_jur,
req_v.num_statut,
req_v.gestion,
req_v.doman,
req_v.proprio,
req_v.type_circu,
req_v.sens_circu,
req_v.v_max,
req_v.c_circu,
req_v.c_observ,
req_v.date_ouv,
req_v.date_rem,
req_v.pente,
req_v.observ,
req_v.src_geom,
req_v.src_date,
req_v.date_sai,
req_v.date_maj,
round(st_length(req_v.geom)::integer::numeric, 0)::integer AS long_troncon,
req_v.src_tronc,
v.libvoie_c,
req_lv.long,
req_v.geom
FROM req_v
LEFT JOIN req_lv ON req_v.id_voie = req_lv.id_voie
LEFT JOIN r_voie.an_voie v ON v.id_voie = req_v.id_voie
ORDER BY req_v.id_tronc
WITH DATA;
ALTER TABLE x_apps.xapps_geo_vmr_troncon_voirie
OWNER TO create_sig;
COMMENT ON MATERIALIZED VIEW x_apps.xapps_geo_vmr_troncon_voirie
IS 'Vue matérilaisée complète et décodée des données relatives au troncon et à ses propriétés métiers de circulation et de gestion, destinée à l''exploitation applicative (générateur d''apps). Cette vue est rafraîchie automatiquement toutes les nuits. Au besoin un rafraîchissement ponctuel est possible.';
-- Materialized View: x_apps.xapps_geo_vmr_voie
-- DROP MATERIALIZED VIEW x_apps.xapps_geo_vmr_voie;
CREATE MATERIALIZED VIEW x_apps.xapps_geo_vmr_voie AS
WITH req_v AS (
SELECT t.id_voie_g AS id_voie,
t.geom
FROM r_objet.geo_objet_troncon t,
r_voie.an_troncon tr
WHERE t.id_tronc = tr.id_tronc AND t.id_voie_g = t.id_voie_d
UNION ALL
SELECT t.id_voie_g AS id_voie,
t.geom
FROM r_objet.geo_objet_troncon t,
r_voie.an_troncon tr
WHERE t.id_tronc = tr.id_tronc AND t.id_voie_g <> t.id_voie_d
UNION ALL
SELECT t.id_voie_d AS id_voie,
t.geom
FROM r_objet.geo_objet_troncon t,
r_voie.an_troncon tr
WHERE t.id_tronc = tr.id_tronc AND t.id_voie_g <> t.id_voie_d
UNION ALL
SELECT t.id_voie_d AS id_voie,
t.geom
FROM r_objet.geo_objet_troncon t,
r_voie.an_troncon tr
WHERE t.id_tronc = tr.id_tronc AND t.id_voie_g IS NULL AND t.id_voie_d IS NULL
), req_nv AS (
SELECT an_voie.insee,
an_voie.id_voie,
an_voie.libvoie_c
FROM r_voie.an_voie
), req_l AS (
SELECT t.id_voie_g AS id_voie,
t.geom
FROM r_objet.geo_objet_troncon t,
r_voie.an_troncon tr
WHERE t.id_tronc = tr.id_tronc AND t.id_voie_g = t.id_voie_d AND tr.fictif = false
UNION ALL
SELECT t.id_voie_g AS id_voie,
t.geom
FROM r_objet.geo_objet_troncon t,
r_voie.an_troncon tr
WHERE t.id_tronc = tr.id_tronc AND t.id_voie_g <> t.id_voie_d AND tr.fictif = false
UNION ALL
SELECT t.id_voie_d AS id_voie,
t.geom
FROM r_objet.geo_objet_troncon t,
r_voie.an_troncon tr
WHERE t.id_tronc = tr.id_tronc AND t.id_voie_g <> t.id_voie_d AND tr.fictif = false
UNION ALL
SELECT t.id_voie_d AS id_voie,
t.geom
FROM r_objet.geo_objet_troncon t,
r_voie.an_troncon tr
WHERE t.id_tronc = tr.id_tronc AND t.id_voie_g IS NULL AND t.id_voie_d IS NULL AND tr.fictif = false
)
SELECT row_number() OVER () AS gid,
now() AS date_extract,
req_v.id_voie,
req_nv.insee,
round(st_length(st_multi(st_union(req_l.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long,
req_nv.libvoie_c,
st_linemerge(st_multi(st_union(req_v.geom))::geometry(MultiLineString,2154)) AS geom
FROM req_v
LEFT JOIN req_nv ON req_v.id_voie = req_nv.id_voie
LEFT JOIN req_l ON req_l.id_voie = req_v.id_voie
WHERE req_v.id_voie IS NOT NULL
GROUP BY req_v.id_voie, req_nv.libvoie_c, req_nv.insee
WITH DATA;
ALTER TABLE x_apps.xapps_geo_vmr_voie
OWNER TO create_sig;
COMMENT ON MATERIALIZED VIEW x_apps.xapps_geo_vmr_voie
IS 'Vue de synthèse des voies (agréagation des tronçons pour calcul) (générateur d''apps)
Cette vue est rafraichie toutes les nuits par une tache CRON sur le serveur sig-sgbd.';
-- Index: x_apps.idx_xapps_v_voie_id_voie
-- DROP INDEX x_apps.idx_xapps_v_voie_id_voie;
CREATE INDEX idx_xapps_v_voie_id_voie
ON x_apps.xapps_geo_vmr_voie
USING btree
(id_voie);
-- View: x_apps.xapps_an_v_troncon
-- DROP MATERIALIZED VIEW x_apps.xapps_an_v_troncon;
CREATE MATERIALIZED VIEW x_apps.xapps_an_vmr_troncon
TABLESPACE pg_default
AS
WITH req_v_com AS (
SELECT geo_vm_osm_commune_apc.insee,
geo_vm_osm_commune_apc.commune_m AS commune
FROM r_osm.geo_vm_osm_commune_apc
), req_v_t1 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_t1
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text = t.insee_d::text AND t.projet = false AND t.insee_g::text = a.insee::text AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text)
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t2 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_t2
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.projet = false AND t.insee_g::text = a.insee::text AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text)
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t3 AS (
SELECT t.insee_d AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_t3
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.projet = false AND t.insee_d::text = a.insee::text AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text)
GROUP BY t.insee_d
ORDER BY t.insee_d
), req_v_t1_g00 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg001
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text = t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '00'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t2_g00 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg002
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '00'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t3_g00 AS (
SELECT t.insee_d AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg003
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_d::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '00'::text
GROUP BY t.insee_d
ORDER BY t.insee_d
), req_v_t1_g01 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg011
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text = t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '01'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t2_g01 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg012
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '01'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t3_g01 AS (
SELECT t.insee_d AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg013
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_d::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '01'::text
GROUP BY t.insee_d
ORDER BY t.insee_d
), req_v_t1_g02 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg021
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text = t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '02'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t2_g02 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg022
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '02'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t3_g02 AS (
SELECT t.insee_d AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg023
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_d::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '02'::text
GROUP BY t.insee_d
ORDER BY t.insee_d
), req_v_t1_g03 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg031
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text = t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '03'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t2_g03 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg032
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '03'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t3_g03 AS (
SELECT t.insee_d AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg033
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_d::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '03'::text
GROUP BY t.insee_d
ORDER BY t.insee_d
), req_v_t1_g04 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg041
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text = t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '04'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t2_g04 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg042
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '04'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t3_g04 AS (
SELECT t.insee_d AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg043
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_d::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '04'::text
GROUP BY t.insee_d
ORDER BY t.insee_d
), req_v_t1_g05 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg051
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text = t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '05'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t2_g05 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg052
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '05'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t3_g05 AS (
SELECT t.insee_d AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg053
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_d::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '05'::text
GROUP BY t.insee_d
ORDER BY t.insee_d
), req_v_t1_g06 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg061
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text = t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '06'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t2_g06 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg062
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '06'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t3_g06 AS (
SELECT t.insee_d AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg063
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_d::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '06'::text
GROUP BY t.insee_d
ORDER BY t.insee_d
), req_v_t1_g07 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg071
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text = t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '07'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t2_g07 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg072
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '07'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t3_g07 AS (
SELECT t.insee_d AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg073
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_d::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '07'::text
GROUP BY t.insee_d
ORDER BY t.insee_d
), req_v_t1_g99 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg991
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text = t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '99'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t2_g99 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg992
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '99'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t3_g99 AS (
SELECT t.insee_d AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_tg993
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_d::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.gestion::text = '99'::text
GROUP BY t.insee_d
ORDER BY t.insee_d
), req_v_t1_d00 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_td001
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text = t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.doman::text = '00'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t2_d00 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_td002
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.doman::text = '00'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t3_d00 AS (
SELECT t.insee_d AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_td003
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_d::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.doman::text = '00'::text
GROUP BY t.insee_d
ORDER BY t.insee_d
), req_v_t1_d01 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_td011
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text = t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.doman::text = '01'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t2_d01 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_td012
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.doman::text = '01'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t3_d01 AS (
SELECT t.insee_d AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_td013
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_d::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.doman::text = '01'::text
GROUP BY t.insee_d
ORDER BY t.insee_d
), req_v_t1_d02 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_td021
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text = t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.doman::text = '02'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t2_d02 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_td022
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.doman::text = '02'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t3_d02 AS (
SELECT t.insee_d AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_td023
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_d::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.doman::text = '02'::text
GROUP BY t.insee_d
ORDER BY t.insee_d
), req_v_t1_s00 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_ts001
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text = t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.statut_jur::text = '00'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t2_s00 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_ts002
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.statut_jur::text = '00'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t3_s00 AS (
SELECT t.insee_d AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_ts003
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_d::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.statut_jur::text = '00'::text
GROUP BY t.insee_d
ORDER BY t.insee_d
), req_v_t1_s01 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_ts011
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text = t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.statut_jur::text = '01'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t2_s01 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_ts012
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.statut_jur::text = '01'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t3_s01 AS (
SELECT t.insee_d AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_ts013
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_d::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.statut_jur::text = '01'::text
GROUP BY t.insee_d
ORDER BY t.insee_d
), req_v_t1_s02 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_ts021
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text = t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.statut_jur::text = '02'::text
GROUP BY t.insee_g
ORDER BY t.insee_g
), req_v_t2_s02 AS (
SELECT t.insee_g AS insee,
round(st_length(st_multi(st_union(t.geom))::geometry(MultiLineString,2154))::integer::numeric, 0)::integer AS long_ts022
FROM m_voirie.geo_v_troncon_voirie t,
r_administratif.an_geo a
WHERE t.insee_g::text <> t.insee_d::text AND t.insee_g::text = a.insee::text AND t.projet = false AND (a.epci::text = '200067965'::text OR a.epci::text = '246000897'::text OR a.epci::text = '246000749'::text) AND t.statut_jur::text = '02'::text
GROUP BY t.insee_g