Andrea suggested I put this on the dev list:
My original post:
The trunk wps gs:clipseems to work nicely in clipping to an arbitrary polygon. Very nice - thanks! Output to the usual shape-zip and gml formats.
I of course, want more, specifically, the all the OGR output formats I’m used to using with WFS using the OGR Output Format extension.
Anyone done this suggestion from Andrea yet?
"For the latter you probably to write a PPIO based on on ogr wfs output format, based on the same principles
as ShapeZipPPIO:
/home/aaime/devel/git-gs/src/extension/wps/wps-core/src/main/java/org/geoserver/wps/ppio/ShapeZipPPIO.java"
Well, I tried briefly, almost getting there with the code below, but failing with this comment from Andrea:
Well, working a little bit more, this seems to work:
public void encode(Object value, OutputStream os) throws Exception {
//SimpleFeatureCollection fc = (SimpleFeatureCollection) value;
Ogr2OgrOutputFormat of = new Ogr2OgrOutputFormat(null);
//ShapeZipOutputFormat of = new ShapeZipOutputFormat();FeatureCollection features = (FeatureCollection) value;
//SimpleFeatureType featureType = (SimpleFeatureType)
features.getSchema();FeatureCollectionType fc =
WfsFactory.eINSTANCE.createFeatureCollectionType();
fc.getFeature().add( features );//FeatureCollectionType fct = (FeatureCollectionType)value;
of.write(fc, os, null);
}
Now, I’m trying to figure out how to specify and get of.write to see the
correct OGR_Format. In the current one, it uses this:
// figure out which output format we’re going to generate
GetFeatureType gft = (GetFeatureType) getFeature.getParameters()[0];
OgrFormat format = formats.get(gft.getOutputFormat());
Which seems odd. Guess I have to figure if there is a way to pass output
parameters to PPIO.
Nope, there is no way, a PPIO is devoted to turn a java class into some serialization format and back, both of which have to be known in advance.
In order to make this pluggable we probably have to resort to some intermediation, like a pluggable PPIO factory that can emit various PPIO (and can do so dynamically).
Hmmm… an easier way could be to have ComplexPPIO return not just one mime type, but a list of them, and then change the 11 points in the code that use the existing getMimeType() method to use a getMimeTypes() instead.
I would like to hear from Justin as well about this one, can you start a discussion topic on geoserver-devel about this?
Thanks,
Roger