Hi,
I've been working on adding time domain support to imagemosaic-jdbc,
specifically
for pgraster. The current state is that it seems to work, but it's really
probably
at a proof of concept stage. I haven't done anything about tests or
documentation,
yet, and apart from making sure things still build I haven't updated drivers
other
than pgraster.
The current code is attached. At this point I'd mainly like to know if I'm on
the
right track, and I'd appreciate some ideas about what sort and level of testing
is
needed.
To add time domain support, the <tileTable> element gets a new
<timeAttributeName>
sub-element. If that element is present time domain support is enabled. The
corresponding field needs to be of a type that's handled by jdbc as a Date, e.g.
timestamp.
<tileTable>
<blobAttributeName name="rast"/>
<timeAttributeName name="datetime"/>
</tileTable>
I can make a pull request if it helps with reviewing.
Frank
--
Frank Gevaerts frank.gevae...@fks.be
fks bvba - Formal and Knowledge Systems http://www.fks.be/
Schampbergstraat 32 Tel: ++32-(0)11-21 49 11
B-3511 KURINGEN-HASSELT Fax: ++32-(0)11-22 04 19
>From 4eade4c40c1918b4fab33fda04bfca2fd107279e Mon Sep 17 00:00:00 2001
From: Frank Gevaerts <frank.gevae...@fks.be>
Date: Tue, 5 Jul 2016 14:04:04 +0200
Subject: [PATCH 3/5] PGRaster time domain support
---
.../org/geotools/gce/imagemosaic/jdbc/Config.java | 8 +-
.../imagemosaic/jdbc/ImageMosaicJDBCFormat.java | 2 +-
.../imagemosaic/jdbc/ImageMosaicJDBCReader.java | 79 ++++++++-
.../geotools/gce/imagemosaic/jdbc/JDBCAccess.java | 9 +-
.../gce/imagemosaic/jdbc/JDBCAccessBase.java | 15 +-
.../imagemosaic/jdbc/custom/JDBCAccessCustom.java | 2 +-
.../jdbc/custom/JDBCAccessOracleGeoRaster.java | 15 +-
.../jdbc/custom/JDBCAccessPGRaster.java | 182 ++++++++++++++++++++-
.../jdbc/custom/JDBCAccessH2Custom.java | 14 +-
9 files changed, 313 insertions(+), 13 deletions(-)
diff --git a/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/Config.java b/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/Config.java
index b268632..4f7d110 100644
--- a/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/Config.java
+++ b/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/Config.java
@@ -80,6 +80,8 @@ public class Config {
private String keyAttributeNameInTileTable;
+ private String timeAttributeNameInTileTable;
+
private String keyAttributeNameInSpatialTable;
private String geomAttributeNameInSpatialTable;
@@ -124,7 +126,6 @@ public class Config {
private String jdbcAccessClassName;
-
protected Config() {
}
@@ -219,6 +220,7 @@ public class Config {
if (tileTableElem!=null) {
result.blobAttributeNameInTileTable = readNameString(tileTableElem, "blobAttributeName");
result.keyAttributeNameInTileTable = readNameString(tileTableElem, "keyAttributeName");
+ result.timeAttributeNameInTileTable = readNameString(tileTableElem, "timeAttributeName");
}
@@ -508,5 +510,7 @@ public class Config {
return ignoreAxisOrder;
}
-
+ public String getTimeAttributeNameInTileTable() {
+ return timeAttributeNameInTileTable;
+ }
}
diff --git a/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/ImageMosaicJDBCFormat.java b/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/ImageMosaicJDBCFormat.java
index f2a2121..2dcb0b6 100644
--- a/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/ImageMosaicJDBCFormat.java
+++ b/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/ImageMosaicJDBCFormat.java
@@ -156,7 +156,7 @@ public class ImageMosaicJDBCFormat extends AbstractGridFormat implements Format
readParameters = new ParameterGroup(
new DefaultParameterDescriptorGroup(mInfo,
new GeneralParameterDescriptor[] { READ_GRIDGEOMETRY2D,
- OUTPUT_TRANSPARENT_COLOR, BACKGROUND_COLOR }));
+ OUTPUT_TRANSPARENT_COLOR, BACKGROUND_COLOR, TIME }));
// reading parameters
writeParameters = null;
diff --git a/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/ImageMosaicJDBCReader.java b/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/ImageMosaicJDBCReader.java
index 8be5602..147d602 100644
--- a/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/ImageMosaicJDBCReader.java
+++ b/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/ImageMosaicJDBCReader.java
@@ -25,8 +25,10 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -256,6 +258,63 @@ public class ImageMosaicJDBCReader extends AbstractGridCoverage2DReader {
LOGGER.info("----PARAMS END-------");
}
+ @Override
+ public String[] getMetadataNames() {
+ final List<String> metadataNames = new ArrayList<String>();
+ metadataNames.add(TIME_DOMAIN);
+ metadataNames.add(HAS_TIME_DOMAIN);
+ metadataNames.add(TIME_DOMAIN_MINIMUM);
+ metadataNames.add(TIME_DOMAIN_MAXIMUM);
+ metadataNames.add(TIME_DOMAIN_RESOLUTION);
+ metadataNames.add(TIME_DOMAIN + "_DATATYPE");
+ return metadataNames.toArray(new String[0]);
+ }
+
+ /**
+ * Populate the metadata names array for the specified coverageName
+ * @param coverageName
+ * @return
+ */
+ @Override
+ public String[] getMetadataNames(String coverageName) {
+ return getMetadataNames();
+ }
+
+ @Override
+ public String getMetadataValue(final String name) {
+ String value = null;
+ final boolean hasTimeDomain = config.getTimeAttributeNameInTileTable() != null;
+
+ if (name.equalsIgnoreCase(HAS_TIME_DOMAIN)) {
+ value =String.valueOf(hasTimeDomain);
+ }
+ else if (name.equalsIgnoreCase(TIME_DOMAIN_RESOLUTION)) { // NOT supported
+ value = null;
+ }
+ else if (hasTimeDomain) {
+ if (name.equalsIgnoreCase(TIME_DOMAIN)) {
+ value = jdbcAccess.getTimeValues();
+ }
+ else if (name.equalsIgnoreCase(TIME_DOMAIN_MINIMUM)) {
+ value = jdbcAccess.getTimeMinimum();
+ }
+ else if (name.equalsIgnoreCase(TIME_DOMAIN_MAXIMUM)) {
+ value =jdbcAccess.getTimeMaximum();
+ }
+ else if (name.equalsIgnoreCase("time_domain_datatype")) {
+ value = "Date"; // TODO
+ }
+ }
+
+ return value;
+ }
+
+ @Override
+ public String getMetadataValue(String coverageName, final String name) {
+ return getMetadataValue(name);
+ }
+
+
/*
* (non-Javadoc)
*
@@ -286,6 +345,7 @@ public class ImageMosaicJDBCReader extends AbstractGridCoverage2DReader {
Color backgroundColor = (Color) ImageMosaicJDBCFormat.BACKGROUND_COLOR
.getDefaultValue();
+ List<?> requestedTimes = null;
Rectangle dim = null;
@@ -304,6 +364,15 @@ public class ImageMosaicJDBCReader extends AbstractGridCoverage2DReader {
} else if (param.getDescriptor().getName().getCode().equals(
ImageMosaicJDBCFormat.BACKGROUND_COLOR.getName().toString())) {
backgroundColor = (Color) param.getValue();
+ } else if (param.getDescriptor().getName().getCode().equals(
+ ImageMosaicJDBCFormat.TIME.getName().toString())) {
+ final Object value = param.getValue();
+ if(value!=null) {
+ final List<?> dates = (List<?>) value;
+ if (dates!=null&& dates.size()>0) {
+ requestedTimes=dates;
+ }
+ }
}
}
}
@@ -313,7 +382,7 @@ public class ImageMosaicJDBCReader extends AbstractGridCoverage2DReader {
// Loading tiles trying to optimize as much as possible
//
// /////////////////////////////////////////////////////////////////////
- GridCoverage2D coverage = loadTiles(backgroundColor,outputTransparentColor, dim, state);
+ GridCoverage2D coverage = loadTiles(backgroundColor,outputTransparentColor, dim, state, requestedTimes);
LOGGER.info("Mosaic Reader needs : " + ((new Date()).getTime() - start.getTime())
+ " millisecs");
@@ -391,11 +460,13 @@ public class ImageMosaicJDBCReader extends AbstractGridCoverage2DReader {
* @param outputTransparentColor
* the transparent color
* @param pixelDimension
+ * @param requestedTimes
+ * the time domain times
* @return the gridcoverage as the final result
* @throws IOException
*/
private GridCoverage2D loadTiles(Color backgroundColor,Color outputTransparentColor, Rectangle pixelDimension,
- ImageMosaicJDBCReaderState state) throws IOException {
+ ImageMosaicJDBCReaderState state, List<?> requestedTimes) throws IOException {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine(new StringBuffer("Creating mosaic to comply with envelope ").append(
(state.getRequestedEnvelope() != null) ? state.getRequestedEnvelope()
@@ -452,7 +523,7 @@ public class ImageMosaicJDBCReader extends AbstractGridCoverage2DReader {
ImageLevelInfo info = jdbcAccess.getLevelInfo(imageChoice.intValue());
LOGGER.info("Coverage " + info.getCoverageName() + " using spatial table "
- + info.getSpatialTableName() + ", image table " + info.getTileTableName());
+ + info.getSpatialTableName() + ", image table " + info.getTileTableName() + ", times " + requestedTimes);
ImageComposerThread imageComposerThread = new ImageComposerThread(backgroundColor,outputTransparentColor,
pixelDimension, state.getRequestEnvelopeTransformed(), info, state.getTileQueue(),
@@ -460,7 +531,7 @@ public class ImageMosaicJDBCReader extends AbstractGridCoverage2DReader {
imageComposerThread.start();
jdbcAccess.startTileDecoders(pixelDimension, state.getRequestEnvelopeTransformed(), info,
- state.getTileQueue(), coverageFactory);
+ state.getTileQueue(), coverageFactory, requestedTimes);
try {
imageComposerThread.join();
diff --git a/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/JDBCAccess.java b/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/JDBCAccess.java
index 8535a55..4abe246 100644
--- a/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/JDBCAccess.java
+++ b/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/JDBCAccess.java
@@ -20,6 +20,7 @@ import java.awt.Rectangle;
import java.io.IOException;
import java.sql.SQLException;
import java.util.concurrent.LinkedBlockingQueue;
+import java.util.List;
import org.geotools.coverage.grid.GridCoverageFactory;
import org.geotools.geometry.GeneralEnvelope;
@@ -49,12 +50,14 @@ public interface JDBCAccess {
* a queue where to put the thread results
* @param coverageFactory
* GridCoverageFactory
+ * @param requestedTimes
+ * Requested times
* @throws IOException
*/
public abstract void startTileDecoders(Rectangle pixelDimension,
GeneralEnvelope requestEnvelope, ImageLevelInfo info,
LinkedBlockingQueue<TileQueueElement> tileQueue,
- GridCoverageFactory coverageFactory) throws IOException;
+ GridCoverageFactory coverageFactory, List<?> requestedTimes) throws IOException;
/**
* @param level
@@ -68,6 +71,10 @@ public interface JDBCAccess {
*/
public int getNumOverviews();
+ public String getTimeMinimum();
+ public String getTimeMaximum();
+ public String getTimeValues();
+
/**
* initialze the the JDBCAccess object, has to be called exactly once
*
diff --git a/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/JDBCAccessBase.java b/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/JDBCAccessBase.java
index b6b63d1..e669f32 100644
--- a/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/JDBCAccessBase.java
+++ b/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/JDBCAccessBase.java
@@ -557,7 +557,7 @@ abstract class JDBCAccessBase implements JDBCAccess {
public void startTileDecoders(Rectangle pixelDimension,
GeneralEnvelope requestEnvelope, ImageLevelInfo levelInfo,
LinkedBlockingQueue<TileQueueElement> tileQueue,
- GridCoverageFactory coverageFactory) throws IOException {
+ GridCoverageFactory coverageFactory, List<?> requestedTimes) throws IOException {
Date start = new Date();
Connection con = null;
List<ImageDecoderThread> threads = new ArrayList<ImageDecoderThread>();
@@ -825,4 +825,17 @@ abstract class JDBCAccessBase implements JDBCAccess {
LOGGER.info("Using "+ availableProcessors + " CPU(s)");
return Executors.newFixedThreadPool(availableProcessors);
}
+
+
+ public String getTimeMinimum() {
+ return null;
+ }
+
+ public String getTimeMaximum() {
+ return null;
+ }
+
+ public String getTimeValues() {
+ return null;
+ }
}
diff --git a/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/custom/JDBCAccessCustom.java b/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/custom/JDBCAccessCustom.java
index cadbf8b..00e5056 100644
--- a/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/custom/JDBCAccessCustom.java
+++ b/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/custom/JDBCAccessCustom.java
@@ -100,7 +100,7 @@ public abstract class JDBCAccessCustom implements JDBCAccess {
*/
abstract public void startTileDecoders(Rectangle pixelDimension, GeneralEnvelope requestEnvelope,
ImageLevelInfo info, LinkedBlockingQueue<TileQueueElement> tileQueue,
- GridCoverageFactory coverageFactory) throws IOException;
+ GridCoverageFactory coverageFactory, List<?> requestedTimes) throws IOException;
/**
* getConnection
diff --git a/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/custom/JDBCAccessOracleGeoRaster.java b/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/custom/JDBCAccessOracleGeoRaster.java
index e4e0975..3fbbb0d 100644
--- a/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/custom/JDBCAccessOracleGeoRaster.java
+++ b/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/custom/JDBCAccessOracleGeoRaster.java
@@ -35,6 +35,7 @@ import java.sql.Types;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.logging.Logger;
+import java.util.List;
import javax.media.jai.PlanarImage;
@@ -393,7 +394,7 @@ public class JDBCAccessOracleGeoRaster extends JDBCAccessCustom {
public void startTileDecoders(Rectangle pixelDimension, GeneralEnvelope requestEnvelope,
ImageLevelInfo info, LinkedBlockingQueue<TileQueueElement> tileQueue,
- GridCoverageFactory coverageFactory) throws IOException {
+ GridCoverageFactory coverageFactory, List<?> requestedTimes) throws IOException {
long start = System.currentTimeMillis();
LOGGER.fine("Starting GeoRaster Tile Decoder");
@@ -549,4 +550,16 @@ public class JDBCAccessOracleGeoRaster extends JDBCAccessCustom {
}
}
+
+ public String getTimeMinimum() {
+ return null;
+ }
+
+ public String getTimeMaximum() {
+ return null;
+ }
+
+ public String getTimeValues() {
+ return null;
+ }
}
diff --git a/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/custom/JDBCAccessPGRaster.java b/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/custom/JDBCAccessPGRaster.java
index 7d3597d..819bd44 100644
--- a/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/custom/JDBCAccessPGRaster.java
+++ b/modules/plugin/imagemosaic-jdbc/src/main/java/org/geotools/gce/imagemosaic/jdbc/custom/JDBCAccessPGRaster.java
@@ -22,6 +22,8 @@ import java.awt.geom.Rectangle2D;
import java.io.IOException;
import java.sql.*;
+import java.text.SimpleDateFormat;
+
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
@@ -35,6 +37,7 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
+import java.util.TimeZone;
import org.geotools.coverage.grid.GridCoverageFactory;
import org.geotools.gce.imagemosaic.jdbc.Config;
@@ -43,6 +46,7 @@ import org.geotools.gce.imagemosaic.jdbc.ImageLevelInfo;
import org.geotools.gce.imagemosaic.jdbc.TileQueueElement;
import org.geotools.geometry.GeneralEnvelope;
import org.geotools.util.logging.Logging;
+import org.geotools.util.Range;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Envelope;
@@ -171,6 +175,8 @@ public class JDBCAccessPGRaster extends JDBCAccessCustom {
*
* @param coverageFactory
* not used (passed as per interface requirement)
+ *
+ * @param requestedTimes the list of times and time ranges to select
*
**/
@@ -183,7 +189,7 @@ public class JDBCAccessPGRaster extends JDBCAccessCustom {
*/
public void startTileDecoders(Rectangle pixelDimension, GeneralEnvelope requestEnvelope,
ImageLevelInfo levelInfo, LinkedBlockingQueue<TileQueueElement> tileQueue,
- GridCoverageFactory coverageFactory) throws IOException {
+ GridCoverageFactory coverageFactory, List<?> requestedTimes) throws IOException {
Date start = new Date();
Connection con = null;
List<ImageDecoderThread> threads = new ArrayList<ImageDecoderThread>();
@@ -191,6 +197,48 @@ public class JDBCAccessPGRaster extends JDBCAccessCustom {
String gridStatement = statementMap.get(levelInfo);
+ if (requestedTimes != null && !requestedTimes.isEmpty()) {
+ List<String> timeConditions = new ArrayList<String>();
+ SimpleDateFormat df = getSQLTimeFormat();
+ for (Object o: requestedTimes) {
+ String fragment = null;
+ if (o instanceof Range && ((Range) o).getElementClass() == Date.class) {
+ Range<Date> r = (Range<Date>) o;
+ String left = null;
+ String right = null;
+ if(r.getMinValue() != null) {
+ left = "'" + df.format(r.getMinValue()) + "'" + (r.isMinIncluded()?" <= ":" < ") + getConfig().getTimeAttributeNameInTileTable();
+ }
+ if(r.getMaxValue() != null) {
+ right = "'" + df.format(r.getMaxValue()) + "'" + (r.isMaxIncluded()?" >= ":" > ") + getConfig().getTimeAttributeNameInTileTable();
+ }
+ if (left != null && right != null) {
+ timeConditions.add("(" + left + " AND " + right + ")");
+ }
+ else if (left != null) {
+ timeConditions.add(left);
+ }
+ else if (right != null) {
+ timeConditions.add(right);
+ }
+ }
+ else if (o instanceof Date){
+ timeConditions.add(getConfig().getTimeAttributeNameInTileTable() + " = '" + df.format((Date) o) + "'");
+ }
+ }
+
+ if (!timeConditions.isEmpty()) {
+ StringBuilder sb = new StringBuilder(" AND (");
+ for (String s: timeConditions) {
+ sb.append(s).append(" OR ");
+ }
+ // Remove the last " OR "
+ sb.setLength(sb.length() - 4);
+ sb.append(")");
+ gridStatement = gridStatement + sb.toString();
+ }
+ }
+
try {
con = getConnection();
@@ -697,5 +745,137 @@ public class JDBCAccessPGRaster extends JDBCAccessCustom {
return null;
}
+ private static final String SQL_PATTERN = "yyyy-MM-dd HH:mm:ss.SSS+00";
+
+ private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone("UTC");
+
+ private SimpleDateFormat getSQLTimeFormat() {
+ final SimpleDateFormat df = new SimpleDateFormat(UTC_PATTERN);
+ df.setTimeZone(UTC_TIME_ZONE);
+ return df;
+ }
+
+ private static final String UTC_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
+
+ private SimpleDateFormat getTimeFormat() {
+ final SimpleDateFormat df = new SimpleDateFormat(UTC_PATTERN);
+ df.setTimeZone(UTC_TIME_ZONE);
+ return df;
+ }
+
+ private String getTableName() {
+ Connection con = null;
+ ResultSet r = null;
+ PreparedStatement s = null;
+ try {
+ con = getConnection();
+ String stmt = "select " + getConfig().getTileTableNameAtribute() + " from " + getConfig().getMasterTable() + " where " + getConfig().getCoverageNameAttribute() + " = ? ORDER BY " + getConfig().getResXAttribute() + " LIMIT 1";
+ s = con.prepareStatement(stmt);
+ s.setString(1, getConfig().getCoverageName());
+ r = s.executeQuery();
+ if (r.next())
+ {
+ return r.getString(1);
+ }
+ }
+ catch (SQLException e)
+ {
+ LOGGER.warning(e.toString());
+ }
+ finally
+ {
+ closeConnection(con);
+ closeStmt(s);
+ closeResultSet(r);
+ }
+ return null;
+ }
+ public String getTimeMinimum() {
+ Connection con = null;
+ ResultSet r = null;
+ PreparedStatement s = null;
+ try {
+ con = getConnection();
+ String stmt = "select min(" + getConfig().getTimeAttributeNameInTileTable() + ") from " + getTableName();
+ s = con.prepareStatement(stmt);
+ r = s.executeQuery();
+ if (r.next())
+ {
+ return getTimeFormat().format(r.getDate(1));
+ }
+ }
+ catch (SQLException e)
+ {
+ LOGGER.warning(e.toString());
+ }
+ finally
+ {
+ closeConnection(con);
+ closeStmt(s);
+ closeResultSet(r);
+ }
+ return null;
+ }
+
+ public String getTimeMaximum() {
+ Connection con = null;
+ ResultSet r = null;
+ PreparedStatement s = null;
+ try {
+ con = getConnection();
+ String stmt = "select max(" + getConfig().getTimeAttributeNameInTileTable() + ") from " + getTableName();
+ s = con.prepareStatement(stmt);
+ r = s.executeQuery();
+ if (r.next())
+ {
+ return getTimeFormat().format(r.getDate(1));
+ }
+ }
+ catch (SQLException e)
+ {
+ LOGGER.warning(e.toString());
+ }
+ finally
+ {
+ closeConnection(con);
+ closeStmt(s);
+ closeResultSet(r);
+ }
+ return null;
+ }
+
+ public String getTimeValues() {
+ Connection con = null;
+ ResultSet r = null;
+ PreparedStatement s = null;
+ try {
+ con = getConnection();
+ String stmt = "select distinct " + getConfig().getTimeAttributeNameInTileTable() + " from " + getTableName();
+ s = con.prepareStatement(stmt);
+ r = s.executeQuery();
+ StringBuilder sb = new StringBuilder();
+ while (r.next())
+ {
+ sb.append(getTimeFormat().format(r.getDate(1)));
+ sb.append(",");
+ }
+ if (sb.length() > 0)
+ {
+ sb.setLength(sb.length()-1);
+ return sb.toString();
+ }
+ }
+ catch (SQLException e)
+ {
+ LOGGER.warning(e.toString());
+ }
+ finally
+ {
+ closeConnection(con);
+ closeStmt(s);
+ closeResultSet(r);
+ }
+ return null;
+ }
}
diff --git a/modules/plugin/imagemosaic-jdbc/src/test/java/org/geotools/gce/imagemosaic/jdbc/custom/JDBCAccessH2Custom.java b/modules/plugin/imagemosaic-jdbc/src/test/java/org/geotools/gce/imagemosaic/jdbc/custom/JDBCAccessH2Custom.java
index 67ec999..0827531 100644
--- a/modules/plugin/imagemosaic-jdbc/src/test/java/org/geotools/gce/imagemosaic/jdbc/custom/JDBCAccessH2Custom.java
+++ b/modules/plugin/imagemosaic-jdbc/src/test/java/org/geotools/gce/imagemosaic/jdbc/custom/JDBCAccessH2Custom.java
@@ -25,6 +25,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.concurrent.LinkedBlockingQueue;
+import java.util.List;
import javax.imageio.ImageIO;
@@ -113,7 +114,7 @@ public class JDBCAccessH2Custom extends JDBCAccessCustom {
@Override
public void startTileDecoders(Rectangle pixelDimension, GeneralEnvelope requestEnvelope,
ImageLevelInfo info, LinkedBlockingQueue<TileQueueElement> tileQueue,
- GridCoverageFactory coverageFactory) throws IOException {
+ GridCoverageFactory coverageFactory, List<?> requestedTimes) throws IOException {
try {
Connection con = getConnection();
int level = getLevelInfos().indexOf(info);
@@ -147,4 +148,15 @@ public class JDBCAccessH2Custom extends JDBCAccessCustom {
}
+ public String getTimeMinimum() {
+ return null;
+ }
+
+ public String getTimeMaximum() {
+ return null;
+ }
+
+ public String getTimeValues() {
+ return null;
+ }
}
--
2.8.1
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel