Lint removal

This commit is contained in:
Tim Schaub
2018-07-16 17:57:57 -06:00
parent f78d0d4cfa
commit d0ab8dce38
63 changed files with 2945 additions and 2917 deletions

View File

@@ -61,42 +61,42 @@ import {get as getProjection, equivalent as equivalentProjection, transformExten
* @api
*/
class FeatureFormat {
constructor() {
constructor() {
/**
/**
* @protected
* @type {module:ol/proj/Projection}
*/
this.dataProjection = null;
this.dataProjection = null;
/**
/**
* @protected
* @type {module:ol/proj/Projection}
*/
this.defaultFeatureProjection = null;
this.defaultFeatureProjection = null;
}
}
/**
/**
* Adds the data projection to the read options.
* @param {Document|Node|Object|string} source Source.
* @param {module:ol/format/Feature~ReadOptions=} opt_options Options.
* @return {module:ol/format/Feature~ReadOptions|undefined} Options.
* @protected
*/
getReadOptions(source, opt_options) {
let options;
if (opt_options) {
options = {
dataProjection: opt_options.dataProjection ?
opt_options.dataProjection : this.readProjection(source),
featureProjection: opt_options.featureProjection
};
}
return this.adaptOptions(options);
}
getReadOptions(source, opt_options) {
let options;
if (opt_options) {
options = {
dataProjection: opt_options.dataProjection ?
opt_options.dataProjection : this.readProjection(source),
featureProjection: opt_options.featureProjection
};
}
return this.adaptOptions(options);
}
/**
/**
* Sets the `dataProjection` on the options, if no `dataProjection`
* is set.
* @param {module:ol/format/Feature~WriteOptions|module:ol/format/Feature~ReadOptions|undefined} options
@@ -105,28 +105,28 @@ class FeatureFormat {
* @return {module:ol/format/Feature~WriteOptions|module:ol/format/Feature~ReadOptions|undefined}
* Updated options.
*/
adaptOptions(options) {
return assign({
dataProjection: this.dataProjection,
featureProjection: this.defaultFeatureProjection
}, options);
}
adaptOptions(options) {
return assign({
dataProjection: this.dataProjection,
featureProjection: this.defaultFeatureProjection
}, options);
}
/**
/**
* Get the extent from the source of the last {@link readFeatures} call.
* @return {module:ol/extent~Extent} Tile extent.
*/
getLastExtent() {
return null;
}
getLastExtent() {
return null;
}
/**
/**
* @abstract
* @return {module:ol/format/FormatType} Format.
*/
getType() {}
getType() {}
/**
/**
* Read a single feature from a source.
*
* @abstract
@@ -134,9 +134,9 @@ class FeatureFormat {
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
* @return {module:ol/Feature} Feature.
*/
readFeature(source, opt_options) {}
readFeature(source, opt_options) {}
/**
/**
* Read all features from a source.
*
* @abstract
@@ -144,9 +144,9 @@ class FeatureFormat {
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
* @return {Array.<module:ol/Feature>} Features.
*/
readFeatures(source, opt_options) {}
readFeatures(source, opt_options) {}
/**
/**
* Read a single geometry from a source.
*
* @abstract
@@ -154,18 +154,18 @@ class FeatureFormat {
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
* @return {module:ol/geom/Geometry} Geometry.
*/
readGeometry(source, opt_options) {}
readGeometry(source, opt_options) {}
/**
/**
* Read the projection from a source.
*
* @abstract
* @param {Document|Node|Object|string} source Source.
* @return {module:ol/proj/Projection} Projection.
*/
readProjection(source) {}
readProjection(source) {}
/**
/**
* Encode a feature in this format.
*
* @abstract
@@ -173,9 +173,9 @@ class FeatureFormat {
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
* @return {string} Result.
*/
writeFeature(feature, opt_options) {}
writeFeature(feature, opt_options) {}
/**
/**
* Encode an array of features in this format.
*
* @abstract
@@ -183,9 +183,9 @@ class FeatureFormat {
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
* @return {string} Result.
*/
writeFeatures(features, opt_options) {}
writeFeatures(features, opt_options) {}
/**
/**
* Write a single geometry in this format.
*
* @abstract
@@ -193,7 +193,7 @@ class FeatureFormat {
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
* @return {string} Result.
*/
writeGeometry(geometry, opt_options) {}
writeGeometry(geometry, opt_options) {}
}
export default FeatureFormat;

View File

@@ -20,6 +20,18 @@ import {createElementNS, getAllTextContent, makeArrayPusher, makeChildAppender,
const schemaLocation = GMLNS + ' http://schemas.opengis.net/gml/2.1.2/feature.xsd';
/**
* @const
* @type {Object.<string, string>}
*/
const MULTIGEOMETRY_TO_MEMBER_NODENAME = {
'MultiLineString': 'lineStringMember',
'MultiCurve': 'curveMember',
'MultiPolygon': 'polygonMember',
'MultiSurface': 'surfaceMember'
};
/**
* @classdesc
* Feature format for reading and writing data in the GML format,
@@ -576,18 +588,6 @@ class GML2 {
inherits(GML2, GMLBase);
/**
* @const
* @type {Object.<string, string>}
*/
const MULTIGEOMETRY_TO_MEMBER_NODENAME = {
'MultiLineString': 'lineStringMember',
'MultiCurve': 'curveMember',
'MultiPolygon': 'polygonMember',
'MultiSurface': 'surfaceMember'
};
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}

View File

@@ -30,6 +30,18 @@ const schemaLocation = GMLNS +
'1.0.0/gmlsf.xsd';
/**
* @const
* @type {Object.<string, string>}
*/
const MULTIGEOMETRY_TO_MEMBER_NODENAME = {
'MultiLineString': 'lineStringMember',
'MultiCurve': 'curveMember',
'MultiPolygon': 'polygonMember',
'MultiSurface': 'surfaceMember'
};
/**
* @classdesc
* Feature format for reading and writing data in the GML format
@@ -1088,18 +1100,6 @@ GML3.prototype.SEGMENTS_PARSERS_ = {
};
/**
* @const
* @type {Object.<string, string>}
*/
const MULTIGEOMETRY_TO_MEMBER_NODENAME = {
'MultiLineString': 'lineStringMember',
'MultiCurve': 'curveMember',
'MultiPolygon': 'polygonMember',
'MultiSurface': 'surfaceMember'
};
/**
* Encode an array of features in GML 3.1.1 Simple Features.
*

View File

@@ -29,6 +29,20 @@ import {getAllTextContent, getAttributeNS, makeArrayPusher, makeReplacer, parseN
export const 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
* space (0xa0) is explicitly included as IE doesn't include it in its
* definition of `\s`.
*
* Information from `goog.string.isEmptyOrWhitespace`: https://github.com/google/closure-library/blob/e877b1e/closure/goog/string/string.js#L156-L160
*
* @const
* @type {RegExp}
*/
const ONLY_WHITESPACE_RE = /^[\s\xa0]*$/;
/**
* @typedef {Object} Options
* @property {Object.<string, string>|string} [featureNS] Feature
@@ -458,20 +472,6 @@ class GMLBase {
inherits(GMLBase, XMLFeature);
/**
* A regular expression that matches if a string only contains whitespace
* characters. It will e.g. match `''`, `' '`, `'\n'` etc. The non-breaking
* space (0xa0) is explicitly included as IE doesn't include it in its
* definition of `\s`.
*
* Information from `goog.string.isEmptyOrWhitespace`: https://github.com/google/closure-library/blob/e877b1e/closure/goog/string/string.js#L156-L160
*
* @const
* @type {RegExp}
*/
const ONLY_WHITESPACE_RE = /^[\s\xa0]*$/;
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}

