Mercurial > dive4elements > gnv-client
changeset 457:47ad9721e692
Added RasterObject for caching the Rastertiles to get a better performance.
gnv-artifacts/trunk@509 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Tue, 05 Jan 2010 14:12:03 +0000 |
parents | b8080695ea62 |
children | 92d6cf448598 |
files | gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/math/QueriedXYDepth.java |
diffstat | 2 files changed, 45 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog Mon Jan 04 15:41:29 2010 +0000 +++ b/gnv-artifacts/ChangeLog Tue Jan 05 14:12:03 2010 +0000 @@ -1,3 +1,9 @@ +2010-01-05 Tim Englich <tim.englich@intevation.de> + + * src/main/java/de/intevation/gnv/math/QueriedXYDepth.java (depth): + Added the usage of the new RasterObject integrated in the geo-backend. + Now the Performance is much better accessing the depth to an coordinate. + 2010-01-04 Ingo Weinzierl <ingo.weinzierl@intevation.de> * src/main/java/de/intevation/gnv/utils/ArtifactXMLUtilities.java: Declared
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/math/QueriedXYDepth.java Mon Jan 04 15:41:29 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/math/QueriedXYDepth.java Tue Jan 05 14:12:03 2010 +0000 @@ -3,7 +3,9 @@ */ package de.intevation.gnv.math; +import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import org.apache.log4j.Logger; @@ -13,6 +15,7 @@ import de.intevation.gnv.geobackend.base.query.QueryExecutor; import de.intevation.gnv.geobackend.base.query.QueryExecutorFactory; import de.intevation.gnv.geobackend.base.query.exception.QueryException; +import de.intevation.gnv.geobackend.sde.datasources.RasterObject; /** @@ -30,6 +33,8 @@ private QueryExecutor queryExecutor = null; + private ArrayList<RasterObject> rasterData = new ArrayList<RasterObject>(); + /** * Constructor */ @@ -42,26 +47,44 @@ */ public double depth(Coordinate coordinate) { log.debug("QueriedXYDepth.depth for " + coordinate.x+" "+ coordinate.y); - double resultValue = 0; - Collection<Result> result = null; - try { - String[] filterValues = new String[]{"Point ("+coordinate.x+" "+coordinate.y+")"}; - result = this.queryExecutor.executeQuery(this.queryID,filterValues); - } catch (QueryException e) { - log.error(e,e); - } + double resultValue = Double.NaN; - if (result != null){ - if (!result.isEmpty()){ - Result row = result.iterator().next(); - resultValue = row.getDouble(0); - }else{ - resultValue = Double.NaN; + RasterObject ro = this.getRasterObject(coordinate); + + if (ro == null){ + Collection<Result> result = null; + try { + String[] filterValues = new String[]{"Point ("+coordinate.x+" "+coordinate.y+")"}; + result = this.queryExecutor.executeQuery(this.queryID,filterValues); + } catch (QueryException e) { + log.error(e,e); } - }else{ - resultValue = Double.NaN; + + if (result != null){ + if (!result.isEmpty()){ + Result row = result.iterator().next(); + ro = (RasterObject)row.getObject(0); + synchronized (rasterData) { + rasterData.add(ro); + } + } + } + } + if (ro != null){ + resultValue = ro.getValue(coordinate); } return resultValue; } + + private RasterObject getRasterObject(Coordinate coordinate){ + for (int i = 0; i < rasterData.size(); i++){ + RasterObject ro = rasterData.get(i); + if (ro.getEnvelope().contains(coordinate)){ + return ro; + } + } + return null; + + } }