Search in sources :

Example 1 with ScaledTemporalRange

use of org.locationtech.geowave.core.geotime.store.query.ScaledTemporalRange in project geowave by locationtech.

the class KMeansUtils method setRunnerTimeParams.

public static ScaledTemporalRange setRunnerTimeParams(final KMeansRunner runner, final DataStorePluginOptions inputDataStore, String typeName) {
    if (typeName == null) {
        // if no id provided, locate a single
        // featureadapter
        final List<String> typeNameList = FeatureDataUtils.getFeatureTypeNames(inputDataStore);
        if (typeNameList.size() == 1) {
            typeName = typeNameList.get(0);
        } else if (typeNameList.isEmpty()) {
            LOGGER.error("No feature adapters found for use with time param");
            return null;
        } else {
            LOGGER.error("Multiple feature adapters found for use with time param. Please specify one.");
            return null;
        }
    }
    final ScaledTemporalRange scaledRange = new ScaledTemporalRange();
    final String timeField = FeatureDataUtils.getTimeField(inputDataStore, typeName);
    if (timeField != null) {
        final TemporalRange timeRange = DateUtilities.getTemporalRange(inputDataStore, typeName, timeField);
        if (timeRange != null) {
            scaledRange.setTimeRange(timeRange.getStartTime(), timeRange.getEndTime());
        }
        final String geomField = FeatureDataUtils.getGeomField(inputDataStore, typeName);
        final Envelope bbox = org.locationtech.geowave.adapter.vector.util.FeatureGeometryUtils.getGeoBounds(inputDataStore, typeName, geomField);
        if (bbox != null) {
            final double xRange = bbox.getMaxX() - bbox.getMinX();
            final double yRange = bbox.getMaxY() - bbox.getMinY();
            final double valueRange = Math.min(xRange, yRange);
            scaledRange.setValueRange(0.0, valueRange);
        }
        runner.setTimeParams(timeField, scaledRange);
        return scaledRange;
    }
    LOGGER.error("Couldn't determine field to use for time param");
    return null;
}
Also used : ScaledTemporalRange(org.locationtech.geowave.core.geotime.store.query.ScaledTemporalRange) TemporalRange(org.locationtech.geowave.core.geotime.store.query.TemporalRange) ScaledTemporalRange(org.locationtech.geowave.core.geotime.store.query.ScaledTemporalRange) Envelope(org.locationtech.jts.geom.Envelope)

Aggregations

ScaledTemporalRange (org.locationtech.geowave.core.geotime.store.query.ScaledTemporalRange)1 TemporalRange (org.locationtech.geowave.core.geotime.store.query.TemporalRange)1 Envelope (org.locationtech.jts.geom.Envelope)1