Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a building is null condition to the landcover layer #217

Closed
wants to merge 1 commit into from

Conversation

pnorman
Copy link
Collaborator

@pnorman pnorman commented Oct 7, 2013

Adds a building IS NULL to the landcover SQL.

The motivation is that this allows substantial performance increases with the right indexes and that landcover is not buildings, as well as fixing some subtle styling oddities.

The performance gain is at least +3.9% over f5ef478 with the greatest gains shown at high zooms with +5.5% at z18 and +2.9% at z13. A partial index WHERE building IS NULL as described in #207 (comment) was present in all cases.

Buildings are drawn on top of this layer, so there isn't a rendering impact.

Details on why this doesn't impact rendering

The old SQL filtering condition is

WHERE "landuse" IS NOT NULL
  OR "leisure" IS NOT NULL
  OR "aeroway" IN ('apron','aerodrome')
  OR "amenity" IN ('parking','university','college','school','hospital','kindergarten','grave_yard')
  OR "military" IN ('barracks','danger_area')
  OR "natural" IN ('field','beach','desert','heath','mud','grassland','wood','sand','scrub')
  OR "power" IN ('station','sub_station','generator')
  OR "tourism" IN ('attraction','camp_site','caravan_site','picnic_site','zoo')
  OR "highway" IN ('services','rest_area')

This pull just adds AND building IS NULL to it.

Additionally, the CASE statement in the columns effectively restricts leisure to 'swimming_pool', 'playground', 'park', 'recreation_ground', 'common', 'garden', 'golf_course' and landuse to

'quarry', 'vineyard', 'orchard', 'cemetery', 'grave_yard', 'residential', 'garages', 'field',
 'meadow', 'grass', 'allotments', 'forest', 'farmyard', 'farm', 'farmland', 'recreation_ground', 
'conservation', 'village_green', 'retail', 'industrial', 'railway', 'commercial', 'brownfield',
'landfill', 'greenfield', 'construction'

I was initially concerned that adding building IS NULL would impact rendering of features like amenity=school, but this is not so.

It turns out that if there is a building tag, the building is rendered on top of the landuse layer, obscuring it, giving it only a very minor rendering effect around the edges due to anti-aliasing.
As an example, see these two buildings, one building=yes amenity=school and one a normal building=yes

8978689785

There is a difference but it is extremely subtle. The building fill is also very subtly different.

The same thing will apply to any building - the building polygon will be drawn on top of the landcover polygon

@pnorman
Copy link
Collaborator Author

pnorman commented Oct 7, 2013

landcover_building_null

N=4 for IS NULL, N=6 for baseline

@gravitystorm
Copy link
Owner

I'm still pondering this over.

There's one minor flaw in the logic, which is that building=no doesn't get rendered as a building, but adding the tag to an amenity polygon would then stop it from rendering. That's just a minor thing though.

A slightly bigger problem is when someone takes the stylesheets, and wants to turn off buildings. Then lots of amenities won't show up.

I think the main problem is that what we want to do has nothing to do with buildings per se - it's just that we want a faster way to retrieve the polygons we're interested in, and it's a combination of

  • there's a lot of buildings
  • we draw buildings later on
    ... neither of which are actually related to the layer in question.

It's not so much that where building is NULL makes logical sense for the partial index, it's more that writing the where landuse is foo and leisure is bar is a lot more cumbersome.

I'm still pondering what the best approach is.

@pnorman
Copy link
Collaborator Author

pnorman commented Dec 9, 2013

It's not so much that where building is NULL makes logical sense for the partial index, it's more that writing the where landuse is foo and leisure is bar is a lot more cumbersome.

Well, the partial index reflects the queries, including the existing queries on water-areas-overlay, glaciers-text, landuse-overlay, national-park-boundaries.

A slightly bigger problem is when someone takes the stylesheets, and wants to turn off buildings. Then lots of amenities won't show up.

True, although these are amenities that don't currently show up as amenities, only as buildings. Right now if they take the stylesheet and turn off buildings, they get additional features (any amenity that was also a building) showing up. I'm not sure if features appearing when you disable buildings or features disappearing when you disable buildings is worse.

In the particular case I used as an example, I'd say that it's a tagging error and the school needs to be a bigger polygon, not just the building.

There's one minor flaw in the logic, which is that building=no doesn't get rendered as a building, but adding the tag to an amenity polygon would then stop it from rendering. That's just a minor thing though.

Hmm - this is also an issue for partitioning, although maybe a partial index where building='no' on the table where building is not null would solve it. That partial index would be very small. I suppose the other option is to do where building is null or building = 'no' everywhere through both the stylesheet, indexes, and partitioning. cc @apmon

@dieterdreist
Copy link

This would also not render those 1% of landuses which have a building tag
in general, including "bad-style-multipolygons" (with the building tag on
the outer way and no tags on the relation), so that you'd get rendering
errors in the yards of those buildings.

http://taginfo.openstreetmap.org/keys/landuse#combinations
93 302
0.97%
building http://taginfo.openstreetmap.org/keys/building

@matkoniecz
Copy link
Contributor

@pnorman
I am confused by combined

as well as fixing some subtle styling oddities

and

Details on why this doesn't impact rendering

So is it supposed to change rendering or not?

@pnorman
Copy link
Collaborator Author

pnorman commented Oct 16, 2014

closed, with #565 open

@pnorman pnorman closed this Oct 16, 2014
@pnorman pnorman deleted the landcover_nobuilding branch August 18, 2015 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants