Search in sources :

Example 6 with Phenomenon

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

Aggregations

Phenomenon (org.geotoolkit.swe.xml.Phenomenon)6 IOException (java.io.IOException)4 ExtractionResult (org.geotoolkit.observation.model.ExtractionResult)4 ProcedureTree (org.geotoolkit.observation.model.ExtractionResult.ProcedureTree)4 GeoSpatialBound (org.geotoolkit.observation.model.GeoSpatialBound)4 Process (org.geotoolkit.observation.xml.Process)4 SamplingFeature (org.geotoolkit.sampling.xml.SamplingFeature)4 MeasureStringBuilder (org.geotoolkit.sos.MeasureStringBuilder)4 AbstractDataRecord (org.geotoolkit.swe.xml.AbstractDataRecord)4 Array (ucar.ma2.Array)4 Variable (ucar.nc2.Variable)4 ArrayList (java.util.ArrayList)2 LinkedHashSet (java.util.LinkedHashSet)2 Field (org.geotoolkit.observation.model.Field)2 CompositePhenomenonType (org.geotoolkit.swe.xml.v101.CompositePhenomenonType)2 PhenomenonType (org.geotoolkit.swe.xml.v101.PhenomenonType)2 HashSet (java.util.HashSet)1 LineString (org.geotoolkit.gml.xml.LineString)1 Test (org.junit.Test)1 DirectPosition (org.opengis.geometry.DirectPosition)1