-
Notifications
You must be signed in to change notification settings - Fork 383
/
FileFormatUtils.js
74 lines (71 loc) · 1.75 KB
/
FileFormatUtils.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
const {head} = require('lodash');
const getFormatByName = (outF) => {
const extension = outF.split(/[^\w]/)[1];
return extension ? {outputFormat: outF, extension: extension.toLowerCase()} : undefined;
};
const formats = [{
outputFormat: "shape-zip",
extension: "zip"
}, {
outputFormat: "csv",
extension: "csv"
}, {
outputFormat: "excel",
extension: "xls"
}, {
outputFormat: "excel2007",
extension: "xlsx"
}, {
outputFormat: "dxf",
extension: "dxf"
}, {
outputFormat: "dxf-zip",
extension: "zip"
}, {
outputFormat: "application/vnd.google-earth.kml+xml",
extension: "kml"
}, {
outputFormat: "application/json",
extension: "json"
}, {
outputFormat: "gml3",
extension: "gml"
}, {
outputFormat: "GML2",
extension: "gml"
}, {
outputFormat: "application/vnd.googlxml",
extension: "kml"
}, {
outputFormat: "OGR-CSV",
extension: "csv"
}, {
outputFormat: "OGR-FileGDB",
extension: "gdb"
}, {
outputFormat: "OGR-GPKG",
extension: "gpkg"
}, {
outputFormat: "OGR-KML",
extension: "kml"
}, {
outputFormat: "OGR-MIF",
extension: "mif"
}, {
outputFormat: "OGR-TAB",
extension: "tab"
}, {
outputFormat: "SHAPE-ZIP",
extension: "zip"
}, {
outputFormat: "gml32",
extension: "gml"
}, {
outputFormat: "application/x-gpk",
extension: "gpk"
}
];
module.exports = {
formats,
getByOutputFormat: (outF) => head(formats.filter(format => format.outputFormat === outF)) || getFormatByName(outF)
};