Hexagon Geospatial
MENU

Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Reply
Contributor
Posts: 28
Registered: ‎04-20-2016
Accepted Solution

Strange WFS Service ValueList

Hi,

 

I´m trying to receive Values from a wfs (did the code from http://community.hexagongeospatial.com/t5/Developer-Discussions/Loop-wfs-service-valuelist/m-p/13257...).

 

The problem is the following:

 

My Oracle View looks like:

 

SUMME_NS	              21	47:26,2	      47:32,0
SUMME_MS	               0	47:26,2	      47:32,0
SUMME_Ausgefallene_MS	       0	47:26,2	      47:32,0
SUMME_Ausgefallene_MS_HE       0	47:26,2	      47:32,0
SUMME_MS_VI	               0	47:26,2	      47:32,0
SUMME_NS_VI	               0	47:26,2	      47:32,0
SUMME_Ausgefallene_MS_SP       0	47:26,2	      47:32,0
SUMME_MS_VI	               0	47:26,2	      47:32,0

 

 I insertet the Oracle View in GeoMedia an publised it as WFS.

 

When I use the Datawindow the WFS looks like:

wfs1.png

 

But when I try to insert the values into a label or as 

$GP.ui.info("Nummer: " + i + " = " + zz[i]); 

LOG

 

$GP.ready(function () {

    var test = "yyy";
    function getLinkButton1(text, vector) {
        return {
            xtype: "button",
            text: text,
            handler: function (b) {
                window.open("");
            }
        };
    }

    function getPanButton(text, vector) {
        return {
            xtype: "button",
            text: text,
            handler: function (b) {
                $GP.map.pan(vector);
            }
        };
    }

    function getPanelLabel(text) {
        return {
            xtype: 'label',
            text: text,
            style: {
                font: 'normal 12px Arial',
                color: 'deepskyblue',
                fontWeight: 'underline',
                //border: '1px dotted lightblue',
                //labelAlign: 'center',
            }
        };
    }

    var currentdate = new Date();
    var date = currentdate.getDate() + "."
                    + (currentdate.getMonth() + 1) + "."
                    + currentdate.getFullYear() + " "
    ;
    var time = currentdate.getHours() + ":"
                    + (currentdate.getMinutes() /*- 5*/) + ":"
                    + currentdate.getSeconds();

    

    // #####################################################################################################################
    // ########## http://community.hexagongeospatial.com/t5/Developer-Discussions/Loop-wfs-service-valuelist/td-p/13257 ##########
    // #####################################################################################################################
  //  function SummaryValues_H() {

   
    $GP.services.add({
        url: "http://local/WFS_002_SV_Summary_Values_H_2017/Service.svc/get",
        definitionName: "WFS"
    }, function (result1) {
        $GP.edit.getFeatureClassIds({
            mapServiceId: result1.mapServiceId
        }, function (result2) {
            $GP.edit.getAttributeList({
                mapServiceId: result1.mapServiceId,
                featureClassId: result2.featureClassIds[0]
            }, function (result3) {
                $GP.edit.getAttributeValues({
                    mapServiceId: result1.mapServiceId,
                    featureClassId: result2.featureClassIds[0],
                    attributeId: result3.attributeList[1].get_id(),
                   // start:0, limit:3000
                }, function (result4) {
                    var valueList = result4.values.map(function (x) {
                        return x.value;
                    });
                    //$GP.ui.info($GP.utils.serialize(valueList));
                    $GP.ui.info("VL: " + valueList);
                    var yy = $GP.utils.serialize(valueList);
                    var xx = yy.substring(1, yy.length - 1);
                    var zz = xx.split(",");
                    //$GP.ui.info("zz=" + zz[1]+","+ zz[2] + "," + zz[19]);
                    $GP.ui.info("yy: " + yy + "  -  " + "xx: " + xx + "  -  " + "zz: " + zz);
                    $GP.ui.info("SUMME_KUNDEN_NS: " + zz[1] + ", SUMME_KUNDEN_MS: " + zz[0] + ", SUMME_Ausgefallene_Stationen_MS: " + zz[2] );
                    $GP.ui.info("count: " + zz.length);
                    for (var i = 0; i < 21; i++) {
                        i
                        $GP.ui.info("Nummer: " + i + " = " + zz[i]);                 
                    }
                    $GP.ui.toolbar.add({
                        xtype: 'label',
                        forId: 'myFieldId',
                        text: 'S TrStMS: ' + String(zz[0]).split('undefined').join('0') + '  -  Kunden(MS/NS): ' + zz[2].split('"').join('') + ' / ' + zz[3].split('"').join('') + ' - Achtung Werte aktuell nicht richtig!!',
                        margins: '0 0 0 10',
                    });
                    var items = [
        getPanButton("&nbsp;", [0, 0]),                     
        getPanButton("&nbsp;", [0, 0]),
        getPanButton("&nbsp;", [0, 0]),
        getLinkButton1("Diagramm", getLinkButton1),
        getPanButton("&nbsp;", [0, 0]),
        getPanButton("&nbsp;", [0, 0]),
        getPanButton("&nbsp;", [0, 0]),
        getPanButton("&nbsp;", [0, 0]),
        getPanButton("&nbsp;", [0, 0]),
        getPanelLabel("Stoerbez."),
        getPanelLabel("TrStat.(MS)"),
        getPanelLabel("Kunden(MS/NS)"),
        getPanButton("&Sigma;", [-10, 10]),
        getPanButton(String(zz[2]).split('undefined').join('0'), [0, 10]),
        getPanButton(zz[0].split('"').join('') + " / " + zz[1].split('"').join(''), [10, 10]),
        getPanButton("HE", [-10, 10]),
        getPanButton("--", [0, 10]),
        getPanButton("--/--", [10, 10]),
        getPanButton("SP ", [-10, 0]),
        getPanButton("--", [0, 0]),
        getPanButton("--/--", [10, 0]),
        getPanButton("SV", [-10, -10]),
        getPanButton("--", [0, -10]),
        getPanButton("--/--", [10, -10]),
        getPanButton("VI", [-10, -10]),
        getPanButton("--", [0, -10]),
        getPanButton("--/--", [10, -10]),
        getPanButton("VK", [-10, -10]),
        getPanButton("--", [0, -10]),
        getPanButton("--/--", [10, -10]),
        getPanButton("WO", [-10, -10]),
        getPanButton("--", [0, -10]),
        getPanButton("--/--", [10, -10]),
        getPanButton("WZ Strom", [-10, -10]),
        getPanButton("--", [0, -10]),
        getPanButton("--/--", [10, -10]),
        getPanButton("XX Auftr&auml;ge", [-10, -10]),
        getPanButton("--", [0, -10]),
        getPanButton("--/--", [10, -10]),
        getPanButton("&nbsp;"),
        getPanButton("&nbsp;"),
        getPanButton("&nbsp;"),
        getPanButton("Letzte akt."),
        getPanButton(date),
        getPanButton(time)
                    ];

                    $GP.ui.sidebar.add({
                        xtype: "panel",
                        layout: "table",
                        layoutConfig: {
                            columns: 3
                        },
                        title: "Zusammenfassung/Statistik",
                        items: items
                    });

                }, function (result4) {

                });
            }, function (result3) {

            });
        }, function (result2) {

        });
    }, function (result1) {

    });

});

Why the values are "undefined" and why the order is totally different from oracle view?

 

kind regards

Technical Evangelist
Posts: 1,016
Registered: ‎09-11-2015

Re: Strange WFS Service ValueList

[ Edited ]

Hi Reinhart,

 

Can you check what values do you see for the variables valueList and result4.values? Use the browser developer console and console.log() function to check the real array content. The map function should 0 number to 0, not undefined. But that will depend on the valueList array content. Also check the real WFS response for a GetFeature request.

 

It also looks to me that the values are actually ordered by the selected attribute which unfortunately seems to be "by design". I can see the same behavior on my data.

 

Regards,

Jan

 

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Contributor
Posts: 28
Registered: ‎04-20-2016

Re: Strange WFS Service ValueList

Hi,

 

the values looks like ordered asc

 

valueList: 0,7,14,21
result4.values: [object Object],[object Object],[object Object],[object Object]

 

I need every value in the correct order and also the undefined values. (question is why the undefined values are not shown as 0 like in the oracle view)

 

kind regards,

R.

Technical Evangelist
Posts: 1,016
Registered: ‎09-11-2015

Re: Strange WFS Service ValueList

That is why I asked to check some sample WFS GetFeature result, to see if they're really 0 or rather null.

 

I made some further investigation and checked what request is sent by Portal to the WFS service. For the single attribute it looks like this (POST body):

<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs/2.0" version="2.0.0" service="WFS" xmlns:gmgml="http://www.intergraph.com/geomedia/gml" count="4000">
  <wfs:Query typeNames="gmgml:MajorCities" srsName="">
    <wfs:PropertyName xmlns="http://www.intergraph.com/geomedia/gml">CITY_NAME</wfs:PropertyName>
  </wfs:Query>
</wfs:GetFeature>

And the result:

Untitled.png

 

Apparently there are primary keys in the results even if I did not specify them in request. That means that there's additional processing on the Portal side, that extracts just the requested attributes and makes the (unnecessary) sort.

 

If you need them in original order, then it could be simplest for you to send an AJAX WFS request by your own, without using SDK's getAttributeValues function. To make things easier, you can use the "application/vnd.geo+json" output format for the WFS which is available in WebMap 2016.

 

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Contributor
Posts: 28
Registered: ‎04-20-2016

Re: Strange WFS Service ValueList

Thank you for your investigation.

 

I will try such a Ajax WFS request. Hoep there are easy to understand examples in the web Smiley Happy .

 

R.

Contributor
Posts: 28
Registered: ‎04-20-2016

Re: Strange WFS Service ValueList

[ Edited ]

I´m able to get all the values as json with this:

http://gmwebmap.local/WFS_002_SV_Summary_Values_H_2017/service.svc/get?request=getfeature&Service=wfs&version=1.1.0&typename=STOER_SUMMARYVALUES_H&namespace=xmlns(http://www.intergraph.com/geomedia/gml)&outputFormat=application/vnd.geo%2Bjson

 Result in Browser:

{"type": "FeatureCollection", "features": [ {"type": "Feature", "properties" : {"CoordGeocodeStatus": null, "LAT": "46:47:31,955", "LON": "13:47:26,225", "NAME": "SUMME_KUNDEN_NS", "SUMME": 51}, "ge ..........

 

Do you have a short example how to implement this to show it in a label or as $GP.ui.info ?

 

thanks

R.

 

Highlighted
Technical Evangelist
Posts: 1,016
Registered: ‎09-11-2015

Re: Strange WFS Service ValueList

[ Edited ]

You can simply extract the attributes like this:

 

// get single properties array
// json - GeoJSON value / response var props = json.features.map(function(attr){ return attr["properties"] }); // extract just selected attribute var attrVals = props.map(function(attr){ return attr["SUMME"]; });

 

 

 

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Contributor
Posts: 28
Registered: ‎04-20-2016

Re: Strange WFS Service ValueList

Whats the best way to get the json string in webmat to use the extraxt? 😁
Technical Evangelist
Posts: 1,016
Registered: ‎09-11-2015

Re: Strange WFS Service ValueList

For example Smiley Wink

https://api.jquery.com/jquery.post/

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Polls
Please register to vote
Do you need immediate support?
Please submit a Ticket through our
Development Ticket Portal.