Quantcast

GML feature collection Problem (WPS execute XML request)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

GML feature collection Problem (WPS execute XML request)

BERTHET Arnaud
Hello list (again),

****PLEASE NOTE THAT MY LAST MESSAGE WAS SEND BY ERROR AND WAS NOT THE FINAL VERSION (THE SAVE BUTTON IS JUST BESIDE SEND BUTTON ....), SORRY FOR THE DISTURB****

I'm using deegree3 WPS implementation to build my own WPS labelling Process using the labbeling library PAL (http://pal.heig-vd.ch/). My process should be able to get different layers that contains features through GML document.
Is there an easy way to send (by val) GML document (with many features) through an XML execute request and then to recover the feature collection contained in this document (With the org.deegree.gml.GMLStreamReader.readFeatureCollection() method) ?

I try lots of different inputs but none of them worked... I often get the following parsing error : "xsi:schemaLocation is missing" or "xsi:schemaLocation is invalid" or "feature member is not a GML document"

I can see that in the degree3-wps-demo client there is a lot of different examples that show how to use complex input but always with a single geometry (it work fine) and none of them are showing how to get feature or feature collection through GML input. I just try to find in the GML 3.1 spec (yummy!) how to build valid GML document that contain features but all the tests I made with degree3 WPS failed.

Here is the part of my describe process where I describe the GML input :

<ComplexInput>
        <Identifier>GMLInput1</Identifier>
        <Title>GMLInput1</Title>
        <DefaultFormat mimeType="text/xml" encoding="UTF-8" schema="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd"/>
 </ComplexInput>

I try to put a lots of different schema but they didn't seems to work as well.

Here is the kind of XML execute request I'd like to send (this request contain only one feature the the aim is of course, to have more features):

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<wps:Execute service="WPS" version="1.0.0"
             xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1"
             xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://www.opengis.net/wps/1.0.0
             http://schemas.opengis.net/wps/1.0.0/wpsExecute_request.xsd">
    <ows:Identifier>ComplexeProcessTest</ows:Identifier>
    <wps:DataInputs>
        <wps:Input>
            <ows:Identifier>GMLInput1</ows:Identifier>
            <wps:Data>
                <wps:ComplexData>
                    <FeatureCollection xmlns="http://www.opengis.net/gml" xmlns:ogo="http://ogo/ogo" xsi:schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd">
                        <featureMember>
                            <ogo:traces fid="traces.1">
                                <ogo:name>Une trace de test</ogo:name>
                                <ogo:the_geom>
                                    <LineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
                                        <coordinates decimal="." cs="," ts=" ">
                                            2.06542447,47.51719581 8.0859335,41.83682585 18.41308279,48.22467216
                                        </coordinates>
                                    </LineString>
                                </ogo:the_geom>
                            </ogo:traces>
                        </featureMember>
                    </FeatureCollection>
                </wps:ComplexData>
            </wps:Data>
        </wps:Input>
    </wps:DataInputs>
...

As you can see there is a specific namespace for the features(here "ogo"). I think it's maybe a key of my problem but I generate different GML document and they always contains that kind of specific namespace for the features.

