Hi,
I'm dumping some thoughts about the og2ogr output formats before
I start to implement it so that we can have a bit of discussion
and decide on the details of how this can be done.
First off, the basic idea is to generate an output on the file
system, and then have ogr2ogr generate the desired output,
and return it. The code would leverage the existing ogr2ogr
executable, not the ogr java bindings, so it would not have
platform dependency/threading/server segfault issues.
On the other side, we don't have much control on which outputs
are actually available in the ogr2ogr build.
The code attached to http://jira.codehaus.org/browse/GEOS-665
is quite old, and has an assumption that makes me wonder if
it's worth using at all: it hard codes in code the output
types that can be used to MapInfo, CSV, KML2. If you want
to add more, you have to write a class.
I see one problem with this approach:
- what if the user wants to write out an S57? Does he have
to make a custom build of the plugin for his GeoServer
version, that he may already have in production?
- what if one wants to specify custom parameters? OGR
output formats have many parameters
Wouldn't it be better to allow users to configure the outputs
instead? Say we add an ogr folder to the data dir, this
folder contains a number of property files, one for each
output format that we want to generate with ogr2ogr,
with the following content:
mapinfo.properties
----------------------------------------------
format=MapInfo (the -f parameter of ogr2ogr)
ofname=MapInfo (the output format name)
options=... (a list of options to be passed to ogr2ogr)
extension=.tab (the extension of the file(s) generated in output)
zip=true/false (can we return a single file?)
contentType=xyz (if we return a single file, what is its content type?)
And then have some generic code in GeoServer that
builds the output, builds a ogr2ogr invocation,
and returns the output file (or zips up all the
files in the resulting folder).
Opinions? (I know I had a similar conversation with Justin
some time ago and he was lending towards having one class
per possible output, thought in that case it was about
an OGR datastore using the java bindings).
Ah, for feeding ogr2ogr we either provide some GML2
or shapefiles. With gml2 we have the issue that
ogr2ogr does not read the schema, and thus will try
to make a guess on the data types.
With shapefiles we have issues when multiple shapefiles
are generated, which happens any time:
- the wfs GetFeature contains multiple Query elements
- the geometry type is "generic" and there are mixed
geometric types in the output, in which case a
shapefile per geometry type is generated
Of course I could circumvent the issue and have
ogr2ogr invoked on each of the shapefiles in output,
and then zip up the whole result (I'm actually kind
of lending towards this solution).
Again, opinions?
Cheers
Andrea
--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.