Changeset 6f688f3 in osmose-backend


Ignore:
Timestamp:
Aug 3, 2014 10:52:37 PM (5 years ago)
Author:
Frédéric Rodrigo <fred.rodrigo@…>
Branches:
master
Children:
a0e2716
Parents:
f0d7885
git-author:
Frédéric Rodrigo <fred.rodrigo@…> (03/08/2014 22:47:18)
git-committer:
Frédéric Rodrigo <fred.rodrigo@…> (03/08/2014 22:52:37)
Message:

Rewrite SQL of analyser_osmosis_surface_overlaps

File:
1 edited

Legend:

Unmodified
Added
Removed
  • analysers/analyser_osmosis_surface_overlaps.py

    rdeab773 r6f688f3  
    44########################################################################### 
    55##                                                                       ## 
    6 ## Copyrights Frédéric Rodrigo 2012                                      ## 
     6## Copyrights Frédéric Rodrigo 2014                                      ## 
    77##                                                                       ## 
    88## This program is free software: you can redistribute it and/or modify  ## 
     
    2323from Analyser_Osmosis import Analyser_Osmosis 
    2424 
     25sql00 = """ 
     26CREATE TEMP TABLE surface AS 
     27SELECT 
     28    id, 
     29    is_polygon, 
     30    linestring, 
     31    tags->'waterway' AS waterway, 
     32    tags->'natural' AS natural, 
     33    tags->'landuse' AS landuse 
     34FROM 
     35    ways 
     36WHERE 
     37    (tags?'waterway' OR tags?'natural' OR tags?'landuse') AND 
     38    (NOT tags?'waterway' OR tags->'waterway' = 'riverbank') AND 
     39    ST_NPoints(linestring) > 1 
     40""" 
     41 
     42sql01 = """ 
     43CREATE INDEX idx_surface_waterway ON surface(waterway); 
     44CREATE INDEX idx_surface_natural ON surface("natural"); 
     45CREATE INDEX idx_surface_landuse ON surface(landuse); 
     46CREATE INDEX idx_surface_linestring ON surface USING GIST(linestring); 
     47""" 
     48 
    2549sql10 = """ 
    2650SELECT 
     
    3054    {1} 
    3155FROM 
    32     ways AS w1, 
    33     ways AS w2 
     56    surface AS w1, 
     57    surface AS w2 
    3458WHERE 
    35     -- Same tags 
    36     w1.tags?'{0}' AND 
    37     w2.tags?'{0}' AND 
    3859    -- Same value 
    39     w1.tags->'{0}' = w2.tags->'{0}' AND 
    40     ('{0}' != 'waterway' OR w1.tags->'{0}' = 'riverbank') AND 
     60    w1."{0}" IS NOT NULL AND 
     61    w2."{0}" IS NOT NULL AND 
     62    w1."{0}" = w2."{0}" AND 
    4163    -- Avoid duplicate check 
    4264    w1.id < w2.id AND 
    43     -- Valid 
    44     ST_NPoints(w1.linestring) > 1 AND 
    45     ST_NPoints(w2.linestring) > 1 AND 
    4665    -- Ways not linked 
    4766    NOT ST_Touches(w1.linestring, w2.linestring) AND 
     
    6988 
    7089    def analyser_osmosis_all(self): 
     90        self.run(sql00) 
     91        self.run(sql01) 
    7192        for t in self.tags: 
    7293            self.run(sql10.format(t[1], t[0]), self.callback10) 
Note: See TracChangeset for help on using the changeset viewer.