Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C125 annotations #2647

Merged
merged 3 commits into from
Feb 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 51 additions & 3 deletions web/client/utils/FileFormatUtils.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
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: "csv",
extension: "csv"
}, {
outputFormat: "excel",
extension: "xls"
Expand All @@ -17,10 +23,52 @@ const formats = [{
}, {
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))
getByOutputFormat: (outF) => head(formats.filter(format => format.outputFormat === outF)) || getFormatByName(outF)
};
19 changes: 19 additions & 0 deletions web/client/utils/__tests__/FileFormatUtils-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright 2018, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
var expect = require('expect');
var FileFormatUtils = require('../FileFormatUtils');


describe('FileFormatUtils', () => {
it('getByOutputFormat custom format', () => {
const result = FileFormatUtils.getByOutputFormat("TEST-CSV");
expect(result).toExist();
expect(result.extension).toBe("csv");
expect(result.outputFormat).toBe("TEST-CSV");
});
});