@@ -37,6 +37,9 @@ import {
3737 extractSpatialPartition ,
3838 ConfirmationComponent ,
3939 geoengineValidators ,
40+ spatialPartitionFromSpatialGridDefinition ,
41+ spatialGridDefinitionFromSpatialPartitionAndGeoTransform ,
42+ Coordinate2D ,
4043} from '@geoengine/common' ;
4144import moment from 'moment' ;
4245import {
@@ -50,6 +53,8 @@ import {
5053 RasterBandDescriptor ,
5154 RasterDataType ,
5255 RasterResultDescriptor ,
56+ SpatialPartition2D ,
57+ GeoTransform as GeoTransformDict ,
5358} from '@geoengine/openapi-client' ;
5459import { MatSnackBar } from '@angular/material/snack-bar' ;
5560import { MatFormField , MatLabel , MatInput , MatError } from '@angular/material/input' ;
@@ -88,6 +93,26 @@ export interface RasterResultDescriptorForm {
8893 bands : FormControl < Array < RasterBandDescriptor > > ;
8994 dataType : FormControl < RasterDataType > ;
9095 spatialReference : FormControl < string > ;
96+ spatialGrid : FormGroup < SpatialGridDescriptorForm > ;
97+ }
98+
99+ export interface SpatialGridDescriptorForm {
100+ geoTransform : FormGroup < GeoTransformForm > ;
101+ gridBounds : FormGroup < GridBoundingBox2DForm > ;
102+ }
103+
104+ export interface GeoTransformForm {
105+ originX : FormControl < number > ;
106+ originY : FormControl < number > ;
107+ xPixelSize : FormControl < number > ;
108+ yPixelSize : FormControl < number > ;
109+ }
110+
111+ export interface GridBoundingBox2DForm {
112+ minX : FormControl < number > ;
113+ minY : FormControl < number > ;
114+ maxX : FormControl < number > ;
115+ maxY : FormControl < number > ;
91116}
92117
93118enum EditMode {
@@ -252,13 +277,13 @@ export class GdalMultiBandComponent implements OnChanges {
252277 async ngOnChanges ( changes : SimpleChanges ) : Promise < void > {
253278 const metaData = this . metaData ( ) ;
254279 if ( changes . metaData && metaData ) {
255- this . setUpFormFromMetaData ( metaData ) ;
280+ this . setUpFormFromResultDescriptor ( metaData . resultDescriptor ) ;
256281 }
257282
258283 this . setUpSource ( ) ;
259284 }
260285
261- async saveLoadingInfo ( ) : Promise < void > {
286+ async saveMetadata ( ) : Promise < void > {
262287 if ( this . form . invalid ) {
263288 return ;
264289 }
@@ -270,6 +295,7 @@ export class GdalMultiBandComponent implements OnChanges {
270295 this . snackBar . open ( 'Dataset loading information successfully updated.' , 'Close' , {
271296 duration : this . config . DEFAULTS . SNACKBAR_DURATION ,
272297 } ) ;
298+ this . form . markAsPristine ( ) ;
273299 } catch ( error ) {
274300 const errorMessage = await errorToText ( error , 'Updating dataset loading information failed.' ) ;
275301 this . snackBar . open ( errorMessage , 'Close' , { panelClass : [ 'error-snackbar' ] } ) ;
@@ -462,11 +488,36 @@ export class GdalMultiBandComponent implements OnChanges {
462488 getMetaData ( ) : MetaDataDefinition {
463489 const resultDescriptorControl = this . form . controls . rasterResultDescriptor . controls ;
464490
491+ const geoTransformControl = resultDescriptorControl . spatialGrid . controls . geoTransform . controls ;
492+ const geoTransform : GeoTransformDict = {
493+ originCoordinate : {
494+ x : geoTransformControl . originX . value ,
495+ y : geoTransformControl . originY . value ,
496+ } ,
497+ xPixelSize : geoTransformControl . xPixelSize . value ,
498+ yPixelSize : geoTransformControl . yPixelSize . value ,
499+ } ;
500+
501+ const spatialGridControl = resultDescriptorControl . spatialGrid . controls . gridBounds . controls ;
502+ const spatialPartition : SpatialPartition2D = {
503+ upperLeftCoordinate : {
504+ x : spatialGridControl . minX . value ,
505+ y : spatialGridControl . maxY . value ,
506+ } ,
507+ lowerRightCoordinate : {
508+ x : spatialGridControl . maxX . value ,
509+ y : spatialGridControl . minY . value ,
510+ } ,
511+ } ;
512+
465513 const resultDescriptor : RasterResultDescriptor = {
466514 bands : resultDescriptorControl . bands . value ,
467515 spatialReference : resultDescriptorControl . spatialReference . value ,
468516 dataType : resultDescriptorControl . dataType . value ,
469- spatialGrid : this . metaData ( ) . resultDescriptor . spatialGrid , // TODO: allow editing
517+ spatialGrid : {
518+ descriptor : 'source' ,
519+ spatialGrid : spatialGridDefinitionFromSpatialPartitionAndGeoTransform ( spatialPartition , geoTransform ) ,
520+ } ,
470521 time : {
471522 bounds : null ,
472523 dimension : {
@@ -506,7 +557,8 @@ export class GdalMultiBandComponent implements OnChanges {
506557 return ;
507558 }
508559
509- this . setResultDescriptor ( resultDescriptor ) ;
560+ this . setUpFormFromResultDescriptor ( resultDescriptor ) ;
561+ this . changeDetectorRef . markForCheck ( ) ;
510562 } catch ( error ) {
511563 const errorMessage = await errorToText ( error , 'Metadata suggestion failed.' ) ;
512564 this . snackBar . open ( errorMessage , 'Close' , { panelClass : [ 'error-snackbar' ] } ) ;
@@ -553,12 +605,6 @@ export class GdalMultiBandComponent implements OnChanges {
553605 }
554606 }
555607
556- setResultDescriptor ( resultDescriptor : RasterResultDescriptor ) : void {
557- this . form . controls . rasterResultDescriptor . controls . bands . setValue ( resultDescriptor . bands ) ;
558- this . form . controls . rasterResultDescriptor . controls . dataType . setValue ( resultDescriptor . dataType ) ;
559- this . form . controls . rasterResultDescriptor . controls . spatialReference . setValue ( resultDescriptor . spatialReference ) ;
560- }
561-
562608 protected calculateInitialNumberOfElements ( ) : number {
563609 const element = this . viewport ( ) . elementRef . nativeElement ;
564610 const numberOfElements = Math . ceil ( element . clientHeight / this . itemSizePx ) ;
@@ -590,21 +636,61 @@ export class GdalMultiBandComponent implements OnChanges {
590636 return [ gdalMetaDataList . resultDescriptor , gdalParams ] ;
591637 }
592638
593- private setUpFormFromMetaData ( metaData : GdalMultiBand ) : void {
639+ private setUpFormFromResultDescriptor ( resultDescriptor : RasterResultDescriptor ) : void {
640+ const spatialPartition = spatialPartitionFromSpatialGridDefinition ( resultDescriptor . spatialGrid . spatialGrid ) ;
641+
594642 this . form = new FormGroup < GdalMultiBandForm > ( {
595643 rasterResultDescriptor : new FormGroup < RasterResultDescriptorForm > ( {
596- bands : new FormControl ( metaData . resultDescriptor . bands , {
644+ bands : new FormControl ( resultDescriptor . bands , {
597645 nonNullable : true ,
598646 validators : [ Validators . required ] ,
599647 } ) ,
600- dataType : new FormControl ( metaData . resultDescriptor . dataType , {
648+ dataType : new FormControl ( resultDescriptor . dataType , {
601649 nonNullable : true ,
602650 validators : [ Validators . required ] ,
603651 } ) ,
604- spatialReference : new FormControl ( metaData . resultDescriptor . spatialReference , {
652+ spatialReference : new FormControl ( resultDescriptor . spatialReference , {
605653 nonNullable : true ,
606654 validators : [ Validators . required ] ,
607655 } ) ,
656+ spatialGrid : new FormGroup < SpatialGridDescriptorForm > ( {
657+ geoTransform : new FormGroup < GeoTransformForm > ( {
658+ originX : new FormControl ( resultDescriptor . spatialGrid . spatialGrid . geoTransform . originCoordinate . x , {
659+ nonNullable : true ,
660+ validators : [ Validators . required ] ,
661+ } ) ,
662+ originY : new FormControl ( resultDescriptor . spatialGrid . spatialGrid . geoTransform . originCoordinate . y , {
663+ nonNullable : true ,
664+ validators : [ Validators . required ] ,
665+ } ) ,
666+ xPixelSize : new FormControl ( resultDescriptor . spatialGrid . spatialGrid . geoTransform . xPixelSize , {
667+ nonNullable : true ,
668+ validators : [ Validators . required ] ,
669+ } ) ,
670+ yPixelSize : new FormControl ( resultDescriptor . spatialGrid . spatialGrid . geoTransform . yPixelSize , {
671+ nonNullable : true ,
672+ validators : [ Validators . required ] ,
673+ } ) ,
674+ } ) ,
675+ gridBounds : new FormGroup < GridBoundingBox2DForm > ( {
676+ minX : new FormControl ( spatialPartition . upperLeftCoordinate . x , {
677+ nonNullable : true ,
678+ validators : [ Validators . required ] ,
679+ } ) ,
680+ minY : new FormControl ( spatialPartition . lowerRightCoordinate . y , {
681+ nonNullable : true ,
682+ validators : [ Validators . required ] ,
683+ } ) ,
684+ maxX : new FormControl ( spatialPartition . lowerRightCoordinate . x , {
685+ nonNullable : true ,
686+ validators : [ Validators . required ] ,
687+ } ) ,
688+ maxY : new FormControl ( spatialPartition . upperLeftCoordinate . y , {
689+ nonNullable : true ,
690+ validators : [ Validators . required ] ,
691+ } ) ,
692+ } ) ,
693+ } ) ,
608694 } ) ,
609695 } ) ;
610696
@@ -634,6 +720,44 @@ export class GdalMultiBandComponent implements OnChanges {
634720 nonNullable : true ,
635721 validators : [ Validators . required ] ,
636722 } ) ,
723+ spatialGrid : new FormGroup < SpatialGridDescriptorForm > ( {
724+ geoTransform : new FormGroup < GeoTransformForm > ( {
725+ originX : new FormControl ( 0 , {
726+ nonNullable : true ,
727+ validators : [ Validators . required ] ,
728+ } ) ,
729+ originY : new FormControl ( 0 , {
730+ nonNullable : true ,
731+ validators : [ Validators . required ] ,
732+ } ) ,
733+ xPixelSize : new FormControl ( 1 , {
734+ nonNullable : true ,
735+ validators : [ Validators . required ] ,
736+ } ) ,
737+ yPixelSize : new FormControl ( - 1 , {
738+ nonNullable : true ,
739+ validators : [ Validators . required ] ,
740+ } ) ,
741+ } ) ,
742+ gridBounds : new FormGroup < GridBoundingBox2DForm > ( {
743+ minX : new FormControl ( 0 , {
744+ nonNullable : true ,
745+ validators : [ Validators . required ] ,
746+ } ) ,
747+ minY : new FormControl ( 0 , {
748+ nonNullable : true ,
749+ validators : [ Validators . required ] ,
750+ } ) ,
751+ maxX : new FormControl ( 1 , {
752+ nonNullable : true ,
753+ validators : [ Validators . required ] ,
754+ } ) ,
755+ maxY : new FormControl ( 1 , {
756+ nonNullable : true ,
757+ validators : [ Validators . required ] ,
758+ } ) ,
759+ } ) ,
760+ } ) ,
637761 } ) ,
638762 } ) ;
639763
@@ -803,3 +927,11 @@ class TileDataSource extends DataSource<DatasetTile> {
803927 } ) ;
804928 }
805929}
930+ function spatialGridFromSpatialPartition (
931+ value : Partial < {
932+ geoTransform : Partial < { originX : number ; originY : number ; xPixelSize : number ; yPixelSize : number } > ;
933+ gridBounds : Partial < { minX : number ; minY : number ; maxX : number ; maxY : number } > ;
934+ } > ,
935+ ) : import ( '@geoengine/openapi-client' ) . SpatialGridDescriptor {
936+ throw new Error ( 'Function not implemented.' ) ;
937+ }
0 commit comments