| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- '''
- Controle les données d'un dossier ou d'une archive contenant des données au format Netgeo 2.2
- Python 3.7+
- @author: olivier.massot, sept. 2018
- '''
- from core import gis
- from core.mn import ReferentielDb
- from core.validation import BaseValidator, BaseGeoModel, is_french_date
- xmin, xmax, ymin, ymax = 1341999, 1429750, 8147750, 8294000
- with ReferentielDb() as ref_db:
- INSEE_VALIDES = [row[0] for row in ref_db.read("SELECT code_insee FROM sig_referentiel.admn_cd50_com;")]
- class Artere(BaseGeoModel):
- schema = {'geom': {'bbox': {type: 'list', 'items': [{'type': 'int', 'min': xmin, 'max': xmax},
- {'type': 'int', 'min': ymin, 'max': ymax},
- {'type': 'int', 'min': xmin, 'max': xmax},
- {'type': 'int', 'min': ymin, 'max': ymax}]},
- 'parts': {},
- 'points': {},
- 'shapeType': {'allowed': [gis.POLYLINE]}},
- 'AR_CODE': {'type': 'string', 'maxlength': 26},
- 'AR_NOM': {'type': 'string', 'maxlength': 26},
- 'AR_ID_INSE': {'type': 'string', 'allowed': INSEE_VALIDES},
- 'AR_LONG': {'type': 'float'},
- 'AR_ETAT': {'type': 'string', 'allowed': ['0', '1', '2', '3', '4']},
- 'AR_OCCP': {'type': 'string', 'allowed': ['0', '1.1', '1.2', '2', '3', '4']},
- 'AR_NOEUD_A': {'type': 'string', 'maxlength': 20},
- 'AR_NOEUD_B': {'type': 'string', 'maxlength': 20},
- 'AR_NB_FOUR': {'type': 'string', 'maxlength': 20},
- 'AR_FOU_DIS': {'type': 'integer'},
- 'AR_TYPE_FO': {'type': 'string', 'allowed': ['PVC', 'PEHD', 'SOUS-TUBAGE PEHD', 'SOUS-TUBAGE SOUPLE', 'FACADE', 'AERIEN', 'ENCORBELLEMENT', 'AUTRE']},
- 'AR_TYFO_AI': {'type': 'string', 'allowed': ['PVC', 'PEH', 'TUB', 'FAC', 'ENC', 'APP']},
- 'AR_DIAM_FO': {'type': 'string', 'allowed': ['10', '14', '18', '25', '28', '32', '40', '45', '60', 'NUL']},
- 'AR_PRO_FOU': {'type': 'string', 'allowed': ['MANCHE NUMERIQUE', 'COLLECTIVITE', 'ORANGE', 'AUTRE (à préciser)']},
- 'AR_FAB': {'type': 'string', 'maxlength': 100}, 'AR_REFFAB': {'type': 'string', 'maxlength': 100},
- 'AR_COULEUR': {'type': 'string', 'maxlength': 20}, 'AR_AIGUIL': {'type': 'string', 'allowed': ['OUI', 'NON']},
- 'AR_NBCABL': {'type': 'integer'},
- 'AR_PRO_CAB': {'type': 'string', 'allowed': ['MANCHE NUMERIQUE']},
- 'AR_GEST_FO': {'type': 'string', 'allowed': ['MANCHE NUMERIQUE', 'MANCHE TELECOM', 'COLLECTIVITE', 'ORANGE', 'AUTRE (à préciser)', 'NUL']},
- 'AR_UTIL_FO': {'type': 'string', 'allowed': ['MANCHE NUMERIQUE', 'MANCHE TELECOM', 'COLLECTIVITE', 'ORANGE', 'MANCHE FIBRE', 'AUTRE (à préciser)', 'NUL']},
- 'AR_DATE_IN': {'validator': is_french_date},
- 'AR_DATE_RE': {'validator': is_french_date},
- 'AR_REF_PLA': {'type': 'string', 'maxlength': 100},
- 'AR_SRC_GEO': {'type': 'string', 'maxlength': 50},
- 'AR_QLT_GEO': {'type': 'string', 'allowed': ['A', 'B', 'C']},
- 'AR_PRO_MD': {'type': 'string', 'allowed': ['MANCHE NUMERIQUE']},
- 'AR_COMMENT': {'type': 'string', 'maxlength': 300, 'empty': True},
- 'AR_STATUT': {'type': 'string', 'allowed': ['EN ETUDE', 'EN REALISATION', 'EN SERVICE', 'HORS SERVICE']}}
-
- class Cable(BaseGeoModel):
- schema = {'geom': {'bbox': {type: 'list', 'items': [{'type': 'int', 'min': xmin, 'max': xmax},
- {'type': 'int', 'min': ymin, 'max': ymax},
- {'type': 'int', 'min': xmin, 'max': xmax},
- {'type': 'int', 'min': ymin, 'max': ymax}]},
- 'parts': {},
- 'points': {},
- 'shapeType': {'allowed': [gis.POLYLINE]}},
- 'CA_CODE': {'type': 'string', 'maxlength': 18},
- 'CA_NOM': {'type': 'string', 'maxlength': 18},
- 'CA_NUMERO': {'type': 'string', 'maxlength': 17},
- 'CA_EMPRISE': {'type': 'string', 'maxlength': 10},
- 'CA_FAB': {'type': 'string', 'maxlength': 100},
- 'CA_REFFAB': {'type': 'string', 'maxlength': 100},
- 'CA_MODELE': {'type': 'string', 'maxlength': 10},
- 'CA_TYPE': {'type': 'string', 'maxlength': 10, 'allowed': ['AERIEN', 'IMMEUBLE', 'FACADE', 'MIXTE', 'SOUTERRAIN']},
- 'CA_TYPFCT': {'type': 'string', 'maxlength': 3, 'allowed': ['CDI', 'CTR', 'CBM', 'RAC', 'CBO']},
- 'CA_ETAT': {'type': 'string', 'maxlength': 1, 'allowed': ['0', '1', '2', '3', '4']},
- 'CA_LONG': {'type': 'float'}, 'CA_EQ_A': {'type': 'string', 'maxlength': 18},
- 'CA_EQ_B': {'type': 'string', 'maxlength': 18},
- 'CA_DIAMETR': {'type': 'integer'},
- 'CA_COULEUR': {'type': 'string', 'maxlength': 20, 'allowed': ['NOIR', 'BLEU', 'BLANC']},
- 'CA_TECHNOL': {'type': 'string', 'maxlength': 17, 'allowed': ['G657A2_M6', 'G657A2_M12']},
- 'A_NB_FO_U': {'type': 'integer'}, 'CA_NB_FO_D': {'type': 'integer'},
- 'CA_PRO': {'type': 'string', 'maxlength': 20, 'allowed': ['MANCHE NUMERIQUE']},
- 'CA_GEST': {'type': 'string', 'maxlength': 20, 'allowed': ['NUL']},
- 'CA_DATE_IN': {'validator': is_french_date},
- 'CA_COMMENT': {'type': 'string', 'maxlength': 300, 'empty': True},
- 'CA_STATUT': {'type': 'string', 'maxlength': 14, 'allowed': ['EN ETUDE', 'EN REALISATION', 'EN SERVICE', 'HORS SERVICE']}}
- class Equipement(BaseGeoModel):
- schema = {'geom': {'bbox': {type: 'list', 'items': [{'type': 'int', 'min': xmin, 'max': xmax},
- {'type': 'int', 'min': ymin, 'max': ymax},
- {'type': 'int', 'min': xmin, 'max': xmax},
- {'type': 'int', 'min': ymin, 'max': ymax}]},
- 'parts': {},
- 'points': {},
- 'shapeType': {'allowed': [gis.POLYLINE]}},
- 'EQ_CODE': {'type': 'string', 'maxlength': 18},
- 'EQ_NOM': {'type': 'string', 'maxlength': 18},
- 'EQ_NOM_NOE': {'type': 'string', 'maxlength': 14},
- 'EQ_REF': {'type': 'string', 'maxlength': 100},
- 'EQ_EMPRISE': {'type': 'string', 'maxlength': 7},
- 'EQ_FABR': {'type': 'string', 'maxlength': 100},
- 'EQ_CAPFO': {'type': 'integer'},
- 'EQ_NBMXEQ': {'type': 'integer'},
- 'EQ_NBCAB': {'type': 'integer'},
- 'EQ_DIMENS': {'type': 'string', 'maxlength': 50},
- 'EQ_TYPEQ': {'type': 'string', 'maxlength': 100},
- 'EQ_ETAT': {'type': 'string', 'maxlength': 1, 'allowed': ['0', '1', '2', '3', '4']},
- 'EQ_OCCP': {'type': 'string', 'maxlength': 3, 'allowed': ['0', '1.1', '1.2', '2', '3', '4']},
- 'EQ_TYPE': {'type': 'string', 'maxlength': 3, 'allowed': ['PBO', 'PEC', 'BPE', 'BAI']},
- 'EQ_TYPSTRC': {'type': 'string', 'maxlength': 16, 'allowed': ['CHAMBRE', 'AERIEN', 'FACADE', 'COLONNE MONTANTE', 'PIED IMMEUBLE', 'DTIO']},
- 'EQ_TYPE_LQ': {'type': 'string', 'maxlength': 6, 'allowed': ['PBO', 'BPE JB', 'BPE JD', 'BAIDC', 'BAIOP']},
- 'EQ_TYPE_PH': {'type': 'string', 'maxlength': 24, 'allowed': ['PBO 6', 'PBO 12', 'BPE 12EP', 'BPE 24EP', 'BPE 48EP', 'BPE 72EP', 'BPE 96EP', 'BPE 144EP', 'BPE 288EP', 'BPE 576EP', 'BPE 720EP']},
- 'EQ_PRO': {'type': 'string', 'maxlength': 20, 'allowed': ['MANCHE NUMERIQUE', 'COLLECTIVITE', 'ORANGE', 'AUTRE (à préciser)', 'NUL']},
- 'EQ_GEST': {'type': 'string', 'maxlength': 20, 'allowed': ['MANCHE NUMERIQUE', 'MANCHE TELECOM', 'COLLECTIVITE', 'ORANGE', 'MANCHE FIBRE', 'AUTRE (à préciser)', 'NUL']},
- 'EQ_HAUT': {'type': 'float'}, 'EQ_DATE_IN': {'type': 'datetime'},
- 'EQ_COMMENT': {'type': 'string', 'maxlength': 300, 'empty': True},
- 'EQ_STATUT': {'type': 'string', 'maxlength': 14, 'allowed': ['EN ETUDE', 'EN REALISATION', 'EN SERVICE', 'HORS SERVICE']}}
- class Noeud(BaseGeoModel):
- schema = {'geom': {'bbox': {type: 'list', 'items': [{'type': 'int', 'min': xmin, 'max': xmax},
- {'type': 'int', 'min': ymin, 'max': ymax},
- {'type': 'int', 'min': xmin, 'max': xmax},
- {'type': 'int', 'min': ymin, 'max': ymax}]},
- 'parts': {},
- 'points': {},
- 'shapeType': {'allowed': [gis.POINT]}},
- 'NO_CODE': {'type': 'string', 'maxlength': 18},
- 'NO_ID_INSE': {'type': 'string', 'allowed': INSEE_VALIDES},
- 'NO_NOM': {'type': 'string', 'maxlength': 20},
- 'NO_VOIE': {'type': 'string', 'maxlength': 100},
- 'NO_EMPRISE': {'type': 'string', 'maxlength': 10},
- 'NO_ETAT': {'type': 'string', 'maxlength': 1, 'allowed': ['0', '1', '2', '3', '4']},
- 'NO_OCCP': {'type': 'string', 'maxlength': 3, 'allowed': ['0', '1.1', '1.2', '2', '3', '4']},
- 'NO_TYPE': {'type': 'string', 'maxlength': 3, 'allowed': ['CHA', 'POT', 'LTE', 'SEM', 'FAC', 'OUV', 'IMM']},
- 'NO_TYPFCT': {'type': 'string', 'maxlength': 14, 'allowed': ['INTERCONNEXION', 'SATELLITE', 'PASSAGE', 'REGARD', 'INDETERMINE']},
- 'NO_TYPE_LQ': {'type': 'string', 'maxlength': 10, 'allowed': ['CHTIR', 'CHRACC', 'POT', 'NRO', 'PM', 'MIMO', 'FAC', 'OUV', 'IMM']},
- 'NO_TYPE_PH': {'type': 'string', 'maxlength': 20, 'allowed': ['CHAMBRE', 'POTEAU', 'ARMOIRE', 'SHELTER', 'BATIMENT', 'SITE MIMO', 'FACADE', 'OUVRAGE', 'IMMEUBLE']},
- 'NO_CODE_PH': {'type': 'string', 'maxlength': 20},
- 'NO_TECH_PS': {'type': 'string', 'maxlength': 4, 'allowed': ['COAX', 'CUT', 'ECL', 'ELEC', 'VP', 'OPT', 'NC']},
- 'NO_AMO': {'type': 'string', 'maxlength': 20},
- 'NO_PLINOX': {'type': 'string', 'maxlength': 3, 'allowed': ['OUI', 'NON']},
- 'NO_X': {'type': 'float'},
- 'NO_Y': {'type': 'float'},
- 'NO_PRO': {'type': 'string', 'maxlength': 20, 'allowed': ['MANCHE NUMERIQUE', 'COLLECTIVITE', 'ORANGE', 'ERDF', 'AUTRE (à préciser)', 'NUL']},
- 'NO_GEST': {'type': 'string', 'maxlength': 20, 'allowed': ['MANCHE NUMERIQUE', 'MANCHE TELECOM', 'COLLECTIVITE', 'ORANGE', 'ERDF', 'MANCHE FIBRE', 'AUTRE (à préciser)', 'NUL']},
- 'NO_HAUT': {'type': 'float'},
- 'NO_DATE_IN': {'validator': is_french_date},
- 'NO_REF_PLA': {'type': 'string', 'maxlength': 100},
- 'NO_SRC_GEO': {'type': 'string', 'maxlength': 50},
- 'NO_QLT_GEO': {'type': 'string', 'maxlength': 1, 'allowed': ['A', 'B', 'C']},
- 'NO_PRO_MD': {'type': 'string', 'maxlength': 20, 'allowed': ['MANCHE NUMERIQUE']},
- 'NO_COMMENT': {'type': 'string', 'maxlength': 300, 'empty': True},
- 'NO_STATUT': {'type': 'string', 'maxlength': 14, 'allowed': ['EN ETUDE', 'EN REALISATION', 'EN SERVICE', 'HORS SERVICE']}}
- class Tranchee(BaseGeoModel):
- schema = {'geom': {'bbox': {type: 'list', 'items': [{'type': 'int', 'min': xmin, 'max': xmax},
- {'type': 'int', 'min': ymin, 'max': ymax},
- {'type': 'int', 'min': xmin, 'max': xmax},
- {'type': 'int', 'min': ymin, 'max': ymax}]},
- 'parts': {},
- 'points': {},
- 'shapeType': {'allowed': [gis.POLYLINE]}},
- 'TR_CODE': {'type': 'string', 'maxlength': 23},
- 'TR_NOM': {'type': 'string', 'maxlength': 23, 'tester': 'lambda t, x: x=t.TR_CODE'},
- 'TR_ID_INSE': {'type': 'string', 'allowed': INSEE_VALIDES},
- 'TR_VOIE': {'type': 'string', 'maxlength': 200},
- 'TR_TYP_IMP': {'type': 'string', 'allowed': ['ACCOTEMENT STABILISE', 'ACCOTEMENT NON STABILISE', 'CHAUSSEE LOURDE', 'CHAUSSEE LEGERE', 'FOSSE', 'TROTTOIR', 'ESPACE VERT', 'ENCORBELLEMENT']},
- 'TR_MOD_POS': {'type': 'string', 'allowed': ['TRADITIONNEL', 'MICRO TRANCHEE', 'FONCAGE 60', 'FONCAGE 90', 'FONCAGE 120', 'TRANCHEUSE', 'FORAGE URBAIN', 'FORAGE RURAL', 'ENCORBELLEMENT']},
- 'TR_MPOS_AI': {'type': 'string', 'allowed': ['TRA', 'ALL', 'FONCAGE 60', 'FON', 'FOR', 'ENC']},
- 'TR_LONG': {'type': 'float'},
- 'TR_LARG': {'type': 'float'},
- 'TR_REVET': {'type': 'string', 'allowed': ['SABLE', 'BICOUCHE', 'ENROBE', 'BETON', 'PAVE', 'TERRAIN NATUREL']},
- 'TR_CHARGE': {'type': 'float'},
- 'TR_GRILLAG': {'type': 'float'},
- 'TR_REMBLAI': {'type': 'string'},
- 'TR_PLYNOX': {'type': 'string', 'allowed': ['OUI', 'NON']},
- 'TR_PRO_VOI': {'type': 'string', 'allowed': ['COMMUNE', 'COMMUNAUTE DE COMMUNES', 'DEPARTEMENT', 'ETAT', 'PRIVE']},
- 'TR_GEST_VO': {'type': 'string', 'allowed': ['COMMUNE', 'COMMUNAUTE DE COMMUNES', 'DEPARTEMENT', 'ETAT', 'PRIVE']},
- 'TR_SCHEMA': {'maxlength': 100, 'type': 'string'},
- 'TR_DATE_IN': {'validator': is_french_date},
- 'TR_SRC_GEO': {'type': 'string', 'maxlength': 50},
- 'TR_QLT_GEO': {'type': 'string', 'allowed': ['A', 'B', 'C']},
- 'TR_PRO_MD': {'type': 'string', 'maxlength': 20},
- 'TR_COMMENT': {'type': 'string', 'maxlength': 300, 'empty': True},
- 'TR_STATUT': {'type': 'string', 'allowed': ['EN ETUDE', 'EN REALISATION', 'EN SERVICE', 'HORS SERVICE']}}
- class Zapbo(BaseGeoModel):
- schema = {'geom': {'bbox': {type: 'list', 'items': [{'type': 'int', 'min': xmin, 'max': xmax},
- {'type': 'int', 'min': ymin, 'max': ymax},
- {'type': 'int', 'min': xmin, 'max': xmax},
- {'type': 'int', 'min': ymin, 'max': ymax}]},
- 'parts': {},
- 'points': {},
- 'shapeType': {'allowed': [gis.POLYGON]}},
- 'ID_ZAPBO': {'type': 'string', 'maxlength': 10},
- 'COMMENTAIR': {'type': 'string', 'maxlength': 254, 'empty': True},
- 'STATUT': {'type': 'string', 'allowed': ['EN ETUDE', 'EN REALISATION', 'EN SERVICE', 'HORS SERVICE']}}
- class Netgeo22Validator(BaseValidator):
- name = "Netgeo v2.2 DOE"
- files = {"artere_geo.shp": Artere, "cable_geo.shp": Cable, "equipement_passif.shp": Equipement, "noeud_geo.shp":Noeud, "tranchee_geo.shp":Tranchee, "zapbo_geo.shp":Zapbo}
-
- @classmethod
- def _load_file(cls, model, file_path):
-
- result = []
-
- with gis.ShapeFile(file_path) as sf:
- fields = sf.fields()
- for record in sf.records():
-
- data = dict(zip(fields, record.record))
-
- item = model(record.shape, **data)
- result.append(item)
-
- return result
-
- @classmethod
- def _technical_validation(cls, dataset):
-
- # rattacher les noeuds aux artères
- # rattacher les equipements aux cables
-
- return dataset
-
- if __name__ == "__main__":
- from core.constants import MAIN
- subject = MAIN / "work" / "STURNO_192AP0_REC_COMPLEMENT_180822_OK.zip"
- report = Netgeo22Validator.submit(subject)
|