Named export from ol/format/GMLBase

This commit is contained in:
Tim Schaub
2018-02-19 09:26:16 -07:00
parent 67e5ba6afa
commit 7b21b41151
4 changed files with 22 additions and 21 deletions

View File

@@ -4,7 +4,7 @@
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import {createOrUpdate} from '../extent.js'; import {createOrUpdate} from '../extent.js';
import {transformWithOptions} from '../format/Feature.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 XSD from '../format/XSD.js';
import Geometry from '../geom/Geometry.js'; import Geometry from '../geom/Geometry.js';
import {assign} from '../obj.js'; import {assign} from '../obj.js';
@@ -17,7 +17,7 @@ import {createElementNS, getAllTextContent, makeArrayPusher, makeChildAppender,
* @const * @const
* @type {string} * @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); GMLBase.call(this, options);
this.FEATURE_COLLECTION_PARSERS[GMLBase.GMLNS][ this.FEATURE_COLLECTION_PARSERS[GMLNS][
'featureMember'] = 'featureMember'] =
makeArrayPusher(GMLBase.prototype.readFeaturesInternal); makeArrayPusher(GMLBase.prototype.readFeaturesInternal);

View File

@@ -5,7 +5,7 @@ import {inherits} from '../index.js';
import {extend} from '../array.js'; import {extend} from '../array.js';
import {createOrUpdate} from '../extent.js'; import {createOrUpdate} from '../extent.js';
import {transformWithOptions} from '../format/Feature.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 XSD from '../format/XSD.js';
import Geometry from '../geom/Geometry.js'; import Geometry from '../geom/Geometry.js';
import GeometryLayout from '../geom/GeometryLayout.js'; import GeometryLayout from '../geom/GeometryLayout.js';
@@ -25,7 +25,7 @@ import {createElementNS, getAllTextContent, makeArrayPusher, makeChildAppender,
* @type {string} * @type {string}
* @private * @private
*/ */
const schemaLocation = GMLBase.GMLNS + const schemaLocation = GMLNS +
' http://schemas.opengis.net/gml/3.1.1/profiles/gmlsfProfile/' + ' http://schemas.opengis.net/gml/3.1.1/profiles/gmlsfProfile/' +
'1.0.0/gmlsf.xsd'; '1.0.0/gmlsf.xsd';

View File

@@ -21,6 +21,14 @@ import {assign} from '../obj.js';
import {get as getProjection} from '../proj.js'; import {get as getProjection} from '../proj.js';
import {getAllTextContent, getAttributeNS, makeArrayPusher, makeReplacer, parseNode, pushParseAndPop} from '../xml.js'; import {getAllTextContent, getAttributeNS, makeArrayPusher, makeReplacer, parseNode, pushParseAndPop} from '../xml.js';
/**
* @const
* @type {string}
*/
export const GMLNS = 'http://www.opengis.net/gml';
/** /**
* @classdesc * @classdesc
* Abstract base class; normally only used for creating subclasses and not * Abstract base class; normally only used for creating subclasses and not
@@ -67,7 +75,7 @@ const GMLBase = function(opt_options) {
* @type {Object.<string, Object.<string, Object>>} * @type {Object.<string, Object.<string, Object>>}
*/ */
this.FEATURE_COLLECTION_PARSERS = {}; this.FEATURE_COLLECTION_PARSERS = {};
this.FEATURE_COLLECTION_PARSERS[GMLBase.GMLNS] = { this.FEATURE_COLLECTION_PARSERS[GMLNS] = {
'featureMember': makeReplacer(GMLBase.prototype.readFeaturesInternal), 'featureMember': makeReplacer(GMLBase.prototype.readFeaturesInternal),
'featureMembers': makeReplacer(GMLBase.prototype.readFeaturesInternal) 'featureMembers': makeReplacer(GMLBase.prototype.readFeaturesInternal)
}; };
@@ -78,13 +86,6 @@ const GMLBase = function(opt_options) {
inherits(GMLBase, XMLFeature); inherits(GMLBase, XMLFeature);
/**
* @const
* @type {string}
*/
GMLBase.GMLNS = 'http://www.opengis.net/gml';
/** /**
* A regular expression that matches if a string only contains whitespace * A regular expression that matches if a string only contains whitespace
* characters. It will e.g. match `''`, `' '`, `'\n'` etc. The non-breaking * 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) { GMLBase.prototype.readFeatureElement = function(node, objectStack) {
let n; let n;
const fid = node.getAttribute('fid') || getAttributeNS(node, GMLBase.GMLNS, 'id'); const fid = node.getAttribute('fid') || getAttributeNS(node, GMLNS, 'id');
const values = {}; const values = {};
let geometryName; let geometryName;
for (n = node.firstElementChild; n; n = n.nextElementSibling) { for (n = node.firstElementChild; n; n = n.nextElementSibling) {

View File

@@ -5,7 +5,7 @@ import {inherits} from '../index.js';
import {assert} from '../asserts.js'; import {assert} from '../asserts.js';
import GML2 from '../format/GML2.js'; import GML2 from '../format/GML2.js';
import GML3 from '../format/GML3.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 {and as andFilter, bbox as bboxFilter} from '../format/filter.js';
import XMLFeature from '../format/XMLFeature.js'; import XMLFeature from '../format/XMLFeature.js';
import XSD from '../format/XSD.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 : {})); assign(context, this.getReadOptions(node, opt_options ? opt_options : {}));
const objectStack = [context]; const objectStack = [context];
this.gmlFormat_.FEATURE_COLLECTION_PARSERS[GMLBase.GMLNS][ this.gmlFormat_.FEATURE_COLLECTION_PARSERS[GMLNS][
'featureMember'] = 'featureMember'] =
makeArrayPusher(GMLBase.prototype.readFeaturesInternal); makeArrayPusher(GMLBase.prototype.readFeaturesInternal);
let features = pushParseAndPop([], let features = pushParseAndPop([],
@@ -696,15 +696,15 @@ function writeDuringFilter(node, filter, objectStack) {
XSD.writeStringTextNode(valueReference, filter.propertyName); XSD.writeStringTextNode(valueReference, filter.propertyName);
node.appendChild(valueReference); node.appendChild(valueReference);
const timePeriod = createElementNS(GMLBase.GMLNS, 'TimePeriod'); const timePeriod = createElementNS(GMLNS, 'TimePeriod');
node.appendChild(timePeriod); node.appendChild(timePeriod);
const begin = createElementNS(GMLBase.GMLNS, 'begin'); const begin = createElementNS(GMLNS, 'begin');
timePeriod.appendChild(begin); timePeriod.appendChild(begin);
writeTimeInstant(begin, filter.begin); writeTimeInstant(begin, filter.begin);
const end = createElementNS(GMLBase.GMLNS, 'end'); const end = createElementNS(GMLNS, 'end');
timePeriod.appendChild(end); timePeriod.appendChild(end);
writeTimeInstant(end, filter.end); writeTimeInstant(end, filter.end);
} }
@@ -839,10 +839,10 @@ function writeOgcLiteral(node, value) {
* @param {string} time PropertyName value. * @param {string} time PropertyName value.
*/ */
function writeTimeInstant(node, time) { function writeTimeInstant(node, time) {
const timeInstant = createElementNS(GMLBase.GMLNS, 'TimeInstant'); const timeInstant = createElementNS(GMLNS, 'TimeInstant');
node.appendChild(timeInstant); node.appendChild(timeInstant);
const timePosition = createElementNS(GMLBase.GMLNS, 'timePosition'); const timePosition = createElementNS(GMLNS, 'timePosition');
timeInstant.appendChild(timePosition); timeInstant.appendChild(timePosition);
XSD.writeStringTextNode(timePosition, time); XSD.writeStringTextNode(timePosition, time);
} }