Skip to content

Filter Data with GeoServer

Jun Wang edited this page Apr 5, 2022 · 5 revisions

Filter Data in WMS/WFS Query in Maptool

Data query/filtering in Maptool is done by using Filtering in GeoServer. Due to the size of the data, the query on sources and sinks are done differently.

  • Sources: WFS requests, to specify the features to be returned in geojson.
  • Sinks: WMS requests, to select which features should be displayed on a map.

Filter Sources

Source query in done by function apply_filters in index.html.

A sample query generated in the function:

https://simccs.org/geoserver/SimCCS/ows?service=WFS&version=1.0.0&request=GetFeature&maxFeatures=10000&outputFormat=text/javascript&format_options=callback:loadsearchresult&typeName=Sources_082819_SimCCS_Format&cql_filter=((strToLowerCase(Name) like '%Indiana%') AND (Type IN ('Electricity (Coal)','Electricity (Gas)','Ethanol','Iron/steel')) AND (Capturable BETWEEN 2 AND 20) AND (costVar___ BETWEEN 25 AND 82.5) AND (Intersects(the_geom,Polygon((-100.06347656250001 39.842286020743394,-70.79589843750001 39.842286020743394,-70.79589843750001 23.42292845506526,-100.06347656250001 23.42292845506526,-100.06347656250001 39.842286020743394)))))&callback=jQuery341007380786870244527_1649167191733&_=1649167191734

Searchable fields in this query: Name, Type, Capturable and costVar___. The default query will be carried out in the current map extent, which is done by Intersects(the_geom,Polygon(...)).

A callback function loadsearchresult is used to display the returned GeoJSON in map.

maptool-source-query

Filter Sinks

function refresh_saline and function refresh_og filter saline sinks and oil/gas sinks.

A sample query generated by function refresh_saline.

https://simccs.org/geoserver/SimCCS/wms?=&service=WMS&request=GetMap&layers=sco2t_national_v1_10k&styles=&format=image/png&transparent=true&version=1.1.1&propertyName=Name,fieldCap_M,costFix_M,wellCostFi,varOM_d_tC&cql_filter=((varOM_d_tC Between 2.5 AND 81.5) AND (fieldCap_M Between 0 AND 39))&width=256&height=256&srs=EPSG:3857&bbox=-10644926.307106787,4383204.949985149,-10018754.171394622,5009377.085697314

maptool-sinks

Query data within a working area

When creating a working area, it is done in the following step

  1. display drawing tool function show_drawingtool
  2. once a drawing is done, function getPopupContent calls $.getJSON("/maptool/get-data",{geom:geom_str,method:'count'}) to get the basic information and generates a popup.
  3. "Use this area" is clicked, function loadworkingarea calls /maptool/get-data separately for source/sink layers to get the data in GeoJSON, e.g., $.getJSON("/maptool/get-data",{geom:geom_str,method:'data',layer:'sink_saline',cql_filter:ex_cql_filter}).

maptoo-workarea