And finally there is a part of my processlet implementation :

    @Override
    public void process(ProcessletInputs pi, ProcessletOutputs po, ProcessletExecutionInfo pei) throws ProcessletException {
        //on récupère tout les inputs. Attention a bien caster les input dans le type prévu.
        ComplexInput gmlInput1 = (ComplexInput) pi.getParameter("GMLInput1");

        this.logInfoComplexeInput(gmlInput1);
 
        Geometry maGeom = null;
        Feature maFeature = null;
        FeatureCollection myFeatureCollection = null;

        try {
            //lecture d'un input GML
            XMLStreamReader xmlReader = gmlInput1.getValueAsXMLStream();
            GMLStreamReader gmlReader = GMLInputFactory.createGMLStreamReader(GML_31, xmlReader);
            //GMLStreamReader gmlReader = GMLInputFactory.createGMLStreamReader(GMLVersion.GML_2 , xmlReader);

            try {
                maGeom = gmlReader.readGeometry();
                this.logInfoGeometry(maGeom);
            } catch (Exception ex) {
                System.out.println("GEOMETRY ERROR : ");
                ex.printStackTrace();
            }
            try {
                maFeature = gmlReader.readFeature();
                this.logInfoFeature(maFeature);
            } catch (Exception ex) {
                System.out.println("FEATURE ERROR : ");
                ex.printStackTrace();
            }
            try {
                myFeatureCollection = gmlReader.readFeatureCollection();
                System.out.println("");
                Iterator<Feature> it = myFeatureCollection.iterator();
                while(it.hasNext()){
                    Feature next = it.next();
                    this.logInfoFeature(next);
                }
                System.out.println(myFeatureCollection);
                //this.logInfoFeatures(myFeatureCollection);
            } catch (XMLStreamException streamEx) {
                System.out.println("StreamException : " + streamEx.getMessage());
            } catch (XMLParsingException parseEx) {
                System.out.println("Parsing Exception : " + parseEx.getMessage());
            } catch (UnknownCRSException unknow) {
                System.out.println("unknow Exception : " + unknow.getMessage());
            }

        } catch (Exception e) {
            throw new ProcessletException("Error parsing parameter " + gmlInput1.getIdentifier() + ": "
                    + e.getMessage());
        }
...

I know that this code will raise some exceptions but I expected that at least one of the reader method works (in this case the readFeatureCollection() ).
I think I can avoid the problem by using JSon input but it would be fine if it can works with XML request including GML input.

Thanks in advance, Regards.
Arnaud Berthet
------------------------------------------------------------------------------

_______________________________________________
deegree-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/deegree-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: GML feature collection Problem (WPS execute XML request)

Markus Schneider-4-3
Hi Arnaud,

by using the GMLStreamReader you're absolutely on the right track, the only missing part is the providing of a correct
GML application schema.

Basically, the GMLStreamReader always needs a definition of the features it is going to read, which is usually specified
as a GML application schema. Your example request provides the following attribute for this purpose:

xsi:schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd

There a several things wrong with it:

- You didn't provide the namespace binding for xsi ("xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance")
- The value in an xsi:schemaLocation attribute must consist of namespace/URL pairs, not just a single value
- Using the GML core schema in the schemaLocation is not enough, you have to specify the URL of a document that actually
defines the feature types. The core GML schemas just provide the blocks for building application schemas.

Basically, a GML application schema is an XSD document, that defines elements which are feature types. The following
request returns an example application schema
http://demo.deegree.org/deegree-wfs/services?service=WFS&version=1.1.0&request=GetFeature&typename=app:Place&namespace=xmlns(app=http://www.deegree.org/app)&outputformat=text%2Fxml%3B+subtype%3Dgml%2F3.1.1

Additionally, it's usually a better idea to specify the application schema used by the GMLStreamReader manually, so it
doesn't depend on a correct xsi:schemaLocation attribute. Also, when done in Processlet#init(), it's much more effective
(building the ApplicationSchema can be rather costly), when it's done only once.

You may want to have a look at this wiki page as well: http://wiki.deegree.org/deegreeWiki/deegree3/HowToWorkWithGML

Best regards,
Markus

P.S.: Be warned that the GML subsystem API has not been stabilized yet -- it should work for most application schemas,
and we're going to fix it if you encounter problems with your documents, but the interface may still change in the
future. BTW, this is the case with all other parts in the deegree API as well.


BERTHET Arnaud wrote:

> Hello list (again),
>
> ****PLEASE NOTE THAT MY LAST MESSAGE WAS SEND BY ERROR AND WAS NOT THE FINAL VERSION (THE SAVE BUTTON IS JUST BESIDE SEND BUTTON ....), SORRY FOR THE DISTURB****
>
> I'm using deegree3 WPS implementation to build my own WPS labelling Process using the labbeling library PAL (http://pal.heig-vd.ch/). My process should be able to get different layers that contains features through GML document.
> Is there an easy way to send (by val) GML document (with many features) through an XML execute request and then to recover the feature collection contained in this document (With the org.deegree.gml.GMLStreamReader.readFeatureCollection() method) ?
>
> I try lots of different inputs but none of them worked... I often get the following parsing error : "xsi:schemaLocation is missing" or "xsi:schemaLocation is invalid" or "feature member is not a GML document"
>
> I can see that in the degree3-wps-demo client there is a lot of different examples that show how to use complex input but always with a single geometry (it work fine) and none of them are showing how to get feature or feature collection through GML input. I just try to find in the GML 3.1 spec (yummy!) how to build valid GML document that contain features but all the tests I made with degree3 WPS failed.
>
> Here is the part of my describe process where I describe the GML input :
>
> <ComplexInput>
>         <Identifier>GMLInput1</Identifier>
>         <Title>GMLInput1</Title>
>         <DefaultFormat mimeType="text/xml" encoding="UTF-8" schema="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd"/>
>  </ComplexInput>
>
> I try to put a lots of different schema but they didn't seems to work as well.
>
> Here is the kind of XML execute request I'd like to send (this request contain only one feature the the aim is of course, to have more features):
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <wps:Execute service="WPS" version="1.0.0"
>              xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1"
>              xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>              xsi:schemaLocation="http://www.opengis.net/wps/1.0.0
>              http://schemas.opengis.net/wps/1.0.0/wpsExecute_request.xsd">
>     <ows:Identifier>ComplexeProcessTest</ows:Identifier>
>     <wps:DataInputs>
>         <wps:Input>
>             <ows:Identifier>GMLInput1</ows:Identifier>
>             <wps:Data>
>                 <wps:ComplexData>
>                     <FeatureCollection xmlns="http://www.opengis.net/gml" xmlns:ogo="http://ogo/ogo" xsi:schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd">
>                         <featureMember>
>                             <ogo:traces fid="traces.1">
>                                 <ogo:name>Une trace de test</ogo:name>
>                                 <ogo:the_geom>
>                                     <LineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
>                                         <coordinates decimal="." cs="," ts=" ">
>                                             2.06542447,47.51719581 8.0859335,41.83682585 18.41308279,48.22467216
>                                         </coordinates>
>                                     </LineString>
>                                 </ogo:the_geom>
>                             </ogo:traces>
>                         </featureMember>
>                     </FeatureCollection>
>                 </wps:ComplexData>
>             </wps:Data>
>         </wps:Input>
>     </wps:DataInputs>
> ...
>
> As you can see there is a specific namespace for the features(here "ogo"). I think it's maybe a key of my problem but I generate different GML document and they always contains that kind of specific namespace for the features.
>
> And finally there is a part of my processlet implementation :
>
>     @Override
>     public void process(ProcessletInputs pi, ProcessletOutputs po, ProcessletExecutionInfo pei) throws ProcessletException {
>         //on récupère tout les inputs. Attention a bien caster les input dans le type prévu.
>         ComplexInput gmlInput1 = (ComplexInput) pi.getParameter("GMLInput1");
>
>         this.logInfoComplexeInput(gmlInput1);
>  
>         Geometry maGeom = null;
>         Feature maFeature = null;
>         FeatureCollection myFeatureCollection = null;
>
>         try {
>             //lecture d'un input GML
>             XMLStreamReader xmlReader = gmlInput1.getValueAsXMLStream();
>             GMLStreamReader gmlReader = GMLInputFactory.createGMLStreamReader(GML_31, xmlReader);
>             //GMLStreamReader gmlReader = GMLInputFactory.createGMLStreamReader(GMLVersion.GML_2 , xmlReader);
>
>             try {
>                 maGeom = gmlReader.readGeometry();
>                 this.logInfoGeometry(maGeom);
>             } catch (Exception ex) {
>                 System.out.println("GEOMETRY ERROR : ");
>                 ex.printStackTrace();
>             }
>             try {
>                 maFeature = gmlReader.readFeature();
>                 this.logInfoFeature(maFeature);
>             } catch (Exception ex) {
>                 System.out.println("FEATURE ERROR : ");
>                 ex.printStackTrace();
>             }
>             try {
>                 myFeatureCollection = gmlReader.readFeatureCollection();
>                 System.out.println("");
>                 Iterator<Feature> it = myFeatureCollection.iterator();
>                 while(it.hasNext()){
>                     Feature next = it.next();
>                     this.logInfoFeature(next);
>                 }
>                 System.out.println(myFeatureCollection);
>                 //this.logInfoFeatures(myFeatureCollection);
>             } catch (XMLStreamException streamEx) {
>                 System.out.println("StreamException : " + streamEx.getMessage());
>             } catch (XMLParsingException parseEx) {
>                 System.out.println("Parsing Exception : " + parseEx.getMessage());
>             } catch (UnknownCRSException unknow) {
>                 System.out.println("unknow Exception : " + unknow.getMessage());
>             }
>
>         } catch (Exception e) {
>             throw new ProcessletException("Error parsing parameter " + gmlInput1.getIdentifier() + ": "
>                     + e.getMessage());
>         }
> ...
>
> I know that this code will raise some exceptions but I expected that at least one of the reader method works (in this case the readFeatureCollection() ).
> I think I can avoid the problem by using JSon input but it would be fine if it can works with XML request including GML input.
>
> Thanks in advance, Regards.
> Arnaud Berthet
> ------------------------------------------------------------------------------
>
> _______________________________________________
> deegree-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/deegree-devel

--
Markus Schneider

l a t / l o n  GmbH
Aennchenstrasse 19           53177 Bonn, Germany
phone ++49 +228 184960       fax ++49 +228 1849629
http://www.lat-lon.de        http://www.deegree.org


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


_______________________________________________
deegree-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/deegree-devel

signature.asc (268 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

RE : GML feature collection Problem (WPS execute XML request)

BERTHET Arnaud
Hello,

Thanks to Markus' answer, I had been able to solve my GML problem! :) I can now read feature collection through GML input.

Describe process of my GML input :

<InputParameters>
     <ComplexInput>
         <Identifier>GMLInput1</Identifier>
         <Title>GMLInput1</Title>
         <DefaultFormat mimeType="text/xml "encoding="UTF-8" schema="http://schemas.opengis.net/gml/3.1.1/base/feature.xsd"/>
     </ComplexInput>
</InputParameters>

We can see that I changed the schema for a more specific one that describe feature and feature collection.

The part of the Processlet implementation :

public void process(ProcessletInputs pi, ProcessletOutputs po, ProcessletExecutionInfo pei) throws ProcessletException {
        //on récupère tout les inputs. Attention a bien caster les input dans le type prévu.
        ComplexInput gmlInput1 = (ComplexInput) pi.getParameter("GMLInput1");

        this.logInfoComplexeInput(gmlInput1);

        try {
            //lecture d'un input GML

            XMLStreamReader xmlReader = gmlInput1.getValueAsXMLStream();

            GMLStreamReader gmlReader = GMLInputFactory.createGMLStreamReader(GML_31, xmlReader);

            String schemaURL = "file:///the/url/of/the/schema/that/describe/your/feature/WpsPalFeature.xsd";
            String wfsSchemaURL = "http://schemas.opengis.net/wfs/1.1.0/wfs.xsd";
            ApplicationSchemaXSDDecoder decoder = new ApplicationSchemaXSDDecoder(GMLVersion.GML_31, null, schemaURL, wfsSchemaURL);
            gmlReader.setApplicationSchema(decoder.extractFeatureTypeSchema());

            try {

                FeatureCollection myFeatureCollection = gmlReader.readFeatureCollection();
                System.out.println("");
                Iterator<Feature> it = myFeatureCollection.iterator();
                while (it.hasNext()) {
                    Feature next = it.next();
                    this.logInfoFeature(next);
                    ...
                }
                System.out.println(myFeatureCollection);
            } catch (XMLStreamException streamEx) {
                ...

    }

In the processlet, i added the schemas for the GMLReader manually. One schema that describe the feature(s) and one other for WFS.

The XSD schema that describe the feature collection :

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
    targetNamespace="http://www.deegree.org/pal"
    xmlns:pal="http://www.deegree.org/pal"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:gml="http://www.opengis.net/gml"
    attributeFormDefault="unqualified"
    elementFormDefault="qualified"
    >
    <xsd:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/feature.xsd"/>
    <xsd:element name="JPalFeature" substitutionGroup="gml:_Feature" type="pal:JPalFeatureType">
    </xsd:element>
    <xsd:complexType name="JPalFeatureType">
        <xsd:complexContent>
            <xsd:extension base="gml:AbstractFeatureType">
                <xsd:sequence>
                    <!-- simple (string) valued property 'name' -->
                    <xsd:element name="LabelText" type="xsd:string" />
                    <xsd:element name="the_geom" type="gml:GeometryPropertyType" nillable="false" minOccurs="1" maxOccurs="1"/>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
</xsd:schema>

This schema describe a feature collection that contain only one feature (which is made of a Label text (LabelText) and a geometry (the_geom))

The XML request that contain GML input with feature collection :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<wps:Execute service="WPS" version="1.0.0"
             xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1"
             xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://www.opengis.net/wps/1.0.0
             http://schemas.opengis.net/wps/1.0.0/wpsExecute_request.xsd">
    <ows:Identifier>ComplexeProcessTest</ows:Identifier>
    <wps:DataInputs>
        <wps:Input>
            <ows:Identifier>GMLInput1</ows:Identifier>
            <wps:Data>
                <wps:ComplexData>
                    <wfs:FeatureCollection numberOfFeatures='1' xmlns="http://www.opengis.net/gml" xmlns:ogo="http://www.deegree.org/pal" xmlns:gml="http://www.opengis.net/gml" xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:schemaLocation="http://www.deegree.org/pal file:///home/arnaud/Documents/HEIG-VD/3eme/TB/wpsProjects/deegree-wps-demo/src/main/resources/WpsPalFeature.xsd http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
                        <featureMember>
                            <ogo:JPalFeature fid="traces.1">
                                <ogo:LabelText>Une trace de test</ogo:LabelText>
                                <ogo:the_geom>
                                    <LineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
                                        <coordinates decimal="." cs="," ts="/">
                                            2.06542447,47.51719581/8.0859335,41.83682585/18.41308279,48.22467216
                                        </coordinates>
                                    </LineString>
                                </ogo:the_geom>
                            </ogo:JPalFeature>
                        </featureMember>
                    </wfs:FeatureCollection>
                </wps:ComplexData>
            </wps:Data>
        </wps:Input>
    </wps:DataInputs>
...

Maybe this functional example will help someone using feature collection with GML input :).
I'll try to build my GML reader and set the schema to it in the init() method of the process cause actually the process is "slow"... (2-3 sec without processing anything except reading input).
I think i can start to build my process and test it with many more features ;)

Thanks again for answer,
Best Regards.
Arnaud
________________________________________
De : Markus Schneider [[hidden email]]
Date d'envoi : lundi 31 mai 2010 10:50
À : [hidden email]
Objet : Re: [deegree-devel] GML feature collection Problem (WPS execute XML request)

Hi Arnaud,

by using the GMLStreamReader you're absolutely on the right track, the only missing part is the providing of a correct
GML application schema.

Basically, the GMLStreamReader always needs a definition of the features it is going to read, which is usually specified
as a GML application schema. Your example request provides the following attribute for this purpose:

xsi:schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd

There a several things wrong with it:

- You didn't provide the namespace binding for xsi ("xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance")
- The value in an xsi:schemaLocation attribute must consist of namespace/URL pairs, not just a single value
- Using the GML core schema in the schemaLocation is not enough, you have to specify the URL of a document that actually
defines the feature types. The core GML schemas just provide the blocks for building application schemas.

Basically, a GML application schema is an XSD document, that defines elements which are feature types. The following
request returns an example application schema
http://demo.deegree.org/deegree-wfs/services?service=WFS&version=1.1.0&request=GetFeature&typename=app:Place&namespace=xmlns(app=http://www.deegree.org/app)&outputformat=text%2Fxml%3B+subtype%3Dgml%2F3.1.1

Additionally, it's usually a better idea to specify the application schema used by the GMLStreamReader manually, so it
doesn't depend on a correct xsi:schemaLocation attribute. Also, when done in Processlet#init(), it's much more effective
(building the ApplicationSchema can be rather costly), when it's done only once.

You may want to have a look at this wiki page as well: http://wiki.deegree.org/deegreeWiki/deegree3/HowToWorkWithGML

Best regards,
Markus

P.S.: Be warned that the GML subsystem API has not been stabilized yet -- it should work for most application schemas,
and we're going to fix it if you encounter problems with your documents, but the interface may still change in the
future. BTW, this is the case with all other parts in the deegree API as well.


BERTHET Arnaud wrote:

> Hello list (again),
>
> ****PLEASE NOTE THAT MY LAST MESSAGE WAS SEND BY ERROR AND WAS NOT THE FINAL VERSION (THE SAVE BUTTON IS JUST BESIDE SEND BUTTON ....), SORRY FOR THE DISTURB****
>
> I'm using deegree3 WPS implementation to build my own WPS labelling Process using the labbeling library PAL (http://pal.heig-vd.ch/). My process should be able to get different layers that contains features through GML document.
> Is there an easy way to send (by val) GML document (with many features) through an XML execute request and then to recover the feature collection contained in this document (With the org.deegree.gml.GMLStreamReader.readFeatureCollection() method) ?
>
> I try lots of different inputs but none of them worked... I often get the following parsing error : "xsi:schemaLocation is missing" or "xsi:schemaLocation is invalid" or "feature member is not a GML document"
>
> I can see that in the degree3-wps-demo client there is a lot of different examples that show how to use complex input but always with a single geometry (it work fine) and none of them are showing how to get feature or feature collection through GML input. I just try to find in the GML 3.1 spec (yummy!) how to build valid GML document that contain features but all the tests I made with degree3 WPS failed.
>
> Here is the part of my describe process where I describe the GML input :
>
> <ComplexInput>
>         <Identifier>GMLInput1</Identifier>
>         <Title>GMLInput1</Title>
>         <DefaultFormat mimeType="text/xml" encoding="UTF-8" schema="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd"/>
>  </ComplexInput>
>
> I try to put a lots of different schema but they didn't seems to work as well.
>
> Here is the kind of XML execute request I'd like to send (this request contain only one feature the the aim is of course, to have more features):
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <wps:Execute service="WPS" version="1.0.0"
>              xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1"
>              xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>              xsi:schemaLocation="http://www.opengis.net/wps/1.0.0
>              http://schemas.opengis.net/wps/1.0.0/wpsExecute_request.xsd">
>     <ows:Identifier>ComplexeProcessTest</ows:Identifier>
>     <wps:DataInputs>
>         <wps:Input>
>             <ows:Identifier>GMLInput1</ows:Identifier>
>             <wps:Data>
>                 <wps:ComplexData>
>                     <FeatureCollection xmlns="http://www.opengis.net/gml" xmlns:ogo="http://ogo/ogo" xsi:schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd">
>                         <featureMember>
>                             <ogo:traces fid="traces.1">
>                                 <ogo:name>Une trace de test</ogo:name>
>                                 <ogo:the_geom>
>                                     <LineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
>                                         <coordinates decimal="." cs="," ts=" ">
>                                             2.06542447,47.51719581 8.0859335,41.83682585 18.41308279,48.22467216
>                                         </coordinates>
>                                     </LineString>
>                                 </ogo:the_geom>
>                             </ogo:traces>
>                         </featureMember>
>                     </FeatureCollection>
>                 </wps:ComplexData>
>             </wps:Data>
>         </wps:Input>
>     </wps:DataInputs>
> ...
>
> As you can see there is a specific namespace for the features(here "ogo"). I think it's maybe a key of my problem but I generate different GML document and they always contains that kind of specific namespace for the features.
>
> And finally there is a part of my processlet implementation :
>
>     @Override
>     public void process(ProcessletInputs pi, ProcessletOutputs po, ProcessletExecutionInfo pei) throws ProcessletException {
>         //on récupère tout les inputs. Attention a bien caster les input dans le type prévu.
>         ComplexInput gmlInput1 = (ComplexInput) pi.getParameter("GMLInput1");
>
>         this.logInfoComplexeInput(gmlInput1);
>
>         Geometry maGeom = null;
>         Feature maFeature = null;
>         FeatureCollection myFeatureCollection = null;
>
>         try {
>             //lecture d'un input GML
>             XMLStreamReader xmlReader = gmlInput1.getValueAsXMLStream();
>             GMLStreamReader gmlReader = GMLInputFactory.createGMLStreamReader(GML_31, xmlReader);
>             //GMLStreamReader gmlReader = GMLInputFactory.createGMLStreamReader(GMLVersion.GML_2 , xmlReader);
>
>             try {
>                 maGeom = gmlReader.readGeometry();
>                 this.logInfoGeometry(maGeom);
>             } catch (Exception ex) {
>                 System.out.println("GEOMETRY ERROR : ");
>                 ex.printStackTrace();
>             }
>             try {
>                 maFeature = gmlReader.readFeature();
>                 this.logInfoFeature(maFeature);
>             } catch (Exception ex) {
>                 System.out.println("FEATURE ERROR : ");
>                 ex.printStackTrace();
>             }
>             try {
>                 myFeatureCollection = gmlReader.readFeatureCollection();
>                 System.out.println("");
>                 Iterator<Feature> it = myFeatureCollection.iterator();
>                 while(it.hasNext()){
>                     Feature next = it.next();
>                     this.logInfoFeature(next);
>                 }
>                 System.out.println(myFeatureCollection);
>                 //this.logInfoFeatures(myFeatureCollection);
>             } catch (XMLStreamException streamEx) {
>                 System.out.println("StreamException : " + streamEx.getMessage());
>             } catch (XMLParsingException parseEx) {
>                 System.out.println("Parsing Exception : " + parseEx.getMessage());
>             } catch (UnknownCRSException unknow) {
>                 System.out.println("unknow Exception : " + unknow.getMessage());
>             }
>
>         } catch (Exception e) {
>             throw new ProcessletException("Error parsing parameter " + gmlInput1.getIdentifier() + ": "
>                     + e.getMessage());
>         }
> ...
>
> I know that this code will raise some exceptions but I expected that at least one of the reader method works (in this case the readFeatureCollection() ).
> I think I can avoid the problem by using JSon input but it would be fine if it can works with XML request including GML input.
>
> Thanks in advance, Regards.
> Arnaud Berthet
> ------------------------------------------------------------------------------
>
> _______________________________________________
> deegree-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/deegree-devel


--
Markus Schneider

l a t / l o n  GmbH
Aennchenstrasse 19           53177 Bonn, Germany
phone ++49 +228 184960       fax ++49 +228 1849629
http://www.lat-lon.de        http://www.deegree.org


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

_______________________________________________
deegree-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/deegree-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: RE : GML feature collection Problem (WPS execute XML request)

Markus Schneider-4-3
Hi Arnaud,

that's good news :-) -- and thanks for providing the info back to the list.

Here are two additional clues to make this example even more comprehensive:

- Instead of using "http://schemas.opengis.net/gml/3.1.1/base/feature.xsd", one should probably provide a URL to the
application schema also in the input parameter description, so that WPS clients can learn about it as well.
- If you plan on processing large numbers of features in your input, you can improve scalability / memory consumption by
not using gmlReader.readFeatureCollection(), as it will read all features into memory at once. If your process allows
it, I would suggest to process the features in a streaming fashion, one by one. This would mean to manually skip the
XMLStreamReader to the first feature element inside the feature collection (you may want to use
org.deegree.commons.xml.stax.StAXParsingHelper#skipElement(XMLStreamReader) for this). Then, use gmlReader.readFeature()
to retrieve only a single member feature from the input. After processing it, skip to the next feature element and read
it. And so on. This will improve scalability of your process drastically and enable it to cope with arbitrarily sized
inputs without running into memory problems -- at least when providing the input parameter by reference (if given inline
in the request document, it currently still happens that the XML is cached internally in the WPS, so it will not scale
as well).

Best regards,
Markus


BERTHET Arnaud wrote:

> Hello,
>
> Thanks to Markus' answer, I had been able to solve my GML problem! :) I can now read feature collection through GML input.
>
> Describe process of my GML input :
>
> <InputParameters>
>      <ComplexInput>
>          <Identifier>GMLInput1</Identifier>
>          <Title>GMLInput1</Title>
>          <DefaultFormat mimeType="text/xml "encoding="UTF-8" schema="http://schemas.opengis.net/gml/3.1.1/base/feature.xsd"/>
>      </ComplexInput>
> </InputParameters>
>
> We can see that I changed the schema for a more specific one that describe feature and feature collection.
>
> The part of the Processlet implementation :
>
> public void process(ProcessletInputs pi, ProcessletOutputs po, ProcessletExecutionInfo pei) throws ProcessletException {
>         //on récupère tout les inputs. Attention a bien caster les input dans le type prévu.
>         ComplexInput gmlInput1 = (ComplexInput) pi.getParameter("GMLInput1");
>
>         this.logInfoComplexeInput(gmlInput1);
>
>         try {
>             //lecture d'un input GML
>
>             XMLStreamReader xmlReader = gmlInput1.getValueAsXMLStream();
>
>             GMLStreamReader gmlReader = GMLInputFactory.createGMLStreamReader(GML_31, xmlReader);
>
>             String schemaURL = "file:///the/url/of/the/schema/that/describe/your/feature/WpsPalFeature.xsd";
>             String wfsSchemaURL = "http://schemas.opengis.net/wfs/1.1.0/wfs.xsd";
>             ApplicationSchemaXSDDecoder decoder = new ApplicationSchemaXSDDecoder(GMLVersion.GML_31, null, schemaURL, wfsSchemaURL);
>             gmlReader.setApplicationSchema(decoder.extractFeatureTypeSchema());
>
>             try {
>
>                 FeatureCollection myFeatureCollection = gmlReader.readFeatureCollection();
>                 System.out.println("");
>                 Iterator<Feature> it = myFeatureCollection.iterator();
>                 while (it.hasNext()) {
>                     Feature next = it.next();
>                     this.logInfoFeature(next);
>                     ...
>                 }
>                 System.out.println(myFeatureCollection);
>             } catch (XMLStreamException streamEx) {
>                 ...
>
>     }
>
> In the processlet, i added the schemas for the GMLReader manually. One schema that describe the feature(s) and one other for WFS.
>
> The XSD schema that describe the feature collection :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema
>     targetNamespace="http://www.deegree.org/pal"
>     xmlns:pal="http://www.deegree.org/pal"
>     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>     xmlns:gml="http://www.opengis.net/gml"
>     attributeFormDefault="unqualified"
>     elementFormDefault="qualified"
>     >
>     <xsd:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/feature.xsd"/>
>     <xsd:element name="JPalFeature" substitutionGroup="gml:_Feature" type="pal:JPalFeatureType">
>     </xsd:element>
>     <xsd:complexType name="JPalFeatureType">
>         <xsd:complexContent>
>             <xsd:extension base="gml:AbstractFeatureType">
>                 <xsd:sequence>
>                     <!-- simple (string) valued property 'name' -->
>                     <xsd:element name="LabelText" type="xsd:string" />
>                     <xsd:element name="the_geom" type="gml:GeometryPropertyType" nillable="false" minOccurs="1" maxOccurs="1"/>
>                 </xsd:sequence>
>             </xsd:extension>
>         </xsd:complexContent>
>     </xsd:complexType>
> </xsd:schema>
>
> This schema describe a feature collection that contain only one feature (which is made of a Label text (LabelText) and a geometry (the_geom))
>
> The XML request that contain GML input with feature collection :
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <wps:Execute service="WPS" version="1.0.0"
>              xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1"
>              xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>              xsi:schemaLocation="http://www.opengis.net/wps/1.0.0
>              http://schemas.opengis.net/wps/1.0.0/wpsExecute_request.xsd">
>     <ows:Identifier>ComplexeProcessTest</ows:Identifier>
>     <wps:DataInputs>
>         <wps:Input>
>             <ows:Identifier>GMLInput1</ows:Identifier>
>             <wps:Data>
>                 <wps:ComplexData>
>                     <wfs:FeatureCollection numberOfFeatures='1' xmlns="http://www.opengis.net/gml" xmlns:ogo="http://www.deegree.org/pal" xmlns:gml="http://www.opengis.net/gml" xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:schemaLocation="http://www.deegree.org/pal file:///home/arnaud/Documents/HEIG-VD/3eme/TB/wpsProjects/deegree-wps-demo/src/main/resources/WpsPalFeature.xsd http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
>                         <featureMember>
>                             <ogo:JPalFeature fid="traces.1">
>                                 <ogo:LabelText>Une trace de test</ogo:LabelText>
>                                 <ogo:the_geom>
>                                     <LineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
>                                         <coordinates decimal="." cs="," ts="/">
>                                             2.06542447,47.51719581/8.0859335,41.83682585/18.41308279,48.22467216
>                                         </coordinates>
>                                     </LineString>
>                                 </ogo:the_geom>
>                             </ogo:JPalFeature>
>                         </featureMember>
>                     </wfs:FeatureCollection>
>                 </wps:ComplexData>
>             </wps:Data>
>         </wps:Input>
>     </wps:DataInputs>
> ...
>
> Maybe this functional example will help someone using feature collection with GML input :).
> I'll try to build my GML reader and set the schema to it in the init() method of the process cause actually the process is "slow"... (2-3 sec without processing anything except reading input).
> I think i can start to build my process and test it with many more features ;)
>
> Thanks again for answer,
> Best Regards.
> Arnaud
> ________________________________________
> De : Markus Schneider [[hidden email]]
> Date d'envoi : lundi 31 mai 2010 10:50
> À : [hidden email]
> Objet : Re: [deegree-devel] GML feature collection Problem (WPS execute XML request)
>
> Hi Arnaud,
>
> by using the GMLStreamReader you're absolutely on the right track, the only missing part is the providing of a correct
> GML application schema.
>
> Basically, the GMLStreamReader always needs a definition of the features it is going to read, which is usually specified
> as a GML application schema. Your example request provides the following attribute for this purpose:
>
> xsi:schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd
>
> There a several things wrong with it:
>
> - You didn't provide the namespace binding for xsi ("xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance")
> - The value in an xsi:schemaLocation attribute must consist of namespace/URL pairs, not just a single value
> - Using the GML core schema in the schemaLocation is not enough, you have to specify the URL of a document that actually
> defines the feature types. The core GML schemas just provide the blocks for building application schemas.
>
> Basically, a GML application schema is an XSD document, that defines elements which are feature types. The following
> request returns an example application schema
> http://demo.deegree.org/deegree-wfs/services?service=WFS&version=1.1.0&request=GetFeature&typename=app:Place&namespace=xmlns(app=http://www.deegree.org/app)&outputformat=text%2Fxml%3B+subtype%3Dgml%2F3.1.1
>
> Additionally, it's usually a better idea to specify the application schema used by the GMLStreamReader manually, so it
> doesn't depend on a correct xsi:schemaLocation attribute. Also, when done in Processlet#init(), it's much more effective
> (building the ApplicationSchema can be rather costly), when it's done only once.
>
> You may want to have a look at this wiki page as well: http://wiki.deegree.org/deegreeWiki/deegree3/HowToWorkWithGML
>
> Best regards,
> Markus
>
> P.S.: Be warned that the GML subsystem API has not been stabilized yet -- it should work for most application schemas,
> and we're going to fix it if you encounter problems with your documents, but the interface may still change in the
> future. BTW, this is the case with all other parts in the deegree API as well.
>
>
> BERTHET Arnaud wrote:
>> Hello list (again),
>>
>> ****PLEASE NOTE THAT MY LAST MESSAGE WAS SEND BY ERROR AND WAS NOT THE FINAL VERSION (THE SAVE BUTTON IS JUST BESIDE SEND BUTTON ....), SORRY FOR THE DISTURB****
>>
>> I'm using deegree3 WPS implementation to build my own WPS labelling Process using the labbeling library PAL (http://pal.heig-vd.ch/). My process should be able to get different layers that contains features through GML document.
>> Is there an easy way to send (by val) GML document (with many features) through an XML execute request and then to recover the feature collection contained in this document (With the org.deegree.gml.GMLStreamReader.readFeatureCollection() method) ?
>>
>> I try lots of different inputs but none of them worked... I often get the following parsing error : "xsi:schemaLocation is missing" or "xsi:schemaLocation is invalid" or "feature member is not a GML document"
>>
>> I can see that in the degree3-wps-demo client there is a lot of different examples that show how to use complex input but always with a single geometry (it work fine) and none of them are showing how to get feature or feature collection through GML input. I just try to find in the GML 3.1 spec (yummy!) how to build valid GML document that contain features but all the tests I made with degree3 WPS failed.
>>
>> Here is the part of my describe process where I describe the GML input :
>>
>> <ComplexInput>
>>         <Identifier>GMLInput1</Identifier>
>>         <Title>GMLInput1</Title>
>>         <DefaultFormat mimeType="text/xml" encoding="UTF-8" schema="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd"/>
>>  </ComplexInput>
>>
>> I try to put a lots of different schema but they didn't seems to work as well.
>>
>> Here is the kind of XML execute request I'd like to send (this request contain only one feature the the aim is of course, to have more features):
>>
>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>> <wps:Execute service="WPS" version="1.0.0"
>>              xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1"
>>              xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>              xsi:schemaLocation="http://www.opengis.net/wps/1.0.0
>>              http://schemas.opengis.net/wps/1.0.0/wpsExecute_request.xsd">
>>     <ows:Identifier>ComplexeProcessTest</ows:Identifier>
>>     <wps:DataInputs>
>>         <wps:Input>
>>             <ows:Identifier>GMLInput1</ows:Identifier>
>>             <wps:Data>
>>                 <wps:ComplexData>
>>                     <FeatureCollection xmlns="http://www.opengis.net/gml" xmlns:ogo="http://ogo/ogo" xsi:schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd">
>>                         <featureMember>
>>                             <ogo:traces fid="traces.1">
>>                                 <ogo:name>Une trace de test</ogo:name>
>>                                 <ogo:the_geom>
>>                                     <LineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
>>                                         <coordinates decimal="." cs="," ts=" ">
>>                                             2.06542447,47.51719581 8.0859335,41.83682585 18.41308279,48.22467216
>>                                         </coordinates>
>>                                     </LineString>
>>                                 </ogo:the_geom>
>>                             </ogo:traces>
>>                         </featureMember>
>>                     </FeatureCollection>
>>                 </wps:ComplexData>
>>             </wps:Data>
>>         </wps:Input>
>>     </wps:DataInputs>
>> ...
>>
>> As you can see there is a specific namespace for the features(here "ogo"). I think it's maybe a key of my problem but I generate different GML document and they always contains that kind of specific namespace for the features.
>>
>> And finally there is a part of my processlet implementation :
>>
>>     @Override
>>     public void process(ProcessletInputs pi, ProcessletOutputs po, ProcessletExecutionInfo pei) throws ProcessletException {
>>         //on récupère tout les inputs. Attention a bien caster les input dans le type prévu.
>>         ComplexInput gmlInput1 = (ComplexInput) pi.getParameter("GMLInput1");
>>
>>         this.logInfoComplexeInput(gmlInput1);
>>
>>         Geometry maGeom = null;
>>         Feature maFeature = null;
>>         FeatureCollection myFeatureCollection = null;
>>
>>         try {
>>             //lecture d'un input GML
>>             XMLStreamReader xmlReader = gmlInput1.getValueAsXMLStream();
>>             GMLStreamReader gmlReader = GMLInputFactory.createGMLStreamReader(GML_31, xmlReader);
>>             //GMLStreamReader gmlReader = GMLInputFactory.createGMLStreamReader(GMLVersion.GML_2 , xmlReader);
>>
>>             try {
>>                 maGeom = gmlReader.readGeometry();
>>                 this.logInfoGeometry(maGeom);
>>             } catch (Exception ex) {
>>                 System.out.println("GEOMETRY ERROR : ");
>>                 ex.printStackTrace();
>>             }
>>             try {
>>                 maFeature = gmlReader.readFeature();
>>                 this.logInfoFeature(maFeature);
>>             } catch (Exception ex) {
>>                 System.out.println("FEATURE ERROR : ");
>>                 ex.printStackTrace();
>>             }
>>             try {
>>                 myFeatureCollection = gmlReader.readFeatureCollection();
>>                 System.out.println("");
>>                 Iterator<Feature> it = myFeatureCollection.iterator();
>>                 while(it.hasNext()){
>>                     Feature next = it.next();
>>                     this.logInfoFeature(next);
>>                 }
>>                 System.out.println(myFeatureCollection);
>>                 //this.logInfoFeatures(myFeatureCollection);
>>             } catch (XMLStreamException streamEx) {
>>                 System.out.println("StreamException : " + streamEx.getMessage());
>>             } catch (XMLParsingException parseEx) {
>>                 System.out.println("Parsing Exception : " + parseEx.getMessage());
>>             } catch (UnknownCRSException unknow) {
>>                 System.out.println("unknow Exception : " + unknow.getMessage());
>>             }
>>
>>         } catch (Exception e) {
>>             throw new ProcessletException("Error parsing parameter " + gmlInput1.getIdentifier() + ": "
>>                     + e.getMessage());
>>         }
>> ...
>>
>> I know that this code will raise some exceptions but I expected that at least one of the reader method works (in this case the readFeatureCollection() ).
>> I think I can avoid the problem by using JSon input but it would be fine if it can works with XML request including GML input.
>>
>> Thanks in advance, Regards.
>> Arnaud Berthet
>> ------------------------------------------------------------------------------
>>
>> _______________________________________________
>> deegree-devel mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/deegree-devel
>
>
> --
> Markus Schneider
>
> l a t / l o n  GmbH
> Aennchenstrasse 19           53177 Bonn, Germany
> phone ++49 +228 184960       fax ++49 +228 1849629
> http://www.lat-lon.de        http://www.deegree.org
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> deegree-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/deegree-devel

--
Markus Schneider

l a t / l o n  GmbH
Aennchenstrasse 19           53177 Bonn, Germany
phone ++49 +228 184960       fax ++49 +228 1849629
http://www.lat-lon.de        http://www.deegree.org


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


_______________________________________________
deegree-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/deegree-devel

signature.asc (268 bytes) Download Attachment
Loading...