diff --git a/src/server/libs/GoogleEarthEngine.js b/src/server/libs/GoogleEarthEngine.js index edd2ddd..71d623a 100644 --- a/src/server/libs/GoogleEarthEngine.js +++ b/src/server/libs/GoogleEarthEngine.js @@ -1,4 +1,5 @@ const ee = require('@google/earthengine'); +const { google } = require('google-auth-library'); const { PrismaClient } = require('@prisma/client') import { mongo } from "./Mongo"; @@ -89,8 +90,16 @@ export class GoogleEarthEngine { run(callback, errorCallback, authenticationErrorCallback) { this.ee.data.authenticateViaPrivateKey( this.credentials, - () => {this.ee.initialize(null, null, callback, errorCallback) }, - authenticationErrorCallback + () => { + this.ee.initialize(null, null, callback, (error) => { + errorCallback(error); + console.error('Initialization error:', error); + }); + }, + (authError) => { + authenticationErrorCallback(authError); + console.error('Authentication error:', authError); + } ); } } \ No newline at end of file diff --git a/src/server/libs/Landsat.js b/src/server/libs/Landsat.js index 4d90ded..ee4029f 100644 --- a/src/server/libs/Landsat.js +++ b/src/server/libs/Landsat.js @@ -21,6 +21,7 @@ export class Landsat extends GoogleEarthEngine { } ]; Landsat.prototype.mosaicsPromises = []; + this.initSatellites(); this.getCompositions(); PythonShell.defaultOptions = { @@ -32,10 +33,9 @@ export class Landsat extends GoogleEarthEngine { } initSatellites() { - - Landsat.prototype.landsat_5 = super.ee.ImageCollection("LANDSAT/LT05/C01/T1_TOA"); - Landsat.prototype.landsat_7 = super.ee.ImageCollection("LANDSAT/LE07/C01/T1_TOA"); - Landsat.prototype.landsat_8 = super.ee.ImageCollection("LANDSAT/LC08/C01/T1_TOA"); + Landsat.prototype.landsat_5 = super.ee.ImageCollection("LANDSAT/LT05/C02/T1_L2"); + Landsat.prototype.landsat_7 = super.ee.ImageCollection("LANDSAT/LE07/C02/T1_L2"); + Landsat.prototype.landsat_8 = super.ee.ImageCollection("LANDSAT/LC08/C02/T1_L2"); } getCompositions() { @@ -86,7 +86,7 @@ export class Landsat extends GoogleEarthEngine { this.getBounds().then(ob => { const year = moment().year() - 1; const bands = ['B5','B6','B4'] - const img = super.ee.ImageCollection("LANDSAT/LC08/C01/T1_TOA").filterDate(year + '-01-01', year + '-12-31') + const img = super.ee.ImageCollection("LANDSAT/LC08/C02/T1_L2").filterDate(year + '-01-01', year + '-12-31') .sort("CLOUD_COVER", false) .filterBounds(ob) .mosaic() @@ -98,7 +98,7 @@ export class Landsat extends GoogleEarthEngine { 'dimensions': 180, 'format': 'png' }); - + console.log(thumb, this.compositions) resolve(thumb) }) } catch (e) { diff --git a/src/server/util/satellites.js b/src/server/util/satellites.js index 65aef45..9397356 100644 --- a/src/server/util/satellites.js +++ b/src/server/util/satellites.js @@ -1,5 +1,5 @@ export const Satellites = { - SENTINEL: 1, - LANDSAT: 2, + SENTINEL: 2, + LANDSAT: 1, PLANET: 3 }