use of org.opengis.observation.CompositePhenomenon in project geotoolkit by Geomatys.
the class OMUtils method getPhenomenon.
public static Phenomenon getPhenomenon(final String version, String name, final List<? extends Field> phenomenons, final String phenomenonIdBase, final Set<org.opengis.observation.Phenomenon> existingPhens) {
final Phenomenon phenomenon;
if (phenomenons.size() == 1) {
phenomenon = SOSXmlFactory.buildPhenomenon(version, phenomenons.get(0).name, phenomenons.get(0).label, phenomenons.get(0).name, phenomenons.get(0).description);
} else {
final Set<PhenomenonType> types = new LinkedHashSet<>();
for (Field phen : phenomenons) {
types.add(new PhenomenonType(phen.name, phen.label, phen.name, phen.description));
}
// look for an already existing (composite) phenomenon to use instead of creating a new one
for (org.opengis.observation.Phenomenon existingPhen : existingPhens) {
if (existingPhen instanceof CompositePhenomenon) {
CompositePhenomenon cphen = (CompositePhenomenon) existingPhen;
if (componentsEquals(cphen.getComponent(), types)) {
return (Phenomenon) cphen;
}
}
}
final String compositeId = "composite" + UUID.randomUUID().toString();
final String definition = phenomenonIdBase + compositeId;
if (name == null) {
name = definition;
}
phenomenon = new CompositePhenomenonType(compositeId, name, definition, null, null, types);
}
return phenomenon;
}
use of org.opengis.observation.CompositePhenomenon in project geotoolkit by Geomatys.
the class OMUtils method getPhenomenonsFields.
public static List<String> getPhenomenonsFields(final PhenomenonProperty phenProp) {
final List<String> results = new ArrayList<>();
if (phenProp.getHref() != null) {
results.add(phenProp.getHref());
} else if (phenProp.getPhenomenon() instanceof CompositePhenomenon) {
final CompositePhenomenon comp = (CompositePhenomenon) phenProp.getPhenomenon();
for (org.opengis.observation.Phenomenon phen : comp.getComponent()) {
if (phen instanceof org.geotoolkit.swe.xml.Phenomenon) {
final org.geotoolkit.swe.xml.Phenomenon p = (org.geotoolkit.swe.xml.Phenomenon) phen;
results.add((p.getName() != null) ? p.getName().getCode() : "");
}
}
} else if (phenProp.getPhenomenon() instanceof org.geotoolkit.swe.xml.Phenomenon) {
final org.geotoolkit.swe.xml.Phenomenon p = (org.geotoolkit.swe.xml.Phenomenon) phenProp.getPhenomenon();
results.add((p.getName() != null) ? p.getName().getCode() : "");
}
return results;
}
Aggregations