Search in sources :

Example 1 with CompositePhenomenon

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CompositePhenomenonType(org.geotoolkit.swe.xml.v101.CompositePhenomenonType) Field(org.geotoolkit.observation.model.Field) CompositePhenomenonType(org.geotoolkit.swe.xml.v101.CompositePhenomenonType) PhenomenonType(org.geotoolkit.swe.xml.v101.PhenomenonType) Phenomenon(org.geotoolkit.swe.xml.Phenomenon) CompositePhenomenon(org.opengis.observation.CompositePhenomenon) CompositePhenomenon(org.opengis.observation.CompositePhenomenon) LineString(org.geotoolkit.gml.xml.LineString)

Example 2 with CompositePhenomenon

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;
}
Also used : Phenomenon(org.geotoolkit.swe.xml.Phenomenon) ArrayList(java.util.ArrayList) CompositePhenomenon(org.opengis.observation.CompositePhenomenon) Phenomenon(org.geotoolkit.swe.xml.Phenomenon) CompositePhenomenon(org.opengis.observation.CompositePhenomenon) LineString(org.geotoolkit.gml.xml.LineString)

Aggregations

LineString (org.geotoolkit.gml.xml.LineString)2 Phenomenon (org.geotoolkit.swe.xml.Phenomenon)2 CompositePhenomenon (org.opengis.observation.CompositePhenomenon)2 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 Field (org.geotoolkit.observation.model.Field)1 CompositePhenomenonType (org.geotoolkit.swe.xml.v101.CompositePhenomenonType)1 PhenomenonType (org.geotoolkit.swe.xml.v101.PhenomenonType)1