I'm planning to create an online map with openlayers (2 or 3) or leaflet. I have to show some points/markers (~30.000), polygons (~500) and lines on top of an OSM map in several layers. Those points and polygons should contain meta data (at least an ID) to show the user extra information on mouse over, click or touch events. Now I'm looking for the best way to send that data to the client. The whole area, where these features are placed, is subdivided into several sections and most of the time, a user is working in one section (reading information - writing is a very rare case, that will not be implemented right now). But these sections are placed next to each other and most of the time at least 3 sections are visible. Also the points could be clustered or hidden at a higher zoom level.

I've heard about WFS, but I can't see the advantages over GeoJSON or KML. Would it be possible to just retrieve the features within the bounding box of the current view with WFS? We've got a MSSQL database and a webservice between the database and the web application and if it has not really advantages, we don't want to set up a GeoServer and a Postgres DB. Also it wouldn't be a problem to tell the webservice: Give me all features of layer L between X1,Y1 and X2,Y2 (as GeoJSON, KML or whatever). What are the advantages of WFS? What is the way, you would go or what more information is relevant for this decision?

  • 3
    You'll have a problem displaying the 30k features on the map. I get performance problems around 1k. You'll need to use a cluster strategy or something else. – CaptDragon Nov 15 '13 at 18:22
  • Yes. And of course 30k features are also useless for the user. – stofl Nov 18 '13 at 7:05
  • What are the advantages of WFS? it's a standard interface (service) that can give you all features of layer L between X1,Y1 and X2,Y2 (as GeoJSON, KML or whatever). – nmtoken Jul 26 '17 at 21:24

Keep in mind that WFS is already a service which returns its data format (mixture of OGC standards). GeoJSON and KML are only a data format, you'll have to build the service to return the data.

So included with WFS are already advanced filtering capabilities such as temporal filters, spatial filters (intersect, touches, overlaps...) as well as logical and comparison operators...and on and on. Yes you can specify to reload results for a BBox as well as the user navigates the map. This is all out of the box. Then ofcourse it's a widely used standard that many servers, clients and applications can read by allowing them to automatically query this data as said.

So the question you should ask yourself is are you going to want to expose this data to other clients, applications and servers? Will your "Give me all features of layer L between X1,Y1 and X2,Y2" service be enough? Is that all you need? If it's all you need then no reason to go with WFS. The GeoJSON or KML option will probably be faster without all the overhead. But if you're going to want to do advanced filtering in the future SOA style, WFS is the way to go.

| improve this answer | |
  • Thank you. There will be no more clients, apps and servers. And the "Give me all.." will be enough as long as I will be able to access the data from JavaScript to be able to modify it (change the icon if a state of a feature changes, highlight selected features, ...) – stofl Nov 18 '13 at 8:02

First of all, I recommend you to read the spec. The biggest pro of WFS is that it is official and standardized way to access vector data. That means when you use WFS, you do not have to reinvent to wheel (e.g. what should happen when two people edit the same feature at the same time?). It is also much easier to share data over WFS than using GeoJSON or KML (again, you do not have to write a function that returns the data user asked for as it is already a part of WFS spec).

If you are about to serve layers for read-only access, why don't you go with WMS? It should be totally OK for your purposes.

If you have any further questions, feel free to ask, I'm in the middle of deciding this dilemma myself and it's always pleasant to read other people's opinion.

| improve this answer | |
  • We've got already a windows client with a map and many operations are already implemented in stored procedures in the database. "WMS": I would need to access the features with JavaScript later (changing icons depending on the state, highlighting). Would that work with a WMS vector layer? – stofl Nov 18 '13 at 8:09
  • 2
    Remember, WMS is NOT a vector layer. It server static raster images that once loaded cannot be changed. What you can do is re-request images on button click or checkbox change event and load them with a different style. – Michal Zimmermann Nov 18 '13 at 9:20
  • WMS can return SVG images. That would be a vector layer in my eyes. And these SVG images are accessible and editable, of course - but I suspect only on a very low level... – stofl Nov 18 '13 at 10:25

WFS gives your client (OpenLayers) the option to perform its calls using different Strategies for the WFS Calls:

BBOX: reads new features when the viewport invalidates some bounds.
Cluster: for vector feature clustering.
Filter: for limiting features that get added to a layer by evaluating a filter.  The strategy maintains a cache of all features until removeFeatures is called on the layer
Fixed: requests features once and never requests new data
Paging: vector feature paging
Refresh: refreshes the layer.  By default the strategy waits for a call to refresh before refreshing.  By configuring the strategy with the interval option, refreshing can take place automatically
Save: commits newly created or modified features.  By default the strategy waits for a call to save before persisting changes.  By configuring the strategy with the auto option, changes can be saved automatically

The BBOX Strategy is commonly used. The Vector Layer will only request features from WFS that are in the viewport and as the viewport is changed, additional features are automatically loaded transparently.

As CaptDragon stated and I mentioned in your previous question the numbers of features will kill OpenLayers, most likely, or make the user experience untenable.

You could stuff your data into an MSSQL database, then write a Server Side routine to return data via Ajax calls and update the layers yourself. You Client provides the Viewport bounds in the Ajax Call. The database has to be spatially aware for this to work.

WMS would generate tiles from the same data-source. The advantage is very rapid implementation, server side styling and no downloading of data to the client for display, other than the tiles. You can also use WFS with WMS to get feature information when users click on a point.

It would also be possible to serve the data from a shape file instead of a database in all these scenarios.

| improve this answer | |
  • Could you explain me in short, how the "use WFS with WMS" would word? Would the tiles returned by WMS be aware of the points or what would be the benefit of using WMS here? – stofl Nov 18 '13 at 8:13
  • You really need to sit down and go through all the OpenLayers Examples so that you understand what it can do. Specifically, WFS Demo Here! – Mark Cupitt Nov 18 '13 at 8:59
  • I've seen that example and right now I took a deeper look into it. The only thing, the OpenLayers WFS control uses WMS in that demo is, to get the URL from the WMS layer. So I still can't see the benefit of WMS here. – stofl Nov 18 '13 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.