models.py 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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, is_multi_int
  7. from core.validation import BaseGeoModel
  8. from schemas.common import INSEE_VALIDES, XMIN, YMIN, XMAX, YMAX
  9. STATUTS = ['EN ETUDE', 'EN REALISATION', 'EN SERVICE', 'HORS SERVICE']
  10. class Artere(BaseGeoModel):
  11. filename = "artere_geo.shp"
  12. geom_type = gis_.GEOM_LINE
  13. bounding_box = (XMIN,YMIN,XMAX,YMAX)
  14. schema = {'AR_CODE': {'type': 'string', 'maxlength': 26},
  15. 'AR_NOM': {'type': 'string', 'maxlength': 26},
  16. 'AR_ID_INSE': {'type': 'string', 'empty': False, 'allowed': INSEE_VALIDES},
  17. 'AR_LONG': {'empty': False, 'validator': is_float},
  18. 'AR_ETAT': {'type': 'string', 'empty': False, 'allowed': ['0', '1', '2', '3', '4']},
  19. 'AR_OCCP': {'type': 'string', 'empty': False, 'allowed': ['0', '1.1', '1.2', '2', '3', '4']},
  20. 'AR_NOEUD_A': {'type': 'string', 'empty': False, 'maxlength': 20},
  21. 'AR_NOEUD_B': {'type': 'string', 'empty': False, 'maxlength': 20},
  22. 'AR_NB_FOUR': {'empty': False, 'validator': is_multi_int},
  23. 'AR_FOU_DIS': {'empty': False, 'validator': is_int},
  24. 'AR_TYPE_FO': {'type': 'string', 'multiallowed': ['PVC', 'PEHD', 'SOUS-TUBAGE PEHD', 'SOUS-TUBAGE SOUPLE', 'FACADE', 'AERIEN', 'ENCORBELLEMENT', 'AUTRE']},
  25. 'AR_TYFO_AI': {'type': 'string', 'multiallowed': ['PVC', 'PEH', 'TUB', 'FAC', 'ENC', 'APP']},
  26. 'AR_DIAM_FO': {'type': 'string', 'multiallowed': ['10', '14', '18', '25', '28', '32', '40', '45', '60', '80', '150', 'NUL']},
  27. 'AR_PRO_FOU': {'type': 'string', 'multiallowed': ['MANCHE NUMERIQUE', 'COLLECTIVITE', 'ORANGE', 'PRIVE', 'ERDF', 'AUTRE (à préciser)']},
  28. 'AR_FABRICANT': {'type': 'string', 'empty': False, 'maxlength': 100},
  29. 'AR_REF_FABRICANT': {'type': 'string', 'empty': False, 'maxlength': 100},
  30. 'AR_COULEUR': {'type': 'string', 'empty': False, 'maxlength': 20},
  31. 'AR_AIGUILLEE': {'type': 'string', 'empty': False, 'maxlength': 3, 'allowed': ['OUI', 'NON']},
  32. 'AR_NB_CABLES': {'empty': False, 'validator': is_int},
  33. 'AR_PRO_CAB': {'type': 'string', 'empty': False, 'allowed': ['MANCHE NUMERIQUE']},
  34. 'AR_GEST_FO': {'type': 'string', 'multiallowed': ['MANCHE NUMERIQUE', 'MANCHE TELECOM', 'COLLECTIVITE', 'ORANGE', 'MANCHE FIBRE', 'PRIVE', 'ERDF', 'AUTRE (à préciser)', 'NUL']},
  35. 'AR_UTIL_FO': {'type': 'string', 'multiallowed': ['MANCHE NUMERIQUE', 'MANCHE TELECOM', 'COLLECTIVITE', 'ORANGE', 'MANCHE FIBRE', 'PRIVE', 'AUTRE (à préciser)', 'NUL']},
  36. 'AR_DATE_IN': {'empty': False, 'validator': is_modern_french_date},
  37. 'AR_DATE_RE': {'empty': False, 'validator': is_modern_french_date},
  38. 'AR_REF_PLA': {'type': 'string', 'maxlength': 100},
  39. 'AR_SRC_GEO': {'type': 'string', 'maxlength': 50},
  40. 'AR_QLT_GEO': {'type': 'string', 'empty': False, 'allowed': ['A', 'B', 'C']},
  41. 'AR_PRO_MD': {'type': 'string', 'empty': False, 'default': 'MANCHE NUMERIQUE', 'allowed': ['MANCHE NUMERIQUE']},
  42. 'AR_COMMENT': {'type': 'string', 'maxlength': 300, 'empty': True},
  43. 'AR_STATUT': {'type': 'string', 'empty': False, 'allowed': STATUTS}}
  44. def __repr__(self):
  45. return "Artere {}".format(self.AR_CODE)
  46. class Cable(BaseGeoModel):
  47. filename = "cable_geo.shp"
  48. geom_type = gis_.GEOM_LINE
  49. bounding_box = (XMIN,YMIN,XMAX,YMAX)
  50. schema = {'CA_CODE': {'type': 'string', 'maxlength': 18},
  51. 'CA_NOM': {'type': 'string', 'maxlength': 18},
  52. 'CA_NUMERO': {'type': 'string', 'maxlength': 17},
  53. 'CA_EMPRISE': {'type': 'string', 'maxlength': 10},
  54. 'CA_FAB': {'type': 'string', 'maxlength': 100},
  55. 'CA_REFFAB': {'type': 'string', 'maxlength': 100},
  56. 'CA_MODELE': {'type': 'string', 'maxlength': 10},
  57. 'CA_TYPE': {'type': 'string', 'maxlength': 10, 'empty': False, 'allowed': ['AERIEN', 'IMMEUBLE', 'FACADE', 'MIXTE', 'SOUTERRAIN']},
  58. 'CA_TYPFCT': {'type': 'string', 'maxlength': 3, 'empty': False, 'allowed': ['CDI', 'CTR', 'CBM', 'RAC', 'CBO']},
  59. 'CA_ETAT': {'type': 'string', 'maxlength': 1, 'empty': False, 'allowed': ['0', '1', '2', '3', '4']},
  60. 'CA_LONG': {'validator': is_float},
  61. 'CA_EQ_A': {'type': 'string', 'maxlength': 18},
  62. 'CA_EQ_B': {'type': 'string', 'maxlength': 18},
  63. 'CA_DIAMETR': {'empty': False, 'validator': is_float},
  64. 'CA_COULEUR': {'type': 'string', 'maxlength': 20, 'empty': False, 'allowed': ['NOIR', 'BLEU', 'BLANC']},
  65. 'CA_TECHNOL': {'type': 'string', 'maxlength': 17, 'empty': False, 'allowed': ['G657A2_M6', 'G657A2_M12']},
  66. 'CA_NB_FO': {'validator': is_int},
  67. 'CA_NB_FO_U': {'empty': False, 'validator': is_int},
  68. 'CA_NB_FO_D': {'empty': False, 'validator': is_int},
  69. 'CA_PRO': {'type': 'string', 'maxlength': 20, 'empty': False, 'allowed': ['MANCHE NUMERIQUE']},
  70. 'CA_GEST': {'type': 'string', 'maxlength': 20, 'empty': False, 'allowed': ['MANCHE FIBRE']},
  71. 'CA_DATE_IN': {'empty': False, 'validator': is_modern_french_date},
  72. 'CA_COMMENT': {'type': 'string', 'maxlength': 300, 'empty': True},
  73. 'CA_STATUT': {'type': 'string', 'empty': False, 'allowed': STATUTS}}
  74. def __repr__(self):
  75. return "Cable {}-{}".format(self.CA_EQ_A, self.CA_EQ_B)
  76. class Equipement(BaseGeoModel):
  77. filename = "equipement_passif.shp"
  78. geom_type = gis_.GEOM_POINT
  79. bounding_box = (XMIN,YMIN,XMAX,YMAX)
  80. schema = {'EQ_CODE': {'type': 'string', 'maxlength': 18},
  81. 'EQ_NOM': {'type': 'string', 'maxlength': 10, 'contains_any_of': ['PBO', 'BPE', 'BAI']},
  82. 'EQ_NOM_NOE': {'type': 'string', 'maxlength': 30},
  83. 'EQ_REF': {'type': 'string', 'maxlength': 100},
  84. 'EQ_EMPRISE': {'type': 'string', 'maxlength': 7},
  85. 'EQ_FABR': {'type': 'string', 'maxlength': 100},
  86. 'EQ_CAPFO': {'empty': False, 'validator': is_int},
  87. 'EQ_NBMXEQ': {'empty': False, 'validator': is_int},
  88. 'EQ_NBCAB': {'empty': False, 'validator': is_int},
  89. 'EQ_DIMENS': {'type': 'string', 'maxlength': 50},
  90. 'EQ_TYPEQ': {'type': 'string', 'maxlength': 100},
  91. 'EQ_ETAT': {'type': 'string', 'empty': False, 'allowed': ['0', '1', '2', '3', '4']},
  92. 'EQ_OCCP': {'type': 'string', 'empty': False, 'allowed': ['0', '1.1', '1.2', '2', '3', '4']},
  93. 'EQ_TYPE': {'type': 'string', 'empty': False, 'allowed': ['PBO', 'PBOE', 'BPE', 'BAI']},
  94. 'EQ_TYPSTRC': {'type': 'string', 'empty': False, 'allowed': ['CHAMBRE', 'AERIEN', 'FACADE', 'COLONNE MONTANTE', 'PIED IMMEUBLE', 'DTIO']},
  95. 'EQ_TYPE_LQ': {'type': 'string', 'empty': False, 'allowed': ['PBO', 'BPE JB', 'BPE JD', 'BAIDC', 'BAIOP']},
  96. 'EQ_TYPE_PH': {'type': 'string', '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']},
  97. 'EQ_PRO': {'type': 'string', 'empty': False, 'allowed': ['MANCHE NUMERIQUE', 'COLLECTIVITE', 'ORANGE', 'PRIVE', 'AUTRE (à préciser)', 'NUL']},
  98. 'EQ_GEST': {'type': 'string', 'empty': False, 'allowed': ['MANCHE NUMERIQUE', 'MANCHE TELECOM', 'COLLECTIVITE', 'ORANGE', 'MANCHE FIBRE', 'PRIVE', 'AUTRE (à préciser)', 'NUL']},
  99. 'EQ_HAUT': {'empty': False, 'validator': is_float},
  100. 'EQ_DATE_IN': {'empty': False, 'validator': is_modern_french_date},
  101. 'EQ_COMMENT': {'type': 'string', 'maxlength': 300, 'empty': True},
  102. 'EQ_STATUT': {'type': 'string', 'empty': False, 'allowed': STATUTS}}
  103. def __repr__(self):
  104. return "Equipement {}".format(self.EQ_NOM)
  105. class Noeud(BaseGeoModel):
  106. filename = "noeud_geo.shp"
  107. geom_type = gis_.GEOM_POINT
  108. bounding_box = (XMIN,YMIN,XMAX,YMAX)
  109. schema = {'NO_CODE': {'type': 'string', 'maxlength': 18},
  110. 'NO_NOM': {'type': 'string', 'maxlength': 30},
  111. 'NO_ID_INSE': {'type': 'string', 'empty': False, 'allowed': INSEE_VALIDES},
  112. 'NO_VOIE': {'type': 'string', 'maxlength': 100},
  113. 'NO_EMPRISE': {'type': 'string', 'maxlength': 10},
  114. 'NO_ETAT': {'type': 'string', 'empty': False, 'allowed': ['0', '1', '2', '3', '4']},
  115. 'NO_OCCP': {'type': 'string', 'empty': False, 'allowed': ['0', '1.1', '1.2', '2', '3', '4']},
  116. 'NO_TYPE': {'type': 'string', 'empty': False, 'allowed': ['CHA', 'POT', 'LTE', 'SEM', 'FAC', 'OUV', 'IMM']},
  117. 'NO_TYPFCT': {'type': 'string', 'empty': False, 'allowed': ['INTERCONNEXION', 'SATELLITE', 'PASSAGE', 'REGARD', 'INDETERMINE']},
  118. 'NO_TYPE_LQ': {'type': 'string', 'empty': False, 'allowed': ['CHTIR', 'CHRACC', 'POT', 'NRO', 'PM', 'MIMO', 'FAC', 'OUV', 'IMM']},
  119. 'NO_TYPE_PH': {'type': 'string', 'empty': False, 'allowed': ['CHAMBRE', 'POTEAU', 'ARMOIRE', 'SHELTER', 'BATIMENT', 'SITE MIMO', 'FACADE', 'OUVRAGE', 'IMMEUBLE']},
  120. 'NO_CODE_PH': {'type': 'string', 'maxlength': 20},
  121. 'NO_TECH_PS': {'type': 'string', 'maxlength': 20, 'multiallowed': ['COAX', 'CUT', 'ECL', 'ELEC', 'VP', 'OPT', 'NC']},
  122. 'NO_AMO': {'type': 'string', 'maxlength': 20},
  123. 'NO_PLINOX': {'required':False, 'type': 'string', 'maxlength': 3, 'allowed': ['OUI', 'NON']},
  124. 'NO_X': {'empty': False, 'validator': is_float},
  125. 'NO_Y': {'empty': False, 'validator': is_float},
  126. 'NO_PRO': {'type': 'string', 'maxlength': 20, 'empty': False, 'allowed': ['MANCHE NUMERIQUE', 'COLLECTIVITE', 'ORANGE', 'ERDF', 'PRIVE', 'ENEDIS', 'AUTRE (à préciser)', 'NUL']},
  127. 'NO_GEST': {'type': 'string', 'maxlength': 20, 'empty': False, 'allowed': ['MANCHE NUMERIQUE', 'MANCHE TELECOM', 'COLLECTIVITE', 'ORANGE', 'ERDF', 'ENEDIS', 'MANCHE FIBRE', 'PRIVE', 'AUTRE (à préciser)', 'NUL']},
  128. 'NO_HAUT': {'empty': False, 'validator': is_float},
  129. 'NO_DATE_IN': {'empty': False, 'validator': is_modern_french_date},
  130. 'NO_REF_PLA': {'type': 'string', 'maxlength': 100},
  131. 'NO_SRC_GEO': {'type': 'string', 'maxlength': 50},
  132. 'NO_QLT_GEO': {'type': 'string', 'maxlength': 1, 'empty': False, 'allowed': ['A', 'B', 'C']},
  133. 'NO_PRO_MD': {'type': 'string', 'maxlength': 20, 'empty': False, 'allowed': ['MANCHE NUMERIQUE']},
  134. 'NO_COMMENT': {'type': 'string', 'maxlength': 300, 'empty': True},
  135. 'NO_STATUT': {'type': 'string', 'empty': False, 'allowed': STATUTS}}
  136. def __repr__(self):
  137. return "Noeud {}".format(self.NO_NOM)
  138. class Tranchee(BaseGeoModel):
  139. filename = "tranchee_geo.shp"
  140. geom_type = gis_.GEOM_LINE
  141. bounding_box = (XMIN,YMIN,XMAX,YMAX)
  142. schema = {'TR_CODE': {'type': 'string', 'maxlength': 23},
  143. 'TR_NOM': {'type': 'string', 'maxlength': 23},
  144. 'TR_ID_INSE': {'type': 'string', 'empty': False, 'allowed': INSEE_VALIDES},
  145. 'TR_VOIE': {'type': 'string', 'maxlength': 200},
  146. 'TR_TYP_IMP': {'type': 'string', 'empty': False, 'allowed': ['ACCOTEMENT STABILISE', 'ACCOTEMENT NON STABILISE', 'CHAUSSEE LOURDE', 'CHAUSSEE LEGERE', 'FOSSE', 'TROTTOIR', 'ESPACE VERT', 'ENCORBELLEMENT']},
  147. 'TR_MOD_POS': {'type': 'string', 'empty': False, 'allowed': ['TRADITIONNEL', 'MICRO TRANCHEE', 'FONCAGE 60', 'FONCAGE 90', 'FONCAGE 120', 'TRANCHEUSE', 'FORAGE URBAIN', 'FORAGE RURAL', 'ENCORBELLEMENT']},
  148. 'TR_MPOS_AI': {'type': 'string', 'empty': False, 'allowed': ['TRA', 'ALL', 'FONCAGE 60', 'FON', 'FOR', 'ENC']},
  149. 'TR_LONG': {'empty': False, 'validator': is_float},
  150. 'TR_LARG': {'empty': False, 'validator': is_float},
  151. 'TR_REVET': {'empty':True, 'type': 'string', 'allowed': ['SABLE', 'BICOUCHE', 'ENROBE', 'BETON', 'PAVE', 'TERRAIN NATUREL']},
  152. 'TR_CHARGE': {'empty': False, 'validator': is_float},
  153. 'TR_GRILLAG': {'empty':True, 'validator': is_float},
  154. 'TR_REMBLAI': {'type': 'string'},
  155. 'TR_PLYNOX': {'type': 'string', 'empty': False, 'allowed': ['OUI', 'NON']},
  156. 'TR_PRO_VOI': {'type': 'string', 'empty': False, 'allowed': ['COMMUNE', 'COMMUNAUTE DE COMMUNES', 'DEPARTEMENT', 'ETAT', 'PRIVE']},
  157. 'TR_GEST_VO': {'type': 'string', 'empty': False, 'allowed': ['COMMUNE', 'COMMUNAUTE DE COMMUNES', 'DEPARTEMENT', 'ETAT', 'PRIVE']},
  158. 'TR_SCHEMA': {'maxlength': 100, 'type': 'string'},
  159. 'TR_DATE_IN': {'empty': False, 'validator': is_modern_french_date},
  160. 'TR_SRC_GEO': {'type': 'string', 'maxlength': 50},
  161. 'TR_QLT_GEO': {'type': 'string', 'empty': False, 'allowed': ['A', 'B', 'C']},
  162. 'TR_PRO_MD': {'type': 'string', 'maxlength': 20},
  163. 'TR_COMMENT': {'type': 'string', 'maxlength': 300, 'empty': True},
  164. 'TR_STATUT': {'type': 'string', 'empty': False, 'allowed': STATUTS}}
  165. def __repr__(self):
  166. return "Tranchee {}".format(self.TR_VOIE)
  167. class Zapbo(BaseGeoModel):
  168. filename = "zapbo_geo.shp"
  169. geom_type = gis_.GEOM_POLYGON
  170. bounding_box = (XMIN,YMIN,XMAX,YMAX)
  171. schema = {'ID_ZAPBO': {'type': 'string', 'maxlength': 30, 'contains_any_of': ['PBO', 'BPE']},
  172. 'COMMENTAIR': {'type': 'string', 'maxlength': 254, 'empty': True},
  173. 'STATUT': {'type': 'string', 'empty': False, 'allowed': STATUTS}}
  174. def __repr__(self):
  175. return "Zapbo {}".format(self.ID_ZAPBO)