use of org.geotoolkit.swe.xml.Phenomenon 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;
}
Aggregations