View File

@@ -18,6 +18,71 @@ import {createElementNS, makeArrayPusher, makeArraySerializer, makeChildAppender
XML_SCHEMA_INSTANCE_URI} from '../xml.js';
/**
* @const
* @type {Array.<null|string>}
*/
const NAMESPACE_URIS = [
null,
'http://www.topografix.com/GPX/1/0',
'http://www.topografix.com/GPX/1/1'
];
/**
* @const
* @type {string}
*/
const SCHEMA_LOCATION = 'http://www.topografix.com/GPX/1/1 ' +
'http://www.topografix.com/GPX/1/1/gpx.xsd';
/**
* @const
* @type {Object.<string, function(Node, Array.<*>): (module:ol/Feature|undefined)>}
*/
const FEATURE_READER = {
'rte': readRte,
'trk': readTrk,
'wpt': readWpt
};
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const GPX_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'rte': makeArrayPusher(readRte),
'trk': makeArrayPusher(readTrk),
'wpt': makeArrayPusher(readWpt)
});
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const LINK_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'text': makeObjectPropertySetter(readString, 'linkText'),
'type': makeObjectPropertySetter(readString, 'linkType')
});
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Serializer>>}
*/
const GPX_SERIALIZERS = makeStructureNS(
NAMESPACE_URIS, {
'rte': makeChildAppender(writeRte),
'trk': makeChildAppender(writeTrk),
'wpt': makeChildAppender(writeWpt)
});
/**
* @typedef {Object} Options
* @property {function(module:ol/Feature, Node)} [readExtensions] Callback function
@@ -150,59 +215,6 @@ class GPX {
inherits(GPX, XMLFeature);
/**
* @const
* @type {Array.<null|string>}
*/
const NAMESPACE_URIS = [
null,
'http://www.topografix.com/GPX/1/0',
'http://www.topografix.com/GPX/1/1'
];
/**
* @const
* @type {string}
*/
const SCHEMA_LOCATION = 'http://www.topografix.com/GPX/1/1 ' +
'http://www.topografix.com/GPX/1/1/gpx.xsd';
/**
* @const
* @type {Object.<string, function(Node, Array.<*>): (module:ol/Feature|undefined)>}
*/
const FEATURE_READER = {
'rte': readRte,
'trk': readTrk,
'wpt': readWpt
};
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const GPX_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'rte': makeArrayPusher(readRte),
'trk': makeArrayPusher(readTrk),
'wpt': makeArrayPusher(readWpt)
});
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const LINK_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'text': makeObjectPropertySetter(readString, 'linkText'),
'type': makeObjectPropertySetter(readString, 'linkType')
});
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
@@ -466,18 +478,6 @@ function GPX_NODE_FACTORY(value, objectStack, opt_nodeName) {
}
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Serializer>>}
*/
const GPX_SERIALIZERS = makeStructureNS(
NAMESPACE_URIS, {
'rte': makeChildAppender(writeRte),
'trk': makeChildAppender(writeTrk),
'wpt': makeChildAppender(writeWpt)
});
/**
* @param {Array.<number>} flatCoordinates Flat coordinates.
* @param {module:ol/format/GPX~LayoutOptions} layoutOptions Layout options.

View File

@@ -19,6 +19,36 @@ const IGCZ = {
NONE: 'none'
};
/**
* @const
* @type {RegExp}
*/
const B_RECORD_RE =
/^B(\d{2})(\d{2})(\d{2})(\d{2})(\d{5})([NS])(\d{3})(\d{5})([EW])([AV])(\d{5})(\d{5})/;
/**
* @const
* @type {RegExp}
*/
const H_RECORD_RE = /^H.([A-Z]{3}).*?:(.*)/;
/**
* @const
* @type {RegExp}
*/
const HFDTE_RECORD_RE = /^HFDTE(\d{2})(\d{2})(\d{2})/;
/**
* A regular expression matching the newline characters `\r\n`, `\r` and `\n`.
*
* @const
* @type {RegExp}
*/
const NEWLINE_RE = /\r\n|\r|\n/;
/**
* @typedef {Object} Options
@@ -170,37 +200,6 @@ class IGC {
inherits(IGC, TextFeature);
/**
* @const
* @type {RegExp}
*/
const B_RECORD_RE =
/^B(\d{2})(\d{2})(\d{2})(\d{2})(\d{5})([NS])(\d{3})(\d{5})([EW])([AV])(\d{5})(\d{5})/;
/**
* @const
* @type {RegExp}
*/
const H_RECORD_RE = /^H.([A-Z]{3}).*?:(.*)/;
/**
* @const
* @type {RegExp}
*/
const HFDTE_RECORD_RE = /^HFDTE(\d{2})(\d{2})(\d{2})/;
/**
* A regular expression matching the newline characters `\r\n`, `\r` and `\n`.
*
* @const
* @type {RegExp}
*/
const NEWLINE_RE = /\r\n|\r|\n/;
/**
* Read the feature from the IGC source.
*

View File

@@ -16,127 +16,127 @@ import FormatType from '../format/FormatType.js';
* @extends {module:ol/format/Feature}
*/
class JSONFeature {
constructor() {
FeatureFormat.call(this);
}
constructor() {
FeatureFormat.call(this);
}
/**
/**
* @inheritDoc
*/
getType() {
return FormatType.JSON;
}
getType() {
return FormatType.JSON;
}
/**
/**
* @inheritDoc
*/
readFeature(source, opt_options) {
return this.readFeatureFromObject(
getObject(source), this.getReadOptions(source, opt_options));
}
readFeature(source, opt_options) {
return this.readFeatureFromObject(
getObject(source), this.getReadOptions(source, opt_options));
}
/**
/**
* @inheritDoc
*/
readFeatures(source, opt_options) {
return this.readFeaturesFromObject(
getObject(source), this.getReadOptions(source, opt_options));
}
readFeatures(source, opt_options) {
return this.readFeaturesFromObject(
getObject(source), this.getReadOptions(source, opt_options));
}
/**
/**
* @abstract
* @param {Object} object Object.
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
* @protected
* @return {module:ol/Feature} Feature.
*/
readFeatureFromObject(object, opt_options) {}
readFeatureFromObject(object, opt_options) {}
/**
/**
* @abstract
* @param {Object} object Object.
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
* @protected
* @return {Array.<module:ol/Feature>} Features.
*/
readFeaturesFromObject(object, opt_options) {}
readFeaturesFromObject(object, opt_options) {}
/**
/**
* @inheritDoc
*/
readGeometry(source, opt_options) {
return this.readGeometryFromObject(
getObject(source), this.getReadOptions(source, opt_options));
}
readGeometry(source, opt_options) {
return this.readGeometryFromObject(
getObject(source), this.getReadOptions(source, opt_options));
}
/**
/**
* @abstract
* @param {Object} object Object.
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
* @protected
* @return {module:ol/geom/Geometry} Geometry.
*/
readGeometryFromObject(object, opt_options) {}
readGeometryFromObject(object, opt_options) {}
/**
/**
* @inheritDoc
*/
readProjection(source) {
return this.readProjectionFromObject(getObject(source));
}
readProjection(source) {
return this.readProjectionFromObject(getObject(source));
}
/**
/**
* @abstract
* @param {Object} object Object.
* @protected
* @return {module:ol/proj/Projection} Projection.
*/
readProjectionFromObject(object) {}
readProjectionFromObject(object) {}
/**
/**
* @inheritDoc
*/
writeFeature(feature, opt_options) {
return JSON.stringify(this.writeFeatureObject(feature, opt_options));
}
writeFeature(feature, opt_options) {
return JSON.stringify(this.writeFeatureObject(feature, opt_options));
}
/**
/**
* @abstract
* @param {module:ol/Feature} feature Feature.
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
* @return {Object} Object.
*/
writeFeatureObject(feature, opt_options) {}
writeFeatureObject(feature, opt_options) {}
/**
/**
* @inheritDoc
*/
writeFeatures(features, opt_options) {
return JSON.stringify(this.writeFeaturesObject(features, opt_options));
}
writeFeatures(features, opt_options) {
return JSON.stringify(this.writeFeaturesObject(features, opt_options));
}
/**
/**
* @abstract
* @param {Array.<module:ol/Feature>} features Features.
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
* @return {Object} Object.
*/
writeFeaturesObject(features, opt_options) {}
writeFeaturesObject(features, opt_options) {}
/**
/**
* @inheritDoc
*/
writeGeometry(geometry, opt_options) {
return JSON.stringify(this.writeGeometryObject(geometry, opt_options));
}
writeGeometry(geometry, opt_options) {
return JSON.stringify(this.writeGeometryObject(geometry, opt_options));
}
/**
/**
* @abstract
* @param {module:ol/geom/Geometry} geometry Geometry.
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
* @return {Object} Object.
*/
writeGeometryObject(geometry, opt_options) {}
writeGeometryObject(geometry, opt_options) {}
}
inherits(JSONFeature, FeatureFormat);

