forked from osm-fr/osmose-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyser_merge_poste_FR.py
98 lines (90 loc) · 6.48 KB
/
analyser_merge_poste_FR.py
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
#!/usr/bin/env python
#-*- coding: utf-8 -*-
###########################################################################
## ##
## Copyrights Frédéric Rodrigo 2012-2015 ##
## ##
## This program is free software: you can redistribute it and/or modify ##
## it under the terms of the GNU General Public License as published by ##
## the Free Software Foundation, either version 3 of the License, or ##
## (at your option) any later version. ##
## ##
## This program is distributed in the hope that it will be useful, ##
## but WITHOUT ANY WARRANTY; without even the implied warranty of ##
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ##
## GNU General Public License for more details. ##
## ##
## You should have received a copy of the GNU General Public License ##
## along with this program. If not, see <http://www.gnu.org/licenses/>. ##
## ##
###########################################################################
import re
from modules.OsmoseTranslation import T_
from .Analyser_Merge import Analyser_Merge, SourceOpenDataSoft, CSV, Load, Conflate, Select, Mapping
# http://wiki.openstreetmap.org/wiki/WikiProject_France/data.gouv.fr/Import_des_points_de_contact_postaux
class Analyser_Merge_Poste_FR(Analyser_Merge):
def __init__(self, config, logger = None):
Analyser_Merge.__init__(self, config, logger)
self.def_class_missing_official(item = 8020, id = 1, level = 3, tags = ['merge', 'post', 'fix:picture', 'fix:survey'],
title = T_('Post office not integrated'))
self.def_class_missing_osm(item = 7050, id = 2, level = 3, tags = ['merge', 'post', 'fix:chair'],
title = T_('Post office without tag "ref:FR:LaPoste" or invalid'))
self.def_class_possible_merge(item = 8021, id = 3, level = 3, tags = ['merge', 'post', 'fix:chair'],
title = T_('Post office, integration suggestion'))
self.def_class_update_official(item = 8022, id = 4, level = 3, tags = ['merge', 'post', 'fix:chair', 'fix:picture'],
title = T_('Post office update'))
self.APBP = re.compile(' (AP|BP|RP)$')
self.init(
"https://datanova.legroupe.laposte.fr/explore/dataset/laposte_poincont",
"Liste des services disponibles en bureaux de poste, agences postales et relais poste",
CSV(
SourceOpenDataSoft(
attribution="LaPoste",
url="https://datanova.legroupe.laposte.fr/explore/dataset/laposte_poincont")),
Load("Longitude", "Latitude"),
Conflate(
select = Select(
types = ["nodes", "ways"],
tags = {"amenity": "post_office"}),
osmRef = "ref:FR:LaPoste",
conflationDistance = 1000,
mapping = Mapping(
static1 = {"amenity": "post_office"},
static2 = {
"source": self.source,
"brand": "La Poste",
# "brand:wikidata": "Q373724", # non-consensual
"brand:wikipedia": "fr:La Poste (entreprise française)"},
mapping1 = {
"ref:FR:LaPoste": "#Identifiant_du_site",
"post_office:type": lambda res:
"post_annex" if res["Libellé_du_site"].endswith(" AP") else # Bureau de poste annexe
"post_partner" if res["Libellé_du_site"].endswith(" RP") else # Relais poste commerçant
None, # BP: Bureau de poste; other
"addr:postcode": "Code_postal",
# localite
# pays
"atm": lambda res: self.bool[res["Distributeur_de_billets"]],
"stamping_machine": lambda res: self.bool[res["Affranchissement_Libre_Service"]],
"wheelchair": lambda res:
"yes" if self.bool[res["Accessibilité_Absence_de_ressaut_de_plus_de_2_cm_de_haut"]] and self.bool[res["Accessibilité_Entrée_autonome_en_fauteuil_roulant_possible"]] else
"limited" if self.bool[res["Accessibilité_Absence_de_ressaut_de_plus_de_2_cm_de_haut"]] or self.bool[res["Accessibilité_Entrée_autonome_en_fauteuil_roulant_possible"]] else
"no"},
mapping2 = {
"operator": lambda res:
None if res["Libellé_du_site"].endswith(" AP") else # Bureau de poste annexe
None if res["Libellé_du_site"].endswith(" RP") else # Relais poste commerçant
"La Poste", # BP: Bureau de poste; other
# "operator:wikidata": lambda res: # non consensuel
# None if res["Libellé_du_site"].endswith(" AP") else # Bureau de poste annexe
# None if res["Libellé_du_site"].endswith(" RP") else # Relais poste commerçant
# "Q373724", # BP: Bureau de poste; other
"operator:wikipedia": lambda res:
None if res["Libellé_du_site"].endswith(" AP") else # Bureau de poste annexe
None if res["Libellé_du_site"].endswith(" RP") else # Relais poste commerçant
"fr:La Poste (entreprise française)", # BP: Bureau de poste; other
"name": lambda res: re.sub(self.APBP, "", res["Libellé_du_site"]),
"change_machine": lambda res: self.bool[res["Changeur_de_monnaie"]],
"phone": lambda res: ("+33" + res["Numéro_de_téléphone"][1:]) if res["Numéro_de_téléphone"] != "3631" else None},
text = lambda tags, fields: {"en": "Post office {0}".format(", ".join(filter(lambda x: x, [fields["Précision_du_géocodage"].lower(), fields["Adresse"], fields["Complément_d_adresse"], fields["Lieu_dit"], fields["Code postal"], fields["Localité"]])))} )))
bool = {"Non": None, "Oui": "yes"}