Personal tools

SRB:Spatial Extensions

From Adapt

Jump to: navigation, search

---+Adding Spatial Elements to the SRB

This was done using a 2.x version of the SRB. Newer versions have the capacity for user-defined tables that should be used instead

in mcat/mk.config set db_informix= to db_informix=1

You'll want to make sure that NODEFDAC=yes is set in your environment
before you do the db mcat setup, this will disable defualt public 
access to any newly created tables

setup mcat to use lobj/table driver, when ingesting the mcat location
use esipmcat01:mcat:mcat since we will be using the table driver

Table setup.
create table GEO_GRANULE_OBJ (
   data_id      integer  not null,
        metadatanum     integer not null,
   bound      ST_Polygon,
   location   varchar(255,20),
--
--  browse files refer to data_id's of other items in the mcat
--
   preview_file   integer, 
   browse_file   integer,
   vendor      varchar(80),
   start_date   date,
   end_date   date,
   wrs_path   int,
   wrs_row      int,
   wrs_fraction   varchar(10),
        wrs_type        int,
--
-- from project table
--
        project_id      int not null,
--
-- description of process applied to data (orthorect, etc)
--
        attributes_text varchar(255)
);
create table GEO_GRANULE_COLL (
   data_grp_id   varchar(127) not null,
        metadatanum     integer not null,
   bound      ST_Polygon,
   location   varchar(255,20),
--
--  browse files refer to data_id's of other items in the mcat
--
   preview_file   integer, 
   browse_file   integer,
   vendor      varchar(80),
   start_date   date,
   end_date   date,
   wrs_path   int,
   wrs_row      int,
   wrs_fraction   varchar(10),
        wrs_type        int,
--
-- from project table
--
        project_id      int not null,
--
-- description of process applied to data (orthorect, etc)
--
        attributes_text varchar(255)
);

Add account mcattbl and grant permissions. You will also need to drop public
permissions from all other tables as well so the DAI interface cannot talk 
to the authentication tables.
grant all on geo_granule_obj to mcattbl;
grant all on geo_granule_coll to mcattbl;
grant select on mdas_ad_repl to mcattbl;
grant select on mdas_ad_mdata to mcattbl;
grant select on mdas_ad_collmdata to mcattbl;
grant select on mdas_td_data_grp to mcattbl;


Add account and password to data/TableConfig

register the resource into the mcat
ingestResource 'esipmcat01-ifmx'  'informix table database' 'esipmcat01' ' permanent 0

test the DAI interface by: 
   Sregister -D 'database shadow object' -R esipmcat01-ifmx ' testdb
   Scat 'testdb&SHADOW= select * from geo_granule_granule'
   Scat 'testdb&SHADOW= select * from mdas_td_locn'
   the last test should error out as you do not have permission to view
   the mdas_td_locn table

 you can test loading in spatial atributes through teh DAI by doing:
   find out the data_id of a file. You can do this through MDAS_AD_REPL
   Sappend -i "dlib1&SHADOW="
   insert into geo_granule values(102,0 POLYGON ((103.242999937 45.3830000241, 105.593000071 45.0410000818, 106.228999979 46.6620000697, 103.811999936 47.0149999195, 103.242999937 45.3830000241)))
----

Now add the spatial attribute to the source code.

edit mdasC_db2_externs.h. and go down to the unused block at USEREXTRA1

mdasC_db2_externs.h:#define GEO_BOUND                      201 /* USER EXTRA 1*/
mdasC_db2_externs.h:#define GEO_LOCATION                   202 /* USER EXTRA 2*/
mdasC_db2_externs.h:#define GEO_PREVIEW_FILE               203 /* USER EXTRA 3*/
mdasC_db2_externs.h:#define GEO_BROWSE_FILE                204 /* USER EXTRA 4*/
mdasC_db2_externs.h:#define GEO_VENDOR                     205 /* USER EXTRA 5*/
mdasC_db2_externs.h:#define GEO_START_DATE                 206 /* USER EXTRA 6*/
mdasC_db2_externs.h:#define GEO_END_DATE                   207 /* USER EXTRA 7*/
mdasC_db2_externs.h:#define GEO_WRS_PATH                   208 /* USER EXTRA 8*/
mdasC_db2_externs.h:#define GEO_WRS_ROW                    209 /* USER EXTRA 9*/
mdasC_db2_externs.h:#define GEO_WRS_FRACTION               210 /* USER EXTRA 10*/


now in the mdasGlobals.h file, change the USEREXTRA in dcs_tname around
marker 280 to the table name you created 'GEO_GRANULE' in our case. Now in 
dcs_aname change the first 'extra' around marker 80 to the column name.
This is bound in our case.

now you can recompile the mcat.


-- Main.MikeSmorul - 02 May 2005