I just uploaded the first cut of my Tile Cache Seeder to the Mapguide wiki.
It uses Openlayers and basically will pan and scan over your entire map, thus
seeding the tile cache. It can also be used with any tiled map accessible via Openlayers.
I did try using the Facilities Map Tiling Engine but it was difficult
to get working and wouldn't work with a remote server without playing around with a
firewall, whereas, this pure client side solution just works :)
http://trac.osgeo.org/mapguide/wiki/CodeSamples/Tiles/TileCacheSeeding
Saturday, July 19, 2008
Mapguide Tile Cache Seeder
Labels:
javascript,
mapguide
27 comments:
Dear Zac:
Your implementation is great. However, i found difficulties trying to seed tiles numbered with negative values (negative numbers in row and/or col ID).
I´ve tried using a buffer in options, and also displayoutsidemaxextent option, but didn´t work as expected.
Problem seems to be that seeder can´t "ask" for tiles lesser than 0.
Feel free to try my implementation and see my code at ( http://sig.se.gov.ar/gis/seeder/ )
Thanks for sharing your knowledge.
Ramiro
( http://sig.se.gov.ar )
Hi Ramiro,
It might be a problem with the openlayers implementation underneath... I'll ping Mike Adair with this..
Just to be clear, I diff'ed your code and you have only modified the map parameters and window sizes right?
z
Do you get an javascript error when you click the centre button? I can't chekc now as server keeps dropping out...
I think the map extents might be in the wrong order
Dear Zac.
I didn´t find any javascript errors, i´ve tested with firebug.
As You´ve said, my version is just your code pointing to my server.
Maybe OpenLayers is part of the problem. I couldn´t make it work with my "negative number" tiles.
Thanks again for your time.
Ramiro
Yep, I think there's definitely a problem with openlayers here.
the javascript error was something else
I'm not sure what the issue is here. There shouldn't be negative tile numbers for mapguide, which start at 0,0 in the upper left corner of the extent and increase from there to the bottom right (it shouldn't matter if the coords are negative) and the bounds look ok to me.
The r_extent bounds look suspicious though. Maybe try setting that to be equal to the map bounds?
One Javascript error I found was that 'extent' needs to be set as a global for the goCenter method.
Mike Adair
Hi Zac:
Is it possible to specify the bounds with a local coordinatesystem?
I have tried to transform my coordinates to latlong and then specify in the html-file but I just can't get it right.
Thanks for sharing.
Stefan
Dear Zach,
i'm trying to use your "Mapguide Tile Cache Seeder" code, but i can't make it work.
So i would ask if yuo can tell me what are the parameters to set and if it is necessary the map to be exposed as a WMS service or not.
Thanks
Davide
The tile cache seeder is basically an openlayers scan and pan application. It was designed to work with mapguide tiled maps, but it will work with any openlayers supported layer type.
Just remember, only tiled maps are the cached mapguide, WMS isn't cached...
There are some links here on getting mapguide to work with openlayers
So i've changed the url variable
(-- url="http://localhost:8008/mapguide/mapagent/mapagent.fcgi?USERNAME=Anonymous&"; --) with mine.
Then i've modified the value of mapdefinition and basemaplayergroupname (--mapdefinition: 'Library://vicmap/maps/tiled.MapDefinition',
57 basemaplayergroupname: "base layers" --).
can i change also "var extent" to make the code work with geographic coordinates instead of lat/long degree?
There's something else i must do to set the code, because actually when i open the page with the script the map doesn't display!
Thanks
Davide
Here's a php script which will setup up things for openlayers and mapguide
http://trac.osgeo.org/mapguide/wiki/CodeSamples/JavaScript/OpenlayersExample
I tried your PHP example but I get this error "Openlayers Mapguide tiled and untiled map, with map as layer Demo.
Setting OpenLayers.INCHES_PER_UNIT is required for tiled maps co-ordindates to be correct, plus this patch Zac Spitzer".
Have I to set these variables?
- OpenLayers.INCHES_PER_UNIT["dd"]
- OpenLayers.INCHES_PER_UNIT["degree"]
Thanks.
Davide
I have updated the sample to point to the production openlayers public url, it was pointing to my local host name.
I've update the code also with this changes, but it still doesn't work.
i get http 500 error and i don't know why!!
Maybe you can tell me if a .NET example, similar to the one you give previously, exists.
Thanks a lot, i know i'm going to make you crazy.
Davide
Try turning on php errors
http://au.php.net/manual/en/errorfunc.configuration.php#ini.display-errors
Also, the MapGuide documentation which is installed locally with mapguide is chock full of samples in both C# and php
I used the samples for create my sample
HI ZAC,
with your help i was able to make the script work.
Now i've got a last problem...
What is the right way to set the coordinates system?
Usually my maps use Gauss Boaga Italy coordinates system.
Thanks a lot.
Davide
Hey Zac.
I'm finding that at the smaller scales (many tiles) that Firefox often is extremely slow, and eventually just quits. No errors, just stops producing tiles.
Chrome on the other hand smokes, but eventually crashes.
Any thoughts or similar experiences?
Lower scales often are just much slower to render?
Is it mapguide's performance playing a role there?
I haven't had any problems with Firefox, were you doing the randomise option. It's a pretty inefficent quick hack in there.
Normally panning and scanning is fine however
Hi Zac.
No, I'm using Pan and Scan. I'm sure Mapguide is playing a role, but interestingly enough, switching to IE help (Gosh I hate saying that!) IE hasn't crashed or frozen
try firefox with addons disable via safe mode
Zac.
I'm trying to implement your code samples with the Tile Seeding and http://trac.osgeo.org/mapguide/wiki/CodeSamples/JavaScript/OpenlayersExample OpenLayers Example.
I can't seem to find the "correct" MapGuide.js to place the patch or even the "corrected" version of the MapGuide.js to download.
I'm using the MapGuide Open Source server 2.1 stable release.
I just uploaded a mg-openlayers.js file to the wiki, it's a bit old but it works
I was actually referring to the patch that is needed. Where do I apply this, that is in what Mapguide.js file ?
http://trac.openlayers.org/ticket/1676
the patch has since been integrated into openlayers, just use openlayers
Hi Zac,
i have a question about mapguide tile cache folder structure.
i wanted to know how does mapguide organize the tiles in the repository?
my guess was that it first divides the X,Y by 30 and name the folders by them and name the tile by the mod of the index to 30, for example tile with the index of 35,65 will store in "3/6/5_6.png", but it doesn't work.
i would be so appreciate if you help me in this case. i am in a hurry for it.
have a look at the
Openlayers support for MapGuide, there is an implementation of the tile logic
also, a have look thru the Mapguide-Internals mailing list archives, this has been discussed mulitple times
tnx a lot dear Zac!
Mohammad
Post a Comment