By Rupert
tilecache
Jpeg decoder problem on TileCache on MacOSX Leopard
May 12th
There is a problem with a “jpeg decoder” because Python Imaging Library (PIL) cannot find the jpeg libraries. Remember that we installed kyngchaos UnixIO libraries, therefore the PIL setup.py script should point to use those libraries.
Actually, I even installed the jpegsrc manually. I believe there is no need to do this, since UnixIO Image libraries is sufficient enough for PIL to install. What is important is to ensure that python tests succeeded. Once you get passed that, then installing PIL should work.
1. Extract Imaging-1.1.6.tar.gz 2. Edit setup.py to reflect: JPEG_ROOT="/Library/Frameworks/UnixImageIO.framework/unix" 3. python setup.py build_ext -i 4. If no test fails, then go ahead and install 5. python setup.py install
Using TileCache, OpenLayers, Mapserver for Projection 900913
Apr 8th
I had a few problems with TileCache the other week which I am eager to blog about, since I knew for sure that later on, I might encounter the same. I don’t have the exact errors with me right now, so I’m jotting this down from my head…
- Classic Resolutions problem. Use extent_type=loose
- Can not set image type
UPDATED (JAN 11, 2010): Classic Resolutions problem:
How are resolutions calculated? Assuming we have:
Original:
Lower Left (LL) or minx, miny: 12453557, -5434940
Upper Right (UR) or max, maxy: 16980842, -1180729
maxResolution = (max – minx)/tilesize = (16980842 – 12453557)/512 = 8842.353
where tilesize = 512.
Therefore, we can set/guess for max so that we have maxResolution as a whole number.
Adjusted:
minx, miny: 12453557, -5434940
maxx, maxy: 16980661, -1180729
gives a maxResolution (whole number) of 8842.
Now, you can use 8842 in both the TileCache.cfg and OpenLayers Javascript. More >
Installing TileCache on RedHat/CentOS
Jul 25th
1. Install Apache
./configure –prefix=/usr/local/apache2 –enable-so –enable-rewrite –with-mpm=prefork
make
make install
rm -Rf /usr/local/apache2/htdocs/*
2. Install mod_python-3.3.1
./configure --with-apxs=/usr/local/apache2/bin/apxs
make
make install
3. Install Python Imaging Library (PIL) – Imaging-1.1.6
python setup.py install
Note: To check if PIL was successfully installed:
#python selftest.py
***Test Failed*** 1 failures.
*** 1 tests of 57 failed.
47 ln -s /usr/lib/libjpeg.so.62 /usr/lib/libjpeg.so
48 ldconfig
49 python setup.py install
51 python selftest.py
54 rm -rf Imaging-1.1.6
55 tar -zxvf Imaging-1.1.6.tar.gz
56 cd Imaging-1.1.6
58 python selftest.py -> still fails
59 python setup.py install
60 python selftest.py -> ok
4. Check if mod_python was sucessfully installed.
http://www.dscpl.com.au/wiki/ModPython/Articles/GettingModPythonWorking
[root@rupert-centos pytest]# python Python 2.4.3 (#1, Mar 14 2007, 18:51:08) [GCC 4.1.1 20070105 (Red Hat 4.1.1-52)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import mod_python >>> mod_python.version '3.3.1' >>>
4. Edit httpd.conf
<directory> AddHandler python-program .py PythonHandler TileCache.Service PythonOption TileCacheConfig /usr/local/apache2/htdocs/tilecache/tilecache.cfg PythonDebug On PythonPath "sys.path + ['/usr/local/apache2/htdocs/tilecache/']" </directory> <directory> AddHandler mod_python .py PythonHandler test PythonDebug On </directory>
Note: This syntax will work for all versions of mod_python. In version 3.0 and later, the name of the mod_python handler reference has actually been changed and thus it is now preferred to use “mod_python” instead of “python-program”. The old name though is still supported and will be used here to avoid confusion for those using version 2.7.
5. Test your python
from mod_python import apache def handler(req): req.log_error('handler') req.content_type = 'text/plain' req.send_http_header() req.write('mptest.py\n') return apache.OK
Transparent Overlays in TileCache
Mar 31st
From the tilecache mailing list….
Hi Everyone,
Really appreciate all the replies…
1. Installed Imaging-1.1.6.tar.gz (PIL).
[root@rupert-linux ~]# python Python 2.3.4 (#1, Mar 10 2006, 06:12:09) [GCC 3.4.5 20051201 (Red Hat 3.4.5-2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> print sys.path ['', '/usr/lib/python23.zip', '/usr/lib/python2.3', '/usr/lib/python2.3/plat-linux2', '/usr/lib/python2.3/lib-tk', '/usr/lib/python2.3/lib-dynload', '/usr/lib/python2.3/site-packages', '/usr/lib/python2.3/site-packages/PIL', '/usr/lib/python2.3/site-packages/gtk-2.0'] >>>
2. Modified test1.cfm
41 var options = {
42 controls: [new OpenLayers.Control.MouseDefaults()]
43 };
44
45 map = new OpenLayers.Map( $('map'), options);
46
47 var layer_base = new OpenLayers.Layer.WMS(
48 "Base Layer",
49 "#request.mapserv_tile#",
50 {
51 map: '/home/map/beijing/new/wms.map',
52 layers: '#request.basemap_tile#',
53 format: 'image/png', 'transparent': 'false'
54 }
55 );
56
57 var layer_road = new OpenLayers.Layer.WMS(
58 "Road Layer",
59 "#request.mapserv_tile#",
60 {
61 map: '/home/map/beijing/new/wms.map',
62 layers: '#request.roads_tile#',
63 format: 'image/png', 'transparent': 'true'
64 },
65 {
66 reproject: false
67 }
68 );
69
70 map.addLayer(layer_base);
71 layer_base.setIsBaseLayer(true);
72
73 layer_road.setIsBaseLayer(false);
74 map.addLayer(layer_road);3. tilecache.cfg. Commented metaTile=true http://222.128.19.19/tilecache/tilecache.cfg
47 [basemap] 48 type=WMSLayer 49 url=http://127.0.0.1/cgi-bin/mapserv?map=/home/map/beijing/new/wms.map 50 layers=district,greens,major_river,minor_river 51 #bbox=-180,-90,180,90 52 #metaTile=true 53 extension=png 54 55 [roads] 56 type=WMSLayer 57 url=http://127.0.0.1/cgi-bin/mapserv?map=/home/map/beijing/new/wms.map 58 #layers=road4,road4label,road3,road3label,road2,road2label,road1,road1label,road11,road11label 59 #bbox=116.1737,39.8211,116.5640,40.0799 60 #maxresolution=1.40625 61 #bbox=-180,-90,180,90 62 layers=road1,road1label,road11,road11label 63 extension=png 64 #metaTile=true
4. Modified wms.map http://222.128.19.19/tilecache/wms.map
OUTPUTFORMAT
NAME png
DRIVER "GD/PNG"
MIMETYPE "image/png"
IMAGEMODE RGB
EXTENSION "png"
FORMATOPTION "INTERLACE=OFF"
END5. Checked access_log. “transparent=true” exists…
192.168.1.150 - - [30/Mar/2007:13:46:26 +0800] "GET /tilecache/tilecache.py?MAP=%2Fhome%2Fmap%2Fbeijing%2Fnew%2Fwms.map&LAYERS=r
oads&FORMAT=image%2Fpng&TRANSPARENT=true&SERVICE=WMS&VERSION=1.1.1&REQUEST=G
etMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BB
OX=116.334229%2C39.891357%
2C116.345215%2C39.902344&WIDTH=256&HEIGHT=256 HTTP/1.1" 200 14580
Now, this is really weird. I have “transparent”: true in test1.cfm all the time. That didn’t worked.
For every test iteration i made, I always tried clearing the cache, removing the python compiled scripts, then restarting Apache just to get a clean state..
rm -Rf /usr/local/apache2/htdocs/tmp/*
rm /wwwroot/tilecache/TileCache/*.pyc
/etc/init.d/httpd restart
Then I tried appending “transparent=true” to tilecache.cfg based on Eric’s suggestion…
That worked. Now I wonder why… Nevertheless, its working now. Again many thanks to everyone…
Rupert
On Fri, Mar 30, 2007 at 01:57:43PM +0800, Rupert de Guzman Jr wrote:
> Hi Everyone,
>
> Really appreciate all the replies…
> Then I tried appending “transparent=true” to tilecache.cfg based on
> Eric’s suggestion…
> That worked. Now I wonder why… Nevertheless, its working now. Again
> many thanks to everyone…
TileCache pays almost no attention to the URL: Only the BBOX and the layername matter. Anything else is simply ignored: so your transparency being set in OpenLayers actually has 0 affect.
The reason for this is that TileCache can only store one copy of an image. If the URL parameters modified the content, you could get an inconsistent cache.
This is ‘by design’, insofar as there is no obvious solution (other than to complain more loudly when TC Gets parameters it isn’t expecting, which is an outstanding FIXME in the code). The lack of error message is not by design, and I’m sorry you got bit by the poorly documented behavior.
Regards,
–
Christopher Schmidt
MetaCarta
Setting python_path on Unix
Mar 29th
At the time of this writing.. download mod_python-3.3.1.tgz
./configure –with-apxs=/usr/local/apache2/bin/apxs
make
make install
You need to pass the PYTHONPATH to apache..
AddHandler python-program .py
PythonHandler TileCache.Service
PythonOption TileCacheConfig /usr/local/apache2/htdocs/tilecache/tilecache.cfg
PythonDebug On
PythonPath “sys.path + ['/usr/local/apache2/htdocs/tilecache/']”
In your bash shells, you could also check the PYTHONPATH…
[root@rupert-linux views]# python Python 2.3.4 (#1, Mar 10 2006, 06:12:09) [GCC 3.4.5 20051201 (Red Hat 3.4.5-2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> print sys.path ['', '/usr/lib/python23.zip', '/usr/lib/python2.3', '/usr/lib/python2.3/plat-linux2', '/usr/lib/python2.3/lib-tk', '/usr/lib/python2.3/lib-dynload', '/usr/lib/python2.3/site-packages', '/usr/lib/python2.3/site-packages/gtk-2.0'] >>>
Comments