Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/WMSGaugeLocationArtifact.java @ 8255:5ffbf97766f7
Removed obsolete imports.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Wed, 10 Sep 2014 12:45:35 +0200 |
parents | e4606eae8ea5 |
children |
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde * Software engineering by Intevation GmbH * * This file is Free Software under the GNU AGPL (>=v3) * and comes with ABSOLUTELY NO WARRANTY! Check out the * documentation coming with Dive4Elements River for details. */ package org.dive4elements.river.artifacts; import java.util.List; import org.apache.log4j.Logger; import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.Geometry; import org.dive4elements.artifactdatabase.state.Facet; import org.dive4elements.artifactdatabase.state.DefaultOutput; import org.dive4elements.artifactdatabase.state.State; import org.dive4elements.river.model.River; import org.dive4elements.river.model.GaugeLocation; import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.model.RiverFactory; import org.dive4elements.river.utils.RiverUtils; import org.dive4elements.river.utils.GeometryUtils; public class WMSGaugeLocationArtifact extends WMSDBArtifact { public static final String NAME = "wmsgaugelocation"; private static final Logger log = Logger.getLogger(WMSGaugeLocationArtifact.class); @Override public String getName() { return NAME; } @Override public State getCurrentState(Object cc) { State s = new WMSGaugeLocationState(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 WMSGaugeLocationState extends WMSDBState implements FacetTypes { private static final Logger log = Logger.getLogger(WMSGaugeLocationState.class); protected Geometry geom; public WMSGaugeLocationState(WMSDBArtifact artifact) { super(artifact); } @Override protected String getFacetType() { return FLOODMAP_GAUGE_LOCATION; } @Override protected String getUrl() { return RiverUtils.getUserWMSUrl(artifact.identifier()); } @Override protected String getSrid() { River river = RiverFactory.getRiver(getRiverId()); return RiverUtils.getRiverSrid(river.getName()); } @Override protected Envelope getExtent(boolean reproject) { List<GaugeLocation> gauges = GaugeLocation.getGaugeLocations(getRiverId(), getName()); Envelope max = null; for (GaugeLocation gauge: gauges) { Envelope env = gauge.getGeom().getEnvelopeInternal(); if (max == null) { max = env; continue; } max.expandToInclude(env); } return max != null && reproject ? GeometryUtils.transform(max, getSrid()) : max; } @Override protected String getFilter() { return "river_id=" + String.valueOf(getRiverId()) + " and name='" + getName() + "'"; } @Override protected String getDataString() { String srid = getSrid(); if (RiverUtils.isUsingOracle()) { return "geom FROM gauge_location USING SRID " + srid; } else { return "geom FROM gauge_location " + "USING UNIQUE id USING SRID " + srid; } } @Override protected String getGeometryType() { return "POINT"; } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :