fleaflet / flutter_map

A versatile mapping package for Flutter. Simple and easy to learn, yet completely customizable and configurable, it's the best choice for mapping in your Flutter app.
https://pub.dev/packages/flutter_map
BSD 3-Clause "New" or "Revised" License
2.75k stars 860 forks source link

WFS support? #706

Closed rktvsiim closed 3 years ago

rktvsiim commented 4 years ago

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?

4F2E4A2E commented 4 years ago

What is WMS and WFS?

rktvsiim commented 4 years ago

@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:

4F2E4A2E commented 4 years ago

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?

rktvsiim commented 4 years ago

@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:

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.

4F2E4A2E commented 4 years ago

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

mblataric commented 3 years ago

Another example for WFS is situation where you want to display names over map. If I use WMS, I am stuck with colors defined on geoserver which rarely works well and there is nothing you can do about it. With WFS, I can get vector information and provide information how to draw it on the map layer.

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 3 years ago

This issue was closed because it has been stalled for 5 days with no activity.

barbalex commented 3 years ago

Being able to add WFS is a fairly basic feature. I feel this issue should not be closed.

Rather it should stay open to motivate someone more able than me to implement it.

Closing a basic feature request like this seems to signal that there is no interest to accept a pull request.

ibrierley commented 3 years ago

If it's a fairly basic feature, I'm guessing it should be easy to create a pull request for it ;). Don't underestimate your own abilities, others would help if they can.

I'm saying the first bit slightly tongue in cheek, as often these are more complex than we think. But, if you can break it down into steps...i.e 1) here is a wfs server working to look at and query... 2) here are the requests we would want it to be able to handle 3) this is what the data looks like every time, and a spec (maybe a bit of test data the server sends) 4) this is what we would want to be able to do with it....

And then break it down from there further if necessary. It sounds quite interesting, but I don't think someone will just pick it up because there is a git issue open for it, but it may overlap with some other projects people are playing with including myself.

barbalex commented 3 years ago

@ibrierley With basic I meant a basic need rather than it being simple to implement. But thanks for the great input.

little-ke-er commented 3 years ago

https://github.com/haikun-li/flutter_map_wfs

FireAndIceFrog commented 1 year ago

Was there any progress on this?