[OpenLayers-Users] Getting specific data from a single vector feature with a large attribute table

Julius Sempio julius.sempio at gmail.com
Mon May 28 02:30:05 PDT 2012


Good day, sires.

I am currently working on a web-based GIS project that mainly concerns with
the extraction of data for viewing purposes, and we're using PostGIS,
Geoserver and OpenLayers for the said project.

Right now we're trying to display data from several rows in the attribute
table in a single vector, but right now we're pretty much stuck at
displaying only the first line of the table (see example below):

fid        survey_no      wqms_id            do          surveydate
135      1                   WQS-10-1         8.45       1/27/2010
==> only this line gets displayed right now
136      2                   WQS-10-2         1.27       1/28/2010
137      3                   WQS-10-3         1.08       2/24/2010
==> we would like to display this (and others) using survey_no as the
parameter to do so
138      4                   WQS-10-4         6.07       3/24/2010
...        ...                  ...                     ...           ...

We're currently using the following codes to get information on the feature:

function linkToWQMS(wqms){
    //clear focus layers from previous selection
    if (wqmsHoverFocus.features != null) {
        wqmsHoverFocus.removeAllFeatures();
    }
    if (popup != null){
        map.removePopup(popup);
    }

    //process wqmsid
    var wqmsSelected = wqms.name;
    getWQMS(wqmsSelected);
}

function getWQMS(wqms){
    var paramsWQMS = {
        REQUEST: "GetFeature",
        SERVICE: "WFS",
        VERSION: "1.1.0",
        TYPENAME: ["prism:WQMS"],
        OUTPUTFORMAT: "GML2",
        SRSNAME: "EPSG:4326",
        CQL_FILTER: "wqms_id = \'" + wqms + "\'"};

    OpenLayers.Request.GET({
        url: "http://202.92.159.15:8080/geoserver/prism/wfs",
        params: paramsWQMS,
        callback: handlerWQMS});
}

function handlerWQMS(response){
    //Create gml format object
    var gml = new OpenLayers.Format.GML();
    gml.extractAttributes = true;

    //Get array of OpenLayers.Feature.Vector
    var features = gml.read(response.responseText);

    //reproject geometry before buffering
    var wqmsid = features[0].attributes["wqms_id"];
    //alert(wqmsid);
    var geom = features[0].geometry.clone();
    geom.transform(geographic, mercator);

    //center tributary to center of bounds
    var parcelCenter = geom.getBounds().getCenterLonLat();
    map.panTo(parcelCenter);

    //pass the control to prismParcelInformationUI.js
    wqmsInformationController(features[0]);
    drawFeatures ("wqms", features, 0);
}

function wqmsInformationController(feature){
    //pass to create status info entry
    setTributaryInformationStatus(feature);
}

function setTributaryInformationStatus(feature){
    //code to prepare data for viewing
    var id, survno, dopercent;
    id = feature.attributes["wqms_id"];
    survno = feature.attributes["survey_no"];
    dopercent = Math.round(feature.attributes["do"]*100)/100;

    var tributaryInformationStatusTablePage = "<table style=\"width:100%\">"
        + "<tr><td
style=\"font-family:verdana;color:navy;font-size:11px;text-align:right;width:25%\"><strong>Station
ID:</strong></td>"
        + "<td
style=\"font-family:verdana;color:navy;font-size:11px;text-align:left\">" +
id + "</td></tr>"
        + "<tr><td
style=\"font-family:verdana;color:navy;font-size:11px;text-align:right;width:25%\"><strong>Survey
No:</strong></td>"
        + "<td
style=\"font-family:verdana;color:navy;font-size:11px;text-align:left\">" +
survno + "</td></tr>"
        + "<tr><td
style=\"font-family:verdana;color:navy;font-size:11px;text-align:right;width:25%\"><strong>Dissolved
Oxygen %:</strong></td>"
        + "<td
style=\"font-family:verdana;color:navy;font-size:11px;text-align:left\">" +
checkIfEmpty(dopercent) + "</td></tr>"
        + "</table>";

    //get html elements and attach tributaryInformationBasicPage

    var statustableDIV =
document.getElementById('tributaryinformationstatustable');
    statustableDIV.innerHTML = tributaryInformationStatusTablePage;
    statusinitDIV.appendChild(statustableDIV);
    toolsStatusBar.setText("~(^.^)~ Viewing Tributary Status Information");
}

We've been surfing a lot of Internet sources the past weeks in trying to
find the answer, but as of the moment we have found no success. So any
enlightening insights would be most welcome.

Yours truly:

Julius Sempio
Department of Geodetic Engineering
University of the Philippines
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120528/1d30471c/attachment.html>


More information about the Users mailing list