The nationaal georegister (NGR) asked us to develop a simple way for third parties to use NGR’s catalogue service. NGR implemented geonetwork as their catalogue-software and it supports CSW v2.0.2. As such anyone or anything that talks CSW can already use NGR’s service. With CSW you can search the NGR database for online geo-information. This could be useful for developers who want to add relevant maps to their websites.
However, CSW is a complex, XML based standard which takes quite some time to understand and implement. Also, being XML it is subject to the security model of browsers, which forces the developer to setup a proxy on their server. This means that it isn’t very easy for a developer to use NGR in their website. CSW supports many different query parameters and returns a lot of meta data, which are important for GIS professionals, but not necessarily for casual users.
To simplify this powerful tool we decided to leave the XML on the server and talk JSON to the client. We created a CSWTransformer service where you can send in one query string and it gives you back a JSON object with the results. The query string only searches in the abstract and title fields of the database and only those which are actual WMS services. Since it is a JSON object it is possible to bypass the browser’s security and directly get the object from a different source than the webserver of the html page.
The trick to do this is to dynamically add a script to the webpage:
var script = document.createElement("script");
It is important to have a callback function, which will be executed after the response gets in. The response looks like this:
"title": "Aerodata luchtfotobedekking Nederland 2005"},
"name": "Mapservice layers",
"title": "GCN concentratie ozon (O3) 2008"}]