[Tilecache] getting different srs/projections to work
david creane
dc at openapp.ie
Tue Sep 25 12:53:48 EDT 2007
sry wondering if anyone can help me here, the following code works for me, it
overlays an image of ireland thats coming from my wms server, onto the world
map coming from http://labs.metacarta.com/wms/vmap0 using tilecache in
between.
index.html ....
<script src="../openlayers/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var lon = -7.5;
var lat = 53.44;
var zoom = 6;
var map, layer;
var bounds = new OpenLayers.Bounds(-10.6, 51.33 ,-5.33, 55.4)
var mapOptions = {
numZoomLevels: 7,
//maxExtent: bounds,
};
var baseOptions = {
isBaseLayer: true,
};
var baseParams = {
layers: 'basic',
format: 'image/png'
};
var eireOptions = {
isBaseLayer: false
};
var eireParams = {
layers: 'eire',
format: 'image/png',
};
function init(){
map = new OpenLayers.Map( $('map'), {}, mapOptions);
blayer = new OpenLayers.Layer.WMS( "World", "tilecache.cgi?",
baseParams, baseOptions );
map.addLayer(blayer);
elayer = new OpenLayers.Layer.WMS( "Eire", "tilecache.cgi?",
eireParams, eireOptions );
map.addLayer(elayer);
map.addControl(new OpenLayers.Control.Permalink());
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
map.addControl( new OpenLayers.Control.LayerSwitcher() );
}
// -->
</script>
tilecache.cfg ....
[cache]
type=DiskCache
base=/tmp/tilecache
[basic]
type=WMSLayer
url=http://labs.metacarta.com/wms/vmap0
extension=png
[eire]
type=WMSLayer
url=http://localhost:8090/hai2/workspaces/siteworks/exploremaps/default/query
/testeeee300/@@wms?transparent=true extension=png
layers=eire
Now the next thing i wanted to do was to just output the ireland map using a
different projection/srs. Now the srs i want is 29900,
http://spatialreference.org/ref/epsg/29900/ . Im not sure how to get it to
work though. I know to change the projection you need to add the new srs,
maxextent and either the maxResolution or a set of resolutions.
I have tried many different combinations but most of the time i end up with
pink squares. Can anyone answer some of these questions, or be able to tell
me the correct figures.
1) For ireland/29900 it says on http://spatialreference.org/ref/epsg/29900/
that the bounds are -10.6 51.33 -5.33 55.4, but these are degrees ??, and i
want to set the units to meters, or am i wrong ??. So what do i set the
maxextent to in the mapOptions variable.
2) Maxresolution is based on some calculation on the bounds divided by the
the tile size (256 default) ???. Can someone tell what exactly is the
calculation??
3) Im unsure what variable need to be passed to openlayers and what need to
be in the tilecache config. For example is the maxresolution the same value
in layer in tilecache.cfg as the value passed to openlayers in javascript,
as have read contradicting info on this. Do i need to pass what units i am
using to tilecache.cfg. Do i need to set the levels variable in
tilecache.cfg.
Any help would be appreciated.
Thanks
David
More information about the Tilecache
mailing list