Feb 282015
 
  • Inserting JSON Data into table for GeoServer?

    I’m very frustrated trying to fix the following code. I’m new in this and I’d like a little help here:

    First, I have the following code and It works perfectly: I received a JSON Data from Geoserver (sectoresURL) and then, I put it into a DIV. That’s all.

    <div id="info" style="width: 100%; height: 280px; overflow-y: scroll;"></div>
    
    <script type="text/javascript">
    function showResult(sectoresURL) {
    
      $('#info').empty(); // Remove all child in stack.
    
      $.getJSON(sectoresURL, function (json) {
        if (sectores.getVisible() && typeof(json.features[0])  != 'undefined') {
          $('#info').append('<iframe width="99%" seamless src="' + sectoresURL + '"></iframe>');
        }
      });
    }
    </script>
    

    But now, I want to insert all this into a table but I can’t do it. At present, I’m showing in the browser like JSON format, but definitely It isn’t the idea.

    By the way, the JSON Data is:

    {
      "type": "FeatureCollection",
      "features": [
        {
          "type": "Feature",
          "id": "SectoresComunaCurico.34",
          "geometry": {
            "type": "Polygon",
            "coordinates": [
              [
                [
                  301138.4332258755,
                  6110719.0948824
                ],
                [
                  307975.62819723826,
                  6117936.350421507
                ],
                [
                  309421.54950536136,
                  6117454.401929129
                ],
                [
                  314529.81321677275,
                  6117779.869510237
                ],
                [
                  321315.062045189,
                  6115168.846100847
                ],
                [
                  309617.2118206576,
                  6102890.015916108
                ],
                [
                  306318.28485806234,
                  6104246.552389812
                ],
                [
                  301138.4332258755,
                  6110719.0948824
                ]
              ]
            ]
          },
          "geometry_name": "FiguraGeometrica",
          "properties": {
            "Numero": 19,
            "Sector": "Cordillera"
          }
        }
      ],
      "crs": {
        "type": "name",
        "properties": {
          "name": "urn:ogc:def:crs:EPSG::32319"
        }
      }
    }
    

    I’ve tried to insert all this in Bootstrap-Table but without success. Also, Is there some way to re-use geoserver template to do it? At the present, I have one but for {'INFO_FORMAT': 'text/html'});

  • How can i filter on ID’s through WFS Post request?

    I want to select a set of features from my GeoServer (its Running 2.0.0) and use a query using multiple ID’s to get their values. For this i send XML in a post message to the Geoserver:

    <wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" service="WFS" version="1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd" maxFeatures= "7000" >
        <wfs:Query typeName="*:MyFeatures_df16" xmlns:feature="http://www.openplans.org/topp">
            <ogc:Filter>
                <ogc:And>
                    <ogc:OR>
                        <PropertyIsEqualTo>
                            <PropertyName>ID</PropertyName>
                            <Literal>98400005701</Literal>
                        </PropertyIsEqualTo>
                        <PropertyIsEqualTo>
                            <PropertyName>ID</PropertyName>
                            <Literal>-1</Literal>
                        </PropertyIsEqualTo>
                    </ogc:OR>
                    <ogc:And>
                        <ogc:PropertyIsLessThanOrEqualTo>
                            <ogc:PropertyName>MH_DATUM_INGANG</ogc:PropertyName>
                            <ogc:Literal>2015-02-27T00:00:00Z</ogc:Literal>
                        </ogc:PropertyIsLessThanOrEqualTo>
                        <ogc:Or>
                            <ogc:PropertyIsGreaterThanOrEqualTo>
                                <ogc:PropertyName>MH_DATUM_EINDE</ogc:PropertyName>
                                <ogc:Literal>2015-02-27T00:00:00Z</ogc:Literal>
                            </ogc:PropertyIsGreaterThanOrEqualTo>
                            <ogc:PropertyIsNull>
                                <ogc:PropertyName>MH_DATUM_EINDE</ogc:PropertyName>
                            </ogc:PropertyIsNull>
                        </ogc:Or>
                    </ogc:And>
                </ogc:And>
            </ogc:Filter>
        </wfs:Query>
    </wfs:GetFeature>
    

    The filter based on the date (MH_DATUM_BEGIN/MH_DATUM_EIND) is working as expected. But the filter using is completly ignored.
    One of the returns includes:

    <gml:featureMember>
          <ws_df16:MyFeatures_df16 fid="MyFeatures_df16.fid--7d7f79e6_14bcb33c65d_161">
             <ws_df16:GEOMETRIE>
                <gml:Polygon srsName="http://www.opengis.net/gml/srs/epsg.xml#28992">
                   <gml:outerBoundaryIs>
                      <gml:LinearRing>
                         <gml:coordinates decimal="." cs="," ts=" ">197089.235,393933.984 197059.285,393941.753 197057.851,393936.587 197061.768,393935.646 197059.436,393926.758 197062.756,393925.888 197062.109,393923.534 197071.095,393921.174 197072.634,393927.002 197074.054,393932.378 197084.891,393929.538 197087.87,393928.757 197089.235,393933.984</gml:coordinates>
                      </gml:LinearRing>
                   </gml:outerBoundaryIs>
                </gml:Polygon>
             </ws_df16:GEOMETRIE>
             <ws_df16:ID>98400007766</ws_df16:ID>
             <ws_df16:MH_DATUM_INGANG>2010-01-01</ws_df16:MH_DATUM_INGANG>
             <ws_df16:GIS_ID>288830</ws_df16:GIS_ID>
          </ws_df16:MyFeatures_df16>
       </gml:featureMember>
    

    In this part of the response, the Date is correct(like all of the answers) but it returns all of the thousands of features in GeoServer.
    I want to select that specific ID because it is used in other parts of a larger application.

    How can i make sure that my filter query is used as well?

Digest powered by RSS Digest

 Posted by at 13:51
%d bloggers like this:
Close Bitnami banner
Bitnami