@@ -60,6 +60,9 @@ var Blocks = function(errorHandler = null, openParameterEditor = null, openSchem
60
60
// Blocks types
61
61
this . moduleTypes = { } ;
62
62
63
+ // Collection default values
64
+ this . collectionDefaults = { } ;
65
+
63
66
// Instances
64
67
this . blocks = { } ;
65
68
@@ -302,7 +305,13 @@ Blocks.prototype.getPositionForPageXY = function(x, y) {
302
305
*/
303
306
Blocks . prototype . addCollection = function ( name , x = null , y = null )
304
307
{
305
- return this . addBlock ( 'load_collection' , 'process' , x , y , { id : name , spatial_extent : null , temporal_extent : null } ) ;
308
+ var spatialExtent = null ;
309
+ var temporalExtent = null ;
310
+ if ( typeof this . collectionDefaults [ name ] === 'object' ) {
311
+ spatialExtent = this . collectionDefaults [ name ] . spatialExtent ;
312
+ temporalExtent = this . collectionDefaults [ name ] . temporalExtent ;
313
+ }
314
+ return this . addBlock ( 'load_collection' , 'process' , x , y , { id : name , spatial_extent : spatialExtent , temporal_extent : temporalExtent } ) ;
306
315
} ;
307
316
308
317
Blocks . prototype . addProcess = function ( name , x = null , y = null )
@@ -343,6 +352,10 @@ Blocks.prototype.addBlock = function(name, type, x, y, values = {})
343
352
return block ;
344
353
} ;
345
354
355
+ Blocks . prototype . unregisterCollectionDefaults = function ( ) {
356
+ this . collectionDefaults = { } ;
357
+ }
358
+
346
359
Blocks . prototype . unregisterProcesses = function ( ) {
347
360
this . moduleTypes [ 'process' ] = { } ;
348
361
}
@@ -351,6 +364,23 @@ Blocks.prototype.unregisterCallbackArguments = function() {
351
364
this . moduleTypes [ 'callback-arguments' ] = { } ;
352
365
}
353
366
367
+ Blocks . prototype . registerCollectionDefaults = function ( collection ) {
368
+ try {
369
+ var hasZ = collection . extent . spatial . length > 4 ;
370
+ this . collectionDefaults [ collection . id ] = {
371
+ spatialExtent : {
372
+ west : collection . extent . spatial [ 0 ] ,
373
+ east : collection . extent . spatial [ hasZ ? 3 : 2 ] ,
374
+ south : collection . extent . spatial [ 1 ] ,
375
+ north : collection . extent . spatial [ hasZ ? 4 : 3 ]
376
+ } ,
377
+ temporalExtent : collection . extent . temporal
378
+ } ;
379
+ } catch ( error ) {
380
+ console . log ( error ) ;
381
+ }
382
+ } ;
383
+
354
384
/**
355
385
* Registers a new block type
356
386
*/
0 commit comments