Archive

Archive for the ‘mapserver’ Category

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: <4564D326.6020607@refractions.net>
References: <4564D326.6020607@refractions.net>
Message-ID: <20061122225429.GA18180@metacarta.com>
 
On Wed, Nov 22, 2006 at 02:45:58PM -0800, Ben Brehmer wrote:
> Hello everyone,
>
> I have setup a basic OpenLayers application with TileCache doing the
> server-side caching. I was wondering if there is a way to pre-cache all
> the tiles (besides panning/zooming everywhere on the map)? I know in
> kamap there is a script that can be run to pre-cache all the tiles. Is
> 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.
 
> Also, I have attached two jpegs. Each has part of a symbol or label
> chopped off. I believe that the "chopping" occurs at the edge of a tile.
> 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″

Installing MS4W, Python2.4, ColdFusion6.1

January 17th, 2007 rupert Comments off

For Windows:

A. Installing MS4W
1. Download ms4w2.2 from maptools.org

2. Extract ms4w2.2 into your root drive (E:\)

3. Run E:\ms4w\apache-install.bat. This would install apache2.2 as a service.

4. Edit E:\ms4w\Apache\conf\httpd.conf to reflect your webroot in “DocumentRoot” (E:\wwwroot\)

149 DocumentRoot "/wwwroot"
...
....
177 <directory>
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks
 
    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None
 
    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all
205 </directory>
....
....
212 DirectoryIndex index.html index.html.var index.php index.phtml index.php3 index.cfm
....
....

5. Test apache, navigate to “http://127.0.0.1/”.

B. Configuring Apache2.2 with ColdFusion6.1
6. Since Apache2.2 was released after CF6.1 and CF7.0 then, it would only bind with Apache2.0.x. We need a new wsconfig.jar that would bind with Apache2.2.x. Read more about the technote:
http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=8001e97

Alternatively, you could download wsconfig.jar from http://www.adobe.com/support/coldfusion/ts/documents/8001e97/wsconfig.zip

7. Backup your existing wsconfig.jar to wsconfig.jar.bak. Replace the wsconfig.jar.

8. Restart ColdFusion.

9. Remove existing connectors from D:\CFusionMX\bin\connectors\Remove_ALL_connectors.bat

10. Execute D:\CFusionMX\bin\connectors\Apache_connector.bat

@echo off
echo WARNING!  This will install the ColdFusion MX Apache Connector.
echo Press Control+C to abort.
pause
SETLOCAL
PATH=..\..\runtime\jre\bin;%PATH%
java -jar ..\..\runtime\lib\wsconfig.jar  -ws apache -bin "e:\\ms4w\Apache\bin\httpd.exe" -dir "e:\\ms4w\apache\conf" -map .cfm,.cfc,.cfml -coldfusion -v
ENDLOCAL

11. Restart Apache and ColdFusion. Browse to http://127.0.0.1/cfide/administrator/index.cfm

C. Installing Python2.4
1. Read Reference document from maptools.org install site

2. Download Python2.4 from http://www.python.org/ftp/python/2.4/python-2.4.msi. Download mod_python from mod_python-3.3.0b.win32-py2.4-Apache2.2.exe

3. Install Python2.4 in your root drive. (D:\)

4. Install mod_python-3.3.0b.win32-py2.4-Apache2.2.exe

5. Edit your Windows Environment Variables (System Variable: PATH) to include “D:\Python23″

6. Edit E:\ms4w\Apache\conf\httpd.conf

#For Python
LoadModule python_module modules/mod_python.so
 
<directory>
	AddHandler python-program .py
	PythonHandler test
	PythonDebug On
</directory>
 
ScriptInterpreterSource Registry
SetEnv PYTHONUNBUFFERED 1
PassEnv PYTHONPATH

7. Restart Apache and test from http://127.0.0.1/pytest/test.py. If you see a “Hello World” web page from python then you are good to go. Sample python test page “test.py”:
E:\wwwroot\pytest\test.py

from mod_python import apache
 
def handler(req):
	req.content_type = 'text/plain'
	req.write("Hello World!")
	return apache.OK
Categories: mapserver, ms4w Tags: , ,