Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.java @ 1775:0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
flys-artifacts/trunk@3097 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 28 Oct 2011 08:36:32 +0000 |
parents | c62ff9e72cea |
children | a8910c1c82fb |
line wrap: on
line source
package de.intevation.flys.artifacts; import java.util.ArrayList; import java.util.List; import org.w3c.dom.Document; import org.apache.log4j.Logger; import de.intevation.artifacts.Artifact; import de.intevation.artifacts.ArtifactFactory; import de.intevation.artifacts.CallMeta; import de.intevation.artifacts.common.ArtifactNamespaceContext; import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.artifactdatabase.data.DefaultStateData; import de.intevation.artifactdatabase.state.Facet; import de.intevation.flys.model.River; import de.intevation.flys.artifacts.model.RiverFactory; import de.intevation.flys.artifacts.states.DefaultState; public class RiverAxisArtifact extends StaticFLYSArtifact { public static final String NAME = "riveraxis"; public static final String XPATH_IDS = "/art:action/art:ids/@value"; private static final Logger logger = Logger.getLogger(RiverAxisArtifact.class); @Override public String getName() { return NAME; } @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); String ids = XMLUtils.xpathString( data, XPATH_IDS, ArtifactNamespaceContext.INSTANCE); String[] splitted = ids != null ? ids.split(" ") : null; if (splitted != null && splitted.length > 0) { try { int river_id = Integer.parseInt(splitted[0]); River river = RiverFactory.getRiver(river_id); if (river == null) { throw new IllegalArgumentException( "No river found for id: " + river_id); } String name = river.getName(); addData("river", new DefaultStateData("river",null,null,name)); List<Facet> fs = new ArrayList<Facet>(); DefaultState state = (DefaultState) getCurrentState(context); state.computeInit(this, hash(), context, callMeta, fs); if (!fs.isEmpty()) { facets.put(getCurrentStateId(), fs); } } catch (NumberFormatException nfe) { logger.error("Could not create Artifact: " + nfe.getMessage()); throw new IllegalArgumentException("No river id given."); } } } @Override protected void initialize( Artifact artifact, Object context, CallMeta callMeta) { // do nothing } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :