Point locations in image coordinates?

mark.wilson at rohoel.at mark.wilson at rohoel.at
Wed Oct 4 03:31:36 EDT 2000



Thanks - option 2 looks the way to go for me.

However, I may have run ahead of myself. My application is similar to the
earthquake mapscript example, in that my point data come from a text file (not a
shape file).

I have two questions:
1) Record numbers are currently appearing in my map symbols, but the map
background is showing through the text. I assume this is because the colour of
the text is the same as the map background (white) and  I have transparency
switched on???  Where can I set the colour of this text? (which it seems is not
actually a "label" since it does not respond to setting label colour, and the
text which is plotted this way is not available in the label cache). I can't
seem to change it no matter what I set. This question is more for my
understanding, rather than actual need.

2) In order to plot blank text (" ") as an annotation layer, I think my
mapscript will need altering to deal with features. Correct? Here are the code
segments from my mapfile, and mapscript which currently deal with plotting the
symbols as a point layer. It is analogous to the quakes example. How do I set
the x and y coordinates for text annotations within mapscript, and what method
do I use to draw them? (Code segments follow)

Thanks,
Mark

Extract from mapfile:
--------------------------------------------------
    LAYER
    TYPE POINT
    NAME destinations
    STATUS OFF
    SYMBOLSCALE 50000000
    CLASS
       SYMBOL 4
       SIZE 30
       OUTLINECOLOR 255 0 0
       COLOR 255 0 0
#       LABEL
#        COLOR 0 255 255
#        SIZE 12
#        MINSIZE 12
#        MAXSIZE 12
#        BACKGROUNDCOLOR 0 0 0
#        POSITION AUTO
#       END
    END
-------------------------

Extract from mapscript file:

-------------------------
$lName = "destinations";
$i = 1;
$layer = $map->getLayerByName($lName) or
     die("Unable to getLayerByName($lName)");
$class = $layer->getClass(0);
foreach $record (@raw_data) {
     chop($record);
     ($xcoord,$ycoord,$class_num)=split(/\s+/,$record);
     $class->{size} = 16;
     $class->{maxsize} = $class->{minsize} = $class->{size};
     $point = new pointObj();  # Do I still need this for positioning the
annotation text?
     $point->{x} = $xcoord;    # Is this still the way to set the x and y of the
annotation?
     $point->{y} = $ycoord;
     # print("<p>record=$record, x=$xcoord, y=$ycoord, $class_num</p>");
     $point->draw($map, $layer, $img, undef, " ");  # Is this the method for
drawing the annotation feature?
     $i++;
     }
$layer->draw($map, $img);
-------------------------







"Stephen Lime" <steve.lime at dnr.state.mn.us> on 02.10.2000 18:40:02

To:   Mark H Wilson/RAG/AT at RAG
cc:

Subject:  Re: Point locations in image coordinates?



Hi Mark: Several ways to do this (assuming you're using mapscript).

1) calc image coords for symbols plotted

To do this you'd need to draw that layer indepently by doing an extent
based query and then process those points by directly accessing the shapefile.
The extent would simply be the map extent. Then cache each point in image
coordinates. The equations to this are straight forward.

2) use the labelcache, one way

You can draw the points as annotation layer with blank text (i.e. TEXT " ").
That way
you can pull them out of the labelcache as described elsewhere. I think you can
use the FORCE  label parameter to make sure they get drawn.

3) use the labelcache, another way

Draw the points as a point layer with blank text. Points with text are handled
like annotation
layers so that collision with point markers is removed. Markers can collide, but
not text with
the markers. This is essentially the same as 2) but marker locations are held in
a different place
in the labelcache structure. I'll have to look at the source to figure out how
to access it
via perl.

Bottom line is it can be done. Questions?

Steve

Stephen Lime
Internet Applications Analyst

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937

>>> <mark.wilson at rohoel.at> 09/29/00 06:01AM >>>


I am investigating adding some imagemap type functionality (?DHTML) to my
mapserver application. From looking at old posts to this list, I can see that it
is possible to easily get label locations in image coordinates from the label
cache.

However, I want only to plot symbols with no labels.

Do I still need to caclulate the (point) image coordinate values manually, or
has an easier way been discovered?

Does position "CC" plot the label directly on top of the symbol? If so, then
this would give the correct location for the point in image coordinates.

Might it be possible to have a "dummy" layer to plot the labels at an extremely
small size, so that they all plot (?), thus ensuring they are all have
coordinates available in the labelcache?

Or, is it safer/better to just do a manual calculation using image size, map
extents and real world point coordinates?

Thanks in advance for any advice,
Mark










More information about the mapserver-users mailing list