[Chameleon] Displaying MySQL point over MapDHTML - ODBC / OGR

Bart van den Eijnden BEN at Syncera-ITSolutions.NL
Thu Nov 17 07:32:13 EST 2005


Hi,

this message would be better off being posted to the mapserver-users list.

Can't you make a view in your database?

You could also use Mapserver's FILTER on a LAYER to define a where clause.

Also important, which version are you using of Mapserver and GDAL?

Best regards,
Bart

Bart van den Eijnden
Syncera IT Solutions
Postbus 270
2600 AG  DELFT

tel.nr.: 015-7512436
email: BEN at Syncera-ITSolutions.nl

>>> "Carlo Tronnberg" <temp at chello.hu> 17-11-2005 5:52 >>>
Thanks Bart for the tip! This is MUCH better.

I have a slight problem still: 

If I use in the 'virtual.ovf' file the SrcLayer tag, there are no problems. 
<OGRVRTDataSource>
    <OGRVRTLayer name="mylayer">
        <SrcDataSource>ODBC:elu/Elu51221!@eluodbc</SrcDataSource> 
  <SrcLayer>lineup</SrcLayer>
 <GeometryType>wkbPoint</GeometryType> 
        <LayerSRS>WGS84</LayerSRS>
 <GeometryField encoding="PointFromColumns" x="gps_lat_degree" y="gps_long_degree"/> 
    </OGRVRTLayer>
</OGRVRTDataSource>

BUT! If I want to execute an SQL Query (which I DO!) with the SrcSQL tag, as follows,
  <OGRVRTDataSource>
      <OGRVRTLayer name="mylayer2">
          <SrcDataSource>ODBC:elu/Elu51221!@eluodbc</SrcDataSource>
        <SrcSQL>SELECT lineup.* FROM lineup WHERE lineup.team_id = 71 </SrcSQL>
       <GeometryType>wkbPoint</GeometryType> 
          <LayerSRS>WGS84</LayerSRS>
       <GeometryField encoding="PointFromColumns" x="gps_lat_degree" y="gps_long_degree"/> 
      </OGRVRTLayer>
  </OGRVRTDataSource>
