* Get featureOfInterest identifiers for observation constellation * * @param oc * Observation constellation * @param session * Hibernate session Hibernate session * @return FeatureOfInterest identifiers for observation constellation * @throws CodedException */ @SuppressWarnings("unchecked") public List<String> getIdentifiers(DatasetEntity oc, Session session) throws OwsExceptionReport { return Lists.newArrayList(oc.getFeature().getIdentifier()); } /**
private Collection<String> getFeatureTypes() { return datasets.stream().filter(d -> d.isSetFeature()).filter(d -> d.getFeature().isSetFeatureType()) .map(d -> d.getFeature().getFeatureType().getFormat()).collect(Collectors.toSet()); }
private AbstractFeature createFeature(AbstractFeatureEntity feature) throws InvalidSridException, OwsExceptionReport { final SamplingFeature sampFeat = new SamplingFeature(new CodeWithAuthority(feature.getIdentifier())); if (feature.isSetName()) { sampFeat.addName(feature.getName()); } if (!Strings.isNullOrEmpty(feature.getDescription())) { sampFeat.setDescription(feature.getDescription()); } if (feature.isSetGeometry() && !feature.getGeometryEntity().isEmpty()) { sampFeat.setGeometry(getGeometryHandler().switchCoordinateAxisFromToDatasourceIfNeeded( JTSConverter.convert(feature.getGeometryEntity().getGeometry()))); } final Set<FeatureEntity> parentFeatures = feature.getParents(); if (parentFeatures != null && !parentFeatures.isEmpty()) { final List<AbstractFeature> sampledFeatures = new ArrayList<>(parentFeatures.size()); for (final FeatureEntity parentFeature : parentFeatures) { sampledFeatures.add(createFeature(parentFeature)); } sampFeat.setSampledFeatures(sampledFeatures); } return sampFeat; } /**
private ReferenceType getFeatureOfInterestReference(Dataset entity, Map<String, ReferenceType> featuresOfInterest) { String identifier = entity.getFeature().getIdentifier(); if (!featuresOfInterest.containsKey(identifier)) { ReferenceType referenceType = new ReferenceType(identifier); if (entity.getFeature().isSetName() ) { referenceType.setTitle(entity.getFeature().getName()); } featuresOfInterest.put(identifier, referenceType); } return featuresOfInterest.get(identifier); }
* Insert and/or get featureOfInterest object for identifier * * @param identifier * FeatureOfInterest identifier * @param url * FeatureOfInterest URL, if defined as link * @param session * Hibernate session * @return FeatureOfInterest object */ public AbstractFeatureEntity getOrInsert(String identifier, String url, Session session) { AbstractFeatureEntity feature = get(identifier, session); if (feature == null) { feature = new FeatureEntity(); feature.setIdentifier(identifier); if (url != null && !url.isEmpty()) { feature.setUrl(url); } FormatEntity type = new FormatDAO().getOrInsertFormatEntity(OGCConstants.UNKNOWN, session); feature.setFeatureType(type); session.save(feature); } else if (feature.getUrl() != null && !feature.getUrl().isEmpty() && url != null && !url.isEmpty()) { feature.setUrl(url); session.saveOrUpdate(feature); } // don't flush here because we may be batching return feature; } /**
if (getActiveProfile().isEncodeFeatureOfInterestInObservations()) { FeatureQueryHandlerQueryObject queryObject = new FeatureQueryHandlerQueryObject(getSession()); queryObject.setFeatureObject(foi).addFeatureIdentifier(foi.getIdentifier()).setVersion(getVersion()); final AbstractFeature feature = getFeatureQueryHandler().getFeatureByID(queryObject); if (getActiveProfile().getEncodingNamespaceForFeatureOfInterest() != null SamplingFeature samplingFeature = new SamplingFeature(new CodeWithAuthority(foi.getIdentifier())); if (foi.isSetIdentifierCodespace()) { samplingFeature.getIdentifierCodeWithAuthority().setCodeSpace(foi.getIdentifierCodespace().getName()); if (foi.isSetName()) { CodeType codeType = new CodeType(foi.getName()); if (foi.isSetNameCodespace()) { try { codeType.setCodeSpace(new URI(foi.getNameCodespace().getName())); } catch (URISyntaxException e) { throw new NoApplicableCodeException().causedBy(e).withMessage( "The codespace '{}' of the name is not an URI!", foi.getNameCodespace().getName());
if (observation.getDataset().getFeature() != null && observation.getDataset().getFeature().isSetIdentifier()) { builder.append(observation.getDataset().getFeature().getIdentifier()); } else { builder.append("");
protected ReferencedEnvelope getEnvelopeForOffering(OfferingEntity offering) throws OwsExceptionReport { if (offering.isSetGeometry()) { return new ReferencedEnvelope(JTSConverter.convert(offering.getGeometry()).getEnvelopeInternal(), offering.getGeometry().getSRID()); } else if (datasets != null && !datasets.isEmpty()) { Envelope e = new Envelope(); int srid = -1; for (DatasetEntity de : datasets) { if (de.isSetFeature() && de.getFeature().isSetGeometry() && !de.getFeature().getGeometryEntity().isEmpty()) { if (srid < 0 ) { srid = de.getFeature().getGeometryEntity().getGeometry().getSRID(); } e.expandToInclude(JTSConverter.convert(de.getFeature().getGeometryEntity().getGeometry()).getEnvelopeInternal()); } } return new ReferencedEnvelope(e, srid); } return new ReferencedEnvelope(); }
if (featureOfInterest.isSetGeometry()) { if (geom instanceof Point) { List<Coordinate> coords = Lists.newArrayList(); Geometry convert = JTSConverter.convert(featureOfInterest.getGeometry()); if (convert instanceof Point) { coords.add(convert.getCoordinate()); } else if (convert instanceof LineString) { coords.addAll(Lists.newArrayList(convert.getCoordinates())); } if (!coords.isEmpty()) { coords.add(geom.getCoordinate()); Geometry newGeometry = new GeometryFactory().createLineString(coords.toArray(new Coordinate[coords.size()])); newGeometry.setSRID(featureOfInterest.getGeometry().getSRID()); featureOfInterest.setGeometry(JTSConverter.convert(newGeometry)); } } } else { featureOfInterest.setGeometry(JTSConverter.convert(geom)); } session.saveOrUpdate(featureOfInterest); } @SuppressWarnings("unchecked")
@Override public String getLabelFrom(String locale) { StringBuilder sb = new StringBuilder(); sb.append(phenomenon.getLabelFrom(locale)) .append(" "); sb.append(procedure.getLabelFrom(locale)) .append(", "); sb.append(feature.getLabelFrom(locale)) .append(", "); return sb.append(offering.getLabelFrom(locale)) .toString(); }
private StationOutput createCondensedStation(QuantityDatasetEntity entity, DbQuery query, Session session) throws DataAccessException { AbstractFeatureEntity feature = entity.getFeature(); String featurePkid = Long.toString(feature.getId()); // XXX explicit cast here return ((StationRepository) stationRepository).getCondensedInstance(featurePkid, query, session); }
public boolean isSetFeatureType() { return getFeatureType() != null; }
if (getActiveProfile().isEncodeFeatureOfInterestInObservations()) { FeatureQueryHandlerQueryObject queryObject = new FeatureQueryHandlerQueryObject(getSession()); queryObject.setFeatureObject(foi).addFeatureIdentifier(foi.getIdentifier()).setVersion(getVersion()); final AbstractFeature feature = getFeatureQueryHandler().getFeatureByID(queryObject); if (getActiveProfile().getEncodingNamespaceForFeatureOfInterest() != null SamplingFeature samplingFeature = new SamplingFeature(new CodeWithAuthority(foi.getIdentifier())); if (foi.isSetIdentifierCodespace()) { samplingFeature.getIdentifierCodeWithAuthority().setCodeSpace(foi.getIdentifierCodespace().getName()); if (foi.isSetName()) { CodeType codeType = new CodeType(foi.getName()); if (foi.isSetNameCodespace()) { try { codeType.setCodeSpace(new URI(foi.getNameCodespace().getName())); } catch (URISyntaxException e) { throw new NoApplicableCodeException().causedBy(e).withMessage( "The codespace '{}' of the name is not an URI!", foi.getNameCodespace().getName());
* Insert and/or get featureOfInterest object for identifier * * @param identifier * FeatureOfInterest identifier * @param url * FeatureOfInterest URL, if defined as link * @param session * Hibernate session * @return FeatureOfInterest object */ public AbstractFeatureEntity getOrInsert(String identifier, String url, Session session) { AbstractFeatureEntity feature = get(identifier, session); if (feature == null) { feature = new FeatureEntity(); feature.setIdentifier(identifier); if (url != null && !url.isEmpty()) { feature.setUrl(url); } FormatEntity type = new FormatDAO().getOrInsertFormatEntity(OGCConstants.UNKNOWN, session); feature.setFeatureType(type); session.save(feature); } else if (feature.getUrl() != null && !feature.getUrl().isEmpty() && url != null && !url.isEmpty()) { feature.setUrl(url); session.saveOrUpdate(feature); } // don't flush here because we may be batching return feature; } /**
if (observation.getDataset().getFeature() != null && observation.getDataset().getFeature().isSetIdentifier()) { builder.append(observation.getDataset().getFeature().getIdentifier()); } else { builder.append("");
offering.setGeometryEntity(observation.getGeometryEntity()); } else if (observation.getDataset().isSetFeature() && observation.getDataset().getFeature().isSetGeometry()) { if (offering.isSetGeometry()) { offering.getGeometryEntity().getGeometry() .union(observation.getDataset().getFeature().getGeometryEntity().getGeometry()); } else { offering.setGeometryEntity(observation.getDataset().getFeature().getGeometryEntity());
if (featureOfInterest.isSetGeometry()) { if (geom instanceof Point) { List<Coordinate> coords = Lists.newArrayList(); Geometry convert = JTSConverter.convert(featureOfInterest.getGeometry()); if (convert instanceof Point) { coords.add(convert.getCoordinate()); } else if (convert instanceof LineString) { coords.addAll(Lists.newArrayList(convert.getCoordinates())); } if (!coords.isEmpty()) { coords.add(geom.getCoordinate()); Geometry newGeometry = new GeometryFactory().createLineString(coords.toArray(new Coordinate[coords.size()])); newGeometry.setSRID(featureOfInterest.getGeometry().getSRID()); featureOfInterest.setGeometry(JTSConverter.convert(newGeometry)); } } } else { featureOfInterest.setGeometry(JTSConverter.convert(geom)); } session.saveOrUpdate(featureOfInterest); } @SuppressWarnings("unchecked")
private String createDatasetLabel(DatasetEntity dataset, String locale) { PhenomenonEntity phenomenon = dataset.getPhenomenon(); ProcedureEntity procedure = dataset.getProcedure(); OfferingEntity offering = dataset.getOffering(); AbstractFeatureEntity feature = dataset.getFeature(); String procedureLabel = procedure.getLabelFrom(locale); String phenomenonLabel = phenomenon.getLabelFrom(locale); String offeringLabel = offering.getLabelFrom(locale); String stationLabel = feature.getLabelFrom(locale); StringBuilder sb = new StringBuilder(); return sb.append(phenomenonLabel) .append(" ") .append(procedureLabel) .append(", ") .append(stationLabel) .append(", ") .append(offeringLabel) .toString(); }
feature.getId()), owse);