forked from osm-fr/osmose-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyser_merge_poste_FR.py
82 lines (74 loc) · 5.28 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
#!/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 .Analyser_Merge import Analyser_Merge, Source, CSV, Load, Mapping, Select, Generate
# 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.missing_official = self.def_class(item = 8020, id = 1, level = 3, tags = ['merge', 'post'],
title = T_('Post office not integrated'))
self.missing_osm = self.def_class(item = 7050, id = 2, level = 3, tags = ['merge', 'post'],
title = T_('Post office without tag "ref:FR:LaPoste" or invalid'))
self.possible_merge = self.def_class(item = 8021, id = 3, level = 3, tags = ['merge', 'post'],
title = T_('Post office, integration suggestion'))
self.update_official = self.def_class(item = 8022, id = 4, level = 3, tags = ['merge', 'post'],
title = T_('Post office update'))
self.APBP = re.compile(' (AP|BP|RP)$')
self.init(
u"https://datanova.legroupe.laposte.fr/explore/dataset/laposte_poincont",
u"Liste des services disponibles en bureaux de poste, agences postales et relais poste",
CSV(Source(attribution = u"LaPoste", millesime = "03/2019",
fileUrl = u"https://datanova.legroupe.laposte.fr/explore/dataset/laposte_poincont/download/?format=csv&timezone=Europe/Berlin&use_labels_for_header=true"),
separator = u";"),
Load("Longitude", "Latitude"),
Mapping(
select = Select(
types = ["nodes", "ways"],
tags = {"amenity": "post_office"}),
osmRef = "ref:FR:LaPoste",
conflationDistance = 1000,
generate = Generate(
static1 = {
"amenity": "post_office",
"operator": "La Poste"},
static2 = {"source": self.source},
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
"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[u"Accessibilité_Absence_de_ressaut_de_plus_de_2_cm_de_haut"]] and self.bool[res[u"Accessibilité_Entrée_autonome_en_fauteuil_roulant_possible"]] else
"limited" if self.bool[res[u"Accessibilité_Absence_de_ressaut_de_plus_de_2_cm_de_haut"]] or self.bool[res[u"Accessibilité_Entrée_autonome_en_fauteuil_roulant_possible"]] else
"no"},
mapping2 = {
"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": u"Post office %s" % ", ".join(filter(lambda x: x, [fields[u"Précision_du_géocodage"].lower(), fields[u"Adresse"], fields[u"Complément_d_adresse"], fields[u"Lieu_dit"], fields["Code postal"], fields[u"Localité"]]))} )))
bool = {"Non": None, "Oui": "yes"}