ok - got zoom to work - another question
Stephen Woodbridge
woodbri at SWOODBRIDGE.COM
Wed Nov 24 14:06:36 PST 2004
Joseph,
You can write a Perl script to read the file.dbf using the XBase.pm
module in perl and write a new one with more columns in it. As long as
you don't delete and records and change the order of the records (you
can change the order and the number of the fields in a record) you can
rename it to file.dbf and the shapefile will now work with this new
attribute information.
An attribute field in a shapefile IS the dbf records associated to the
shape records. The association is done by record numbers. i.e. shape #1
is record number one and it's attributes are in record number one of the
dbf file.
Regarding you teachers issue, if you have the number of teachers, and
lat/lon in mysql, then you can dynamically place the markers using
mapscript without needing a shapefile. For each record in mysql, you
would dynamically construct a point object and set the lat/lon position
to the value in mysql and set the text of the label object to "$num
teachers" there have been lots a posts about how to do this along with
perl and php snippets. Or you can dynamically set the size of a marked
based on the number of teachers as I suggested in an earlier post.
-Steve
Joseph Norris wrote:
> Thanks for this information. And as always it leads to another question.
> When you say add a field to your shapefile - are you referring to just the
> dbf file or is there something I have to do to the shp file itself? This
> would be a general type question on adding any type data to shapefiles -
> what is the process for doing this?
>
>
> #Joseph Norris (Perl - what else is there?/Linux/CGI/Mysql) print @c=map chr
> $_+100,(6,17,15,16,-68,-3,10,11,16,4,1,14,-68,12,1,14,8,-68,4,-3,-1,7,1,14,-
> 68,-26,11,15,1,12,4,-68,-22,11,14,14,5,15,-90);
>
> -----Original Message-----
> From: UMN MapServer Users List [mailto:MAPSERVER-USERS at lists.umn.edu]On
> Behalf Of David Fawcett
> Sent: Wednesday, November 24, 2004 11:35 AM
> To: MAPSERVER-USERS at lists.umn.edu
> Subject: Re: [UMN_MAPSERVER-USERS] ok - got zoom to work - another question
>
> Joseph,
>
> The most simple way to do this is to have a field in your shapefile
> with text for each label. (e.g. 23 teachers, 10 teachers, etc.)
> Call it something like 'labeltext'.
>
> Then in the Layer Object in the Map File for the layer that you want to
> label, place a LABELITEM.
>
> LABELITEM 'labeltext'
>
> If you are just storing the number of teachers in a ZipCode in the
> shapefile, you can concatonate a label together by using.
>
> TEXT ([NUM_TEACHERS] Teachers) in your class.
>
>
> David.
>
>
>
>
>
>>>>Joseph Norris <sirronj at PACBELL.NET> 11/24/2004 1:11:55 PM >>>
>
> Thanks Dylan,
>
> A question: I have found these parms labelminscale and labelmaxscale.
> How
> do I set the label for "23 teachers" or "10 teachers" so that - as I
> understand when the user zooms into a polygon, the see this label. Does
> that
> have something to do with Feature object?
>
> #Joseph Norris (Perl - what else is there?/Linux/CGI/Mysql) print
> @c=map chr
> $_+100,(6,17,15,16,-68,-3,10,11,16,4,1,14,-68,12,1,14,8,-68,4,-3,-1,7,1,14,-
> 68,-26,11,15,1,12,4,-68,-22,11,14,14,5,15,-90);
>
> -----Original Message-----
> From: Dylan Keon [mailto:keon at nacse.org]
> Sent: Wednesday, November 24, 2004 10:32 AM
> To: Joseph Norris
> Cc: MAPSERVER-USERS at LISTS.UMN.EDU
> Subject: Re: [UMN_MAPSERVER-USERS] ok - got zoom to work - another
> question
>
> On 11/24/2004 10:13 AM, Joseph Norris wrote:
>
>
>> The lengthy <elaborate kludge> that you mention is something I
>
> would
> like
>
>>to avoid due to the nature of the project. So that leaves me with
>
> the
>
>>open-ended question to all - what suggestions do any and all have
>
> with
>
>>regard to the last part of what I am trying to accomplish - namely -
>
> allow
>
>>the user to zoom into a polygon and see some representation of
>
> what's
>
>>there - a label of the actual number of teachers? I am opened to that
>
> but
> at
>
>>this point in my mapserver education, I am limited in my
>
> understanding of
>
>>Labeling. Can a label be placed within the minscale/maxscale scenario
>
> so
>
>>that when you zoom in you see the label and when you zoom out it
>
> disappears?
>
> Yes. Look for LABELMINSCALE and LABELMAXSCALE at
> http://mapserver.gis.umn.edu/doc42/mapfile-reference.html. Just store
> the desired label as an attribute within the shapefile. There are
> also
> ways to apply labels dynamically via mapscript.
>
> --Dylan
>
More information about the MapServer-users
mailing list