Providing geoscience data globally Navigation
Main content
Bottom links

OneGeology

Home > How to serve a OneGeology WMS > Using GeoServer software to serve OneGeology Web Services > Using application schemas
Information:

This is the OneGeology archive website, for the latest information return to the main OneGeology website

6.4.2.1 Using application schemas extension

If you wish to configure a GeoSciML-Portrayal cabaility in any layers in your service and you are using shapefiles as the data source for those layers then you will need to use the application schemas extension.

Shapefiles use dBase tables to contain thematic property data, and the field names in a shapefile are limited to 10 characters in length. Because some of the fields in the GeoSciML-Portrayal schema are longer than 10 characters a more complicated configuration utilizing the GeoServer Application Schema extension must be used for GeoServer GeoSciML-Portrayal implementation based on a shapefile. This extension allows data sources to be configured with a mapping from field names in the data source to XML element names in the representation of that data returned by a WMS GetFeatureInfo request. This field name mapping is essential for enabling user-defined map legend schemes based on OGC Styled Layer Descriptor (SLD) files that expect GeoSciML-Portrayal field names

The application scheme extension must be downloaded and installed separately, as it is not part of the standard GeoServer installation. Once the extension is installed, you will need to create a mapping file, and restart GeoServer to enable the new configuration.

6.4.2.1.1 Install application schema .jar files

See the Geoserver extensions page on Sourceforge http://sourceforge.net/projects/geoserver/files/GeoServer%20Extensions/ to get the application schema extension appropriate to uyour version of GeoServer

  1. Go to the above Sourceforge page and click the link for the version of GeoServer that you have installed. For example if you have Geoserver 2.3.5 installed click on the 2.3.5 link.
  2. Download the app-schema plugin zip file for the same version of your GeoServer instance. So for Geoserver 2.3.5 you would download the geoserver-2.3.5-app-schema-plugin.zip file
  3. Unzip the app-schema plugin zip file to obtain the jar files inside. Do not unzip the jar files.
  4. Place the jar files in the WEB-INF/lib directory of your GeoServer installation.
  5. Restart GeoServer to load the extension

6.4.2.1.2 Create mapping file

The mapping file is an XML file that maps fields from the data source into the fields of the XML output schema. For this example, the data source is a shapefile; this could be used as a workflow with continuation from Section 7.1.2. The example mapping file, below, uses field names in a shapefile that are the automatically truncated names generated by ESRI software mapping from the long field names to the valid Shapefile field names. If other field names are used in the shapefile (e.g. the recommended abbreviations in Appendix K), the strings in the sourceExpression/OCQL elements should be modified appropriately.

