Mapserver – virtual data sources

Following gdal org’s Virtual data source description and mapserver.org’s documentation on Virtual Spatial Data, I tried to set up a data source using the ODBC-textual data driver, but even if using ogrinfo with the driver and table name seemed to work well, using the ovf-file and thereby reading it in through the .map-file just didn’t work.

The mapserver application came out with a few error messages, where

Warning: [MapServer Error]: msOGRFileOpen(): Open failed for OGR connection in layer `test’. Failed to find layer ‘test.txt’ on datasource ‘ODBC:mapserver’. in C:\ms4w\apps\tutorial\htdocs\test1.php on line 52

was the one that pointed to the problem. Ogrinfo test.ovf told me that

ERROR 4: Update access not supported for VRT datasources.
ERROR 1: Unable to identify source X or Y field for PointFromColumns encoding.
FAILURE:
Unable to open datasource `test.ovf’ with the following drivers.
-> ESRI Shapefile
-> MapInfo File (…)”

whereas ogrinfo ODBC:mapserver test.txt worked fine. the ovf-file was as simple as

<ogrvrtdatasource>
	<ogrvrtlayer name="test">
		<srcdatasource>ODBC:mapserver</srcdatasource>
		<srclayer>test.txt</srclayer>
		<geometryfield encoding="PointFromColumns" x="x" y="y"/>
		<geometrytype>wkbPoint</geometrytype>
	</ogrvrtlayer>
</ogrvrtdatasource>

so this caused quite a few grey hairs.

At last it occured to me, I had put the text files with data into the same directory where I had the other data files for the project. A few of this files also had the .txt extention, after I had once looked into the “Define format” dialog in the odbc setup, the odbc driver tried to also make sense of those files, as they were not well-defined tables, it erred out, not even trying to read the table file I wanted it to read… Moving the data files into their own directory and adjusting the ODBC-source saved my day.

Addendum:
Looking back into the directory, I found the schema.ini file, by removing or editing that, I could probably have kept the text-table files in the old directory.

This entry was posted in Data and tagged . Bookmark the permalink.