[mapserver-users] point does not appear in mapscript (fwd)

teb teb at mallit.fr.umn.edu
Tue Sep 11 09:24:18 EDT 2001


------------- Begin Forwarded Message -------------

From: "Steven Hayes" <shayes at bigpond.net.au>
To: <mapserver-info at lists.gis.umn.edu>
Subject: point does not appear in mapscript
Date: Tue, 11 Sep 2001 22:19:08 +1000
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
Importance: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200

Hi,

I've been using MapServ in a very basic way for some time but have just
started working with mapscript. I have gotten a simple map to draw but what
I really want to do is to dynamically add points (based on a sql query,
though I think that is not relevant to this question).

My problem is in using the pointObj() method and specifically the class
parameter. I am a bit vague on this one but it seems to me that the symbol
and the colour used to draw the point is sourced from the class definition
in a layer called from the map file using the getLayerByName method. My
relevant layer statement in the map file is as follows:

########################################################################33
LAYER
	NAME sw_sites
	TYPE point
	STATUS OFF
	DATA locations
	#DATA location_mi_point
	labelitem "ID"

	CLASS
		SYMBOL 3
		SIZE 7
		NAME sw_sites
		COLOR 254 0 0
		LABEL
      			BACKGROUNDCOLOR 200 255 255
     			COLOR 30 94 94
     			SIZE SMALL
     			POSITION AUTO
     			WRAP " "
   		 END

	END
END
#############################################################

My mapscript code is as follows:



###############################################################
#! /usr/bin/perl

use CGI qw/:standard :html3 -no_debug/;
use mapscript;

$q = new CGI;

print $q->header();

$map = new mapObj("/www/hosted/streamwatch/cgi-bin/streamwatch.map") or
die('Unable to open mapfile.');
my $layer = $map->getLayerByName('regall');
$layer->{status} = $mapscript::MS_ON;
my $layer = $map->getLayerByName('ocean');
$layer->{status} = $mapscript::MS_ON;
my $layer = $map->getLayerByName('rivall');
$layer->{status} = $mapscript::MS_ON;


$point = new pointObj();
$point->{y} = $data->{'-33.7577'};
$point->{x} = $data->{'151.0188'};

$map->{extent}->{minx}= 150.9000;
$map->{extent}->{miny}= -33.6000;
$map->{extent}->{maxx}= 151.1000;
$map->{extent}->{maxy}= -33.8000;
$map->{height} = 300;
$map->{width} = 300;

my $img = $map->prepareImage();
#$layer->draw($map, $img);

$img = $map->draw() or die('Unable to draw map');
$layer = $map->getLayerByName('sw_sites');
$point->draw($map, $layer, $img, 0, "test point");
$map->drawLabelCache($img);

mapscript::msSaveImage($img, undef, $map->{interlace}, $map->{transparent});
########################################################################3

The following link shows what result I get:

http://www.streamwatch.org.au/cgi-bin/testmapscript.pl

There should by rights be a small red triangle in somewhere near the center
of the map with the lable "test point".

I am clearly missing something fundamental. Can anyone help?

Regards

Steven Hayes
TND Computer Systems
Sydney NSW Australia




------------- End Forwarded Message -------------





More information about the mapserver-users mailing list