view gwt-client/src/main/java/org/dive4elements/river/client/server/MapHelper.java @ 8870:c26fb37899ca

Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui. Also using now the localization info from the server instead of localizing the modules again on the client side.
author gernotbelger
date Wed, 07 Feb 2018 11:59:13 +0100
parents 238fc722f87a
children 0a5239a1e46e
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.client.server;

import org.w3c.dom.Document;

import org.apache.log4j.Logger;

import org.dive4elements.artifacts.common.ArtifactNamespaceContext;
import org.dive4elements.artifacts.common.utils.XMLUtils;

import org.dive4elements.river.client.shared.model.MapConfig;


public class MapHelper {

    private static final Logger log = Logger.getLogger(MapHelper.class);


    public static final String XPATH_SRID =
        "/art:floodmap/art:srid/text()";

    public static final String XPATH_MAX_EXTENT =
        "/art:floodmap/art:maxExtent/text()";

    public static final String XPATH_INITIAL_EXTENT =
        "/art:floodmap/art:initialExtent/text()";


    private MapHelper() {
    }


    public static MapConfig parseConfig(Document raw) {
        log.debug("MapHelper.parseConfig");

        if (log.isDebugEnabled()) {
            log.debug(XMLUtils.toString(raw));
        }

        MapConfig config = new MapConfig();

        setSrid(config, raw);
        setMaxExtent(config, raw);
        setInitialExtent(config, raw);

        return config;
    }


    protected static void setSrid(MapConfig config, Document raw) {
        String srid = (String) XMLUtils.xpathString(
            raw,
            XPATH_SRID,
            ArtifactNamespaceContext.INSTANCE);

        log.debug("Found srid: '" + srid + "'");

        if (srid != null && srid.length() > 0) {
            log.debug("Set srid: '" + srid + "'");
            config.setSrid(srid);
        }
    }


    protected static void setMaxExtent(MapConfig config, Document raw) {
        String maxExtent = (String) XMLUtils.xpathString(
            raw,
            XPATH_MAX_EXTENT,
            ArtifactNamespaceContext.INSTANCE);

        log.debug("Found max extent: '" + maxExtent + "'");

        if (maxExtent != null && maxExtent.length() > 0) {
            log.debug("Set max extent: '" + maxExtent + "'");
            config.setMaxExtent(maxExtent);
        }
    }


    protected static void setInitialExtent(MapConfig config, Document raw) {
        String initialExtent = (String) XMLUtils.xpathString(
            raw,
            XPATH_INITIAL_EXTENT,
            ArtifactNamespaceContext.INSTANCE);

        if (initialExtent != null && initialExtent.length() > 0) {
            log.debug("Set initial extent: '" + initialExtent + "'");
            config.setInitialExtent(initialExtent);
        }
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org