[ka-Map-users] tiling print service (WMS)
Paul Spencer
pspencer at dmsolutions.ca
Wed May 10 10:37:51 EDT 2006
Bart,
to get back to the original question, I believe that you don't really
need ka-Map for this, just a custom php script.
I would imagine that there would need to be an intermediate step that
takes the request and parses the WMS parts out, then generates either
cgi,mapscript,or wms requests for each needed sub-image, then
combines them into a single image and then return it to the client.
The general logic (for a mapscript version) would be something like
this I would think:
<?
$aBBox = explode(',', $_GET['BBOX']);
$width = $_GET['WIDTH'];
$height = $_GET['HEIGHT'];
//assume square pixels?
$cellSize = $width/($aBBox[2]-$aBBox[0]);
//limit the size of a single map draw
$mapWidth = 1000;
$mapHeight = 1000;
//map draws are this much more in all dimensions
$buffer = 10;
$geoBuffer = $buffer * $cellSize;
$cols = ceil($width/$mapWidth);
$rows = ceil($height/$mapHeight);
$oMap = ms_newMapObj(MAPFILE);
//prevent labels from drawing too close to the edge
$oMap->setMetadata("labelcache_map_edge_buffer", -(2*$buffer);
$oMap->set('width', $mapWidth + 2 * $buffer); //alternately you could
read this and set $mapWidth
$oMap->set('height', $mapHeight + 2 * $buffer); //alternately you
could read this and set $mapHeight
//need to handle LAYERS, SRS etc also
$image = imagecreate($width,$height); //or imagecreatetruecolor
for ($i=0; $i<$cols; $i++) {
for ($j=0; $j<$rows; $j++) {
$minx = $aBBox[0] + $i * $mapWidth * $cellSize - $geoBuffer;
$maxy = $aBBox[3] - $j * $mapHeight * $cellSize + $geoBuffer;
$maxx = min($minx + $mapWidth*$cellSize + $geoBuffer, $aBBox[2]
+ $geoBuffer);
$miny = max($maxy - $mapHeight$cellSize - $geoBuffer, $aBBox[1]-
$geoBuffer);
$oMap->setextent($minx, $miny, $maxx, $maxy);
$oImg = $oMap->draw();
$tmpImgName = tempnam('/tmp/', 'tile').'png'; //fix to use right
extension?
$oImg->save($tmpImgName);
$oImg->free()
$gdImg = imagecreatefrompng($tmpImgName);
imagecopy( $image, $gdImg, $i*$mapWidth, $j*$mapHeight, $buffer,
$buffer, $mapWidth, $mapHeight );
imagedestroy($gdImg);
}
}
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>
Obviously you'd want to make the url params case insensitive etc.
Instead of using php/mapscript to create the images, you could also
just pass the extents on to another WMS or to a cgi.
Cheers
Paul
On 10-May-06, at 10:05 AM, Bart van den Eijnden (OSGIS) wrote:
> Hi Ed,
>
> we did a quick test, 10k x 10k pixels did not finish on our machine
> with
> 1.5 Gb and 500 Mb swap. In the end Mapserver had 1700 Mb in memory,
> but
> crashed with an itnernal server error when the swap was full.
>
> How much RAM do you use in your servers for this kind of task? And
> what
> kind of pixel width/height limit do you use?
>
> Thanks in advance.
>
> Best regards,
> Bart
>
>> Bart -
>>
>> RAM is cheap <g>. Seriously, although it depends a lot on the
>> machine
>> you're installing it in, that much memory (1GB) for many systems runs
>> about USD $100. And depending on the usage level, you might just let
>> the system swap and use virtual memory for the task.
>>
>> - Ed
>>
>> Ed McNierney
>> President and Chief Mapmaker
>> TopoZone.com / Maps a la carte, Inc.
>> 73 Princeton Street, Suite 305
>> North Chelmsford, MA 01863
>> ed at topozone.com
>> (978) 251-4242
>>
>> -----Original Message-----
>> From: ka-map-users-bounces at lists.maptools.org
>> [mailto:ka-map-users-bounces at lists.maptools.org] On Behalf Of Bart
>> van
>> den Eijnden (OSGIS)
>> Sent: Wednesday, May 10, 2006 8:12 AM
>> To: ka-map-users at lists.maptools.org
>> Subject: RE: [ka-Map-users] tiling print service (WMS)
>>
>> Hi Ed,
>>
>> but won't that consume too much memory?
>>
>> For generating a 15.000 x 15.000 pixels PNG24 image Mapserver
>> would take
>> about 900 Mb into memory or not?
>>
>> Best regards,
>> Bart
>>
>>> Bart -
>>>
>>> I'm not aware that a 2048x2048 pixel limit is "normal" for WMS
>> servers.
>>> That's the default limit for MapServer but it is very easily
>>> changed.
>>> I've done that for several years and produce very large images from
>>> single MapServer WMS requests.
>>>
>>> - Ed
>>>
>>> Ed McNierney
>>> President and Chief Mapmaker
>>> TopoZone.com / Maps a la carte, Inc.
>>> 73 Princeton Street, Suite 305
>>> North Chelmsford, MA 01863
>>> Phone: +1 (978) 251-4242
>>> Fax: +1 (978) 251-1396
>>> ed at topozone.com
>>>
>>> -----Original Message-----
>>> From: ka-map-users-bounces at lists.maptools.org
>>> [mailto:ka-map-users-bounces at lists.maptools.org] On Behalf Of
>>> Bart van
>>
>>> den Eijnden (OSGIS)
>>> Sent: Wednesday, May 10, 2006 7:52 AM
>>> To: ka-map-users at lists.maptools.org
>>> Subject: [ka-Map-users] tiling print service (WMS)
>>>
>>> Hi list,
>>>
>>> can the ka-map tiling logic be used to create a WMS print service?
>>>
>>> Imagine our use case, people wanting to print on A0 paper from
>>> ArcGIS,
>>
>>> and ArcGIS has a WMS layer for aerial photographs in it. Ofcourse
>>> normal WMS services limit themselves to 2048x2048 pixels like
>> Mapserver does.
>>> But ArcGIS requests an image of about 15000 pixels wide.
>>>
>>> If a tiling php script could act as WMS service, and would ask for
>>> 2048x2048 tiles to the aerial photograph WMS, and stream that
>>> back to
>>> the client (ArcGIS), it could be a solution. Could ka-map be used
>>> for
>>> this?
>>> Would it be a lot of work?
>>>
>>> Also, is it possible to stream back the whole 15000x15000 pixels
>>> image
>>
>>> without taking the whole thing in memory? I.e. could the script read
>>> up the tiles from disk and stream them sequentially into 1 image?
>>>
>>> Thanks in advance for some thoughts on this.
>>>
>>> Best regards,
>>> Bart
>>>
>>> _______________________________________________
>>> ka-Map-users mailing list
>>> ka-Map-users at lists.maptools.org
>>> http://lists.maptools.org/mailman/listinfo/ka-map-users
>>>
>>>
>>
>>
>>
>> _______________________________________________
>> ka-Map-users mailing list
>> ka-Map-users at lists.maptools.org
>> http://lists.maptools.org/mailman/listinfo/ka-map-users
>>
>>
>
>
> _______________________________________________
> ka-Map-users mailing list
> ka-Map-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/ka-map-users
+-----------------------------------------------------------------+
|Paul Spencer pspencer at dmsolutions.ca |
+-----------------------------------------------------------------+
|Applications & Software Development |
|DM Solutions Group Inc http://www.dmsolutions.ca/|
+-----------------------------------------------------------------+
More information about the ka-Map-users
mailing list