view gnv/src/main/webapp/scripts/olutils.js @ 990:56b22bc68dfa

Added error messages for Java heap size errors (issue177). gnv/trunk@1190 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 10 Jun 2010 09:54:58 +0000
parents 96db238fc5ab
children ebc3d018af6a
line wrap: on
line source
function handleMeasurements(event) {
    var geometry = event.geometry;
    var units    = event.units;
    var order    = event.order;
    var measure  = event.measure;
    var element  = document.getElementById('measurements');
    
    var out = "";
    if(order == 1) {
        out += "L\u00e4nge: " + measure.toFixed(3) + " " + units;
    } else {
        out += "Fl\u00e4che: " + measure.toFixed(3) + " " + units + "<sup>2</sup>";
    }

    element.innerHTML=out;
};



function readWMC(merge) {
    var layers = mapPanel.layers;
    map    = mapPanel.map;

    var format = new OpenLayers.Format.WMC({'layerOptions': {buffer: 0}});
    var text = document.getElementById("wmc").value;

    merge = true;
    if(merge) {
        try {
            map = format.read(text, {map: map});
        } catch(err) {
            document.getElementById("wmc").value = err;
        }
    } else {
        map.destroy();
        try {
            var jsonFormat = new OpenLayers.Format.JSON();
            var mapOptions = jsonFormat.read();
            map = format.read(text, {map: mapOptions});
        } catch(err) {
            document.getElementById("wmc").value = err;
        }
    }

    // create MapPanel
    mapPanel = new GeoExt.MapPanel({
        border: true,
        title: "Karte",
        region: "center",
        map: map,
        zoom: 1,
        layers: map.layers
    });
}


function writeWMC(merge) {
    var format = new OpenLayers.Format.WMC({'layerOptions': {buffer: 0}});

    try {
        var text = format.write(map);
        document.getElementById("wmc").value = text;
    } catch(err) {
        document.getElementById("wmc").value = err;
    }
}



function toggleGetFeatureInfo(evt) {
    if (infoActive) {
        infoControls.click.deactivate();
        infoActive = false;
    }
    else {
        infoControls.click.activate();
        infoActive = true;
    }
}


function showInfo(evt) {
}


function addLayer() {
    var record = grid.getSelectionModel().getSelected();
    
    if (record) {
        var copy = record.copy();
        copy.set("layer", record.get("layer"));
        copy.get("layer").mergeNewParams({
            format: "image/png",
            transparent: true
        });

        mapPanel.layers.add(copy);
        mapPanel.map.zoomToExtent(OpenLayers.Bounds.fromArray(copy.get("llbbox")));
    }
}


// this is just copied from OpenLayers.Util
function urlAppend(url, paramStr) {
    var newUrl = url;
    if(paramStr) {
        var parts = (url + " ").split(/[?&]/);
        newUrl += (parts.pop() === " " ?
            paramStr :
            parts.length ? "&" + paramStr : "?" + paramStr);
    }
    return newUrl;
}


function updateCapabilities() {
    var ele = Ext.Element.get('capfield');

    var url     = ele.getValue();
    var service = "SERVICE=WMS";
    var request = "REQUEST=GetCapabilities";
    url = urlAppend(url, service);
    url = urlAppend(url, request);

    store = new GeoExt.data.WMSCapabilitiesStore({
        url: url
    });
    store.load();

    grid.destroy();
    grid = new Ext.grid.GridPanel({
        id: 'wmsgrid',
        collapsible: false,
        split: false,
        border: true,
        // TODO: autoHeight might cause trouble
        autoHeight: true,
        overflow: 'auto',
        store: store,
        cm: new Ext.grid.ColumnModel([
        {
            header: 'Name',
            dataIndex: 'name',
            sortable: true
        },
        {
            id: 'title',
            header: 'Title',
            dataIndex: 'title',
            sortable: true
        }]),
        renderTo: 'capgrid',
        bbar: [{
            text: 'Add Layer',
            handler: addLayer
        }]
    });
}


function editFeature(e) {
    var feature = e.feature;

    // TODO SET FEATURE ATTRIBUTES
    //feature.attributes['lawa'] = 999;
    //feature.attributes['lawa_id'] = 999;
    //feature.attributes['w_gwk_lawa'] = 999;
    //feature.attributes['w_wrrl'] = 999;
    //feature.attributes['length_fee'] = 999;
}

function updateControls() {
    var controls = panel.controls;

    controls.remove(drawPointControl);
    controls.remove(drawPathControl);
    controls.remove(drawPolygonControl);

    panel.destroy();
    panel = new OpenLayers.Control.Panel();
    panel.addControls(controls);

    if (points.getVisibility())
        panel.addControls(drawPointControl);
    if (lines.getVisibility())
        panel.addControls(drawPathControl);
    if (polygons.getVisibility())
        panel.addControls(drawPolygonControl);

    map.addControl(panel);
}

http://dive4elements.wald.intevation.org