Flutter_map: WFS support?

Created on 30 Jul 2020  路  5Comments  路  Source: fleaflet/flutter_map

I was very glad to discover that flutter_map added WMS support since 0.9.0 (already using it!)

Are there any plans to implement support for WFS as well?

Most helpful comment

@4F2E4A2E - WMS and WFS are just different ways to show information on the map. I wouldn't say WFS is superior to WMS but it allows a bit more different control and is better suited to show various vector elements on the map (especially when they need to be interactive or manipulated- clicked/tapped/style changes/etc...).

WMS sample query:
map?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image/png&TRANSPARENT=true&LAYERS=my_wms_layer_name&STYLES=default&some_extra_param=123&CRS=my_projection&WIDTH=X&HEIGHT=Y&BBOX=x,y,x,y
And this basically returns a large PNG file (heatmaps, baselayers). Depending on your client-app WMS can be a good thing - you might run into real performance issues (but it is a rare case with high volumes) when rendering a huge amount of vector features onto the map via WFS (the exact amount depends on the viewport, device, library being used (openlayers/leaflet etc..), how you are rendering the element, how you are styling the element while rendering. But there are things you cannot do by just using a WMS service.

WFS sample query
&SERVICE=WFS&SRS=projection&FORMAT=image/png&LAYERS=my_wfs_layer&TRANSPARENT=TRUE&VERSION=1.0.0&REQUEST=getfeature&STYLES=&TYPENAME=my_type_name&MAXFEATURES=10&outputFormat=geojson&BBOX=x,y,x,y
The query itself is quite similar but instead of a PNG you would get JSON something like this:

crs: {...some props...}
features: [
   {
       geometry: {type: 'Polygon', coordinates: [...] }
       properties: {id: 123, name: 'My park', address: 'Some street 26', city: 'Dolor', number_of_trees_in_park: 321, dogs_allowed: false}
   }
   ...
]
type: "FeatureCollection"

The trick here with a WFS now is that depending on the library/plugin being used you can immediately style or plot the vector elements (polygons, lines etc...) onto the map and interact with them (highlight the vector shape, style it, animate it, add listeners).
Depending on the WFS service you usually also pass several custom properties which then can be read by the client-app.

In the _dummy_ example above: the WMS layer might show a raster layer with park boundaries (marked with a different color so that they can be easily distinguished at various zoom levels. The WFS layer is used to draw a vector polygon when a user clicks on a park (and now we can use the custom properties from the WFS service response to show a modal/popup or do all kinds of magic with the vector element).


Again an oversimplified generalization:

  • You usually use WMS for static baselayers, heatmaps, cadastral units, object borders etc...
  • You usually (but it is definitely not a rule) accompany the WMS layer with a WFS layer to have more interactivity and data.

UX wise: WMS usually works better in low zoom levels (country/county/city view), WFS works better with higher zoom levels (a certain smaller area).

Technically most WFS plugins construct the necessary query (like the current wmsTileOptions does), sets a bounding box and has some sort of support or documentation on how to easily plot and style the received geoJSON as vector elements onto the map. And of-course usually it makes sure that everything unnecessary outside the viewport gets destroyed.

All 5 comments

What is WMS and WFS?

@4F2E4A2E

What is WMS and WFS?

https://www.ogc.org/standards/wfs

An oversimplified generalization:
1) WMS map services (the ones that I usually work with) mostly return PNG (or jpeg) raster tiles. The flutter_map's WMSTileLayerOptions has quite nice support for that.
2) WFS services usually return a bunch of JSON (usually FeatureCollections containing all sorts of information (geometry, properties) about polygons/lines etc... which can then be plotted onto the map.

WMS/WFS queries are quite similar in terms of passed in parameters.

For leaflet there are a few plugins which behave a bit differently:

Thank you for your kind explanation. Do I understand it correctly that WFS would be superior in terms of efficiency on display and data transport?

@4F2E4A2E - WMS and WFS are just different ways to show information on the map. I wouldn't say WFS is superior to WMS but it allows a bit more different control and is better suited to show various vector elements on the map (especially when they need to be interactive or manipulated- clicked/tapped/style changes/etc...).

WMS sample query:
map?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image/png&TRANSPARENT=true&LAYERS=my_wms_layer_name&STYLES=default&some_extra_param=123&CRS=my_projection&WIDTH=X&HEIGHT=Y&BBOX=x,y,x,y
And this basically returns a large PNG file (heatmaps, baselayers). Depending on your client-app WMS can be a good thing - you might run into real performance issues (but it is a rare case with high volumes) when rendering a huge amount of vector features onto the map via WFS (the exact amount depends on the viewport, device, library being used (openlayers/leaflet etc..), how you are rendering the element, how you are styling the element while rendering. But there are things you cannot do by just using a WMS service.

WFS sample query
&SERVICE=WFS&SRS=projection&FORMAT=image/png&LAYERS=my_wfs_layer&TRANSPARENT=TRUE&VERSION=1.0.0&REQUEST=getfeature&STYLES=&TYPENAME=my_type_name&MAXFEATURES=10&outputFormat=geojson&BBOX=x,y,x,y
The query itself is quite similar but instead of a PNG you would get JSON something like this:

crs: {...some props...}
features: [
   {
       geometry: {type: 'Polygon', coordinates: [...] }
       properties: {id: 123, name: 'My park', address: 'Some street 26', city: 'Dolor', number_of_trees_in_park: 321, dogs_allowed: false}
   }
   ...
]
type: "FeatureCollection"

The trick here with a WFS now is that depending on the library/plugin being used you can immediately style or plot the vector elements (polygons, lines etc...) onto the map and interact with them (highlight the vector shape, style it, animate it, add listeners).
Depending on the WFS service you usually also pass several custom properties which then can be read by the client-app.

In the _dummy_ example above: the WMS layer might show a raster layer with park boundaries (marked with a different color so that they can be easily distinguished at various zoom levels. The WFS layer is used to draw a vector polygon when a user clicks on a park (and now we can use the custom properties from the WFS service response to show a modal/popup or do all kinds of magic with the vector element).


Again an oversimplified generalization:

  • You usually use WMS for static baselayers, heatmaps, cadastral units, object borders etc...
  • You usually (but it is definitely not a rule) accompany the WMS layer with a WFS layer to have more interactivity and data.

UX wise: WMS usually works better in low zoom levels (country/county/city view), WFS works better with higher zoom levels (a certain smaller area).

Technically most WFS plugins construct the necessary query (like the current wmsTileOptions does), sets a bounding box and has some sort of support or documentation on how to easily plot and style the received geoJSON as vector elements onto the map. And of-course usually it makes sure that everything unnecessary outside the viewport gets destroyed.

Thank you so much for taking your time for explaining it. I love it and understand it much better now.

Was this page helpful?
0 / 5 - 0 ratings