-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathtoolExportAreaService.js
78 lines (74 loc) · 2.86 KB
/
toolExportAreaService.js
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
(function (angular) {
'use strict';
/**
* @memberof spApp
* @ngdoc service
* @name ToolExportAreaService
* @description
* Client side tool to export area layers
*/
angular.module('tool-export-area-service', [])
.factory("ToolExportAreaService", ["$http", "$q", "MapService", "LayersService", function ($http, $q, MapService, LayersService) {
return {
// Override text with view-config.json
spec: {
"input": [
{
"description": $i18n(420),
"type": "area",
"constraints": {
"min": 1,
"max": 1,
"optional": false,
"defaultAreas": false
}
},
{
"description": $i18n(421),
"type": "list",
"constraints": {
"default": "Shapefile",
"selection": "single",
"content": [
"Shapefile",
"KML",
"WKT"
],
"optional": false
}
}],
"view": [
{
"name": $i18n(422),
"inputs": [
"area"
]
},
{
"name": $i18n(423),
"inputs": [
"layer"
]
},
{
"name": $i18n(424),
"inputs": [
"groups",
"shp"
]
}
],
"description": $i18n(425)
},
execute: function (inputs) {
//We only allow to download this first area at the current stage
var areas = inputs[0];
var downloadingArea = areas[0];
var pid = downloadingArea.pid;
var name = downloadingArea.name;
var url = LayersService.getAreaDownloadUrl(pid, inputs[1].toLowerCase(), name);
Util.download(url, name.replace('[^a-zA-Z0-9]', '_') + "." + inputs[1].toLowerCase());
}
};
}])
}(angular));