Defining a line from SQL server using OGR
James Perrins
JamesP at ESDM.CO.UK
Thu Mar 30 09:12:09 PST 2006
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:work at XWB.COM]
Sent: 30 March 2006 16:00
To: MAPSERVER-USERS at LISTS.UMN.EDU
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/myPwd at myDSN</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 ###############
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20060330/4297f25c/attachment.htm>
More information about the MapServer-users
mailing list