Use union type instead of enum for feature format

This commit is contained in:
Tim Schaub
2021-09-05 10:59:57 -06:00
committed by Andreas Hocevar
parent 03dbe1f9a1
commit d05204f50b
9 changed files with 21 additions and 37 deletions
+4 -5
View File
@@ -1,7 +1,6 @@
/**
* @module ol/featureloader
*/
import FormatType from './format/FormatType.js';
import {VOID} from './functions.js';
/**
@@ -72,7 +71,7 @@ export function loadFeaturesXhr(
typeof url === 'function' ? url(extent, resolution, projection) : url,
true
);
if (format.getType() == FormatType.ARRAY_BUFFER) {
if (format.getType() == 'arraybuffer') {
xhr.responseType = 'arraybuffer';
}
xhr.withCredentials = withCredentials;
@@ -86,9 +85,9 @@ export function loadFeaturesXhr(
const type = format.getType();
/** @type {Document|Node|Object|string|undefined} */
let source;
if (type == FormatType.JSON || type == FormatType.TEXT) {
if (type == 'json' || type == 'text') {
source = xhr.responseText;
} else if (type == FormatType.XML) {
} else if (type == 'xml') {
source = xhr.responseXML;
if (!source) {
source = new DOMParser().parseFromString(
@@ -96,7 +95,7 @@ export function loadFeaturesXhr(
'application/xml'
);
}
} else if (type == FormatType.ARRAY_BUFFER) {
} else if (type == 'arraybuffer') {
source = /** @type {ArrayBuffer} */ (xhr.response);
}
if (source) {