Adding geospatial types to an XML schema
You can add a geospatial type to an element in your XML schema. A geospatial type is a geometric object (point, line, or polygon) that represents either a geographic position or a spatial feature. It can be static or moving.
About this task
To use geospatial types, you must first import the geometry.xsd file in your schema.
To define moving geometries, you must also import the geolibst.xsd file in your schema.
Procedure
- Specify the XML namespace of the geometry schema: xmlns:geom="http://www.ibm.com/geolib/geom" and xmlns:crs="http://www.ibm.com/geolib/crs".
- Import the main schema: <import namespace="http://www.ibm.com/geolib/geom" schemaLocation="InstallDir/CIS-runtime-target-platform/schema/geometry.xsd"/>. If you need to define moving geometries, you must also import the geolibst.xsd file: <import namespace="http://www.ibm.com/geolib/geom" schemaLocation="InstallDir/CIS-runtime-target-platform/schema/geolibst.xsd"/>
- Specify the geospatial type of the element. For example, <element name="country" type="geom:MultiPolygon">.
Example
The following example shows an XML schema that defines a bike station entity, a bike entity, and a search station event. This example does not include any moving geometries. The bike and the bike station are defined with the point geospatial type.
<?xml version="1.0" encoding="UTF-8"?>
<schema elementFormDefault="qualified"
targetNamespace="http://www.ibm.com/ia/bikestation"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:ns="http://www.ibm.com/ia/bikestation"
xmlns:geom="http://www.ibm.com/geolib/geom"
xmlns:crs="http://www.ibm.com/geolib/crs">
<import namespace="http://www.ibm.com/geolib/geom" schemaLocation="C:/IBM/ODMInsights880/CIS-runtime-target-platform/schema/geometry.xsd"/>
<element name="BikeStation" type="ns:BikeStation"/>
<complexType name="BikeStation">
<annotation>
<appinfo source="http://www.ibm.com/ia/Annotation">
<entity elementName="BikeStation"/>
</appinfo>
</annotation>
<sequence>
<element name="location" type="geom:Point">
</element>
<element name="name" type="string">
</element>
<element name="id" type="string">
<annotation>
<appinfo source="http://www.ibm.com/ia/Annotation">
<entityId/>
</appinfo>
</annotation>
</element>
</sequence>
</complexType>
<element name="Bike" type="ns:Bike"/>
<complexType name="Bike">
<annotation>
<appinfo source="http://www.ibm.com/ia/Annotation">
<entity elementName="Bike"/>
</appinfo>
</annotation>
<sequence>
<element name="currentLocation" type="geom:Point">
</element>
<element name="id" type="string">
<annotation>
<appinfo source="http://www.ibm.com/ia/Annotation">
<entityId/>
</appinfo>
</annotation>
</element>
</sequence>
</complexType>
<element name="SearchStation" type="ns:SearchStation"/>
<complexType name="SearchStation">
<annotation>
<appinfo source="http://www.ibm.com/ia/Annotation">
<event elementName="SearchStation"/>
</appinfo>
</annotation>
<sequence>
<element name="bike" type="string">
<annotation>
<appinfo source="http://www.ibm.com/ia/Annotation">
<businessName name="bike"/>
<businessType type="com.ibm.ia.bikestation.Bike"/>
</appinfo>
</annotation>
</element>
<element name="timestamp" type="dateTime">
<annotation>
<appinfo source="http://www.ibm.com/ia/Annotation">
<timestamp/>
</appinfo>
</annotation>
</element>
</sequence>
</complexType>
</schema>
The following example shows an XML schema that defines a car entity. This example includes a moving geometry. The location of the car is defined with the MovingGeometry geospatial type.
<?xml version="1.0" encoding="UTF-8"?>
<schema elementFormDefault="qualified"
xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/car"
xmlns:car="http://www.example.org/car"
xmlns:geost="http://www.ibm.com/geolib/st"
xmlns:geom="http://www.ibm.com/geolib/geom"
xmlns:crs="http://www.ibm.com/geolib/crs">
<import namespace="http://www.ibm.com/geolib/st" schemaLocation="C:/IBM/ODMInsights880/CIS-runtime-target-platform/schema/geolibst.xsd" />
<import namespace="http://www.ibm.com/geolib/geom" schemaLocation="C:/IBM/ODMInsights880/CIS-runtime-target-platform/schema/geometry.xsd" />
<element name="car" type="car:Car" />
<complexType name="Car">
<annotation>
<appinfo source="http://www.ibm.com/ia/Annotation">
<entity elementName="car" />
</appinfo>
</annotation>
<sequence>
<element name="licenseNumber" type="string" minOccurs="1" maxOccurs="1">
<annotation>
<appinfo source="http://www.ibm.com/ia/Annotation">
<entityId />
</appinfo>
</annotation>
</element>
<element name="driverName" type="string" minOccurs="1" maxOccurs="1" />
<element name="location" type="geost:MovingGeometry" minOccurs="1" maxOccurs="1" />
</sequence>
</complexType>
</schema>