Cool, that sounds better than the others, I will try that solution now.

Thanks Justin.

On Fri, Jul 11, 2008 at 6:58 PM, Justin Deoliveira <[EMAIL PROTECTED]>
wrote:

> Hi Alessio,
>
> It sounds like you found a away around your problem. But a possible third
> solution:
>
> 3. Change the generated class SpatialSubsetType "manually" so that its
> Envelope property is actually of the type geotools type envelope. I call
> this "instrumenting" the model.
>
> Then the GML bindings should parse the Envelope, and the reflective EMF
> bindings should still be able to reflectivley set the property.
>
> -Justin
>
> Alessio Fabiani wrote:
>
>> Well, finally I got the solution .... just for knowledge I will briefly
>> share the solution with the community, soon I will update the tutorial that
>> I have written for the EMF model generation, adding the binding
>> implementation also.
>>
>> A bit of introduction first.
>>
>> The WCS 1.0.0 schema for the DomainSubset part requires a structure like
>> the following:
>>
>>    <wcs:domainSubset>
>>        <wcs:spatialSubset>
>>            <gml:Envelope srsName="EPSG:32633">
>>                <gml:pos>347649.93086859107 5176214.082539256</gml:pos>
>>                <gml:pos>370725.976428591 5196961.352859256</gml:pos>
>>            </gml:Envelope>
>>            <gml:Grid dimension="2" srsName="EPSG:4326">
>>                <gml:limits>
>>                    <gml:GridEnvelope>
>>                        <gml:low>0 0</gml:low>
>>                        <gml:high>545 490</gml:high>
>>                    </gml:GridEnvelope>
>>                </gml:limits>
>>            </gml:Grid>
>>        </wcs:spatialSubset>
>>    </wcs:domainSubset>
>>
>> As you can notice the domainSubset and the spatialSubset nodes belong to
>> the "wcs" namespace, while the Envelope and Grid to the "gml" one instead.
>> That means that the EnvelopeBinding and GridBinding have to be implemented
>> into some "gt-gml" (just a dummy name) module and the spatialSubsetBinding
>> and domainSubsetBinding have to be implemented into some "gt-wcs" package
>> instead.
>>
>> At this point we have several ways to do that, but particular attention
>> has to be put on how we implement the WCSConfiguration and GMLConfiguration
>> for both the WCS and GML binding packages (more details later).
>>
>> Method 1: if you would like the Parser to automatically populate the
>> objects, than you must leave the EnvelopeBinding and the GridBinding
>> respectively return the EMF Objects (EObjects) EnvelopeType and GridType.
>>
>> Method 2: if you would like to allow the EnvelopeBinding returning for
>> instance a geotools GeneralEnvelope (or a JTS Envelope or whatelse), than
>> you MUST say to the WCS spatialSubsetBinding and to the domainSubsetBinding
>> how to handle such case. You have here several ways too. One would be to
>> write some specific geotools Converters from EnvelopeType to whatelse;
>> another one, easier, would be to manually rewrite te "parse" methods of the
>> spatialSubsetBinding and domainSubsetBinding in order to handle the
>> GeneralEnvelope parsing. The latter is for sure the best path to follow ...
>> but you have to pay particular attention on how you write the
>> WCSConfiguration binding file, infact you have to explicitly register both
>> the spatialSubsetBinding and the domainSubsetBinding implementations as
>> represented below.
>>
>>        bindings.put(WCS.DomainSubsetType, new DomainSubsetTypeBinding());
>>        bindings.put(WCS.SpatialSubsetType, new
>> SpatialSubsetTypeBinding());
>>
>> Cheers,
>>                Alessio.
>>
>> On Thu, Jul 10, 2008 at 4:18 PM, Alessio Fabiani <
>> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:
>>
>>    Hi Gabriel,
>>
>>    thanks for the response ... I have already inspected this
>>    possibility, but does not seem to solve the problem ... I also
>>    tryied several WCSConfiguration and GMLConfiguration combinations
>>    ... but I got no successful result.
>>    The only thing I noticed is that the AbstractComplexEMFBinding
>>    superclass fails on the setProperty method trying to instantiate a
>>    geotools.util.Converter from the expected EnvelopeType class to
>>    jts.Envelope (or ReferencedEnvelope) one, since no one exists ...
>>    the only thing I cannot really figure out is why that works for
>>    gt-GML3 module and not for mine since they are almost equal !!!
>>
>>    On Thu, Jul 10, 2008 at 4:06 PM, Gabriel Roldán <[EMAIL PROTECTED]
>>    <mailto:[EMAIL PROTECTED]>> wrote:
>>
>>        I guess if the binding declares it returns
>>        ReferencedEnvelope.class in
>>        getType() it should be respected...
>>
>>        like in class EnvelopeTypeBinding extends
>>        AbstractComplexTypeBinding{
>>
>>         public Class getType() {
>>               return ReferencedEnvelope.class;
>>           }
>>
>>        }
>>
>>        though not sure that is the solution actually...
>>
>>        Gabriel
>>
>>        On Thursday 10 July 2008 03:43:30 pm Alessio Fabiani wrote:
>>         > Hi all,
>>         >
>>         > I'm trying to create a new binding for the GML EnvelopeType
>>        as a JTS
>>         > Envelope, since I couldn't use geotools gml2/3 EMF models due
>>        to some
>>         > specific Elements defined only for WCS 1.0.0. <http://1.0.0.>
>>
>>         > Nevertheless I followed the implementation of the existing
>>        gt-GML3 module
>>         > EvnelopeTypeBinding, returning a ReferencedEnvelope object as
>>        result of the
>>         > EnvelopeTypeBinding parsing.
>>         >
>>         > Now ... all seems working fine until I try to parse a WCS 1.0.0
>>         > SpatialSubsetType ... here I get an exception like the
>> following:
>>         >
>>         > org.vfny.geoserver.wcs.WcsException: Parsing failed, the xml
>>        request is
>>         > most probably not compliant to the wcs schema
>>         >     at
>>
>>  org.geoserver.wcs.xml.v1_0_0.WcsXmlReader.read(WcsXmlReader.java:50)
>>         >     at
>>         >
>>
>>  org.geoserver.wcs.xml.GetCoverageXmlParserTest.testBasic(GetCoverageXmlPars
>>         >erTest.java:86) at
>>        sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>>         > Method) at
>>        sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
>>         > sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
>>        Source) at
>>         > java.lang.reflect.Method.invoke(Unknown Source)
>>         >     at junit.framework.TestCase.runTest(TestCase.java:164)
>>         >     at junit.framework.TestCase.runBare(TestCase.java:130)
>>         >     at junit.framework.TestResult$1.protect(TestResult.java:106)
>>         >     at
>>        junit.framework.TestResult.runProtected(TestResult.java:124)
>>         >     at junit.framework.TestResult.run(TestResult.java:109)
>>         >     at junit.framework.TestCase.run(TestCase.java:120)
>>         >     at junit.framework.TestSuite.runTest(TestSuite.java:230)
>>         >     at junit.framework.TestSuite.run(TestSuite.java:225)
>>         >     at
>>         >
>>
>>  org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3
>>         >TestReference.java:130) at
>>         >
>>
>>  org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:
>>         >38) at
>>         >
>>
>>  org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestR
>>         >unner.java:460) at
>>         >
>>
>>  org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestR
>>         >unner.java:673) at
>>         >
>>
>>  org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner
>>         >.java:386) at
>>         >
>>
>>  org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunne
>>         >r.java:196) Caused by: java.lang.RuntimeException: Parsing
>>        failed for
>>         > spatialSubset: java.lang.RuntimeException: Unable to set
>>        property: Envelope
>>         > for eobject: { 
>> http://www.opengis.net/wcs}SpatialSubsetType<http://www.opengis.net/wcs%7DSpatialSubsetType>
>>        <http://www.opengis.net/wcs%7DSpatialSubsetType>
>>
>>         >     at
>>        org.geotools.xml.impl.ParseExecutor.visit(ParseExecutor.java:152)
>>         >     at
>>         >
>>
>>  org.geotools.xml.impl.BindingWalker$BindingExecutionChain.execute(BindingWa
>>         >lker.java:208) at
>>         >
>>        org.geotools.xml.impl.BindingWalker.walk(BindingWalker.java:174) at
>>         >
>>
>>  org.geotools.xml.impl.ElementHandlerImpl.endElement(ElementHandlerImpl.java
>>         >:222) at
>>         >
>>
>>  org.geotools.xml.impl.ParserHandler.endElement(ParserHandler.java:582)
>>         >     at
>>        org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown
>>         > Source)
>>         >     at
>>        org.apache.xerces.impl.xs.XMLSchemaValidator.endElement(Unknown
>>         > Source)
>>         >     at
>>         >
>>
>>  org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown
>>         > Source)
>>         >     at
>>         >
>>
>>  org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispat
>>         >cher.dispatch(Unknown Source)
>>         >     at
>>         >
>>
>>  org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
>>         > Source)
>>         >     at
>>        org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>>         >     at
>>        org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>>         >     at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>>         >     at
>>        org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>>         >     at org.geotools.xml.Parser.parse(Parser.java:180)
>>         >     at org.geotools.xml.Parser.parse(Parser.java:158)
>>         >     at
>>
>>  org.geoserver.wcs.xml.v1_0_0.WcsXmlReader.read(WcsXmlReader.java:48)
>>         >     ... 19 more
>>         > Caused by: java.lang.RuntimeException: Unable to set
>>        property: Envelope for
>>         > eobject: 
>> {http://www.opengis.net/wcs}SpatialSubsetType<http://www.opengis.net/wcs%7DSpatialSubsetType>
>>        <http://www.opengis.net/wcs%7DSpatialSubsetType>
>>
>>         >     at
>>         >
>>
>>  org.geotools.xml.AbstractComplexEMFBinding.setProperty(AbstractComplexEMFBi
>>         >nding.java:271) at
>>         >
>>
>>  org.geotools.xml.AbstractComplexEMFBinding.setProperties(AbstractComplexEMF
>>         >Binding.java:202) at
>>         >
>>
>>  org.geotools.xml.AbstractComplexEMFBinding.parse(AbstractComplexEMFBinding.
>>         >java:143) at
>>         >
>>        org.geotools.xml.impl.ParseExecutor.visit(ParseExecutor.java:143)
>>        ... 35
>>         > more
>>         > Caused by: java.lang.ClassCastException: The feature
>>        'envelope's type
>>         > 'EnvelopeType' does not permit a value of type
>>         > 'org.geotools.geometry.jts.ReferencedEnvelope'
>>         >     at
>>         >
>>
>>  org.eclipse.emf.ecore.impl.EStructuralFeatureImpl$BasicFeatureMapEntry.vali
>>         >date(EStructuralFeatureImpl.java:2843) at
>>         >
>>
>>  org.eclipse.emf.ecore.util.FeatureMapUtil.createEntry(FeatureMapUtil.java:1
>>         >46) at
>>         >
>>
>>  org.eclipse.emf.ecore.util.BasicFeatureMap.createEntry(BasicFeatureMap.java
>>         >:94) at
>>         >
>>
>>  org.eclipse.emf.ecore.util.BasicFeatureMap.addAll(BasicFeatureMap.java:1253
>>         >) at
>>         >
>>
>>  org.eclipse.emf.ecore.util.FeatureMapUtil$FeatureEList.addAll(FeatureMapUti
>>         >l.java:656) at org.geotools.xml.EMFUtils.add(EMFUtils.java:93)
>>         >     at
>>         >
>>
>>  org.geotools.xml.AbstractComplexEMFBinding.setProperty(AbstractComplexEMFBi
>>         >nding.java:230) ... 38 more
>>         >
>>         > And if I return an EvnelopeType all works well ...
>>         >
>>         > any ideas? am I missing something? Do I have to build a
>>        geotools converter
>>         > or something like that?
>>         >
>>         > Any help kindly appreciated.
>>         >
>>         > Cheers,
>>         >             Alessio.
>>
>>
>>
>>
>>  -------------------------------------------------------------------------
>>        Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
>>        Studies have shown that voting for your favorite open source
>>        project,
>>        along with a healthy diet, reduces your potential for chronic
>>        lameness
>>        and boredom. Vote Now at
>> http://www.sourceforge.net/community/cca08
>>        _______________________________________________
>>        Geoserver-devel mailing list
>>        [email protected]
>>        <mailto:[email protected]>
>>        https://lists.sourceforge.net/lists/listinfo/geoserver-devel
>>
>>
>>
>>
>>    --    -------------------------------------------------------
>>    Eng. Alessio Fabiani
>>    Vice-President /CTO GeoSolutions S.A.S.
>>    Via Carignoni 51
>>    55041 Camaiore (LU)
>>    Italy
>>
>>    phone: +39 0584983027
>>    fax: +39 0584983027
>>    mob: +39 349 8227000
>>
>>
>>    http://www.geo-solutions.it
>>
>>    -------------------------------------------------------
>>
>>
>>
>> --
>> -------------------------------------------------------
>> Eng. Alessio Fabiani
>> Vice-President /CTO GeoSolutions S.A.S.
>> Via Carignoni 51
>> 55041 Camaiore (LU)
>> Italy
>>
>> phone: +39 0584983027
>> fax: +39 0584983027
>> mob: +39 349 8227000
>>
>>
>> http://www.geo-solutions.it
>>
>> -------------------------------------------------------
>> !DSPAM:4007,487732ef278366491211187!
>>
>>
>> ------------------------------------------------------------------------
>>
>> -------------------------------------------------------------------------
>> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
>> Studies have shown that voting for your favorite open source project,
>> along with a healthy diet, reduces your potential for chronic lameness
>> and boredom. Vote Now at http://www.sourceforge.net/community/cca08
>>
>> !DSPAM:4007,487732ef278366491211187!
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Geoserver-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/geoserver-devel
>>
>>
>> !DSPAM:4007,487732ef278366491211187!
>>
>
>
> --
> Justin Deoliveira
> The Open Planning Project
> [EMAIL PROTECTED]
>



-- 
-------------------------------------------------------
Eng. Alessio Fabiani
Vice-President /CTO GeoSolutions S.A.S.
Via Carignoni 51
55041 Camaiore (LU)
Italy

phone: +39 0584983027
fax: +39 0584983027
mob: +39 349 8227000


http://www.geo-solutions.it

-------------------------------------------------------
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Geoserver-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

Reply via email to