2
2
import logging
3
3
import urllib .request
4
4
5
- CONSTANTS = {
6
- "output_formats" : [
7
- {"id" : 1 , "label" : "GeoTIFF" , "active" : True , "display_order" : 1 , "default" : True , "extension" : "tif" },
8
- {"id" : 2 , "label" : "PNG" , "active" : False , "display_order" : 4 , "default" : False , "extension" : "png" },
9
- {"id" : 3 , "label" : "BMP" , "active" : False , "display_order" : 3 , "default" : False , "extension" : "bmp" },
10
- {"id" : 4 , "label" : "ENVI (hdr)" , "active" : False , "display_order" : 2 , "default" : False , "extension" : "bil" },
11
- {"id" : 5 , "label" : "XML" , "active" : False , "display_order" : 999 , "default" : False , "extension" : "xml" }
12
- ],
13
- "dem_resamplings" : [
14
- {"id" : 1 , "label" : "Nearest Neighbour" , "active" : True , "display_order" : 1 , "default" : False },
15
- {"id" : 2 , "label" : "Bilinear Interpolation" , "active" : True , "display_order" : 2 , "default" : True },
16
- {"id" : 3 , "label" : "Cubic Convolution" , "active" : True , "display_order" : 3 , "default" : False },
17
- {"id" : 4 , "label" : "Bi-Sinc Interpolation" , "active" : True , "display_order" : 4 , "default" : False },
18
- {"id" : 5 , "label" : "Bi-Cubic Interpolation" , "active" : True , "display_order" : 5 , "default" : False }
19
- ],
20
- "resampling_methods" : [
21
- {"id" : 1 , "label" : "Nearest Neighbour" , "active" : True , "display_order" : 1 , "default" : False , "gamma_code" : "0" },
22
- {"id" : 2 , "label" : "Bi-cubic" , "active" : True , "display_order" : 3 , "default" : True , "gamma_code" : "1" },
23
- {"id" : 3 , "label" : "Bi-linear" , "active" : True , "display_order" : 2 , "default" : False , "gamma_code" : "3" },
24
- {"id" : 4 , "label" : "Bi-cubic of log" , "active" : False , "display_order" : 999 , "default" : False , "gamma_code" : "2" },
25
- ],
26
- "dems" : [
27
- {"id" : 1 , "label" : "CDEM" , "active" : True , "display_order" : 1 },
28
- {"id" : 2 , "label" : "CDSM (CDEM+SRTM)" , "active" : True , "display_order" : 2 },
29
- {"id" : 3 , "label" : "SRTM 30m (Canada)" , "active" : True , "display_order" : 3 },
30
- {"id" : 4 , "label" : "SRTM 90m (World)" , "active" : True , "display_order" : 4 },
31
- {"id" : 5 , "label" : "Fixed Elevation - 0 meter at Mean Sea Level" , "active" : False , "display_order" : 5 },
32
- {"id" : 6 , "label" : "ASTER 30m (World)" , "active" : True , "display_order" : 6 },
33
- {"id" : 7 , "label" : "SRTM 30m (World)" , "active" : True , "display_order" : 5 },
34
- {"id" : 8 , "label" : "EQUI7 Basemap (NA)" , "active" : False , "display_order" : 8 }
35
- ],
36
- "projections" : [
37
- {"id" : 1 , "label" : "UTM (auto) / NAD83 (CSRS)" , "active" : True , "display_order" : 1 },
38
- {"id" : 2 , "label" : "UTM (auto) / WGS84" , "active" : True , "display_order" : 2 },
39
- {"id" : 3 , "label" : "UTM (auto) / NAD27" , "active" : False , "display_order" : 3 },
40
- {"id" : 4 , "label" : "UTM / NAD83 (CSRS)" , "active" : True , "display_order" : 4 },
41
- {"id" : 5 , "label" : "UTM / WGS84" , "active" : True , "display_order" : 5 },
42
- {"id" : 6 , "label" : "UTM / NAD27" , "active" : False , "display_order" : 6 },
43
- {"id" : 7 , "label" : "Geographic / WGS84" , "active" : False , "display_order" : 7 },
44
- {"id" : 9 , "label" : "Canada Atlas Lambert / NAD83 (EPSG:3978)" , "active" : True , "display_order" : 10 },
45
- {"id" : 11 , "label" : "Canada Albers Equal Area / NAD83 (EPSG:102001)" , "active" : True , "display_order" : 13 },
46
- {"id" : 12 , "label" : "Polar Stereographic - North / WGS84" , "active" : False , "display_order" : 16 },
47
- {"id" : 13 , "label" : "Polar Stereographic - South / WGS84" , "active" : False , "display_order" : 17 },
48
- {"id" : 14 , "label" : "Geographic / NAD83 (CSRS)" , "active" : False , "display_order" : 8 },
49
- {"id" : 15 , "label" : "Geographic / NAD27" , "active" : False , "display_order" : 9 },
50
- {"id" : 16 , "label" : "Canada Crop Inventory Albers Equal Area / WGS84 " , "active" : True , "display_order" : 14 },
51
- {"id" : 17 , "label" : "NSIDC Sea Ice Polar Stereographic North / WGS84" , "active" : True , "display_order" : 15 },
52
- {"id" : 18 , "label" : "NSIDC EASE-Grid 2.0 North / WGS84" , "active" : True , "display_order" : 16 },
53
- {"id" : 19 , "label" : "Canada Atlas Lambert / NAD83 (CSRS) (EPSG:3979)" , "active" : False , "display_order" : 11 }
54
- ],
55
- "ortho_methods" : [
56
- {"id" : 1 , "label" : "Rational Function" , "active" : True , "display_order" : 1 },
57
- {"id" : 2 , "label" : "Range Doppler" , "active" : False , "display_order" : 2 }
58
- ],
59
- "mosaic_overlap_modes" : [
60
- {"id" : 1 , "label" : "Average valid inputs" , "active" : False , "display_order" : 3 , "default" : False },
61
- {"id" : 2 , "label" : "First image preferred" , "active" : False , "display_order" : 2 , "default" : False },
62
- {"id" : 3 , "label" : "Last image preferred" , "active" : True , "display_order" : 1 , "default" : True }
63
- ],
64
- "weighting_types" : [
65
- {"id" : 0 , "label" : "Constant" , "active" : True , "display_order" : 1 , "default" : True },
66
- {"id" : 1 , "label" : "Linear" , "active" : True , "display_order" : 2 , "default" : False },
67
- {"id" : 2 , "label" : "Gaussian" , "active" : True , "display_order" : 3 , "default" : False }
68
- ],
69
- "angle_units" : [
70
- {'id' : 1 , 'label' : 'Degree' , 'active' : True , 'display_order' : 1 , 'default' : True },
71
- {'id' : 2 , 'label' : 'Radian' , 'active' : True , 'display_order' : 2 , 'default' : False }
72
- ],
73
- "gd_spat_avgs" : [
74
- {'id' : 1 , 'label' : 'x1' , 'active' : True , 'display_order' : 1 , 'default' : False , 'multilooking_value' : 1 },
75
- {'id' : 2 , 'label' : 'x2' , 'active' : True , 'display_order' : 2 , 'default' : False , 'multilooking_value' : 2 },
76
- {'id' : 3 , 'label' : 'x4' , 'active' : True , 'display_order' : 3 , 'default' : True , 'multilooking_value' : 4 },
77
- {'id' : 4 , 'label' : 'x8' , 'active' : True , 'display_order' : 4 , 'default' : False , 'multilooking_value' : 8 }
78
- ],
79
- "vlg_spat_avgs" : [
80
- {'id' : 1 , 'label' : 'x8' , 'active' : True , 'display_order' : 1 , 'default' : False , 'multilooking_value' : 8 },
81
- {'id' : 2 , 'label' : 'x16 (recommended)' , 'active' : True , 'display_order' : 2 , 'default' : True , 'multilooking_value' : 16 },
82
- {'id' : 3 , 'label' : 'x32' , 'active' : True , 'display_order' : 3 , 'default' : False , 'multilooking_value' : 32 },
83
- {'id' : 4 , 'label' : 'x64' , 'active' : True , 'display_order' : 4 , 'default' : False , 'multilooking_value' : 64 }
84
- ],
85
- "polarizations" : [
86
- {'id' : 1 , 'label' : 'All available' , 'uid_name' : 'AllPol' , 'active' : True , 'display_order' : 1 , 'default' : True },
87
- {'id' : 2 , 'label' : 'CH' , 'uid_name' : 'CHPol' , 'active' : True , 'display_order' : 2 , 'default' : False },
88
- {'id' : 3 , 'label' : 'CV' , 'uid_name' : 'CVPol' , 'active' : True , 'display_order' : 3 , 'default' : False },
89
- {'id' : 4 , 'label' : 'HH' , 'uid_name' : 'HHPol' , 'active' : True , 'display_order' : 4 , 'default' : False },
90
- {'id' : 5 , 'label' : 'HV' , 'uid_name' : 'HVPol' , 'active' : True , 'display_order' : 5 , 'default' : False },
91
- {'id' : 6 , 'label' : 'VV' , 'uid_name' : 'VVPol' , 'active' : True , 'display_order' : 6 , 'default' : False },
92
- {'id' : 7 , 'label' : 'VH' , 'uid_name' : 'VHPol' , 'active' : True , 'display_order' : 7 , 'default' : False }
93
- ],
94
- "units" : [
95
- {'id' : 1 , 'label' : 'Meters' , 'active' : True , 'display_order' : 1 , 'default' : True },
96
- {'id' : 2 , 'label' : 'Degrees' , 'active' : True , 'display_order' : 2 , 'default' : False }
97
- ]
98
- }
99
-
100
5
def create_table_row (row , col_lens , centre = False ):
101
6
"""
102
7
Creates a table row.
@@ -228,7 +133,8 @@ def get_name(self):
228
133
229
134
class Parameter :
230
135
231
- def __init__ (self , param_info , multiple = False ):
136
+ def __init__ (self , st , param_info , multiple = False ):
137
+ self .st = st
232
138
self .param_id = param_info .get ('param_id' )
233
139
self .label = param_info .get ('label' )
234
140
self .data_type = param_info .get ('data_type' )
@@ -267,11 +173,11 @@ def __init__(self, param_info, multiple=False):
267
173
if in_subs :
268
174
self .sub_params = list ()
269
175
for param in in_subs :
270
- self .sub_params .append (Parameter (param ))
176
+ self .sub_params .append (Parameter (self . st , param ))
271
177
272
178
# print(f"self.param_id: {self.param_id}")
273
179
# print(f"self.constants_key: {self.constants_key}")
274
- self .const_vals = CONSTANTS .get (self .constants_key )
180
+ self .const_vals = self . st . constants .get (self .constants_key )
275
181
# print(f"self.const_vals: {self.const_vals}")
276
182
277
183
if self .const_vals and not self .default :
@@ -728,7 +634,7 @@ def __init__(self, eod, record_ids=None, out_fn=None):
728
634
# self.record_ids = rec_ids.split('|')
729
635
self .record_ids = record_ids
730
636
731
- # self.constants = None
637
+ self .constants = self . schema_json . get ( 'constants' )
732
638
self .out_fn = out_fn
733
639
self .full_request = None
734
640
@@ -743,7 +649,7 @@ def __init__(self, eod, record_ids=None, out_fn=None):
743
649
"data_type" : "list" ,
744
650
"constants_key" : "polarizations" ,
745
651
}
746
- self .polarization = Parameter (param_info , multiple = True )
652
+ self .polarization = Parameter (self , param_info , multiple = True )
747
653
748
654
self .logger = logging .getLogger ('eodms' )
749
655
@@ -826,7 +732,7 @@ def get_constants(self, const_key, include_inactive=False):
826
732
827
733
out_lst = list ()
828
734
829
- const_vals = CONSTANTS .get (const_key )
735
+ const_vals = self . constants .get (const_key )
830
736
const_vals = sorted (const_vals , key = lambda d : d ['display_order' ])
831
737
832
738
for c in const_vals :
@@ -950,7 +856,7 @@ def get_request(self):
950
856
951
857
pols = self .polarization .value
952
858
pol_uid = [pol .get ('uid_name' )
953
- for pol in CONSTANTS .get ('polarizations' )
859
+ for pol in self . constants .get ('polarizations' )
954
860
if pol .get ('label' ) in pols ]
955
861
for p in pol_uid :
956
862
vap_request [p ] = "on"
@@ -1084,7 +990,7 @@ def _add_categories(self):
1084
990
if param .get ('param_id' ) == 'LabelName' :
1085
991
param ['default' ] = f"My { method_name } "
1086
992
1087
- params .append (Parameter (param ))
993
+ params .append (Parameter (self , param ))
1088
994
1089
995
products = list ()
1090
996
if method .get ('products' ):
0 commit comments