question on Filters

View: New views
3 Messages — Rating Filter:   Alert me  

question on Filters

by wclapham :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I ran into an issue when trying to render a test map (python + xml) from a postgis db with filters in place.  I'm not sure if this is by design or a bug, so i thought i'd post and ask so i can stop scratching my head over it.

If a filter field is not found in the source database, is it supposed to cause mapnik to abort rendering that entire layer?  or should it just ignore that filter and move on to the next?

Let me elaborate a bit:
Lets say i have a database with only 3 fields: "name", "leisure", and "landuse".   If i try to run mapnik with a filter that doesn't exist, or is misspelled, like..."land_usage", i get a blank map...thus skipping all other filters that are correct.  If i take that one filter out, then everything else gets rendered normal again.

Here's my working xml example (it draws all 3 requested things):

    <Rule>
      <Filter>[landuse] = 'farm'</Filter>
      <MaxScaleDenominator>1000000</MaxScaleDenominator>
      <PolygonSymbolizer>
        <CssParameter name="fill">#ead8bd</CssParameter>
     </PolygonSymbolizer>
    </Rule>
    <Rule>
      <Filter>[leisure] = 'park'</Filter>
      <MaxScaleDenominator>1000000</MaxScaleDenominator>
      <PolygonSymbolizer>
        <CssParameter name="fill">#b6fdb6</CssParameter>
     </PolygonSymbolizer>
    </Rule>
    <Rule>
      <Filter>[leisure] = 'golf_course'</Filter>
      <MaxScaleDenominator>1000000</MaxScaleDenominator>
      <PolygonSymbolizer>
        <CssParameter name="fill">#b5e3b5</CssParameter>
     </PolygonSymbolizer>
    </Rule>

Here's my NON-working xml example (It draws nothing at all.  Not even the correct filters):

    <Rule>
      <Filter>[land_usage] = 'farm'</Filter>
      <MaxScaleDenominator>1000000</MaxScaleDenominator>
      <PolygonSymbolizer>
        <CssParameter name="fill">#ead8bd</CssParameter>
     </PolygonSymbolizer>
    </Rule>
    <Rule>
      <Filter>[leisure] = 'park'</Filter>
      <MaxScaleDenominator>1000000</MaxScaleDenominator>
      <PolygonSymbolizer>
        <CssParameter name="fill">#b6fdb6</CssParameter>
     </PolygonSymbolizer>
    </Rule>
    <Rule>
      <Filter>[leisure] = 'golf_course'</Filter>
      <MaxScaleDenominator>1000000</MaxScaleDenominator>
      <PolygonSymbolizer>
        <CssParameter name="fill">#b5e3b5</CssParameter>
     </PolygonSymbolizer>
    </Rule>

The obvious "fix" to this, is to always make sure every single filter field exists is spelled correctly, but as the xml grows, it's harder and harder to track.  Again, just wondering if this is a bug or just the way that filters are supposed to work.

Thanks in advance,
-will

Re: question on Filters

by Lennard-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

wclapham wrote:

> If a filter field is not found in the source database, is it supposed to
> cause mapnik to abort rendering that entire layer?  or should it just ignore
> that filter and move on to the next?

That's how it currently works, yes. You're not the first to be bitten by
it, and there's also already a ticket for this, but not much has been
done there, yet.

http://trac.mapnik.org/ticket/242


--
Lennard
_______________________________________________
Mapnik-users mailing list
Mapnik-users@...
https://lists.berlios.de/mailman/listinfo/mapnik-users

Re: question on Filters

by wclapham :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks a ton for the quick reply and verification of this problem.  I thought i was going crazy for a while there as i couldnt find reference to that behavior anywhere in the documentation.  Hopefully not too many other people will fall into that trap after seeing this post.
I'll just have to keep a sharp eye out for those potential gotchas until a fix is in place in a future version.
-will

Lennard-2 wrote:
That's how it currently works, yes. You're not the first to be bitten by
it, and there's also already a ticket for this, but not much has been
done there, yet.

http://trac.mapnik.org/ticket/242