zhongrj
2025-11-25 b89962006164a462404b79a738bee8cbb6d7fe7e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { _ } from './gettext';
 
class AssetDownload{
  constructor(label, asset, icon, exportFormats = null, exportParams = {}){
    this.label = label;
    this.asset = asset;
    this.icon = icon;
    this.exportFormats = exportFormats;
    this.exportParams = exportParams;
  }
 
  downloadUrl(project_id, task_id){
    return `/api/projects/${project_id}/tasks/${task_id}/download/${this.asset}`;
  }
 
  exportId(){
      // Export identifier is the same as the asset value (minus the extension)
      return this.asset.replace(/\..+$/, "");
  }
 
  get separator(){ 
    return false;
  }
}
 
class AssetDownloadSeparator extends AssetDownload{
  constructor(){
    super("-");
  }
 
  downloadUrl(){
    return "#";
  }
 
  get separator(){
    return true;
  }
}
 
const tiffExportFormats = ["gtiff", "gtiff-rgb", "jpg", "png", "kmz"];
const elevationExportParams = {'hillshade': 6, "color_map": "viridis"};
 
const api = {
  all: function() {
    return [
      new AssetDownload(_("Orthophoto"),"orthophoto.tif","far fa-image", tiffExportFormats),
      new AssetDownload(_("Orthophoto (MBTiles)"),"orthophoto.mbtiles","far fa-image"),
      new AssetDownload(_("Orthophoto (Tiles)"),"orthophoto_tiles.zip","fa fa-table"),
      new AssetDownload(_("Terrain Model"),"dtm.tif","fa fa-chart-area", tiffExportFormats, elevationExportParams),
      new AssetDownload(_("Terrain Model (Tiles)"),"dtm_tiles.zip","fa fa-table"),
      new AssetDownload(_("Surface Model"),"dsm.tif","fa fa-chart-area", tiffExportFormats, elevationExportParams),
      new AssetDownload(_("Surface Model (Tiles)"),"dsm_tiles.zip","fa fa-table"),
      new AssetDownload(_("Point Cloud"),"georeferenced_model.laz","fa fa-cube", ["laz", "las", "ply", "csv"]),
      new AssetDownload(_("Point Cloud (3D Tiles)"),"3d_tiles_pointcloud.zip","fa fa-cube"),
      new AssetDownload(_("Textured Model"),"textured_model.zip","fab fa-connectdevelop"),
      new AssetDownload(_("Textured Model (3D Tiles)"),"3d_tiles_model.zip","fab fa-connectdevelop"),
      new AssetDownload(_("Textured Model (glTF)"),"textured_model.glb","fab fa-connectdevelop"),
      new AssetDownload(_("Camera Parameters"),"cameras.json","fa fa-camera"),
      new AssetDownload(_("Camera Shots"),"shots.geojson","fa fa-camera"),
      new AssetDownload(_("Ground Control Points"),"ground_control_points.geojson","far fa-dot-circle"),
      new AssetDownload(_("Quality Report"),"report.pdf","far fa-file-pdf"),
      
      
      
      new AssetDownloadSeparator(),
      new AssetDownload(_("All Assets"),"all.zip","far fa-file-archive")
    ];
  },
 
  excludeSeparators: function(){
    return api.all().filter(asset => !asset.separator);
  },
 
  // @param assets {String[]} list of assets (example: ['geotiff', 'las']))
  only: function(assets){
    return api.all().filter(asset => assets.indexOf(asset.asset) !== -1);
  }
}
 
export default api;