B カスタム空間データ・プロバイダの作成および登録

この付録では、空間データ・プロバイダのサンプル実装を示し、このプロバイダをマップ・ビジュアライゼーション・コンポーネントで使用するための登録方法について説明します。

完全な実装は、マップ・ビジュアライゼーション・コンポーネントのweb/demo/spatialproviderディレクトリにあります。実装では次のファイルが使用されます。

  • us_bigcities.xml: プロバイダが解析するサンプルXMLファイル

  • customSpatialProviderSample.java: 空間データ・プロバイダのJava実装

  • spatialprovider.jar: ソース・ファイルcustomSpatialProviderSample.javaのコンパイル済バージョンを含むjarファイル

us_bigcities.xmlファイルには、データ属性、データ・エクステントおよび地物情報を定義するセクションがあり、ジオメトリ(GML形式)および属性値が含まれます。このファイルの内容は次のとおりです。

<?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>