From 7b21b41151ce9a939ce9770d900ba6f09e77d960 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 19 Feb 2018 09:26:16 -0700 Subject: [PATCH] Named export from ol/format/GMLBase --- src/ol/format/GML2.js | 6 +++--- src/ol/format/GML3.js | 4 ++-- src/ol/format/GMLBase.js | 19 ++++++++++--------- src/ol/format/WFS.js | 14 +++++++------- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/ol/format/GML2.js b/src/ol/format/GML2.js index b0d7a72447..39fcfc88f1 100644 --- a/src/ol/format/GML2.js +++ b/src/ol/format/GML2.js @@ -4,7 +4,7 @@ import {inherits} from '../index.js'; import {createOrUpdate} from '../extent.js'; import {transformWithOptions} from '../format/Feature.js'; -import GMLBase from '../format/GMLBase.js'; +import GMLBase, {GMLNS} from '../format/GMLBase.js'; import XSD from '../format/XSD.js'; import Geometry from '../geom/Geometry.js'; import {assign} from '../obj.js'; @@ -17,7 +17,7 @@ import {createElementNS, getAllTextContent, makeArrayPusher, makeChildAppender, * @const * @type {string} */ -const schemaLocation = GMLBase.GMLNS + ' http://schemas.opengis.net/gml/2.1.2/feature.xsd'; +const schemaLocation = GMLNS + ' http://schemas.opengis.net/gml/2.1.2/feature.xsd'; /** @@ -36,7 +36,7 @@ const GML2 = function(opt_options) { GMLBase.call(this, options); - this.FEATURE_COLLECTION_PARSERS[GMLBase.GMLNS][ + this.FEATURE_COLLECTION_PARSERS[GMLNS][ 'featureMember'] = makeArrayPusher(GMLBase.prototype.readFeaturesInternal); diff --git a/src/ol/format/GML3.js b/src/ol/format/GML3.js index 89cc07d8fc..66e9e8459e 100644 --- a/src/ol/format/GML3.js +++ b/src/ol/format/GML3.js @@ -5,7 +5,7 @@ import {inherits} from '../index.js'; import {extend} from '../array.js'; import {createOrUpdate} from '../extent.js'; import {transformWithOptions} from '../format/Feature.js'; -import GMLBase from '../format/GMLBase.js'; +import GMLBase, {GMLNS} from '../format/GMLBase.js'; import XSD from '../format/XSD.js'; import Geometry from '../geom/Geometry.js'; import GeometryLayout from '../geom/GeometryLayout.js'; @@ -25,7 +25,7 @@ import {createElementNS, getAllTextContent, makeArrayPusher, makeChildAppender, * @type {string} * @private */ -const schemaLocation = GMLBase.GMLNS + +const schemaLocation = GMLNS + ' http://schemas.opengis.net/gml/3.1.1/profiles/gmlsfProfile/' + '1.0.0/gmlsf.xsd'; diff --git a/src/ol/format/GMLBase.js b/src/ol/format/GMLBase.js index b8935b27e5..852e1e8e43 100644 --- a/src/ol/format/GMLBase.js +++ b/src/ol/format/GMLBase.js @@ -21,6 +21,14 @@ import {assign} from '../obj.js'; import {get as getProjection} from '../proj.js'; import {getAllTextContent, getAttributeNS, makeArrayPusher, makeReplacer, parseNode, pushParseAndPop} from '../xml.js'; + +/** + * @const + * @type {string} + */ +export const GMLNS = 'http://www.opengis.net/gml'; + + /** * @classdesc * Abstract base class; normally only used for creating subclasses and not @@ -67,7 +75,7 @@ const GMLBase = function(opt_options) { * @type {Object.>} */ this.FEATURE_COLLECTION_PARSERS = {}; - this.FEATURE_COLLECTION_PARSERS[GMLBase.GMLNS] = { + this.FEATURE_COLLECTION_PARSERS[GMLNS] = { 'featureMember': makeReplacer(GMLBase.prototype.readFeaturesInternal), 'featureMembers': makeReplacer(GMLBase.prototype.readFeaturesInternal) }; @@ -78,13 +86,6 @@ const GMLBase = function(opt_options) { inherits(GMLBase, XMLFeature); -/** - * @const - * @type {string} - */ -GMLBase.GMLNS = 'http://www.opengis.net/gml'; - - /** * A regular expression that matches if a string only contains whitespace * characters. It will e.g. match `''`, `' '`, `'\n'` etc. The non-breaking @@ -215,7 +216,7 @@ GMLBase.prototype.readGeometryElement = function(node, objectStack) { */ GMLBase.prototype.readFeatureElement = function(node, objectStack) { let n; - const fid = node.getAttribute('fid') || getAttributeNS(node, GMLBase.GMLNS, 'id'); + const fid = node.getAttribute('fid') || getAttributeNS(node, GMLNS, 'id'); const values = {}; let geometryName; for (n = node.firstElementChild; n; n = n.nextElementSibling) { diff --git a/src/ol/format/WFS.js b/src/ol/format/WFS.js index cd1f10f82d..f7516059bf 100644 --- a/src/ol/format/WFS.js +++ b/src/ol/format/WFS.js @@ -5,7 +5,7 @@ import {inherits} from '../index.js'; import {assert} from '../asserts.js'; import GML2 from '../format/GML2.js'; import GML3 from '../format/GML3.js'; -import GMLBase from '../format/GMLBase.js'; +import GMLBase, {GMLNS} from '../format/GMLBase.js'; import {and as andFilter, bbox as bboxFilter} from '../format/filter.js'; import XMLFeature from '../format/XMLFeature.js'; import XSD from '../format/XSD.js'; @@ -149,7 +149,7 @@ WFS.prototype.readFeaturesFromNode = function(node, opt_options) { }); assign(context, this.getReadOptions(node, opt_options ? opt_options : {})); const objectStack = [context]; - this.gmlFormat_.FEATURE_COLLECTION_PARSERS[GMLBase.GMLNS][ + this.gmlFormat_.FEATURE_COLLECTION_PARSERS[GMLNS][ 'featureMember'] = makeArrayPusher(GMLBase.prototype.readFeaturesInternal); let features = pushParseAndPop([], @@ -696,15 +696,15 @@ function writeDuringFilter(node, filter, objectStack) { XSD.writeStringTextNode(valueReference, filter.propertyName); node.appendChild(valueReference); - const timePeriod = createElementNS(GMLBase.GMLNS, 'TimePeriod'); + const timePeriod = createElementNS(GMLNS, 'TimePeriod'); node.appendChild(timePeriod); - const begin = createElementNS(GMLBase.GMLNS, 'begin'); + const begin = createElementNS(GMLNS, 'begin'); timePeriod.appendChild(begin); writeTimeInstant(begin, filter.begin); - const end = createElementNS(GMLBase.GMLNS, 'end'); + const end = createElementNS(GMLNS, 'end'); timePeriod.appendChild(end); writeTimeInstant(end, filter.end); } @@ -839,10 +839,10 @@ function writeOgcLiteral(node, value) { * @param {string} time PropertyName value. */ function writeTimeInstant(node, time) { - const timeInstant = createElementNS(GMLBase.GMLNS, 'TimeInstant'); + const timeInstant = createElementNS(GMLNS, 'TimeInstant'); node.appendChild(timeInstant); - const timePosition = createElementNS(GMLBase.GMLNS, 'timePosition'); + const timePosition = createElementNS(GMLNS, 'timePosition'); timeInstant.appendChild(timePosition); XSD.writeStringTextNode(timePosition, time); }