4.3 Web Feature Service Architecture
4.3.2 Adding New Features
For each new feature type to be added we first create a definitive xml Schema. This schema inherits necessary GML schemas and describes both geographic information and non-geographic metadata about the feature.
The second step is to create a sample xml instance from the xml Schema with all the possible element and attributes present. This is the xml skeleton of the feature type or simply an ‘empty’ feature-xml document and should not have any actual element or attribute values.
The third file to be created is a mapping file that associates the sample xml instance with the relational database table. This xml file contains several MapElement elements each of which has two attributes: XSDNodeXPath and DBColumnName. The first attribute contains the XPath [108] path to a particular element in the xml instance while the second one contains the relational database column name for that particular element. For instance the mapping entry for the Magnitude column from the SCEDC [107] seismic catalog example is:
64
Here the XPath value to this element in the xml-instance is //Magnitude and the actual magnitude values are stored in the MAGNITUDE column.
The last file is the configuration file for this feature type which includes the database connection information, physical paths of the aforementioned files, names of the columns that contain maximum and minimum values for the geographic data and metadata.
To further explain our approach we give the required files created for SCEDC seismic catalog. Following picture depicts a graphical representation of the XML schema describing seismic events.
Note from the above schema that the geographic information entry is described using a complex type “gml:PointPropertyType” inherited from the GML2 schemas:
<element name="Location" type="gml:PointPropertyType"/>
The gml:Point type has two choices, gml:coord and gml:coordinates.
gml:coord type is extended from gml:CoordType which contains X, Y and Z values for three dimensional coordinate systems.
65
66
For instance we can encode GPS measurements with this complex type since these measurements contain Latitude, Longitude and Height values.
The geographic element for the fault schema would be
since the fault segments are actually lines and contain multiple coordinates. For instance: The second file is an xml instance generated from the schema:
<xs:element name="SegmentCoordinates" ref="gml:lineStringProperty"/> <gml:lineStringProperty>
<gml:LineString srsName="EPSG:4230">
<gml:coordinates>-82.7335,27.8846,1.0 -82.7586,28.1352,1.0 - 82.6368,28.4571,1.0 -82.7335,27.8846,1.0 -82.7218,28.1763,1.0 - 82.5235,28.6658,1.0 -82.2489,27.2001,1.0 -81.5399,28.6771,1.0 - 81.1583,28.4414,1.0</gml:coordinates> </gml:LineString> </gml:lineStringProperty>
67
Here the element that holds geographic information which is inherited from the GML schema is <?xml version="1.0" encoding="UTF-8"?> <SeismicEvent xmlns:gml=http://www.opengis.net/gml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://sensorgrid.org/seismicity.xsd"> <Date> <Year/> <Month/> <Day/> </Date> <Time> <Hour/> <Minute/> <Second/> </Time> <Location>
<gml:Point srsName="EPSG:6356"> <gml:coord> <gml:X/> <gml:Y/> </gml:coord> </gml:Point> </Location> <EventType/> <Magnitude/> <MagnitudeType/> <Depth/> <Quality/> <NPH/> <NGRM/> <EventId/> </SeismicEvent>
68
Note from the xml instance that none of the elements contain actual values except an attribute which is the same value for all the features.
The third file created for this feature type is the following mapping type:
<?xml version="1.0" encoding="UTF-8"?>
<MapElements xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <MapElement No="0" XSDNodeXPath="//Date/Year" DBColumnName="YEAR"/> <MapElement No="1" XSDNodeXPath="//Date/Month" DBColumnName="MONTH"/> <MapElement No="2" XSDNodeXPath="//Date/Day" DBColumnName="DAY"/> <MapElement No="3" XSDNodeXPath="//Time/Hour" DBColumnName="HOUR"/> <MapElement No="4" XSDNodeXPath="//Time/Minute" DBColumnName="MINUTE"/> <MapElement No="5" XSDNodeXPath="//Time/Second" DBColumnName="SECOND"/> <MapElement No="5" XSDNodeXPath="//EventType" DBColumnName="ET"/> <MapElement No="6" XSDNodeXPath="//Magnitude" DBColumnName="MAGNITUDE"/> <Location>
<gml:Point srsName="EPSG:6356"> <gml:coord> <gml:X/> <gml:Y/> </gml:coord> </gml:Point> </Location>
69
This file is used after the WFS retrieves the queried features from the database. WFS then uses this mapping file to populate the xml instance with the results.
The last file is the following configuration file:
<MapElement No="7" XSDNodeXPath="//MagnitudeType" DBColumnName="MAGNITUDE_TYPE"/> <MapElement No="8" XSDNodeXPath="//Location/gml:Point/gml:coord/gml:X" DBColumnName="LATITUDE"/> <MapElement No="9" XSDNodeXPath="//Location/gml:Point/gml:coord/gml:Y" DBColumnName="LONGITUDE"/> <MapElement No="10" XSDNodeXPath="//Depth" DBColumnName="DEPTH"/> <MapElement No="11" XSDNodeXPath="//Quality" DBColumnName="QUALITY"/> <MapElement No="12" XSDNodeXPath="//EventId" DBColumnName="EVID"/> <MapElement No="13" XSDNodeXPath="//NPH" DBColumnName="NPH"/> <MapElement No="14" XSDNodeXPath="//NGRM" DBColumnName="NGRM"/> </MapElements>
70
<?xml version="1.0" encoding="UTF-8"?>
<feature> <db>
<type>mySQL</type>
<serveraddress>gf8.ucs.indiana.edu</serveraddress>
<dbname>cce</dbname>
<tablename>scedc</tablename>
<driver>com.mysql.jdbc.Driver</driver>
<username>uname</username>
<password>passwd</password> </db>
<xml_instance>
<localaddress>/home/galip/wfs/seismic_instance.xml</localaddress> </xml_instance>
<map_file>
<localaddress>/home/galip/wfs/scedc_mapping.xml</localaddress> </map_file>
<xmlschema>
<localaddress>/home/galip/wfs/seismicity.xsd</localaddress> </xmlschema>
<maxmin_column_names>
<minx>LONGITUDE</minx>
<miny>LATITUDE</miny>
<maxx>LONGITUDE</maxx>
<maxy>LATITUDE</maxy> </maxmin_column_names> <Metadata>
<Name>scedc</Name>
<Title>California Earthquake Data in SCEDC Format</Title>
<Abstract> </Abstract>
<Keywords>Seismic,WFS</Keywords>
<SRS>EPSG:6356</SRS>
<Operations>
<Operation type="Query"/>
</Operations>
<MetadataURL>http://www.crisisgrid.org</MetadataURL> </Metadata>
71
WFS uses this file to locate and query the database that contains this particular feature type. After the query results are returned it uses the file locations provided in this file to generate the GML feature collection.