changeset 2126:d626ae185305

Use the fast cross section lines from backend now. flys-artifacts/trunk@3697 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 17 Jan 2012 17:05:18 +0000
parents 7a8f52267a5c
children 0c7847b8e85e
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/cache.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/WaterLineArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/CrossSectionWaterLineFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DataFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FastCrossSectionChunk.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FastCrossSectionLine.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FastCrossSectionLineFactory.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/StaticWQKmsState.java flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java
diffstat 13 files changed, 67 insertions(+), 91 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Jan 17 09:00:30 2012 +0000
+++ b/flys-artifacts/ChangeLog	Tue Jan 17 17:05:18 2012 +0000
@@ -1,3 +1,24 @@
+2012-01-17	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/FastCrossSectionLine.java:
+	  Deleted. It is in the backend now.
+
+	* src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java,
+	  src/main/java/de/intevation/flys/artifacts/model/FastCrossSectionChunk.java,
+	  src/main/java/de/intevation/flys/artifacts/model/CrossSectionWaterLineFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/FastCrossSectionLineFactory.java,
+	  src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java,
+	  src/main/java/de/intevation/flys/artifacts/WaterLineArtifact.java,
+	  src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java:
+	  Adjusted to use the fast cross section line from backend now.
+
+	* doc/conf/cache.xml: Store cross section lines cache on disk.
+
+	* src/main/java/de/intevation/flys/artifacts/states/StaticWQKmsState.java,
+	  src/main/java/de/intevation/flys/artifacts/model/DataFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java: Removed
+	  superfluous imports.
+
 2012-01-17	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	Fix assignment of stateId/hash in WaterlevelFacet.
--- a/flys-artifacts/doc/conf/cache.xml	Tue Jan 17 09:00:30 2012 +0000
+++ b/flys-artifacts/doc/conf/cache.xml	Tue Jan 17 17:05:18 2012 +0000
@@ -94,10 +94,12 @@
 
     <!-- This one is used to load chunks of the cross section lines  -->
     <cache name="fast-cross-section-lines"
-           maxElementsInMemory="100"
+           maxElementsInMemory="500"
            eternal="false"
            timeToLiveSeconds="7200"
            memoryStoreEvictionPolicy="LRU"
+		   overflowToDisk="true"
+           diskPersistent="true"
            />
 
     <!-- This one is used for the cross section lookup 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java	Tue Jan 17 09:00:30 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java	Tue Jan 17 17:05:18 2012 +0000
@@ -13,9 +13,10 @@
 import de.intevation.artifacts.CallMeta;
 
 import de.intevation.flys.artifacts.model.CrossSectionFacet;
-import de.intevation.flys.artifacts.model.FastCrossSectionLine;
 import de.intevation.flys.artifacts.model.FastCrossSectionLineFactory;
 
+import de.intevation.flys.model.FastCrossSectionLine;
+
 import de.intevation.flys.model.CrossSection;
 import de.intevation.flys.model.CrossSectionLine;
 import de.intevation.flys.artifacts.model.CrossSectionFactory;
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java	Tue Jan 17 09:00:30 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java	Tue Jan 17 17:05:18 2012 +0000
@@ -31,7 +31,7 @@
 
 import de.intevation.flys.geom.Lines;
 
