[gdal-dev] Issues with WFS driver

Even Rouault even.rouault at mines-paris.org
Sat May 25 03:35:32 PDT 2013


Le samedi 25 mai 2013 11:54:46, Ari Jolma a écrit :
> On 05/25/2013 12:37 PM, Even Rouault wrote:
> > If you output to a regular file, the GML driver will generate a .xsd
> > file with the schema alongside the GML file. If you output to
> > /vsistdout/ directly, then of course it is not possible to generate
> > the .xsd file. If you don't want to write on the filesystem, an
> > alternative would be to output to /vsimem/ so that you can read both
> > files afterwards. Another way if you want to use the .xsd generated by
> > the GML driver and keep the advantage of using streaming to vsistdout,
> > would be to: 1) Output to /vsimem/ , create the layer definition, but
> > write 0 feature. You just fetch the .xsd that can be used for
> > DescribeFeatureType 2) Output to /vsistdout/ with all the needed
> > features.
> 
> so, if I understand correctly:
> 
> my $postgis = Geo::OGR::Open($Datasource);
> my $postgis_layer = $postgis->Layer($Name);
> 
> my $vsi = '/vsimem/';

You need to specify a valid filename, something like "/vsimem/something.gml"

> my $gml = Geo::OGR::Driver('GML')->Create($vsi, {
>      TARGET_NAMESPACE => 'http://www.opengis.net/wfs', PREFIX => 'wfs' });
> my $gml_layer = $gml->CreateLayer($Name);
> 
> my $schema = $postgis_layer->GetLayerDefn;
> for my $i (0..$schema->GetFieldCount-1) {
>      $gml_layer->CreateField($schema->GetFieldDefn($i));
> }

Close the datasource at that point so files get flushed.

> 
> # at this point there should be a .xsd in /vsimem/, which could/should
> be used for the DescribeFeatureType request

Yes, there should be a "/vsimem/something.xsd" now

> 
> I'll try this later. Now I'm happy with the hack.
> 
> Ari

-- 
Geospatial professional services
http://even.rouault.free.fr/services.html


More information about the gdal-dev mailing list