Changeset 41eac600 in osmose-backend


Ignore:
Timestamp:
Mar 17, 2013 10:37:23 PM (7 years ago)
Author:
Frédéric Rodrigo <frodrigo@…>
Branches:
master
Children:
7ab3c99
Parents:
89d64cb
Message:

Make merge conflation analysis by osm shape, not just by centroid

Location:
analysers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • analysers/Analyser_Merge.py

    r996213d r41eac600  
    116116    ST_AsText(osm_item.geom), 
    117117    osm_item.tags, 
    118     osm_item.geom 
     118    osm_item.geom, 
     119    osm_item.shape 
    119120FROM 
    120121    osm_item 
     
    127128 
    128129sql21 = """ 
    129 CREATE INDEX missing_osm_index_geom ON missing_osm USING GIST(geom) 
     130CREATE INDEX missing_osm_index_shape ON missing_osm USING GIST(shape) 
    130131""" 
    131132 
     
    163164    missing_osm 
    164165WHERE 
    165     ST_DWithin(missing_official.geom, missing_osm.geom, %(conflationDistance)s) 
     166    ST_DWithin(missing_official.geom, missing_osm.shape, %(conflationDistance)s) 
    166167ORDER BY 
    167168    missing_osm.id, 
    168     ST_Distance(missing_official.geom, missing_osm.geom) ASC 
     169    ST_Distance(missing_official.geom, missing_osm.shape) ASC 
    169170""" 
    170171 
     
    328329 
    329330        typeGeom = {'n': 'geom', 'w': 'way_locate(linestring)', 'r': 'relation_locate(id)'} 
     331        typeShape = {'n': 'geom', 'w': 'ST_Envelope(linestring)', 'r': 'relation_bbox(id)'} 
    330332        self.logger.log(u"Retrive OSM item") 
    331333        where = "(" + (") OR (".join(map(lambda x: self.where(x), self.osmTags))) + ")" 
     
    342344                        END AS ref, 
    343345                        %(geom)s::geography AS geom, 
     346                        %(shape)s::geography AS shape, 
    344347                        tags 
    345348                    FROM 
     
    348351                        %(geom)s IS NOT NULL AND 
    349352                        ST_SetSRID(ST_GeomFromText('%(bbox)s'), 4326) && %(geom)s AND 
    350                         %(where)s)""" % {"type":type[0], "ref":self.osmRef, "geom":typeGeom[type[0]], "from":type, "bbox":bbox, "where":where}, 
     353                        %(where)s)""" % {"type":type[0], "ref":self.osmRef, "geom":typeGeom[type[0]], "shape":typeShape[type[0]], "from":type, "bbox":bbox, "where":where}, 
    351354                    self.osmTypes 
    352355                ) 
     
    355358        if self.osmRef != "NULL": 
    356359            self.run("CREATE INDEX osm_item_index_ref ON osm_item(ref)") 
    357         self.run("CREATE INDEX osm_item_index_geom ON osm_item USING GIST(geom)") 
     360        self.run("CREATE INDEX osm_item_index_shape ON osm_item USING GIST(shape)") 
    358361 
    359362        joinClause = [] 
     
    361364            joinClause.append("official.ref = osm_item.ref") 
    362365        else: 
    363             joinClause.append("ST_DWithin(official.geom, osm_item.geom, %s)" % self.conflationDistance) 
     366            joinClause.append("ST_DWithin(official.geom, osm_item.shape, %s)" % self.conflationDistance) 
    364367        if self.extraJoin: 
    365368            joinClause.append("osm_item.tags->'%(tag)s' = official.tags->'%(tag)s'" % {"tag": self.extraJoin}) 
  • analysers/analyser_merge_wikipedia.py

    r0254ab7 r41eac600  
    431431            {"place": ["island"]}, 
    432432            ["ways", "relations"], 
    433             300, 
     433            100, 
    434434            logger) 
    435435 
Note: See TracChangeset for help on using the changeset viewer.