View File

@@ -48,6 +48,143 @@ import {createElementNS, getAllTextContent, isDocument, isNode, makeArrayExtende
* @property {Array.<number>} whens
*/
/**
* @const
* @type {Array.<string>}
*/
const GX_NAMESPACE_URIS = [
'http://www.google.com/kml/ext/2.2'
];
/**
* @const
* @type {Array.<null|string>}
*/
const NAMESPACE_URIS = [
null,
'http://earth.google.com/kml/2.0',
'http://earth.google.com/kml/2.1',
'http://earth.google.com/kml/2.2',
'http://www.opengis.net/kml/2.2'
];
/**
* @const
* @type {string}
*/
const SCHEMA_LOCATION = 'http://www.opengis.net/kml/2.2 ' +
'https://developers.google.com/kml/schema/kml22gx.xsd';
/**
* @type {Object.<string, module:ol/style/IconAnchorUnits>}
*/
const ICON_ANCHOR_UNITS_MAP = {
'fraction': IconAnchorUnits.FRACTION,
'pixels': IconAnchorUnits.PIXELS,
'insetPixels': IconAnchorUnits.PIXELS
};
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const PLACEMARK_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'ExtendedData': extendedDataParser,
'Region': regionParser,
'MultiGeometry': makeObjectPropertySetter(
readMultiGeometry, 'geometry'),
'LineString': makeObjectPropertySetter(
readLineString, 'geometry'),
'LinearRing': makeObjectPropertySetter(
readLinearRing, 'geometry'),
'Point': makeObjectPropertySetter(
readPoint, 'geometry'),
'Polygon': makeObjectPropertySetter(
readPolygon, 'geometry'),
'Style': makeObjectPropertySetter(readStyle),
'StyleMap': placemarkStyleMapParser,
'address': makeObjectPropertySetter(readString),
'description': makeObjectPropertySetter(readString),
'name': makeObjectPropertySetter(readString),
'open': makeObjectPropertySetter(readBoolean),
'phoneNumber': makeObjectPropertySetter(readString),
'styleUrl': makeObjectPropertySetter(readURI),
'visibility': makeObjectPropertySetter(readBoolean)
}, makeStructureNS(
GX_NAMESPACE_URIS, {
'MultiTrack': makeObjectPropertySetter(
readGxMultiTrack, 'geometry'),
'Track': makeObjectPropertySetter(
readGxTrack, 'geometry')
}
));
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const NETWORK_LINK_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'ExtendedData': extendedDataParser,
'Region': regionParser,
'Link': linkParser,
'address': makeObjectPropertySetter(readString),
'description': makeObjectPropertySetter(readString),
'name': makeObjectPropertySetter(readString),
'open': makeObjectPropertySetter(readBoolean),
'phoneNumber': makeObjectPropertySetter(readString),
'visibility': makeObjectPropertySetter(readBoolean)
});
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const LINK_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'href': makeObjectPropertySetter(readURI)
});
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const REGION_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'LatLonAltBox': latLonAltBoxParser,
'Lod': lodParser
});
/**
* @const
* @type {Object.<string, Array.<string>>}
*/
const KML_SEQUENCE = makeStructureNS(
NAMESPACE_URIS, [
'Document', 'Placemark'
]);
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Serializer>>}
*/
const KML_SERIALIZERS = makeStructureNS(
NAMESPACE_URIS, {
'Document': makeChildAppender(writeDocument),
'Placemark': makeChildAppender(writePlacemark)
});
/**
* @type {module:ol/color~Color}
*/
@@ -713,46 +850,6 @@ class KML {
inherits(KML, XMLFeature);
/**
* @const
* @type {Array.<string>}
*/
const GX_NAMESPACE_URIS = [
'http://www.google.com/kml/ext/2.2'
];
/**
* @const
* @type {Array.<null|string>}
*/
const NAMESPACE_URIS = [
null,
'http://earth.google.com/kml/2.0',
'http://earth.google.com/kml/2.1',
'http://earth.google.com/kml/2.2',
'http://www.opengis.net/kml/2.2'
];
/**
* @const
* @type {string}
*/
const SCHEMA_LOCATION = 'http://www.opengis.net/kml/2.2 ' +
'https://developers.google.com/kml/schema/kml22gx.xsd';
/**
* @type {Object.<string, module:ol/style/IconAnchorUnits>}
*/
const ICON_ANCHOR_UNITS_MAP = {
'fraction': IconAnchorUnits.FRACTION,
'pixels': IconAnchorUnits.PIXELS,
'insetPixels': IconAnchorUnits.PIXELS
};
/**
* @param {module:ol/style/Style|undefined} foundStyle Style.
* @param {string} name Name.
@@ -1723,17 +1820,6 @@ function extendedDataParser(node, objectStack) {
parseNode(EXTENDED_DATA_PARSERS, node, objectStack);
}
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const REGION_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'LatLonAltBox': latLonAltBoxParser,
'Lod': lodParser
});
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
@@ -1955,34 +2041,6 @@ function outerBoundaryIsParser(node, objectStack) {
}
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const NETWORK_LINK_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'ExtendedData': extendedDataParser,
'Region': regionParser,
'Link': linkParser,
'address': makeObjectPropertySetter(readString),
'description': makeObjectPropertySetter(readString),
'name': makeObjectPropertySetter(readString),
'open': makeObjectPropertySetter(readBoolean),
'phoneNumber': makeObjectPropertySetter(readString),
'visibility': makeObjectPropertySetter(readBoolean)
});
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const LINK_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'href': makeObjectPropertySetter(readURI)
});
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
@@ -2006,43 +2064,6 @@ function whenParser(node, objectStack) {
}
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const PLACEMARK_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'ExtendedData': extendedDataParser,
'Region': regionParser,
'MultiGeometry': makeObjectPropertySetter(
readMultiGeometry, 'geometry'),
'LineString': makeObjectPropertySetter(
readLineString, 'geometry'),
'LinearRing': makeObjectPropertySetter(
readLinearRing, 'geometry'),
'Point': makeObjectPropertySetter(
readPoint, 'geometry'),
'Polygon': makeObjectPropertySetter(
readPolygon, 'geometry'),
'Style': makeObjectPropertySetter(readStyle),
'StyleMap': placemarkStyleMapParser,
'address': makeObjectPropertySetter(readString),
'description': makeObjectPropertySetter(readString),
'name': makeObjectPropertySetter(readString),
'open': makeObjectPropertySetter(readBoolean),
'phoneNumber': makeObjectPropertySetter(readString),
'styleUrl': makeObjectPropertySetter(readURI),
'visibility': makeObjectPropertySetter(readBoolean)
}, makeStructureNS(
GX_NAMESPACE_URIS, {
'MultiTrack': makeObjectPropertySetter(
readGxMultiTrack, 'geometry'),
'Track': makeObjectPropertySetter(
readGxTrack, 'geometry')
}
));
/**
* Read the first feature from a KML source. MultiGeometries are converted into
* GeometryCollections if they are a mix of geometry types, and into MultiPoint/
@@ -2941,27 +2962,6 @@ function writeVec2(node, vec2) {
}
/**
* @const
* @type {Object.<string, Array.<string>>}
*/
const KML_SEQUENCE = makeStructureNS(
NAMESPACE_URIS, [
'Document', 'Placemark'
]);
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Serializer>>}
*/
const KML_SERIALIZERS = makeStructureNS(
NAMESPACE_URIS, {
'Document': makeChildAppender(writeDocument),
'Placemark': makeChildAppender(writePlacemark)
});
/**
* Encode an array of features in the KML format. GeometryCollections, MultiPoints,
* MultiLineStrings, and MultiPolygons are output as MultiGeometries.

View File

@@ -15,6 +15,36 @@ import {isEmpty} from '../obj.js';
import {get as getProjection} from '../proj.js';
import {pushParseAndPop, makeStructureNS} from '../xml.js';
/**
* @const
* @type {Array.<null>}
*/
const NAMESPACE_URIS = [null];
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const WAY_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'nd': readNd,
'tag': readTag
});
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'node': readNode,
'way': readWay
});
/**
* @classdesc
* Feature format for reading data in the
@@ -96,35 +126,6 @@ class OSMXML {
inherits(OSMXML, XMLFeature);
/**
* @const
* @type {Array.<null>}
*/
const NAMESPACE_URIS = [null];
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const WAY_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'nd': readNd,
'tag': readTag
});
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'node': readNode,
'way': readWay
});
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}

