labelObj in mapscript ?
Doyon, Jean-Francois
Jean-Francois.Doyon at CCRS.NRCan.gc.ca
Tue Jun 27 13:08:25 PDT 2000
Thanks, that fixed the problem right away !
Now, same KINd of problem, but with a twist.
I am now trying to map elevation levels.
In order to do this, I set a CLASSITEM of LEVEL_RANGE in my case.
Then I define various classes with different EXPRESSION statements. Right
now I just have one that says "60", which basically would mean : draw alll
the polygons that have a LEVEL_RANGE of 60, right ?
Well, no such luck. It keeps drawing the whole country ! (or, at times,
nothing at all).
So, what am I doing wrong ? I've successfully used CLASSITEM and EXPRESSION
allready to draw the provinces and territories different colors.
(CLASSITEM "NAME" , EXPRESSION "Ontario" , EXPRESSION "Quebec" , etc ...)
I tried setting the "annotate" flag, no dice. I tried using a type of
"Polygon" and "Annotation" without success.
The rendering allways takes a while though (i.e. it IS doing something).
I was wondering if the datatype might be a concern (since, as you might
remember, all this configuration information comes from a DB Backend), but
after playing with that, it didn't help. (i.e. 60 or '60' or '[ELEV_RANGE] =
60' , etc ...)
I'm out of ideas ... anyone ?
BTW, Stephen, thanks for thet Proj.pm ... I haven't tried it yet, but I was
looking for such a beast, might want to officially release it someday !
Jean-Francois Doyon
Internet Service Development and Systems Support
GeoAccess Division
Natural Resources Canada
(613) 992-4902
> ----------
> From: Stephen Lime[SMTP:steve.lime at dnr.state.mn.us]
> Sent: Thursday, June 22, 2000 3:34 PM
> To: Jean-Francois.Doyon at CCRS.NRCan.gc.ca;
> mapserver-users at lists.gis.umn.edu
> Subject: RE: labelObj in mapscript ?
>
> This probably has to do with an internal annotation flag that is set when
> the mapfile is read. In cases where the decision to annotate is set after
> the mapfile is loaded then then flag isn't set and annotation won't be
> done.
> This has been remedied in the latest CVS (which I would avoid until
> next Monday unless you're desperate).
>
> For now there are a couple of workarounds. If you're using a mapfile
> with all layers predefined then you can define a dummy classitem
> property or class text porperty. This is suffiecient to set the annotate
> flag.
> Since your building the entire map from scratch you'll need to set the
> flag
> by hand for each layer that has annotation. Use something like:
>
> $layer->{annotate} = 1;
>
> and see if that fixes things. Again this has been fixed in the latest
> code.
>
> Use $class->{label}->{outlinecolor} rather than backgoundcolor. Both
> keywords
> do the samething, but I had to choose one name for the C structures.
>
> Steve
>
> Stephen Lime
> Internet Applications Analyst
>
> Minnesota DNR
> 500 Lafayette Road
> St. Paul, MN 55155
> 651-297-2937
>
> >>> "Doyon, Jean-Francois" <Jean-Francois.Doyon at CCRS.NRCan.gc.ca> 06/22/00
> 01:56PM >>>
> Thanks a bunch ...
>
> Now, I'm just stumped ...
>
> I've setup a system where the mapfile type parameters are now stored in a
> database (At least all the ones that I can).
>
> So it cycles through the database, determining classes and labels and so
> on
> .. It's been working well so far. I've managed
> to color all canadian provinces and territories using a classitem and an
> expression, and storing all the classes in the DB
> and so on. Now I'm trying to generate an annotation layer that is the city
> names, but I'm having no luck, the labels simply
> won't draw it seems, and I'm running out of ideas as to why this might be
> ...
>
> Assuming the back end data is correct (which it IS !), can anybody find a
> problem with the code below ? It's fairly straightforward ...
> I know it's ugly, I'm just toying around for now, the production version
> will be much nicer :)
>
> I've commented some lines of code as well , meaning I've toyed around with
> them without success ...
>
> Any help would be greatly appreciated !
>
> oh BTW, I'm using a nightly build from a couple of nights ago, and
> $class->{label}->{backgroundcolor} does not seem to "exist" ...
>
> J.F.
>
> sub getmap {
> checklayers();
> checksrs();
> checkformat();
> $map = new mapObj('/home/mapdata/canada/perltest.map');
> $map->{name} = 'Test';
> $map->{status} = $mapscript::MS_ON;
> $map->{height} = $height;
> $map->{width} = $width;
> $map->{interlace} = $mapscript::MS_OFF;
> $map->{transparent} = $mapscript::MS_OFF;
> $map->{shapepath} = 'data';
> $map->{imagecolor}->{red} = 255;
> $map->{imagecolor}->{green} = 255;
> $map->{imagecolor}->{blue} = 255;
> my $ext = new rectObj();
> my @bb = split(/,/,$bbox);
> $ext->{minx} = $bb[0];
> $ext->{miny} = $bb[1];
> $ext->{maxx} = $bb[2];
> $ext->{maxy} = $bb[3];
> $map->{extent} = $ext;
> $map->{units} = $mapscript::MS_METERS;
> foreach ( @reqlayer ) {
> $res = $conn->exec("SELECT id,data,type,classitem,labelitem
> FROM layers WHERE name='$_'");
> my @laydata = $res->fetchrow;
> $layer = new layerObj($map);
> $layer->{name} = $_;
> if ( $laydata[2] eq "p" ) { $layer->{type} =
> $mapscript::MS_POLYGON }
> elsif ( $laydata[2] eq "l" ) { $layer->{type} =
> $mapscript::MS_LINE }
> elsif ( $laydata[2] eq "t" ) { $layer->{type} =
> $mapscript::MS_POINT }
> elsif ( $laydata[2] eq "a" ) { $layer->{type} =
> $mapscript::MS_ANNOTATION }
> else { showerror('There seems to be a server configuration
> error. Layer <B>'.$_.'</B> specifies an unsupported shape type :
> ',$laydata[1],'Please contact the server administrator listed below.') }
> $layer->{status} = $mapscript::MS_ON;
> $layer->{data} = $laydata[1];
> if ( $laydata[3] ) { $layer->{classitem} = $laydata[3] }
> elsif ( $laydata[4] ) { $layer->{labelitem} = $laydata[4] }
> $res = $conn->exec("SELECT
> id,color,outlinecolor,expression,symbol,size FROM classes WHERE
> layid=$laydata[0]");
> while ( @classdata = $res->fetchrow ) {
> $class = new classObj($layer);
> $class->{symbol} = $classdata[4];
> @colors = getcol($classdata[2]);
> $class->{outlinecolor} =
> $map->addColor($colors[0],$colors[1],$colors[2]);
> @colors = getcol($classdata[1]);
> $class->{color} =
> $map->addColor($colors[0],$colors[1],$colors[2]);
> if ( $classdata[5] ) { $class->{size} =
> $classdata[5] }
> if ( $laydata[3] ) {
> $class->setExpression($classdata[3]) }
> elsif ( $laydata[4] ) {
> $res2 = $conn->exec("SELECT
> backgroundcolor,color,relposition,size,type FROM classlabels WHERE
> classid=$classdata[0]");
> while ( @labeldata = $res2->fetchrow ) {
> @colors = getcol($labeldata[1]);
> $class->{label}->{color} =
> $map->addColor($colors[0],$colors[1],$colors[2]);
> $class->{label}->{position} =
> $mapscript::MS_AUTO;
> $class->{label}->{size} = 'GIANT';
> $class->{label}->{type} =
> $mapscript::MS_BITMAP;
> $class->{label}->{wrap} = " ";
> }
> }
> }
> }
> # $map->prepareImage();
> $img = $map->draw();
> # $map->drawLabelCache($img);
> print "Content-Type: image/gif\n\n";
>
> mapscript::msSaveImage($img,undef,$map->{interlace},$map->{transparent});
>
>
> > ----------
> > From: Stephen Lime[SMTP:steve.lime at dnr.state.mn.us]
> > Sent: Thursday, June 22, 2000 11:43 AM
> > To: Jean-Francois.Doyon at CCRS.NRCan.gc.ca;
> > mapserver-users at lists.gis.umn.edu
> > Subject: Re: labelObj in mapscript ?
> >
> > Since there are no formal methods for label objects most of the
> > documentation
> > is simply the labelObj parameters in the map file docs. Labels are part
> of
> > classes,
> > scalebar and legend objects and are accessed through those. Syntax is
> > simple:
> >
> > $class->{label}->{size} = 12;
> > $map->{scalebar}->{label}->{color} = $map->addColor(0,0,0);
> >
> > There are 2 exceptions to the params in the mapfile docs, ANGLE and
> > MINFEATURESIZE
> > when using the AUTO keyword. Instead use:
> >
> > $class->{label}->{autoangle} = 1;
> > $class->{label}->{autominfeaturesize} = 1;
> >
> > Will add this to the new site...
> >
> > Steve
> >
> > >>> "Doyon, Jean-Francois" <Jean-Francois.Doyon at CCRS.NRCan.gc.ca>
> 06/22/00
> > 09:22AM >>>
> > Exactly how are Label Objects handled with mapscript ? I don't see any
> > labelObj type method defined in the docs ...
> >
> > I'm trying to put labels together for a class for an annotation type
> layer
> > ... (Cites w/ names)
> >
> > Or ar the Label parameters just part of the class ? can I go
> > $class->{type}
> > = 'Bitmap' ?
> >
> > Thanks,
> >
> >
> > Jean-Francois Doyon
> > Internet Service Development and Systems Support
> > GeoAccess Division
> > Natural Resources Canada
> > (613) 992-4902
> >
> >
> > Stephen Lime
> > Internet Applications Analyst
> >
> > Minnesota DNR
> > 500 Lafayette Road
> > St. Paul, MN 55155
> > 651-297-2937
> >
>
More information about the MapServer-users
mailing list