models.py 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. '''
  2. @author: olivier.massot, 2018
  3. '''
  4. from core import gis
  5. from core.cerberus_extend import is_int, is_float, \
  6. is_modern_french_date
  7. from core.validation import BaseGeoModel
  8. from schemas.common import INSEE_VALIDES, XMIN, YMIN, XMAX, YMAX
  9. class Artere(BaseGeoModel):
  10. filename = "artere_geo.shp"
  11. schema = {'geom': {'geometry': (gis.POLYLINE, (XMIN, YMIN, XMAX, YMAX))},
  12. 'AR_ID_INSE': {'type': 'string', 'empty': False, 'allowed': INSEE_VALIDES},
  13. 'AR_LONG': {'empty': False, 'validator': is_float},
  14. 'AR_ETAT': {'type': 'string', 'empty': False, 'allowed': ['0', '1', '2', '3', '4']},
  15. 'AR_OCCP': {'type': 'string', 'empty': False, 'allowed': ['0', '1.1', '1.2', '2', '3', '4']},
  16. 'AR_NOEUD_A': {'type': 'string', 'empty': False, 'maxlength': 20},
  17. 'AR_NOEUD_B': {'type': 'string', 'empty': False, 'maxlength': 20},
  18. 'AR_NB_FOUR': {'empty': False, 'validator': is_int},
  19. # 'AR_NB_FOUR': {'type': 'string', 'maxlength': 10},
  20. 'AR_FOU_DIS': {'empty': False, 'validator': is_int},
  21. 'AR_TYPE_FO': {'type': 'string', 'empty': False, 'multiallowed': ['PVC', 'PEHD', 'SOUS-TUBAGE PEHD', 'SOUS-TUBAGE SOUPLE', 'FACADE', 'AERIEN', 'ENCORBELLEMENT', 'AUTRE']},
  22. 'AR_DIAM_FO': {'type': 'string', 'empty': False, 'multiallowed': ['10', '14', '18', '25', '28', '32', '40', '45', '60', 'NUL']},
  23. 'AR_PRO_FOU': {'type': 'string', 'empty': False, 'multiallowed': ['MANCHE NUMERIQUE', 'COLLECTIVITE', 'ORANGE', 'AUTRE (à préciser)']},
  24. 'AR_PRO_CAB': {'type': 'string', 'empty': False, 'allowed': ['MANCHE NUMERIQUE']},
  25. 'AR_GEST_FO': {'type': 'string', 'empty': False, 'multiallowed': ['MANCHE NUMERIQUE', 'MANCHE TELECOM', 'COLLECTIVITE', 'ORANGE', 'MANCHE FIBRE', 'PRIVE', 'ERDF', 'AUTRE (à préciser)', 'NUL']},
  26. 'AR_UTIL_FO': {'type': 'string', 'empty': False, 'multiallowed': ['MANCHE NUMERIQUE', 'MANCHE TELECOM', 'COLLECTIVITE', 'ORANGE', 'PRIVE', 'AUTRE (à préciser)', 'NUL']},
  27. 'AR_DATE_IN': {'empty': False, 'validator': is_modern_french_date},
  28. 'AR_DATE_RE': {'empty': False, 'validator': is_modern_french_date},
  29. 'AR_REF_PLA': {'type': 'string', 'maxlength': 100},
  30. 'AR_SRC_GEO': {'type': 'string', 'maxlength': 50},
  31. 'AR_QLT_GEO': {'type': 'string', 'empty': False, 'allowed': ['A', 'B', 'C']},
  32. 'AR_PRO_MD': {'type': 'string', 'empty': False, 'default': 'MANCHE NUMERIQUE', 'allowed': ['MANCHE NUMERIQUE']},
  33. 'AR_COMMENT': {'type': 'string', 'maxlength': 300, 'empty': True},
  34. 'AR_STATUT': {'type': 'string', 'empty': False, 'allowed': ['APS', 'APD', 'EXE', 'REC']}}
  35. def __repr__(self):
  36. return "Artere {}-{}".format(self.AR_NOEUD_A, self.AR_NOEUD_B)
  37. class Cable(BaseGeoModel):
  38. filename = "cable_geo.shp"
  39. schema = {'geom': {'geometry': (gis.POLYLINE, (XMIN, YMIN, XMAX, YMAX))},
  40. 'CA_NUMERO': {'type': 'string', 'maxlength': 17},
  41. 'CA_TYPE': {'type': 'string', 'maxlength': 10, 'empty': False, 'allowed': ['AERIEN', 'IMMEUBLE', 'FACADE', 'MIXTE', 'SOUTERRAIN']},
  42. 'CA_ETAT': {'type': 'string', 'maxlength': 1, 'empty': False, 'allowed': ['0', '1', '2', '3', '4']},
  43. 'CA_LONG': {'validator': is_float},
  44. 'CA_EQ_A': {'type': 'string', 'maxlength': 18},
  45. 'CA_EQ_B': {'type': 'string', 'maxlength': 18},
  46. 'CA_DIAMETR': {'empty': False, 'validator': is_float},
  47. 'CA_COULEUR': {'type': 'string', 'maxlength': 20, 'empty': False, 'allowed': ['NOIR', 'BLEU', 'BLANC']},
  48. 'CA_TECHNOL': {'type': 'string', 'maxlength': 17, 'empty': False, 'allowed': ['G657A2_M6', 'G657A2_M12']},
  49. 'CA_NB_FO': {'validator': is_int},
  50. 'CA_NB_FO_U': {'empty': False, 'validator': is_int},
  51. 'CA_NB_FO_D': {'empty': False, 'validator': is_int},
  52. 'CA_PRO': {'type': 'string', 'maxlength': 20, 'empty': False, 'allowed': ['MANCHE NUMERIQUE']},
  53. 'CA_GEST': {'type': 'string', 'maxlength': 20, 'empty': False, 'allowed': ['MANCHE FIBRE']},
  54. 'CA_DATE_IN': {'empty': False, 'validator': is_modern_french_date},
  55. 'CA_COMMENT': {'type': 'string', 'maxlength': 300, 'empty': True},
  56. 'CA_STATUT': {'type': 'string', 'maxlength': 14, 'empty': False, 'allowed': ['APS', 'APD', 'EXE', 'REC']}}
  57. def __repr__(self):
  58. return "Cable {}-{}".format(self.CA_EQ_A, self.CA_EQ_B)
  59. class Equipement(BaseGeoModel):
  60. filename = "equipement_passif.shp"
  61. schema = {'geom': {'geometry': (gis.POINT, (XMIN, YMIN, XMAX, YMAX))},
  62. 'EQ_NOM': {'type': 'string', 'maxlength': 10, 'contains_any_of': ['PBO', 'BPE', 'BAI']},
  63. 'EQ_NOM_NOE': {'type': 'string', 'maxlength': 14},
  64. 'EQ_ETAT': {'type': 'string', 'maxlength': 1, 'empty': False, 'allowed': ['0', '1', '2', '3', '4']},
  65. 'EQ_OCCP': {'type': 'string', 'maxlength': 3, 'empty': False, 'allowed': ['0', '1.1', '1.2', '2', '3', '4']},
  66. 'EQ_TYPE': {'type': 'string', 'empty': False, 'allowed': ['PBO', 'PBOE', 'BPE', 'BAI']},
  67. 'EQ_TYPE_LQ': {'type': 'string', 'maxlength': 6, 'empty': False, 'allowed': ['PBO', 'BPE JB', 'BPE JD', 'BAIDC', 'BAIOP']},
  68. 'EQ_TYPE_PH': {'type': 'string', 'maxlength': 24, 'empty': False, 'allowed': ['PBO 6', 'PBO 12', 'BPE 12EP', 'BPE 24EP', 'BPE 48EP', 'BPE 72EP', 'BPE 96EP', 'BPE 144EP', 'BPE 288EP', 'BPE 576EP', 'BPE 720EP', 'BAI']},
  69. 'EQ_PRO': {'type': 'string', 'maxlength': 20, 'empty': False, 'allowed': ['MANCHE NUMERIQUE', 'COLLECTIVITE', 'ORANGE', 'PRIVE', 'AUTRE (à préciser)', 'NUL']},
  70. 'EQ_GEST': {'type': 'string', 'maxlength': 20, 'empty': False, 'allowed': ['MANCHE NUMERIQUE', 'MANCHE TELECOM', 'COLLECTIVITE', 'ORANGE', 'MANCHE FIBRE', 'PRIVE', 'AUTRE (à préciser)', 'NUL']},
  71. 'EQ_HAUT': {'empty': False, 'validator': is_float},
  72. 'EQ_DATE_IN': {'empty': False, 'validator': is_modern_french_date},
  73. 'EQ_COMMENT': {'type': 'string', 'maxlength': 300, 'empty': True},
  74. 'EQ_STATUT': {'type': 'string', 'maxlength': 14, 'empty': False, 'allowed': ['APS', 'APD', 'EXE', 'REC']}}
  75. def __repr__(self):
  76. return "Equipement {}".format(self.EQ_NOM)
  77. class Noeud(BaseGeoModel):
  78. filename = "noeud_geo.shp"
  79. schema = {'geom': {'geometry': (gis.POINT, (XMIN, YMIN, XMAX, YMAX))},
  80. 'NO_NOM': {'type': 'string', 'maxlength': 20},
  81. 'NO_ID_INSE': {'type': 'string', 'empty': False, 'allowed': INSEE_VALIDES},
  82. 'NO_VOIE': {'type': 'string', 'maxlength': 100},
  83. 'NO_ETAT': {'type': 'string', 'maxlength': 1, 'empty': False, 'allowed': ['0', '1', '2', '3', '4']},
  84. 'NO_OCCP': {'type': 'string', 'maxlength': 3, 'empty': False, 'allowed': ['0', '1.1', '1.2', '2', '3', '4']},
  85. 'NO_TYPE': {'type': 'string', 'maxlength': 3, 'empty': False, 'allowed': ['CHA', 'POT', 'LTE', 'SEM', 'FAC', 'OUV', 'IMM']},
  86. 'NO_TYPE_LQ': {'type': 'string', 'maxlength': 10, 'empty': False, 'allowed': ['CHTIR', 'CHRACC', 'POT', 'NRO', 'PM', 'MIMO', 'FAC', 'OUV', 'IMM']},
  87. 'NO_TYPE_PH': {'type': 'string', 'maxlength': 20, 'empty': False, 'allowed': ['CHAMBRE', 'POTEAU', 'ARMOIRE', 'SHELTER', 'BATIMENT', 'SITE MIMO', 'FACADE', 'OUVRAGE', 'IMMEUBLE']},
  88. 'NO_CODE_PH': {'type': 'string', 'maxlength': 20},
  89. 'NO_TECH_PS': {'type': 'string', 'maxlength': 20, 'empty': False, 'multiallowed': ['COAX', 'CUT', 'ECL', 'ELEC', 'VP', 'OPT', 'NC']},
  90. 'NO_AMO': {'type': 'string', 'maxlength': 20},
  91. 'NO_PLINOX': {'type': 'string', 'maxlength': 3, 'empty': False, 'allowed': ['OUI', 'NON']},
  92. 'NO_X': {'empty': False, 'validator': is_float},
  93. 'NO_Y': {'empty': False, 'validator': is_float},
  94. 'NO_PRO': {'type': 'string', 'maxlength': 20, 'empty': False, 'allowed': ['MANCHE NUMERIQUE', 'COLLECTIVITE', 'ORANGE', 'ERDF', 'PRIVE', 'AUTRE (à préciser)', 'NUL']},
  95. 'NO_GEST': {'type': 'string', 'maxlength': 20, 'empty': False, 'allowed': ['MANCHE NUMERIQUE', 'MANCHE TELECOM', 'COLLECTIVITE', 'ORANGE', 'ERDF', 'MANCHE FIBRE', 'PRIVE', 'AUTRE (à préciser)', 'NUL']},
  96. 'NO_HAUT': {'empty': False, 'validator': is_float},
  97. 'NO_DATE_IN': {'empty': False, 'validator': is_modern_french_date},
  98. 'NO_REF_PLA': {'type': 'string', 'maxlength': 100},
  99. 'NO_SRC_GEO': {'type': 'string', 'maxlength': 50},
  100. 'NO_QLT_GEO': {'type': 'string', 'maxlength': 1, 'empty': False, 'allowed': ['A', 'B', 'C']},
  101. 'NO_PRO_MD': {'type': 'string', 'maxlength': 20, 'empty': False, 'allowed': ['MANCHE NUMERIQUE']},
  102. 'NO_COMMENT': {'type': 'string', 'maxlength': 300, 'empty': True},
  103. 'NO_STATUT': {'type': 'string', 'maxlength': 14, 'empty': False, 'allowed': ['APS', 'APD', 'EXE', 'REC']}}
  104. def __repr__(self):
  105. return "Noeud {}".format(self.NO_NOM)
  106. class Tranchee(BaseGeoModel):
  107. filename = "tranchee_geo.shp"
  108. schema = {'geom': {'geometry': (gis.POLYLINE, (XMIN, YMIN, XMAX, YMAX))},
  109. 'TR_ID_INSE': {'type': 'string', 'empty': False, 'allowed': INSEE_VALIDES},
  110. 'TR_VOIE': {'type': 'string', 'maxlength': 200},
  111. 'TR_TYP_IMP': {'type': 'string', 'empty': False, 'allowed': ['ACCOTEMENT STABILISE', 'ACCOTEMENT NON STABILISE', 'CHAUSSEE LOURDE', 'CHAUSSEE LEGERE', 'FOSSE', 'TROTTOIR', 'ESPACE VERT', 'ENCORBELLEMENT']},
  112. 'TR_MOD_POS': {'type': 'string', 'empty': False, 'allowed': ['TRADITIONNEL', 'MICRO TRANCHEE', 'FONCAGE 60', 'FONCAGE 90', 'FONCAGE 120', 'TRANCHEUSE', 'FORAGE URBAIN', 'FORAGE RURAL', 'ENCORBELLEMENT']},
  113. 'TR_LONG': {'empty': False, 'validator': is_float},
  114. 'TR_LARG': {'empty': False, 'validator': is_float},
  115. 'TR_REVET': {'type': 'string', 'empty': False, 'allowed': ['SABLE', 'BICOUCHE', 'ENROBE', 'BETON', 'PAVE', 'TERRAIN NATUREL']},
  116. 'TR_CHARGE': {'empty': False, 'validator': is_float},
  117. 'TR_GRILLAG': {'empty': False, 'validator': is_float},
  118. 'TR_REMBLAI': {'type': 'string'},
  119. 'TR_PLYNOX': {'type': 'string', 'empty': False, 'allowed': ['OUI', 'NON']},
  120. 'TR_PRO_VOI': {'type': 'string', 'empty': False, 'allowed': ['COMMUNE', 'COMMUNAUTE DE COMMUNES', 'DEPARTEMENT', 'ETAT', 'PRIVE']},
  121. 'TR_GEST_VO': {'type': 'string', 'empty': False, 'allowed': ['COMMUNE', 'COMMUNAUTE DE COMMUNES', 'DEPARTEMENT', 'ETAT', 'PRIVE']},
  122. 'TR_SCHEMA': {'maxlength': 100, 'type': 'string'},
  123. 'TR_DATE_IN': {'empty': False, 'validator': is_modern_french_date},
  124. 'TR_SRC_GEO': {'type': 'string', 'maxlength': 50},
  125. 'TR_QLT_GEO': {'type': 'string', 'empty': False, 'allowed': ['A', 'B', 'C']},
  126. 'TR_PRO_MD': {'type': 'string', 'maxlength': 20},
  127. 'TR_COMMENT': {'type': 'string', 'maxlength': 300, 'empty': True},
  128. 'TR_STATUT': {'type': 'string', 'empty': False, 'allowed': ['APS', 'APD', 'EXE', 'REC']}}
  129. def __repr__(self):
  130. return "Tranchee {}".format(self.TR_VOIE)
  131. class Zapbo(BaseGeoModel):
  132. filename = "zapbo_geo.shp"
  133. schema = {'geom': {'geometry': (gis.POLYGON, (XMIN, YMIN, XMAX, YMAX))},
  134. 'ID_ZAPBO': {'type': 'string', 'maxlength': 30, 'contains_any_of': ['PBO', 'BPE']},
  135. 'COMMENTAIR': {'type': 'string', 'maxlength': 254, 'empty': True},
  136. 'STATUT': {'type': 'string', 'empty': False, 'allowed': ['APS', 'APD', 'EXE', 'REC']}}
  137. def __repr__(self):
  138. return "Zapbo {}".format(self.ID_ZAPBO)