B Creating and Registering a Custom Spatial Data Provider

This appendix shows a sample implementation of a spatial data provider, and explains how to register this provider to be used with the map visualization component.

The complete implementation can be found under the map visualization component web/demo/spatialprovider directory. The implementation uses then following files:

  • us_bigcities.xml: sample XML file that the provider parses

  • customSpatialProviderSample.java: Java implementation of the spatial data provider

  • spatialprovider.jar: jar file with the compiled version of the customSpatialProviderSample.java source file

The us_bigcities.xml file has sections to define the data attributes, the data extents, and the feature information, including the geometry (in GML format) and the attribute values. This file includes the following:

<?xml version="1.0" standalone="yes"?>
<spatial_data>
 
<data_attributes>
  <attribute name="city" type="string" />
  <attribute name="state_abrv" type="string" />
  <attribute name="pop90" type="double" />
</data_attributes>
 
<data_extents>
   <xmin> -122.49586 </xmin>
   <ymin> 29.45765 </ymin>
   <xmax> -73.943849 </xmax>
   <ymax> 42.3831 </ymax>
</data_extents>
 
<geoFeature>
  <attributes> New York,NY,7322564 </attributes>
  <geometricProperty>
    <Point>
      <coordinates>-73.943849, 40.6698</coordinates>
    </Point>
   </geometricProperty>
 </geoFeature>
 
. . .
</spatial_data>