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;
}
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;
}
Aggregations