Search in sources :

Example 6 with FeatureProperty

use of org.geotoolkit.gml.xml.FeatureProperty in project geotoolkit by Geomatys.

the class NetcdfFeatureReader method getFeatureFromFOI.

protected final Feature getFeatureFromFOI(final AnyFeature foi) {
    if (foi instanceof SamplingFeature) {
        final SamplingFeature feature = (SamplingFeature) foi;
        final org.opengis.geometry.Geometry isoGeom = feature.getGeometry();
        try {
            final Geometry geom;
            if (isoGeom instanceof AbstractGeometry) {
                geom = GeometrytoJTS.toJTS((AbstractGeometry) isoGeom, AxisResolve.STRICT);
            } else {
                geom = null;
            }
            if (firstCRS && isoGeom != null) {
                // configure crs in the feature type
                final CoordinateReferenceSystem crs = ((AbstractGeometry) isoGeom).getCoordinateReferenceSystem(false);
                type = new ReprojectMapper(type, crs).getMappedType();
                firstCRS = false;
            }
            final Feature f = type.newInstance();
            f.setPropertyValue(AttributeConvention.IDENTIFIER, feature.getId());
            f.setPropertyValue(OMFeatureTypes.ATT_DESC.toString(), feature.getDescription());
            f.setPropertyValue(OMFeatureTypes.ATT_NAME.toString(), feature.getName());
            f.setPropertyValue(OMFeatureTypes.ATT_POSITION.toString(), geom);
            final List<String> sampleds = new ArrayList<>();
            for (FeatureProperty featProp : feature.getSampledFeatures()) {
                if (featProp.getHref() != null) {
                    sampleds.add(featProp.getHref());
                }
            }
            f.setPropertyValue(OMFeatureTypes.ATT_SAMPLED.toString(), sampleds);
            return f;
        } catch (FactoryException ex) {
            LOGGER.log(Level.WARNING, "error while transforming GML geometry to JTS", ex);
        }
    } else {
        LOGGER.warning("unable to find a valid feature of interest in the observation");
    }
    return null;
}
Also used : AbstractGeometry(org.geotoolkit.gml.xml.AbstractGeometry) FactoryException(org.opengis.util.FactoryException) ReprojectMapper(org.geotoolkit.feature.ReprojectMapper) ArrayList(java.util.ArrayList) SamplingFeature(org.geotoolkit.sampling.xml.SamplingFeature) SamplingFeature(org.geotoolkit.sampling.xml.SamplingFeature) Feature(org.opengis.feature.Feature) AnyFeature(org.opengis.observation.AnyFeature) FeatureProperty(org.geotoolkit.gml.xml.FeatureProperty) AbstractGeometry(org.geotoolkit.gml.xml.AbstractGeometry) Geometry(org.locationtech.jts.geom.Geometry) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem)

Example 7 with FeatureProperty

use of org.geotoolkit.gml.xml.FeatureProperty in project geotoolkit by Geomatys.

the class XmlObservationReader method getFeatureOfInterestNames.

private Collection<String> getFeatureOfInterestNames() throws DataStoreException {
    final Set<String> featureOfInterest = new HashSet<>();
    for (Object xmlObject : xmlObjects) {
        if (xmlObject instanceof ObservationCollection) {
            final ObservationCollection collection = (ObservationCollection) xmlObject;
            for (Observation obs : collection.getMember()) {
                final AbstractObservation o = (AbstractObservation) obs;
                final FeatureProperty foiProp = o.getPropertyFeatureOfInterest();
                featureOfInterest.add(OMUtils.getFOIId(foiProp));
            }
        } else if (xmlObject instanceof AbstractObservation) {
            final AbstractObservation obs = (AbstractObservation) xmlObject;
            final FeatureProperty foiProp = obs.getPropertyFeatureOfInterest();
            featureOfInterest.add(OMUtils.getFOIId(foiProp));
        }
    }
    return featureOfInterest;
}
Also used : Observation(org.opengis.observation.Observation) FeatureProperty(org.geotoolkit.gml.xml.FeatureProperty) ObservationCollection(org.opengis.observation.ObservationCollection) HashSet(java.util.HashSet)

Aggregations

FeatureProperty (org.geotoolkit.gml.xml.FeatureProperty)7 ArrayList (java.util.ArrayList)3 AbstractGeometry (org.geotoolkit.gml.xml.AbstractGeometry)2 SamplingFeature (org.geotoolkit.sampling.xml.SamplingFeature)2 DataArrayProperty (org.geotoolkit.swe.xml.DataArrayProperty)2 Geometry (org.locationtech.jts.geom.Geometry)2 Feature (org.opengis.feature.Feature)2 AnyFeature (org.opengis.observation.AnyFeature)2 Observation (org.opengis.observation.Observation)2 ObservationCollection (org.opengis.observation.ObservationCollection)2 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)2 FactoryException (org.opengis.util.FactoryException)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 Path (java.nio.file.Path)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Stream (java.util.stream.Stream)1