Changeset 91540b8 in osmose-backend


Ignore:
Timestamp:
Mar 5, 2013 11:08:54 PM (7 years ago)
Author:
Frédéric Rodrigo <frodrigo@…>
Branches:
master
Children:
4fd809a
Parents:
7f01626
git-author:
Frédéric Rodrigo <frodrigo@…> (03/03/2013 10:38:11)
git-committer:
Frédéric Rodrigo <frodrigo@…> (05/03/2013 23:08:54)
Message:

Remove sourceRef from merge analyser as is same of osmRef after translation

Location:
analysers
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • analysers/Analyser_Merge.py

    rf8ca5b56 r91540b8  
    3838sql01_ref = """ 
    3939SELECT 
    40     %(table)s.%(ref)s AS _ref, 
    4140    %(x)s AS _x, 
    4241    %(y)s AS _y, 
     
    5453sql01_geo = """ 
    5554SELECT 
    56     NULL::varchar AS _ref, 
    5755    %(x)s AS _x, 
    5856    %(y)s AS _y, 
     
    251249            self.moved_official = None 
    252250        self.osmRef = "NULL" 
    253         self.sourceRef = "NULL" 
    254251        self.extraJoin = None 
    255252        self.sourceWhere = lambda res: True 
     
    280277        self.logger.log(u"Convert official to OSM") 
    281278        giscurs = self.gisconn.cursor(cursor_factory=psycopg2.extras.DictCursor) 
    282         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: 
     279        def insertOfficial(res): 
     280            tags = self.tagFactory(res) 
    283281            giscurs.execute(sql02, { 
    284                 "ref": res[0], 
    285                 "tags": self.tagFactory(res), 
     282                "ref": tags[self.osmRef] if self.osmRef != "NULL" else None, 
     283                "tags": tags, 
    286284                "fields": dict(zip(dict(res).keys(), map(lambda x: str(x), dict(res).values()))), 
    287                 "x": self.sourceXfunction(res[1]), "y": self.sourceYfunction(res[2]), "SRID": self.sourceSRID 
     285                "x": self.sourceXfunction(res[0]), "y": self.sourceYfunction(res[1]), "SRID": self.sourceSRID 
    288286            } ) if self.sourceWhere(res) else False 
    289         ) 
     287        self.run0((sql01_ref if self.osmRef != "NULL" else sql01_geo) % {"table":self.sourceTable, "x":self.sourceX, "y":self.sourceY, "where":self.formatCSVSelect(self.csv_select)}, insertOfficial) 
    290288        giscurs.execute("SELECT ST_AsText(ST_Envelope(ST_Extent(geom::geometry))::geography) FROM official") 
    291289        bbox = giscurs.fetchone()[0] 
     
    325323 
    326324        joinClause = [] 
    327         if self.sourceRef != "NULL": 
     325        if self.osmRef != "NULL": 
    328326            joinClause.append("official.ref = osm_item.ref") 
    329327        else: 
     
    336334        self.run(sql10 % {"joinClause": joinClause}) 
    337335        self.run(sql11) 
    338         self.run(sql12, lambda res: { 
    339             "class": self.missing_official["class"], 
    340             "subclass": str(abs(int(hash("%s%s"%(res[0],res[1]))))), 
    341             "self": lambda r: [0]+r[1:], 
    342             "data": [self.node_new, self.positionAsText], 
    343             "text": self.text(defaultdict(lambda:None,res[2]), defaultdict(lambda:None,res[3])), 
    344             "fix": {"+": res[2]} if res[2] != {} else None, 
    345         } ) 
    346  
    347         if self.sourceRef == "NULL": 
     336        if self.missing_official: 
     337            self.run(sql12, lambda res: { 
     338                "class": self.missing_official["class"], 
     339                "subclass": str(abs(int(hash("%s%s"%(res[0],res[1]))))), 
     340                "self": lambda r: [0]+r[1:], 
     341                "data": [self.node_new, self.positionAsText], 
     342                "text": self.text(defaultdict(lambda:None,res[2]), defaultdict(lambda:None,res[3])), 
     343                "fix": {"+": res[2]} if res[2] != {} else None, 
     344            } ) 
     345 
     346        if self.osmRef == "NULL": 
    348347            return # Job done, can't do more in geo mode 
    349348 
     
    390389        file = open("%s/%s.metainfo.csv" % (self.config.dst_dir, self.officialName), "w") 
    391390        file.write("file,origin,osm_date,official_non_merged,osm_non_merged,merged\n") 
    392         self.giscurs.execute("SELECT COUNT(*) FROM missing_official;") 
    393         official_non_merged = self.giscurs.fetchone()[0] 
     391        if self.missing_official: 
     392            self.giscurs.execute("SELECT COUNT(*) FROM missing_official;") 
     393            official_non_merged = self.giscurs.fetchone()[0] 
     394        else: 
     395            official_non_merged = 0 
    394396        self.giscurs.execute("SELECT COUNT(*) FROM missing_osm;") 
    395397        osm_non_merged = self.giscurs.fetchone()[0] 
  • analysers/analyser_merge_geodesie.py

    r60a0a48 r91540b8  
    5050        self.osmTypes = ["nodes"] 
    5151        self.sourceTable = "geodesie" 
    52         self.sourceRef = "ref" 
    5352        self.sourceX = "lon" 
    5453        self.sourceY = "lat" 
  • analysers/analyser_merge_merimee.py

    rfeccd33 r91540b8  
    6262        self.osmTypes = ["nodes", "ways", "relations"] 
    6363        self.sourceTable = "merimee" 
    64         self.sourceRef = "ref" 
    6564        self.sourceX = "lon" 
    6665        self.sourceY = "lat" 
  • analysers/analyser_merge_poste_fr.py

    r5a136ea r91540b8  
    7575        self.osmTypes = ["nodes", "ways"] 
    7676        self.sourceTable = "poste_fr" 
    77         self.sourceRef = "identifiant" 
    7877        self.sourceX = "longitude" 
    7978        self.sourceY = "latitude" 
  • analysers/analyser_merge_railstation_fr.py

    rfeccd33 r91540b8  
    5555        self.osmTypes = ["nodes", "ways"] 
    5656        self.sourceTable = "railstation_fr" 
    57         self.sourceRef = "uic" 
    5857        self.sourceX = "lon" 
    5958        self.sourceY = "lat" 
  • analysers/analyser_merge_ratp.py

    r0662569 r91540b8  
    5151        self.osmTypes = ["nodes", "ways"] 
    5252        self.sourceTable = "ratp" 
    53         self.sourceRef = "id" 
    5453        self.sourceX = "lon" 
    5554        self.sourceY = "lat" 
  • analysers/analyser_merge_school_fr.py

    r748f4da6 r91540b8  
    5757        self.osmTypes = ["nodes", "ways", "relations"] 
    5858        self.sourceTable = "school_fr" 
    59         self.sourceRef = "numero_uai" 
    6059        self.sourceX = "X" 
    6160        self.sourceY = "Y" 
Note: See TracChangeset for help on using the changeset viewer.