Search in sources :

Example 1 with JAXBFeatureTypeReader

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++;
            }
        }
    }
}
Also used : JAXBException(javax.xml.bind.JAXBException) JAXBFeatureTypeReader(org.geotoolkit.feature.xml.jaxb.JAXBFeatureTypeReader) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 2 with JAXBFeatureTypeReader

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();
}
Also used : FeatureType(org.opengis.feature.FeatureType) ArrayList(java.util.ArrayList) JAXBFeatureTypeReader(org.geotoolkit.feature.xml.jaxb.JAXBFeatureTypeReader) FeatureComparator(org.apache.sis.test.feature.FeatureComparator)

Example 3 with JAXBFeatureTypeReader

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());
}
Also used : FeatureType(org.opengis.feature.FeatureType) AttributeType(org.opengis.feature.AttributeType) ArrayList(java.util.ArrayList) JAXBFeatureTypeReader(org.geotoolkit.feature.xml.jaxb.JAXBFeatureTypeReader) PropertyType(org.opengis.feature.PropertyType)

Example 4 with JAXBFeatureTypeReader

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();
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) FeatureType(org.opengis.feature.FeatureType) FeatureTypeBuilder(org.apache.sis.feature.builder.FeatureTypeBuilder) AttributeTypeBuilder(org.apache.sis.feature.builder.AttributeTypeBuilder) ArrayList(java.util.ArrayList) JAXBFeatureTypeReader(org.geotoolkit.feature.xml.jaxb.JAXBFeatureTypeReader) FeatureComparator(org.apache.sis.test.feature.FeatureComparator)

Example 5 with JAXBFeatureTypeReader

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;
}
Also used : JAXBFeatureTypeReader(org.geotoolkit.feature.xml.jaxb.JAXBFeatureTypeReader)

Aggregations

JAXBFeatureTypeReader (org.geotoolkit.feature.xml.jaxb.JAXBFeatureTypeReader)26 FeatureType (org.opengis.feature.FeatureType)22 ArrayList (java.util.ArrayList)13 FeatureComparator (org.apache.sis.test.feature.FeatureComparator)8 JAXBException (javax.xml.bind.JAXBException)7 IOException (java.io.IOException)4 URL (java.net.URL)4 FeatureTypeBuilder (org.apache.sis.feature.builder.FeatureTypeBuilder)3 JAXPStreamFeatureReader (org.geotoolkit.feature.xml.jaxp.JAXPStreamFeatureReader)3 PropertyType (org.opengis.feature.PropertyType)3 InputStream (java.io.InputStream)2 MalformedURLException (java.net.MalformedURLException)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 DataStoreException (org.apache.sis.storage.DataStoreException)2 UnconvertibleObjectException (org.apache.sis.util.UnconvertibleObjectException)2 FeatureReader (org.geotoolkit.storage.feature.FeatureReader)2 GenericNameIndex (org.geotoolkit.storage.feature.GenericNameIndex)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1