@Override public ConfigurableFactory<TileTransformer<?>> createFactory (String name, ConfigurableFactory<?> parent, List<String> path) { return new TileTransformerFactory(name, parent, path); } }
public TileTransformerFactory( String name, ConfigurableFactory<?> parent, List<String> path) { super(name, getFactoryClass(), parent, path); addProperty(TILE_TRANSFORMER_TYPE); addProperty(INITIALIZATION_DATA); }
@Override public Pair<Double, Double> getTransformedExtrema(LayerConfiguration config) throws ConfigurationException { return getRawExtrema(config); }
@Override protected TileTransformer<?> create () throws ConfigurationException { String transformerTypes = getPropertyValue(TILE_TRANSFORMER_TYPE); if ("filtervars".equals(transformerTypes)) { JSONObject variables = getPropertyValue(INITIALIZATION_DATA); return new FilterVarsDoubleArrayTileTransformer<>(variables); } else if ("filterbucket".equals(transformerTypes)) { JSONObject arguments = getPropertyValue(INITIALIZATION_DATA); return new FilterByBucketTileTransformer<>(arguments); } else if ("filtertopicbucket".equals(transformerTypes)) { JSONObject arguments = getPropertyValue(INITIALIZATION_DATA); return new FilterTopicByBucketTileTransformer<>(arguments); } else if ("avgdivbucket".equals(transformerTypes)) { JSONObject arguments = getPropertyValue(INITIALIZATION_DATA); return new AvgDivBucketTileTransformer<>(arguments); } else if ("avglogbucket".equals(transformerTypes)) { JSONObject arguments = getPropertyValue(INITIALIZATION_DATA); return new AvgLogBucketTileTransformer<>(arguments); } else { // 'identity' or none passed in will give the default transformer return new IdentityTileTransformer<Object>(); } } }
/** * Set the tile index, and level minimum and maximum for the impending read * @param tileIndex The index of the tile to be rendererd. * @param levelMinimum The level minimum. * @param levelMaximum The level maximum. */ public void setLevelProperties (TileIndex tileIndex, String levelMinimum, String levelMaximum) { _tileCoordinate = tileIndex; _levelMaximum = levelMaximum; _levelMinimum = levelMinimum; try { TileTransformer<?> tileTransformer = produce(TileTransformer.class); if (null != tileTransformer) { Pair<Double, Double> extrema = tileTransformer.getTransformedExtrema(this); _transformFactory.setExtrema(extrema.getFirst(), extrema.getSecond()); Pair<Double, Double> rawExtrema = tileTransformer.getRawExtrema(this); _alphaTransformFactory.setExtrema(rawExtrema.getFirst(), rawExtrema.getSecond()/2); } } catch (ConfigurationException e1) { String layer; try { layer = getPropertyValue(LAYER_ID); } catch (ConfigurationException e2) { layer = "unknown layer"; } LOGGER.warn("Error determining layer-specific extrema for "+layer); } }
@Override public JSONObject transform (JSONObject inputJSON) throws JSONException { JSONObject resultJSON = new JSONObject(inputJSON); if (inputJSON.has("meta")) { resultJSON.put("meta", filterKeywordMetadata( inputJSON.getJSONObject("meta") )); } return resultJSON; }
return transformer.transform( deserializedJSON );
@Override public Pair<Double, Double> getTransformedExtrema(LayerConfiguration config) throws ConfigurationException { return getRawExtrema(config); }
@Override public Pair<Double, Double> getRawExtrema(LayerConfiguration config) throws ConfigurationException { String layer = config.getPropertyValue(LayerConfiguration.LAYER_ID); double minimumValue = parseExtremum(config, LayerConfiguration.LEVEL_MINIMUMS, "minimum", layer, 0.0); double maximumValue = parseExtremum(config, LayerConfiguration.LEVEL_MAXIMUMS, "maximum", layer, 1000.0); return new Pair<>(minimumValue, maximumValue); }
@Override public Pair<Double, Double> getTransformedExtrema(LayerConfiguration config) throws ConfigurationException { // Parse the mins and maxes for the buckets out of the supplied JSON. if (_minVals == null) { String layer = config.getPropertyValue(LAYER_ID); _minVals = parseExtremum(config, LEVEL_MINIMUMS, "minimum", layer, 0.0); _maxVals = parseExtremum(config, LEVEL_MAXIMUMS, "maximum", layer, 1000.0); } // Compute the min/max for the range of buckets. double minimumValue = Double.MIN_VALUE; double maximumValue = -Double.MAX_VALUE; for (Integer index: _variables) { Double val = _minVals.get(index); if (val < minimumValue) { minimumValue = val; } val = _maxVals.get(index); if (val > maximumValue) { maximumValue = val; } } return new Pair<>(minimumValue, maximumValue); }
_minVals = parseExtremum(config, LayerConfiguration.LEVEL_MINIMUMS, "minimum", layer, 0.0); _maxVals = parseExtremum(config, LayerConfiguration.LEVEL_MAXIMUMS, "maximum", layer, 1000.0); if (_startBucket == null) { _startBucket = 0;
@Override public Pair<Double, Double> getTransformedExtrema(LayerConfiguration config) throws ConfigurationException { Pair<Double, Double> result = super.getTransformedExtrema(config); double min = result.getFirst() <= 0.0 ? 0.0 : Math.log10(result.getFirst()); double max = result.getSecond() <= 0.0 ? 0.0 : Math.log10(result.getSecond()); return new Pair<>(min, max); } }
@Override public TileData<List<T>> transform (TileData<List<T>> inputData) throws Exception { TileData<List<T>> resultTile = inputData; // add in metadata to the tile JSONObject metadata = new JSONObject(inputData.getMetaData("meta")); JSONObject filteredMetadata = null; if ( metadata.length() > 0 ) { filteredMetadata = filterKeywordMetadata(metadata); if (null != filteredMetadata) { resultTile.setMetaData("meta", filteredMetadata); } } return resultTile; }
modifiedData = tileTransformer.transform( modifiedData );