[Geoserver-devel] WPS Clip and Ship with OGR output

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

On Fri, Sep 9, 2011 at 4:26 PM, Roger Bedell <sylvanascent@anonymised.com> wrote:

My original post:
The trunk wps gs:clip seems 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?

Just a quick note, the idea is still the same as I suggested to Roger, add
some some dynamic bits to the lookup of PPIOs so that we can leverage
what's in the spring context (in particular, the wfs encoders), but I'm
not sure about the best route to get there.

The other thing is that these objects would be just output encoders,
they would be PPO. How to mark that a PPIO is assimetric?
I guess the most natural way would be to have separate PPI and PPO.

Ah, Roger, the incoming week is less likely than usual to see a good
conversation on this one as good part of the GeoServer developers
are in Denver at FOSS4G (http://2011.foss4g.org)

Cheers
Andrea

--
-------------------------------------------------------
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf

-------------------------------------------------------

Hello,
Has anyone put any thought into this? Or perhaps give me some pointers
so I can hack around in more or less the right direction?

Thanks,
Roger

On Sun, Sep 11, 2011 at 5:48 PM, Andrea Aime
<andrea.aime@anonymised.com> wrote:

On Fri, Sep 9, 2011 at 4:26 PM, Roger Bedell <sylvanascent@anonymised.com> wrote:

My original post:
The trunk wps gs:clip seems 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?

Just a quick note, the idea is still the same as I suggested to Roger, add
some some dynamic bits to the lookup of PPIOs so that we can leverage
what's in the spring context (in particular, the wfs encoders), but I'm
not sure about the best route to get there.

The other thing is that these objects would be just output encoders,
they would be PPO. How to mark that a PPIO is assimetric?
I guess the most natural way would be to have separate PPI and PPO.

Ah, Roger, the incoming week is less likely than usual to see a good
conversation on this one as good part of the GeoServer developers
are in Denver at FOSS4G (http://2011.foss4g.org)

Cheers
Andrea

--
-------------------------------------------------------
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf

-------------------------------------------------------