[postgis-users] Failing hstore query

Zenon Panoussis oracle at provocation.net
Sat Dec 20 07:58:10 PST 2014


I'm rendering OSM tiles with mapnik and I want to get rid of
maritime borders, so I added the "AND NOT" statement to the
style:

<Parameter name="table"><![CDATA[( SELECT way, admin_level
  FROM eur_line
  WHERE boundary = 'administrative'
    AND admin_level = '2'
    AND NOT tags @> '"maritime"=>"yes"'::hstore
) AS data]]></Parameter>

Manually executing the query inside the parenthesis as-is
works exactly as expected. The data (osm_id, tags) can look
like this:

46419225 | "name:en"=>"Portugal, Azores, Flores and Corvo (territorial
waters)", "name:fr"=>"Portugal, Açores, Flores et Corvo (eaux territoriales)",
"name:pt"=>"Portugal, Açores, Flores e Corvo (águas territoriais)",
"maritime"=>"yes", "border_type"=>"territorial"

Mapnik's full query based on the above style looks like
this:

SELECT ST_AsBinary("way") AS geom,"admin_level" FROM (
SELECT way, admin_level
          FROM eur_line
          WHERE boundary = 'administrative'
            AND admin_level = '2'
            AND NOT tags @> '"maritime"=>"yes"'::hstore
        ) AS data WHERE "way" && ST_SetSRID('BOX3D(-939258.2035682483 6574807.42
4977713,313086.0678560843 7827151.69640205)'::box3d, 3857)

The end result is that all maritime borders which do have
the "maritime"=>"yes" tag are still rendered. And for my
life I just can't grasp how the outer SELECT can ever see
maritime borders when the inner SELECT is supposed to have
excluded them.

Can anyone see what I'm doing wrong here and help me regain
my sanity?

Z



More information about the postgis-users mailing list