Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.java @ 5664:fb9892036bd6
Added vimline.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 11 Apr 2013 16:31:55 +0200 |
parents | ae60bb7b8085 |
children |
line wrap: on
line source
package de.intevation.flys.artifacts; import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.Geometry; import de.intevation.artifactdatabase.state.DefaultOutput; import de.intevation.artifactdatabase.state.Facet; import de.intevation.artifactdatabase.state.State; import de.intevation.artifacts.ArtifactFactory; import de.intevation.artifacts.CallMeta; import de.intevation.flys.artifacts.model.FacetTypes; import de.intevation.flys.artifacts.model.RiverFactory; import de.intevation.flys.model.River; import de.intevation.flys.model.RiverAxis; import de.intevation.flys.utils.FLYSUtils; import de.intevation.flys.utils.GeometryUtils; import java.util.List; import org.apache.log4j.Logger; import org.w3c.dom.Document; @Deprecated public class RiverAxisArtifact extends WMSDBArtifact { public static final String NAME = "riveraxis"; private static final Logger logger = Logger.getLogger(RiverAxisArtifact.class); @Override public void setup( String identifier, ArtifactFactory factory, Object context, CallMeta callMeta, Document data) { logger.debug("RiverAxisArtifact.setup"); super.setup(identifier, factory, context, callMeta, data); } @Override public String getName() { return NAME; } @Override public State getCurrentState(Object cc) { State s = new RiverAxisState(this); List<Facet> fs = getFacets(getCurrentStateId()); DefaultOutput o = new DefaultOutput( "floodmap", "floodmap", "image/png", fs, "map"); s.getOutputs().add(o); return s; } public static class RiverAxisState extends WMSDBState implements FacetTypes { private static final Logger logger = Logger.getLogger(RiverAxisState.class); protected Geometry geom; protected int riverId; public RiverAxisState(){} public RiverAxisState(FLYSArtifact artifact) { super(artifact); } @Override protected String getFacetType() { return FLOODMAP_RIVERAXIS; } @Override protected String getLayer() { return RiverFactory.getRiver(getRiverId()).getName(); } @Override protected String getUrl() { return FLYSUtils.getRiverWMSUrl(); } @Override protected String getSrid() { River river = RiverFactory.getRiver(getRiverId()); return FLYSUtils.getRiverSrid(river.getName()); } @Override protected Envelope getExtent(boolean reproject) { River river = RiverFactory.getRiver(getRiverId()); List<RiverAxis> axes; String kind = getIdPart(2); if (kind != null && kind.equals("1")) { axes = RiverAxis.getRiverAxis(river.getName(), Integer.parseInt(kind)); } else if (kind != null) { axes = RiverAxis.getRiverAxis(river.getName(), getName(), Integer.parseInt(kind)); } else { if (reproject) { logger.debug("Query extent for RiverAxis with Srid: " + getSrid()); return GeometryUtils.transform( GeometryUtils.getRiverBoundary(river.getName()), getSrid()); } else { return GeometryUtils.transform( GeometryUtils.getRiverBoundary(river.getName()), "31467"); } } Envelope max = null; for (RiverAxis ax: axes) { Envelope env = ax.getGeom().getEnvelopeInternal(); if (max == null) { max = env; continue; } max.expandToInclude(env); } return max != null && reproject ? GeometryUtils.transform(max, getSrid()) : max; } @Override protected String getFilter() { String kind = getIdPart(2); if (kind != null && kind.equals("1")) { return "river_id=" + String.valueOf(getRiverId()) + " AND kind_id=" + kind; } else if (kind != null) { return "river_id=" + String.valueOf(getRiverId()) + " AND kind_id=" + kind + " AND name='" + getName() + "'"; } else if (getIdPart(1) != null) { return "river_id=" + String.valueOf(getRiverId()) + " AND name='" + getName() + "'"; } return "river_id=" + String.valueOf(getRiverId()) + " AND kind_id=" + kind; } @Override protected String getDataString() { if (FLYSUtils.isUsingOracle()) { return "geom FROM river_axes USING SRID " + getSrid(); } else { return "geom FROM river_axes USING UNIQUE id"; } } @Override protected String getGeometryType() { return "LINE"; } } // end of WMSKmState } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :