[tpoindex at nyx.net: Re: [mapserver-users] tcl mapscript real world examples]

Artem 'Thomas' Hlushko tom at asd-g.com
Thu Sep 13 00:44:51 PDT 2001


----- Forwarded message from Tom Poindexter <tpoindex at nyx.net> -----

X-Nyx-Envelope-Data: Date=Tue Sep 11 11:12:19 2001, Sender=tpoindex, Recipient=tom at asd-g.com, Valsender=tpoindex at localhost
From: Tom Poindexter <tpoindex at nyx.net>
To: "Artem 'Thomas' Hlushko" <tom at asd-g.com>
Subject: Re: [mapserver-users] tcl mapscript real world examples
X-OriginalArrivalTime: 11 Sep 2001 17:05:12.0310 (UTC) FILETIME=[EB522160:01C13AE3]

On Tue, Sep 11, 2001 at 03:44:13PM +0300, Artem 'Thomas' Hlushko wrote:

> I have load mapfiles, modify mapObj, add
> inline features, change expressions, ...,
> save map, reference, scale and legend images
> to build complex web application.

Sounds like you have a good grip on things if you're doing this much!


> The only examples I found are shpinfo.tcl
> and msworkbench. The first is short, the
> second uses object packages and obfuscates
> mapscript API.

There are two different API's.  The first the the Mapscript interface 
as implemented in Tcl.  This should be relatively equivalent to the Perl
and Python interfaces, as they are each built from the same Swig specification.
There is a Swig generated documentation file,  that pretty much just lists
the objects and methods.  Yes, sadly, there isn't a lot of docs.  The
Mapscript docs at mapserver.gis.umn.edu/mapscript.html should give you
a good intro, even for Tcl.  

The main differences are the language syntax issues.  Where Perl uses '->' as 
an object method or data specifier, Tcl
simply uses a space.  
	Perl:  $map = newmapObj('foo.map');
	Tcl:   set map [mapscript::mapObj -args foo.map]

All Tcl Mapscript objects reside in a namespace of
'mapscript'.  Other differences are that Tcl objects use methods 'configure' 
and 'cget' to get an set data members, rather than just resolving with
a '->', e.g:
	Perl:	$map->{name} = 'test';
	Tcl:    $map configure -name test
	
Tcl also needs to dereference object references in one object, to gain
access to child object data & methods:
	Perl:	$map->{extent}->{minx} = $minimum_x;
	Tcl:    set extent [$map cget -extent]
		mapscript::rectObjRef $extent configure -minx $minimum_x
	
	The 'mapscript::rectObjRef' command is used as a cast, which is
	a more readable way of:
		rectObj_minx_set $extent $minimum_x
	which is the actual command constructed by Swig.  The 'rectObjRef' 
	command is constructed in mapscriptsupp.tcl to provide the other
	syntax.



The other API used by MapServer Workbench is 'msTclObjs', which allows
manipulation of map objects for editing, when a map object may be in
an invalid state.  I wrote these to do things like cut/copy/paste, allow
data entry validation and meta-data for the Mapscript objects.


> Perl and PHP docs and examples don't help -
> tcl is too different.

First, you should have a good understanding of Tcl (should take most people
a few hours, a day at most.)  There are several good books on Tcl, and lots
of info on the web.

I'm currently working on updating Mapscript/Tcl and MapServer Workbench for
Mapserver 3.5,  if I have time, I'll try to add some addtional docs or
examples.

-- 
Tom Poindexter
tpoindex at nyx.net
http://www.nyx.net/~tpoindex/

----- End forwarded message -----



More information about the MapServer-users mailing list