def __init__(self, config, logger = None): Analyser_Merge_Point.__init__(self, config, logger) self.def_class_missing_official(item = 8370, id = 120, level = 3, tags = ["merge", "emergency", "fix:picture", "fix:survey"], title = T_("Defibrillator not integrated"), trap = T_("Location of defibrillators from this dataset can be very approximative. Check carefully the position before adding to OSM.")) self.def_class_possible_merge(item = 8371, id = 13, level = 3, tags = ['merge', 'emergency', 'fix:chair', 'fix:picture'], title = T_('Defibrillator integration suggestion'), trap = T_("Location of defibrillators from this dataset can be very approximative. Check carefully the position before adding to OSM.")) self.def_class_update_official(item = 8372, id = 14, level = 3, tags = ['merge', 'emergency', 'fix:picture', 'fix:survey'], title = T_('Defibrillator update')) self.init( "https://www.data.gouv.fr/fr/datasets/geodae-base-nationale-des-defibrillateurs/", "Géo'DAE - Base Nationale des Défibrillateurs", GeoJSON( SourceDataGouv( attribution="Ministère de la Santé", dataset="61556e1e9d6adb2df86eb0fc", resource="86ea48a0-dd94-4a23-b71c-80d3041d7db2")), Load_XY("geom_x", "geom_y", select = {"c_etat_fonct": "En fonctionnement", "c_doublon": "f"}), Conflate( select = Select( types = ["nodes"], tags = {"emergency": "defibrillator"}), osmRef = "ref:FR:GeoDAE", conflationDistance = 100, mapping = Mapping( static1 = {"emergency": "defibrillator"}, mapping1 = { "ref:FR:GeoDAE": "c_gid", "indoor": lambda res: "yes" if res["c_acc"] == "Intérieur" else "no" if res["c_acc"] == "Extérieur" else None, "access": lambda res: "yes" if res["c_acc_lib"] == "t" else "permissive" if res["c_acc_lib"] == "f" else None, "level": lambda res: self.normalizeEtage(res["c_acc_etg"]), "opening_hours": lambda res: self.normalizeHours(res["c_disp_j"], res["c_disp_h"]) }, mapping2 = { "name": lambda res: reaccentue.reaccentue(res["c_nom"]) if res["c_nom"] and res["c_acc_complt"] else None, "operator": lambda res: reaccentue.reaccentue(res["c_expt_rais"]) if "c_expt_rais" in res else None, "source": lambda res: ("Direction Générale de la Santé - " + res["c__edit_datemaj|timePosition"].split("T")[0]), "defibrillator:location": lambda res: res["c_acc_complt"] if "c_acc_complt" in res else reaccentue.reaccentue(res["c_nom"]) if res["c_nom"] else None, "start_date": "c_date_instal|timePosition", "security_desk": lambda res: "yes" if res["c_acc_pcsec"] == "t" else "no" if res["c_acc_pcsec"] == "f" else None, "reception_desk": lambda res: "yes" if res["c_acc_acc"] == "t" else "no" if res["c_acc_acc"] == "f" else None, "operator:ref:FR:SIREN": lambda res: res["c_expt_siren"] if "c_expt_siren" in res else None }, text = lambda tags, fields: {"en": " - ".join(filter(lambda x: x, [ "POSITION APPROXIMATIVE À VÉRIFIER" if fields["c_etat_valid"] == "en attente de validation" else None, fields["c_nom"], "Horaires : "+fields["c_disp_j"][1:-1]+" "+fields["c_disp_h"][1:-1] if fields["c_disp_j"] and fields["c_disp_h"] else None, " ".join(filter(lambda x: x, [ fields["c_adr_num"], fields["c_adr_voie"], fields["c_com_cp"], fields["c_com_nom"] ])) ]))} )))
def __init__(self, config, logger = None): Analyser_Merge.__init__(self, config, logger) self.def_class_missing_official(item = 8370, id = 120, level = 3, tags = ["merge"], title = T_("Defibrillator not integrated"), trap = T_("Location of defibrillators from this dataset can be very approximative. Check carefully the position before adding to OSM.")) self.init( u"https://geo.data.gouv.fr/fr/datasets/a701db3964e8fd81823c92afc029f138ffa207b3", u"Défibrillateurs de la base nationale GeoDAE", CSV(Source(attribution = u"Direction Générale de la Santé", fileUrl = u"https://transcode.geo.data.gouv.fr/services/5e2a1fbefa4268bc25629472/feature-types/ms:geodae_publique?format=CSV&projection=WGS84")), Load("c_long_coor1", "c_lat_coor1", select = {"c_etat_fonct": u"En fonctionnement", "c_doublon": u"f"}), Mapping( select = Select( types = ["nodes"], tags = {"emergency": "defibrillator"}), conflationDistance = 100, generate = Generate( static1 = {"emergency": "defibrillator"}, static2 = {"source": self.source}, mapping1 = { "name": lambda res: reaccentue.reaccentue(res["c_nom"]) if res["c_nom"] and res["c_acc_complt"] else None, "indoor": lambda res: "yes" if res["c_acc"] == u"Intérieur" else "no" if res["c_acc"] == u"Extérieur" else None, "access": lambda res: "yes" if res["c_acc_lib"] == "t" else "permissive" if res["c_acc_lib"] == "f" else None, "security_desk": lambda res: "yes" if res["c_acc_pcsec"] == "t" else "no" if res["c_acc_pcsec"] == "f" else None, "reception_desk": lambda res: "yes" if res["c_acc_acc"] == "t" else "no" if res["c_acc_acc"] == "f" else None, "level": lambda res: self.normalizeEtage(res["c_acc_etg"]), "defibrillator:location": lambda res: res["c_acc_complt"] if "c_acc_complt" in res else reaccentue.reaccentue(res["c_nom"]) if res["c_nom"] else None, "opening_hours": lambda res: self.normalizeHours(res["c_disp_j"], res["c_disp_h"]), "start_date": "c_date_instal|timePosition", "operator:ref:FR:SIREN": lambda res: res["c_expt_siren"] if "c_expt_siren" in res else None, "operator": lambda res: reaccentue.reaccentue(res["c_expt_rais"]) if "c_expt_rais" in res else None }, text = lambda tags, fields: {"en": " - ".join(filter(lambda x: x, [ u"POSITION APPROXIMATIVE À VÉRIFIER" if fields["c_etat_valid"] == u"en attente de validation" else None, fields["c_nom"], "Horaires : "+fields["c_disp_j"][1:-1]+" "+fields["c_disp_h"][1:-1] if fields["c_disp_j"] and fields["c_disp_h"] else None, " ".join(filter(lambda x: x, [ fields["c_adr_num"], fields["c_adr_voie"], fields["c_com_cp"], fields["c_com_nom"] ])) ]))} )))
def __init__(self, config, error_file, logger, missing_official, missing_osm, classs, level, title, trancheEffectifs, selectTags, generateTags): SubAnalyser_Merge_Dynamic.__init__(self, config, error_file, logger) classss = int(classs.replace('.', '0')[:-1]) * 100 + ord(classs[-1]) - 65 self.def_class_missing_official(item = missing_official, id = classss+1, level = level, tags = ['merge'], title = T_f('{0} not integrated', classs + ', ' + title)) #self.def_class_missing_osm(item = missing_osm, id = classss+2, level = level, tags = ['merge'], # title = T_f('{0} without tag "{1}" or invalid', title, 'ref:FR:SIRET')) #self.def_class_possible_merge(item = missing_official[0:-1]+"1", id = classss+3, level = level, tags = ['merge'], # title = T_f('{0}, integration suggestion', title)) #self.def_class_update_official(item = missing_official[0:-1]+"2", id = classss+4, level = level, tags = ['merge'], # title = T_f('{0} update', title)) dep_code = config.options.get('dep_code') or config.options.get('country').split('-')[1] self.init( u"http://www.sirene.fr/sirene/public/static/open-data", u"Sirene", CSV(Source(attribution = u"INSEE", millesime = "06/2019", gzip = True, fileUrl = u"http://data.cquest.org/geo_sirene/v2019/last/dep/geo_siret_{0}.csv.gz".format(dep_code))), Load("longitude", "latitude", select = {"activitePrincipaleEtablissement": classs, "geo_type": "housenumber", "etatAdministratifEtablissement": "A"}, where = lambda res: ( float(res["geo_score"]) > 0.9 and (not res["complementAdresseEtablissement"] or (" APP" not in res["complementAdresseEtablissement"] and " CHEZ " not in res["complementAdresseEtablissement"])) and (not trancheEffectifs or (res["trancheEffectifsEtablissement"] and res["trancheEffectifsEtablissement"] != "NN" and int(res["trancheEffectifsEtablissement"]) > trancheEffectifs)) ), uniq = ["siren", "nic"]), Mapping( select = Select( types = ['nodes', 'ways'], tags = selectTags), conflationDistance = 50, generate = Generate( static1 = generateTags, static2 = {"source": self.source}, mapping1 = { "ref:FR:SIRET": lambda fields: fields["siret"], # "ref:FR:RNA": "RNA", #"short_name": "SIGLE", #"start_date": lambda fields: # "-".join([fields["DDEBACT"][0:4], fields["DDEBACT"][4:6], fields["DDEBACT"][6:8]]) if fields["DDEBACT"] != "19000101" else # "-".join([fields["DCRET"][0:4], fields["DCRET"][4:6], fields["DCRET"][6:8]]) if fields["DCRET"] != "19000101" else # None, "name": lambda fields: reaccentue.reaccentue(fields["enseigne1Etablissement"]) if fields["enseigne1Etablissement"] else (reaccentue.reaccentue(fields["denominationUsuelleEtablissement"]) if fields["denominationUsuelleEtablissement"] else None)}, text = lambda tags, fields: {"en": ', '.join(filter(lambda f: f and f != 'None', [fields["enseigne1Etablissement"] or fields["denominationUsuelleEtablissement"]] + list(map(lambda k: fields[k], ["numeroVoieEtablissement", "indiceRepetitionEtablissement", "typeVoieEtablissement", "libelleVoieEtablissement", "complementAdresseEtablissement", "codePostalEtablissement", "libelleCommuneEtablissement"]))))} )))
def cleanName(self, name): return reaccentue.reaccentue(name) if name.upper() == name else name