View File

@@ -7,6 +7,26 @@ import XML from '../format/XML.js';
import {readString} from '../format/xsd.js';
import {makeObjectPropertyPusher, makeObjectPropertySetter, makeStructureNS, pushParseAndPop} from '../xml.js';
/**
* @const
* @type {Array.<null|string>}
*/
const NAMESPACE_URIS = [null, 'http://www.opengis.net/ows/1.1'];
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'ServiceIdentification': makeObjectPropertySetter(readServiceIdentification),
'ServiceProvider': makeObjectPropertySetter(readServiceProvider),
'OperationsMetadata': makeObjectPropertySetter(readOperationsMetadata)
});
/**
* @constructor
* @extends {module:ol/format/XML}
@@ -41,25 +61,6 @@ class OWS {
inherits(OWS, XML);
/**
* @const
* @type {Array.<null|string>}
*/
const NAMESPACE_URIS = [null, 'http://www.opengis.net/ows/1.1'];
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'ServiceIdentification': makeObjectPropertySetter(readServiceIdentification),
'ServiceProvider': makeObjectPropertySetter(readServiceProvider),
'OperationsMetadata': makeObjectPropertySetter(readOperationsMetadata)
});
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}

View File

@@ -16,128 +16,128 @@ import FormatType from '../format/FormatType.js';
* @extends {module:ol/format/Feature}
*/
class TextFeature {
constructor() {
FeatureFormat.call(this);
}
constructor() {
FeatureFormat.call(this);
}
/**
/**
* @inheritDoc
*/
getType() {
return FormatType.TEXT;
}
getType() {
return FormatType.TEXT;
}
/**
/**
* @inheritDoc
*/
readFeature(source, opt_options) {
return this.readFeatureFromText(getText(source), this.adaptOptions(opt_options));
}
readFeature(source, opt_options) {
return this.readFeatureFromText(getText(source), this.adaptOptions(opt_options));
}
/**
/**
* @abstract
* @param {string} text Text.
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
* @protected
* @return {module:ol/Feature} Feature.
*/
readFeatureFromText(text, opt_options) {}
readFeatureFromText(text, opt_options) {}
/**
/**
* @inheritDoc
*/
readFeatures(source, opt_options) {
return this.readFeaturesFromText(getText(source), this.adaptOptions(opt_options));
}
readFeatures(source, opt_options) {
return this.readFeaturesFromText(getText(source), this.adaptOptions(opt_options));
}
/**
/**
* @abstract
* @param {string} text Text.
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
* @protected
* @return {Array.<module:ol/Feature>} Features.
*/
readFeaturesFromText(text, opt_options) {}
readFeaturesFromText(text, opt_options) {}
/**
/**
* @inheritDoc
*/
readGeometry(source, opt_options) {
return this.readGeometryFromText(getText(source), this.adaptOptions(opt_options));
}
readGeometry(source, opt_options) {
return this.readGeometryFromText(getText(source), this.adaptOptions(opt_options));
}
/**
/**
* @abstract
* @param {string} text Text.
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
* @protected
* @return {module:ol/geom/Geometry} Geometry.
*/
readGeometryFromText(text, opt_options) {}
readGeometryFromText(text, opt_options) {}
/**
/**
* @inheritDoc
*/
readProjection(source) {
return this.readProjectionFromText(getText(source));
}
readProjection(source) {
return this.readProjectionFromText(getText(source));
}
/**
/**
* @param {string} text Text.
* @protected
* @return {module:ol/proj/Projection} Projection.
*/
readProjectionFromText(text) {
return this.dataProjection;
}
readProjectionFromText(text) {
return this.dataProjection;
}
/**
/**
* @inheritDoc
*/
writeFeature(feature, opt_options) {
return this.writeFeatureText(feature, this.adaptOptions(opt_options));
}
writeFeature(feature, opt_options) {
return this.writeFeatureText(feature, this.adaptOptions(opt_options));
}
/**
/**
* @abstract
* @param {module:ol/Feature} feature Features.
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
* @protected
* @return {string} Text.
*/
writeFeatureText(feature, opt_options) {}
writeFeatureText(feature, opt_options) {}
/**
/**
* @inheritDoc
*/
writeFeatures(features, opt_options) {
return this.writeFeaturesText(features, this.adaptOptions(opt_options));
}
writeFeatures(features, opt_options) {
return this.writeFeaturesText(features, this.adaptOptions(opt_options));
}
/**
/**
* @abstract
* @param {Array.<module:ol/Feature>} features Features.
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
* @protected
* @return {string} Text.
*/
writeFeaturesText(features, opt_options) {}
writeFeaturesText(features, opt_options) {}
/**
/**
* @inheritDoc
*/
writeGeometry(geometry, opt_options) {
return this.writeGeometryText(geometry, this.adaptOptions(opt_options));
}
writeGeometry(geometry, opt_options) {
return this.writeGeometryText(geometry, this.adaptOptions(opt_options));
}
/**
/**
* @abstract
* @param {module:ol/geom/Geometry} geometry Geometry.
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
* @protected
* @return {string} Text.
*/
writeGeometryText(geometry, opt_options) {}
writeGeometryText(geometry, opt_options) {}
}
inherits(TextFeature, FeatureFormat);

