ラベル 投影法 の投稿を表示しています。 すべての投稿を表示
ラベル 投影法 の投稿を表示しています。 すべての投稿を表示

2010年6月9日水曜日

OpenLayers57g OpenStreetMap & GeoWebCache - GeoWebCache の設定ファイル 7

GeoWebCache 投影法を EPSG:2456でキャッシュ
- geowebcache.xml ファイルを作成


EPSG:4326、EPSG:900913 以外の投影法のキャッシュを作成するときは geowebcache.xml ファイルを作成することで実現できます。

geowebcache.xml の場所については、

GeoWebCache の Configurating Layers
http://geowebcache.org/docs/current/configuration/xml/index.html

には、

WEB-INF/classes/geowebcache.xml

5. GWC - GeoWebCache(前バージョンのマニュアル)
http://geoserver.org/display/GEOSDOC/5.+GWC+-+GeoWebCache

には、例えばということで

data_dir/gwc/geowebcache.xml

になっています。
今回は、

geoserver-2.0.1/wbapps/geoserver/WEB-INF/classes/geowebcache.xml

で試してみます。
(geowebcache.xml の場所を変えるには WEB-INF/geowebcache-servlet.xml で設定すると記述されています。)

geowebcache.xml の内容は

Simple Configuration Examples
http://geowebcache.org/docs/current/configuration/xml/simple.html

の Simple を参考に次のようにします。

<gwcConfiguration>
<!-- ... -->
<layers>
<!-- ... -->
<wmsLayer>
<name>sde:japan_highway</name>
<!-- <wmsUrl><string>http://localhost:8080/geoserver/wms</string></wmsUrl> -->
<mimeFormats><string>image/png</string></mimeFormats>
<gridSubsets>
<gridSetName>EPSG:2456</gridSetName>
<extent>
<coords>
<double>-279000</double>
<double>1054000</double>
<double>-185000</double>
<double>1104000</double>
</coords>
</extent>
<zoomStart>13</zoomStart><zoomStart>0</zoomStart>
<zoomStop>13</zoomStop>
</gridSubsets>
<wmsLayers>sde:japan_highway</wmsLayers>
<wmsUrl>
<string>http://localhost:8080/geoserver/wms</string>
</wmsUrl>
<bgColor>0x0066FF</bgColor>
<palette>popshade</palette>
</wmsLayer>
<!-- ... -->
</layers>
</gwcConfiguration>

この様なエラーが表示されました。

---
08 3 20:02:59 ERROR [context.ContextLoader] - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gwcXmlConfig' defined in URL [jar:file:/home/user/geoserver-2.0.1/webapps/geoserver/WEB-INF/lib/gwc-2.0.1.jar!/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.geowebcache.config.XMLConfiguration]: Constructor threw exception; nested exception is java.lang.NullPointerException

このエラーは、XML ファイルが文章ルール通りでないと、他の XML ファイルを参照するために発生するようです。

geowebcache.xml を

Complete List of Configuration Elements
http://geowebcache.org/docs/current/configuration/xml/exhaustive.html

に従って作成しました。

<?xml version="1.0" encoding="utf-8"?>
<gwcConfiguration
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://geowebcache.org/schema/1.2.2/geowebcache.xsd"
xmlns="http://geowebcache.org/schema/1.2.2">
<version>1.2.1</version>
<formatModifiers>
<formatModifier>
<responseFormat>image/jpeg</responseFormat>
<requestFormat>image/png</requestFormat>
<transparent>true</transparent>
<!-- OPTIONAL Background color
<bgColor>0x0066DD</bgColor> -->
<!-- OPTIONAL Palette used on WMS server
<palette>somepalette</palette> -->
<!-- OPTIONAL Tune the compression level, 1.0 is best quality -->
<compressionQuality>0.9</compressionQuality>
</formatModifier>
</formatModifiers>
<gridSets>
<gridSet>
<name>EPSG:2456</name>
<srs><number>2456</number></srs>
<extent>
<coords>
<double>-279000</double>
<double>1054000</double>
<double>-185000</double>
<double>1104000</double>
</coords>
</extent>
</gridSet>
</gridSets>
<layers>
<!-- ... -->
<wmsLayer>
<name>sde:japan_highway</name>
<mimeFormats>
<string>image/png</string>
<string>image/jpeg</string>
</mimeFormats>
<gridSubsets>
<gridSubset>
<gridSetName>EPSG:2456</gridSetName>
<extent>
<coords>
<double>-279000</double>
<double>1054000</double>
<double>-185000</double>
<double>1104000</double>
</coords>
</extent>
<zoomStart>0</zoomStart>
<zoomStop>25</zoomStop>
</gridSubset>
</gridSubsets>
<wmsUrl>
<string>http://localhost:8080/geoserver/wms</string>
</wmsUrl>
<wmsLayers>sde:japan_highway</wmsLayers>
<!-- <bgColor>0x0066FF</bgColor>
<palette>popshade</palette> -->
</wmsLayer>
<!-- ... -->
</layers>
</gwcConfiguration>

GeoServer のログイン画面の左側の欄の Services -> GWC をクリックします。
GeoWebCache 画面の Automatically Generated Demos: の 「A list of all the layers and automatic demos」リンクをクリックします。
GeoWebCache Demo 画面の sde:japan_highway に EPSG:2456 が追加されているので、OpenLayers の png をクリックして確かめてみます。

2009年9月12日土曜日

東京都の基盤地図情報 6 標高画像データに投影法を追加

4 標高画像データに投影法を追加
Tagchan's Blog
GDALを使って地理座標を与えた地図画像を投影変換する
http://www.tagchan.net/blog/2009/03/gdal_translate_warp.html
を参考にさせてもらいました。

