Advantages of WFS Over GeoJSON and KML Formats

geojsonkmlleafletopenlayers-2wfs

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?

Best Answer

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.