-import de.intevation.flys.artifacts.model.FastCrossSectionLine;
+import de.intevation.flys.model.FastCrossSectionLine;
 
 /**
  * Artifact to access additional "waterlevel"-type of data, like the height
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Tue Jan 17 09:00:30 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Tue Jan 17 17:05:18 2012 +0000
@@ -36,7 +36,8 @@
 import de.intevation.flys.artifacts.model.WQKms;
 import de.intevation.flys.artifacts.model.WstValueTable;
 import de.intevation.flys.artifacts.model.WstValueTableFactory;
-import de.intevation.flys.artifacts.model.FastCrossSectionLine;
+
+import de.intevation.flys.model.FastCrossSectionLine;
 
 import de.intevation.flys.artifacts.states.DefaultState;
 import de.intevation.flys.artifacts.states.LocationDistanceSelect;
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WaterLineArtifact.java	Tue Jan 17 09:00:30 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WaterLineArtifact.java	Tue Jan 17 17:05:18 2012 +0000
@@ -1,7 +1,7 @@
 package de.intevation.flys.artifacts;
 
 
-import de.intevation.flys.artifacts.model.FastCrossSectionLine;
+import de.intevation.flys.model.FastCrossSectionLine;
 /**
  * Interface, Artifact can create WaterLines (Water against Cross-Profile).
  */
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/CrossSectionWaterLineFacet.java	Tue Jan 17 09:00:30 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/CrossSectionWaterLineFacet.java	Tue Jan 17 17:05:18 2012 +0000
@@ -12,7 +12,7 @@
 
 import de.intevation.flys.artifacts.WaterLineArtifact;
 
