[Mapserver-users] how to paste an image over the map image???

Paul Spencer spencer at dmsolutions.ca
Wed Feb 19 12:53:22 PST 2003


Actually, there is a pasteImage function in php_mapscript :)

In any case, I don't think that you can load an image from disk as you 
are trying to do.  One solution is to add the image to the symbol file

Symbol
Name 'compass'
Type PIXMAP
Image 'path_to_image.png'
END

then your code would look something like (not guaranteed to work ;)):


//$oMap is the mapscript map object
//$nX and $nY are the pixel position to draw the image

// create temp layer
$tmpLayer = ms_newLayerObj($oMap);
$tmpLayer->set("name", "temp_layer");
$tmpLayer->set("type", MS_LAYER_POINT);
$tmpLayer->set("status", MS_OFF);
$tmpLayer->set("transform", MS_FALSE);
$tmpLayer->set("labelitem", "test_label");
$tmpLayer->set("labelcache", MS_OFF);
$tmpClass = ms_newClassObj($tmpLayer);

//add colour to palette - this changes in MS3.7
$nColor = $oMap->addColor(0,0,0);

$nLogo = 16; //index of the symbol in the symbol file

//set class properties
$tmpClass->set("color" , $nColor );
$tmpClass->set("size" , 1 );
$tmpClass->set("symbol" ,$nLogo );

// create new point object
$oPoint = ms_newPointObj();

//position
$oPoint->setXY($xPos,$yPos);

//the map image to draw on
$oImage = $oMap->draw();

// draw the point onto the map
$oPoint->draw($oMap, $tmpLayer, $oImage, 0,"");

$oImage->saveWebImage(...);

Cheers,

Paul

Sean Gillies wrote:
> 
> On Wednesday, February 19, 2003, at 10:22  AM, Andres Garcia wrote:
> 
>> Hi!!
>>
>> I need to paste an image (a compass) over the map image:
>>
>> $compass = $mapa->prepareImage();
>> $compass->image_path = "/ms_tmp/";
>> $compass->image_url = "rosa_vientos.png";
>> $compass->saveWebImage($format,0,0,-1);
>> $image->pasteImage($compass,-1,0,0);
>>
>> $image_url = $image->saveWebImage($formato,0,0,-1);
>>
>> I tried with that code with out success. Can somebody tell me wich is 
>> the rigth way to paste an image over the image object that is 
>> generated by mapserver???
>>
>> thanks in advance
>>
>> Andress Garcia
>>
>>
> Andres,
> 
> There is no 'pasteImage' method in MapScript.
> 
> If you want to do post-MapServer image processing, you should look
> into using Perl ImageMagick or GD modules.  These modules will let
> you do what you want and much more.  Do a search on the
> web, check their user list archives, and you'll soon come up with
> some great tips on how you can overlay images.
> 
> cheers,
> Sean
> 
> -- 
> Sean Gillies
> sgillies at frii.com
> http://www.frii.com/~sgillies
> 
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> 

-- 
Paul Spencer
Applications and Software Development
DM Solutions Group Inc.
http://www.dmsolutions.ca





More information about the MapServer-users mailing list