Friday, August 27, 2010

Mapnik label cut off strategies

I've been spending a lot of time dealing with mapnik labels/shields being cut off. Here are some strategies:

  1. change the "buffer_size" property of the map object in the mapnik xml ... you can also direclty change this in generate_tiles.py (which comes with osm mapnik package). I don't think the mapnik xml was being read in my case. When I changed the line self.m.buffer_size to = 0, my cutoff problems disappear
  2. you'll need to do some tweaking with the order layers are defined within mapnik/cascadenik
  3. also tweaking of text-allow-overlap and text-avoid-edges (these are cascadenik properties, there are similarly named ones for mapnik alone)
  4. you may need to merge segments of the same road
To sum up: my strategy was first getting all my ordering straightened out with how layers are defined/ordered within mapnik/cascadenik. I then turned most layers to text-avoid-edges and text-allow-overlap to true. I set the buffer value to 0 in the .py file that I was using to render my tiles (in the osm package). Then moving around stuff that overlapped badly and will possibly need to merge segments of the same road.

Tuesday, August 10, 2010

ImportError: No module named mapnik

I'm still not sure what exactly causes this error: "ImportError: No module named mapnik" .. clearly Python is not finding the mapnik bindings, but why?  I think it might be related to a new install of ArcGIS, which installs a new version of Python.  I am also trying to figure out how exactly to fix this.  Recently I relaunched "cmd" and that worked.

Thursday, July 29, 2010

python zipfile.py MemoryError

Was getting the following error on zipfile.py (actually while attempting to run a cascadenik script):
newdata = self.dc.decompress(newdata)
MemoryError

I fixed this error by changing the compression algorithm that my .zip was being created with to "STORE" (i.e. no compression).

Wednesday, April 21, 2010

python cgi with xxamp/apache on windows

I recently figured out that a web service class I was dealing with (WFS in OpenLayers) would only accept requests through a proxy script (despite the requests were sent to my local machine!). OpenLayers has a .cgi proxy script which runs through Python, and here's how I got it to work:

1. Download proxy.cgi to the cgi-bin folder within xampp (or wherever it is), and install Python. I used version 2.5
2. Follow these instructions to setup Apache for running python
3. Finally, make sure you change the "shebang" line at the top of proxy.cgi from #!/usr/bin/env python to #!c:/python25/python (if python.exe is installed at C:\Python25\python.exe)

Monday, March 15, 2010

Tilecaching MXD/ArcGIS Server to file/folder-based only (e.g. google, mapnik)

So it seems like there's no automated way to go from mxd to file/folder based (rather than web service) tile cache. The best I could do was use maptiler/gdal2tiles (maptiler is a very nice gui for gdal2tiles) to cache raster layers. This will fuse multiple raster layers, but doesn't handle vectors. If you want to pass vectors through here you can always convert to raster with some other tool but you'll end up loosing any scale dependencies. Please note, you'll likely have to incorporate a part of their auto-generated code for google maps, since the file naming doesn't completely conform to x/y/z google scheme naming. I've included my modified tile provider class for the gmap_overlays submodule (part of the gmap addons submod collection ... lives in PATH_TO_DRUPAL\sites\all\modules\gmap_addons\gmap_overlays\js), which handles output from maptiler/gdal2tiles.

note: exposing as wms and using tilecache might be a good idea, but this non-automated solution that is OK for me right now

Thursday, March 11, 2010

AGS error: #000569: Failed to generate cache. All server contexts failed to cache map.

I was getting the following error when trying to cache a map service in ArcGIS Server/ArcCatalog: 000569: Failed to generate cache. All server contexts failed to cache map.

I ultimately resolved this issue by upgrading my server software (ArcGIS Desktop) to the same version as my client (in my case 9.3.1 service pack 1). Caching only within a feature, which in my case was a three county polygon that was much larger than the area I wanted to cache, greatly improved performance ... I'm not sure if it even would have worked without that.

Note: if postinstallation hangs while upgrading server software check out this post: http://support.esri.com/index.cfm?fa=knowledgebase.techarticles.articleShow&d=32766

Thursday, March 4, 2010

Drupal SWFTools Error

Was getting the following error: "You are missing some Flash content that should appear here! Perhaps your browser cannot display it, or maybe it did not initialize correctly." on Chrome and I.E. only. Figured out that by changing the embed method under Embedding settings (Home>Administer>Site configuration>SWF Tools>Embedding settings) back to "Direct embedding - do not use JavaScript replacement" from " SWFObject 2 - JavaScript" I no longer get this error