Changeset 2e370eb in osmose-backend


Ignore:
Timestamp:
Nov 1, 2012 1:43:51 PM (5 years ago)
Author:
Frédéric Rodrigo <frodrigo@…>
Branches:
master
Children:
af4e049
Parents:
1325f81
Message:

Update RATP merge

Files:
1 added
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • analysers/Analyser_Merge.py

    rfeccd33 r2e370eb  
    4848    %(y)s IS NOT NULL AND 
    4949    %(x)s::varchar != '' AND 
    50     %(y)s::varchar != '' 
     50    %(y)s::varchar != '' AND 
     51    %(where)s 
    5152""" 
    5253 
     
    6364    %(y)s IS NOT NULL AND 
    6465    %(x)s::varchar != '' AND 
    65     %(y)s::varchar != '' 
     66    %(y)s::varchar != '' AND 
     67    %(where)s 
    6668""" 
    6769 
     
    236238        self.csv_encoding = "utf-8" 
    237239        self.csv_filter = lambda i: i 
     240        self.csv_select = {} 
    238241        if hasattr(self, 'missing_official'): 
    239242            self.classs[self.missing_official["class"]] = self.missing_official 
     
    274277        self.logger.log(u"Convert official to OSM") 
    275278        giscurs = self.gisconn.cursor(cursor_factory=psycopg2.extras.DictCursor) 
    276         self.run0((sql01_ref if self.sourceRef != "NULL" else sql01_geo) % {"table":self.sourceTable, "ref":self.sourceRef, "x":self.sourceX, "y":self.sourceY}, lambda res: 
     279        self.run0((sql01_ref if self.sourceRef != "NULL" else sql01_geo) % {"table":self.sourceTable, "ref":self.sourceRef, "x":self.sourceX, "y":self.sourceY, "where":self.formatCSVSelect(self.csv_select)}, lambda res: 
    277280            giscurs.execute(sql02, { 
    278281                "ref": res[0], 
     
    446449                tags[tag] = str(res[colomn]) 
    447450        return tags 
     451 
     452    def formatCSVSelect(self, csv_select): 
     453        where = [] 
     454        for k, v in csv_select.items(): 
     455            where.append("%s = '%s'" % (k, v)) 
     456        if where == []: 
     457            return "1=1" 
     458        else: 
     459            return " AND ".join(where) 
  • analysers/analyser_merge_ratp.py

    rfeccd33 r2e370eb  
    2525 
    2626 
    27 class Analyser_Merge_Ratp(Analyser_Merge): 
     27class _Analyser_Merge_Ratp(Analyser_Merge): 
    2828 
    2929    create_table = """ 
    30         id VARCHAR(254) PRIMARY KEY, 
     30        id VARCHAR(254), 
    3131        lon VARCHAR(254), 
    3232        lat VARCHAR(254), 
     
    3636    """ 
    3737 
    38     def __init__(self, config, logger = None): 
     38    def __init__(self, config, logger, select, osmTags, defaultTag): 
    3939        self.missing_official = {"item":"8040", "class": 1, "level": 3, "tag": ["merge", "railway"], "desc":{"fr":u"Station RATP non intégrée"} } 
    4040        self.possible_merge   = {"item":"8041", "class": 3, "level": 3, "tag": ["merge", "railway"], "desc":{"fr":u"Station RATP, proposition d'intégration"} } 
    4141        Analyser_Merge.__init__(self, config, logger) 
    42         self.officialURL = "http://www.data.gouv.fr/donnees/view/Positions-g%C3%A9ographiques-des-stations-du-r%C3%A9seau-ferr%C3%A9-RATP-564122" 
    43         self.officialName = "Positions géographiques des stations du réseau ferré RATP" 
    44         self.csv_file = "merge_data/a4cc3aae97f68aa98e8baee5e9e08cf7.csv" 
    45         self.csv_format = "WITH DELIMITER AS '#' NULL AS 'null' CSV" 
    46         self.osmTags = { 
    47             "railway": ["station", "tram_stop"], 
     42        self.officialURL = "http://data.ratp.fr/fr/les-donnees/fiche-de-jeu-de-donnees/dataset/positions-geographiques-des-stations-du-reseau-ratp.html" 
     43        self.officialName = "Positions géographiques des stations du réseau RATP" 
     44        self.csv_file = "merge_data/ratp_arret_graphique.csv" 
     45        self.csv_format = "WITH DELIMITER AS '#' NULL AS '' CSV" 
     46        self.csv_select = { 
     47            "reseau": select 
    4848        } 
     49        self.osmTags = osmTags 
    4950        self.osmRef = "ref:FR:RATP" 
    5051        self.osmTypes = ["nodes", "ways"] 
     
    5556        self.sourceSRID = "4326" 
    5657        self.defaultTag = { 
    57             "railway": "station", 
    58             "source": "data.gouv.fr:RATP - 07/2012" 
     58            "source": "RATP - 07/2012", 
    5959        } 
     60        self.defaultTag.update(defaultTag) 
    6061        self.defaultTagMapping = { 
    6162            "ref:FR:RATP": "id", 
     
    6465        self.conflationDistance = 100 
    6566        self.text = lambda tags, fields: {"fr":"Station RATP de %s" % tags["name"]} 
     67 
     68 
     69class Analyser_Merge_Ratp_Bus(_Analyser_Merge_Ratp): 
     70    def __init__(self, config, logger = None): 
     71        _Analyser_Merge_Ratp.__init__(self, config, logger, "bus", {"highway": "bus_stop"}, {"highway": "bus_stop", "public_transport": "stop_position", "bus": "yes"}) 
     72 
     73class Analyser_Merge_Ratp_Metro(_Analyser_Merge_Ratp): 
     74    def __init__(self, config, logger = None): 
     75        _Analyser_Merge_Ratp.__init__(self, config, logger, "metro", {"railway": "station"}, {"railway": "station"}) 
     76 
     77class Analyser_Merge_Ratp_RER(_Analyser_Merge_Ratp): 
     78    def __init__(self, config, logger = None): 
     79        _Analyser_Merge_Ratp.__init__(self, config, logger, "rer", {"railway": "station"}, {"railway": "station"}) 
     80 
     81class Analyser_Merge_Ratp_Tram(_Analyser_Merge_Ratp): 
     82    def __init__(self, config, logger = None): 
     83        _Analyser_Merge_Ratp.__init__(self, config, logger, "tram", {"railway": "tram_stop"}, {"railway": "tram_stop", "public_transport": "stop_position", "tram": "yes"}) 
Note: See TracChangeset for help on using the changeset viewer.