try to get it through your mapfile! base on what I read here
http://mapserver.org/input/vector/ogr.html#using-ogr-data-sources-in-the-map-file,
you'll supposed to be able to add an SQL in DATA tag for any OGR data
source, and there you should be able to select fid... I guess
LAYER
...
CONNECTIONTYPE OGR
CONNECTION "<datasource_name>"
DATA "select fid, field_1, field_2, field_3 from <datasource_name>"
...
END
On 16-04-26 11:05 AM, Ian Walberg wrote:
Simon,
We tried this yesterday but could not see how to include the sql statement in
the vrt file so that mapserver got an fid for each record.
Thanks
Ian
-----Original Message-----
From: Simon Mercier [mailto:[email protected]]
Sent: Tuesday, April 26, 2016 8:01 AM
To: Ian Walberg <[email protected]>; [email protected]
Subject: Re: [mapserver-users] RE OGR csv - no field names
Ian
Try with FID field, OGR generate this ID for you. But you should try use your
own ID field for consistency between version of your data (if needed). I tested
with my demo data and I can select FID even if it doesn't exist in source file.
<OGRVRTDataSource>
<OGRVRTLayer name="Inventory">
<SrcDataSource>/home/smercier/data/vrt/Inventory.csv</SrcDataSource>
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>EPSG:4326</LayerSRS>
<GeometryField encoding="PointFromColumns" x="longitude"
y="latitude"/>
<Field name="site_name" src="SiteName"/>
<Field name="site_phone" src="SitePhone"/>
<Field name="site_type" src="SiteType"/>
<Field name="address" src="address"/>
<Field name="site_aed_placement" src="AEDPlacementLocation"/>
</OGRVRTLayer>
</OGRVRTDataSource>
smercier@optimus: $ ogrinfo Inventory.vrt -sql "select fid from Inventory"
INFO: Open of `Inventory.vrt'
using driver `VRT' successful.
Layer name: Inventory
Geometry: Point
Feature Count: 117
Extent: (-80.977043, 0.000000) - (0.000000, 43.978620) Layer SRS WKT:
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],
UNIT["degree",0.0174532925199433,
AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4326"]]
fid: Integer (0.0)
OGRFeature(Inventory):1
fid (Integer) = 1
POINT (-80.2171407 43.4970847)
OGRFeature(Inventory):2
fid (Integer) = 2
POINT (-80.5357573 43.8367679)
OGRFeature(Inventory):3
fid (Integer) = 3
POINT (0 0)
....
On 16-04-25 07:11 PM, Ian Walberg wrote:
Jeff,
Many thanks that worked great.
Next is there any way of getting the row ID as part of the data passed to
mapserver?
We are planning to serve this data as a WFS layer.
Thanks
Ian
-----Original Message-----
From: mapserver-users [mailto:[email protected]]
On Behalf Of Jeff McKenna
Sent: Monday, April 25, 2016 3:03 PM
To: [email protected]
Subject: Re: [mapserver-users] RE OGR csv - no field names
On 2016-04-25 6:49 PM, Simon Mercier wrote:
really not sure CSVT file is supported by ogr, but you can easily
define field type in VRT
<Field name="precipitation_mm" src="prec_mm" type="Real"/>
<Field name="field_1" src="field_1" type="String" width="100"
/>
Simon is right, very nice, specifying the field name to classify in the vrt
works, for a csv without field names:
<OGRVRTDataSource>
<OGRVRTLayer name="occurrence">
<SrcDataSource relativeToVRT="1">CSV:occurrence.txt</SrcDataSource>
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>WGS84</LayerSRS>
<GeometryField encoding="PointFromColumns" x="field_37"
y="field_38"/>
<Field name="name" src="field_51" type="String" width="100"/>
</OGRVRTLayer>
</OGRVRTDataSource>
LAYER
NAME "occurrence"
TYPE POINT
STATUS ON
CONNECTIONTYPE OGR
CONNECTION "../occurrence.vrt"
CLASSITEM "name"
CLASS
NAME "Occurrences"
EXPRESSION "ttt"
STYLE
SYMBOL 7
SIZE 10
COLOR 0 0 0
END
END
END # Layer
-jeff
--
Jeff McKenna
MapServer Consulting and Training Services
http://www.gatewaygeomatics.com/
_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
--
simon mercier
mapgears
+1.418.476.7139 p101
--
simon mercier
mapgears
+1.418.476.7139 p101
_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users