spatialiteにイメージをimport(rasterlite2 その2 結局失敗編)

前回は「rl2tool CREATE」でエラーが発生した今回はエラーが発生しないようにテーブル「strict_resolution」のNOT NULL制約の付いている項目にdefault 0を設定。

CREATE TABLE raster_coverages (
coverage_name TEXT NOT NULL PRIMARY KEY,
title TEXT NOT NULL DEFAULT '*** missing Title ***',
abstract TEXT NOT NULL DEFAULT '*** missing Abstract ***',
sample_type TEXT NOT NULL DEFAULT '*** undefined ***',
pixel_type TEXT NOT NULL DEFAULT '*** undefined ***',
num_bands INTEGER NOT NULL DEFAULT 1,
compression TEXT NOT NULL DEFAULT 'NONE',
quality INTEGER NOT NULL DEFAULT 100,
tile_width INTEGER NOT NULL DEFAULT 512,
tile_height INTEGER NOT NULL DEFAULT 512,
horz_resolution DOUBLE NOT NULL,
vert_resolution DOUBLE NOT NULL,
srid INTEGER NOT NULL,
nodata_pixel BLOB NOT NULL,
palette BLOB,
statistics BLOB,
geo_minx DOUBLE,
geo_miny DOUBLE,
geo_maxx DOUBLE,
geo_maxy DOUBLE,
extent_minx DOUBLE,
extent_miny DOUBLE,
extent_maxx DOUBLE,
extent_maxy DOUBLE,
strict_resolution INTEGER NOT NULL DEFAULT 0,
mixed_resolutions INTEGER NOT NULL DEFAULT 0,
section_paths INTEGER NOT NULL DEFAULT 0,
section_md5 INTEGER NOT NULL DEFAULT 0,
section_summary INTEGER NOT NULL DEFAULT 0,
is_queryable INTEGER,
red_band_index INTEGER,
green_band_index INTEGER,
blue_band_index INTEGER,
nir_band_index INTEGER,
enable_auto_ndvi INTEGER,
CONSTRAINT fk_rc_srs FOREIGN KEY (srid) REFERENCES spatial_ref_sys (srid))

今度はrl2too.を使わずに「Tutorial: building and testing the Planet Earth sample – full SQL」
に従ってインポート。

「空間データを使うために必要なテーブルを作成」までは前回で終了している。

Coverage作成

sqlite> SELECT RL2_CreateCoverage('Test', 'UINT8', 'RGB', 3, 'JPEG', 80, 512, 512, 2451, 0.0138888889);
1
sqlite> SELECT RL2_LoadRaster('Test', '0108.jpg');
Importing: 0108.jpg
------------------
    Image Size (pixels): 5000 x 3750
                   SRID: -1
       LowerLeft Corner: X=-63999.92 Y=-36600.08
      UpperRight Corner: X=-63199.92 Y=-36000.08
       Pixel resolution: X=0.16 Y=0.16
INSERT INTO sections; sqlite3_step() error: Test_sections.geometry violates Geometry constraint [geom-type or SRI
llowed]
0
sqlite> SELECT RL2_LoadRaster('Test', '0108.jpg', 1, 2451);
Importing: 0108.jpg
------------------
    Image Size (pixels): 5000 x 3750
                   SRID: 2451
       LowerLeft Corner: X=-63999.92 Y=-36600.08
      UpperRight Corner: X=-63199.92 Y=-36000.08
       Pixel resolution: X=0.16 Y=0.16
  ----------
    Pyramid levels successfully built for: 0108
1
sqlite> select RL2_Pyramidize('test');
1
sqlite> select RL2_SetCoverageInfos('test','test1','hello');
1
sqlite> .quit

とりあえずエラーが発生せずに終了

動作確認のためにwmsliteを実行してみると

wmslite -db test.sqlite

======================================================
              WmsLite server startup
======================================================
         SQLite version: 3.8.5
     SpatiaLite version: 4.2.0
    RasterLite2 version: 1.0.0-rc0
======================================================
the DB "test.sqlite" doesn't contain any valid Raster Coverage
wmslite server shutdown in progress
wmslite shutdown completed ... bye bye

「doesn’t contain any valid Raster Coverage」失敗のようだ!

wmsliteのソースを追えば問題箇所が判明するかもしれないが、とりあえず一旦終了して次回はGDALのTOOLで試す。