This is a Common Gateway Interface (CGI) web application written in Perl. It is a simple implementation of the Open Geospatial Consortium's Web Feature Service (WFS). The output is GML Simple Feature Profile complaint. The intended use of this code is to exercise the use of the OGC WFS with the GML Simple Feature Profile to handle time series data. This application was written by the NOAA Coastal Services Center Data Transport Laboratory (DTL)as part of DTL Project 4. See http://www.csc.noaa.gov/DTL/.
This code is a REST based XML data service. The general flow is:
1. Parse config parameters from config file (sub parse_config_file).
2. parse and check user inputs (sub parse_checks_inputs).
3. connect to DB
4. construct SQL query
5. run DB query and build memory structure
6. disconnect DB
7. cylce through memory structure building featureMembers
8. send HTTP response
It accepts a few input fields in an HTTP Get. The required input fields are:
1. BBOX (-93.00,29.00,-95.00,30.00)
2. TIME (2007-06-01T12:00Z,2007-06-01T14:00Z)
3. TYPENAME (salinity, waterTemperature)
The service returns either a valid data reponse expressed as GML Simple Feature Profile XML or a WFS error response. Note that there is only one method provided, 'getFeature'. This is an incomplete WFS implementation. No 'getCapabilities' method is provided.
A few global configuration parameters are stored in a configuration file. They include:
1. dbname - name of the db to which to connect.
2. dbhost - host on which dbname is available
3. dbport - port on that host
4. dbuser - database user name used for connection
5. dbpass - database password for that user
6. logDir - location for the application log
7. TYPENAMES - an array of valid parameter names that the service should handle.
This is useful in checking requests to guard against db code insertion hacks.
This code was developed on Red Hat Linux and interfaces with a PostgreSQL database server. It has not been tested on other platforms. However, the code is fairly generic Perl/CGI code and the database interactions are simple and generic using the typical Perl DBI::DBD approach. To run this application you must have:
1. A recent Linux OS or equivalent (Use of another OS may require modification of the code.)
2. An Apache HTTP server or equivalent. There is no known reason this code
would not run on any HTTP server that supports CGI applications and Perl.
3. A PostgreSQL instance or equivalent that is supported by the Perl DBI::DBD
architecture.
4. Appropriate Perl DBD driver to talk to your database server.
5. A database view compliant with the view specification provided by CSC DTL Proj4.
1. Place the code (microWFS.cgi) in the 'cgi-bin' area of your web server.
2. Modify the first line of the code to point at the Perl interpreter on your system.
3. Set the execute bit on that file so that the web server process can execute it.
4. Put the configuration file (microWFSConf.xml) in an appropriate place where your web
server can 'see' it.
5. Edit the configuration file location variable to point at your microWFSCon.xml file.
The variable is near the top of the code and looks like:
my $config_location = '/var/www/cgi-bin/microwfs/beta/microWFSConf.xml';
6. Edit the config file with the connection specifics for your database server.
To use a database other than PostgreSQL, make sure the necessary Perl DBD driver
is installed and adjust the connection statement near the top of the code
appropriately. Some drivers use slightly different attributes and syntaxes in their
connection statements. See the documentation provided with your driver for details.
The connection statement is on or near line 55 and looks like:
my $dbh = DBI->connect("dbi:.....
7. Create a database view compliant with the specifications provided by the
DTL Project4. See http://www.csc.noaa.gov/DTL/.