Changeset 3821411 in osmose-backend


Ignore:
Timestamp:
May 26, 2013 10:35:55 PM (6 years ago)
Author:
Frédéric Rodrigo <frodrigo@…>
Branches:
master
Children:
e62d4bb
Parents:
12b54e7
git-author:
Frédéric Rodrigo <frodrigo@…> (25/05/2013 15:31:05)
git-committer:
Frédéric Rodrigo <frodrigo@…> (26/05/2013 22:35:55)
Message:

Detect misc intersections (highway, water, tree)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • analysers/analyser_osmosis_highway_vs_building.py

    rb0e822f7 r3821411  
    4646    buildings.tags->'building' = 'yes' AND 
    4747    NOT buildings.tags ? 'wall' AND 
    48     ST_Intersects(buildings.linestring, highways.linestring) AND 
    49     NOT ST_Touches(buildings.linestring, highways.linestring) 
    50 ; 
     48    ST_NPoints(buildings.linestring) > 1 AND 
     49    ST_NPoints(highways.linestring) > 1 AND 
     50    ST_Crosses(buildings.linestring, highways.linestring) 
     51""" 
     52 
     53sql20 = """ 
     54SELECT 
     55    tree.id, 
     56    building.id, 
     57    ST_AsText(tree.geom) 
     58FROM 
     59    nodes AS tree 
     60    JOIN ways AS building ON 
     61        tree.geom && building.linestring AND 
     62        ST_NPoints(highway.linestring) > 2 AND 
     63        ST_Intersects(tree.geom, ST_MakePolygon(building.linestring)) 
     64    LEFT JOIN relation_members ON 
     65        relation_members.member_type = 'W' AND 
     66        relation_members.member_id = building.id 
     67WHERE 
     68    relation_members.member_id IS NULL AND 
     69    tree.tags?'natural' AND 
     70    tree.tags->'natural' = 'tree' AND 
     71    building.tags?'building' AND 
     72    building.tags->'building' != 'no' AND 
     73    NOT building.tags ? 'wall' AND 
     74    building.is_polygon 
     75""" 
     76 
     77sql30 = """ 
     78SELECT 
     79    tree.id, 
     80    highway.id, 
     81    ST_AsText(tree.geom) 
     82FROM 
     83    nodes AS tree 
     84    JOIN ways AS highway ON 
     85        tree.geom && highway.linestring AND 
     86        ST_NPoints(highway.linestring) > 1 AND 
     87        ST_Intersects(ST_Buffer(tree.geom::geography, 0.25)::geometry, highway.linestring) 
     88WHERE 
     89    tree.tags?'natural' AND 
     90    tree.tags->'natural' = 'tree' AND 
     91    highway.tags?'highway' AND 
     92    highway.tags->'highway' IN ( 
     93        'motorway', 'motorway_link', 
     94        'trunk', 'trunk_link', 
     95        'primary', 'primary_link', 
     96        'secondary', 'secondary_link', 
     97        'tertiary', 'tertiary_link', 
     98        'unclassified', 'residential', 'living_street') AND 
     99    NOT highway.tags?'layer' 
     100""" 
     101 
     102sql40 = """ 
     103SELECT 
     104    highways.id, 
     105    water.id, 
     106    ST_AsText(ST_Centroid(ST_Intersection(highways.linestring, water.linestring))) 
     107FROM 
     108    ways AS highways 
     109    JOIN ways AS water ON 
     110        highways.linestring && water.linestring AND 
     111        ST_NPoints(highways.linestring) > 1 AND 
     112        ST_NPoints(water.linestring) > 1 AND 
     113        ST_Crosses(highways.linestring, water.linestring) 
     114WHERE 
     115    (highways.tags?'highway' OR highways.tags?'railway') AND 
     116    NOT highways.tags?'tunnel' AND 
     117    NOT highways.tags?'bridge' AND 
     118    ( 
     119        ( 
     120            water.tags?'waterway' AND 
     121            NOT water.tags?'tunnel' AND 
     122            NOT water.tags?'bridge' 
     123        ) OR ( 
     124            water.tags?'natural' AND 
     125            water.tags->'natural' = 'water' 
     126        ) 
     127    ) 
    51128""" 
    52129 
     
    55132    def __init__(self, config, logger = None): 
    56133        Analyser_Osmosis.__init__(self, config, logger) 
    57         self.classs_change[1] = {"item":"1070", "level": 2, "tag": ["highway", "building", "geom"], "desc":{"fr": u"Intersection entre une voie et un bâtiment", "en": u"Way intersecting building"} } 
     134        self.classs_change[1] = {"item":"1070", "level": 2, "tag": ["highway", "building", "geom"], "desc":{"fr": u"Intersection entre une voie et un bâtiment", "en": u"Highway intersecting building"} } 
     135        self.classs_change[2] = {"item":"1070", "level": 2, "tag": ["tree", "building", "geom"], "desc":{"fr": u"Intersection entre un arbre et un bâtiment", "en": u"Tree intersecting building"} } 
     136        self.classs_change[3] = {"item":"1070", "level": 2, "tag": ["highway", "tree", "geom"], "desc":{"fr": u"Arbre très proche d'une voie", "en": u"Tree and highway too close"} } 
     137        self.classs_change[4] = {"item":"1070", "level": 2, "tag": ["highway", "waterway", "geom"], "desc":{"fr": u"Intersection entre une voie et de l'eau", "en": u"Highway intersecting water"} } 
    58138        self.callback10 = lambda res: {"class":1, "data":[self.way_full, self.way_full, self.positionAsText]} 
     139        self.callback20 = lambda res: {"class":1, "data":[self.node_full, self.way_full, self.positionAsText]} 
     140        self.callback30 = lambda res: {"class":1, "data":[self.node_full, self.way_full, self.positionAsText]} 
     141        self.callback40 = lambda res: {"class":1, "data":[self.way_full, self.way_full, self.positionAsText]} 
    59142 
    60143    def analyser_osmosis_all(self): 
    61144        self.run(sql10.format("", ""), self.callback10) 
     145        self.run(sql20.format("", ""), self.callback20) 
     146        self.run(sql30.format("", ""), self.callback30) 
     147        self.run(sql40.format("", ""), self.callback40) 
    62148 
    63149    def analyser_osmosis_touched(self): 
    64         dup = set() 
    65         self.run(sql10.format("touched_", ""), lambda res: dup.add(res[0]) or self.callback10(res)) 
    66         self.run(sql10.format("", "touched_"), lambda res: res[0] in dup or dup.add(res[0]) or self.callback10(res)) 
     150        self.run(sql10.format("touched_", ""), self.callback10) 
     151        self.run(sql10.format("", "touched_"), self.callback10) 
     152        self.run(sql20.format("touched_", ""), self.callback20) 
     153        self.run(sql20.format("", "touched_"), self.callback20) 
     154        self.run(sql30.format("touched_", ""), self.callback30) 
     155        self.run(sql30.format("", "touched_"), self.callback30) 
     156        self.run(sql40.format("touched_", ""), self.callback40) 
     157        self.run(sql40.format("", "touched_"), self.callback40) 
Note: See TracChangeset for help on using the changeset viewer.