Skip to content

Commit

Permalink
Merge pull request #123 from raphaelrpl/latest
Browse files Browse the repository at this point in the history
🐛 Fix grid creation step (close #122)
  • Loading branch information
raphaelrpl authored Oct 18, 2022
2 parents 5e7dd08 + 67b20af commit 6e7d1cd
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 38 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changes


## Version 0.6.2 (2022-10-18)

- Fix grid creation on create cube page [`#122`](https://github.com/brazil-data-cube/dc-manager/issues/122)


## Version 0.6.1 (2022-10-04)

- Add support to customize data cube name of IDT/Temporal Composed [`#119`](https://github.com/brazil-data-cube/dc-manager/issues/119)
Expand Down
2 changes: 1 addition & 1 deletion data-cube-manager/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion data-cube-manager/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "data-cube-manager",
"version": "0.6.1",
"version": "0.6.2",
"license": "GPLv3",
"scripts": {
"ng": "ng",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ export class CheckCubeComponent implements OnInit {
try {
this.store.dispatch(showLoading());

const tileId = item.tile_id || this.currentTab;

const cubeName = this.cube.name;
let start = item.start_date;
let end = item.end_date;
Expand All @@ -276,7 +278,7 @@ export class CheckCubeComponent implements OnInit {
end = moment(start).endOf('month').format('YYYY-MM-DD');
}

const response = await this.cbs.listMerges(this.cube.id, start, end, item.tile_id);
const response = await this.cbs.listMerges(this.cube.id, start, end, tileId);
const dialogRef = this.dialog.open(SceneDetailsComponent, {
width: '600px',
height: '90%',
Expand All @@ -285,7 +287,7 @@ export class CheckCubeComponent implements OnInit {
cube: this.cube.name,
merges: response,
itemDate: item.start_date,
tileId: item.tile_id,
tileId,
itemId: item.name
}
})
Expand All @@ -310,7 +312,7 @@ export class CheckCubeComponent implements OnInit {
grid: this.cube.grid,
datacube: this.cube.name,
datacube_version: this.cube.version,
tiles: [item.tile_id],
tiles: [this.currentTab],
editable: false,
start_date: item.start_date,
end_date: item.end_date,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ <h3 style="display: flex; align-items: center;">
<form [formGroup]="formCreateGrid" (ngSubmit)="createGrid()">
<mat-form-field appearance="outline">
<mat-label>Name</mat-label>
<input matInput placeholder="Name" formControlName="name">
<input matInput placeholder="Name (Names delimited by comma)" formControlName="names">
<mat-error>
<form-field-error [errors]="formCreateGrid.get('name').errors"></form-field-error>
<form-field-error [errors]="formCreateGrid.get('names').errors"></form-field-error>
</mat-error>
</mat-form-field>
<mat-form-field appearance="outline">
Expand All @@ -58,27 +58,47 @@ <h3 style="display: flex; align-items: center;">
<form-field-error [errors]="formCreateGrid.get('description').errors"></form-field-error>
</mat-error>
</mat-form-field>
<mat-form-field appearance="outline">
<mat-label>Meridian</mat-label>
<input matInput type="number" placeholder="Central Meridian" formControlName="meridian">
<mat-error>
<form-field-error [errors]="formCreateGrid.get('meridian').errors"></form-field-error>
</mat-error>
</mat-form-field>
<mat-form-field appearance="outline">
<mat-label>Width (in graus)</mat-label>
<input matInput type="number" placeholder="Width Tile" formControlName="degreesx">
<mat-error>
<form-field-error [errors]="formCreateGrid.get('degreesx').errors"></form-field-error>
</mat-error>
</mat-form-field>
<mat-form-field appearance="outline">
<mat-label>Height (in graus)</mat-label>
<input matInput type="number" placeholder="Height Tile" formControlName="degreesy">
<mat-error>
<form-field-error [errors]="formCreateGrid.get('degreesy').errors"></form-field-error>
</mat-error>
</mat-form-field>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12">
<mat-form-field appearance="outline">
<mat-label>Meridian</mat-label>
<input matInput type="number" placeholder="Central Meridian" formControlName="meridian">
<mat-error>
<form-field-error [errors]="formCreateGrid.get('meridian').errors"></form-field-error>
</mat-error>
</mat-form-field>
</div>

<div class="col-lg-6 col-md-6 col-sm-12">
<mat-form-field appearance="outline">
<mat-label>Custom SRID</mat-label>
<input matInput type="number" placeholder="Custom SRID Number to create" formControlName="srid">
<mat-error>
<form-field-error [errors]="formCreateGrid.get('srid').errors"></form-field-error>
</mat-error>
</mat-form-field>
</div>

<div class="col-lg-6 col-md-6 col-sm-12">
<mat-form-field appearance="outline">
<mat-label>Cell Shape (Row,Col)</mat-label>
<input matInput type="text" placeholder="Cell Shape (Row,Col)" formControlName="shape">
<mat-error>
<form-field-error [errors]="formCreateGrid.get('shape').errors"></form-field-error>
</mat-error>
</mat-form-field>
</div>

<div class="col-lg-6 col-md-6 col-sm-12">
<mat-form-field appearance="outline" matTooltip="Tile Resolution Factor (in meters)">
<mat-label>Tile Resolution Factor (in meters)</mat-label>
<input matInput type="text" placeholder="Tile Resolution delimited by comma and semi colon" formControlName="tile_factor">
<mat-error>
<form-field-error [errors]="formCreateGrid.get('tile_factor').errors"></form-field-error>
</mat-error>
</mat-form-field>
</div>
</div>

<button mat-raised-button class="btn" type="submit">CREATE GRID</button>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ export class CreateCubeGridComponent implements OnInit {
private fb: FormBuilder,
private ref: ChangeDetectorRef) {
this.formCreateGrid = this.fb.group({
name: ['', [Validators.required]],
names: ['', [Validators.required]],
description: ['', [Validators.required]],
meridian: [null, [Validators.required]],
degreesx: [{value: 1.5}, [Validators.required]],
degreesy: [{value: 1}, [Validators.required]]
shape: [null, [Validators.required]],
tile_factor: [null, [Validators.required]],
srid: [null, [Validators.required]],
});
}

Expand All @@ -67,11 +68,12 @@ export class CreateCubeGridComponent implements OnInit {
crs: ''
}
this.formCreateGrid.setValue({
name: '',
names: '',
description: '',
meridian: null,
degreesx: 1.5,
degreesy: 1
shape: null,
tile_factor: null,
srid: null,
})
}

Expand Down Expand Up @@ -153,6 +155,34 @@ export class CreateCubeGridComponent implements OnInit {
projection: 'aea',
bbox: this.formatBBox(this.bbox)
}
// Transform into list
data['tile_factor'] = [data['tile_factor']]
data['names'] = data['names'].split(',');
data['shape'] = data['shape'].split(',').map(value => parseInt(value))

if (data['tile_factor'][0].includes(';')) {
data['tile_factor'] = data['tile_factor'][0].split(';')
}

let tileFactorList = [];
for (let tileFactor of data['tile_factor']) {
const [pixelX, pixelY] = tileFactor.split(',')
tileFactorList.push([parseInt(pixelX), parseInt(pixelY)]);
}

if (tileFactorList.length !== data['names'].length) {
this.snackBar.open(`The grids ${data['names']} not match with ${tileFactorList}. It must have same dimension.`, '', {
duration: 4000,
verticalPosition: 'top',
panelClass: 'app_snack-bar-error'
});
return;
}

if (tileFactorList.length > 0) {
data['tile_factor'] = tileFactorList;
}

const response = await this.cbs.createGrid(data)
this.action = 'select'
this.getGrids()
Expand Down Expand Up @@ -185,8 +215,7 @@ export class CreateCubeGridComponent implements OnInit {
}

private formatBBox(bbox) {
const parts = bbox.split(',')
return `${parts[0]},${parts[3]},${parts[2]},${parts[1]}`
return bbox.split(',').map(value => parseFloat(value));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion data-cube-manager/src/app/app.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { AppState } from './app.state';
/** initial values to App State */
const initialState: AppState = {
loading: false,
token: localStorage.getItem('DC_MANAGER_api_token') || '',
token: localStorage.getItem('DC_MANAGER_api_token'),
urlService: localStorage.getItem('DC_MANAGER_url_service') || ''
};

Expand Down
2 changes: 1 addition & 1 deletion data-cube-manager/src/app/services/cube-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export class CubeBuilderService {
* create grid (grs_schema)
*/
public async createGrid(infos): Promise<any> {
const urlSuffix = `/create-grs`;
const urlSuffix = `/create-grids`;
const { data } = await api.post(`${this.urlCubeBuilder}${urlSuffix}`, infos);
return data;
}
Expand Down

0 comments on commit 6e7d1cd

Please sign in to comment.