Mercurial > dive4elements > gnv-client
changeset 444:85f48e287fb3
Added configuration for vertical cross sections ("Profilschnitte")
gnv-artifacts/trunk@492 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 30 Dec 2009 10:35:19 +0000 |
parents | da21c256a0ba |
children | f42ed4f10b79 |
files | gnv-artifacts/ChangeLog gnv-artifacts/doc/conf/conf.xml gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContext.java gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java |
diffstat | 4 files changed, 154 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog Tue Dec 29 14:54:17 2009 +0000 +++ b/gnv-artifacts/ChangeLog Wed Dec 30 10:35:19 2009 +0000 @@ -1,3 +1,19 @@ +2009-12-30 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/conf/conf.xml: Added section gnv/vertical-cross-section + to configure the "Profilschnitte". + <samples width="..." height="..."/> configures the size of + the sample area. Defaults to 1024x768. + <filters><filter>...</filter></filters> configures the + list of post processing filters applied to the sample area + after the interpolation is done. Defaults to empty list. + + * src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContext.java: + Added keys for vertical cross section samples and filters. + + * src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java: + Parse the configuration for the new parameters. + 2009-12-29 Sascha L. Teichmann <sascha.teichmann@intevation.de> * doc/conf/conf.xml: Added a gnv/horizontal-cross-section-profile
--- a/gnv-artifacts/doc/conf/conf.xml Tue Dec 29 14:54:17 2009 +0000 +++ b/gnv-artifacts/doc/conf/conf.xml Wed Dec 30 10:35:19 2009 +0000 @@ -416,6 +416,15 @@ <!-- This section configures the "horizontales Schnittprofil" --> <samples number="200"/> </horizontal-cross-section-profile> + <vertical-cross-section> + <!-- This section configures the "Profilschnitt" --> + <samples width="1024" height="768"/> + <filters> + <filter factory="de.intevation.gnv.raster.KernelFilter.GaussFactory" + sigma="1" + radius="5"/> + <filters> + </vertical-cross-section> </gnv> <ehcache> <!-- In this Section the Path to Configurationfile for the EHCache,
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContext.java Tue Dec 29 14:54:17 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContext.java Wed Dec 30 10:35:19 2009 +0000 @@ -4,8 +4,11 @@ package de.intevation.gnv.artifacts.context; import org.apache.log4j.Logger; + import org.w3c.dom.Document; +import java.awt.Dimension; + import de.intevation.artifactdatabase.DefaultArtifactContext; /** @@ -32,6 +35,15 @@ public static final String PALETTES_KEY = "gnv.color.palettes"; + public static final String VERTICAL_CROSS_SECTION_SAMPLES_KEY = + "gnv.vertical.cross.section.samples"; + + public static final Dimension DEFAULT_VERTICAL_CROSS_SECTION_SAMPLES = + new Dimension(1024, 768); + + public static final String VERTICAL_CROSS_SECTION_FILTER_FACTORIES_KEY = + "gnv.vertical.cross.section.filter.factories"; + public GNVArtifactContext() { super(); log.debug("GNVArtifactContext.Constructor");
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java Tue Dec 29 14:54:17 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java Wed Dec 30 10:35:19 2009 +0000 @@ -12,6 +12,9 @@ import java.util.Properties; import java.util.HashMap; import java.util.ArrayList; +import java.util.Collections; + +import java.awt.Dimension; import org.apache.log4j.Logger; @@ -29,6 +32,7 @@ import de.intevation.gnv.artifacts.cache.CacheFactory; import de.intevation.gnv.raster.Palette; +import de.intevation.gnv.raster.Filter; import de.intevation.gnv.raster.PaletteManager; import de.intevation.artifacts.ArtifactContextFactory; @@ -68,6 +72,12 @@ public final static String HORIZONTAL_CROSS_SECTION_PROFILE_SAMPLES = "/artifact-database/gnv/horizontal-cross-section-profile/samples/@number"; + public final static String VERTICAL_CROSS_SECTION_SAMPLES = + "/artifact-database/gnv/vertical-cross-section/samples"; + + public final static String VERTICAL_CROSS_SECTION_FILTERS = + "/artifact-database/gnv/vertical-cross-section/filters/filter"; + /** * Constructor */ @@ -120,6 +130,8 @@ configureHorizontalCrossSectionProfile(config, returnValue); + configureVerticalCrossSection(config, returnValue); + } catch (FileNotFoundException e) { log.error(e, e); } catch (IOException e) { @@ -130,6 +142,111 @@ return returnValue; } + protected void configureVerticalCrossSection( + Document config, + GNVArtifactContext context + ) { + log.info("configuration of vertical cross section"); + configureVerticalCrossSectionSamples(config, context); + configureVerticalCrossSectionFilters(config, context); + } + + protected void configureVerticalCrossSectionFilters( + Document config, + GNVArtifactContext context + ) { + log.info("configuration of vertical cross section filters"); + + NodeList filters = Config.getNodeSetXPath( + VERTICAL_CROSS_SECTION_FILTERS); + + ArrayList<Filter.Factory> filterFactories = + new ArrayList<Filter.Factory>(); + + if (filters == null) { + log.warn("no filters found"); + } + else { + for (int i = 0, N = filters.getLength(); i < N; ++i) { + Element filterElement = (Element)filters.item(i); + String factoryName = filterElement.getAttribute("factory"); + if ((factoryName = factoryName.trim()).length() > 0) { + try { + Class clazz = Class.forName(factoryName); + Filter.Factory filterFactory = + (Filter.Factory)clazz.newInstance(); + filterFactories.add(filterFactory); + } + catch (ClassNotFoundException cnfe) { + log.error("filter class not found", cnfe); + } + catch (InstantiationException ie) { + log.error("cannot instantiate filter factory", ie); + } + catch (IllegalAccessException iae) { + log.error("cannot access filter factory", iae); + } + catch (ClassCastException cce) { + log.error("not a filter factory class", cce); + } + } + else { + log.error("No factory name given"); + } + } + } + + log.info("number of filters: " + filterFactories.size()); + + context.put( + GNVArtifactContext.VERTICAL_CROSS_SECTION_FILTER_FACTORIES_KEY, + Collections.unmodifiableList(filterFactories)); + } + + protected void configureVerticalCrossSectionSamples( + Document config, + GNVArtifactContext context + ) { + log.info("configuration of vertical cross section samples"); + + Element samples = (Element)Config.getNodeXPath( + VERTICAL_CROSS_SECTION_SAMPLES); + + Dimension sampleSize = new Dimension( + GNVArtifactContext.DEFAULT_VERTICAL_CROSS_SECTION_SAMPLES); + + if (samples == null) { + log.warn("no samples found"); + } + else { + String widthString = samples.getAttribute("width"); + if ((widthString = widthString.trim()).length() > 0) { + try { + sampleSize.width = Math.max(1, Integer.parseInt(widthString)); + } + catch (NumberFormatException nfe) { + log.error("invalid value for width: '" + widthString + "'"); + } + } + String heightString = samples.getAttribute("height"); + if ((heightString = heightString.trim()).length() > 0) { + try { + sampleSize.height = Math.max(1, Integer.parseInt(heightString)); + } + catch (NumberFormatException nfe) { + log.error("invalid value for height: '" + heightString + "'"); + } + } + } + log.info("samples (width x height): " + + sampleSize.width + " x " + sampleSize.height); + + context.put( + GNVArtifactContext.VERTICAL_CROSS_SECTION_SAMPLES_KEY, + sampleSize); + + } + protected void configureHorizontalCrossSectionProfile( Document config, GNVArtifactContext context