[Tilecache] Basic Questions
Jeffrey Johnson
ortelius at gmail.com
Wed Sep 19 17:18:03 EDT 2007
Ok, Making progress here ;)
So, I modified Example.py to look like this.
------------------Example.py------------------
#!C:/Python25/python.exe -u
import glob
from TileCache.Service import Service, modPythonHandler, cgiHandler
from TileCache.Layer import Layer, MapServerLayer, WMSLayer, ImageLayer
from TileCache.Cache import DiskCache
layerList = {}
for file in glob.glob("c:\CrystalImages\*.jpg"):
parts=file.split("\\")
filename = parts[2]
fileparts = filename.split(".")
filenameprefix = fileparts[0]
layerList[filenameprefix] = ImageLayer(filenameprefix, file=file,
filebounds="0,0,2432,1835", bbox="0,0,2432,1835",
maxresolution="4",levels="3")
myService = Service (DiskCache("c:/tmp/tilecache"), layerList)
def handler (req):
return modPythonHandler(req, myService)
if __name__ == '__main__':
cgiHandler(myService
------------------End Example.py------------------
And the JS is simply hard-coded at the moment to one of the known
images in this dir
------------------snip from example.html------------------
<script type="text/javascript">
<!--
var map;
function init(){
map = new OpenLayers.Map( $('map'));
map.addLayer(new
OpenLayers.Layer.WMS("b000000012345_wA01-1_d20070829_t174940_i00_s2432_",
["http://localhost/cgi-bin/tilecache-1.8.1/Example.py?",
"http://localhost/cgi-bin/tilecache-1.8.1/Example.py?"],
{'layers':'b000000012345_wA01-1_d20070829_t174940_i00_s2432_'},
{maxResolution:4, numZoomLevels:3, maxExtent: new
OpenLayers.Bounds(0,0,2432,1835)}));
map.addLayer(test);
map.zoomToExtent(new OpenLayers.Bounds(0,0,2432,1835));
}
// -->
</script
------------------snip from example.html------------------
But again, I get pink empty tiles.
The error output is
An error occurred: couldn't calculate tile index for layer
b000000012345_wA01-1_d20070829_t174940_i00_s2432_ from ([0.0, 1024.0,
1024.0, 2048.0])
File "TileCache\Service.py", line 481, in cgiHandler
format, image = service.dispatchRequest( params, path_info,
req_method, host )
File "TileCache\Service.py", line 395, in dispatchRequest
tile = WMS(self).parse(params, path_info, host)
File "TileCache\Service.py", line 120, in parse
return self.getMap(param)
File "TileCache\Service.py", line 129, in getMap
% (layer.name, bbox))
So, it looks like somehow I need to specify the maxResolution and the
bbox in my Layer definition when I am setting up the layers, but I
think I have done this correctly. What am I missing here.
Also, is this going to be a serious performance bottleneck to dive
through this directory and setup the layers everytime the script
Example.py is called? Any alternatives?
Thanks again,
Jeff
On 9/19/07, Jeffrey Johnson <ortelius at gmail.com> wrote:
> On 9/18/07, Christopher Schmidt <crschmidt at metacarta.com> wrote:
> > On Tue, Sep 18, 2007 at 05:50:25PM -0700, Jeffrey Johnson wrote:
> > > > > so this works 'ok' ... when the page loads it is blank :(
> > > >
> > > > Call map.zoomToMaxExtent() to get the ball rolling.
> > >
> > > No change in behavior. Strage, zoomToMapExtent() gets called when I
> > > click the globe, but doesnt want to do it if I put this in the js
> > > code. Not a big deal for now, but strange.
> > >
> > > > > ... as soon
> > > > > as I drag around the tiles appear. There is a thick black border
> > > > > around the image but only on the top and right.
> > > >
> > > > I expect that, but I think there's a fix in TileCache for it. Maybe some
> > > > property you can set on the layer with regard to transparency. Yeah,
> > > > maybe setting 'transparency=True' on the ImageLayer config would do it.
> > >
> > > Ah, this may have something to do with the size of the tiles? I.e. TC
> > > is cutting tiles that have extra space in them and making them black?
> > > ... Putting transparency=true into the layer definition in
> > > tilecache.cfg doesnt have any affect. Do you mean in the layer
> > > definition in the js?
> >
> > No, I meant in TC: did you clear your cache after doing it?
> >
> > It does come down to the fact that if your image is not evenly divisible by
> > maxRes * 256, you'll get the black space -- and even if you get it right
> > in one direction, you'll usually be off in the other.
>
> Ok, toyed around with this a bit, and results are a bit better, but
> not perfect. Anyway, not a big deal, just wondered.
>
> > > > > Is there something simple I am doing wrong with the dimensions?
> > > >
> > > > What makes you think that you might be? Not sure I understand.
> > >
> > > The black borders on the top and right, the trouble with the zoom
> > > levels, and the problem with zoomToMaxExtent() not working. Just not
> > > used to working with non-spatial images ;)
> >
> > The black stuff is somewhat related - not wrong per se, just different
> > ;) If the transparent=true thing didn't work even after clearing the
> > cache, I should probably investigate why not.
>
> Still some of the tiles are coming out strangely. I attached some
> images for you to have a look at. These are off on the right side of
> the original image. The top one comes out ok, but the bottom has some
> weirdness in it. Anyway, again not a show-stopper at the moment.
>
> > > One more question ... if I want to use TileCache to tile up 10s of
> > > 1000s of images ... is there a way I setup the cfg file on the fly.
> > > Basically, when the camera snaps an image, i want to pre-cut the tiles
> > > with tilecache_seed.py. Could I do this all in js?
> >
> > No, you couldn't do this all in JS. There is an Example.py:
> >
> > http://svn.tilecache.org/trunk/tilecache/Example.py
> >
> > Which shows how you can write Python code to generate a service (Rather
> > than using service.load() from a config file), which would probably be
> > the right place to start.
>
> Forgive my ignorance here (not usually a serious python coder). I get
> this to work in the cgi-bin directory ... but it returns only
>
> <Services>
> <TileMapService version="1.0.0" href="http://localhostTEST/1.0.0/"/>
> </Services>
>
> I assume I have to pass some arguments to this? Is there any
> documentation floating around to show how to run this as a service. I
> 'could' just simply rewrite the config file every time a new image
> came in, and then dynamically generate the OL HTML page, but this
> seems silly. If you can just point me to some explanation of this kind
> of thing that would be great.
>
> Jeff
>
More information about the Tilecache
mailing list