view flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java @ 186:cf8cbcb6a10d

Added parser to read *.KM files. flys-backend/trunk@1506 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 17 Mar 2011 17:43:57 +0000
parents 4ab2c3bd474c
children 003ac16812dd
line wrap: on
line source
package de.intevation.flys.importer;

import java.util.List;

import java.io.File;
import java.io.IOException;

import org.apache.log4j.Logger;

import de.intevation.flys.utils.FileTools;

public class ImportRiver
{
    private static Logger log = Logger.getLogger(ImportRiver.class);

    public static final String PEGEL_GLT = "PEGEL.GLT";

    protected String name;

    protected File   wstFile;

    protected File   bbInfoFile;

    protected List<ImportGauge> gauges;

    protected List<ImportAnnotation> annotations;

    public ImportRiver() {
    }

    public ImportRiver(String name, File wstFile, File bbInfoFile) {
        this.name       = name;
        this.wstFile    = wstFile;
        this.bbInfoFile = bbInfoFile;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public File getWstFile() {
        return wstFile;
    }

    public void setWstFile(File wstFile) {
        this.wstFile = wstFile;
    }

    public File getBBInfo() {
        return bbInfoFile;
    }

    public void setBBInfo(File bbInfoFile) {
        this.bbInfoFile = bbInfoFile;
    }

    public void parseDependencies() throws IOException {
        parseGauges();
        parseAnnotations();
    }

    public void parseGauges() throws IOException {
        File gltFile = new File(wstFile.getParentFile(), PEGEL_GLT);
        gltFile = FileTools.repair(gltFile);

        if (!gltFile.isFile() || !gltFile.canRead()) {
            log.warn("cannot read gauges from '" + gltFile + "'");
            return;
        }

        PegelGltParser pgltp = new PegelGltParser();
        pgltp.parse(gltFile);

        gauges = pgltp.getGauges();
    }

    public void parseAnnotations() throws IOException {
        File riverDir = wstFile.getParentFile().getParentFile();
        AnnotationsParser aparser = new AnnotationsParser();
        aparser.parse(riverDir);

        annotations = aparser.getAnnotations();
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org