use of org.geotoolkit.feature.xml.jaxb.JAXBFeatureTypeReader in project geotoolkit by Geomatys.
the class JAXPStreamFeatureReader method readFeatureTypes.
private void readFeatureTypes() {
// we search an embedded featureType description
String schemaLocation = reader.getAttributeValue(Namespaces.XSI, "schemaLocation");
if (isReadEmbeddedFeatureType() && schemaLocation != null) {
final JAXBFeatureTypeReader featureTypeReader = new JAXBFeatureTypeReader();
schemaLocation = schemaLocation.trim();
final String[] urls = schemaLocation.split("\\s+");
for (int i = 0; i < urls.length; i++) {
final String namespace = urls[i];
if (!(namespace.equalsIgnoreCase("http://www.opengis.net/gml") || namespace.equalsIgnoreCase("http://www.opengis.net/wfs")) && i + 1 < urls.length) {
final String fturl = urls[i + 1];
schemaLocations.put(namespace, fturl);
try {
final URI uri = Utils.resolveURI(base, fturl);
featureTypes = featureTypeReader.read(uri);
} catch (IOException | JAXBException | URISyntaxException ex) {
// TODO : should we not crash here ?
LOGGER.log(Level.WARNING, null, ex);
}
i = i + 2;
} else if (namespace.equalsIgnoreCase("http://www.opengis.net/gml") || namespace.equalsIgnoreCase("http://www.opengis.net/wfs")) {
i++;
}
}
}
}
use of org.geotoolkit.feature.xml.jaxb.JAXBFeatureTypeReader in project geotoolkit by Geomatys.
the class XmlFeatureTypeTest method testReadSimpleFeatureType.
@Test
public void testReadSimpleFeatureType() throws JAXBException {
final JAXBFeatureTypeReader reader = getReader(true);
final List<FeatureType> types = new ArrayList<>(reader.read(XmlFeatureTypeTest.class.getResourceAsStream("/org/geotoolkit/feature/xml/SimpleType.xsd")).getValues());
removeGMLBaseTypes(types);
assertEquals(1, types.size());
FeatureComparator comparator = new FeatureComparator(simpleTypeFull, types.get(0));
comparator.ignoredCharacteristics.add("http://www.w3.org/1999/xlink:href");
comparator.ignoredCharacteristics.add("mapping");
comparator.compare();
}
use of org.geotoolkit.feature.xml.jaxb.JAXBFeatureTypeReader in project geotoolkit by Geomatys.
the class XmlFeatureTypeTest method testReadSimpleFeatureEmpty2.
@Test
public void testReadSimpleFeatureEmpty2() throws JAXBException {
final JAXBFeatureTypeReader reader = getReader(false);
final List<FeatureType> types = new ArrayList<>(reader.read(XmlFeatureTypeTest.class.getResourceAsStream("/org/geotoolkit/feature/xml/SimpleTypeEmpty.xsd")).getValues());
removeGMLBaseTypes(types);
assertEquals(1, types.size());
// TODO we should check all properties
final FeatureType type = types.get(0);
final PropertyType itype = type.getProperty("http://www.opengis.net/gml/3.2:identifier");
assertNotNull(itype);
assertTrue(itype instanceof AttributeType);
final AttributeType ct = (AttributeType) itype;
assertEquals(String.class, ct.getValueClass());
assertNotNull(ct.characteristics().get("@codeSpace"));
// assertEquals("CodeWithAuthorityType", ct.getName().tip().toString());
}
use of org.geotoolkit.feature.xml.jaxb.JAXBFeatureTypeReader in project geotoolkit by Geomatys.
the class XmlFeatureTypeTest method testReadWfsFeatureType.
@Test
public void testReadWfsFeatureType() throws JAXBException {
final JAXBFeatureTypeReader reader = getReader(true);
final List<FeatureType> types = new ArrayList<>(reader.read(XmlFeatureTypeTest.class.getResourceAsStream("/org/geotoolkit/feature/xml/wfs1.xsd")).getValues());
removeGMLBaseTypes(types);
assertEquals(1, types.size());
final String ns = "http://mapserver.gis.umn.edu/mapserver";
final FeatureTypeBuilder ftb = new FeatureTypeBuilder();
ftb.setName(ns, "quadrige");
ftb.setSuperTypes(GMLConvention.ABSTRACTFEATURETYPE_31);
AttributeTypeBuilder atb = ftb.addAttribute(Geometry.class).setName(ns, "msGeometry").setMinimumOccurs(0).setMaximumOccurs(1);
atb.addCharacteristic(NILLABLE_CHARACTERISTIC).setDefaultValue(true);
atb.addRole(AttributeRole.DEFAULT_GEOMETRY);
ftb.addAttribute(String.class).setName(ns, "C_SIEPT38").setMinimumOccurs(1).setMaximumOccurs(1);
ftb.addAttribute(String.class).setName(ns, "L_SIEPT").setMinimumOccurs(1).setMaximumOccurs(1);
final FeatureType wfsType = ftb.build();
FeatureComparator comparator = new FeatureComparator(wfsType, types.get(0));
comparator.ignoredCharacteristics.add("http://www.w3.org/1999/xlink:href");
comparator.ignoredCharacteristics.add("http://www.w3.org/2001/XMLSchema-instance:@nil");
comparator.ignoredCharacteristics.add("mapping");
comparator.compare();
}
use of org.geotoolkit.feature.xml.jaxb.JAXBFeatureTypeReader in project geotoolkit by Geomatys.
the class XmlFeatureTypeTest method getReader.
private static JAXBFeatureTypeReader getReader(boolean skipStandardObjectProperties) {
final JAXBFeatureTypeReader reader = new JAXBFeatureTypeReader();
reader.setSkipStandardObjectProperties(skipStandardObjectProperties);
return reader;
}
Aggregations