@Override public List<T> getDefaultValue () { return _data.getDefaultValue(); }
@Override public List<T> getDefaultValue () { return _base.getDefaultValue(); }
@Override public T getDefaultValue () { return _source.getDefaultValue(); }
@Override public List<T> getDefaultValue () { return Arrays.asList(_data.getDefaultValue()); }
@Override public T getDefaultValue () { List<T> baseDefault = _base.getDefaultValue(); if (null == baseDefault || baseDefault.size() <= _slice) return null; else return baseDefault.get(_slice); }
@Override public List<T> getDefaultValue() { List<T> ourDefault = new ArrayList<>(); for (TileData<List<T>> component: _components) { List<T> componentDefault = component.getDefaultValue(); if (null == componentDefault) // If one component has a null default, we can't aggregate any of the defaults properly. return null; ourDefault.addAll(componentDefault); } return ourDefault; }
@Override public List<T> getDefaultValue() { List<T> base = _base.getDefaultValue(); if (null == base) return null; List<T> ourDefault = new ArrayList<>(); for (int slice: _slices) { if (base.size() > slice) ourDefault.add(base.get(slice)); else ourDefault.add(null); } return ourDefault; }
@Override public List<T> getDefaultValue () { List<T> default1 = _tileData1.getDefaultValue(); List<T> default2 = _tileData2.getDefaultValue(); if (null == default1 || null == default2) return null; else { List<T> ourDefault = new ArrayList<>(); for (int i=0; i<Math.min(default1.size(), default2.size()); ++i) { ourDefault.add((T) _op.calculate(default1.get(i), default2.get(i), _errorValue)); } return ourDefault; } }
@Override public List<T> getDefaultValue () { List<T> baseDefault = _tileData.getDefaultValue(); if (null == baseDefault) return null; else { List<T> ourDefault = new ArrayList<>(); for (T t: baseDefault) ourDefault.add((T) _op.calculate(t, _errorValue)); } return null; }
@Override public List<T> getDefaultValue () { List<T> baseDefault = _base.getDefaultValue(); if (null == baseDefault) return null; else { List<T> ourDefault = new ArrayList<>(); int binSize = baseDefault.size(); // if the bucket range falls outside of the available bin range, return empty list. null values assume full range boolean inRange = ( _endBucket == null && _startBucket == null ) || ( _endBucket >= 0 && _startBucket <= binSize ); // If start or end (but not both) fall outside the bin range, constrain the range to available bin range int start = ( _startBucket != null && _startBucket >= 0 ) ? _startBucket : 0; int end = ( _endBucket != null && _endBucket < binSize ) ? _endBucket : binSize; for(int i = 0; i < binSize; i++) { if (i >= start && i <= end && inRange ) { ourDefault.add(baseDefault.get(i)); } else { ourDefault.add(null); } } return ourDefault; } }
@Override public TileData<T> combine(TileData<T> data, TileIndex index, int coarseness, JSONObject tileProperties) throws IOException, JSONException { TileData normalizingData = TileIOUtils.tileDataForIndex(index, _dataId, _serializer, _pyramidIO, coarseness, tileProperties); // Need to make sure TileData is of type List<?> for use with BinaryOperationTileView if (!(data.getDefaultValue() instanceof List<?>)) { data = new ListTileView(data); } if (!(normalizingData.getDefaultValue() instanceof List<?>)) { normalizingData = new ListTileView(normalizingData); } // Both datasets need to have the same number of buckets for BinaryOperationTileView int normalizeSize = getBucketCount((TileData<List<?>>)normalizingData); int dataSize = getBucketCount((TileData<List<?>>)data); if (dataSize < normalizeSize) { data = new ScaledTileView(data, normalizeSize); } else if (normalizeSize < dataSize) { normalizingData = new ScaledTileView(normalizingData, dataSize); } return new BinaryOperationTileView( data, normalizingData, BinaryOperator.OPERATOR_TYPE.DIVIDE, 0.0); } }
private void serializeDense (TileData<T> tile, OutputStream stream) throws IOException { Schema recordSchema = getRecordSchema(); Schema tileSchema = getTileSchema(StorageType.Dense); TileIndex idx = tile.getDefinition(); List<GenericRecord> bins = new ArrayList<GenericRecord>(); List<T> denseData = DenseTileData.getData(tile); for (T value: denseData) { GenericRecord bin = new GenericData.Record(recordSchema); setValue(bin, value); bins.add(bin); } GenericRecord tileRecord = new GenericData.Record(tileSchema); tileRecord.put("level", idx.getLevel()); tileRecord.put("xIndex", idx.getX()); tileRecord.put("yIndex", idx.getY()); tileRecord.put("xBinCount", idx.getXBins()); tileRecord.put("yBinCount", idx.getYBins()); tileRecord.put("values", bins); tileRecord.put("meta", getTileMetaData(tile)); T defaultValue = tile.getDefaultValue(); if (null == defaultValue) { tileRecord.put("default", null); } else { GenericRecord defaultValueRecord = new GenericData.Record(recordSchema); setValue(defaultValueRecord, tile.getDefaultValue()); tileRecord.put("default", defaultValueRecord); } writeRecord(tileRecord, tileSchema, stream); }
public TileData<List<T>> harden () { TileIndex index = getDefinition(); if (isDense()) { DenseTileData<List<T>> hardened = new DenseTileData<>(index); hardened.setDefaultValue(_base.getDefaultValue()); for (int x=0; x<index.getXBins(); ++x) { for (int y=0; y<index.getYBins(); ++y) { hardened.setBin(x, y, getBin(x, y)); } } return hardened; } else { SparseTileData<List<T>> hardened = new SparseTileData<>(index, _base.getDefaultValue()); for (int x=0; x<index.getXBins(); ++x) { for (int y=0; y<index.getYBins(); ++y) { List<T> value = getBin(x, y); if (null != value) { hardened.setBin(x, y, getBin(x, y)); } } } return hardened; } }