# HG changeset patch # User Ingo Weinzierl # Date 1331214291 0 # Node ID afebbe9c2fcecbac0403bf7b6e26369f189ad35b # Parent 3d240200364c87dd15f470d6e95d778c055994e5 Added a new Artifact for loading existing 'floodmaps' via datacage. flys-artifacts/trunk@4130 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 3d240200364c -r afebbe9c2fce flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Thu Mar 08 13:06:11 2012 +0000 +++ b/flys-artifacts/ChangeLog Thu Mar 08 13:44:51 2012 +0000 @@ -1,3 +1,25 @@ +2012-03-08 Ingo Weinzierl + + * src/main/java/de/intevation/flys/artifacts/WMSFloodmapsArtifact.java: New. + This Artifacts allows loading 'floodmaps'. + + * src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java: Added a + new Facet type "floodmap.floodmaps" which are created by + WMSFloodmapsArtifact. + + * doc/conf/artifacts/winfo.xml: Registered the "floodmap.floodmaps" facet + for "floodmap" output. + + * doc/conf/conf.xml: Registered the new WMSFloodmapsArtifact. + + * doc/conf/themes.xml: Added a theme for the "floodmap.floodmaps" facet. + + * src/main/resources/messages.properties, + src/main/resources/messages_de_DE.properties, + src/main/resources/messages_en.properties, + src/main/resources/messages_de.properties: Added i18n string for + "floodmap.floodmaps" title. + 2012-03-08 Ingo Weinzierl * doc/conf/meta-data.xml: Improved datacage configuration to serve diff -r 3d240200364c -r afebbe9c2fce flys-artifacts/doc/conf/artifacts/winfo.xml --- a/flys-artifacts/doc/conf/artifacts/winfo.xml Thu Mar 08 13:06:11 2012 +0000 +++ b/flys-artifacts/doc/conf/artifacts/winfo.xml Thu Mar 08 13:44:51 2012 +0000 @@ -464,6 +464,7 @@ + diff -r 3d240200364c -r afebbe9c2fce flys-artifacts/doc/conf/conf.xml --- a/flys-artifacts/doc/conf/conf.xml Thu Mar 08 13:06:11 2012 +0000 +++ b/flys-artifacts/doc/conf/conf.xml Thu Mar 08 13:44:51 2012 +0000 @@ -46,6 +46,9 @@ artifact="de.intevation.flys.artifacts.WMSBuildingsArtifact">de.intevation.artifactdatabase.DefaultArtifactFactory de.intevation.artifactdatabase.DefaultArtifactFactory + de.intevation.artifactdatabase.DefaultArtifactFactory + + + + + + + + @@ -998,6 +1006,7 @@ + diff -r 3d240200364c -r afebbe9c2fce flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSFloodmapsArtifact.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSFloodmapsArtifact.java Thu Mar 08 13:44:51 2012 +0000 @@ -0,0 +1,185 @@ +package de.intevation.flys.artifacts; + +import java.util.List; + +import org.w3c.dom.Document; + +import org.apache.log4j.Logger; + +import com.vividsolutions.jts.geom.Envelope; + +import de.intevation.artifacts.ArtifactFactory; +import de.intevation.artifacts.CallMeta; + +import de.intevation.artifactdatabase.state.DefaultOutput; +import de.intevation.artifactdatabase.state.Facet; +import de.intevation.artifactdatabase.state.State; + +import de.intevation.flys.model.River; +import de.intevation.flys.model.Floodmaps; + +import de.intevation.flys.artifacts.model.FacetTypes; +import de.intevation.flys.artifacts.model.RiverFactory; +import de.intevation.flys.artifacts.resources.Resources; +import de.intevation.flys.utils.FLYSUtils; + + +public class WMSFloodmapsArtifact extends WMSDBArtifact { + + public static final String NAME = "floodmaps"; + + + private static final Logger logger = + Logger.getLogger(WMSFloodmapsArtifact.class); + + + @Override + public void setup( + String identifier, + ArtifactFactory factory, + Object context, + CallMeta callMeta, + Document data) + { + logger.debug("WMSFloodmapsArtifact.setup"); + + super.setup(identifier, factory, context, callMeta, data); + } + + + @Override + public String getName() { + return NAME; + } + + + @Override + public State getCurrentState(Object cc) { + State s = new FloodmapsState(this); + + List fs = facets.get(getCurrentStateId()); + + DefaultOutput o = new DefaultOutput( + "floodmap", + "floodmap", + "image/png", + fs, + "map"); + + s.getOutputs().add(o); + + return s; + } + + + public static class FloodmapsState extends WMSDBState implements FacetTypes + { + private static final Logger logger = + Logger.getLogger(FloodmapsState.class); + + protected int riverId; + protected String floodmapName; + + public FloodmapsState(WMSDBArtifact artifact) { + super(artifact); + riverId = 0; + floodmapName = null; + } + + public int getRiverId() { + if (riverId == 0) { + String ids = artifact.getDataAsString("ids"); + + try { + String[] parts = ids.split("_"); + riverId = Integer.valueOf(parts[0]); + } + catch (NumberFormatException nfe) { + logger.error("Cannot parse river id from '" + ids + "'"); + } + } + + return riverId; + } + + public String getFloodmapName() { + if (floodmapName == null) { + String ids = artifact.getDataAsString("ids"); + + String parts[] = ids.split("_"); + floodmapName = parts[1]; + } + + return floodmapName; + } + + @Override + protected String getFacetType() { + return FLOODMAP_FLOODMAPS; + } + + @Override + protected String getTitle(CallMeta meta) { + return Resources.getMsg( + meta, + FLOODMAP_FLOODMAPS, + FLOODMAP_FLOODMAPS); + } + + @Override + protected String getUrl() { + return FLYSUtils.getUserWMSUrl(artifact.identifier()); + } + + @Override + protected String getSrid() { + River river = RiverFactory.getRiver(getRiverId()); + return FLYSUtils.getRiverSrid(river.getName()); + } + + @Override + protected Envelope getExtent() { + List floodmaps = + Floodmaps.getFloodmaps(getRiverId(), getFloodmapName()); + + Envelope max = null; + + for (Floodmaps f: floodmaps) { + Envelope env = f.getGeom().getEnvelopeInternal(); + + if (max == null) { + max = env; + continue; + } + + max.expandToInclude(env); + } + + return max; + } + + @Override + protected String getFilter() { + return "river_id=" + String.valueOf(getRiverId()) + + "name=" + getFloodmapName(); + } + + @Override + protected String getDataString() { + String srid = getSrid(); + + if (FLYSUtils.isUsingOracle()) { + return "geom FROM floodmaps USING SRID " + srid; + } + else { + return "geom FROM floodmaps USING UNIQUE id USING SRID " + srid; + } + } + + @Override + protected String getGeometryType() { + return "MULTIPOLYGON"; + } + } // end of WMSKmState +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 3d240200364c -r afebbe9c2fce flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java Thu Mar 08 13:06:11 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java Thu Mar 08 13:44:51 2012 +0000 @@ -74,6 +74,7 @@ String FLOODMAP_LINES = "floodmap.lines"; String FLOODMAP_BUILDINGS = "floodmap.buildings"; String FLOODMAP_FIXPOINTS = "floodmap.fixpoints"; + String FLOODMAP_FLOODMAPS = "floodmap.floodmaps"; String FLOODMAP_EXTERNAL_WMS = "floodmap.externalwms"; String DISCHARGE_LONGITUDINAL_W = "discharge_longitudinal_section.w"; diff -r 3d240200364c -r afebbe9c2fce flys-artifacts/src/main/resources/messages.properties --- a/flys-artifacts/src/main/resources/messages.properties Thu Mar 08 13:06:11 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages.properties Thu Mar 08 13:44:51 2012 +0000 @@ -170,6 +170,7 @@ floodmap.lines = Lines floodmap.buildings = Buildings floodmap.fixpoints = Fixpoints +floodmap.floodmaps = Floodmaps wsplgen.job.queued = WSPLGEN job in queue. wsplgen.job.error = An unexpected error while starting WSPLGEN occured. diff -r 3d240200364c -r afebbe9c2fce flys-artifacts/src/main/resources/messages_de.properties --- a/flys-artifacts/src/main/resources/messages_de.properties Thu Mar 08 13:06:11 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de.properties Thu Mar 08 13:44:51 2012 +0000 @@ -170,6 +170,7 @@ floodmap.lines = Linien floodmap.buildings = Bauwerke floodmap.fixpoints = Festpunkte +floodmap.floodmaps = \u00dcberschwemmungsfl\u00e4che wsplgen.job.queued = WSPLGEN Berechnung befindet sich in Warteschlange. wsplgen.job.error = Ein unerwarteter Fehler beim Starten von WSPLGEN ist aufgetreten. diff -r 3d240200364c -r afebbe9c2fce flys-artifacts/src/main/resources/messages_de_DE.properties --- a/flys-artifacts/src/main/resources/messages_de_DE.properties Thu Mar 08 13:06:11 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de_DE.properties Thu Mar 08 13:44:51 2012 +0000 @@ -169,6 +169,7 @@ floodmap.lines = Linien floodmap.buildings = Bauwerke floodmap.fixpoints = Festpunkte +floodmap.floodmaps = \u00dcberschwemmungsfl\u00e4che wsplgen.job.queued = WSPLGEN Berechnung befindet sich in Warteschlange. wsplgen.job.error = Ein unerwarteter Fehler beim Starten von WSPLGEN ist aufgetreten. diff -r 3d240200364c -r afebbe9c2fce flys-artifacts/src/main/resources/messages_en.properties --- a/flys-artifacts/src/main/resources/messages_en.properties Thu Mar 08 13:06:11 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_en.properties Thu Mar 08 13:44:51 2012 +0000 @@ -166,6 +166,7 @@ floodmap.lines = Lines floodmap.buildings = Buildings floodmap.fixpoints = Fixpoints +floodmap.floodmaps = Floodmaps wsplgen.job.queued = WSPLGEN job in queue. wsplgen.job.error = An unexpected error while starting WSPLGEN occured.