-import de.intevation.flys.artifacts.model.FastCrossSectionLine;
+import de.intevation.flys.model.FastCrossSectionLine;
 
 /**
  * Facet for Waterlines in Cross Sections.
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DataFacet.java	Tue Jan 17 09:00:30 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DataFacet.java	Tue Jan 17 17:05:18 2012 +0000
@@ -3,7 +3,6 @@
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.CallContext;
 
-import de.intevation.artifactdatabase.state.DefaultFacet;
 import de.intevation.artifactdatabase.state.Facet;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FastCrossSectionChunk.java	Tue Jan 17 09:00:30 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FastCrossSectionChunk.java	Tue Jan 17 17:05:18 2012 +0000
@@ -1,17 +1,21 @@
 package de.intevation.flys.artifacts.model;
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Collections;
 
 import java.io.Serializable;
 
-import de.intevation.flys.model.CrossSectionLine;
 import de.intevation.flys.model.CrossSection;
 
+import de.intevation.flys.model.FastCrossSectionLine;
+
+import org.apache.log4j.Logger;
+
 public class FastCrossSectionChunk
 implements   Serializable
 {
+    private static Logger log = Logger.getLogger(FastCrossSectionChunk.class);
+
     public static final String PREFIX = "FCSC:";
     public static final double KM_RANGE = 1.0;
 
@@ -29,13 +33,15 @@
         startKm = Math.floor(km);
         double stopKm = startKm + KM_RANGE;
 
-        List<CrossSectionLine> csls = cs.getLines(startKm, stopKm);
+        long startTime = System.currentTimeMillis();
 
-        crossSectionLines = new ArrayList
-            <FastCrossSectionLine>(csls.size());
+        crossSectionLines = cs.getFastLines(startKm, stopKm);
 
-        for (CrossSectionLine csl: csls) {
-            crossSectionLines.add(new FastCrossSectionLine(csl));
+        long stopTime = System.currentTimeMillis();
+
+        if (log.isDebugEnabled()) {
+            log.debug("Fetching cross section lines took " + 
+                (float)(stopTime-startTime)/1000f + " secs.");
         }
     }
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FastCrossSectionLine.java	Tue Jan 17 09:00:30 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-package de.intevation.flys.artifacts.model;
-
-import java.util.List;
-import java.util.Comparator;
-
-import java.io.Serializable;
-
-import java.math.BigDecimal;
-
-import de.intevation.flys.model.CrossSectionLine;
-
-import java.awt.geom.Point2D;
-
-public class FastCrossSectionLine
-implements   Serializable
-{
-    public static final double EPSILON = 1e-5;
-
-    public static final Comparator<FastCrossSectionLine> KM_CMP =
-        new Comparator<FastCrossSectionLine>() {
-            public int compare(
-                FastCrossSectionLine a,
-                FastCrossSectionLine b
-            ) {
-                double diff = a.km - b.km;
-                if (diff < -EPSILON) return -1;
-                return diff > +EPSILON ? +1 : 0;
-            }
-        };
-
-    protected double km;
-    protected List<Point2D> points;
-
-    public FastCrossSectionLine() {
-    }
-
-    public FastCrossSectionLine(double km) {
-        this.km = km;
-    }
-
-    public FastCrossSectionLine(CrossSectionLine csl) {
-        BigDecimal kmBD = csl.getKm();
-        km = kmBD != null ? kmBD.doubleValue() : 0d;
-        points = csl.fetchCrossSectionLinesPoints();
-    }
-
-    public double getKm() {
-        return km;
-    }
-
-    public void setKm(double km) {
-        this.km = km;
-    }
-
-    public List<Point2D> getPoints() {
-        return points;
-    }
-
-    public void setPoints(List<Point2D> points) {
-        this.points = points;
-    }
-
-    public double [][] fetchCrossSectionProfile() {
-        return CrossSectionLine.fetchCrossSectionProfile(points);
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FastCrossSectionLineFactory.java	Tue Jan 17 09:00:30 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FastCrossSectionLineFactory.java	Tue Jan 17 17:05:18 2012 +0000
@@ -3,16 +3,21 @@
 import de.intevation.flys.artifacts.cache.CacheFactory;
 
 import de.intevation.flys.model.CrossSection;
-import de.intevation.flys.model.CrossSectionLine;
+
+import de.intevation.flys.model.FastCrossSectionLine;
 
 import net.sf.ehcache.Cache;
 import net.sf.ehcache.Element;
 
 import java.util.List;
 
+import org.apache.log4j.Logger;
 
 public class FastCrossSectionLineFactory
 {
+    private static Logger log =
+        Logger.getLogger(FastCrossSectionLineFactory.class);
+
     public static final String CACHE_NAME = "fast-cross-section-lines";
 
     private FastCrossSectionLineFactory() {
@@ -24,11 +29,14 @@
     ) {
         Cache cache = CacheFactory.getCache(CACHE_NAME);
 
+        boolean debug = log.isDebugEnabled();
+
         if (cache == null) {
-            List<CrossSectionLine> lines = cs.getLines(km, km);
-            return lines.isEmpty()
-                ? null
-                : new FastCrossSectionLine(lines.get(0));
+            if (debug) {
+                log.debug("No cross section chunk cache configured.");
+            }
+            List<FastCrossSectionLine> lines = cs.getFastLines(km, km);
+            return lines.isEmpty() ? null : lines.get(0);
         }
 
         String cacheKey = FastCrossSectionChunk.createHashKey(cs, km);
@@ -38,9 +46,18 @@
         FastCrossSectionChunk fcsc;
 
         if (element != null) {
+            if (debug) {
+                log.debug("Found cross section chunk in cache id: " +
+                    cs.getId() + " km: " + km);
+            }
+
             fcsc = (FastCrossSectionChunk)element.getValue();
         }
         else {
+            if (debug) {
+                log.debug("Not found cross section chunk in cache id: " +
+                    cs.getId() + " km: " + km + " -> loading");
+            }
             fcsc = new FastCrossSectionChunk(cs, km);
             element = new Element(cacheKey, fcsc);
             cache.put(element);
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/StaticWQKmsState.java	Tue Jan 17 09:00:30 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/StaticWQKmsState.java	Tue Jan 17 17:05:18 2012 +0000
@@ -12,14 +12,10 @@
 import de.intevation.flys.artifacts.FLYSArtifact;
 import de.intevation.flys.artifacts.StaticWQKmsArtifact;
 
-import de.intevation.flys.artifacts.model.DataFacet;
 import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.WQKms;
 import de.intevation.flys.artifacts.model.WQKmsFacet;
 
-import de.intevation.flys.artifacts.resources.Resources;
-
-
 /**
  * Only state of WQKmsArtifact.
  */
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Tue Jan 17 09:00:30 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Tue Jan 17 17:05:18 2012 +0000
@@ -18,7 +18,7 @@
 import de.intevation.flys.artifacts.model.CrossSectionFacet;
 import de.intevation.flys.jfree.StyledXYSeries;
 
-import de.intevation.flys.artifacts.model.FastCrossSectionLine;
+import de.intevation.flys.model.FastCrossSectionLine;
 
 /**
  * An OutGenerator that generates cross section graphs.

http://dive4elements.wald.intevation.org