|
@@ -72,14 +72,22 @@ app.post("/buy", async (req, res, next) => {
|
|
|
|
|
|
|
|
//TODO validate this properly
|
|
//TODO validate this properly
|
|
|
let txDetail = await getTransactionDetail(req.body.txHash, req.body.user);
|
|
let txDetail = await getTransactionDetail(req.body.txHash, req.body.user);
|
|
|
|
|
+
|
|
|
|
|
+ let extent: Array<Array<number>> = JSON.parse(txDetail.description).extent as Array<Array<number>>;
|
|
|
|
|
+ let dataFileId: string = Date.now().toString();
|
|
|
|
|
|
|
|
- const { stdout, stderr } = await asyncExec(CHAIN4ALL_RASTER_CLIP_SCRIPT_PATH);
|
|
|
|
|
|
|
+ let dataCommand = CHAIN4ALL_RASTER_CLIP_SCRIPT_PATH + ' ' + extent[3][1] + ' ' + extent[3][0] + ' ' + extent[1][1] + ' ' + extent[1][0] + ' ' + dataFileId;
|
|
|
|
|
+ console.debug(dataCommand);
|
|
|
|
|
+
|
|
|
|
|
+ const { stdout, stderr } = await asyncExec(dataCommand);
|
|
|
|
|
|
|
|
|
|
+ console.debug(stdout);
|
|
|
|
|
+
|
|
|
if(stderr){
|
|
if(stderr){
|
|
|
- throw(stderr);
|
|
|
|
|
|
|
+ console.warn(stderr);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- res.send(stdout);
|
|
|
|
|
|
|
+ res.send({dataUrl: "https://gis.lesprojekt.cz/chain4all/raster_" + dataFileId + ".tif"});
|
|
|
}
|
|
}
|
|
|
catch (err) {
|
|
catch (err) {
|
|
|
next(err);
|
|
next(err);
|
|
@@ -131,7 +139,7 @@ function getPrice(extent: Array<Array<number>>): number {
|
|
|
function errorMiddleware(err: any, req: any, res: any, next: any): void { //TODO: add custom Exception class
|
|
function errorMiddleware(err: any, req: any, res: any, next: any): void { //TODO: add custom Exception class
|
|
|
console.log(err);
|
|
console.log(err);
|
|
|
res.status(500);
|
|
res.status(500);
|
|
|
- res.send(err.message);
|
|
|
|
|
|
|
+ res.send(err);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
app.use(errorMiddleware);
|
|
app.use(errorMiddleware);
|