[gdal-dev] OGR GML and other drivers producing text output: stdout,
/dev/stdout and /vsistdout/ (was: ogr2ogr - output WKT to console?)
Hermann Peifer
peifer at gmx.eu
Thu Sep 1 06:10:40 EDT 2011
On 01/09/2011 00:28, Even Rouault wrote:
> Le jeudi 01 septembre 2011 00:19:52, Elijah Robison a écrit :
>>
>> ogr2ogr -f "GML" "/vsistdout/"
>> "C:\xData\CountyUpdate\GeoFix\feb16_polygons.shp" -sql "select * from
>> feb16_polygons where objectid= 2126"
>>
>> ogr2ogr -f "KML" "/vsistdout/"
>> "C:\xData\CountyUpdate\GeoFix\feb16_polygons.shp" -sql "select * from
>> feb16_polygons where objectid= 2126"
>>
>> ogr2ogr -f "GeoJSON" "/vsistdout/"
>> "C:\xData\CountyUpdate\GeoFix\feb16_polygons.shp" -sql "select * from
>> feb16_polygons where objectid= 2126"
>
> You can also add the BNA, PGDump, GeoRSS and GPX drivers to the list
>
About the GML driver:
I was just wondering where the .xsd file is written to when using:
ogr2ogr -f gml /vsistdout/. According to the gml file's
xsi:schemaLocation attribute, the schema file is `.xsd', see [1]. I
can't find `.xsd' locally.
When using /dev/stdout rather than /vsistdout/, I receive an error,
which tells me that the schema file can't be created, see [2].
Another observation with the gml driver: stdout is defined as an alias
for /vsistdout/ (rather than /dev/stdout). When using the alias,
xsi:schemaLocation tells me that the schema file is `stdout.xsd', see
[3]. I can't find `stdout.xsd' locally.
About other drivers producing text output:
There seem to be several options about how to alias (/dev/)stdout and
/vsistdout/. The current practice is perhaps somewhat inconsistent, see
[4]. IMO, Even's recently added /dev/stdout -> /vsistdout/ alias looks
most appropriate, I am however not so sure about non-Unix OSs.
Finally, only drv_pgdump.html seems to mention /vsistdout/ as an option
for writing to standard output, see [5]. Perhaps other relevant driver
pages should also mention this option ?
Would it be worth creating a ticket (or two) related to the above
observations?
Hermann
[1]
$ ogr2ogr -f gml /vsistdout/ test.shp
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ .xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:featureMember>
<ogr:test fid="F0">
(...)
[2]
ERROR 4: Failed to open file /dev/stdout.xsd for schema output.
[3]
$ ogr2ogr -f gml stdout test.shp
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ stdout.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:featureMember>
<ogr:test fid="F0">
(...)
[4]
./gpx/ogrgpxdatasource.cpp: if( EQUAL(pszFilename,"stdout") ||
EQUAL(pszFilename,"/vsistdout/"))
./gml/ogrgmldatasource.cpp: if( EQUAL(pszFilename,"stdout") ||
EQUAL(pszFilename,"/vsistdout/"))
./kml/ogrkmldatasource.cpp: if( EQUAL(pszName, "stdout") ||
EQUAL(pszName, "/vsistdout/") )
./csv/ogrcsvdriver.cpp: if (strcmp(pszName, "/dev/stdout") == 0)
./bna/ogrbnadatasource.cpp: if( EQUAL(pszFilename,"stdout") )
./georss/ogrgeorssdatasource.cpp: if( EQUAL(pszFilename,"stdout") )
./geojson/ogrgeojsondatasource.cpp: if( EQUAL( pszName, "stdout" ) )
[5]
$ find ogr/ -name '*.html' | xargs grep "/vsistdout/"
ogr/ogrsf_frmts/pgdump/drv_pgdump.html:to specify /vsistdout/ as output
file to output on the standard output.<p>
ogr/ogrsf_frmts/pgdump/drv_pgdump.html:% ogr2ogr --config PG_USE_COPY
YES -f PGDump /vsistdout/ abc.shp | psql -d my_dbname -f -
More information about the gdal-dev
mailing list