private String findFeatureTypeGmlVersion(AttributeType featureType) { if (featureType == null) { return null; } if (isAbstractFeatureType(featureType)) { String gmlNamespace = featureType.getName().getNamespaceURI(); if (org.geotools.gml3.GML.NAMESPACE.equals(gmlNamespace)) { // GML 3.1.1 return "gml3"; } else if (org.geotools.gml3.v3_2.GML.NAMESPACE.equals(gmlNamespace)) { // GML 3.2 return GML32OutputFormat.FORMATS.get(0); } else { // should never happen LOGGER.log( Level.FINE, "Cannot determine GML version from AbstractFeatureType type"); return null; } } // recursively check super types AttributeType parent = featureType.getSuper(); return findFeatureTypeGmlVersion(parent); }
/** * Returns the GML version used in the feature type's definition. * * <p>The method recursively climbs up the type hierarchy of the provided feature type, until it * finds AbstractFeatureType. Then, the GML version is determined by looking at the namespace * URI. * * <p>Please note that this method does not differentiate between GML 2 and GML 3.1.1, but * assumes that "http://www.opengis.net/gml" namespace always refers to GML 3.1.1. * * @param ftInfo the feature type info * @return the GML version used in the feature type definition * @throws IOException if the underlying datastore instance cannot be retrieved */ String findGmlVersion(FeatureTypeInfo ftInfo) throws IOException { ProgressListener listener = new NullProgressListener(); Name qName = ftInfo.getQualifiedName(); FeatureType fType = ftInfo.getStore().getDataStore(listener).getSchema(qName); return findFeatureTypeGmlVersion(fType); }