Skip to content

Commit

Permalink
add(import-export): gpx support format (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
gignacnic authored and mbarbeau committed Feb 6, 2019
1 parent eaece1c commit 2ac1cc2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class DropGeoFileDirective extends DragAndDropDirective {

constructor(importExportService: ImportExportService) {
super();
this.allowed_extensions = ['zip', 'geojson', 'kml', 'gml', 'json'];
this.allowed_extensions = ['zip', 'geojson', 'kml', 'gpx', 'gml', 'json'];
this.filesDropped.subscribe(f => importExportService.import(f));
this.filesInvalid.subscribe(f => importExportService.onFilesInvalid(f));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ export class ImportExportService {
const mimeTypeAllowed = [
'application/gml+xml',
'application/vnd.google-earth.kml+xml',
'application/gpx+xml',
'application/json'
];
const zipMimeType = [
'application/zip',
'application/x-zip-compressed',
'application/x-zip'
];
const extensionAllowed = ['geojson', 'kml', 'json'];
const extensionAllowed = ['geojson', 'kml', 'gpx', 'json'];
if (
mimeTypeAllowed.indexOf(mimeType) !== -1 ||
extensionAllowed.indexOf(ext.toLowerCase()) !== -1
Expand Down Expand Up @@ -159,12 +160,17 @@ export class ImportExportService {
format = new olformat.KML();
} else if (mimeType === 'application/gml+xml') {
format = new olformat.GML();
} else if (mimeType === 'application/gpx+xml') {
format = new olformat.GPX();
} else if (ext) {
ext = ext.toLowerCase();
switch (ext) {
case 'kml':
format = new olformat.KML();
break;
case 'gpx':
format = new olformat.GPX();
break;
case 'gml':
format = new olformat.GML();
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { strEnum } from '@igo2/utils';

export const ExportFormat = strEnum(['GeoJSON', 'KML', 'GML', 'shapefile']);
export const ExportFormat = strEnum(['GeoJSON', 'KML', 'GPX', 'GML', 'shapefile']);
export type ExportFormat = keyof typeof ExportFormat;

0 comments on commit 2ac1cc2

Please sign in to comment.