<?xml version="1.0" encoding="UTF-8"?>
  <as:AppSchemaDataAccess
  xmlns:as="http://www.geotools.org/app-schema"
  xmlns:ogc="http://www.opengis.net/ogc"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.geotools.org/app-schema
  http://ogc.bgs.ac.uk/mapping/AppSchemaDataAccess.xsd">
  <namespaces>
    <Namespace>
      <prefix>gsmlp</prefix>
      <uri>http://xmlns.geosciml.org/geosciml-portrayal/2.0</uri>
    </Namespace>
    <Namespace>
      <prefix>gml</prefix>
      <uri>http://www.opengis.net/gml</uri>
    </Namespace>
  </namespaces>
  <sourceDataStores>
    <DataStore>
      <id>shapefile</id>
      <parameters>
        <Parameter>
          <name>url</name>
          <value>
            file:/home/geoserver/downloads/shapefiles/GeologicUnitView.shp
          </value>
        </Parameter>
        <Parameter>
          <name>memory mapped buffer</name>
          <value>false</value>
        </Parameter>
        <Parameter>
          <name>create spatial index</name>
          <value>true</value>
        </Parameter>
        <Parameter>
          <name>charset</name>
          <value>ISO-8859-1</value>
        </Parameter>
      </parameters>
    </DataStore>
  </sourceDataStores>
  <targetTypes>
    <FeatureType>
      <schemaUri>
        http://schemas.usgin.org/files/geologic-units/2.0/GeoSciML.xsd
      </schemaUri>
    </FeatureType>
  </targetTypes>
  <typeMappings>
    <FeatureTypeMapping>
      <sourceDataStore>shapefile</sourceDataStore>
      <sourceType>GeologicUnitView</sourceType>
      <targetElement>gsmlp:GeologicUnitView</targetElement>
      <attributeMappings>
        <AttributeMapping>
          <targetAttribute>gsmlp:GeologicUnitView</targetAttribute>
          <idExpression>
            <OCQL>getId()</OCQL>
          </idExpression>
        </AttributeMapping>
        <AttributeMapping>
          <targetAttribute>gsmlp:identifier</targetAttribute>
          <sourceExpression>
            <OCQL>identifier</OCQL>
          </sourceExpression>
        </AttributeMapping>
        <AttributeMapping>
          <targetAttribute>gsmlp:name</targetAttribute>
          <sourceExpression>
            <OCQL>name</OCQL>
          </sourceExpression>
        </AttributeMapping>
        <AttributeMapping>
          <targetAttribute>gsmlp:description</targetAttribute>
          <sourceExpression>
            <OCQL>descriptio</OCQL>
          </sourceExpression>
        </AttributeMapping>
        <AttributeMapping>
          <targetAttribute>gsmlp:geologicUnitType</targetAttribute>
          <sourceExpression>
            <OCQL>geologicUn</OCQL>
          </sourceExpression>
        </AttributeMapping>
        <AttributeMapping>
          <targetAttribute>gsmlp:rank</targetAttribute>
          <sourceExpression>
            <OCQL>rank</OCQL>
          </sourceExpression>
        </AttributeMapping>
        <AttributeMapping>
          <targetAttribute>gsmlp:lithology</targetAttribute>
          <sourceExpression>
            <OCQL>lithology</OCQL>
          </sourceExpression>
        </AttributeMapping>
        <AttributeMapping>
          <targetAttribute>gsmlp:geologicHistory</targetAttribute>
          <sourceExpression>
            <OCQL>geologicHi</OCQL>
          </sourceExpression>
        </AttributeMapping>
        <AttributeMapping>
          <targetAttribute>gsmlp:observationMethod</targetAttribute>
          <sourceExpression>
            <OCQL>observatio</OCQL>
          </sourceExpression>
        </AttributeMapping>
        <AttributeMapping>
          <targetAttribute>gsmlp:positionalAccuracy</targetAttribute>
          <sourceExpression>
            <OCQL>positional</OCQL>
          </sourceExpression>
        </AttributeMapping>
        <AttributeMapping>
          <targetAttribute>gsmlp:source</targetAttribute>
          <sourceExpression>
            <OCQL>source</OCQL>
          </sourceExpression>
        </AttributeMapping>
        <AttributeMapping>
          <targetAttribute>gsmlp:geologicUnitType_uri</targetAttribute>
          <sourceExpression>
            <OCQL>geologic_1</OCQL>
          </sourceExpression>
        </AttributeMapping>
        <AttributeMapping>
          <targetAttribute>gsmlp:representativeLithology_uri</targetAttribute>
          <sourceExpression>
            <OCQL>representa</OCQL>
          </sourceExpression>
        </AttributeMapping>
        <AttributeMapping>
          <targetAttribute>gsmlp:representativeAge_uri</targetAttribute>
          <sourceExpression>
            <OCQL>represen_1</OCQL>
          </sourceExpression>
        </AttributeMapping>
        <AttributeMapping>
          <targetAttribute>gsmlp:representativeOlderAge_uri</targetAttribute>
          <sourceExpression>
            <OCQL>represen_2</OCQL>
          </sourceExpression>
        </AttributeMapping>
        <AttributeMapping>
          <targetAttribute>gsmlp:representativeYoungerAge_uri</targetAttribute>
          <sourceExpression>
            <OCQL>represen_3</OCQL>
          </sourceExpression>
        </AttributeMapping>
        <AttributeMapping>
          <targetAttribute>gsmlp:specification_uri</targetAttribute>
          <sourceExpression>
            <OCQL>specificat</OCQL>
          </sourceExpression>
        </AttributeMapping>
        <AttributeMapping>
          <targetAttribute>gsmlp:metadata_uri</targetAttribute>
          <sourceExpression>
            <OCQL>metadata_u</OCQL>
          </sourceExpression>
        </AttributeMapping>
        <AttributeMapping>
          <targetAttribute>gsmlp:genericSymbolizer</targetAttribute>
          <sourceExpression>
            <OCQL>genericSym</OCQL>
          </sourceExpression>
        </AttributeMapping>
        <AttributeMapping>
          <targetAttribute>gsmlp:shape</targetAttribute>
          <sourceExpression>
            <OCQL>the_geom</OCQL>
          </sourceExpression>
        </AttributeMapping>
      </attributeMappings>
    </FeatureTypeMapping>
  </typeMappings>
</as:AppSchemaDataAccess>

Create this mapping file with the prefix and namespace binding, the connection parameters (data source here is a shapefile), the online location of the schema (XSD), and the field mapping.

See helpful GeoServer documentation at the following locations:
http://docs.geoserver.org/stable/en/user/data/app-schema/mapping-file.html
http://docs.geoserver.org/stable/en/user/data/app-schema/data-stores.html#shapefile

Place the file in the GeoServer file location of the datastore. An example file location might be:
C:\Program Files (x86)\OpenGeo\OpenGeo Suite\webapps\geoserver\data\workspaces\gsmlp\Lithostratigraphy\
Where gsmlp is the name of your Workspace, and Lithostratigraphy is the Data Store name.

6.4.2.1.3 Edit datastore.xml file

This file is located in the same Data Store directory. To enable application-schemas, this file must indicate that the shapefile is no longer used for field names, but the mapping file instead. Example datastore.xml, after editing:

<dataStore>
  <id>DataStoreInfoImpl--49e58162:140a6f913de:-8000</id>
  <name>ShearDisplacementStructureView</name>
  <enabled>true</enabled>
  <workspace>
    <id>WorkspaceInfoImpl--1739a454:14097568969:-7fe9</id>
  </workspace>
  <connectionParameters>
    <entry key="dbtype">app-schema</entry>
    <entry key="url">
    file:workspaces/gsmlp/ShearDisplacementStructureView/ShearDisplacementStructureViewAZGS.xml
    </entry>
    <entry key="namespace">http://xmlns.geosciml.org/geosciml-portrayal/2.0</entry>
  </connectionParameters>
  <__default>false</__default>
</dataStore>

6.4.2.1.4 Restart GeoServer

After restarting GeoServer, the datastore for the desired layer will now read the field names from the mapping file, while still pulling the data from the indicated shapefile. The same can be done with data connections to PostGIS or any other type of data store.

Section last modified: 07 October 2015

Back|Next