インストール
4-1 「osgeo4w-setup.exe」を保存し、ダブルクリックします。
(「開いているファイル-セキュリティの警告」ダイアログが表示されたら「実行」をクリックします。)
4-2 OSGeo4W Setup:OSGeo4W Net Release Setup Program の「Express Install」を選んで「次へ」ボタンをクリックします。
4-3 OSGeo4W Setup:Select Packages の「GDAL」を選んで「次へ」ボタンをクリックします。
(インストールが始まります。)
4-4 OSGeo4W Setup:Create Icons でアイコンを置く場所を選んで「完了」ボタンをクリックします。

標高画像データに投影法を追加
4-5 OSGeo4W Shell を Windows の スタート->プログラム-> OSGeo4W -> OSGeo4W -> OSGeo4W Shell で起動します。
4-6 座標を追加した標高画像データのあるフォルダに移動します。
4-7 データを確認します。
投影法のデータがありません。

gdalinfo tokyo_height201-modified.tif
Driver: GTiff/GeoTIFF
Files: tokyo_height201-modified.tif
Size is 3825, 2104
Coordinate System is `'
Origin = (-278077.715182927200000,1103508.866089876300000)
Pixel Size = (23.910819753353326,-23.910819753353326)
Image Structure Metadata:
INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left ( -278077.715, 1103508.866)
Lower Left ( -278077.715, 1053200.501)
Upper Right ( -186618.830, 1103508.866)
Lower Right ( -186618.830, 1053200.501)
Center ( -232348.272, 1078354.684)
Band 1 Block=3825x1 Type=Byte, ColorInterp=Red
NoData Value=-10000000000
Band 2 Block=3825x1 Type=Byte, ColorInterp=Green
NoData Value=-10000000000
Band 3 Block=3825x1 Type=Byte, ColorInterp=Blue
NoData Value=-10000000000

4-8 座標の追加で参考にした東京の地図のデータの座標を確認します。

ogrinfo -summary AdmArea.shp AdmArea
INFO: Open of `AdmArea.shp'
using driver `ESRI Shapefile' successful.

Layer name: AdmArea
Geometry: Polygon
Feature Count: 323
Extent: (-619709.111772, -606129.469810) - (1222781.861788, 1101432.881066)
Layer SRS WKT:
PROJCS["JGD2000_Japan_Zone_14",
GEOGCS["GCS_JGD_2000",
DATUM["Japanese_Geodetic_Datum_2000",
SPHEROID["GRS_1980",6378137.0,298.257222101]],
PRIMEM["Greenwich",0.0],
UNIT["Degree",0.0174532925199433]],
PROJECTION["Transverse_Mercator"],
PARAMETER["False_Easting",0.0],
PARAMETER["False_Northing",0.0],
PARAMETER["Central_Meridian",142],
PARAMETER["Scale_Factor",0.9999],
PARAMETER["Latitude_Of_Origin",26],
UNIT["Meter",1.0]]
ID: String (7.0)
UUID: String (24.0)
PRESENCE: Integer (8.0)
FINISHED: Integer (8.0)
ORGGILVL: String (5.0)
ORGMDID: String (3.0)
TYPE: String (6.0)
NAME: String (25.0)
AAC: Integer (5.0)


4-9 PROJCS["JGD2000_Japan_Zone_14",
の EPSG は、/usr/share/proj から 2456 です。

nob61@debian:/usr/share/proj$ grep -A1 JGD2000 epsg
# JGD2000
<4612> +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs <>
--
...
# JGD2000 / Japan Plane Rectangular CS XIV
<2456> +proj=tmerc +lat_0=26 +lon_0=142 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs <>
...


4-10 gdal_translate コマンドで投影法のデータを追加します。

‾>gdal_translate -a_srs "EPSG:2456" tokyo_height201-modified.tif tokyo_height201-epsg2456.tif
Input file size is 3825, 2104
0...10...20...30...40...50...60...70...80...90...100 - done.

‾>gdalinfo tokyo_height201-epsg2456.tif
Driver: GTiff/GeoTIFF
Files: tokyo_height201-epsg2456.tif
Size is 3825, 2104
Coordinate System is:
PROJCS["JGD2000 / Japan Plane Rectangular CS XIV",
GEOGCS["JGD2000",
DATUM["Japanese_Geodetic_Datum_2000",
SPHEROID["GRS 1980",6378137,298.2572221010002,
AUTHORITY["EPSG","7019"]],
AUTHORITY["EPSG","6612"]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433],
AUTHORITY["EPSG","4612"]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",26],
PARAMETER["central_meridian",142],
PARAMETER["scale_factor",0.9999],
PARAMETER["false_easting",0],
PARAMETER["false_northing",0],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]],
AUTHORITY["EPSG","2456"]]
Origin = (-278077.715182927200000,1103508.866089876300000)
Pixel Size = (23.910819753353326,-23.910819753353326)
Metadata:
AREA_OR_POINT=Area
Image Structure Metadata:
INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left ( -278077.715, 1103508.866) (138d55'9.60"E, 35d54'52.52"N)
Lower Left ( -278077.715, 1053200.501) (138d56'12.16"E, 35d27'42.40"N)
Upper Right ( -186618.830, 1103508.866) (139d55'54.54"E, 35d56'10.74"N)
Lower Right ( -186618.830, 1053200.501) (139d56'36.59"E, 35d28'59.33"N)
Center ( -232348.272, 1078354.684) (139d25'57.89"E, 35d42'0.07"N)
Band 1 Block=3825x1 Type=Byte, ColorInterp=Red
NoData Value=-10000000000
Band 2 Block=3825x1 Type=Byte, ColorInterp=Green
NoData Value=-10000000000
Band 3 Block=3825x1 Type=Byte, ColorInterp=Blue
NoData Value=-10000000000