[mapserver-users] Re: [Fwd: Re: tcl / mapserver]
Tom Poindexter
tpoindex at nyx.net
Thu Feb 28 12:30:19 PST 2002
The best examples I have are in MapServer Workbench (msworkbench.sf.net).
I haven't had time to fully update this code for MapServer 3.5 yet, but
it's high on my todo list. The code that's available is for MapServer 3.4.
Of the four programs in the Workbench, msexplorer.tcl probably does the
most - it opens a mapfile, renders images, queries points; msshapex.tcl
does some manipulation with shapefiles. Review the source code to
these programs for ideas on how to program Mapscript/Tcl.
The tiny example Tcl program in
mapserver_3.5/mapscript/tcl/examples/shpinfo.tcl
illustrates how the Mapscript objects are used:
mapscript::shapefileObj shp1 $file -1
^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ^^^^^^^^^^^^^
object constructor object constructor
name arguments
# shp1 will be a Mapscript shapefile object
then, invoke methods on the object:
puts "\tnumber of features: [shp1 cget -numshapes]"
^^^^ ^^^^ ^^^^^^^^^^
obj method arguments
In this case, the 'cget' method returns object member data.
Some return values you would get are pointers to other objects. I build
some 'helper' procs to easily deal with them (in effect, it's like
'casting' the pointer to a certain object type):
set rectPtr [shp1 cget -bounds]
#rectPtr is a pointer to an object
puts "\tbounds: ([mapscript::rectObjRef $rectPtr cget -minx] ...."
# 'cast' the pointer as a rectObj, and invoke the cget method
SWIG actually provides a constructor to turn an object pointer (like rectPtr)
into a bona-fide object, but in many cases you just want access to the
object in order to access some memeber data, so why bother. Plus if you
do instantiate an object reference, you'll need to manually delete it
after you're finished with it.
The SWIG generated doc file is fairly terse, but does give an idea of
what methods and member data is available for each mapfile object.
Good luck,
Tom
On Thu, Feb 28, 2002 at 11:41:33AM -0800, Drew wrote:
>
>
> -------- Original Message --------
> Subject: Re: tcl / mapserver
> Date: Thu, 28 Feb 2002 13:22:17 -0600
> From: "Steve Lime" <steve.lime at dnr.state.mn.us>
> To: <drew at no6.com>
>
>
>
> Tom Poindexter, the author of the MapServer Workbench is the local TCL
> guru. You might try posting
> to the main list and see if he bites...
>
> Steve
>
> Stephen Lime
> Data & Applications Manager
>
> Minnesota DNR
> 500 Lafayette Road
> St. Paul, MN 55155
> 651-297-2937
>
> >>> Drew 02/28/02 01:13PM >>>
> I'm wondering if you know of anyone using TCL scripting for mapserver,
>
> and if so, are there examples / code I can borrow / steal? ;)
>
> thx
> Drew
>
>
>
--
Tom Poindexter
tpoindex at nyx.net
http://www.nyx.net/~tpoindex/
More information about the MapServer-users
mailing list