1

I have an unusual challenge that I'm struggling with. I'm hoping someone has come across this and can point me towards a solution.

Overview:

I am searching for a way to use mapnik + shapefiles with dynamically filtered results without PostgreSQL or manual changes to the dbf file.

Details:

I need to draw territories made up of ZIP codes on a map. My current solution pulls polys from a MySQL database and draws them on a Google Map at runtime. This is obviously very slow. I'd prefer to move this to a mapnik-compatible solution so I can render the tiles on the fly and have the maps respond much more quickly.

Now, before you say, just use Postgres instead of shapefiles, let me say that this server doesn't and can't have Postgres on it. It sucks, but it's a hard limitation. The dynamic data source is MySQL which mapnik doesn't support.

I can, of course, render these territories manually offline (I happen to use TileMill for this). To do so, I must manipulate the shapefile's dbf file in OpenOffice by adding a simple column that flags if a ZIP is in a territory or not and to whom it belongs. Then in my CartoCSS, it's a simple matter of looking for [INCLUDE="Y"] { ... } to draw or hide the poly, and a simple color assignment based on the territory owner's id. No problem there except for the fact that this is incredibly time- and labor-intensive.

The real problem is that the client has nearly a hundred territories that change from time to time. To make matters worse, when they change, a ripple effect can cause a chain reaction whereby neighboring territories change. And to make matters even worse, they don't want the the territory owners to see each others' territories, meaning each territory has to be filtered and drawn in isolation.

So, I'm looking for an automated hybrid solution to handle the filtering the shapefile so I don't have to redo this by hand every time the territories change.

My hair is turning gray on this one. I'm open to options so long as the solution doesn't rely on PostgreSQL or manual manipulation of the shapefile's dbf database.

Any help and advice is much appreciated.

Thanks, Steve

TLDR: I need to use mapnik + shapefiles with dynamically filtered results without PostgreSQL or manual changes to the dbf file

sstringer
  • 486
  • 7
  • 12
  • This is a very specific question, I fear too specific for stackoverflow. Therefore I suggest to re-ask your question either at the openstreetmap mailing lists or help.openstreetmap.org in order to reach significantly more OSM developers. – scai Nov 02 '13 at 21:02

1 Answers1

0

You can do this by rendering territories with unique colors, and then manipulating the color palette of the rendered images when you serve them. Doing this on the server is cheap if done in C, or you can attempt to do it in javascript (Performance unknown to me Possible to change an image color palette using javascript?).

There's a description of this here: http://blog.webfoot.com/2013/03/12/optimizing-map-tile-generation/

If you're rendering boundaries only, then this will not work.

If you haven't already, you can speed up polygon rendering in browser for your existing system by using encoded polylines (https://developers.google.com/maps/documentation/utilities/polylinealgorithm). This is a huge performance bump, and reduces wire-transfer size as well.

Community
  • 1
  • 1
Nino Walker
  • 2,742
  • 22
  • 30