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

Gery . gamejihou at hotmail.com
Wed May 30 00:58:57 PDT 2012



Very nice example Julius! thanks for sharing

Cheers,

Gery

Date: Wed, 30 May 2012 13:27:18 +0800
Subject: Re: [OpenLayers-Users] Fwd: Getting specific data from a single vector feature with a large attribute table
From: julius.sempio at gmail.com
To: gamejihou at hotmail.com; openlayers-users at lists.osgeo.org

Ah, sure. We would be glad to comply. 
The screenshots requested are sent as attachments to this e-mail.

Cheers sires.
Yours truly:
Julius
On Tue, May 29, 2012 at 3:22 PM, Gery . <gamejihou at hotmail.com> wrote:






Hello Julius!, Glad to hear that finally it worked as you wanted it! that's really great and I'm happy for that. It looks really neat your solution, could it be possible to see a picture (JPEG) about this solution running in your application? it'd be excellent.


Thanks for sharing this very nice solution,

Cheers,

Gery

Date: Tue, 29 May 2012 12:19:37 +0800
From: julius.sempio at gmail.com

To: openlayers-users at lists.osgeo.org
Subject: [OpenLayers-Users] Fwd: Getting specific data from a single vector feature with a large attribute table


Special thanks to sir Gery for the valuable assistance he provided us.

Yours truly:

Julius

---------- Forwarded message ----------
From: Julius Sempio <julius.sempio at gmail.com>


Date: Tue, May 29, 2012 at 12:17 PM
Subject: Re: [OpenLayers-Users] Getting specific data from a single vector feature with a large attribute table
To: "Gery ." <gamejihou at hotmail.com>




Good day sir. 

We're pretty happy to say that we finally managed to solve the issue. We made use of a ready-made drop-down box (from the free DHTMLx standard edition library) and made entries linked to the CQL_FILTER in the GetFeature. We're happy to share the solution for the reference of others:




var survno; <== the repository of the survey number parameter, declared as a global variable

Snippet within our init() function:
var survnoOptions = [];



    survnoOptions.push(["0", "Select a survey #"]);
    survnoOptions.push(["1", "1"]);
    survnoOptions.push(["2", "2"]);
    survnoOptions.push(["3", "3"]);



    survnoOptions.push(["4", "4"]);
    survnoOptions.push(["5", "5"]);
    survnoOptions.push(["6", "6"]);
    survnoOptions.push(["7", "7"]);



    survnoOptions.push(["8", "8"]);
    survnoOptions.push(["9", "9"]);
    survnoOptions.push(["10", "10"]);
    survnoOptions.push(["11", "11"]);



    survnoOptions.push(["12", "12"]);
    
    survnoCombo = new dhtmlXCombo("tsncombobox", "survnosearch", 0.075*width);
    survnoCombo.addOption(survnoOptions);
    survnoCombo.selectOption(1, false, false);



    survno = survnoCombo.getSelectedValue();
    survnoCombo.attachEvent("onChange",
        function(){
            survno = survnoCombo.getSelectedValue();
        });
    var tsncomboboxDIV = document.getElementById('tsncombobox');



    
    var survnoPage =
        "<p style=\"font-family:verdana;color:navy;font-size:11px;text-align:left;width:25%\">"
            + "<strong>Survey #: </strong></p>";



    
    var statusinitDIV = document.getElementById('tributaryinformationstatusinit');
    statusinitDIV.innerHTML = survnoPage;
    statusinitDIV.appendChild(tsncomboboxDIV);

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 + "\' AND survey_num = " + survno};  <== the modified CQL_FILTER parameter that uses the survno global variable




    
    OpenLayers.Request.GET({
        url: "http://202.92.159.15:8080/geoserver/prism/wfs",

        params: paramsWQMS,
        callback: handlerWQMS});
}

We placed the data display in the handlerWQMS(feature) function, which is simply an "innerHTML-setting" function.


Again, thank you for the assistance and insights, good sires. 



Yours truly:

Julius

On Tue, May 29, 2012 at 10:55 AM, Julius Sempio <julius.sempio at gmail.com> wrote:



Good day sir.

While studying the idea on attaching innerHTML's in the drop-down box, we also found out that the CQL_FILTER parameter in our WFS GetFeature request can be utilized as well in outputting the row you need (as long as they have unique values):





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 + "\'"}; <== can also help :D




    
    OpenLayers.Request.GET({
        url: "http://202.92.159.15:8080/geoserver/prism/wfs",

        params: paramsWQMS,
        callback: handlerWQMS});
}

We'll try to work around on both ideas.

Thanks for the insights given as of the moment.

Yours truly:

Julius



On Mon, May 28, 2012 at 9:05 PM, Gery . <gamejihou at hotmail.com> wrote:








Hi Julius,

Now I understand, probably this may work: http://www.mail-archive.com/users@openlayers.org/msg04937.html. This is an example in html: http://www.echoecho.com/htmlforms11.htm. It should be a way to link that to your postgis table, perhaps through your geoserver but no idea about how.





HTH,

Date: Mon, 28 May 2012 19:33:01 +0800
Subject: Re: [OpenLayers-Users] Getting specific data from a single vector feature with a large attribute table

From: julius.sempio at gmail.com
To: gamejihou at hotmail.com

Good day, sir. Thank you for the prompt reply.





The sample data we provided are stored in a single point vector, and in effect we can actually click on only a single vector (or, in essence, a single point vector storing multiple rows).


We're planning to make a drop-down box that lists the Survey Numbers and then when the end user selects a survey number (which are, by the way, our means to display data in a temporal manner - that is, each survey number has an assigned date of the times the water quality surveys were done) the information regarding water quality on that particular date is displayed.






We're thinking of displaying data one row at a time using that drop-down box, but right now we're still finding ways to do so. As of the moment, we were unsuccessful in linking the drop-down box to GetFeature or GetFeatureInfo.






We do find the information you provided helpful when it comes to overlapping features, however, so we still appreciate the insight.

Thank you for the time in considering this problem of ours.

Yours truly:






Julius

On Mon, May 28, 2012 at 6:14 PM, Gery . <gamejihou at hotmail.com> wrote:










Hello Julius,

I work with PostGis, Mapserver and Openlayers to plot my data. My tables are quite similar to what you have, but my code is different. If I understand well, you're trying to get the info stored in your tables after clicking each feature, is it that? if so, you have to play with the GetFeatureInfo code, here is the code: http://openlayers.org/dev/examples/getfeatureinfo-popup.html






I understand also that you want to display all the rows in your table based on survey_no column, but just clicking one feature (this is one row), is it that? as far as I know you can assign info to one feature, this is one row, and then press each feature to get its corresponding info, I know that in that way works, probably you may make a query and select only the features that match certain pattern in your survey_no column, ie. all of them that are multiple of 10.






Hope this helps,

Gery

Date: Mon, 28 May 2012 17:30:05 +0800
From: julius.sempio at gmail.com
To: openlayers-users at lists.osgeo.org





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

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







_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users
 		 	   		  

 		 	   		  







_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users 		 	   		  

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120530/c410b97c/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 360.gif
Type: image/gif
Size: 453 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120530/c410b97c/attachment-0001.gif>


More information about the Users mailing list