Skip to content

Commit

Permalink
Museum integration in France with Muséofile database (#621)
Browse files Browse the repository at this point in the history
Museum integration in France with Muséofile database
  • Loading branch information
Olyon authored and frodrigo committed Sep 26, 2019
1 parent 6af6c9a commit e945fe2
Showing 1 changed file with 58 additions and 0 deletions.
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 -*-

###########################################################################
## ##
## 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"]]))})))

0 comments on commit e945fe2

Please sign in to comment.