Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Museum integration in France with Muséofile database #621

Merged
merged 6 commits into from
Sep 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions analysers/analyser_merge_museum_FR.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

frodrigo marked this conversation as resolved.
Show resolved Hide resolved
###########################################################################
## ##
## Copyrights Jérôme Amagat 2019 ##
## ##
## 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/>. ##
## ##
###########################################################################

from .Analyser_Merge import Analyser_Merge, Source, CSV, Load, Mapping, Select, Generate
import re

class Analyser_Merge_Museum_FR(Analyser_Merge):
def __init__(self, config, logger = None):

self.missing_official = {"item":"8010", "class": 31, "level": 3, "tag": ["merge"], "desc": T_(u"Museum not integrated") }
self.possible_merge = {"item":"8011", "class": 33, "level": 3, "tag": ["merge"], "desc": T_(u"Museum, integration suggestion") }

Analyser_Merge.__init__(self, config, logger,
u"https://www.data.gouv.fr/fr/datasets/musees-de-france-base-museofile/",
u"Musées de France : base Muséofile",
CSV(Source(attribution = u"Ministère de la Culture - Muséofile", millesime = "09/2019",
fileUrl = u"https://www.data.gouv.fr/fr/datasets/r/5ccd6238-4fb0-4b2c-b14a-581909489320"),
separator = u';'),
Load("geolocalisation", "geolocalisation",
where = lambda row: row["geolocalisation"],
xFunction = lambda x: x and x.split(',')[1],
yFunction = lambda y: y and y.split(',')[0]
),
Mapping(
select = Select(
types = ["nodes", "ways", "relations"],
tags = {"tourism": "museum"}),
conflationDistance = 300,
osmRef = u"ref:FR:museofile",
generate = Generate(
static1 = {"tourism": "museum"},
static2 = {"source": self.source},
mapping1 = {u"ref:FR:museofile": "Identifiant"},
mapping2 = {"website": lambda res: None if not res["URL"] else res["URL"] if res["URL"].startswith('http') else 'http://' + res["URL"],
"phone": lambda res: "+33 " + res["Téléphone"][1:] if re.match(r"^0[0-9] [0-9]{2} [0-9]{2} [0-9]{2} [0-9]{2}$", res["Téléphone"]) else None,
"name": lambda res: res["Nom usage"][0].upper() + res["Nom usage"][1:] if res["Nom usage"] else res["Nom officiel"][0].upper() + res["Nom officiel"][1:],
"official_name" : lambda res: res["Nom officiel"][0].upper() + res["Nom officiel"][1:] if res["Nom usage"] and res["Nom officiel"].lower() != res["Nom usage"].lower() else None,
},
text = lambda tags, fields: {"en": ' '.join(filter(lambda x: x, [fields["Adresse"], fields["Code Postal"], fields["Ville"]]))})))