Then mapserver will not generate the map. (Nothing comes out then, not even the other existing layers)
I ran both versions of the ovf file with ogrinfo and the SrcSQL version threw an ERROR 1: SetAttributeFilter() not supported on ExecuteSQL() results.
  C:\ms4w\apps\elu\map>ogrinfo -ro virtual.ovf mylayer
  INFO: Open of `virtual.ovf'
  using driver `VRT' successful.

  Layer name: mylayer
  Geometry: Point
  Feature Count: 35
  ERROR 1: SetAttributeFilter() not supported on ExecuteSQL() results.
  Extent: (0.000000, 0.000000) - (42.000000, 18.000000)
  Layer SRS WKT:
  GEOGCS["WGS 84",
      DATUM["WGS_1984",
          SPHEROID["WGS 84",6378137,298.257223563,
              AUTHORITY["EPSG","7030"]],
  etc ....
Even the simplest SQL query will cause the same problem.

Here is the layer I am using:
      LAYER
          NAME "All Stations"
          TYPE POINT
          CONNECTIONTYPE OGR
          CONNECTION "virtual.ovf"
          DATA "mylayer"
          STATUS ON
         # LABELITEM lineup.team_id #may need to use table.name or just name depending on your OVF file.
          PROJECTION
            "init=epsg:4326"
          END
          CLASS
            SYMBOL 2
            SIZE 16
            COLOR 100 100 100
            LABEL
           SIZE MEDIUM
           TYPE BITMAP
           COLOR 0 0 0
            END
          END
      END
What am I doing wrong?

Best regards,

Carlo

----- Original Message ----- 
From: "Bart van den Eijnden" <bartvde at xs4all.nl>
To: "Carlo Tronnberg" <temp at chello.hu>
Cc: <chameleon at lists.maptools.org>
Sent: Tuesday, November 15, 2005 20:59
Subject: Re: [Chameleon] Displaying MySQL point over MapDHTML or MapImageSharedResource widgets


> Hi,
> 
> with respect to your MySQL points, I would suggest looking at 
> Mapserver's Virtual Spatial Data through OGR. You could use an ODBC 
> connection, or compile GDAL/OGR against the MySQL client.
> 
> See also here:
> http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?VirtualSpatialData 
> 
> I would suggest sticking with the MapDHTML widget.
> 
> Best regards,
> Bart
> 
> Carlo Tronnberg wrote:
> 
>> Dear List,
>>
>> Sorry for this rather long message, but I need to get an answer as 
>> soon as possible and want to be clear from the beginning. I have a 
>> feeling that this can be useful to MANY newbies like me out there.
>>
>> I have some MySQL data (basically latitude, longitude, color of the 
>> icon) that I want to plot on a map.
>>
>> This is rather urgent...
>>
>> 1.
>> I use the SQLQuery Widget to get the data and tried out the 
>> "MapImageSharedResource" Widget which sounded very promising, 
>> extracting directly the points from the sharedresource returned by the 
>> SQLQuery.
>>
>> Here is an extract of the code I used with the 
>> "MapImageSharedResource" Widget:
>> __________
>> <CWC2 Type="SQLQuery" sqlquery="SELECT latitude, longitude FROM 
>> dealer" Server="localhost" DBTYPE="MYSQL" Database="test2" 
>> UserName="root" Password="1234" SharedResourceName="MyResult2">
>>    <ONEVENT Event="ConnectFailed" Text="Connection failed."/>
>>    <ONEVENT Event="SelectDBFailed" Text="Databse don't exist."/>
>>    <ONEVENT Event="QueryFailed" Text="Query failed."/>
>>    <ONEVENT Event="NoRowReturned" Template="noresult"/>
>>    <ONEVENT Event="GeocodeFailed" Template="error"/>
>> </CWC2>
>>
>> <CWC2 TYPE="MapImageSharedResource" id="inline" Width="500" 
>> Height="250" Navigable="false" Transparent="true" SYMBOLOVERLAP="true" 
>> AUTOEXTENT="false">
>>    <POINTS NAME="START" SRNAME="MyResult_IMAGE" SRLATCOL="latitude" 
>> SRLONCOL="longitude" type="unique" LABEL="Team [$MyResult_IMAGE.Id]"/>
>>    <MAP POINT="START" TYPE="STYLE" PARAM="color" VALUE="00FF00"/>
>>    <MAP POINT="START" TYPE="STYLE" PARAM="size" VALUE="25"/>
>>    <POINTS NAME="END" SRNAME="Elu" SRLATCOL="gps_lat_degree" 
>> SRLONCOL="gps_long_degree" type="unique" LABEL="Team [$Elu.team_id]"/>
>>    <MAP POINT="END" TYPE="STYLE" PARAM="color" VALUE="0000FF"/>
>>    <MAP POINT="END" TYPE="STYLE" PARAM="size" VALUE="20"/>
>> </CWC2>
>> ___________
>> Unfortunately this doesn't work well. After some tweaking I got the 
>> map generated OK but a lot of error messages in the web page which 
>> cannot be removed.
>>
>> Error message:
>> Notice: Undefined property: sName in 
>> C:\ms4w\apps\chameleon\htdocs\common\wrapper\map_session.php on line 
>> 1073.
>>
>> I went through all the material online I could find but I simply could 
>> not make it work well. Am I missing something?
>>
>> I use ms4w_1.2.2 and chameleon_ms4w-2.2
>> Is it possible that the versions I use do not work properly (too 
>> new?). I also tried ms4w_1.3.0 but that gave even more errors with PHP 
>> (not even the Cameleon samples worked!)
>>
>> 2.
>> I have generated a pretty nice environment based on the Chameleon 
>> samples, using the MapDHTML widget for the map. Unfortunately I do not 
>> know how to get MySQL points on it via the mapserver.
>>
>> Can the MapDHTML Widget also get points added to it in the same way as 
>> the MapImageSharedResource Widget can?
>>
>> 3.
>> Anotherway around... If the MapImageSharedResource works correctly, is 
>> it possible to make it behave as the MapDHTML widget (Navigation...) 
>> so it can be integrated instead of it in the Chameleon samples?
>>
>> A lot of questions from a desesperate newbie... (I went through the 
>> Mailing lists and could not get the answers...)
>>
>> Best Regards,
>>
>> Carlo Tronnberg
>> _______________________________________________
>> Chameleon mailing list
>> Chameleon at lists.maptools.org 
>> http://lists.maptools.org/mailman/listinfo/chameleon 
>>
>>
>



More information about the Chameleon mailing list