I have created a simple CGI interface to our geomagnetic data - you can find it on our public web site - see the link below. A little background first. The data set used is compiled by INTERMAGNET (
http://www.intermagnet.org/) of which BGS is a member. Data from here is freely available to academic institutions (no restrictions). Observatories from around the world send data to us every day. Some send it quite quickly (say every 10 minutes) others more slowly (perhaps once a day, or slower). The data consists of 'columns' of numbers - the magnetic field is a vector, so three values are needed to describe it. We often record a fourth number as well, as a sort of quality check. These 'columns' have very simple names like 'X' (strength of the field in the northerly direction), Y, Z, ...
The CGI interfaces lets you do three things:
1.) Get a list of observatories (command='list-observatories'). This would be the first step for any application, to find out what observatories are available.
2.) Request the date/time of the most recently recorded data from a single observatory. This allows an application to know what data is available (going backwards in time, we store 2 years of data from the current date).
3.) Request the data itself. To make a data request you need to specify the observatory code, the start date and the number of days. You will always get back data in 24 hour chunks - this is something I need to work on (to allow arbitary lengths of data to be requested).
The CGI interface is here:
http://www.geomag.bgs.ac.uk/cgi-bin/gin_xml
To use it you need to POST or GET the following name-value pairs:
| Variable name |
When is it needed |
How to use it |
| command |
Always needed |
Controls which of the three functions will be used. Set to one of "observatory-list", "most-recent-data" or "data" |
| observatory_code |
Needed if command is "most-recent-data" or "data" |
Controls which observatory data will be returned for. Set to one of the observatory codes retrieved with command=observatory-list |
| sdate |
Needed if command is "data" |
Controls the start date of returned data. Set to the start date of the data you want, format is dd-mm-yyyy |
| length |
Needed if command is "data" |
Controls the length of returned data. Set to the number of days you want to retrieve |
There is a trivial example of how to use the CGI interface here:
http://www.geomag.bgs.ac.uk/workshop/test_xml.html
The XML returned by requests for "observatory-list" and "data" can be validated by DTDs (both in the same directory - www.geomag.bgs.ac.uk/workshop). I have checked that a couple of examples did validate OK (using the validation tool in
NetBeans).
I do not really know what I am doing with XML, so any comments / suggestions here would be very welcome.
--
SimonFlower - 06 Oct 2006
Topic revision: r2 - 13 Oct 2006 - 17:59:03 -
SimonFlower