[Mapserver-users] Creating classes with data from a mysql database

Attri, Abhishek aattri at cba.ua.edu
Fri Apr 30 11:58:18 PDT 2004


Hi all,

I used the following syntax to query a mysql table and create a layer
and a class, and got the errors listed below.

$layer->set(data,"colname from (select table1.colname FROM table ,
table1 WHERE  table.col1='xx'  AND table.col2='xx2' AND
table.col3=table1.col3)");

$layer->set(classitem,"colname");

$class->setexpression('([colname]< 50000)');



line 75: $image=$map->draw();
line 77: $image_url=$image->saveWebImage();


========================================================================
=========================================


Warning: [MapServer Error]: msDrawMap(): Failed to draw layer named
'county'. in /home/tech/abhi/public_html/mapExamples/Map2.php on line 75

Warning: [MapServer Error]: msSHPOpenFile():
(/home/tech/abhi/WWW/ms/map_files/) in
/home/tech/abhi/public_html/mapExamples/Map2.php on line 75

Warning: [MapServer Error]: msSHPOpenFile():
(/home/tech/abhi/WWW/ms/data/) in
/home/tech/abhi/public_html/mapExamples/Map2.php on line 75

Fatal error: Call to a member function on a non-object in
/home/tech/abhi/public_html/mapExamples/Map2.php on line 77

========================================================================
========================================================

Also tha data with which i am trying to create a layer with, is not
related to the shapefiles at all. Its just a population variable, and i
want to color the map differently based on different
population values.

Please help me understand what the right method is to create a layer
dynamically from a mysql database, and then generate an image to be
displayed.


With thanks in advance..

Abhishek






-----Original Message-----
From: Alexandros Chimarios [mailto:alhim at intracom.gr] 
Sent: Friday, April 30, 2004 1:04 AM
To: Attri, Abhishek; mapserver-users at lists.gis.umn.edu
Subject: Re: [Mapserver-users] Creating classes with data from a mysql
database


First of all, you should select the columns you wish to appear in the 
CLASSITEM and EXPRESSION in your data fiels like this :

DATA " geolocation from (SELECT unit_tracks.geolocation,
unit_tracks.unit_id 
,units.name , units.identification from unit_tracks LEFT JOIN units ON 
unit_tracks.unit_id = units.unit_id) as foo using unique unit_id using 
srid=-1  "

Then you set the EXPRESSION and CLASSITEM :

		..........
CLASSITEM "identification"
                   
        CLASS
            
            EXPRESSION "UNKNOWN"	

 			.......

Hope this example helps. Please notice that no DB table expression are
set in 
CLASSITEM. If i put "CLASSITEM 'units.identification'   "   then I will
get 
an error. Once the data have been imported from the DB, MapServer treats
them 
as its own table. 

Alexandros


On Friday 30 April 2004 05:26, Attri, Abhishek wrote:
> Hi All,
>
>
>
> I need to create classes on a map object based on data fetched from a
> MySQL database. The classes will be created and displayed based on the
> attributes in the MySQL table (These are not shapefiles). My confusion
> is what will go in the 'data' and 'classitem' fields of the layer
> object, and also how will I set an expression in the class based on
> MySQL table attributes.
>
>
>
> Any examples?
>
>
>
> With thanks in advance....
>
>
>
> Abhishek







More information about the MapServer-users mailing list