That makes sense. That GMLSchema contains autogenerated types for all gml
schema types and gets customized in a need by need basis, as with the
regular geometry types. +1 here but I think you may want to wait for Ben or
Rini to weigh in before proceeding.
2c.
-Justin
On Mon, Oct 4, 2010 at 11:51 AM, Andrea Aime
<andrea.a...@geo-solutions.it>wrote:
> On Mon, Oct 4, 2010 at 7:26 PM, Andrea Aime
> <andrea.a...@geo-solutions.it> wrote:
> > Hi,
> > I'm trying to use app-schema with a target schema that, unfortunately,
> > uses a DirectPosition as
> > the feature "geometry". I don't have any control over the schema so I
> > have to try and make it work
> > anyways.
> >
> > What I get overall is that my points are turned into their WKT
> > representation when the
> > GML encoding happens. Which is not what I want.
> >
> > Looking a bit more deeply I see that the attribute is correctly bound
> > to DirectPosition:
> > ComplexTypeImpl http://www.opengis.net/gml:DirectPositionType extends
> >
> doubleList(axisLabels:NCNameList,srsDimension:positiveInteger,srsName:anyURI,uomLabels:NCNameList)
> > but nowhere in the code there is an attempt to use converters to turn
> > the JTS Point into a DirectPosition.
> >
> > Now, I tracked down the issue to XPath.convertValue:
> >
> > private Object convertValue(final AttributeDescriptor descriptor,
> > final Object value) {
> > final AttributeType type = descriptor.getType();
> > Class<?> binding = type.getBinding();
> >
> > if (type instanceof ComplexType && binding == Collection.class) {
> > if (!(value instanceof Collection) &&
> isSimpleContentType(type)) {
> > ArrayList<Property> list = new ArrayList<Property>();
> > if (value == null && !descriptor.isNillable()) {
> > return list;
> > }
> > list.add(buildSimpleContent(type, value));
> > return list;
> > }
> > }
> > if (binding == String.class && value instanceof Collection) {
> > // if it's a single value in a collection, strip the square
> brackets
> > String collectionString = value.toString();
> > return collectionString.substring(1, collectionString.length()
> - 1);
> > }
> > return FF.literal(value).evaluate(value, binding);
> > }
> >
> > type is a complex type, but binding for some reason is exactly
> Collection.class,
> > which results in the wrong code path being chosen (the right one, imho,
> would
> > be the usage of the last line, FF.literal(value).evaluate(value,
> binding), which
> > could be expressed also as Converters.convert(value, binding)).
> >
> > Now... does anybody know why the binding ends up being a collection
> instead
> > of org.opengis.geometry.DirectPosition?
> > I still haven't quite tracked down where the bindings are built...
>
> Ok, tracked it down.
> The GMLSchema class contains the definitions of many gml foundation types,
> for point the definition is:
>
>
> public static final AttributeType POINTTYPE_TYPE = build_POINTTYPE_TYPE();
>
> private static AttributeType build_POINTTYPE_TYPE() {
> AttributeType builtType;
> builtType = new AttributeTypeImpl(
> new NameImpl("http://www.opengis.net/gml","PointType"),
> com.vividsolutions.jts.geom.Point.class, false,
> false, Collections.<Filter>emptyList(),
> ABSTRACTGEOMETRICPRIMITIVETYPE_TYPE, null
> );
> return builtType;
> }
>
> Notice the direct binding to Point.class.
> But for DirectPosition it is:
>
> public static final ComplexType DIRECTPOSITIONTYPE_TYPE =
> build_DIRECTPOSITIONTYPE_TYPE();
>
> private static ComplexType build_DIRECTPOSITIONTYPE_TYPE() {
> ComplexType builtType;
> List<PropertyDescriptor> schema = new
> ArrayList<PropertyDescriptor>();
> schema.add(
> new AttributeDescriptorImpl(
> NCNAMELIST_TYPE, new
> NameImpl("http://www.opengis.net/gml","axisLabels"), 0, 1, true, null
> )
> );
> schema.add(
> new AttributeDescriptorImpl(
> XSSchema.POSITIVEINTEGER_TYPE, new
> NameImpl("http://www.opengis.net/gml","srsDimension"), 0, 1, true,
> null
> )
> );
> schema.add(
> new AttributeDescriptorImpl(
> XSSchema.ANYURI_TYPE, new
> NameImpl("http://www.opengis.net/gml","srsName"), 0, 1, true, null
> )
> );
> schema.add(
> new AttributeDescriptorImpl(
> NCNAMELIST_TYPE, new
> NameImpl("http://www.opengis.net/gml","uomLabels"), 0, 1, true, null
> )
> );
> builtType = new ComplexTypeImpl(
> new
> NameImpl("http://www.opengis.net/gml","DirectPositionType"), schema,
> false,
> false, Collections.<Filter>emptyList(), DOUBLELIST_TYPE, null
> );
> return builtType;
> }
>
> That is, it's built as a complex type, and all complex types bind to
> Collection.class (that's inside the
> ComplexTypeImpl constructor).
>
> The change I'm tempted to perform is to make the direct position bound
> to a opengis DirectPosition
> instead. It would contain the ordinates and the crs, but not the other
> attributes...
> And then make a converter between Point and DirectPosition... the
> DirectPositionTypeBinding
> is actually already there and should work
>
> Thoughts?
>
> Cheers
> Andrea
>
>
> -----------------------------------------------------
> Ing. Andrea Aime
> Senior Software Engineer
>
> GeoSolutions S.A.S.
> Via Poggio alle Viti 1187
> 55054 Massarosa (LU)
> Italy
>
> phone: +39 0584962313
> fax: +39 0584962313
>
> http://www.geo-solutions.it
> http://geo-solutions.blogspot.com/
> http://www.linkedin.com/in/andreaaime
> http://twitter.com/geowolf
>
> -----------------------------------------------------
>
>
> ------------------------------------------------------------------------------
> Virtualization is moving to the mainstream and overtaking non-virtualized
> environment for deploying applications. Does it make network security
> easier or more difficult to achieve? Read this whitepaper to separate the
> two and get a better understanding.
> http://p.sf.net/sfu/hp-phase2-d2d
> _______________________________________________
> Geotools-devel mailing list
> Geotools-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-devel
>
--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.
------------------------------------------------------------------------------
Virtualization is moving to the mainstream and overtaking non-virtualized
environment for deploying applications. Does it make network security
easier or more difficult to achieve? Read this whitepaper to separate the
two and get a better understanding.
http://p.sf.net/sfu/hp-phase2-d2d
_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel