geo-data / node-mapserv

All the functionality of Mapserver's `mapserv` CGI program made available to Node.js
BSD 2-Clause "Simplified" License
21 stars 8 forks source link

Allow instantiation of `Map` instances from javascript object mapfile representations #3

Open homme opened 11 years ago

homme commented 11 years ago

Mapfiles can be represented very effectively as JSON structures: most mapfile directives would map over to object properties. Those directives that would not do so are ones like LAYER and CLASS which would instead map over to arrays of objects, following the underlying mapserver C data structure.

Defining such a JSON structure would be very useful in the context of declarative mapping as it allows easy manipulation of the mapfile parameters from plain javascript code: the mapfile object representation could be created and modified at will and then used to instantiate a Map object using an asynchronous FromJSON() class method.

Although strictly speaking the argument to FromJSON() would be a native javascript object literal the name underlies the intent.

Implementation would involve a synchronous serialising object/function that returns a mapfile string: this string would then be used to instantiate the object.