Skip to content

jarpi/node_wfs_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Join the chat at https://gitter.im/jarpi/node_wfs_api

Web Feature Layer implementation in NodeJS

What's this project about?

While i was at h4ckademy i was challenged to create a web feature layer to hit an API. The project itself must be open source and also fill a need for a company, so that's the goal of it. There's only one method implemented, but it's enough to see how it works and how to extend it, in a near future i expect to implement more methods.

What's WFS?

WFS it's an communication standard defined by OGC to retrieve and manipulate maps served by WMS (Web Map Service). It can take http requests or post requests in GML (derived from XML) Example

Usage

I choosed NodeJS because i feel very comfortable with Javascript and also there’s nothing implemented before, so though was great to contribute to NodeJS community with something not done yet.

There’s a main “class” that parses a config file (app.conf.json), those objects defined, will be parsed and compared with the query that comes to the application layer, and then merged together, and then will call business method to call the API and return server response to user.

Show me that!

{"availableMethods":
	{
		"GetFeature": {
			"ModelDefinition": "/models/WFSMethodGetFeature.js", 
			"Params": 
			{
				"MandatoryParams": {"request":"","typename":""},
				"OptionalParams": {"aliases":"","srsName":"","projectionClause":"","filter":"","resourceid":"","bbox":"","sortby":"","storedquery_id":"","storedquery_parameter":""}  
			} 
		}, 
		"AAA":{
			"ModelDefinition": "/models/WFSMethodGetFeature.js", 
			"Params": 
			{
				"MandatoryParams": {"request":"","typename":""},
				"OptionalParams": {"aliases":"","srsName":"","projectionClause":"","filter":"","resourceid":"","bbox":"","sortby":"","storedquery_id":"","storedquery_parameter":""}  
			} 
		}
	} 
} 

So WFS have 11 methods for now in 2.0 version, that's not so much, but i'm lazy so i've decided that the developer that is developing the final product must work. app.conf.js define an availableMethods object, which contains the methods which our layer will answer. Besides the method definition will be defined a params object who will contain mandatory params and optional params for the request. That's simple, right?

In fact, we can use this library to hit any API, just adapt it at your will

To add a new method to hit our API, edit conf/app.conf.json, add your method definition, and your mandatory params and optional params. Create a new file inside models/*, with this structure:

function WFSMethod[Feature_Name](queryParams, configParams) 
{ 
	WFSMethod.call(this, queryParams, configParams); 
	
}; 

WFSMethodGetFeature.prototype = Object.create(WFSMethod.prototype); 
WFSMethodGetFeature.prototype.constructor = WFSMethod[Feature_Name];  

WFSMethodGetFeature.prototype.createRequest = function() {}; 

And start serving.

Enjoy!

Thanks h4ckademy! You rock guys!

About

WFS Layer written in Javascript that runs on Node.JS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published