Sorry, I don't think this is going to work with the current GeoTools 
implementation. The problem is that all geometry types are bound in Java 
to JTS geometry types (implementations of 
com.vividsolutions.jts.geom.Geometry) so that they can be used in 
spatial operations and encoded to GML. When you define a new complex 
type derived from gml:Point you create a type that is represented by a 
GeoTools ComplexAttributeImpl, which is not a 
com.vividsolutions.jts.geom.Geometry, and so anything expecting a 
Geometry will choke on it. Furthermore, GeoTools treats all geometries 
as simple (non-complex) attributes: they are an atomic data type like 
xs:double. This approach allows GML geometries to be converted to Java 
objects for spatial operations.

This problem is an issue in the core GeoTools code. The app-schema 
plugin just allows you to run into the problem.

Justin, can an application schema extension of a GML geometry such as 
gml:Point be accommodated within the GeoTools declared-type binding 
framework?

Kind regards,
Ben.


On 09/09/10 03:30, Volker Grabsch wrote:
> Hi App-Schema experts,
>
> I'm trying to map a PostGIS table with columns
>
>      ...
>      point      GEOMETRY NOT NULL,
>      height     INTEGER  NOT NULL,
>      height_uom TEXT     NOT NULL
>
> to the following XML structure:
>
>      <myns:MyFeature gml:id="...">
>        <myns:myPoint>
>          <myns:MyPoint gml:id="..." 
> srsName="http://www.opengis.net/gml/srs/epsg.xml#4326";>
>            <gml:pos>10.4721897381 43.2874901353</gml:pos>
>            <myns:height uom="FT">3</myns:height>
>          </myns:MyPoint>
>        </myns:myPoint>
>      </myns:MyFeature>
>
> That is, the type of myns:MyPoint is an extension of gml:Point with
> an additional element. The corresponding part of the XML schema is:
>
>      <complexType name="MyPointType">
>        <complexContent>
>          <extension base="gml:PointType">
>            <sequence>
>              <element name="height" type="gml:MeasureType"/>
>            </sequence>
>          </extension>
>        </complexContent>
>      </complexType>
>
> I've tried lots of variants of the following mapping:
>
>      <AttributeMapping>
>        <targetAttribute>myns:myPoint</targetAttribute>
>        <sourceExpression>
>          <OCQL>point</OCQL>
>        </sourceExpression>
>      </AttributeMapping>
>      <AttributeMapping>
>        
> <targetAttribute>myns:myPoint/myns:MyPoint/myns:height</targetAttribute>
>        <sourceExpression>
>          <OCQL>height</OCQL>
>        </sourceExpression>
>        <ClientProperty>
>          <name>uom</name>
>          <value>height_uom</value>
>        </ClientProperty>
>      </AttributeMapping>
>
> But I always got the following exception:
>
>      java.lang.RuntimeException: Failed to get property: gid
>      Failed to get property: gid
>      org.geotools.feature.ComplexAttributeImpl cannot be cast to 
> com.vividsolutions.jts.geom.Geometry
>      ... [1]
>
> Note that the "gid" attribute is optional and even deprecated!
> Nevertheless, I added it via the following mapping rule:
>
>      <AttributeMapping>
>          <targetAttribute>myns:myPoint/myns:MyPoint</targetAttribute>
>          <ClientProperty>
>            <name>gid</name>
>            <value>'DUMMY'</value>
>          </ClientProperty>
>      </AttributeMapping>
>
> Then, I got the same error message regarding many other optional(!)
> attributes. After providing dummy mappings for them, GeoServer finally
> produced an output, but that output didn't contain the geometry data:
>
>      <myns:MyFeature gml:id="...">
>        <myns:myPoint>
>          <myns:MyPoint axisLabels="DUMMY" gid="DUMMY" gml:id="DUMMY" 
> srsDimension="DUMMY" srsName="DUMMY" uomLabels="DUMMY">
>            <myns:height uom="FT">3</myns:height>
>          </myns:MyPoint>
>        </myns:myPoint>
>      </myns:MyFeature>
>
> I also tried to map the geometry to the MyPoint sub element:
>
>      <AttributeMapping>
>        <targetAttribute>myns:myPoint/myns:MyPoint</targetAttribute>
>        <sourceExpression>
>          <OCQL>point</OCQL>
>        </sourceExpression>
>        ...
>      </AttributeMapping>
>
> Although the "point" column was not NULL, it produced the following
> strange exception:
>
>      
> org.geotools.feature.IllegalAttributeException:http://example.com/myns:MyPointType
>  not nillable:null value:null
>      ... [2]
>
> What am I doing wrong here?
>
>
> Greets,
> Volker
>
>
>
> [1] Full trace:
>
>      org.geoserver.platform.ServiceException: java.lang.RuntimeException: 
> Failed to get property: gid
>          at org.geoserver.ows.Dispatcher.exception(Dispatcher.java:1304)
>          at 
> org.geoserver.ows.Dispatcher.handleRequestInternal(Dispatcher.java:240)
>          at 
> org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
>          at 
> org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
>          at 
> org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
>          at 
> org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
>          at 
> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
>          at 
> org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
>          at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
>          at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>          at 
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
>          at 
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
>          at 
> org.vfny.geoserver.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
>          at 
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
>          at 
> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
>          at 
> org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
>          at 
> org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
>          at 
> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
>          at 
> org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:124)
>          at 
> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
>          at 
> org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
>          at 
> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
>          at 
> org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:174)
>          at 
> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
>          at 
> org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
>          at 
> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
>          at 
> org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
>          at 
> org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
>          at 
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
>          at 
> org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:73)
>          at 
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
>          at 
> org.geoserver.filters.ReverseProxyFilter.doFilter(ReverseProxyFilter.java:183)
>          at 
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
>          at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:41)
>          at 
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
>          at 
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
>          at 
> org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
>          at 
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>          at 
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
>          at 
> org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
>          at 
> org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
>          at 
> org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
>          at 
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>          at org.mortbay.jetty.Server.handle(Server.java:324)
>          at 
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
>          at 
> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:842)
>          at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648)
>          at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
>          at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
>          at 
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
>          at 
> org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
>      Caused by: java.lang.RuntimeException: Failed to get property: gid
>          at 
> org.geotools.xml.impl.GetPropertyExecutor.visit(GetPropertyExecutor.java:93)
>          at 
> org.geotools.xml.impl.BindingWalker$BindingExecutionChain.execute(BindingWalker.java:215)
>          at org.geotools.xml.impl.BindingWalker.walk(BindingWalker.java:181)
>          at 
> org.geotools.xml.impl.BindingVisitorDispatch.walk(BindingVisitorDispatch.java:44)
>          at 
> org.geotools.xml.impl.BindingVisitorDispatch.walk(BindingVisitorDispatch.java:29)
>          at org.geotools.xml.Encoder.encode(Encoder.java:854)
>          at org.geotools.xml.Encoder.encode(Encoder.java:561)
>          at 
> org.geoserver.wfs.xml.GML3OutputFormat.write(GML3OutputFormat.java:190)
>          at 
> org.geoserver.wfs.WFSGetFeatureOutputFormat.write(WFSGetFeatureOutputFormat.java:137)
>          at org.geoserver.ows.Dispatcher.response(Dispatcher.java:726)
>          at 
> org.geoserver.ows.Dispatcher.handleRequestInternal(Dispatcher.java:234)
>          ... 49 more
>      Caused by: java.lang.ClassCastException: 
> org.geotools.feature.ComplexAttributeImpl cannot be cast to 
> com.vividsolutions.jts.geom.Geometry
>          at 
> org.geotools.gml3.bindings.PointTypeBinding.getProperty(PointTypeBinding.java:137)
>          at 
> org.geotools.xml.impl.GetPropertyExecutor.visit(GetPropertyExecutor.java:91)
>          ... 59 more
>
>
> [2] Full trace:
>
>      org.geoserver.platform.ServiceException: 
> org.geotools.feature.IllegalAttributeException:http://example.com/myns:MyPointType
>  not nillable:null value:null
>          at org.geoserver.ows.Dispatcher.exception(Dispatcher.java:1304)
>          at 
> org.geoserver.ows.Dispatcher.handleRequestInternal(Dispatcher.java:240)
>          at 
> org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
>          at 
> org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
>          at 
> org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
>          at 
> org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
>          at 
> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
>          at 
> org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
>          at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
>          at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>          at 
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
>          at 
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
>          at 
> org.vfny.geoserver.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
>          at 
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
>          at 
> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
>          at 
> org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
>          at 
> org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
>          at 
> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
>          at 
> org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:124)
>          at 
> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
>          at 
> org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
>          at 
> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
>          at 
> org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:174)
>          at 
> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
>          at 
> org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
>          at 
> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
>          at 
> org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
>          at 
> org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
>          at 
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
>          at 
> org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:73)
>          at 
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
>          at 
> org.geoserver.filters.ReverseProxyFilter.doFilter(ReverseProxyFilter.java:183)
>          at 
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
>          at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:41)
>          at 
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
>          at 
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
>          at 
> org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
>          at 
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>          at 
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
>          at 
> org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
>          at 
> org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
>          at 
> org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
>          at 
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>          at org.mortbay.jetty.Server.handle(Server.java:324)
>          at 
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
>          at 
> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:842)
>          at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648)
>          at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
>          at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
>          at 
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
>          at 
> org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
>      Caused by: 
> org.geotools.feature.IllegalAttributeException:http://example.com/myns:MyPointType
>  not nillable:null value:null
>          at org.geotools.feature.type.Types.validate(Types.java:112)
>          at org.geotools.feature.type.Types.validate(Types.java:80)
>          at 
> org.geotools.feature.AttributeImpl.&lt;init&gt;(AttributeImpl.java:52)
>          at 
> org.geotools.feature.GeometryAttributeImpl.&lt;init&gt;(GeometryAttributeImpl.java:66)
>          at 
> org.geotools.feature.AppSchemaFeatureFactoryImpl.createGeometryAttribute(AppSchemaFeatureFactoryImpl.java:73)
>          at 
> org.geotools.feature.AttributeBuilder.create(AttributeBuilder.java:571)
>          at 
> org.geotools.feature.AttributeBuilder.add(AttributeBuilder.java:486)
>          at org.geotools.data.complex.filter.XPath.setValue(XPath.java:730)
>          at org.geotools.data.complex.filter.XPath.set(XPath.java:646)
>          at org.geotools.data.complex.filter.XPath.set(XPath.java:529)
>          at 
> org.geotools.data.complex.DataAccessMappingFeatureIterator.setAttributeValue(DataAccessMappingFeatureIterator.java:432)
>          at 
> org.geotools.data.complex.DataAccessMappingFeatureIterator.computeNext(DataAccessMappingFeatureIterator.java:704)
>          at 
> org.geotools.data.complex.AbstractMappingFeatureIterator.next(AbstractMappingFeatureIterator.java:193)
>          at 
> org.geotools.data.complex.MappingFeatureCollection.size(MappingFeatureCollection.java:300)
>          at org.geoserver.wfs.GetFeature.run(GetFeature.java:371)
>          at 
> org.geoserver.wfs.DefaultWebFeatureService.getFeature(DefaultWebFeatureService.java:115)
>          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>          at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>          at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>          at java.lang.reflect.Method.invoke(Method.java:616)
>          at 
> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
>          at 
> org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
>          at 
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
>          at org.geoserver.ows.util.EMFLogger.invoke(EMFLogger.java:51)
>          at 
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
>          at 
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
>          at $Proxy15.getFeature(Unknown Source)
>          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>          at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>          at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>          at java.lang.reflect.Method.invoke(Method.java:616)
>          at org.geoserver.ows.Dispatcher.execute(Dispatcher.java:599)
>          at 
> org.geoserver.ows.Dispatcher.handleRequestInternal(Dispatcher.java:230)
>          ... 49 more
>
>
> ------------------------------------------------------------------------------
> This SF.net Dev2Dev email is sponsored by:
>
> Show off your parallel programming skills.
> Enter the Intel(R) Threading Challenge 2010.
> http://p.sf.net/sfu/intel-thread-sfd
> _______________________________________________
> Geoserver-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>


-- 
Ben Caradoc-Davies <[email protected]>
Software Engineering Team Leader
CSIRO Earth Science and Resource Engineering
Australian Resources Research Centre

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to