-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdh.install
1903 lines (1795 loc) · 63.9 KB
/
dh.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
function dh_schema() {
//
$schema['dh_feature_type'] = array (
'description' => 'Base Feature class in dh (ArcHydro: Feature)',
'fields' => array(
'fid' => array(
'description' => 'Primary key for Feature Types',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'name' => array(
'description' => 'Feature Name (Watershed, Waterbody, Monitoring Point, etc)',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'bundle' => array(
'description' => 'Feature Type / Bundle (watershed, waterbody, monitoringpoint, etc)',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'description' => array(
'description' => 'Description of this Feature Class',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
) + entity_exportable_schema_fields(),
'primary key' => array('fid'),
'indexes' => array(
'dh_fet_fix' => array('fid'),
'dh_fet_ftix' => array('bundle')
)
);
$schema['dh_feature'] = array (
'description' => 'Base Feature class in dh (ArcHydro: Feature)',
'fields' => array(
'hydroid' => array(
'description' => 'HydroID - Primary key for Features',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'hydrocode' => array(
'description' => 'HydroCode',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
),
'ftype' => array(
'description' => 'Feature Type (monitoring well, production well, geologic structure, contour line)',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'bundle' => array(
'description' => 'Bundle (Base Feature Class watershed, waterbody, monitoringpoint, etc)',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'name' => array(
'description' => 'Name',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'fstatus' => array(
'description' => 'Feature Status (0-unk,1-active,2-oos/temp,3-abandoned)',
'type' => 'varchar',
'length' => 32,
'not null' => FALSE,
'default' => 'active',
),
'uid' => array(
'description' => 'Record Owner',
'type' => 'int',
'not null' => FALSE,
'size' => 'big',
),
) + entity_exportable_schema_fields(),
'primary key' => array('hydroid'),
'indexes' => array(
'dh_fe_hyix' => array('hydroid'),
'dh_fe_ftix' => array('bundle')
)
);
// Table Desc for: HydrogeologicUnit
// Relationships: AquiferID, HorizonID
// HydroID sequence linked later in dh_install()
$schema['dh_hydrogeologicunit'] = array (
'description' => 'Hydrogeologic Unit table in dh (ArcHydro: HydrogeologicUnit)',
'fields' => array(
'hydroid' => array(
'description' => 'Primary key for Variables',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'hgucode' => array(
'description' => 'Hydrogeologic unit code. The permanent identification code of hydrogeologic units, used to establish a linkage with external information systems.',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'hguname' => array(
'description' => 'Text descriptor of hydrogeologic units used for labeling and symbolization.',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'aqcode' => array(
'description' => 'Aquifer code. Text descriptor of the aquifer used for labeling, symbolization, and querying.',
'type' => 'varchar',
'length' => 64,
'not null' => FALSE,
'default' => '',
),
'hydrocode' => array(
'description' => 'Text field to associate with external data source.',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'description' => array(
'description' => 'Text for storing detailed descriptions of hydrogeologic units.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => '',
),
) + entity_exportable_schema_fields(),
'primary key' => array('hydroid'),
'indexes' => array(
'dh_hgu_hiix' => array('hydroid'),
'dh_hgu_hgix' => array('hgucode'),
'dh_hgu_aqix' => array('aqcode'),
)
);
//
$schema['dh_boreholelog_type'] = array (
'description' => 'Base Feature class in dh (ArcHydro: Feature)',
'fields' => array(
'bhltid' => array(
'description' => 'Primary key for Borehole Types',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'name' => array(
'description' => 'Borehole Type Descriptive Name (Well Interval, etc.)',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'bundle' => array(
'description' => 'Feature Type / Bundle (well_interval, ...)',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'description' => array(
'description' => 'Description of this Borehole Class',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
) + entity_exportable_schema_fields(),
'primary key' => array('bhltid'),
'indexes' => array(
'dh_fet_fix' => array('bhltid'),
'dh_fet_ftix' => array('bundle')
)
);
// Table Desc for: BoreholeLog
// Relationships: WellID, HGUID, logtype
$schema['dh_boreholelog'] = array (
'description' => 'Borehole Log in dh (ArcHydro: BoreholeLog)',
'fields' => array(
'bhlid' => array(
'description' => 'Primary key for Variables',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'bundle' => array(
'description' => 'Bundle (Base class well_interval, ...)',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => 'dh_boreholelog',
),
'fromdepth' => array(
'description' => 'The top elevation of an interval measured as depth along the borehole.',
'type' => 'float',
'not null' => FALSE,
),
'todepth' => array(
'description' => 'The bottom elevation of an interval measured as depth along the borehole.',
'type' => 'float',
'not null' => FALSE,
),
'topelev' => array(
'description' => 'Top elevation of an interval represented in absolute elevation units (e.g., feet above mean sea level).',
'type' => 'float',
'not null' => FALSE,
),
'bottomelev' => array(
'description' => 'Bottom elevation of an interval represented in absolute elevation units (e.g., feet above mean sea level).',
'type' => 'float',
'not null' => FALSE,
),
'refelev' => array(
'description' => 'Reference Elevation',
'type' => 'float',
'not null' => FALSE,
),
'material' => array(
'description' => 'Description of strata observed along a borehole. Usually documented in drilling logs and later classified into geologic/hydrogeologic units.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => '',
),
'hgucode' => array(
'description' => 'Hydrogeologic unit code. Text for classifying, symbolizing, and labeling hydrogeologic units. (External)',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => '',
),
'hguid' => array(
'description' => 'Link to ID column of table geologic/hydrogeologic units.',
'type' => 'int',
'size' => 'big',
'not null' => FALSE,
),
'logtype' => array(
'description' => 'Distinguishes between types of borehole logs (e.g., well completion, hydrostratigraphy).',
'type' => 'int',
'size' => 'big',
'not null' => FALSE,
),
'ftype' => array(
'description' => 'Feature Type (grout, screen, casing)',
'type' => 'varchar',
'length' => 64,
'not null' => FALSE,
'default' => '',
),
'diameter' => array(
'description' => 'Well diameter (in).',
'type' => 'float',
'not null' => FALSE,
),
'elevunits' => array(
'description' => 'Units of elevations stored in the TopElev and BottomElev attributes.',
'type' => 'varchar',
'length' => 32,
'not null' => FALSE,
'default' => '',
)
) + entity_exportable_schema_fields(),
'primary key' => array('bhlid'),
'indexes' => array(
'dh_bhl_bix' => array('bhlid'),
)
);
// this table may be no longer used in favor of the "VariableDefinition" tablE
// even though this provides a richer set of information and could be useful?
$schema['dh_tstype'] = array (
'description' => 'Data Dictionary for Variables in dh (ArcHydro: TSTYPE)',
'fields' => array(
'tstypeid' => array(
'description' => 'Primary key for Variables',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'variable' => array(
'description' => 'Variable Name',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
),
'units' => array(
'description' => 'Unit of Measure',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'isregular' => array(
'description' => 'Is Regular?',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 1,
),
'tsinterval' => array(
'description' => 'Interval Type',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'size' => 'tiny',
'not null' => TRUE,
),
'datatype' => array(
'description' => 'Data Type (ArcHydro: TSDataType)',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'size' => 'tiny',
'not null' => TRUE,
),
'origin' => array(
'description' => 'Origin (ArcHydro: TSOrigins (1 = Recorded, 2 = Generated)',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'size' => 'tiny',
'not null' => TRUE,
)
) + entity_exportable_schema_fields(),
'primary key' => array('tstypeid'),
'indexes' => array(
'dh_tst_tstix' => array('tstypeid'),
'dh_tst_vix' => array('variable')
)
);
// VariableDefinition
// Extra Fields:
// Vocabulary Text Name of the list of variables in which a particular VarCode is defined (e.g., USGS NWIS).
// need to do this as a reference, not a text field
// Medium Text Medium in which the variable is observed or occurs (e.g., "Groundwater“)-
$schema['dh_variabledefinition'] = array (
'description' => 'Data Dictionary for Variables in dh (ArcHydro: TSTYPE)',
'fields' => array(
'hydroid' => array(
'description' => 'Primary key for Variables',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'varname' => array(
'description' => 'The name of the variable.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
),
'vardesc' => array(
'description' => 'The description of the variable.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'vocabulary' => array(
'description' => 'Name of the list of variables in which a particular VarCode is defined (e.g., USGS NWIS).',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'varunits' => array(
'description' => 'Units of measure for the variable.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'varkey' => array(
'description' => 'Unique text ID for a variable, used when a variable is indexed in an attribute series table via field names.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'multiplicity' => array(
'description' => 'How to handle multiples - default tstime for timeseries, name for properties.',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'varabbrev' => array(
'description' => 'Abbreviation for use in small format displays.',
'type' => 'varchar',
'length' => 32,
'not null' => FALSE,
'default' => '',
),
'datatype' => array(
'description' => 'Describes whether the time series contains instantaneous measurements, cumulative values, etc.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'data_entry' => array(
'description' => 'Describes which form fields to show and their format, comma delimited options: numeric,text,boolean,index,date_start, date_end.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => '',
),
'varcode' => array(
'description' => 'Public identifier for a variable (e.g., "00060" for discharge in USGS NWIS).',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'isregular' => array(
'description' => 'Integer field that stores 1 (TRUE) if the time series values are regularly spaced in time, or 0 (FALSE) if the time series is irregular.',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'size' => 'tiny',
'not null' => TRUE,
),
'timestep' => array(
'description' => 'For regular time series, the number of TimeUnits between each occurrence of a time series value.',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'size' => 'big',
'not null' => TRUE,
),
'timeunits' => array(
'description' => 'For regular time series, the time unit used to describe the length of time between occurrences of a time series value.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'nodataval' => array(
'description' => 'Numerical value used to indicate a "No Data Value" (e.g., a missing value) in the time series table.',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'size' => 'big',
'not null' => TRUE,
),
'plugin' => array(
'description' => 'Plugin (different bundles may have multiple plugin options)',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => 'dHVariablePluginDefault',
),
'options' => array(
'description' => 'The options for this source (option settings vary by source type).',
'type' => 'text',
'serialize' => TRUE,
),
) + entity_exportable_schema_fields(),
'primary key' => array('hydroid'),
'indexes' => array(
'dh_vd_vix' => array('hydroid'),
'dh_vd_vnix' => array('varname'),
'dh_vd_vkix' => array('varkey'),
)
);
// Table Desc for: TimeSeries
// Relationships: FeatureID (dh_feature:hydroid)
// these relationships can be kept on table, and use custom Views settings to connect?
// the only difficulty is populating them for new entries from forms, but that is workable?
$schema['dh_timeseries'] = array (
'description' => 'Time Series Data in dh (ArcHydro: timeseries)',
'fields' => array(
'tid' => array(
'description' => 'Primary key for Variables',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'tstime' => array(
'description' => 'Timestamp for monitored value.',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'size' => 'big',
),
'utcoffset' => array(
'description' => 'UTC Offset for timestamp.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'big',
),
'tscode' => array(
'description' => 'Short text fragment value.',
'type' => 'varchar',
'length' => 32,
'not null' => FALSE,
'default' => NULL,
),
'tsvalue' => array(
'description' => 'The numerical value itself.',
'type' => 'float',
'not null' => FALSE,
'default' => NULL,
),
'tsendtime' => array(
'description' => 'Timestamp for end time value.',
'type' => 'int',
'not null' => FALSE,
'default' => 1,
'size' => 'big',
),
'entity_type' => array(
'description' => 'Entity Type (default: dh_feature)',
'type' => 'varchar',
'length' => 64,
'not null' => FALSE,
'default' => 'dh_feature',
),
// 'bundle' => array(
// 'description' => 'Bundle (TimeSeries Class type)',
// 'type' => 'varchar',
// 'length' => 64,
// 'not null' => FALSE,
// 'default' => 'dh_timeseries',
//` ),
'featureid' => array(
'description' => 'Unique numerical identifier of a feature within the geodatabase. Usually, the FeatureID of a TimeSeries record is equal to the HydroID of a feature (e.g., well, monitoring point).',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'size' => 'big',
'not null' => TRUE,
),
'varid' => array(
'description' => 'Unique numerical identifier of a variable within the geodatabase. Variables are defined in the VariableDefinition table.',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'size' => 'big',
'not null' => TRUE,
),
'timeline' => array(
'description' => 'TimeLine ID, 1 is historical record, >1 alternative timelines/scenariod',
'type' => 'int',
'size' => 'tiny',
'not null' => FALSE,
'default' => 1,
),
'modified' => array(
'description' => 'Timestamp for last modified.',
'type' => 'int',
'not null' => FALSE,
'size' => 'big',
),
'uid' => array(
'description' => 'Record Owner',
'type' => 'int',
'not null' => FALSE,
'size' => 'big',
),
) + entity_exportable_schema_fields(),
'primary key' => array('tid'),
'indexes' => array(
'dh_ts_tix' => array('tid'),
'dh_ts_fix' => array('featureid'),
'dh_ts_vix' => array('varid'),
'dh_ts_tstix' => array('tstime'),
'dh_ts_tlix' => array('timeline'),
)
);
// Table Desc for: Properties
$schema['dh_properties_type'] = array (
'description' => 'Base Feature class in dh (ArcHydro: Feature)',
'fields' => array(
'ptid' => array(
'description' => 'Primary key for Property Types',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'name' => array(
'description' => 'Type Descriptive Name (Well Interval, etc.)',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'bundle' => array(
'description' => 'Feature Type / Bundle (dh_properties, stream_channel, ...)',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'description' => array(
'description' => 'Description of this Borehole Class',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
) + entity_exportable_schema_fields(),
'primary key' => array('ptid'),
'indexes' => array(
'dh_pt_ptix' => array('ptid'),
'dh_pt_bix' => array('bundle')
)
);
// Custom extension to dH for storing non-temporal or semi-static parameters
// Relationships: FeatureID (dh_feature:hydroid)
$schema['dh_properties'] = array (
'description' => 'Properties table in dh',
'fields' => array(
'pid' => array(
'description' => 'Primary key for Variables',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'propname' => array(
'description' => 'The numerical value itself.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'propvalue' => array(
'description' => 'The numerical value itself.',
'type' => 'numeric',
'not null' => FALSE,
),
'propcode' => array(
'description' => 'Short text fragment value.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => NULL,
),
'startdate' => array(
'description' => 'Start Date',
'type' => 'int',
'not null' => FALSE,
'size' => 'big',
),
'enddate' => array(
'description' => 'End Date',
'type' => 'int',
'not null' => FALSE,
'size' => 'big',
),
'featureid' => array(
'description' => 'Unique numerical identifier of a feature within the geodatabase. Usually, the FeatureID of a TimeSeries record is equal to the HydroID of a feature (e.g., well, monitoring point).',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'size' => 'big',
'not null' => TRUE,
),
'modified' => array(
'description' => 'Timestamp for last modified.',
'type' => 'int',
'not null' => FALSE,
'size' => 'big',
),
// not ready to implement just yet
'entity_type' => array(
'description' => 'Entity Type (default: dh_feature)',
'type' => 'varchar',
'length' => 64,
'not null' => FALSE,
'default' => 'dh_feature',
),
'bundle' => array(
'description' => 'Bundle (Base Property Class property)',
'type' => 'varchar',
'length' => 64,
'not null' => FALSE,
'default' => 'dh_properties',
),
'varid' => array(
'description' => 'Unique numerical identifier of a variable within the geodatabase. Variables are defined in the VariableDefinition table.',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'size' => 'big',
'not null' => TRUE,
),
'uid' => array(
'description' => 'Record Owner',
'type' => 'int',
'not null' => FALSE,
'size' => 'big',
),
'vid' => array(
'description' => 'The current {dh_properties}.vid version identifier.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => NULL,
),
) + entity_exportable_schema_fields(),
'primary key' => array('pid'),
'indexes' => array(
'dh_ps_tix' => array('pid'),
'dh_ps_pnix' => array('propname'),
'dh_ps_fix' => array('featureid'),
'dh_ps_vix' => array('varid'),
)
);
// Custom extension to dH for storing non-temporal or semi-static parameters
// Relationships: FeatureID (dh_feature:hydroid)
$schema['dh_properties_revision'] = array (
'description' => 'Properties table in dh',
'fields' => array(
'vid' => array(
'description' => 'The current {dh_properties}.vid version identifier.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'pid' => array(
'description' => 'Primary key for Properties',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'propname' => array(
'description' => 'The numerical value itself.',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'propcode' => array(
'description' => 'Short text fragment value.',
'type' => 'varchar',
'length' => 32,
'not null' => FALSE,
'default' => NULL,
),
'propvalue' => array(
'description' => 'The numerical value itself.',
'type' => 'numeric',
'not null' => FALSE,
),
'startdate' => array(
'description' => 'Start Date',
'type' => 'int',
'not null' => FALSE,
'size' => 'big',
),
'enddate' => array(
'description' => 'End Date',
'type' => 'int',
'not null' => FALSE,
'size' => 'big',
),
'featureid' => array(
'description' => 'Unique numerical identifier of a feature within the geodatabase. Usually, the FeatureID of a TimeSeries record is equal to the HydroID of a feature (e.g., well, monitoring point).',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'size' => 'big',
'not null' => TRUE,
),
// not ready to implement just yet
'entity_type' => array(
'description' => 'Entity Type (default: dh_feature)',
'type' => 'varchar',
'length' => 64,
'not null' => FALSE,
'default' => 'dh_feature',
),
'bundle' => array(
'description' => 'Bundle (Base Property Class property)',
'type' => 'varchar',
'length' => 64,
'not null' => FALSE,
'default' => 'dh_properties',
),
'varid' => array(
'description' => 'Unique numerical identifier of a variable within the geodatabase. Variables are defined in the VariableDefinition table.',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'size' => 'big',
'not null' => TRUE,
),
'uid' => array(
'description' => 'Record Owner',
'type' => 'int',
'not null' => FALSE,
'size' => 'big',
),
) + entity_exportable_schema_fields(),
'primary key' => array('vid'),
'indexes' => array(
'dh_psr_rvix' => array('vid'),
'dh_ps_pnix' => array('propname'),
'dh_psr_tix' => array('pid'),
'dh_psr_fix' => array('featureid'),
'dh_psr_vix' => array('varid'),
)
);
return $schema;
}
function dh_uninstall() {
$fields = array('dh_geofield', 'wellid', 'hguid', 'dh_welldepth', 'dh_landelev', 'dh_lengthkm', 'dh_usgs_site_no', 'dh_areasqkm', 'dh_fips', 'proptext', 'aquiferid');
foreach ($fields as $field) {
drupal_set_message("Removing field '$field'");
$numd = 0;
while (!(field_info_field($field) === NULL)) {
field_delete_field($field);
$numd++;
if ($numd < 10) {
drupal_set_message("Loop detected - exiting");
break;
}
}
drupal_set_message("Deleted $numd fields");
}
}
function dh_install() {
// set links to sequence for non-feature tables that
// need a global hydroid
// note that we use the Drupal "{tablename}" to allow
// Drupal to add a prefix to our table name if the install
// is using prefixes (allows for multisite)
// but when we do the alter table, this may fail
// with prefixes because the prefix is probably also
// added to the sequence name dh_feature_hydroid_seq
// may need to process that also (not sure how)
//$hydroid_tables = array('dh_hydrogeologicunit');
$hydroid_tables = array();
foreach ($hydroid_tables as $thistable) {
if (db_table_exists($thistable)) {
db_query("alter table {$thistable} alter column hydroid set default nextval('dh_feature_hydroid_seq'::regclass)");
}
}
// add geometry columns to all feature classes
dh_addGeometry('dh_feature');
dh_add_bundles();
dh_add_references();
dh_boreholelog_add_bundles();
dh_properties_add_bundles();
dh_initialize_fields('dh_properties', 'proptext', 'dh_properties');
}
function dh_add_bundles() {
$typedefs = dh_define_bundles();
foreach ($typedefs as $key => $thistype) {
dh_base_feature_type_save($thistype);
dh_initialize_fields($key);
}
}
function dh_boreholelog_add_bundles() {
$bhl_types = dh_define_boreholelog_bundles();
foreach ($bhl_types as $thistype) {
if ($e = entity_create('dh_boreholelog_type', $thistype)) {
$e->save();
}
}
}
function dh_define_boreholelog_bundles() {
$typedefs = array(
'dh_boreholelog' => array('bundle' => 'dh_boreholelog', 'name' => 'Default Borehole Log Type', 'description' => 'dH Basic Borehole Interval'),
'well_interval' => array('bundle' => 'well_interval', 'name' => 'Well Interval', 'description' => 'dH Basic Groundwater Well Interval'),
);
return $typedefs;
}
function dh_properties_add_bundles() {
$bhl_types = dh_define_properties_bundles();
foreach ($bhl_types as $thistype) {
if ($e = entity_create('dh_properties_type', $thistype)) {
$e->save();
}
}
}
function dh_define_properties_bundles() {
$typedefs = array(
'dh_properties' => array('bundle' => 'dh_properties', 'name' => 'Default Properties Type', 'description' => 'dH Properties Default'),
);
return $typedefs;
}
function dh_define_bundles() {
$typedefs = array(
'well' => array('bundle' => 'well', 'name' => 'Well', 'description' => 'dH Basic Groundwater Well Feature'),
'intake' => array('bundle' => 'intake', 'name' => 'Surface Water Intake', 'description' => 'dH Basic Surface Water Intake Feature'),
'aquifer' => array('bundle' => 'aquifer', 'name' => 'Aquifer', 'description' => 'dH Basic Aquifer Feature'),
'monitoringpoint' => array('bundle' => 'monitoringpoint', 'name' => 'MonitoringPoint', 'description' => 'dH Basic Monitoring Point Feature'),
'waterpoint' => array('bundle' => 'waterpoint', 'name' => 'WaterPoint', 'description' => 'dH Basic Water Point Feature'),
'waterline' => array('bundle' => 'waterline', 'name' => 'WaterLine', 'description' => 'dH Basic Water Line Feature'),
'waterbody' => array('bundle' => 'waterbody', 'name' => 'WaterBody', 'description' => 'dH Basic Water Body Feature'),
'watershed' => array('bundle' => 'watershed', 'name' => 'Watershed', 'description' => 'dH Basic Watershed Feature'),
'borepoint' => array('bundle' => 'borepoint', 'name' => 'BorePoint', 'description' => 'dH Basic Borepoint Feature'),
'boreline' => array('bundle' => 'boreline', 'name' => 'BoreLine', 'description' => 'dH Basic Boreline Feature'),
'usgsgage' => array('bundle' => 'usgsgage', 'name' => 'USGSGage', 'description' => 'dH Basic USGS Gage Feature'),
'usafips' => array('bundle' => 'usafips', 'name' => 'USAFips', 'description' => 'dH USA FIPS Political Boundaries'),
'landunit' => array('bundle' => 'landunit', 'name' => 'Land Unit', 'description' => 'dH Land Unit'),
);
return $typedefs;
}
function dh_base_feature_type_save($info) {
// set the base dh_feature_type entries
// modeled after node_type_save
$existing_type = !empty($info['old_bundle']) ? $info['old_bundle'] : $info['bundle'];
$is_existing = (bool) db_query_range('SELECT 1 FROM {dh_feature_type} WHERE bundle = :bundle', 0, 1, array(':bundle' => $existing_type))->fetchField();
$fields = array(
'bundle' => $info['bundle'],
'name' => $info['name'],
'description' => $info['description'],
);
if ($is_existing) {
db_update('dh_feature_type')
->fields($fields)
->condition('bundle', $existing_type)
->execute();
if (!empty($info['old_bundle']) && $info['old_bundle'] != $info['bundle']) {
field_attach_rename_bundle('dh_feature', $info['old_bundle'], $info['bundle']);
}
// need equivalent?
//module_invoke_all('node_type_update', $type);
$status = SAVED_UPDATED;
}
else {
db_insert('dh_feature_type')
->fields($fields)
->execute();
field_attach_create_bundle('dh_feature', $info['bundle']);
$status = SAVED_NEW;
}
// Clear the node type cache.
// hmmm ... do we need to supply an equivalent to this?
// node_type_cache_reset();
dh_feature_type_cache_reset();
return $status;
}
function dh_initialize_fields($type, $field = '', $entity = 'dh_feature', $fields_fields = array(), $debug = 0) {
$base_instance = array(
'field_name' => 'welldepth',
'entity_type' => $entity,
'bundle' => 'well',
'label' => 'Well Depth',
'settings' => array(
),
'widget' => array(
'type' => 'number',
'settings' => array('size' => 60),
),
'display' => array(
'full' => array(
'type' => 'text_default',
),
),
);
if (count($fields_fields) > 0) {
$extra_fields = $fields_fields;