Hi,

 

I’ve just been playing with this.

 

As Frank says – if your Lat/Long fields are single/double then you need something like:

 

 

  '<OGRVRTDataSource>

       <OGRVRTLayer name="TestPoint">

        <SrcDataSource>ODBC:WKT,TestPoint</SrcDataSource>

        <SrcSQL>SELECT X,Y FROM TestPoint WHERE KeyName=2</SrcSQL>

        <GeometryType>wkbPoint</GeometryType>

        <GeometryField encoding="PointFromColumns" x="X" y="Y"/>

      </OGRVRTLayer>

  </OGRVRTDataSource>'

 

Note wkbPoint not wkbLine

 

If you can convert your GPS readings into a WKT string and store this in a text field in your table - such as:

POLYGON (( 100000 100000, 200000 500000,500000 500000,500000 200000, 100000 100000))

 

Then something like:

'<OGRVRTDataSource>

       <OGRVRTLayer name="TestPolygon">

        <SrcDataSource>ODBC:WKT,TestPolygon</SrcDataSource>

        <SrcSQL>SELECT * FROM TestPolygon WHERE KeyField=1</SrcSQL>

        <SrcLayer>TestPolygon</SrcLayer>

        <GeometryType>wkbPolygon</GeometryType>

        <GeometryField encoding="WKT" field="GEOMETRY"/>

      </OGRVRTLayer>

  </OGRVRTDataSource>'

 

Should work.

 

Best wishes

James


From: Chip Taylor [mailto:[EMAIL PROTECTED]
Sent: 30 March 2006 16:00
To: [email protected]
Subject: [UMN_MAPSERVER-USERS] Defining a line from SQL server using OGR

 

I am retrieving a set of point from SQL Server using OGR.  If I declare the layer type to be "Point" then it works fine.  However, I want the series of XY coordinates to define a line.  If I declare the layer type "Line" nothing renders.  Any help would be appreciated.  Here is the layer code defined as a line (there are two xy points in the database):

 

#####################################

# Tracking

#

LAYER

  NAME GPSLayer1

  TYPE Point

  CONNECTIONTYPE OGR

  CONNECTION

 

 '<OGRVRTDataSource>

       <OGRVRTLayer name="GPSData">

        <SrcDataSource>ODBC:myUser/[EMAIL PROTECTED]</SrcDataSource>

       <SrcSQL>EXEC pGetTracking</SrcSQL>

       <GeometryType>wkbLineString</GeometryType>

        <GeometryField encoding="PointFromColumns" x="gpsLongitude" y="gpsLatitude"/>

      </OGRVRTLayer>

  </OGRVRTDataSource>'

 

  DATA "GPSData"

  CLASSITEM "gpsDeviceId"

  STATUS off

  CLASS

          _expression_ /Device1/

          STYLE

                 COLOR 90 0 255

                 OUTLINECOLOR 0 255 0

                 SYMBOL 'BigLine'

                 SIZE 40

          END

  END

 

 END

 

########### End of Tracking Layer ###############

 

Reply via email to