Сервер переехал на новый сайт http://www.oraclegis.com/blog. Здесь идет ретрансляция

вторник, 24 июня 2008 г.

Работа с Georaster

1. Инсталляция
Начиная с Oracle Database 10g в базе данных появилась новая возможность по хранению географически привязанных растровых данных, таких как спутниковые снимки. К сожалению, с самого начала Oracle не предложил инструментария для работы с растровыми данными, полагаясь на партнеров. В 11-ой версии все стало лучше. Давайте посмотрим как можно загружаться данные.
1. После инсталляции примеров, в папке $ORACLE_HOME\md\demo\georaster\java есть загрузчик в базу данных.
2. Есть загрузчик от сторонних разработчиков - http://www.pcigeomatics.com/download_georaster_loader.php. Его можно проинсталлировать и получить ключик для использования. Объявлено, что он бесплатный.
К сожалению ни тот ни другой не автоматизурют процедуру заполнения метаданных для георастра. Для этого необходимо скачать инструмент http://dl.maptools.org/dl/geotiff/libgeotiff/.

2. Загрузка
Сначала необходимо создать 2 таблицы: таблицу с полем SDO_GEORASTER и таблицы, где непосредственно будут храниться метаданные.
Кроме это необходимо создать DML триггеры.
You should create the necessary DML trigger or triggers immediately after you create a GeoRaster table, and you must create the trigger or triggers before you perform any operations on the table.

Each time you call the SDO_GEOR_UTL.createDMLTrigger procedure successfully, GeoRaster creates a trigger with a unique name. (All GeoRaster DML trigger names start with the string GRDMLTR_.) When you drop a GeoRaster table, all GeoRaster triggers associated with the table are automatically dropped also.

If you have created the GeoRaster DML trigger on a column, GeoRaster automatically performs the following actions when the trigger is fired as a result of a DML operation affecting that column:

  • After an insert operation, the trigger inserts a row with the GeoRaster table name, GeoRaster column name, raster data table name, and rasterID value into the USER_SDO_GEOR_SYSDATA view (described in Section 2.4). If an identical entry already exists, an exception is raised.

  • After an update operation, if the new GeoRaster object is null or empty, the trigger deletes the old GeoRaster object. If there is no entry in the USER_SDO_GEOR_SYSDATA view for the old GeoRaster object (that is, if the old GeoRaster object is null), the trigger inserts a row into that view for the new GeoRaster object. If there is an entry in the USER_SDO_GEOR_SYSDATA view for the old GeoRaster object, the trigger updates the information to reflect the new GeoRaster object.

  • After a delete operation, the trigger deletes raster data blocks for the GeoRaster object in its raster data table, and it deletes the row in the USER_SDO_GEOR_SYSDATA view for the GeoRaster object.


create table city_data
(city_name varchar2(50),
population number,
georaster sdo_georaster);

call SDO_GEOR_UTL.createDMLTrigger('CITY_DATA', 'GEORASTER');

create table city_data_rdt_01
of sdo_raster (primary key (
rasterId,
pyramidLevel,
bandBlockNumber,
rowBlockNumber,
columnBlockNumber))
lob(rasterblock) store as (nocache nologging);

После этого можно создать пустые объекты, в которые будет осуществляться загрузка Georaster объектов (для PCI Geomatics это можно не делать).

-- Initialize a GeoRaster image with RASTERID=1
INSERT INTO city_data
values ('Boston', 625494,
sdo_geor.init('city_data_rdt_01', 1));

Имена таблицы RDT (где непосредственно хранятся данные георастра), судя по всем, должны быть уникальны в рамках все базы данных. Иначе получаем вот такую ошибку

ERROR at line 1:
ORA-13403: invalid rasterDataTable specification: GPS.MOSCOW_DATA_RD
ORA-06512: at "MDSYS.MD", line 1723
ORA-06512: at "MDSYS.MDERR", line 17
ORA-06512: at "MDSYS.SDO_GEOR_DEF", line 116
ORA-06512: at "MDSYS.SDO_GEOR_INT", line 2482
ORA-06512: at "MDSYS.SDO_GEOR_AUX", line 34
ORA-06512: at "GPS.GRDMLTR_73192_3", line 1
ORA-04088: error during execution of trigger 'GPS.GRDMLTR_73192_3'

3. Отображение в Map
После того как данные загружены - попробуем отобразить их в Mapviewer. Тут для России есть один очень существенный нюанс. Необходимо в запуск MapBuilder включить библиотеку orai18n.jar, иначе будет выдаваться вот такая ошибка (спасибо братьям китайцам http://hi.baidu.com/tiny_lk/blog/item/78e4510f5285bc2f6159f34e.html - им тоже тяжело с их иероглифами, как и нам с кириллицей)
Can not find a GeoRaster object with specified rdt and rid
Команда "правильного" запуска MapBuilder (библиотеку
orai18n.jar кладем в тот же каталог, где и MapBuilder и из него и запускаем):
java -cp orai18n.jar;mapbuilder.jar oracle.mapviewer.builder.MapBuilder

Здесь создаем Georaster theme. Процесс создания совершенно простой.
Создаем BASEMAP, с включенной темой Georaster.
Создаем MapTile на базе BASEMAP.
Кроме всего прочего для корректного показа нужно создать индекс на свойство spatialextent:
CREATE INDEX geor_idx ON moscow_data(georaster.spatialextent)
INDEXTYPE IS MDSYS.SPATIAL_INDEX;

Все. После этого базе TILECACHE можно создавать страничку в Mapviewer



1 комментарий:

Анонимный комментирует...
Этот комментарий был удален администратором блога.