Ticket #177: update0.sql

File update0.sql, 19.0 KB (added by Jinsongdi Yu, 12 years ago)

test script to insert the 1D, 2D and 3D coverage

Line 
1-- These SQL statements will create the metadata database required by WCPS. Each coverage defined here must have a rasdaman collection by the same name in order to work.
2
3-- There are three types of tables.
4-- The "static" fixed tables are the ones for which you see "insert" statements in this file. They should generally never be modified. Any modifications of these tables will require to be reflected in the WCPS source code, so a code review must be done if anything is inserted or deleted there. The values of these tables are specified by the WCPS standard.
5-- The "service" tables contain various things that are not per-coverage. These are modifiable, but see the comments for each before you change them.
6-- The "coverage" tables contain information for each coverage. They can be modified freely, as long as the end result makes sense, as described below.
7
8-----------------------------------------------------------------------------------------
9-- STATIC TABLES. Once again, modifying any of these will break WCPS.
10-----------------------------------------------------------------------------------------
11
12-- This is a static table, describing the type of axes WCPS knows about. Don't touch it.
13CREATE TABLE ps_axistype (
14 id serial NOT NULL,
15 axistype character varying(9) UNIQUE NOT NULL,
16 primary key (id)
17);
18
19INSERT INTO ps_axistype VALUES (1, 'x');
20INSERT INTO ps_axistype VALUES (2, 'y');
21INSERT INTO ps_axistype VALUES (3, 'temporal');
22INSERT INTO ps_axistype VALUES (4, 'elevation');
23INSERT INTO ps_axistype VALUES (5, 'other');
24INSERT INTO ps_axistype VALUES (6, 't');
25SELECT pg_catalog.setval('ps_axistype_id_seq', 6, true);
26
27-- This is a static table, describing the range datatypes WCPS knows about. Don't touch it.
28CREATE TABLE ps_datatype (
29 id serial NOT NULL,
30 datatype text NOT NULL,
31 primary key (id)
32);
33
34INSERT INTO ps_datatype (id, datatype) VALUES (1, 'boolean');
35INSERT INTO ps_datatype (id, datatype) VALUES (2, 'char');
36INSERT INTO ps_datatype (id, datatype) VALUES (3, 'unsigned char');
37INSERT INTO ps_datatype (id, datatype) VALUES (4, 'short');
38INSERT INTO ps_datatype (id, datatype) VALUES (5, 'unsigned short');
39INSERT INTO ps_datatype (id, datatype) VALUES (6, 'int');
40INSERT INTO ps_datatype (id, datatype) VALUES (7, 'unsigned int');
41INSERT INTO ps_datatype (id, datatype) VALUES (8, 'long');
42INSERT INTO ps_datatype (id, datatype) VALUES (9, 'unsigned long');
43INSERT INTO ps_datatype (id, datatype) VALUES (10, 'float');
44INSERT INTO ps_datatype (id, datatype) VALUES (11, 'double');
45INSERT INTO ps_datatype (id, datatype) VALUES (12, 'complex');
46INSERT INTO ps_datatype (id, datatype) VALUES (13, 'complex2');
47SELECT pg_catalog.setval('ps_datatype_id_seq', 13, true);
48
49-- This is a static table, describing the interpolation types WCPS knows about. Don't touch it.
50CREATE TABLE ps_interpolationtype (
51 id serial NOT NULL,
52 interpolationtype text NOT NULL,
53 primary key (id)
54);
55
56INSERT INTO ps_interpolationtype (id, interpolationtype) VALUES (1, 'nearest');
57INSERT INTO ps_interpolationtype (id, interpolationtype) VALUES (2, 'linear');
58INSERT INTO ps_interpolationtype (id, interpolationtype) VALUES (3, 'cubic');
59INSERT INTO ps_interpolationtype (id, interpolationtype) VALUES (4, 'quadratic');
60INSERT INTO ps_interpolationtype (id, interpolationtype) VALUES (5, 'none');
61SELECT pg_catalog.setval('ps_interpolationtype_id_seq', 5, true);
62
63-- This is a static table, describing the null resistances WCPS knows about. Don't touch it.
64CREATE TABLE ps_nullresistance (
65 id serial NOT NULL,
66 nullresistance text NOT NULL,
67 primary key (id)
68);
69
70INSERT INTO ps_nullresistance (id, nullresistance) VALUES (1, 'full');
71INSERT INTO ps_nullresistance (id, nullresistance) VALUES (2, 'none');
72INSERT INTO ps_nullresistance (id, nullresistance) VALUES (3, 'half');
73INSERT INTO ps_nullresistance (id, nullresistance) VALUES (4, 'other');
74SELECT pg_catalog.setval('ps_nullresistance_id_seq', 4, true);
75
76-- This is a static table, describing the coordinate reference systems known by WCPS. Don't touch it.
77-- Whether it's actually present in the table or not, the CRS called "CRS:1" is always supported. CRS:1 is the image CRS, i.e. addressable by pixels.
78-- The current implementation does not support CRSs other than CRS:1, and does not use the contents of the table.
79CREATE TABLE ps_crs (
80 id serial NOT NULL,
81 name text UNIQUE NOT NULL,
82 primary key (id)
83);
84
85INSERT INTO ps_crs VALUES (9, 'http://www.opengis.net/def/crs/EPSG/0/4326');
86INSERT INTO ps_crs VALUES (8, 'CRS:1');
87SELECT pg_catalog.setval('ps_crs_id_seq', 9, true);
88
89
90-----------------------------------------------------------------------------------------
91-- SERVICE TABLES.
92-----------------------------------------------------------------------------------------
93
94-- This table describes the encoding formats known to WCPS, as well as their mappings to mimetypes. WCPS doesn't care about these, but if you add any, make sure that rasdaman can encode in the format specified by 'name', or encoding to that format won't work.
95CREATE TABLE ps_format (
96 id serial NOT NULL,
97 name character varying(64) NOT NULL,
98 mimetype character varying(128) NOT NULL,
99 primary key (id)
100);
101
102INSERT INTO ps_format VALUES (1, 'csv', 'text/plain');
103INSERT INTO ps_format VALUES (2, 'jpg', 'image/jpeg');
104INSERT INTO ps_format VALUES (3, 'jpeg', 'image/jpeg');
105INSERT INTO ps_format VALUES (4, 'png', 'image/png');
106INSERT INTO ps_format VALUES (5, 'tif', 'image/tiff');
107INSERT INTO ps_format VALUES (6, 'tiff', 'image/tiff');
108INSERT INTO ps_format VALUES (7, 'raw', 'application/x-octet-stream');
109
110SELECT pg_catalog.setval('ps_format_id_seq', 7, true);
111
112
113-----------------------------------------------------------------------------------------
114-- COVERAGE TABLES. At this point, you need to have read the beginning of the WCPS standard, which describes the different metadata a coverage may have.
115-- When entering a new coverage, it's best to fill the tables in the order listed here, to satisfy foreign key constraints.
116-----------------------------------------------------------------------------------------
117
118-- A coverage must be introduced here.
119-- The name must correspond to the rasdaman collection for that data. It must also be present in PS_NullSet below.
120-- The nullDefault must be the default null value for the coverage. It must match the range type. If the range type is a structure, it must look like this: {c1,c2,c3...} where cn is the nth component of the value.
121-- The interpolationTypeDefault is the default interpolation type used in operations that require one, but don't have one specified. It must point to an entry in the static table above.
122-- The nullResistanceDefault is the default null resistance used in operations that require one, but don't have one specified. It must point to an entry in the static table above.
123CREATE TABLE ps_coverage (
124 id serial NOT NULL,
125 name text UNIQUE NOT NULL,
126 nullvalue text,
127 crs text,
128 nulldefault text,
129 interpolationtypedefault integer,
130 nullresistancedefault integer,
131 primary key (id),
132 foreign key (interpolationTypeDefault) references ps_interpolationType (id),
133 foreign key (nullResistanceDefault) references ps_nullResistance (id)
134);
135
136INSERT INTO ps_coverage VALUES (1, 'NIR', NULL, NULL, '{0,0,0}', 5, 2);
137INSERT INTO ps_coverage VALUES (2, 'mean_summer_airtemp', NULL, NULL, '0', 5, 2);
138INSERT INTO ps_coverage VALUES (3, 'lena', NULL, NULL, '0', 5, 2);
139
140INSERT INTO ps_coverage VALUES (4, 'mowglie', NULL, NULL, '{0,0,0}', 5, 2);
141
142INSERT INTO ps_coverage VALUES (5, 'NN3_1', NULL, NULL, '0', 5, 2);
143INSERT INTO ps_coverage VALUES (6, 'NN3_2', NULL, NULL, '0', 5, 2);
144INSERT INTO ps_coverage VALUES (7, 'NN3_3', NULL, NULL, '0', 5, 2);
145INSERT INTO ps_coverage VALUES (8, 'NN3_4', NULL, NULL, '0', 5, 2);
146INSERT INTO ps_coverage VALUES (9, 'NN3_5', NULL, NULL, '0', 5, 2);
147INSERT INTO ps_coverage VALUES (10, 'NN3_6', NULL, NULL, '0', 5, 2);
148
149
150-- Each coverage has a number of axes, called its dimension. Each axis must have an entry here.
151-- The coverage is the id of the coverage a given entry describes.
152-- The i is the number of axis for that coverage. Axes are ordered, so be careful.
153-- The lo is the lowest addressable pixel, usually 0.
154-- The hi is the highest addressable pixel, usually the total number of pixels on the axis minus 1.
155CREATE TABLE ps_celldomain (
156 id serial NOT NULL,
157 coverage integer NOT NULL,
158 i integer NOT NULL,
159 lo integer NOT NULL,
160 hi integer NOT NULL,
161 primary key (id),
162 unique (coverage, i),
163 foreign key (coverage) references ps_coverage (id) on delete cascade
164);
165
166INSERT INTO ps_celldomain VALUES (1, 1, 0, 0, 1915);
167INSERT INTO ps_celldomain VALUES (2, 1, 1, 0, 1075);
168INSERT INTO ps_celldomain VALUES (3, 2, 0, 0, 885);
169INSERT INTO ps_celldomain VALUES (4, 2, 1, 0, 710);
170INSERT INTO ps_celldomain VALUES (5, 3, 0, 0, 506);
171INSERT INTO ps_celldomain VALUES (6, 3, 1, 0, 553);
172
173INSERT INTO ps_celldomain VALUES (7, 4, 0, 0, 119);
174INSERT INTO ps_celldomain VALUES (8, 4, 1, 0, 158);
175INSERT INTO ps_celldomain VALUES (9, 4, 2, 0, 118);
176
177INSERT INTO ps_celldomain VALUES (10, 5, 0, 0, 125);
178INSERT INTO ps_celldomain VALUES (11, 6, 0, 0, 125);
179INSERT INTO ps_celldomain VALUES (12, 7, 0, 0, 125);
180INSERT INTO ps_celldomain VALUES (13, 8, 0, 0, 125);
181INSERT INTO ps_celldomain VALUES (14, 9, 0, 0, 125);
182INSERT INTO ps_celldomain VALUES (15, 10, 0, 0, 125);
183
184
185
186-- Addressing by pixels is good enough for some things, but sometimes you need to address a coverage via its geo coordinates. The geographic extent of each coverage is similar to the cell domain, but in geo coordinates.
187-- For each coverage, the number of entries must be the same as in the CellDomain table.
188-- The coverage is the id of the coverage a given entry describes.
189-- The i is the number of axis for that coverage. Axes are ordered, so be careful.
190-- The name is the name of a given axis. For example, a horizontal axis could have the name "x", and the a vertical one could have "y". You can then ask WCPS to scale x by 2, etc.
191-- The type is one of the axes types in the static table above.
192-- If the type is not temporal, numLo and numHi must be the lowest and highest addressable points in geo coordinates, and strLo and strHi must be left null.
193-- If the type is temporal, numLo and numHi must be left null, and strLo and strHi must be timestamps, specifying the extent.
194-- Because the current implementation does not currently support temporal axes, you can use "other" as the type and specify dummy values for numLo and numHi.
195-- Finally, geocoordinates are dependent on the CRS, so this table doesn't currently make much sense. An entry should be per coverage, axis, and CRS, rather than just per coverage and axis as it is now.
196CREATE TABLE ps_domain (
197 id serial NOT NULL,
198 coverage integer NOT NULL,
199 i integer NOT NULL,
200 name text NOT NULL,
201 type integer NOT NULL,
202 numlo double precision,
203 numhi double precision,
204 strlo text,
205 strhi text,
206 primary key (id),
207 unique (coverage, i),
208 foreign key (coverage) references ps_coverage (id) on delete cascade,
209 foreign key (type) references ps_axisType (id) on delete cascade
210);
211
212INSERT INTO ps_domain VALUES (1, 1, 0, 'x', 1, 0, 1, NULL, NULL);
213INSERT INTO ps_domain VALUES (2, 1, 1, 'y', 2, 0, 1, NULL, NULL);
214INSERT INTO ps_domain VALUES (3, 2, 0, 'x', 1, 111.975, 156.275, NULL, NULL);
215INSERT INTO ps_domain VALUES (4, 2, 1, 'y', 2, -44.525, -8.975, NULL, NULL);
216INSERT INTO ps_domain VALUES (5, 3, 0, 'x', 1, 0, 1, NULL, NULL);
217INSERT INTO ps_domain VALUES (6, 3, 1, 'y', 2, 0, 1, NULL, NULL);
218
219INSERT INTO ps_domain VALUES (7, 4, 0, 'x', 1, 0, 1, NULL, NULL);
220INSERT INTO ps_domain VALUES (8, 4, 1, 'y', 2, 0, 1, NULL, NULL);
221INSERT INTO ps_domain VALUES (9, 4, 2, 't', 5, 0, 1, NULL, NULL);
222
223INSERT INTO ps_domain VALUES (10, 5, 0, 't', 5, 0, 1, NULL, NULL);
224INSERT INTO ps_domain VALUES (11, 6, 0, 't', 5, 0, 1, NULL, NULL);
225INSERT INTO ps_domain VALUES (12, 7, 0, 't', 5, 0, 1, NULL, NULL);
226INSERT INTO ps_domain VALUES (13, 8, 0, 't', 5, 0, 1, NULL, NULL);
227INSERT INTO ps_domain VALUES (14, 9, 0, 't', 5, 0, 1, NULL, NULL);
228INSERT INTO ps_domain VALUES (15, 10, 0, 't', 5, 0, 1, NULL, NULL);
229
230-- The range is the datatype of the coverage cell values.
231-- The coverage is the id of the coverage a given entry describes.
232-- The i is the number of the structure component. Because cells can have composite types, you could have multiple entries for each coverage. Entries are ordered.
233-- The name is a handle for that component. Names for the components for a RGB coverage, for example, could be "red", "green", and "blue". You can then ask WCPS for the blue channel of a coverage, and it will know what you're talking about.
234-- The type is the datatype of the given component. Note that while in principle each component could have a different datatype, having that might cause problems.
235CREATE TABLE ps_range (
236 id serial NOT NULL,
237 coverage integer NOT NULL,
238 i integer NOT NULL,
239 name text NOT NULL,
240 type integer NOT NULL,
241 primary key (id),
242 unique (coverage, i),
243 foreign key (coverage) references ps_coverage (id) on delete cascade,
244 foreign key (type) references ps_dataType (id) on delete cascade
245);
246
247INSERT INTO ps_range VALUES (1, 1, 0, 'red', 7);
248INSERT INTO ps_range VALUES (2, 1, 1, 'green', 7);
249INSERT INTO ps_range VALUES (3, 1, 2, 'blue', 7);
250INSERT INTO ps_range VALUES (4, 2, 0, 'pan', 7);
251INSERT INTO ps_range VALUES (5, 3, 0, 'pan', 7);
252
253INSERT INTO ps_range VALUES (6, 4, 0, 'red', 7);
254INSERT INTO ps_range VALUES (7, 4, 1, 'green', 7);
255INSERT INTO ps_range VALUES (8, 4, 2, 'blue', 7);
256
257INSERT INTO ps_range VALUES (9, 5, 0, 'value', 5);
258INSERT INTO ps_range VALUES (10, 6, 0, 'value', 5);
259INSERT INTO ps_range VALUES (11, 7, 0, 'value', 5);
260INSERT INTO ps_range VALUES (12, 8, 0, 'value', 5);
261INSERT INTO ps_range VALUES (13, 9, 0, 'value', 5);
262INSERT INTO ps_range VALUES (14, 10, 0, 'value', 5);
263
264
265-- Each coverage allows a set of interpolation methods. An interpolation method is a pair of an interpolation type and a null resistance. Each coverage is required to have at least one entry in that table, and the defaults in PS_Coverage must be present here.
266-- The current implementation does not use the contents of this table, but it does ensure that the above constraints are met.
267CREATE TABLE ps_interpolationset (
268 id serial NOT NULL,
269 coverage integer NOT NULL,
270 interpolationtype integer NOT NULL,
271 nullresistance integer NOT NULL,
272 primary key (id),
273 unique (coverage, interpolationType, nullResistance),
274 foreign key (coverage) references ps_coverage (id) on delete cascade,
275 foreign key (interpolationType) references ps_interpolationType (id) on delete cascade,
276 foreign key (nullResistance) references ps_nullResistance (id) on delete cascade
277);
278
279INSERT INTO ps_interpolationset VALUES (1, 1, 5, 2);
280INSERT INTO ps_interpolationset VALUES (2, 2, 5, 2);
281INSERT INTO ps_interpolationset VALUES (3, 3, 5, 2);
282
283INSERT INTO ps_interpolationset VALUES (4, 4, 5, 2);
284
285INSERT INTO ps_interpolationset VALUES (5, 5, 5, 2);
286INSERT INTO ps_interpolationset VALUES (6, 6, 5, 2);
287INSERT INTO ps_interpolationset VALUES (7, 7, 5, 2);
288INSERT INTO ps_interpolationset VALUES (8, 8, 5, 2);
289INSERT INTO ps_interpolationset VALUES (9, 9, 5, 2);
290INSERT INTO ps_interpolationset VALUES (10, 10, 5, 2);
291
292
293-- Each coverage allows a set of null values. If the range is non-composite, a null value is the value of the single component, e.g. "0". If the range is composite, a null value is of the form "{c1,c2,c3}", e.g. "{0,0,0}" for a RGB coverage. Each coverage is required to have at least one entry in that table, and the defaults in PS_Coverage must be present here.
294-- The current implementation does not use the contents of this table, but it does ensure that the above constraints are met.
295CREATE TABLE ps_nullset (
296 id serial NOT NULL,
297 coverage integer NOT NULL,
298 nullvalue text NOT NULL,
299 primary key (id),
300 unique (coverage, nullValue),
301 foreign key (coverage) references ps_coverage (id) on delete cascade
302);
303
304INSERT INTO ps_nullset VALUES (1, 1, '{0,0,0}');
305INSERT INTO ps_nullset VALUES (2, 2, '0');
306INSERT INTO ps_nullset VALUES (3, 3, '0');
307
308INSERT INTO ps_nullset VALUES (4, 4, '{0,0,0}');
309
310
311INSERT INTO ps_nullset VALUES (5, 5, '0');
312INSERT INTO ps_nullset VALUES (6, 6, '0');
313INSERT INTO ps_nullset VALUES (7, 7, '0');
314INSERT INTO ps_nullset VALUES (8, 8, '0');
315INSERT INTO ps_nullset VALUES (9, 9, '0');
316INSERT INTO ps_nullset VALUES (10, 10, '0');
317
318
319
320
321-- Each axis of a coverage has a set of allowed coordinate reference systems.
322-- CRS:1 is used for non-georeferenced coverages.
323CREATE TABLE ps_crsset (
324 id serial NOT NULL,
325 axis integer NOT NULL,
326 crs integer NOT NULL,
327 primary key (id),
328 unique (axis, crs),
329 foreign key (axis) references ps_domain (id) on delete cascade,
330 foreign key (crs) references ps_crs (id) on delete cascade
331);
332
333INSERT INTO ps_crsset VALUES (1, 1, 8);
334INSERT INTO ps_crsset VALUES (2, 2, 8);
335INSERT INTO ps_crsset VALUES (3, 3, 9);
336INSERT INTO ps_crsset VALUES (4, 4, 9);
337
338INSERT INTO ps_crsset VALUES (5, 5, 8);
339INSERT INTO ps_crsset VALUES (6, 6, 8);
340
341INSERT INTO ps_crsset VALUES (7, 7, 8);
342INSERT INTO ps_crsset VALUES (8, 8, 8);
343INSERT INTO ps_crsset VALUES (9, 9, 8);
344
345INSERT INTO ps_crsset VALUES (10, 10, 8);
346INSERT INTO ps_crsset VALUES (11, 11, 8);
347INSERT INTO ps_crsset VALUES (12, 12, 8);
348INSERT INTO ps_crsset VALUES (13, 13, 8);
349INSERT INTO ps_crsset VALUES (14, 14, 8);
350INSERT INTO ps_crsset VALUES (15, 15, 8);
351
352-- This table contains textual descriptions of the available coverages.
353CREATE TABLE ps_descriptions (
354 id serial NOT NULL,
355 coverage integer NOT NULL,
356 title text NOT NULL,
357 abstract text,
358 keywords text,
359 primary key (id),
360 unique (coverage),
361 foreign key (coverage) references ps_coverage (id) on delete cascade
362);
363
364INSERT INTO ps_descriptions VALUES (1, 1, 'NIR', 'Abstract for coverage NIR', 'keywords');
365INSERT INTO ps_descriptions VALUES (2, 2, 'mean_summer_airtemp', 'This coverage shows the mean summer air temperatures over Australia in the period 2001-2007', 'summer temperature, australia');
366INSERT INTO ps_descriptions VALUES (3, 3, 'lena', 'Abstract for coverage lena', 'lena');
367
368INSERT INTO ps_descriptions VALUES (4, 4, 'mowglie', 'Abstract for coverage mowglie', 'keywords');
369
370INSERT INTO ps_descriptions VALUES (5, 5, 'NN3_1', 'Abstract coverage', 'keywords');
371INSERT INTO ps_descriptions VALUES (6, 6, 'NN3_2', 'Abstract coverage', 'keywords');
372INSERT INTO ps_descriptions VALUES (7, 7, 'NN3_3', 'Abstract coverage', 'keywords');
373INSERT INTO ps_descriptions VALUES (8, 8, 'NN3_4', 'Abstract coverage', 'keywords');
374INSERT INTO ps_descriptions VALUES (9, 9, 'NN3_5', 'Abstract coverage', 'keywords');
375INSERT INTO ps_descriptions VALUES (10, 10, 'NN3_6', 'Abstract coverage', 'keywords');
376
377-- This table contains metadata for CRS transformations: WGS84 bounding box limits and offsets for the X and Y axis.
378CREATE TABLE ps_crsdetails (
379 id serial NOT NULL,
380 coverage integer NOT NULL,
381 low1 float,
382 high1 float,
383 low2 float,
384 high2 float,
385 offset1 float,
386 offset2 float,
387 unique (coverage),
388 foreign key (coverage) references ps_coverage (id) on delete cascade
389);
390
391INSERT INTO ps_crsdetails VALUES (1, 1, 0, 1, 0, 1, NULL, NULL);
392INSERT INTO ps_crsdetails VALUES (2, 2, 111.975, 156.275, -44.525, -8.975, NULL, NULL);
393INSERT INTO ps_crsdetails VALUES (3, 3, 0, 1, 0, 1, NULL, NULL);
394
395INSERT INTO ps_crsdetails VALUES (4, 4, 0, 1, 0, 1, NULL, NULL);
396