Search in sources :

Example 1 with BinProfileSubSensor

use of org.n52.sos.netcdf.data.subsensor.BinProfileSubSensor in project SOS by 52North.

the class AbstractNetcdfEncoder method populateHeightDepthArray.

private Double populateHeightDepthArray(AbstractSensorDataset sensorDataset, Array heightDephtArray, Variable v) throws EncodingException {
    Index index = heightDephtArray.getIndex();
    int indexCounter = 0;
    Double consistentBinHeight = null;
    for (SubSensor subSensor : sensorDataset.getSubSensors()) {
        if (subSensor instanceof ProfileSubSensor) {
            index.setDim(0, indexCounter++);
            heightDephtArray.setDouble(index, checkValue(v, ((ProfileSubSensor) subSensor).getHeight()));
            // check for consistent bin size
            if (subSensor instanceof BinProfileSubSensor) {
                double binHeight = checkValue(v, ((BinProfileSubSensor) subSensor).getBinHeight());
                if (consistentBinHeight == null) {
                    consistentBinHeight = binHeight;
                } else if (consistentBinHeight != getNetcdfHelper().getFillValue() && consistentBinHeight != binHeight) {
                    // mark bin height as inconsistent
                    consistentBinHeight = getNetcdfHelper().getFillValue();
                }
            }
        } else {
            throw new EncodingException("Non-profile subsensors not supported.");
        }
    }
    return consistentBinHeight;
}
Also used : BinProfileSubSensor(org.n52.sos.netcdf.data.subsensor.BinProfileSubSensor) EncodingException(org.n52.svalbard.encode.exception.EncodingException) Index(ucar.ma2.Index) ProfileSubSensor(org.n52.sos.netcdf.data.subsensor.ProfileSubSensor) SubSensor(org.n52.sos.netcdf.data.subsensor.SubSensor) BinProfileSubSensor(org.n52.sos.netcdf.data.subsensor.BinProfileSubSensor) ArrayDouble(ucar.ma2.ArrayDouble) ProfileSubSensor(org.n52.sos.netcdf.data.subsensor.ProfileSubSensor) BinProfileSubSensor(org.n52.sos.netcdf.data.subsensor.BinProfileSubSensor)

Aggregations

BinProfileSubSensor (org.n52.sos.netcdf.data.subsensor.BinProfileSubSensor)1 ProfileSubSensor (org.n52.sos.netcdf.data.subsensor.ProfileSubSensor)1 SubSensor (org.n52.sos.netcdf.data.subsensor.SubSensor)1 EncodingException (org.n52.svalbard.encode.exception.EncodingException)1 ArrayDouble (ucar.ma2.ArrayDouble)1 Index (ucar.ma2.Index)1