Dynamic map annotation in animated GIF file
Steve Lime
Steve.Lime at DNR.STATE.MN.US
Wed Jul 11 21:42:49 PDT 2007
Robert: I think I would approach this slightly differently using a layer definition like:
LAYER
NAME 'copyright'
TYPE ANNOTATION
STATUS OFF
FEATURE
POINTS ... END
END
CLASS
LABEL ... END
TEXT 'Image Date Goes Here'
END
END
Then in the script you'd use the classObj setText() method to alter the timestamp. Essentially the TEXT property allows you to set a text constant that is applied to all features. In this case it's only one. I think you'll find it's a bit more straight forward.
Steve
>>> "Burgholzer,Robert" <rwburgholzer at DEQ.VIRGINIA.GOV> 07/11/07 9:04 AM >>>
Julien,
Thanks for your suggestions. I am close, although the points are not
being rendered. They return a "MS_SUCCESS", however, it does not show on
the map. I have tried many possibilities, but am thus far unable to get
success.
r.b.
-----Original Message-----
From: Julien-Samuel Lacroix [mailto:jlacroix at mapgears.com]
Sent: Monday, July 09, 2007 8:32 PM
To: Burgholzer,Robert
Cc: MAPSERVER-USERS at LISTS.UMN.EDU
Subject: Re: [UMN_MAPSERVER-USERS] Dynamic map annotation in animated
GIF file
Hi,
You are right. PHP/MapScript doesn't provide the TEXT portion of an
annotation feature. It's because it's easier to add directly a point on
the top of the map. Instead of adding a FEATURE object to the layer,
simply create a point object and draw it on the map image.
(Following code not tested)
// Outside the loop create a pointObj
$oPoint = ms_newPointObj();
$oPoint->setXY(1,1);
[...snipp...]
// Inside the foreach, draw your map without the copyright layer
$thislayer->set("status",MS_OFF);
$image[$i] = $amap->map->draw();
// Then draw the point on the top of it
// Don't forget to remove the FEATURE object in the mapfile
// Also you should give a name to your class in the copyright layer
// For now, I'll use "CLASSNAME"
$thislayer->set("status",MS_ON);
$oPoint->draw($amap->map, $thislayer, $image[$i], "CLASSNAME",
$filter);
$image_url[$i] = $image[$i]->saveWebImage(MS_GIF,1,1,0);
[...snip...]
The code is not tested, but it should give you a good idea.
Julien
Burgholzer,Robert wrote:
> I am trying to produce a time series animated GIF, with an annotation
at
> the bottom of the map that shows the time. Thanks to an example from
> Charlton Purvis found by a search of previous postings on making an
> animated GIF (modified to use a single layer, changing the filter to
> select for the data that is in my current time step):
>
>
http://mapserver.gis.umn.edu/data2/wilma/mapserver-users/0304/msg00482.h
tml
>
>
>
> And a Wiki entry from Jeff McKenna about making a copyright notation:
>
> http://mapserver.gis.umn.edu/docs/faq/copyright-layer
>
>
>
> I have the basics, that is, an animated time series, with a statically
> placed text entry at the bottom (at a map-specific point, rather than
a
> lat lon). However, the annotation layer can only display a single
> entry, not one that is updated with the time step. I am wondering how
> to do this, if I can modify the property of the annotation layer, or
if
> I need to create a point of some sort from a dynamic postgis call. I
> can't seem to set the TEXT portion of the feature via php mapscript.
>
>
>
> Anyone have any ideas? (code and mapfile follow)
>
>
>
> foreach ($gifmaps as $thismap) {
>
> $thislayer = $amap->map->getLayerByName('stream_stat');
>
> $filter = " projectid = $projectid and thismetric = '$thismap' ";
>
> $listobject->querystring = " select count(*) as numrecs from
> proj_group_stat ";
>
> $listobject->querystring .= " where $filter ";
>
> $listobject->performQuery();
>
> $numrecs = $listobject->getRecordValue(1,'numrecs');
>
> #$annotlayer = $amap->map->getLayerByName('copyright');
>
> #$annotation = $annotlayer->getFeature(1,-1);
>
> if ($numrecs > 0) {
>
> $thislayer->setFilter($filter);
>
> $thislayer->set("status",MS_ON);
>
> #$annotation->set("TEXT", $filter);
>
> $image[$i] = $amap->map->draw();
>
> $image_url[$i] = $image[$i]->saveWebImage(MS_GIF,1,1,0);
>
> $file_path[$i] = $amap->map->web->imagepath
>
> . substr(strrchr($image_url[$i], "/"),1);
>
> $anim_files = $anim_files . '"' . $file_path[$i] . '"' . " ";
>
> $i++;
>
> print(" Adding <i>$filter</i>, $image_url[$i] <br>");
>
> }
>
> }
>
>
>
> // Create a unique filename and URL for the animated GIF output
>
> $anim_name = "anim".substr(strrchr($image_url[1], '/'),1);
>
> $anim_path = '"' . $amap->map->web->imagepath . $anim_name .'"';
>
> $anim_url = $amap->map->web->imageurl . $anim_name;
>
>
>
> print("Creating $anim_path <br>");
>
> $cmd = $anim_gif_cmd . " -o " . $anim_path . " " . $anim_files;
>
> print("Using: $cmd <br>");
>
>
>
> system($cmd);
>
>
>
> # annotation layer
>
> LAYER
>
> NAME copyright
>
> STATUS ON
>
> TYPE annotation
>
> TRANSFORM false
>
> FEATURE
>
> POINTS
>
> 150 180 #this is the position of the text in image coordinates
> (pixels)
>
> END
>
> TEXT "From 2007/01/01 to 2007/06/30" #this is your displaying text
>
> END
>
> CLASS
>
> LABEL #defines the font, colors etc. of the text
>
> FONT "arial"
>
> TYPE TRUETYPE
>
> SIZE 10
>
> BUFFER 1
>
> COLOR 0 0 0
>
> BACKGROUNDCOLOR 255 255 255
>
> FORCE TRUE
>
> END
>
> END
>
> END
>
> Robert W. Burgholzer
>
> Surface Water Modeler
>
> Office of Water Supply and Planning
>
> Virginia Department of Environmental Quality
>
> rwburgholzer at deq.virginia.gov <mailto:rwburgholzer at deq.virginia.gov>
>
> 804-698-4405
>
> Open Source Modeling Tools:
>
> http://sourceforge.net/projects/npsource/
>
>
>
--
Julien-Samuel Lacroix
Mapgears
http://www.mapgears.com/
More information about the MapServer-users
mailing list