View File

@@ -17,6 +17,69 @@ import {createElementNS, isDocument, isNode, makeArrayPusher, makeChildAppender,
pushParseAndPop, pushSerializeAndPop, XML_SCHEMA_INSTANCE_URI} from '../xml.js';
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const FEATURE_COLLECTION_PARSERS = {
'http://www.opengis.net/gml': {
'boundedBy': makeObjectPropertySetter(
GMLBase.prototype.readGeometryElement, 'bounds')
}
};
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const TRANSACTION_SUMMARY_PARSERS = {
'http://www.opengis.net/wfs': {
'totalInserted': makeObjectPropertySetter(readNonNegativeInteger),
'totalUpdated': makeObjectPropertySetter(readNonNegativeInteger),
'totalDeleted': makeObjectPropertySetter(readNonNegativeInteger)
}
};
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const TRANSACTION_RESPONSE_PARSERS = {
'http://www.opengis.net/wfs': {
'TransactionSummary': makeObjectPropertySetter(
readTransactionSummary, 'transactionSummary'),
'InsertResults': makeObjectPropertySetter(
readInsertResults, 'insertIds')
}
};
/**
* @type {Object.<string, Object.<string, module:ol/xml~Serializer>>}
*/
const QUERY_SERIALIZERS = {
'http://www.opengis.net/wfs': {
'PropertyName': makeChildAppender(writeStringTextNode)
}
};
/**
* @type {Object.<string, Object.<string, module:ol/xml~Serializer>>}
*/
const TRANSACTION_SERIALIZERS = {
'http://www.opengis.net/wfs': {
'Insert': makeChildAppender(writeFeature),
'Update': makeChildAppender(writeUpdate),
'Delete': makeChildAppender(writeDelete),
'Property': makeChildAppender(writeProperty),
'Native': makeChildAppender(writeNative)
}
};
/**
* @typedef {Object} Options
* @property {Object.<string, string>|string} [featureNS] The namespace URI used for features.
@@ -487,31 +550,6 @@ inherits(WFS, XMLFeature);
WFS.prototype.readFeatures;
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const FEATURE_COLLECTION_PARSERS = {
'http://www.opengis.net/gml': {
'boundedBy': makeObjectPropertySetter(
GMLBase.prototype.readGeometryElement, 'bounds')
}
};
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const TRANSACTION_SUMMARY_PARSERS = {
'http://www.opengis.net/wfs': {
'totalInserted': makeObjectPropertySetter(readNonNegativeInteger),
'totalUpdated': makeObjectPropertySetter(readNonNegativeInteger),
'totalDeleted': makeObjectPropertySetter(readNonNegativeInteger)
}
};
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
@@ -567,30 +605,6 @@ function readInsertResults(node, objectStack) {
}
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const TRANSACTION_RESPONSE_PARSERS = {
'http://www.opengis.net/wfs': {
'TransactionSummary': makeObjectPropertySetter(
readTransactionSummary, 'transactionSummary'),
'InsertResults': makeObjectPropertySetter(
readInsertResults, 'insertIds')
}
};
/**
* @type {Object.<string, Object.<string, module:ol/xml~Serializer>>}
*/
const QUERY_SERIALIZERS = {
'http://www.opengis.net/wfs': {
'PropertyName': makeChildAppender(writeStringTextNode)
}
};
/**
* @param {Node} node Node.
* @param {module:ol/Feature} feature Feature.
@@ -663,20 +677,6 @@ function writeDelete(node, feature, objectStack) {
}
/**
* @type {Object.<string, Object.<string, module:ol/xml~Serializer>>}
*/
const TRANSACTION_SERIALIZERS = {
'http://www.opengis.net/wfs': {
'Insert': makeChildAppender(writeFeature),
'Update': makeChildAppender(writeUpdate),
'Delete': makeChildAppender(writeDelete),
'Property': makeChildAppender(writeProperty),
'Native': makeChildAppender(writeNative)
}
};
/**
* @param {Node} node Node.
* @param {module:ol/Feature} feature Feature.

View File

@@ -17,6 +17,19 @@ import Polygon from '../geom/Polygon.js';
import SimpleGeometry from '../geom/SimpleGeometry.js';
/**
* @enum {function (new:module:ol/geom/Geometry, Array, module:ol/geom/GeometryLayout)}
*/
const GeometryConstructor = {
'POINT': Point,
'LINESTRING': LineString,
'POLYGON': Polygon,
'MULTIPOINT': MultiPoint,
'MULTILINESTRING': MultiLineString,
'MULTIPOLYGON': MultiPolygon
};
/**
* @typedef {Object} Options
* @property {boolean} [splitCollection=false] Whether to split GeometryCollections into
@@ -521,12 +534,42 @@ class Parser {
const geometries = this.parseGeometryCollectionText_();
return new GeometryCollection(geometries);
} else {
const parser = GeometryParser[geomType];
const ctor = GeometryConstructor[geomType];
if (!parser || !ctor) {
if (!ctor) {
throw new Error('Invalid geometry type: ' + geomType);
}
let coordinates = parser.call(this);
let coordinates;
switch (geomType) {
case GeometryType.POINT: {
coordinates = this.parsePointText_();
break;
}
case GeometryType.LINESTRING: {
coordinates = this.parseLineStringText_();
break;
}
case GeometryType.POLYGON: {
coordinates = Parser.prototype.parsePolygonText_();
break;
}
case GeometryType.MULTIPOINT: {
coordinates = Parser.prototype.parseMultiPointText_();
break;
}
case GeometryType.MULTILINESTRING: {
coordinates = Parser.prototype.parseMultiLineStringText_();
break;
}
case GeometryType.MULTIPOLYGON: {
coordinates = Parser.prototype.parseMultiPolygonText_();
break;
}
default: {
throw new Error('Invalid geometry type: ' + geomType);
}
}
if (!coordinates) {
if (ctor === GeometryConstructor[GeometryType.POINT]) {
coordinates = [NaN, NaN];
@@ -541,6 +584,7 @@ class Parser {
}
}
/**
* @classdesc
* Geometry format for reading and writing data in the `WellKnownText` (WKT)
@@ -855,32 +899,6 @@ WKT.prototype.readFeatures;
WKT.prototype.readGeometry;
/**
* @enum {function (new:module:ol/geom/Geometry, Array, module:ol/geom/GeometryLayout)}
*/
const GeometryConstructor = {
'POINT': Point,
'LINESTRING': LineString,
'POLYGON': Polygon,
'MULTIPOINT': MultiPoint,
'MULTILINESTRING': MultiLineString,
'MULTIPOLYGON': MultiPolygon
};
/**
* @enum {(function(): Array)}
*/
const GeometryParser = {
'POINT': Parser.prototype.parsePointText_,
'LINESTRING': Parser.prototype.parseLineStringText_,
'POLYGON': Parser.prototype.parsePolygonText_,
'MULTIPOINT': Parser.prototype.parseMultiPointText_,
'MULTILINESTRING': Parser.prototype.parseMultiLineStringText_,
'MULTIPOLYGON': Parser.prototype.parseMultiPolygonText_
};
/**
* Encode a feature as a WKT string.
*

View File

@@ -9,6 +9,39 @@ import {makeArrayPusher, makeObjectPropertyPusher, makeObjectPropertySetter,
makeStructureNS, pushParseAndPop} from '../xml.js';
/**
* @const
* @type {Array.<null|string>}
*/
const NAMESPACE_URIS = [
null,
'http://www.opengis.net/wms'
];
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'Service': makeObjectPropertySetter(readService),
'Capability': makeObjectPropertySetter(readCapability)
});
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const CAPABILITY_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'Request': makeObjectPropertySetter(readRequest),
'Exception': makeObjectPropertySetter(readException),
'Layer': makeObjectPropertySetter(readCapabilityLayer)
});
/**
* @classdesc
* Format for reading WMS capabilities data
@@ -55,39 +88,6 @@ class WMSCapabilities {
inherits(WMSCapabilities, XML);
/**
* @const
* @type {Array.<null|string>}
*/
const NAMESPACE_URIS = [
null,
'http://www.opengis.net/wms'
];
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'Service': makeObjectPropertySetter(readService),
'Capability': makeObjectPropertySetter(readCapability)
});
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const CAPABILITY_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'Request': makeObjectPropertySetter(readRequest),
'Exception': makeObjectPropertySetter(readException),
'Layer': makeObjectPropertySetter(readCapabilityLayer)
});
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}

