Archive

Posts Tagged ‘tilecache’

Using TileCache, OpenLayers, Mapserver for Projection 900913

April 8th, 2008 rupert Comments off

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…

  1. Classic Resolutions problem. Use extent_type=loose
  2. 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. Read more…

Installing TileCache on RedHat/CentOS

July 25th, 2007 rupert Comments off

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

TileCache Experiment

February 16th, 2007 rupert Comments off

I am now able to do tilecache using TileCache1.3 from metacarta. Base from archives (archive-user.txt)

From crschmidt at metacarta.com  Wed Nov 22 17:54:29 2006
From: crschmidt at metacarta.com (Christopher Schmidt)
Date: Wed, 22 Nov 2006 17:54:29 -0500
Subject: [OpenLayers-Users] TileCache - Tiling issues
In-Reply-To: &lt;4564D326.6020607@refractions.net&gt;
References: &lt;4564D326.6020607@refractions.net&gt;
Message-ID: &lt;20061122225429.GA18180@metacarta.com&gt;
 
On Wed, Nov 22, 2006 at 02:45:58PM -0800, Ben Brehmer wrote:
&gt; Hello everyone,
&gt;
&gt; I have setup a basic OpenLayers application with TileCache doing the
&gt; server-side caching. I was wondering if there is a way to pre-cache all
&gt; the tiles (besides panning/zooming everywhere on the map)? I know in
&gt; kamap there is a script that can be run to pre-cache all the tiles. Is
&gt; there something similair for TileCache?
 
In the TileCache directory, there is a 'Client.py' script. To pre-cache
your data, use it in the following manner:
 
python Client.py "http://example.com/tilecachelocation/tilecache.cgi?"
"layername" startzoomlevel endzoomlevel [BBOX]
 
Something like:
 
python Client.py "http://labs.metacarta.com/wms-c/Basic.py?" "basic" 0 16
 
Is what we used to precache all of the Vmap0 data in the MetaCarta VMap0
layer.
 
&gt; Also, I have attached two jpegs. Each has part of a symbol or label
&gt; chopped off. I believe that the "chopping" occurs at the edge of a tile.
&gt; Has anyone ever experience something like this in OpenLayers?
 
This is based on your Mapserver setup, rather than something specific in
OpenLayers. Using WMS would result in the same visual result. Labels can
have this prevented using the "PARTIALS OFF" on your label layer, if
you're using Mapserver. I'm not aware of a way to prevent this in symbol
generation. 
 
We are currently working on ka-map style rendering to add to TileCache,
to help people not run into this issue. No timeframe available yet on
when that'll be released. 
 
Regards,
--
Christopher Schmidt
MetaCarta

1. TileCache Configuration: tilecache.cfg

[cache]
type=DiskCache
base=E:\\usr\\local\\apache2\\htdocs\\tmp\\
 
[basemap]
type=WMSLayer
url=http://127.0.0.1/cgi-bin/mapserv.exe?map=/home/basemap/wmstest_longlat.map
layers=district,greens,major_river,minor_river
extension=png
 
[roads]
type=WMSLayer
url=http://127.0.0.1/cgi-bin/mapserv.exe?map=/home/basemap/wmstest_longlat.map
layers=road4,road4label,road3,road3label,road2,road2label,road1,road1label,road11,road11label
extension=png

2. Calling CFM Script: Test.cfm

    <cfset request.mapserv="http://127.0.0.1/tilecache/tilecache.py"> 
 
    <script src="/OpenLayers-2.2/lib/OpenLayers.js"></script>
    <script type="text/javascript"></script>
        <!--<br /-->        //var lon = 116.3842;
        //var lat = 39.9150;
        var lon = 116.3846;
        var lat = 39.9202;
        var zoom = 16;
        var map, markers;
 
        function init(){
      	    map = new OpenLayers.Map( $('map'), { maxResolution: 'auto'});
 
	    var layer_base = new OpenLayers.Layer.WMS(
					"Base Layer",
					"#request.mapserv#",
					{
						layers: 'basemap',
						format: 'png', 'transparent': 'off'
					}
					);
 
                map.addLayer(layer_base);
	   layer_base.setIsBaseLayer(true);	
 
               ...more code here...
 
       }
</cfset>

I want to fine tune this script since I am getting odd tiles like duplicate tiles or tiles shown of different scale on the same scale.

3. Precaching:
/d/Python24/python.exe Client.py “http://127.0.0.1/tilecache/tilecache.py” “roads” 14 16 116.35397,39.88984,116.42988,39.91918

I need to understand the “cache hit” or “cache miss” during execution.

Categories: mapserver, tilecache Tags: ,

TileCache for Windows Revisited

January 17th, 2007 rupert Comments off

1. Downloaded TileCache1.8 from http://www.tilecache.org/

2. Get the current releases of python and mod_python.
http://www.python.org/download/releases/2.5/

http://httpd.apache.org/modules/python-download.cgi -> click on win32 binaries. Get the mod_python-3.3.1.win32-py2.5-Apache2.2.exe if your Apache is running on 2.2.

http://www.pythonware.com/products/pil/

http://effbot.org/downloads/PIL-1.1.6.win32-py2.5.exe

3. Install python2.5

4. Install mod_python and python_imaging.

5. Edit httpd.conf

LoadModule python_module modules/mod_python.so
 
<directory>
AddHandler python-program .py
PythonHandler test
PythonDebug On
</directory>
 
<directory>
	AddHandler python-program .py .cgi
	PythonHandler TileCache.Service
	PythonOption TileCacheConfig /wwwroot/tilecache/tilecache.cfg
	PythonDebug On
</directory>
 
ScriptInterpreterSource Registry
SetEnv PYTHONUNBUFFERED 1
PassEnv PYTHONPATH

6. run regedit. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.4\PythonPath. Append “E:\wwwroot\tilecache” to PYTHONPATH

D:\Python24\Lib;D:\Python24\DLLs;D:\Python24\Lib\lib-tk;E:\wwwroot\tilecache;

7. Put D:\Python24 in your WINDOWS PATH

8. Test if apache could read python by http://127.0.0.1/pytest/test.py

9. http://127.0.0.1/tilecache/test1.cfm

10. tilecache_seed.py “http://127.0.0.1/tilecache/tilecache.py” roads 12 17 “116.28229,39.85291,116.48657,39.98783″