|
|
@@ -6,6 +6,7 @@ import {
|
|
|
|
|
|
import ExtentIteraction, { ExtentEvent } from 'ol/interaction/Extent'
|
|
|
import { shiftKeyOnly } from 'ol/events/condition';
|
|
|
+import { transformExtent } from 'ol/proj'
|
|
|
import {
|
|
|
Extent,
|
|
|
getArea
|
|
|
@@ -55,14 +56,14 @@ export class BcInfoComponent implements HsPanelComponent, OnInit {
|
|
|
|
|
|
//bind event handlers to this scope
|
|
|
this.onMouseUp = this.onMouseUp.bind(this);
|
|
|
- this.onExtentChanged = this.onExtentChanged.bind(this);
|
|
|
+ this.onExtentChanged = this.onExtentChanged.bind(this);
|
|
|
}
|
|
|
|
|
|
async ngOnInit(): Promise<void> {
|
|
|
await this.refreshUserBalance();
|
|
|
}
|
|
|
|
|
|
- async refreshUserBalance(): Promise<void>{
|
|
|
+ async refreshUserBalance(): Promise<void> {
|
|
|
this.getUserBalanceInProgress = true;
|
|
|
this.userBalance = await this.bcInfoService.getUserBalance(this.user, this.userPrivateKey, this.assetId);
|
|
|
this.getUserBalanceInProgress = false;
|
|
|
@@ -84,24 +85,28 @@ export class BcInfoComponent implements HsPanelComponent, OnInit {
|
|
|
}
|
|
|
|
|
|
async onBuy(): Promise<void> {
|
|
|
- if(!confirm("You sure?")){
|
|
|
+ if (!confirm("You sure?")) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
this.buyInProgress = true;
|
|
|
|
|
|
- this.paymentHash = await this.bcInfoService.transferAssets(this.user, this.userPrivateKey, this.assetId, this.extent, this.price);
|
|
|
+ let transformedExtent = transformExtent(this.extent, this.mapService.getMap().getView().getProjection(), "EPSG:4326");
|
|
|
+ transformedExtent = this.roundExtentCoords(transformedExtent);
|
|
|
+ //console.log(transformedExtent);
|
|
|
+
|
|
|
+ this.paymentHash = await this.bcInfoService.transferAssets(this.user, this.userPrivateKey, this.assetId, transformedExtent, this.price);
|
|
|
this.refreshUserBalance();
|
|
|
- this.dataUrl = "https://eo.lesprojekt.cz/produkty/S2/2020/S2A_MSIL2A_20200422T095031_N9999_R079_T33UXQ_20201127T165009_NDVI.tif" //await this.bcInfoService.requestData(this.paymentHash, this.user);
|
|
|
+ this.dataUrl = await this.bcInfoService.requestData(this.paymentHash, this.user);//"https://eo.lesprojekt.cz/produkty/S2/2020/S2A_MSIL2A_20200422T095031_N9999_R079_T33UXQ_20201127T165009_NDVI.tif"
|
|
|
|
|
|
- this.buyInProgress = false;
|
|
|
+ this.buyInProgress = false;
|
|
|
}
|
|
|
|
|
|
onCancel(): void {
|
|
|
let map = this.mapService.getMap();
|
|
|
|
|
|
this.extent = this.price = this.paymentHash = this.dataUrl = null;
|
|
|
- this.extentIteraction.setExtent(null);
|
|
|
+ this.extentIteraction.setExtent(null);
|
|
|
|
|
|
map.getTargetElement().removeEventListener("mouseup", this.onMouseUp); //This doesnt seem to work...
|
|
|
this.extentIteraction.un("extentchanged", this.onExtentChanged);
|
|
|
@@ -113,28 +118,33 @@ export class BcInfoComponent implements HsPanelComponent, OnInit {
|
|
|
|
|
|
async onMouseUp(event): Promise<void> {
|
|
|
if (this.extent) {
|
|
|
- this.price = this.roundTwoDecimalPlaces(await this.bcInfoService.getPrice(getArea(this.extent))); //round the price => allow more decimal places in iroha?
|
|
|
+ this.price = this.roundTwoDecimalPlaces(await this.bcInfoService.getPrice(getArea(this.extent))); //round the price => allow more decimal places in iroha?
|
|
|
}
|
|
|
}
|
|
|
|
|
|
onExtentChanged(event: ExtentEvent): any {
|
|
|
- if(event.extent){
|
|
|
+ if (event.extent) {
|
|
|
this.extent = this.roundExtentCoords(event.extent); //!! workaround for fixed description length to 64 chars in iroha-helpers !!
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ onTest() {
|
|
|
+ this.bcInfoService.getUserTransactions(this.user, this.userPrivateKey);
|
|
|
+ //console.log(this.mapService.getMap().getView().getProjection());
|
|
|
}
|
|
|
|
|
|
//UTILS SECTION - should be separeted in solo file
|
|
|
- private roundExtentCoords(extent: Extent): Extent{
|
|
|
+ private roundExtentCoords(extent: Extent): Extent {
|
|
|
let roundedExtent: number[] = new Array<number>(4);
|
|
|
|
|
|
- for(let i = 0; i !== extent.length; i++ ){
|
|
|
+ for (let i = 0; i !== extent.length; i++) {
|
|
|
roundedExtent[i] = this.roundTwoDecimalPlaces(extent[i]);
|
|
|
}
|
|
|
|
|
|
return roundedExtent;
|
|
|
}
|
|
|
|
|
|
- private roundTwoDecimalPlaces(num: number): number{
|
|
|
+ private roundTwoDecimalPlaces(num: number): number {
|
|
|
return Math.round((num + Number.EPSILON) * 100) / 100;
|
|
|
}
|
|
|
}
|