view flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ReferenceGaugeState.java @ 2201:4e3bfa2d9584

"Bezugslinienverfahren": Add start and end km to WW to determine if kms are at gauges. flys-artifacts/trunk@3819 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 30 Jan 2012 09:57:59 +0000
parents f28844a57fed
children a38f43f626f5
line wrap: on
line source
package de.intevation.flys.artifacts.states;

import java.util.List;

import org.apache.log4j.Logger;

import org.w3c.dom.Element;

import de.intevation.artifacts.Artifact;
import de.intevation.artifacts.CallContext;
import de.intevation.artifacts.CallMeta;

import de.intevation.artifacts.common.utils.XMLUtils;

import de.intevation.flys.model.Gauge;
import de.intevation.flys.model.River;

import de.intevation.flys.artifacts.FLYSArtifact;
import de.intevation.flys.utils.FLYSUtils;


/**
 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
 */
public class ReferenceGaugeState extends DefaultState {

    private static final Logger logger =
        Logger.getLogger(ReferenceGaugeState.class);


    @Override
    protected Element[] createItems(
        XMLUtils.ElementCreator cr,
        Artifact    artifact,
        String      name,
        CallContext context)
    {
        CallMeta  meta = context.getMeta();

        River       river   = FLYSUtils.getRiver((FLYSArtifact) artifact);
        List<Gauge> gauges  = river.getGauges();

        int num = gauges != null ? gauges.size() : 0;

        Element[] opts = new Element[num];

        for (int i = 0; i < num; i++ ) {
            Gauge g = gauges.get(i);

            String gaugeName      = g.getName();
            long   officialNumber = g.getOfficialNumber();

            opts[i] = createItem(
                cr, new String[] { gaugeName, String.valueOf(officialNumber) });
        }

        return opts;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org