View File

@@ -15,6 +15,20 @@ import {makeArrayPusher, makeStructureNS, pushParseAndPop} from '../xml.js';
*/
/**
* @const
* @type {string}
*/
const featureIdentifier = '_feature';
/**
* @const
* @type {string}
*/
const layerIdentifier = '_layer';
/**
* @classdesc
* Format for reading WMSGetFeatureInfo format. It uses
@@ -159,20 +173,6 @@ class WMSGetFeatureInfo {
inherits(WMSGetFeatureInfo, XMLFeature);
/**
* @const
* @type {string}
*/
const featureIdentifier = '_feature';
/**
* @const
* @type {string}
*/
const layerIdentifier = '_layer';
/**
* Read all features from a WMSGetFeatureInfo response.
*

View File

@@ -10,6 +10,37 @@ import {readString, readNonNegativeInteger, readDecimal} from '../format/xsd.js'
import {pushParseAndPop, makeStructureNS,
makeObjectPropertySetter, makeObjectPropertyPusher, makeArrayPusher} from '../xml.js';
/**
* @const
* @type {Array.<null|string>}
*/
const NAMESPACE_URIS = [
null,
'http://www.opengis.net/wmts/1.0'
];
/**
* @const
* @type {Array.<null|string>}
*/
const OWS_NAMESPACE_URIS = [
null,
'http://www.opengis.net/ows/1.1'
];
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'Contents': makeObjectPropertySetter(readContents)
});
/**
* @classdesc
* Format for reading WMTS capabilities data.
@@ -59,36 +90,6 @@ class WMTSCapabilities {
inherits(WMTSCapabilities, XML);
/**
* @const
* @type {Array.<null|string>}
*/
const NAMESPACE_URIS = [
null,
'http://www.opengis.net/wmts/1.0'
];
/**
* @const
* @type {Array.<null|string>}
*/
const OWS_NAMESPACE_URIS = [
null,
'http://www.opengis.net/ows/1.1'
];
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
*/
const PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'Contents': makeObjectPropertySetter(readContents)
});
/**
* @const
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}

View File

@@ -12,36 +12,36 @@ import {isDocument, isNode, parse} from '../xml.js';
* @struct
*/
class XML {
/**
/**
* @param {Document|Node|string} source Source.
* @return {Object} The parsed result.
*/
read(source) {
if (isDocument(source)) {
return this.readFromDocument(/** @type {Document} */ (source));
} else if (isNode(source)) {
return this.readFromNode(/** @type {Node} */ (source));
} else if (typeof source === 'string') {
const doc = parse(source);
return this.readFromDocument(doc);
} else {
return null;
}
}
read(source) {
if (isDocument(source)) {
return this.readFromDocument(/** @type {Document} */ (source));
} else if (isNode(source)) {
return this.readFromNode(/** @type {Node} */ (source));
} else if (typeof source === 'string') {
const doc = parse(source);
return this.readFromDocument(doc);
} else {
return null;
}
}
/**
/**
* @abstract
* @param {Document} doc Document.
* @return {Object} Object
*/
readFromDocument(doc) {}
readFromDocument(doc) {}
/**
/**
* @abstract
* @param {Node} node Node.
* @return {Object} Object
*/
readFromNode(node) {}
readFromNode(node) {}
}
export default XML;

View File

@@ -14,22 +14,22 @@
* @struct
*/
class Filter {
constructor(tagName) {
constructor(tagName) {
/**
/**
* @private
* @type {!string}
*/
this.tagName_ = tagName;
}
this.tagName_ = tagName;
}
/**
/**
* The XML tag name for a filter.
* @returns {!string} Name.
*/
getTagName() {
return this.tagName_;
}
getTagName() {
return this.tagName_;
}
}
export default Filter;