* Maps the default geometry attribute regardless of whether they are the same type.
*/
@SuppressWarnings("unchecked")
private static void mapGeometryAttributes( SimpleFeatureType sourceSchema, SimpleFeatureType targetSchema, Map<String, String> queryAttributes ) {
// Now we'll match the geometry on type only. I don't care if it has the same type name.
GeometryDescriptor defaultGeometry = targetSchema.getGeometryDescriptor();
if( defaultGeometry==null ){
return;
}
else if (!queryAttributes.containsKey(defaultGeometry.getName())) {
// first check source's default geom and see if it matches
Class<?> binding = sourceSchema.getGeometryDescriptor().getType().getBinding();
if (defaultGeometry.getType().getBinding().isAssignableFrom(
binding)) {
queryAttributes.put(defaultGeometry.getName().getLocalPart(), sourceSchema.getGeometryDescriptor()
.getName().getLocalPart());
} else {
// we have to look through all the source attributes looking for a geometry that
// matches.
boolean found = false;
for( int i = 0; i < sourceSchema.getAttributeCount(); i++ ) {
AttributeDescriptor source = sourceSchema.getDescriptor(i);
if (defaultGeometry.getType().getBinding().isAssignableFrom(source.getType().getBinding())) {
queryAttributes.put(defaultGeometry.getName().getLocalPart(), source.getName().getLocalPart());
found = true;
break;
}
}
// ok so we're going to have to do some transformations. Match default geometries
// then.
if (!found) {
queryAttributes.put(defaultGeometry.getName().getLocalPart(), sourceSchema
.getGeometryDescriptor().getName().getLocalPart());
}
}
}
}