second times sql and SUM function in Map script

Murat Beyhan beyhan at DEPREM.GOV.TR
Wed Aug 15 06:10:05 PDT 2007


Dear Friends,

I would like to draw a casualty distribution map for  various building 
types.

On the srcSQL as you see  I need summation of the casualties of each 
type of buildings(rc,wood,briq,brick,stone,adobe)
So I have used sum function to obtain total number of casualties. But 
when I tried to make legend I have to select classitem so I have used AS 
totald for that reason
then I have used totald as a classitem.
But mapserver returns an error message.

When I select only one item for select query for example select 
d_damage.deadp_wood from d_damage
then If I use deadp_wood as classitem the query works and the map drawn.

For my intend what I have to do?
Regards...
MURAT

script: as follows


LAYER
NAME "Dhuman"
   CONNECTIONTYPE OGR    CONNECTION '<OGRVRTDataSource>
   <OGRVRTLayer name="Dhuman">
<SrcDataSource>MYSQL:turkey,user=root,password=mysql_123,host=localhost,port=3306,tables=d_damage 
m_village1</SrcDataSource>
       <SrcSQL>SELECT m_village1.latitude,m_village1.longitude, 
*sum(d_damage.deadp_rc + d_damage.deadp_wood + d_damage.deadp_briq + 
d_damage.deadp_brick + d_damage.deadp_stone + d_damage.deadp_adobe) as 
totald *from d_damage, m_village1 where d_damage.eq_id like "%eq_id%" 
and d_damage.region_id=m_village1.dist_id and m_village1.name not like 
"%(%"</SrcSQL>
       <GeometryType>wkbPoint</GeometryType>
       <GeometryField encoding="PointFromColumns" x="longitude" 
y="latitude"/>
   </OGRVRTLayer>
</OGRVRTDataSource>'
  TYPE POINT
   DATA Dhuman
   STATUS default
           CLASSITEM "totald"
   CLASS
   NAME "HUMAN DAMAGE"
   EXPRESSION ([totald] < 0)
#    COLOR 255 0 255
#    SYMBOL "cpoint"
#    SIZE 12
 END



   CLASS
   NAME "1-10"
   EXPRESSION ([totald] GE 1.0 AND [totald] LT 10.0)
  SYMBOL "cpoint"
  SIZE 5
   COLOR 255 250 250
 END

   CLASS
   NAME "11-50"
   EXPRESSION ([totald] GE 11.0 AND [totald] LT 50.0)
  SYMBOL "cpoint"
  SIZE 5
   COLOR 248 248 255
 END

 CLASS
   NAME "51-100"
   EXPRESSION ([totald] GE 51.0 AND [totald] LT 100.0)
  SYMBOL "cpoint"
  SIZE 5
   COLOR 255 250 240
 END
 CLASS
   NAME "101-200"
   EXPRESSION ([totald] GE 101.0 AND [totald] LT 200.0)
  SYMBOL "cpoint"
  SIZE 5
   COLOR 102 255 204
 END
 CLASS
   NAME "201-400"
 EXPRESSION ([totald] GE 201.0 AND [totald] LT 400.0)
   SYMBOL "cpoint"
   SIZE 5
   COLOR 102 53 0
 END
 CLASS
   NAME "400<"
    EXPRESSION ([totald] GT 400.0)
   SYMBOL "cpoint"
   SIZE 5
   COLOR 102 153 255
 END
END



the error message as follows:

msDrawMap(): Image handling error. Failed to draw layer named 'Dhuman'.
msOGRFileOpen(): OGR error. Open failed for OGR connection ` 
MYSQL:turkey,user=root,password=mysql_123,host=localhost,port=3306,tables=d_damage 
m_village1 SELECT m_village1.latitude,m_village1.longitude, 
sum(d_damage.deadp_rc+ d_damage.deadp_wood +d_damage.deadp_briq + 
d_damage.deadp_brick + d_damage.deadp_stone + d_damage.deadp_adobe) as 
totald from d_damage, m_village1 where d_damage.eq_id like 
"200006060242-auto-000" and d_damage.region_id=m_village1.dist_id and 
m_village1.name not like "%(%" wkbPoint '. SQL statement failed, or 
returned no layer result: SELECT 
m_village1.latitude,m_village1.longitude, sum(d_damage.deadp_rc+ 
d_damage.deadp_wood +d_damage.deadp_briq + d_damage.deadp_brick + 
d_damage.deadp_stone + d_damage.deadp_adobe) as totald from d_damage, 
m_village1 where d_damage.eq_id like "200006060242-auto-000" and 
d_damage.region_id=m_village1.dist_id and m_village1.name not like "%(%"


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



More information about the MapServer-users mailing list