Merge pull request #7855 from tschaub/named-exports

More named exports
This commit is contained in:
Tim Schaub
2018-02-20 06:41:23 -07:00
committed by GitHub
26 changed files with 429 additions and 473 deletions
+5 -4
View File
@@ -68,7 +68,7 @@ inherits(ImageTile, Tile);
ImageTile.prototype.disposeInternal = function() { ImageTile.prototype.disposeInternal = function() {
if (this.state == TileState.LOADING) { if (this.state == TileState.LOADING) {
this.unlistenImage_(); this.unlistenImage_();
this.image_ = ImageTile.getBlankImage(); this.image_ = getBlankImage();
} }
if (this.interimTile) { if (this.interimTile) {
this.interimTile.dispose(); this.interimTile.dispose();
@@ -105,7 +105,7 @@ ImageTile.prototype.getKey = function() {
ImageTile.prototype.handleImageError_ = function() { ImageTile.prototype.handleImageError_ = function() {
this.state = TileState.ERROR; this.state = TileState.ERROR;
this.unlistenImage_(); this.unlistenImage_();
this.image_ = ImageTile.getBlankImage(); this.image_ = getBlankImage();
this.changed(); this.changed();
}; };
@@ -167,10 +167,11 @@ ImageTile.prototype.unlistenImage_ = function() {
* Get a 1-pixel blank image. * Get a 1-pixel blank image.
* @return {HTMLCanvasElement} Blank image. * @return {HTMLCanvasElement} Blank image.
*/ */
ImageTile.getBlankImage = function() { function getBlankImage() {
const ctx = createCanvasContext2D(1, 1); const ctx = createCanvasContext2D(1, 1);
ctx.fillStyle = 'rgba(0,0,0,0)'; ctx.fillStyle = 'rgba(0,0,0,0)';
ctx.fillRect(0, 0, 1, 1); ctx.fillRect(0, 0, 1, 1);
return ctx.canvas; return ctx.canvas;
}; }
export default ImageTile; export default ImageTile;
+9 -10
View File
@@ -4,8 +4,8 @@
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 {writeStringTextNode} 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';
import {get as getProjection, transformExtent} from '../proj.js'; import {get as getProjection, transformExtent} from '../proj.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);
@@ -199,8 +199,7 @@ GML2.prototype.writeFeatureElement = function(node, feature, objectStack) {
} }
} else { } else {
if (!(key in context.serializers[featureNS])) { if (!(key in context.serializers[featureNS])) {
context.serializers[featureNS][key] = makeChildAppender( context.serializers[featureNS][key] = makeChildAppender(writeStringTextNode);
XSD.writeStringTextNode);
} }
} }
} }
@@ -339,7 +338,7 @@ GML2.prototype.writeCoordinates_ = function(node, value, objectStack) {
point = points[i]; point = points[i];
parts[i] = this.getCoords_(point, srsName, hasZ); parts[i] = this.getCoords_(point, srsName, hasZ);
} }
XSD.writeStringTextNode(node, parts.join(' ')); writeStringTextNode(node, parts.join(' '));
}; };
@@ -473,7 +472,7 @@ GML2.prototype.writePoint_ = function(node, geometry, objectStack) {
node.appendChild(coordinates); node.appendChild(coordinates);
const point = geometry.getCoordinates(); const point = geometry.getCoordinates();
const coord = this.getCoords_(point, srsName, hasZ); const coord = this.getCoords_(point, srsName, hasZ);
XSD.writeStringTextNode(coordinates, coord); writeStringTextNode(coordinates, coord);
}; };
@@ -772,8 +771,8 @@ GML2.prototype.SURFACEORPOLYGONMEMBER_SERIALIZERS_ = {
*/ */
GML2.prototype.ENVELOPE_SERIALIZERS_ = { GML2.prototype.ENVELOPE_SERIALIZERS_ = {
'http://www.opengis.net/gml': { 'http://www.opengis.net/gml': {
'lowerCorner': makeChildAppender(XSD.writeStringTextNode), 'lowerCorner': makeChildAppender(writeStringTextNode),
'upperCorner': makeChildAppender(XSD.writeStringTextNode) 'upperCorner': makeChildAppender(writeStringTextNode)
} }
}; };
+12 -13
View File
@@ -5,8 +5,8 @@ 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 {readNonNegativeIntegerString, writeStringTextNode} 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';
import LineString from '../geom/LineString.js'; import LineString from '../geom/LineString.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';
@@ -366,16 +366,16 @@ GML3.prototype.readFlatPosList_ = function(node, objectStack) {
// The "dimension" attribute is from the GML 3.0.1 spec. // The "dimension" attribute is from the GML 3.0.1 spec.
let dim = 2; let dim = 2;
if (node.getAttribute('srsDimension')) { if (node.getAttribute('srsDimension')) {
dim = XSD.readNonNegativeIntegerString( dim = readNonNegativeIntegerString(
node.getAttribute('srsDimension')); node.getAttribute('srsDimension'));
} else if (node.getAttribute('dimension')) { } else if (node.getAttribute('dimension')) {
dim = XSD.readNonNegativeIntegerString( dim = readNonNegativeIntegerString(
node.getAttribute('dimension')); node.getAttribute('dimension'));
} else if (node.parentNode.getAttribute('srsDimension')) { } else if (node.parentNode.getAttribute('srsDimension')) {
dim = XSD.readNonNegativeIntegerString( dim = readNonNegativeIntegerString(
node.parentNode.getAttribute('srsDimension')); node.parentNode.getAttribute('srsDimension'));
} else if (contextDimension) { } else if (contextDimension) {
dim = XSD.readNonNegativeIntegerString(contextDimension); dim = readNonNegativeIntegerString(contextDimension);
} }
let x, y, z; let x, y, z;
const flatCoordinates = []; const flatCoordinates = [];
@@ -600,7 +600,7 @@ GML3.prototype.writePos_ = function(node, value, objectStack) {
const z = point[2] || 0; const z = point[2] || 0;
coords += ' ' + z; coords += ' ' + z;
} }
XSD.writeStringTextNode(node, coords); writeStringTextNode(node, coords);
}; };
@@ -650,7 +650,7 @@ GML3.prototype.writePosList_ = function(node, value, objectStack) {
point = points[i]; point = points[i];
parts[i] = this.getCoords_(point, srsName, hasZ); parts[i] = this.getCoords_(point, srsName, hasZ);
} }
XSD.writeStringTextNode(node, parts.join(' ')); writeStringTextNode(node, parts.join(' '));
}; };
@@ -994,8 +994,7 @@ GML3.prototype.writeFeatureElement = function(node, feature, objectStack) {
} }
} else { } else {
if (!(key in context.serializers[featureNS])) { if (!(key in context.serializers[featureNS])) {
context.serializers[featureNS][key] = makeChildAppender( context.serializers[featureNS][key] = makeChildAppender(writeStringTextNode);
XSD.writeStringTextNode);
} }
} }
} }
@@ -1181,8 +1180,8 @@ GML3.prototype.RING_SERIALIZERS_ = {
*/ */
GML3.prototype.ENVELOPE_SERIALIZERS_ = { GML3.prototype.ENVELOPE_SERIALIZERS_ = {
'http://www.opengis.net/gml': { 'http://www.opengis.net/gml': {
'lowerCorner': makeChildAppender(XSD.writeStringTextNode), 'lowerCorner': makeChildAppender(writeStringTextNode),
'upperCorner': makeChildAppender(XSD.writeStringTextNode) 'upperCorner': makeChildAppender(writeStringTextNode)
} }
}; };
+10 -9
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) {
+68 -69
View File
@@ -6,7 +6,7 @@ import Feature from '../Feature.js';
import {includes} from '../array.js'; import {includes} from '../array.js';
import {transformWithOptions} from '../format/Feature.js'; import {transformWithOptions} from '../format/Feature.js';
import XMLFeature from '../format/XMLFeature.js'; import XMLFeature from '../format/XMLFeature.js';
import XSD from '../format/XSD.js'; import {readString, readDecimal, readNonNegativeInteger, readDateTime, writeStringTextNode, writeNonNegativeIntegerTextNode, writeDecimalTextNode, writeDateTimeTextNode} from '../format/xsd.js';
import GeometryLayout from '../geom/GeometryLayout.js'; import GeometryLayout from '../geom/GeometryLayout.js';
import LineString from '../geom/LineString.js'; import LineString from '../geom/LineString.js';
import MultiLineString from '../geom/MultiLineString.js'; import MultiLineString from '../geom/MultiLineString.js';
@@ -95,8 +95,8 @@ const GPX_PARSERS = makeStructureNS(
*/ */
const LINK_PARSERS = makeStructureNS( const LINK_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'text': makeObjectPropertySetter(XSD.readString, 'linkText'), 'text': makeObjectPropertySetter(readString, 'linkText'),
'type': makeObjectPropertySetter(XSD.readString, 'linkType') 'type': makeObjectPropertySetter(readString, 'linkType')
}); });
@@ -106,14 +106,14 @@ const LINK_PARSERS = makeStructureNS(
*/ */
const RTE_PARSERS = makeStructureNS( const RTE_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'name': makeObjectPropertySetter(XSD.readString), 'name': makeObjectPropertySetter(readString),
'cmt': makeObjectPropertySetter(XSD.readString), 'cmt': makeObjectPropertySetter(readString),
'desc': makeObjectPropertySetter(XSD.readString), 'desc': makeObjectPropertySetter(readString),
'src': makeObjectPropertySetter(XSD.readString), 'src': makeObjectPropertySetter(readString),
'link': parseLink, 'link': parseLink,
'number': makeObjectPropertySetter(XSD.readNonNegativeInteger), 'number': makeObjectPropertySetter(readNonNegativeInteger),
'extensions': parseExtensions, 'extensions': parseExtensions,
'type': makeObjectPropertySetter(XSD.readString), 'type': makeObjectPropertySetter(readString),
'rtept': parseRtePt 'rtept': parseRtePt
}); });
@@ -124,8 +124,8 @@ const RTE_PARSERS = makeStructureNS(
*/ */
const RTEPT_PARSERS = makeStructureNS( const RTEPT_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'ele': makeObjectPropertySetter(XSD.readDecimal), 'ele': makeObjectPropertySetter(readDecimal),
'time': makeObjectPropertySetter(XSD.readDateTime) 'time': makeObjectPropertySetter(readDateTime)
}); });
@@ -135,13 +135,13 @@ const RTEPT_PARSERS = makeStructureNS(
*/ */
const TRK_PARSERS = makeStructureNS( const TRK_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'name': makeObjectPropertySetter(XSD.readString), 'name': makeObjectPropertySetter(readString),
'cmt': makeObjectPropertySetter(XSD.readString), 'cmt': makeObjectPropertySetter(readString),
'desc': makeObjectPropertySetter(XSD.readString), 'desc': makeObjectPropertySetter(readString),
'src': makeObjectPropertySetter(XSD.readString), 'src': makeObjectPropertySetter(readString),
'link': parseLink, 'link': parseLink,
'number': makeObjectPropertySetter(XSD.readNonNegativeInteger), 'number': makeObjectPropertySetter(readNonNegativeInteger),
'type': makeObjectPropertySetter(XSD.readString), 'type': makeObjectPropertySetter(readString),
'extensions': parseExtensions, 'extensions': parseExtensions,
'trkseg': parseTrkSeg 'trkseg': parseTrkSeg
}); });
@@ -163,8 +163,8 @@ const TRKSEG_PARSERS = makeStructureNS(
*/ */
const TRKPT_PARSERS = makeStructureNS( const TRKPT_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'ele': makeObjectPropertySetter(XSD.readDecimal), 'ele': makeObjectPropertySetter(readDecimal),
'time': makeObjectPropertySetter(XSD.readDateTime) 'time': makeObjectPropertySetter(readDateTime)
}); });
@@ -174,24 +174,24 @@ const TRKPT_PARSERS = makeStructureNS(
*/ */
const WPT_PARSERS = makeStructureNS( const WPT_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'ele': makeObjectPropertySetter(XSD.readDecimal), 'ele': makeObjectPropertySetter(readDecimal),
'time': makeObjectPropertySetter(XSD.readDateTime), 'time': makeObjectPropertySetter(readDateTime),
'magvar': makeObjectPropertySetter(XSD.readDecimal), 'magvar': makeObjectPropertySetter(readDecimal),
'geoidheight': makeObjectPropertySetter(XSD.readDecimal), 'geoidheight': makeObjectPropertySetter(readDecimal),
'name': makeObjectPropertySetter(XSD.readString), 'name': makeObjectPropertySetter(readString),
'cmt': makeObjectPropertySetter(XSD.readString), 'cmt': makeObjectPropertySetter(readString),
'desc': makeObjectPropertySetter(XSD.readString), 'desc': makeObjectPropertySetter(readString),
'src': makeObjectPropertySetter(XSD.readString), 'src': makeObjectPropertySetter(readString),
'link': parseLink, 'link': parseLink,
'sym': makeObjectPropertySetter(XSD.readString), 'sym': makeObjectPropertySetter(readString),
'type': makeObjectPropertySetter(XSD.readString), 'type': makeObjectPropertySetter(readString),
'fix': makeObjectPropertySetter(XSD.readString), 'fix': makeObjectPropertySetter(readString),
'sat': makeObjectPropertySetter(XSD.readNonNegativeInteger), 'sat': makeObjectPropertySetter(readNonNegativeInteger),
'hdop': makeObjectPropertySetter(XSD.readDecimal), 'hdop': makeObjectPropertySetter(readDecimal),
'vdop': makeObjectPropertySetter(XSD.readDecimal), 'vdop': makeObjectPropertySetter(readDecimal),
'pdop': makeObjectPropertySetter(XSD.readDecimal), 'pdop': makeObjectPropertySetter(readDecimal),
'ageofdgpsdata': makeObjectPropertySetter(XSD.readDecimal), 'ageofdgpsdata': makeObjectPropertySetter(readDecimal),
'dgpsid': makeObjectPropertySetter(XSD.readNonNegativeInteger), 'dgpsid': makeObjectPropertySetter(readNonNegativeInteger),
'extensions': parseExtensions 'extensions': parseExtensions
}); });
@@ -209,8 +209,8 @@ const LINK_SEQUENCE = ['text', 'type'];
*/ */
const LINK_SERIALIZERS = makeStructureNS( const LINK_SERIALIZERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'text': makeChildAppender(XSD.writeStringTextNode), 'text': makeChildAppender(writeStringTextNode),
'type': makeChildAppender(XSD.writeStringTextNode) 'type': makeChildAppender(writeStringTextNode)
}); });
@@ -230,13 +230,13 @@ const RTE_SEQUENCE = makeStructureNS(
*/ */
const RTE_SERIALIZERS = makeStructureNS( const RTE_SERIALIZERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'name': makeChildAppender(XSD.writeStringTextNode), 'name': makeChildAppender(writeStringTextNode),
'cmt': makeChildAppender(XSD.writeStringTextNode), 'cmt': makeChildAppender(writeStringTextNode),
'desc': makeChildAppender(XSD.writeStringTextNode), 'desc': makeChildAppender(writeStringTextNode),
'src': makeChildAppender(XSD.writeStringTextNode), 'src': makeChildAppender(writeStringTextNode),
'link': makeChildAppender(writeLink), 'link': makeChildAppender(writeLink),
'number': makeChildAppender(XSD.writeNonNegativeIntegerTextNode), 'number': makeChildAppender(writeNonNegativeIntegerTextNode),
'type': makeChildAppender(XSD.writeStringTextNode), 'type': makeChildAppender(writeStringTextNode),
'rtept': makeArraySerializer(makeChildAppender(writeWptType)) 'rtept': makeArraySerializer(makeChildAppender(writeWptType))
}); });
@@ -267,13 +267,13 @@ const TRK_SEQUENCE = makeStructureNS(
*/ */
const TRK_SERIALIZERS = makeStructureNS( const TRK_SERIALIZERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'name': makeChildAppender(XSD.writeStringTextNode), 'name': makeChildAppender(writeStringTextNode),
'cmt': makeChildAppender(XSD.writeStringTextNode), 'cmt': makeChildAppender(writeStringTextNode),
'desc': makeChildAppender(XSD.writeStringTextNode), 'desc': makeChildAppender(writeStringTextNode),
'src': makeChildAppender(XSD.writeStringTextNode), 'src': makeChildAppender(writeStringTextNode),
'link': makeChildAppender(writeLink), 'link': makeChildAppender(writeLink),
'number': makeChildAppender(XSD.writeNonNegativeIntegerTextNode), 'number': makeChildAppender(writeNonNegativeIntegerTextNode),
'type': makeChildAppender(XSD.writeStringTextNode), 'type': makeChildAppender(writeStringTextNode),
'trkseg': makeArraySerializer(makeChildAppender(writeTrkSeg)) 'trkseg': makeArraySerializer(makeChildAppender(writeTrkSeg))
}); });
@@ -313,24 +313,24 @@ const WPT_TYPE_SEQUENCE = makeStructureNS(
*/ */
const WPT_TYPE_SERIALIZERS = makeStructureNS( const WPT_TYPE_SERIALIZERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'ele': makeChildAppender(XSD.writeDecimalTextNode), 'ele': makeChildAppender(writeDecimalTextNode),
'time': makeChildAppender(XSD.writeDateTimeTextNode), 'time': makeChildAppender(writeDateTimeTextNode),
'magvar': makeChildAppender(XSD.writeDecimalTextNode), 'magvar': makeChildAppender(writeDecimalTextNode),
'geoidheight': makeChildAppender(XSD.writeDecimalTextNode), 'geoidheight': makeChildAppender(writeDecimalTextNode),
'name': makeChildAppender(XSD.writeStringTextNode), 'name': makeChildAppender(writeStringTextNode),
'cmt': makeChildAppender(XSD.writeStringTextNode), 'cmt': makeChildAppender(writeStringTextNode),
'desc': makeChildAppender(XSD.writeStringTextNode), 'desc': makeChildAppender(writeStringTextNode),
'src': makeChildAppender(XSD.writeStringTextNode), 'src': makeChildAppender(writeStringTextNode),
'link': makeChildAppender(writeLink), 'link': makeChildAppender(writeLink),
'sym': makeChildAppender(XSD.writeStringTextNode), 'sym': makeChildAppender(writeStringTextNode),
'type': makeChildAppender(XSD.writeStringTextNode), 'type': makeChildAppender(writeStringTextNode),
'fix': makeChildAppender(XSD.writeStringTextNode), 'fix': makeChildAppender(writeStringTextNode),
'sat': makeChildAppender(XSD.writeNonNegativeIntegerTextNode), 'sat': makeChildAppender(writeNonNegativeIntegerTextNode),
'hdop': makeChildAppender(XSD.writeDecimalTextNode), 'hdop': makeChildAppender(writeDecimalTextNode),
'vdop': makeChildAppender(XSD.writeDecimalTextNode), 'vdop': makeChildAppender(writeDecimalTextNode),
'pdop': makeChildAppender(XSD.writeDecimalTextNode), 'pdop': makeChildAppender(writeDecimalTextNode),
'ageofdgpsdata': makeChildAppender(XSD.writeDecimalTextNode), 'ageofdgpsdata': makeChildAppender(writeDecimalTextNode),
'dgpsid': makeChildAppender(XSD.writeNonNegativeIntegerTextNode) 'dgpsid': makeChildAppender(writeNonNegativeIntegerTextNode)
}); });
@@ -883,8 +883,7 @@ GPX.prototype.writeFeaturesNode = function(features, opt_options) {
const xmlnsUri = 'http://www.w3.org/2000/xmlns/'; const xmlnsUri = 'http://www.w3.org/2000/xmlns/';
const xmlSchemaInstanceUri = 'http://www.w3.org/2001/XMLSchema-instance'; const xmlSchemaInstanceUri = 'http://www.w3.org/2001/XMLSchema-instance';
setAttributeNS(gpx, xmlnsUri, 'xmlns:xsi', xmlSchemaInstanceUri); setAttributeNS(gpx, xmlnsUri, 'xmlns:xsi', xmlSchemaInstanceUri);
setAttributeNS(gpx, xmlSchemaInstanceUri, 'xsi:schemaLocation', setAttributeNS(gpx, xmlSchemaInstanceUri, 'xsi:schemaLocation', SCHEMA_LOCATION);
SCHEMA_LOCATION);
gpx.setAttribute('version', '1.1'); gpx.setAttribute('version', '1.1');
gpx.setAttribute('creator', 'OpenLayers'); gpx.setAttribute('creator', 'OpenLayers');
+70 -78
View File
@@ -8,7 +8,7 @@ import {assert} from '../asserts.js';
import {asArray} from '../color.js'; import {asArray} from '../color.js';
import {transformWithOptions} from '../format/Feature.js'; import {transformWithOptions} from '../format/Feature.js';
import XMLFeature from '../format/XMLFeature.js'; import XMLFeature from '../format/XMLFeature.js';
import XSD from '../format/XSD.js'; import {readDecimal, readBoolean, readString, writeStringTextNode, writeCDATASection, writeDecimalTextNode, writeBooleanTextNode} from '../format/xsd.js';
import GeometryCollection from '../geom/GeometryCollection.js'; import GeometryCollection from '../geom/GeometryCollection.js';
import GeometryLayout from '../geom/GeometryLayout.js'; import GeometryLayout from '../geom/GeometryLayout.js';
import GeometryType from '../geom/GeometryType.js'; import GeometryType from '../geom/GeometryType.js';
@@ -575,7 +575,7 @@ function readVec2(node) {
* @return {number|undefined} Scale. * @return {number|undefined} Scale.
*/ */
function readScale(node) { function readScale(node) {
return XSD.readDecimal(node); return readDecimal(node);
} }
@@ -607,7 +607,7 @@ function readStyleMapValue(node, objectStack) {
const ICON_STYLE_PARSERS = makeStructureNS( const ICON_STYLE_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'Icon': makeObjectPropertySetter(readIcon), 'Icon': makeObjectPropertySetter(readIcon),
'heading': makeObjectPropertySetter(XSD.readDecimal), 'heading': makeObjectPropertySetter(readDecimal),
'hotSpot': makeObjectPropertySetter(readVec2), 'hotSpot': makeObjectPropertySetter(readVec2),
'scale': makeObjectPropertySetter(readScale) 'scale': makeObjectPropertySetter(readScale)
}); });
@@ -758,7 +758,7 @@ function labelStyleParser(node, objectStack) {
const LINE_STYLE_PARSERS = makeStructureNS( const LINE_STYLE_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'color': makeObjectPropertySetter(readColor), 'color': makeObjectPropertySetter(readColor),
'width': makeObjectPropertySetter(XSD.readDecimal) 'width': makeObjectPropertySetter(readDecimal)
}); });
@@ -794,8 +794,8 @@ function lineStyleParser(node, objectStack) {
const POLY_STYLE_PARSERS = makeStructureNS( const POLY_STYLE_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'color': makeObjectPropertySetter(readColor), 'color': makeObjectPropertySetter(readColor),
'fill': makeObjectPropertySetter(XSD.readBoolean), 'fill': makeObjectPropertySetter(readBoolean),
'outline': makeObjectPropertySetter(XSD.readBoolean) 'outline': makeObjectPropertySetter(readBoolean)
}); });
@@ -948,10 +948,10 @@ const ICON_PARSERS = makeStructureNS(
'href': makeObjectPropertySetter(readURI) 'href': makeObjectPropertySetter(readURI)
}, makeStructureNS( }, makeStructureNS(
GX_NAMESPACE_URIS, { GX_NAMESPACE_URIS, {
'x': makeObjectPropertySetter(XSD.readDecimal), 'x': makeObjectPropertySetter(readDecimal),
'y': makeObjectPropertySetter(XSD.readDecimal), 'y': makeObjectPropertySetter(readDecimal),
'w': makeObjectPropertySetter(XSD.readDecimal), 'w': makeObjectPropertySetter(readDecimal),
'h': makeObjectPropertySetter(XSD.readDecimal) 'h': makeObjectPropertySetter(readDecimal)
})); }));
@@ -998,9 +998,9 @@ function readFlatCoordinatesFromNode(node, objectStack) {
*/ */
const EXTRUDE_AND_ALTITUDE_MODE_PARSERS = makeStructureNS( const EXTRUDE_AND_ALTITUDE_MODE_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'extrude': makeObjectPropertySetter(XSD.readBoolean), 'extrude': makeObjectPropertySetter(readBoolean),
'tessellate': makeObjectPropertySetter(XSD.readBoolean), 'tessellate': makeObjectPropertySetter(readBoolean),
'altitudeMode': makeObjectPropertySetter(XSD.readString) 'altitudeMode': makeObjectPropertySetter(readString)
}); });
@@ -1286,8 +1286,8 @@ function setCommonGeometryProperties(multiGeometry,
*/ */
const DATA_PARSERS = makeStructureNS( const DATA_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'displayName': makeObjectPropertySetter(XSD.readString), 'displayName': makeObjectPropertySetter(readString),
'value': makeObjectPropertySetter(XSD.readString) 'value': makeObjectPropertySetter(readString)
}); });
@@ -1353,7 +1353,7 @@ function regionParser(node, objectStack) {
const PAIR_PARSERS = makeStructureNS( const PAIR_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'Style': makeObjectPropertySetter(readStyle), 'Style': makeObjectPropertySetter(readStyle),
'key': makeObjectPropertySetter(XSD.readString), 'key': makeObjectPropertySetter(readString),
'styleUrl': makeObjectPropertySetter(readURI) 'styleUrl': makeObjectPropertySetter(readURI)
}); });
@@ -1431,7 +1431,7 @@ function schemaDataParser(node, objectStack) {
function simpleDataParser(node, objectStack) { function simpleDataParser(node, objectStack) {
const name = node.getAttribute('name'); const name = node.getAttribute('name');
if (name !== null) { if (name !== null) {
const data = XSD.readString(node); const data = readString(node);
const featureObject = const featureObject =
/** @type {Object} */ (objectStack[objectStack.length - 1]); /** @type {Object} */ (objectStack[objectStack.length - 1]);
featureObject[name] = data; featureObject[name] = data;
@@ -1445,13 +1445,13 @@ function simpleDataParser(node, objectStack) {
*/ */
const LAT_LON_ALT_BOX_PARSERS = makeStructureNS( const LAT_LON_ALT_BOX_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'altitudeMode': makeObjectPropertySetter(XSD.readString), 'altitudeMode': makeObjectPropertySetter(readString),
'minAltitude': makeObjectPropertySetter(XSD.readDecimal), 'minAltitude': makeObjectPropertySetter(readDecimal),
'maxAltitude': makeObjectPropertySetter(XSD.readDecimal), 'maxAltitude': makeObjectPropertySetter(readDecimal),
'north': makeObjectPropertySetter(XSD.readDecimal), 'north': makeObjectPropertySetter(readDecimal),
'south': makeObjectPropertySetter(XSD.readDecimal), 'south': makeObjectPropertySetter(readDecimal),
'east': makeObjectPropertySetter(XSD.readDecimal), 'east': makeObjectPropertySetter(readDecimal),
'west': makeObjectPropertySetter(XSD.readDecimal) 'west': makeObjectPropertySetter(readDecimal)
}); });
@@ -1484,10 +1484,10 @@ function latLonAltBoxParser(node, objectStack) {
*/ */
const LOD_PARSERS = makeStructureNS( const LOD_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'minLodPixels': makeObjectPropertySetter(XSD.readDecimal), 'minLodPixels': makeObjectPropertySetter(readDecimal),
'maxLodPixels': makeObjectPropertySetter(XSD.readDecimal), 'maxLodPixels': makeObjectPropertySetter(readDecimal),
'minFadeExtent': makeObjectPropertySetter(XSD.readDecimal), 'minFadeExtent': makeObjectPropertySetter(readDecimal),
'maxFadeExtent': makeObjectPropertySetter(XSD.readDecimal) 'maxFadeExtent': makeObjectPropertySetter(readDecimal)
}); });
@@ -1569,12 +1569,12 @@ const NETWORK_LINK_PARSERS = makeStructureNS(
'ExtendedData': extendedDataParser, 'ExtendedData': extendedDataParser,
'Region': regionParser, 'Region': regionParser,
'Link': linkParser, 'Link': linkParser,
'address': makeObjectPropertySetter(XSD.readString), 'address': makeObjectPropertySetter(readString),
'description': makeObjectPropertySetter(XSD.readString), 'description': makeObjectPropertySetter(readString),
'name': makeObjectPropertySetter(XSD.readString), 'name': makeObjectPropertySetter(readString),
'open': makeObjectPropertySetter(XSD.readBoolean), 'open': makeObjectPropertySetter(readBoolean),
'phoneNumber': makeObjectPropertySetter(XSD.readString), 'phoneNumber': makeObjectPropertySetter(readString),
'visibility': makeObjectPropertySetter(XSD.readBoolean) 'visibility': makeObjectPropertySetter(readBoolean)
}); });
@@ -1631,13 +1631,13 @@ const PLACEMARK_PARSERS = makeStructureNS(
readPolygon, 'geometry'), readPolygon, 'geometry'),
'Style': makeObjectPropertySetter(readStyle), 'Style': makeObjectPropertySetter(readStyle),
'StyleMap': placemarkStyleMapParser, 'StyleMap': placemarkStyleMapParser,
'address': makeObjectPropertySetter(XSD.readString), 'address': makeObjectPropertySetter(readString),
'description': makeObjectPropertySetter(XSD.readString), 'description': makeObjectPropertySetter(readString),
'name': makeObjectPropertySetter(XSD.readString), 'name': makeObjectPropertySetter(readString),
'open': makeObjectPropertySetter(XSD.readBoolean), 'open': makeObjectPropertySetter(readBoolean),
'phoneNumber': makeObjectPropertySetter(XSD.readString), 'phoneNumber': makeObjectPropertySetter(readString),
'styleUrl': makeObjectPropertySetter(readURI), 'styleUrl': makeObjectPropertySetter(readURI),
'visibility': makeObjectPropertySetter(XSD.readBoolean) 'visibility': makeObjectPropertySetter(readBoolean)
}, makeStructureNS( }, makeStructureNS(
GX_NAMESPACE_URIS, { GX_NAMESPACE_URIS, {
'MultiTrack': makeObjectPropertySetter( 'MultiTrack': makeObjectPropertySetter(
@@ -1908,7 +1908,7 @@ KML.prototype.readNameFromNode = function(node) {
for (n = node.firstElementChild; n; n = n.nextElementSibling) { for (n = node.firstElementChild; n; n = n.nextElementSibling) {
if (includes(NAMESPACE_URIS, n.namespaceURI) && if (includes(NAMESPACE_URIS, n.namespaceURI) &&
n.localName == 'name') { n.localName == 'name') {
return XSD.readString(n); return readString(n);
} }
} }
for (n = node.firstElementChild; n; n = n.nextElementSibling) { for (n = node.firstElementChild; n; n = n.nextElementSibling) {
@@ -2083,7 +2083,7 @@ function writeColorTextNode(node, color) {
const hex = parseInt(abgr[i], 10).toString(16); const hex = parseInt(abgr[i], 10).toString(16);
abgr[i] = (hex.length == 1) ? '0' + hex : hex; abgr[i] = (hex.length == 1) ? '0' + hex : hex;
} }
XSD.writeStringTextNode(node, abgr.join('')); writeStringTextNode(node, abgr.join(''));
} }
@@ -2124,7 +2124,7 @@ function writeCoordinatesTextNode(node, coordinates, objectStack) {
} }
} }
} }
XSD.writeStringTextNode(node, text); writeStringTextNode(node, text);
} }
@@ -2172,7 +2172,7 @@ function writeDataNode(node, pair, objectStack) {
* @param {string} name DisplayName. * @param {string} name DisplayName.
*/ */
function writeDataNodeName(node, name) { function writeDataNodeName(node, name) {
XSD.writeCDATASection(node, name); writeCDATASection(node, name);
} }
@@ -2181,7 +2181,7 @@ function writeDataNodeName(node, name) {
* @param {string} value Value. * @param {string} value Value.
*/ */
function writeDataNodeValue(node, value) { function writeDataNodeValue(node, value) {
XSD.writeStringTextNode(node, value); writeStringTextNode(node, value);
} }
@@ -2268,13 +2268,13 @@ const ICON_SEQUENCE = makeStructureNS(
*/ */
const ICON_SERIALIZERS = makeStructureNS( const ICON_SERIALIZERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'href': makeChildAppender(XSD.writeStringTextNode) 'href': makeChildAppender(writeStringTextNode)
}, makeStructureNS( }, makeStructureNS(
GX_NAMESPACE_URIS, { GX_NAMESPACE_URIS, {
'x': makeChildAppender(XSD.writeDecimalTextNode), 'x': makeChildAppender(writeDecimalTextNode),
'y': makeChildAppender(XSD.writeDecimalTextNode), 'y': makeChildAppender(writeDecimalTextNode),
'w': makeChildAppender(XSD.writeDecimalTextNode), 'w': makeChildAppender(writeDecimalTextNode),
'h': makeChildAppender(XSD.writeDecimalTextNode) 'h': makeChildAppender(writeDecimalTextNode)
})); }));
@@ -2329,7 +2329,7 @@ const ICON_STYLE_SEQUENCE = makeStructureNS(
const ICON_STYLE_SERIALIZERS = makeStructureNS( const ICON_STYLE_SERIALIZERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'Icon': makeChildAppender(writeIcon), 'Icon': makeChildAppender(writeIcon),
'heading': makeChildAppender(XSD.writeDecimalTextNode), 'heading': makeChildAppender(writeDecimalTextNode),
'hotSpot': makeChildAppender(writeVec2), 'hotSpot': makeChildAppender(writeVec2),
'scale': makeChildAppender(writeScaleTextNode) 'scale': makeChildAppender(writeScaleTextNode)
}); });
@@ -2455,7 +2455,7 @@ const LINE_STYLE_SEQUENCE = makeStructureNS(
const LINE_STYLE_SERIALIZERS = makeStructureNS( const LINE_STYLE_SERIALIZERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'color': makeChildAppender(writeColorTextNode), 'color': makeChildAppender(writeColorTextNode),
'width': makeChildAppender(XSD.writeDecimalTextNode) 'width': makeChildAppender(writeDecimalTextNode)
}); });
@@ -2625,28 +2625,20 @@ function writeBoundaryIs(node, linearRing, objectStack) {
*/ */
const PLACEMARK_SERIALIZERS = makeStructureNS( const PLACEMARK_SERIALIZERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'ExtendedData': makeChildAppender( 'ExtendedData': makeChildAppender(writeExtendedData),
writeExtendedData), 'MultiGeometry': makeChildAppender(writeMultiGeometry),
'MultiGeometry': makeChildAppender( 'LineString': makeChildAppender(writePrimitiveGeometry),
writeMultiGeometry), 'LinearRing': makeChildAppender(writePrimitiveGeometry),
'LineString': makeChildAppender( 'Point': makeChildAppender(writePrimitiveGeometry),
writePrimitiveGeometry),
'LinearRing': makeChildAppender(
writePrimitiveGeometry),
'Point': makeChildAppender(
writePrimitiveGeometry),
'Polygon': makeChildAppender(writePolygon), 'Polygon': makeChildAppender(writePolygon),
'Style': makeChildAppender(writeStyle), 'Style': makeChildAppender(writeStyle),
'address': makeChildAppender(XSD.writeStringTextNode), 'address': makeChildAppender(writeStringTextNode),
'description': makeChildAppender( 'description': makeChildAppender(writeStringTextNode),
XSD.writeStringTextNode), 'name': makeChildAppender(writeStringTextNode),
'name': makeChildAppender(XSD.writeStringTextNode), 'open': makeChildAppender(writeBooleanTextNode),
'open': makeChildAppender(XSD.writeBooleanTextNode), 'phoneNumber': makeChildAppender(writeStringTextNode),
'phoneNumber': makeChildAppender( 'styleUrl': makeChildAppender(writeStringTextNode),
XSD.writeStringTextNode), 'visibility': makeChildAppender(writeBooleanTextNode)
'styleUrl': makeChildAppender(XSD.writeStringTextNode),
'visibility': makeChildAppender(
XSD.writeBooleanTextNode)
}); });
@@ -2752,11 +2744,10 @@ const PRIMITIVE_GEOMETRY_SEQUENCE = makeStructureNS(
*/ */
const PRIMITIVE_GEOMETRY_SERIALIZERS = makeStructureNS( const PRIMITIVE_GEOMETRY_SERIALIZERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'extrude': makeChildAppender(XSD.writeBooleanTextNode), 'extrude': makeChildAppender(writeBooleanTextNode),
'tessellate': makeChildAppender(XSD.writeBooleanTextNode), 'tessellate': makeChildAppender(writeBooleanTextNode),
'altitudeMode': makeChildAppender(XSD.writeStringTextNode), 'altitudeMode': makeChildAppender(writeStringTextNode),
'coordinates': makeChildAppender( 'coordinates': makeChildAppender(writeCoordinatesTextNode)
writeCoordinatesTextNode)
}); });
@@ -2870,7 +2861,7 @@ function writePolyStyle(node, style, objectStack) {
*/ */
function writeScaleTextNode(node, scale) { function writeScaleTextNode(node, scale) {
// the Math is to remove any excess decimals created by float arithmetic // the Math is to remove any excess decimals created by float arithmetic
XSD.writeDecimalTextNode(node, writeDecimalTextNode(node,
Math.round(scale * 1e6) / 1e6); Math.round(scale * 1e6) / 1e6);
} }
@@ -3011,4 +3002,5 @@ KML.prototype.writeFeaturesNode = function(features, opt_options) {
this); this);
return kml; return kml;
}; };
export default KML; export default KML;
+29 -44
View File
@@ -4,7 +4,7 @@
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import {readHref} from '../format/XLink.js'; import {readHref} from '../format/XLink.js';
import XML from '../format/XML.js'; import XML from '../format/XML.js';
import XSD from '../format/XSD.js'; import {readString} from '../format/xsd.js';
import {makeObjectPropertyPusher, makeObjectPropertySetter, makeStructureNS, pushParseAndPop} from '../xml.js'; import {makeObjectPropertyPusher, makeObjectPropertySetter, makeStructureNS, pushParseAndPop} from '../xml.js';
/** /**
@@ -31,12 +31,9 @@ const NAMESPACE_URIS = [null, 'http://www.opengis.net/ows/1.1'];
*/ */
const PARSERS = makeStructureNS( const PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'ServiceIdentification': makeObjectPropertySetter( 'ServiceIdentification': makeObjectPropertySetter(readServiceIdentification),
readServiceIdentification), 'ServiceProvider': makeObjectPropertySetter(readServiceProvider),
'ServiceProvider': makeObjectPropertySetter( 'OperationsMetadata': makeObjectPropertySetter(readOperationsMetadata)
readServiceProvider),
'OperationsMetadata': makeObjectPropertySetter(
readOperationsMetadata)
}); });
@@ -46,15 +43,12 @@ const PARSERS = makeStructureNS(
*/ */
const ADDRESS_PARSERS = makeStructureNS( const ADDRESS_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'DeliveryPoint': makeObjectPropertySetter( 'DeliveryPoint': makeObjectPropertySetter(readString),
XSD.readString), 'City': makeObjectPropertySetter(readString),
'City': makeObjectPropertySetter(XSD.readString), 'AdministrativeArea': makeObjectPropertySetter(readString),
'AdministrativeArea': makeObjectPropertySetter( 'PostalCode': makeObjectPropertySetter(readString),
XSD.readString), 'Country': makeObjectPropertySetter(readString),
'PostalCode': makeObjectPropertySetter(XSD.readString), 'ElectronicMailAddress': makeObjectPropertySetter(readString)
'Country': makeObjectPropertySetter(XSD.readString),
'ElectronicMailAddress': makeObjectPropertySetter(
XSD.readString)
}); });
@@ -74,8 +68,7 @@ const ALLOWED_VALUES_PARSERS = makeStructureNS(
*/ */
const CONSTRAINT_PARSERS = makeStructureNS( const CONSTRAINT_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'AllowedValues': makeObjectPropertySetter( 'AllowedValues': makeObjectPropertySetter(readAllowedValues)
readAllowedValues)
}); });
@@ -137,8 +130,8 @@ const OPERATIONS_METADATA_PARSERS = makeStructureNS(
*/ */
const PHONE_PARSERS = makeStructureNS( const PHONE_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'Voice': makeObjectPropertySetter(XSD.readString), 'Voice': makeObjectPropertySetter(readString),
'Facsimile': makeObjectPropertySetter(XSD.readString) 'Facsimile': makeObjectPropertySetter(readString)
}); });
@@ -148,8 +141,7 @@ const PHONE_PARSERS = makeStructureNS(
*/ */
const REQUEST_METHOD_PARSERS = makeStructureNS( const REQUEST_METHOD_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'Constraint': makeObjectPropertyPusher( 'Constraint': makeObjectPropertyPusher(readConstraint)
readConstraint)
}); });
@@ -160,11 +152,9 @@ const REQUEST_METHOD_PARSERS = makeStructureNS(
const SERVICE_CONTACT_PARSERS = const SERVICE_CONTACT_PARSERS =
makeStructureNS( makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'IndividualName': makeObjectPropertySetter( 'IndividualName': makeObjectPropertySetter(readString),
XSD.readString), 'PositionName': makeObjectPropertySetter(readString),
'PositionName': makeObjectPropertySetter(XSD.readString), 'ContactInfo': makeObjectPropertySetter(readContactInfo)
'ContactInfo': makeObjectPropertySetter(
readContactInfo)
}); });
@@ -175,13 +165,12 @@ const SERVICE_CONTACT_PARSERS =
const SERVICE_IDENTIFICATION_PARSERS = const SERVICE_IDENTIFICATION_PARSERS =
makeStructureNS( makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'Abstract': makeObjectPropertySetter(XSD.readString), 'Abstract': makeObjectPropertySetter(readString),
'AccessConstraints': makeObjectPropertySetter(XSD.readString), 'AccessConstraints': makeObjectPropertySetter(readString),
'Fees': makeObjectPropertySetter(XSD.readString), 'Fees': makeObjectPropertySetter(readString),
'Title': makeObjectPropertySetter(XSD.readString), 'Title': makeObjectPropertySetter(readString),
'ServiceTypeVersion': makeObjectPropertySetter( 'ServiceTypeVersion': makeObjectPropertySetter(readString),
XSD.readString), 'ServiceType': makeObjectPropertySetter(readString)
'ServiceType': makeObjectPropertySetter(XSD.readString)
}); });
@@ -192,10 +181,9 @@ const SERVICE_IDENTIFICATION_PARSERS =
const SERVICE_PROVIDER_PARSERS = const SERVICE_PROVIDER_PARSERS =
makeStructureNS( makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'ProviderName': makeObjectPropertySetter(XSD.readString), 'ProviderName': makeObjectPropertySetter(readString),
'ProviderSite': makeObjectPropertySetter(readHref), 'ProviderSite': makeObjectPropertySetter(readHref),
'ServiceContact': makeObjectPropertySetter( 'ServiceContact': makeObjectPropertySetter(readServiceContact)
readServiceContact)
}); });
@@ -303,8 +291,7 @@ function readGet(node, objectStack) {
* @return {Object|undefined} The HTTP object. * @return {Object|undefined} The HTTP object.
*/ */
function readHttp(node, objectStack) { function readHttp(node, objectStack) {
return pushParseAndPop({}, HTTP_PARSERS, return pushParseAndPop({}, HTTP_PARSERS, node, objectStack);
node, objectStack);
} }
@@ -331,8 +318,7 @@ function readOperation(node, objectStack) {
* @param {Array.<*>} objectStack Object stack. * @param {Array.<*>} objectStack Object stack.
* @return {Object|undefined} The operations metadata. * @return {Object|undefined} The operations metadata.
*/ */
function readOperationsMetadata(node, function readOperationsMetadata(node, objectStack) {
objectStack) {
return pushParseAndPop({}, return pushParseAndPop({},
OPERATIONS_METADATA_PARSERS, node, OPERATIONS_METADATA_PARSERS, node,
objectStack); objectStack);
@@ -355,8 +341,7 @@ function readPhone(node, objectStack) {
* @param {Array.<*>} objectStack Object stack. * @param {Array.<*>} objectStack Object stack.
* @return {Object|undefined} The service identification. * @return {Object|undefined} The service identification.
*/ */
function readServiceIdentification(node, function readServiceIdentification(node, objectStack) {
objectStack) {
return pushParseAndPop( return pushParseAndPop(
{}, SERVICE_IDENTIFICATION_PARSERS, node, {}, SERVICE_IDENTIFICATION_PARSERS, node,
objectStack); objectStack);
@@ -393,7 +378,7 @@ function readServiceProvider(node, objectStack) {
* @return {string|undefined} The value. * @return {string|undefined} The value.
*/ */
function readValue(node, objectStack) { function readValue(node, objectStack) {
return XSD.readString(node); return readString(node);
} }
+19 -22
View File
@@ -5,10 +5,10 @@ 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 {readNonNegativeIntegerString, readNonNegativeInteger, writeStringTextNode} 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';
import {get as getProjection} from '../proj.js'; import {get as getProjection} from '../proj.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([],
@@ -242,7 +242,7 @@ const FEATURE_COLLECTION_PARSERS = {
*/ */
WFS.prototype.readFeatureCollectionMetadataFromNode = function(node) { WFS.prototype.readFeatureCollectionMetadataFromNode = function(node) {
const result = {}; const result = {};
const value = XSD.readNonNegativeIntegerString( const value = readNonNegativeIntegerString(
node.getAttribute('numberOfFeatures')); node.getAttribute('numberOfFeatures'));
result['numberOfFeatures'] = value; result['numberOfFeatures'] = value;
return pushParseAndPop( return pushParseAndPop(
@@ -257,12 +257,9 @@ WFS.prototype.readFeatureCollectionMetadataFromNode = function(node) {
*/ */
const TRANSACTION_SUMMARY_PARSERS = { const TRANSACTION_SUMMARY_PARSERS = {
'http://www.opengis.net/wfs': { 'http://www.opengis.net/wfs': {
'totalInserted': makeObjectPropertySetter( 'totalInserted': makeObjectPropertySetter(readNonNegativeInteger),
XSD.readNonNegativeInteger), 'totalUpdated': makeObjectPropertySetter(readNonNegativeInteger),
'totalUpdated': makeObjectPropertySetter( 'totalDeleted': makeObjectPropertySetter(readNonNegativeInteger)
XSD.readNonNegativeInteger),
'totalDeleted': makeObjectPropertySetter(
XSD.readNonNegativeInteger)
} }
}; };
@@ -366,7 +363,7 @@ WFS.prototype.readTransactionResponseFromNode = function(node) {
*/ */
const QUERY_SERIALIZERS = { const QUERY_SERIALIZERS = {
'http://www.opengis.net/wfs': { 'http://www.opengis.net/wfs': {
'PropertyName': makeChildAppender(XSD.writeStringTextNode) 'PropertyName': makeChildAppender(writeStringTextNode)
} }
}; };
@@ -507,7 +504,7 @@ function writeProperty(node, pair, objectStack) {
const context = objectStack[objectStack.length - 1]; const context = objectStack[objectStack.length - 1];
const gmlVersion = context['gmlVersion']; const gmlVersion = context['gmlVersion'];
node.appendChild(name); node.appendChild(name);
XSD.writeStringTextNode(name, pair.name); writeStringTextNode(name, pair.name);
if (pair.value !== undefined && pair.value !== null) { if (pair.value !== undefined && pair.value !== null) {
const value = createElementNS(WFSNS, 'Value'); const value = createElementNS(WFSNS, 'Value');
node.appendChild(value); node.appendChild(value);
@@ -520,7 +517,7 @@ function writeProperty(node, pair, objectStack) {
pair.value, objectStack); pair.value, objectStack);
} }
} else { } else {
XSD.writeStringTextNode(value, pair.value); writeStringTextNode(value, pair.value);
} }
} }
} }
@@ -540,7 +537,7 @@ function writeNative(node, nativeElement, objectStack) {
node.setAttribute('safeToIgnore', nativeElement.safeToIgnore); node.setAttribute('safeToIgnore', nativeElement.safeToIgnore);
} }
if (nativeElement.value !== undefined) { if (nativeElement.value !== undefined) {
XSD.writeStringTextNode(node, nativeElement.value); writeStringTextNode(node, nativeElement.value);
} }
} }
@@ -693,18 +690,18 @@ function writeWithinFilter(node, filter, objectStack) {
function writeDuringFilter(node, filter, objectStack) { function writeDuringFilter(node, filter, objectStack) {
const valueReference = createElementNS(FESNS, 'ValueReference'); const valueReference = createElementNS(FESNS, 'ValueReference');
XSD.writeStringTextNode(valueReference, filter.propertyName); 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);
} }
@@ -811,7 +808,7 @@ function writeIsLikeFilter(node, filter, objectStack) {
*/ */
function writeOgcExpression(tagName, node, value) { function writeOgcExpression(tagName, node, value) {
const property = createElementNS(OGCNS, tagName); const property = createElementNS(OGCNS, tagName);
XSD.writeStringTextNode(property, value); writeStringTextNode(property, value);
node.appendChild(property); node.appendChild(property);
} }
@@ -839,12 +836,12 @@ 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); writeStringTextNode(timePosition, time);
} }
+58 -58
View File
@@ -4,7 +4,7 @@
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import {readHref} from '../format/XLink.js'; import {readHref} from '../format/XLink.js';
import XML from '../format/XML.js'; import XML from '../format/XML.js';
import XSD from '../format/XSD.js'; import {readDecimalString, readString, readNonNegativeInteger, readDecimal, readBooleanString, readNonNegativeIntegerString} from '../format/xsd.js';
import {makeArrayPusher, makeObjectPropertyPusher, makeObjectPropertySetter, import {makeArrayPusher, makeObjectPropertyPusher, makeObjectPropertySetter,
makeStructureNS, pushParseAndPop} from '../xml.js'; makeStructureNS, pushParseAndPop} from '../xml.js';
@@ -69,17 +69,17 @@ const CAPABILITY_PARSERS = makeStructureNS(
*/ */
const SERVICE_PARSERS = makeStructureNS( const SERVICE_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'Name': makeObjectPropertySetter(XSD.readString), 'Name': makeObjectPropertySetter(readString),
'Title': makeObjectPropertySetter(XSD.readString), 'Title': makeObjectPropertySetter(readString),
'Abstract': makeObjectPropertySetter(XSD.readString), 'Abstract': makeObjectPropertySetter(readString),
'KeywordList': makeObjectPropertySetter(readKeywordList), 'KeywordList': makeObjectPropertySetter(readKeywordList),
'OnlineResource': makeObjectPropertySetter(readHref), 'OnlineResource': makeObjectPropertySetter(readHref),
'ContactInformation': makeObjectPropertySetter(readContactInformation), 'ContactInformation': makeObjectPropertySetter(readContactInformation),
'Fees': makeObjectPropertySetter(XSD.readString), 'Fees': makeObjectPropertySetter(readString),
'AccessConstraints': makeObjectPropertySetter(XSD.readString), 'AccessConstraints': makeObjectPropertySetter(readString),
'LayerLimit': makeObjectPropertySetter(XSD.readNonNegativeInteger), 'LayerLimit': makeObjectPropertySetter(readNonNegativeInteger),
'MaxWidth': makeObjectPropertySetter(XSD.readNonNegativeInteger), 'MaxWidth': makeObjectPropertySetter(readNonNegativeInteger),
'MaxHeight': makeObjectPropertySetter(XSD.readNonNegativeInteger) 'MaxHeight': makeObjectPropertySetter(readNonNegativeInteger)
}); });
@@ -90,11 +90,11 @@ const SERVICE_PARSERS = makeStructureNS(
const CONTACT_INFORMATION_PARSERS = makeStructureNS( const CONTACT_INFORMATION_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'ContactPersonPrimary': makeObjectPropertySetter(readContactPersonPrimary), 'ContactPersonPrimary': makeObjectPropertySetter(readContactPersonPrimary),
'ContactPosition': makeObjectPropertySetter(XSD.readString), 'ContactPosition': makeObjectPropertySetter(readString),
'ContactAddress': makeObjectPropertySetter(readContactAddress), 'ContactAddress': makeObjectPropertySetter(readContactAddress),
'ContactVoiceTelephone': makeObjectPropertySetter(XSD.readString), 'ContactVoiceTelephone': makeObjectPropertySetter(readString),
'ContactFacsimileTelephone': makeObjectPropertySetter(XSD.readString), 'ContactFacsimileTelephone': makeObjectPropertySetter(readString),
'ContactElectronicMailAddress': makeObjectPropertySetter(XSD.readString) 'ContactElectronicMailAddress': makeObjectPropertySetter(readString)
}); });
@@ -104,8 +104,8 @@ const CONTACT_INFORMATION_PARSERS = makeStructureNS(
*/ */
const CONTACT_PERSON_PARSERS = makeStructureNS( const CONTACT_PERSON_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'ContactPerson': makeObjectPropertySetter(XSD.readString), 'ContactPerson': makeObjectPropertySetter(readString),
'ContactOrganization': makeObjectPropertySetter(XSD.readString) 'ContactOrganization': makeObjectPropertySetter(readString)
}); });
@@ -115,12 +115,12 @@ const CONTACT_PERSON_PARSERS = makeStructureNS(
*/ */
const CONTACT_ADDRESS_PARSERS = makeStructureNS( const CONTACT_ADDRESS_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'AddressType': makeObjectPropertySetter(XSD.readString), 'AddressType': makeObjectPropertySetter(readString),
'Address': makeObjectPropertySetter(XSD.readString), 'Address': makeObjectPropertySetter(readString),
'City': makeObjectPropertySetter(XSD.readString), 'City': makeObjectPropertySetter(readString),
'StateOrProvince': makeObjectPropertySetter(XSD.readString), 'StateOrProvince': makeObjectPropertySetter(readString),
'PostCode': makeObjectPropertySetter(XSD.readString), 'PostCode': makeObjectPropertySetter(readString),
'Country': makeObjectPropertySetter(XSD.readString) 'Country': makeObjectPropertySetter(readString)
}); });
@@ -130,7 +130,7 @@ const CONTACT_ADDRESS_PARSERS = makeStructureNS(
*/ */
const EXCEPTION_PARSERS = makeStructureNS( const EXCEPTION_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'Format': makeArrayPusher(XSD.readString) 'Format': makeArrayPusher(readString)
}); });
@@ -140,23 +140,23 @@ const EXCEPTION_PARSERS = makeStructureNS(
*/ */
const LAYER_PARSERS = makeStructureNS( const LAYER_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'Name': makeObjectPropertySetter(XSD.readString), 'Name': makeObjectPropertySetter(readString),
'Title': makeObjectPropertySetter(XSD.readString), 'Title': makeObjectPropertySetter(readString),
'Abstract': makeObjectPropertySetter(XSD.readString), 'Abstract': makeObjectPropertySetter(readString),
'KeywordList': makeObjectPropertySetter(readKeywordList), 'KeywordList': makeObjectPropertySetter(readKeywordList),
'CRS': makeObjectPropertyPusher(XSD.readString), 'CRS': makeObjectPropertyPusher(readString),
'EX_GeographicBoundingBox': makeObjectPropertySetter(readEXGeographicBoundingBox), 'EX_GeographicBoundingBox': makeObjectPropertySetter(readEXGeographicBoundingBox),
'BoundingBox': makeObjectPropertyPusher(readBoundingBox), 'BoundingBox': makeObjectPropertyPusher(readBoundingBox),
'Dimension': makeObjectPropertyPusher(readDimension), 'Dimension': makeObjectPropertyPusher(readDimension),
'Attribution': makeObjectPropertySetter(readAttribution), 'Attribution': makeObjectPropertySetter(readAttribution),
'AuthorityURL': makeObjectPropertyPusher(readAuthorityURL), 'AuthorityURL': makeObjectPropertyPusher(readAuthorityURL),
'Identifier': makeObjectPropertyPusher(XSD.readString), 'Identifier': makeObjectPropertyPusher(readString),
'MetadataURL': makeObjectPropertyPusher(readMetadataURL), 'MetadataURL': makeObjectPropertyPusher(readMetadataURL),
'DataURL': makeObjectPropertyPusher(readFormatOnlineresource), 'DataURL': makeObjectPropertyPusher(readFormatOnlineresource),
'FeatureListURL': makeObjectPropertyPusher(readFormatOnlineresource), 'FeatureListURL': makeObjectPropertyPusher(readFormatOnlineresource),
'Style': makeObjectPropertyPusher(readStyle), 'Style': makeObjectPropertyPusher(readStyle),
'MinScaleDenominator': makeObjectPropertySetter(XSD.readDecimal), 'MinScaleDenominator': makeObjectPropertySetter(readDecimal),
'MaxScaleDenominator': makeObjectPropertySetter(XSD.readDecimal), 'MaxScaleDenominator': makeObjectPropertySetter(readDecimal),
'Layer': makeObjectPropertyPusher(readLayer) 'Layer': makeObjectPropertyPusher(readLayer)
}); });
@@ -167,7 +167,7 @@ const LAYER_PARSERS = makeStructureNS(
*/ */
const ATTRIBUTION_PARSERS = makeStructureNS( const ATTRIBUTION_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'Title': makeObjectPropertySetter(XSD.readString), 'Title': makeObjectPropertySetter(readString),
'OnlineResource': makeObjectPropertySetter(readHref), 'OnlineResource': makeObjectPropertySetter(readHref),
'LogoURL': makeObjectPropertySetter(readSizedFormatOnlineresource) 'LogoURL': makeObjectPropertySetter(readSizedFormatOnlineresource)
}); });
@@ -179,10 +179,10 @@ const ATTRIBUTION_PARSERS = makeStructureNS(
*/ */
const EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS = const EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS =
makeStructureNS(NAMESPACE_URIS, { makeStructureNS(NAMESPACE_URIS, {
'westBoundLongitude': makeObjectPropertySetter(XSD.readDecimal), 'westBoundLongitude': makeObjectPropertySetter(readDecimal),
'eastBoundLongitude': makeObjectPropertySetter(XSD.readDecimal), 'eastBoundLongitude': makeObjectPropertySetter(readDecimal),
'southBoundLatitude': makeObjectPropertySetter(XSD.readDecimal), 'southBoundLatitude': makeObjectPropertySetter(readDecimal),
'northBoundLatitude': makeObjectPropertySetter(XSD.readDecimal) 'northBoundLatitude': makeObjectPropertySetter(readDecimal)
}); });
@@ -204,7 +204,7 @@ const REQUEST_PARSERS = makeStructureNS(
*/ */
const OPERATIONTYPE_PARSERS = makeStructureNS( const OPERATIONTYPE_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'Format': makeObjectPropertyPusher(XSD.readString), 'Format': makeObjectPropertyPusher(readString),
'DCPType': makeObjectPropertyPusher(readDCPType) 'DCPType': makeObjectPropertyPusher(readDCPType)
}); });
@@ -236,9 +236,9 @@ const HTTP_PARSERS = makeStructureNS(
*/ */
const STYLE_PARSERS = makeStructureNS( const STYLE_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'Name': makeObjectPropertySetter(XSD.readString), 'Name': makeObjectPropertySetter(readString),
'Title': makeObjectPropertySetter(XSD.readString), 'Title': makeObjectPropertySetter(readString),
'Abstract': makeObjectPropertySetter(XSD.readString), 'Abstract': makeObjectPropertySetter(readString),
'LegendURL': makeObjectPropertyPusher(readSizedFormatOnlineresource), 'LegendURL': makeObjectPropertyPusher(readSizedFormatOnlineresource),
'StyleSheetURL': makeObjectPropertySetter(readFormatOnlineresource), 'StyleSheetURL': makeObjectPropertySetter(readFormatOnlineresource),
'StyleURL': makeObjectPropertySetter(readFormatOnlineresource) 'StyleURL': makeObjectPropertySetter(readFormatOnlineresource)
@@ -251,7 +251,7 @@ const STYLE_PARSERS = makeStructureNS(
*/ */
const FORMAT_ONLINERESOURCE_PARSERS = const FORMAT_ONLINERESOURCE_PARSERS =
makeStructureNS(NAMESPACE_URIS, { makeStructureNS(NAMESPACE_URIS, {
'Format': makeObjectPropertySetter(XSD.readString), 'Format': makeObjectPropertySetter(readString),
'OnlineResource': makeObjectPropertySetter(readHref) 'OnlineResource': makeObjectPropertySetter(readHref)
}); });
@@ -262,7 +262,7 @@ const FORMAT_ONLINERESOURCE_PARSERS =
*/ */
const KEYWORDLIST_PARSERS = makeStructureNS( const KEYWORDLIST_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'Keyword': makeArrayPusher(XSD.readString) 'Keyword': makeArrayPusher(readString)
}); });
@@ -319,15 +319,15 @@ function readAttribution(node, objectStack) {
*/ */
function readBoundingBox(node, objectStack) { function readBoundingBox(node, objectStack) {
const extent = [ const extent = [
XSD.readDecimalString(node.getAttribute('minx')), readDecimalString(node.getAttribute('minx')),
XSD.readDecimalString(node.getAttribute('miny')), readDecimalString(node.getAttribute('miny')),
XSD.readDecimalString(node.getAttribute('maxx')), readDecimalString(node.getAttribute('maxx')),
XSD.readDecimalString(node.getAttribute('maxy')) readDecimalString(node.getAttribute('maxy'))
]; ];
const resolutions = [ const resolutions = [
XSD.readDecimalString(node.getAttribute('resx')), readDecimalString(node.getAttribute('resx')),
XSD.readDecimalString(node.getAttribute('resy')) readDecimalString(node.getAttribute('resy'))
]; ];
return { return {
@@ -454,38 +454,38 @@ function readLayer(node, objectStack) {
if (!layerObject) { if (!layerObject) {
return undefined; return undefined;
} }
let queryable = XSD.readBooleanString(node.getAttribute('queryable')); let queryable = readBooleanString(node.getAttribute('queryable'));
if (queryable === undefined) { if (queryable === undefined) {
queryable = parentLayerObject['queryable']; queryable = parentLayerObject['queryable'];
} }
layerObject['queryable'] = queryable !== undefined ? queryable : false; layerObject['queryable'] = queryable !== undefined ? queryable : false;
let cascaded = XSD.readNonNegativeIntegerString( let cascaded = readNonNegativeIntegerString(
node.getAttribute('cascaded')); node.getAttribute('cascaded'));
if (cascaded === undefined) { if (cascaded === undefined) {
cascaded = parentLayerObject['cascaded']; cascaded = parentLayerObject['cascaded'];
} }
layerObject['cascaded'] = cascaded; layerObject['cascaded'] = cascaded;
let opaque = XSD.readBooleanString(node.getAttribute('opaque')); let opaque = readBooleanString(node.getAttribute('opaque'));
if (opaque === undefined) { if (opaque === undefined) {
opaque = parentLayerObject['opaque']; opaque = parentLayerObject['opaque'];
} }
layerObject['opaque'] = opaque !== undefined ? opaque : false; layerObject['opaque'] = opaque !== undefined ? opaque : false;
let noSubsets = XSD.readBooleanString(node.getAttribute('noSubsets')); let noSubsets = readBooleanString(node.getAttribute('noSubsets'));
if (noSubsets === undefined) { if (noSubsets === undefined) {
noSubsets = parentLayerObject['noSubsets']; noSubsets = parentLayerObject['noSubsets'];
} }
layerObject['noSubsets'] = noSubsets !== undefined ? noSubsets : false; layerObject['noSubsets'] = noSubsets !== undefined ? noSubsets : false;
let fixedWidth = XSD.readDecimalString(node.getAttribute('fixedWidth')); let fixedWidth = readDecimalString(node.getAttribute('fixedWidth'));
if (!fixedWidth) { if (!fixedWidth) {
fixedWidth = parentLayerObject['fixedWidth']; fixedWidth = parentLayerObject['fixedWidth'];
} }
layerObject['fixedWidth'] = fixedWidth; layerObject['fixedWidth'] = fixedWidth;
let fixedHeight = XSD.readDecimalString(node.getAttribute('fixedHeight')); let fixedHeight = readDecimalString(node.getAttribute('fixedHeight'));
if (!fixedHeight) { if (!fixedHeight) {
fixedHeight = parentLayerObject['fixedHeight']; fixedHeight = parentLayerObject['fixedHeight'];
} }
@@ -524,10 +524,10 @@ function readDimension(node, objectStack) {
'units': node.getAttribute('units'), 'units': node.getAttribute('units'),
'unitSymbol': node.getAttribute('unitSymbol'), 'unitSymbol': node.getAttribute('unitSymbol'),
'default': node.getAttribute('default'), 'default': node.getAttribute('default'),
'multipleValues': XSD.readBooleanString(node.getAttribute('multipleValues')), 'multipleValues': readBooleanString(node.getAttribute('multipleValues')),
'nearestValue': XSD.readBooleanString(node.getAttribute('nearestValue')), 'nearestValue': readBooleanString(node.getAttribute('nearestValue')),
'current': XSD.readBooleanString(node.getAttribute('current')), 'current': readBooleanString(node.getAttribute('current')),
'values': XSD.readString(node) 'values': readString(node)
}; };
return dimensionObject; return dimensionObject;
} }
@@ -592,8 +592,8 @@ function readSizedFormatOnlineresource(node, objectStack) {
const formatOnlineresource = readFormatOnlineresource(node, objectStack); const formatOnlineresource = readFormatOnlineresource(node, objectStack);
if (formatOnlineresource) { if (formatOnlineresource) {
const size = [ const size = [
XSD.readNonNegativeIntegerString(node.getAttribute('width')), readNonNegativeIntegerString(node.getAttribute('width')),
XSD.readNonNegativeIntegerString(node.getAttribute('height')) readNonNegativeIntegerString(node.getAttribute('height'))
]; ];
formatOnlineresource['size'] = size; formatOnlineresource['size'] = size;
return formatOnlineresource; return formatOnlineresource;
+26 -26
View File
@@ -6,7 +6,7 @@ import {boundingExtent} from '../extent.js';
import OWS from '../format/OWS.js'; import OWS from '../format/OWS.js';
import {readHref} from '../format/XLink.js'; import {readHref} from '../format/XLink.js';
import XML from '../format/XML.js'; import XML from '../format/XML.js';
import XSD from '../format/XSD.js'; import {readString, readNonNegativeInteger, readDecimal} from '../format/xsd.js';
import {pushParseAndPop, makeStructureNS, import {pushParseAndPop, makeStructureNS,
makeObjectPropertySetter, makeObjectPropertyPusher, makeArrayPusher} from '../xml.js'; makeObjectPropertySetter, makeObjectPropertyPusher, makeArrayPusher} from '../xml.js';
@@ -79,15 +79,15 @@ const CONTENTS_PARSERS = makeStructureNS(
const LAYER_PARSERS = makeStructureNS( const LAYER_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'Style': makeObjectPropertyPusher(readStyle), 'Style': makeObjectPropertyPusher(readStyle),
'Format': makeObjectPropertyPusher(XSD.readString), 'Format': makeObjectPropertyPusher(readString),
'TileMatrixSetLink': makeObjectPropertyPusher(readTileMatrixSetLink), 'TileMatrixSetLink': makeObjectPropertyPusher(readTileMatrixSetLink),
'Dimension': makeObjectPropertyPusher(readDimensions), 'Dimension': makeObjectPropertyPusher(readDimensions),
'ResourceURL': makeObjectPropertyPusher(readResourceUrl) 'ResourceURL': makeObjectPropertyPusher(readResourceUrl)
}, makeStructureNS(OWS_NAMESPACE_URIS, { }, makeStructureNS(OWS_NAMESPACE_URIS, {
'Title': makeObjectPropertySetter(XSD.readString), 'Title': makeObjectPropertySetter(readString),
'Abstract': makeObjectPropertySetter(XSD.readString), 'Abstract': makeObjectPropertySetter(readString),
'WGS84BoundingBox': makeObjectPropertySetter(readWgs84BoundingBox), 'WGS84BoundingBox': makeObjectPropertySetter(readWgs84BoundingBox),
'Identifier': makeObjectPropertySetter(XSD.readString) 'Identifier': makeObjectPropertySetter(readString)
})); }));
@@ -99,8 +99,8 @@ const STYLE_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'LegendURL': makeObjectPropertyPusher(readLegendUrl) 'LegendURL': makeObjectPropertyPusher(readLegendUrl)
}, makeStructureNS(OWS_NAMESPACE_URIS, { }, makeStructureNS(OWS_NAMESPACE_URIS, {
'Title': makeObjectPropertySetter(XSD.readString), 'Title': makeObjectPropertySetter(readString),
'Identifier': makeObjectPropertySetter(XSD.readString) 'Identifier': makeObjectPropertySetter(readString)
})); }));
@@ -110,7 +110,7 @@ const STYLE_PARSERS = makeStructureNS(
*/ */
const TMS_LINKS_PARSERS = makeStructureNS( const TMS_LINKS_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'TileMatrixSet': makeObjectPropertySetter(XSD.readString), 'TileMatrixSet': makeObjectPropertySetter(readString),
'TileMatrixSetLimits': makeObjectPropertySetter(readTileMatrixLimitsList) 'TileMatrixSetLimits': makeObjectPropertySetter(readTileMatrixLimitsList)
}); });
@@ -130,11 +130,11 @@ const TMS_LIMITS_LIST_PARSERS = makeStructureNS(
*/ */
const TMS_LIMITS_PARSERS = makeStructureNS( const TMS_LIMITS_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'TileMatrix': makeObjectPropertySetter(XSD.readString), 'TileMatrix': makeObjectPropertySetter(readString),
'MinTileRow': makeObjectPropertySetter(XSD.readNonNegativeInteger), 'MinTileRow': makeObjectPropertySetter(readNonNegativeInteger),
'MaxTileRow': makeObjectPropertySetter(XSD.readNonNegativeInteger), 'MaxTileRow': makeObjectPropertySetter(readNonNegativeInteger),
'MinTileCol': makeObjectPropertySetter(XSD.readNonNegativeInteger), 'MinTileCol': makeObjectPropertySetter(readNonNegativeInteger),
'MaxTileCol': makeObjectPropertySetter(XSD.readNonNegativeInteger) 'MaxTileCol': makeObjectPropertySetter(readNonNegativeInteger)
}); });
@@ -144,10 +144,10 @@ const TMS_LIMITS_PARSERS = makeStructureNS(
*/ */
const DIMENSION_PARSERS = makeStructureNS( const DIMENSION_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'Default': makeObjectPropertySetter(XSD.readString), 'Default': makeObjectPropertySetter(readString),
'Value': makeObjectPropertyPusher(XSD.readString) 'Value': makeObjectPropertyPusher(readString)
}, makeStructureNS(OWS_NAMESPACE_URIS, { }, makeStructureNS(OWS_NAMESPACE_URIS, {
'Identifier': makeObjectPropertySetter(XSD.readString) 'Identifier': makeObjectPropertySetter(readString)
})); }));
@@ -168,11 +168,11 @@ const WGS84_BBOX_READERS = makeStructureNS(
*/ */
const TMS_PARSERS = makeStructureNS( const TMS_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'WellKnownScaleSet': makeObjectPropertySetter(XSD.readString), 'WellKnownScaleSet': makeObjectPropertySetter(readString),
'TileMatrix': makeObjectPropertyPusher(readTileMatrix) 'TileMatrix': makeObjectPropertyPusher(readTileMatrix)
}, makeStructureNS(OWS_NAMESPACE_URIS, { }, makeStructureNS(OWS_NAMESPACE_URIS, {
'SupportedCRS': makeObjectPropertySetter(XSD.readString), 'SupportedCRS': makeObjectPropertySetter(readString),
'Identifier': makeObjectPropertySetter(XSD.readString) 'Identifier': makeObjectPropertySetter(readString)
})); }));
@@ -183,13 +183,13 @@ const TMS_PARSERS = makeStructureNS(
const TM_PARSERS = makeStructureNS( const TM_PARSERS = makeStructureNS(
NAMESPACE_URIS, { NAMESPACE_URIS, {
'TopLeftCorner': makeObjectPropertySetter(readCoordinates), 'TopLeftCorner': makeObjectPropertySetter(readCoordinates),
'ScaleDenominator': makeObjectPropertySetter(XSD.readDecimal), 'ScaleDenominator': makeObjectPropertySetter(readDecimal),
'TileWidth': makeObjectPropertySetter(XSD.readNonNegativeInteger), 'TileWidth': makeObjectPropertySetter(readNonNegativeInteger),
'TileHeight': makeObjectPropertySetter(XSD.readNonNegativeInteger), 'TileHeight': makeObjectPropertySetter(readNonNegativeInteger),
'MatrixWidth': makeObjectPropertySetter(XSD.readNonNegativeInteger), 'MatrixWidth': makeObjectPropertySetter(readNonNegativeInteger),
'MatrixHeight': makeObjectPropertySetter(XSD.readNonNegativeInteger) 'MatrixHeight': makeObjectPropertySetter(readNonNegativeInteger)
}, makeStructureNS(OWS_NAMESPACE_URIS, { }, makeStructureNS(OWS_NAMESPACE_URIS, {
'Identifier': makeObjectPropertySetter(XSD.readString) 'Identifier': makeObjectPropertySetter(readString)
})); }));
@@ -355,7 +355,7 @@ function readLegendUrl(node, objectStack) {
* @return {Object|undefined} Coordinates object. * @return {Object|undefined} Coordinates object.
*/ */
function readCoordinates(node, objectStack) { function readCoordinates(node, objectStack) {
const coordinates = XSD.readString(node).split(' '); const coordinates = readString(node).split(' ');
if (!coordinates || coordinates.length != 2) { if (!coordinates || coordinates.length != 2) {
return undefined; return undefined;
} }
+33 -35
View File
@@ -1,61 +1,60 @@
/** /**
* @module ol/format/XSD * @module ol/format/xsd
*/ */
import {getAllTextContent, DOCUMENT} from '../xml.js'; import {getAllTextContent, DOCUMENT} from '../xml.js';
import {padNumber} from '../string.js'; import {padNumber} from '../string.js';
const XSD = {};
/** /**
* @param {Node} node Node. * @param {Node} node Node.
* @return {boolean|undefined} Boolean. * @return {boolean|undefined} Boolean.
*/ */
XSD.readBoolean = function(node) { export function readBoolean(node) {
const s = getAllTextContent(node, false); const s = getAllTextContent(node, false);
return XSD.readBooleanString(s); return readBooleanString(s);
}; }
/** /**
* @param {string} string String. * @param {string} string String.
* @return {boolean|undefined} Boolean. * @return {boolean|undefined} Boolean.
*/ */
XSD.readBooleanString = function(string) { export function readBooleanString(string) {
const m = /^\s*(true|1)|(false|0)\s*$/.exec(string); const m = /^\s*(true|1)|(false|0)\s*$/.exec(string);
if (m) { if (m) {
return m[1] !== undefined || false; return m[1] !== undefined || false;
} else { } else {
return undefined; return undefined;
} }
}; }
/** /**
* @param {Node} node Node. * @param {Node} node Node.
* @return {number|undefined} DateTime in seconds. * @return {number|undefined} DateTime in seconds.
*/ */
XSD.readDateTime = function(node) { export function readDateTime(node) {
const s = getAllTextContent(node, false); const s = getAllTextContent(node, false);
const dateTime = Date.parse(s); const dateTime = Date.parse(s);
return isNaN(dateTime) ? undefined : dateTime / 1000; return isNaN(dateTime) ? undefined : dateTime / 1000;
}; }
/** /**
* @param {Node} node Node. * @param {Node} node Node.
* @return {number|undefined} Decimal. * @return {number|undefined} Decimal.
*/ */
XSD.readDecimal = function(node) { export function readDecimal(node) {
const s = getAllTextContent(node, false); const s = getAllTextContent(node, false);
return XSD.readDecimalString(s); return readDecimalString(s);
}; }
/** /**
* @param {string} string String. * @param {string} string String.
* @return {number|undefined} Decimal. * @return {number|undefined} Decimal.
*/ */
XSD.readDecimalString = function(string) { export function readDecimalString(string) {
// FIXME check spec // FIXME check spec
const m = /^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(string); const m = /^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(string);
if (m) { if (m) {
@@ -63,65 +62,65 @@ XSD.readDecimalString = function(string) {
} else { } else {
return undefined; return undefined;
} }
}; }
/** /**
* @param {Node} node Node. * @param {Node} node Node.
* @return {number|undefined} Non negative integer. * @return {number|undefined} Non negative integer.
*/ */
XSD.readNonNegativeInteger = function(node) { export function readNonNegativeInteger(node) {
const s = getAllTextContent(node, false); const s = getAllTextContent(node, false);
return XSD.readNonNegativeIntegerString(s); return readNonNegativeIntegerString(s);
}; }
/** /**
* @param {string} string String. * @param {string} string String.
* @return {number|undefined} Non negative integer. * @return {number|undefined} Non negative integer.
*/ */
XSD.readNonNegativeIntegerString = function(string) { export function readNonNegativeIntegerString(string) {
const m = /^\s*(\d+)\s*$/.exec(string); const m = /^\s*(\d+)\s*$/.exec(string);
if (m) { if (m) {
return parseInt(m[1], 10); return parseInt(m[1], 10);
} else { } else {
return undefined; return undefined;
} }
}; }
/** /**
* @param {Node} node Node. * @param {Node} node Node.
* @return {string|undefined} String. * @return {string|undefined} String.
*/ */
XSD.readString = function(node) { export function readString(node) {
return getAllTextContent(node, false).trim(); return getAllTextContent(node, false).trim();
}; }
/** /**
* @param {Node} node Node to append a TextNode with the boolean to. * @param {Node} node Node to append a TextNode with the boolean to.
* @param {boolean} bool Boolean. * @param {boolean} bool Boolean.
*/ */
XSD.writeBooleanTextNode = function(node, bool) { export function writeBooleanTextNode(node, bool) {
XSD.writeStringTextNode(node, (bool) ? '1' : '0'); writeStringTextNode(node, (bool) ? '1' : '0');
}; }
/** /**
* @param {Node} node Node to append a CDATA Section with the string to. * @param {Node} node Node to append a CDATA Section with the string to.
* @param {string} string String. * @param {string} string String.
*/ */
XSD.writeCDATASection = function(node, string) { export function writeCDATASection(node, string) {
node.appendChild(DOCUMENT.createCDATASection(string)); node.appendChild(DOCUMENT.createCDATASection(string));
}; }
/** /**
* @param {Node} node Node to append a TextNode with the dateTime to. * @param {Node} node Node to append a TextNode with the dateTime to.
* @param {number} dateTime DateTime in seconds. * @param {number} dateTime DateTime in seconds.
*/ */
XSD.writeDateTimeTextNode = function(node, dateTime) { export function writeDateTimeTextNode(node, dateTime) {
const date = new Date(dateTime * 1000); const date = new Date(dateTime * 1000);
const string = date.getUTCFullYear() + '-' + const string = date.getUTCFullYear() + '-' +
padNumber(date.getUTCMonth() + 1, 2) + '-' + padNumber(date.getUTCMonth() + 1, 2) + '-' +
@@ -130,34 +129,33 @@ XSD.writeDateTimeTextNode = function(node, dateTime) {
padNumber(date.getUTCMinutes(), 2) + ':' + padNumber(date.getUTCMinutes(), 2) + ':' +
padNumber(date.getUTCSeconds(), 2) + 'Z'; padNumber(date.getUTCSeconds(), 2) + 'Z';
node.appendChild(DOCUMENT.createTextNode(string)); node.appendChild(DOCUMENT.createTextNode(string));
}; }
/** /**
* @param {Node} node Node to append a TextNode with the decimal to. * @param {Node} node Node to append a TextNode with the decimal to.
* @param {number} decimal Decimal. * @param {number} decimal Decimal.
*/ */
XSD.writeDecimalTextNode = function(node, decimal) { export function writeDecimalTextNode(node, decimal) {
const string = decimal.toPrecision(); const string = decimal.toPrecision();
node.appendChild(DOCUMENT.createTextNode(string)); node.appendChild(DOCUMENT.createTextNode(string));
}; }
/** /**
* @param {Node} node Node to append a TextNode with the decimal to. * @param {Node} node Node to append a TextNode with the decimal to.
* @param {number} nonNegativeInteger Non negative integer. * @param {number} nonNegativeInteger Non negative integer.
*/ */
XSD.writeNonNegativeIntegerTextNode = function(node, nonNegativeInteger) { export function writeNonNegativeIntegerTextNode(node, nonNegativeInteger) {
const string = nonNegativeInteger.toString(); const string = nonNegativeInteger.toString();
node.appendChild(DOCUMENT.createTextNode(string)); node.appendChild(DOCUMENT.createTextNode(string));
}; }
/** /**
* @param {Node} node Node to append a TextNode with the string to. * @param {Node} node Node to append a TextNode with the string to.
* @param {string} string String. * @param {string} string String.
*/ */
XSD.writeStringTextNode = function(node, string) { export function writeStringTextNode(node, string) {
node.appendChild(DOCUMENT.createTextNode(string)); node.appendChild(DOCUMENT.createTextNode(string));
}; }
export default XSD;
+3 -2
View File
@@ -321,7 +321,7 @@ SimpleGeometry.prototype.translate = function(deltaX, deltaY) {
* @param {Array.<number>=} opt_dest Destination. * @param {Array.<number>=} opt_dest Destination.
* @return {Array.<number>} Transformed flat coordinates. * @return {Array.<number>} Transformed flat coordinates.
*/ */
SimpleGeometry.transform2D = function(simpleGeometry, transform, opt_dest) { export function transformGeom2D(simpleGeometry, transform, opt_dest) {
const flatCoordinates = simpleGeometry.getFlatCoordinates(); const flatCoordinates = simpleGeometry.getFlatCoordinates();
if (!flatCoordinates) { if (!flatCoordinates) {
return null; return null;
@@ -331,5 +331,6 @@ SimpleGeometry.transform2D = function(simpleGeometry, transform, opt_dest) {
flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates, 0, flatCoordinates.length, stride,
transform, opt_dest); transform, opt_dest);
} }
}; }
export default SimpleGeometry; export default SimpleGeometry;
+4 -4
View File
@@ -25,7 +25,7 @@ const DoubleClickZoom = function(opt_options) {
this.delta_ = options.delta ? options.delta : 1; this.delta_ = options.delta ? options.delta : 1;
Interaction.call(this, { Interaction.call(this, {
handleEvent: DoubleClickZoom.handleEvent handleEvent: handleEvent
}); });
/** /**
@@ -45,9 +45,8 @@ inherits(DoubleClickZoom, Interaction);
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event. * @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation. * @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.DoubleClickZoom} * @this {ol.interaction.DoubleClickZoom}
* @api
*/ */
DoubleClickZoom.handleEvent = function(mapBrowserEvent) { function handleEvent(mapBrowserEvent) {
let stopEvent = false; let stopEvent = false;
const browserEvent = mapBrowserEvent.originalEvent; const browserEvent = mapBrowserEvent.originalEvent;
if (mapBrowserEvent.type == MapBrowserEventType.DBLCLICK) { if (mapBrowserEvent.type == MapBrowserEventType.DBLCLICK) {
@@ -60,5 +59,6 @@ DoubleClickZoom.handleEvent = function(mapBrowserEvent) {
stopEvent = true; stopEvent = true;
} }
return !stopEvent; return !stopEvent;
}; }
export default DoubleClickZoom; export default DoubleClickZoom;
+46 -56
View File
@@ -18,20 +18,62 @@ import {get as getProjection} from '../proj.js';
const DragAndDropEventType = { const DragAndDropEventType = {
/** /**
* Triggered when features are added * Triggered when features are added
* @event ol.interaction.DragAndDrop.Event#addfeatures * @event ol.interaction.DragAndDropEvent#addfeatures
* @api * @api
*/ */
ADD_FEATURES: 'addfeatures' ADD_FEATURES: 'addfeatures'
}; };
/**
* @classdesc
* Events emitted by {@link ol.interaction.DragAndDrop} instances are instances
* of this type.
*
* @constructor
* @extends {ol.events.Event}
* @implements {oli.interaction.DragAndDropEvent}
* @param {ol.interaction.DragAndDropEventType} type Type.
* @param {File} file File.
* @param {Array.<ol.Feature>=} opt_features Features.
* @param {ol.proj.Projection=} opt_projection Projection.
*/
const DragAndDropEvent = function(type, file, opt_features, opt_projection) {
Event.call(this, type);
/**
* The features parsed from dropped data.
* @type {Array.<ol.Feature>|undefined}
* @api
*/
this.features = opt_features;
/**
* The dropped file.
* @type {File}
* @api
*/
this.file = file;
/**
* The feature projection.
* @type {ol.proj.Projection|undefined}
* @api
*/
this.projection = opt_projection;
};
inherits(DragAndDropEvent, Event);
/** /**
* @classdesc * @classdesc
* Handles input of vector data by drag and drop. * Handles input of vector data by drag and drop.
* *
* @constructor * @constructor
* @extends {ol.interaction.Interaction} * @extends {ol.interaction.Interaction}
* @fires ol.interaction.DragAndDrop.Event * @fires ol.interaction.DragAndDropEvent
* @param {olx.interaction.DragAndDropOptions=} opt_options Options. * @param {olx.interaction.DragAndDropOptions=} opt_options Options.
* @api * @api
*/ */
@@ -40,7 +82,7 @@ const DragAndDrop = function(opt_options) {
const options = opt_options ? opt_options : {}; const options = opt_options ? opt_options : {};
Interaction.call(this, { Interaction.call(this, {
handleEvent: DragAndDrop.handleEvent handleEvent: TRUE
}); });
/** /**
@@ -146,23 +188,12 @@ DragAndDrop.prototype.handleResult_ = function(file, event) {
this.source_.addFeatures(features); this.source_.addFeatures(features);
} }
this.dispatchEvent( this.dispatchEvent(
new DragAndDrop.Event( new DragAndDropEvent(
DragAndDropEventType.ADD_FEATURES, file, DragAndDropEventType.ADD_FEATURES, file,
features, projection)); features, projection));
}; };
/**
* Handles the {@link ol.MapBrowserEvent map browser event} unconditionally and
* neither prevents the browser default nor stops event propagation.
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.DragAndDrop}
* @api
*/
DragAndDrop.handleEvent = TRUE;
/** /**
* @private * @private
*/ */
@@ -236,45 +267,4 @@ DragAndDrop.prototype.unregisterListeners_ = function() {
}; };
/**
* @classdesc
* Events emitted by {@link ol.interaction.DragAndDrop} instances are instances
* of this type.
*
* @constructor
* @extends {ol.events.Event}
* @implements {oli.interaction.DragAndDropEvent}
* @param {ol.interaction.DragAndDropEventType} type Type.
* @param {File} file File.
* @param {Array.<ol.Feature>=} opt_features Features.
* @param {ol.proj.Projection=} opt_projection Projection.
*/
DragAndDrop.Event = function(type, file, opt_features, opt_projection) {
Event.call(this, type);
/**
* The features parsed from dropped data.
* @type {Array.<ol.Feature>|undefined}
* @api
*/
this.features = opt_features;
/**
* The dropped file.
* @type {File}
* @api
*/
this.file = file;
/**
* The feature projection.
* @type {ol.proj.Projection|undefined}
* @api
*/
this.projection = opt_projection;
};
inherits(DragAndDrop.Event, Event);
export default DragAndDrop; export default DragAndDrop;
+2 -2
View File
@@ -23,7 +23,7 @@ import MouseSource from '../pointer/MouseSource.js';
import Point from '../geom/Point.js'; import Point from '../geom/Point.js';
import Polygon, {fromCircle, makeRegular} from '../geom/Polygon.js'; import Polygon, {fromCircle, makeRegular} from '../geom/Polygon.js';
import DrawEventType from '../interaction/DrawEventType.js'; import DrawEventType from '../interaction/DrawEventType.js';
import PointerInteraction from '../interaction/Pointer.js'; import PointerInteraction, {handleEvent as handlePointerEvent} from '../interaction/Pointer.js';
import InteractionProperty from '../interaction/Property.js'; import InteractionProperty from '../interaction/Property.js';
import VectorLayer from '../layer/Vector.js'; import VectorLayer from '../layer/Vector.js';
import VectorSource from '../source/Vector.js'; import VectorSource from '../source/Vector.js';
@@ -398,7 +398,7 @@ export function handleEvent(event) {
pass = false; pass = false;
} }
return PointerInteraction.handleEvent.call(this, event) && pass; return handlePointerEvent.call(this, event) && pass;
} }
+2 -2
View File
@@ -12,7 +12,7 @@ import GeometryType from '../geom/GeometryType.js';
import Point from '../geom/Point.js'; import Point from '../geom/Point.js';
import {fromExtent as polygonFromExtent} from '../geom/Polygon.js'; import {fromExtent as polygonFromExtent} from '../geom/Polygon.js';
import ExtentEventType from '../interaction/ExtentEventType.js'; import ExtentEventType from '../interaction/ExtentEventType.js';
import PointerInteraction from '../interaction/Pointer.js'; import PointerInteraction, {handleEvent as handlePointerEvent} from '../interaction/Pointer.js';
import VectorLayer from '../layer/Vector.js'; import VectorLayer from '../layer/Vector.js';
import VectorSource from '../source/Vector.js'; import VectorSource from '../source/Vector.js';
import Style from '../style/Style.js'; import Style from '../style/Style.js';
@@ -139,7 +139,7 @@ function handleEvent(mapBrowserEvent) {
this.handlePointerMove_(mapBrowserEvent); this.handlePointerMove_(mapBrowserEvent);
} }
//call pointer to determine up/down/drag //call pointer to determine up/down/drag
PointerInteraction.handleEvent.call(this, mapBrowserEvent); handlePointerEvent.call(this, mapBrowserEvent);
//return false to stop propagation //return false to stop propagation
return false; return false;
} }
+4 -4
View File
@@ -28,7 +28,7 @@ import Interaction from '../interaction/Interaction.js';
const KeyboardPan = function(opt_options) { const KeyboardPan = function(opt_options) {
Interaction.call(this, { Interaction.call(this, {
handleEvent: KeyboardPan.handleEvent handleEvent: handleEvent
}); });
const options = opt_options || {}; const options = opt_options || {};
@@ -74,9 +74,8 @@ inherits(KeyboardPan, Interaction);
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event. * @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation. * @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.KeyboardPan} * @this {ol.interaction.KeyboardPan}
* @api
*/ */
KeyboardPan.handleEvent = function(mapBrowserEvent) { function handleEvent(mapBrowserEvent) {
let stopEvent = false; let stopEvent = false;
if (mapBrowserEvent.type == EventType.KEYDOWN) { if (mapBrowserEvent.type == EventType.KEYDOWN) {
const keyEvent = mapBrowserEvent.originalEvent; const keyEvent = mapBrowserEvent.originalEvent;
@@ -107,5 +106,6 @@ KeyboardPan.handleEvent = function(mapBrowserEvent) {
} }
} }
return !stopEvent; return !stopEvent;
}; }
export default KeyboardPan; export default KeyboardPan;
+4 -4
View File
@@ -26,7 +26,7 @@ import Interaction from '../interaction/Interaction.js';
const KeyboardZoom = function(opt_options) { const KeyboardZoom = function(opt_options) {
Interaction.call(this, { Interaction.call(this, {
handleEvent: KeyboardZoom.handleEvent handleEvent: handleEvent
}); });
const options = opt_options ? opt_options : {}; const options = opt_options ? opt_options : {};
@@ -61,9 +61,8 @@ inherits(KeyboardZoom, Interaction);
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event. * @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation. * @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.KeyboardZoom} * @this {ol.interaction.KeyboardZoom}
* @api
*/ */
KeyboardZoom.handleEvent = function(mapBrowserEvent) { function handleEvent(mapBrowserEvent) {
let stopEvent = false; let stopEvent = false;
if (mapBrowserEvent.type == EventType.KEYDOWN || if (mapBrowserEvent.type == EventType.KEYDOWN ||
mapBrowserEvent.type == EventType.KEYPRESS) { mapBrowserEvent.type == EventType.KEYPRESS) {
@@ -81,5 +80,6 @@ KeyboardZoom.handleEvent = function(mapBrowserEvent) {
} }
} }
return !stopEvent; return !stopEvent;
}; }
export default KeyboardZoom; export default KeyboardZoom;
+7 -6
View File
@@ -17,7 +17,7 @@ import {boundingExtent, buffer, createOrUpdateFromCoordinate} from '../extent.js
import GeometryType from '../geom/GeometryType.js'; import GeometryType from '../geom/GeometryType.js';
import Point from '../geom/Point.js'; import Point from '../geom/Point.js';
import ModifyEventType from '../interaction/ModifyEventType.js'; import ModifyEventType from '../interaction/ModifyEventType.js';
import PointerInteraction from '../interaction/Pointer.js'; import PointerInteraction, {handleEvent as handlePointerEvent} from '../interaction/Pointer.js';
import VectorLayer from '../layer/Vector.js'; import VectorLayer from '../layer/Vector.js';
import VectorSource from '../source/Vector.js'; import VectorSource from '../source/Vector.js';
import VectorEventType from '../source/VectorEventType.js'; import VectorEventType from '../source/VectorEventType.js';
@@ -48,7 +48,7 @@ const Modify = function(options) {
PointerInteraction.call(this, { PointerInteraction.call(this, {
handleDownEvent: handleDownEvent, handleDownEvent: handleDownEvent,
handleDragEvent: handleDragEvent, handleDragEvent: handleDragEvent,
handleEvent: Modify.handleEvent, handleEvent: handleEvent,
handleUpEvent: handleUpEvent handleUpEvent: handleUpEvent
}); });
@@ -789,9 +789,8 @@ function handleUpEvent(evt) {
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event. * @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation. * @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.Modify} * @this {ol.interaction.Modify}
* @api
*/ */
Modify.handleEvent = function(mapBrowserEvent) { function handleEvent(mapBrowserEvent) {
if (!(mapBrowserEvent instanceof MapBrowserPointerEvent)) { if (!(mapBrowserEvent instanceof MapBrowserPointerEvent)) {
return true; return true;
} }
@@ -815,8 +814,8 @@ Modify.handleEvent = function(mapBrowserEvent) {
this.ignoreNextSingleClick_ = false; this.ignoreNextSingleClick_ = false;
} }
return PointerInteraction.handleEvent.call(this, mapBrowserEvent) && !handled; return handlePointerEvent.call(this, mapBrowserEvent) && !handled;
}; }
/** /**
@@ -1219,5 +1218,7 @@ Modify.Event = function(type, features, mapBrowserPointerEvent) {
*/ */
this.mapBrowserEvent = mapBrowserPointerEvent; this.mapBrowserEvent = mapBrowserPointerEvent;
}; };
inherits(Modify.Event, Event); inherits(Modify.Event, Event);
export default Modify; export default Modify;
+3 -4
View File
@@ -39,7 +39,7 @@ export const Mode = {
const MouseWheelZoom = function(opt_options) { const MouseWheelZoom = function(opt_options) {
Interaction.call(this, { Interaction.call(this, {
handleEvent: MouseWheelZoom.handleEvent handleEvent: handleEvent
}); });
const options = opt_options || {}; const options = opt_options || {};
@@ -141,9 +141,8 @@ inherits(MouseWheelZoom, Interaction);
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event. * @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} Allow event propagation. * @return {boolean} Allow event propagation.
* @this {ol.interaction.MouseWheelZoom} * @this {ol.interaction.MouseWheelZoom}
* @api
*/ */
MouseWheelZoom.handleEvent = function(mapBrowserEvent) { function handleEvent(mapBrowserEvent) {
if (!this.condition_(mapBrowserEvent)) { if (!this.condition_(mapBrowserEvent)) {
return true; return true;
} }
@@ -257,7 +256,7 @@ MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
this.timeoutId_ = setTimeout(this.handleWheelZoom_.bind(this, map), timeLeft); this.timeoutId_ = setTimeout(this.handleWheelZoom_.bind(this, map), timeLeft);
return false; return false;
}; }
/** /**
+3 -6
View File
@@ -27,11 +27,8 @@ const PointerInteraction = function(opt_options) {
const options = opt_options ? opt_options : {}; const options = opt_options ? opt_options : {};
const handleEvent = options.handleEvent ?
options.handleEvent : PointerInteraction.handleEvent;
Interaction.call(this, { Interaction.call(this, {
handleEvent: handleEvent handleEvent: options.handleEvent || handleEvent
}); });
/** /**
@@ -177,7 +174,7 @@ PointerInteraction.handleMoveEvent = nullFunction;
* @this {ol.interaction.Pointer} * @this {ol.interaction.Pointer}
* @api * @api
*/ */
PointerInteraction.handleEvent = function(mapBrowserEvent) { export function handleEvent(mapBrowserEvent) {
if (!(mapBrowserEvent instanceof MapBrowserPointerEvent)) { if (!(mapBrowserEvent instanceof MapBrowserPointerEvent)) {
return true; return true;
} }
@@ -201,7 +198,7 @@ PointerInteraction.handleEvent = function(mapBrowserEvent) {
} }
} }
return !stopEvent; return !stopEvent;
}; }
/** /**
+3 -4
View File
@@ -50,7 +50,7 @@ const SelectEventType = {
const Select = function(opt_options) { const Select = function(opt_options) {
Interaction.call(this, { Interaction.call(this, {
handleEvent: Select.handleEvent handleEvent: handleEvent
}); });
const options = opt_options ? opt_options : {}; const options = opt_options ? opt_options : {};
@@ -207,9 +207,8 @@ Select.prototype.getLayer = function(feature) {
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event. * @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation. * @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.Select} * @this {ol.interaction.Select}
* @api
*/ */
Select.handleEvent = function(mapBrowserEvent) { function handleEvent(mapBrowserEvent) {
if (!this.condition_(mapBrowserEvent)) { if (!this.condition_(mapBrowserEvent)) {
return true; return true;
} }
@@ -294,7 +293,7 @@ Select.handleEvent = function(mapBrowserEvent) {
selected, deselected, mapBrowserEvent)); selected, deselected, mapBrowserEvent));
} }
return pointerMove(mapBrowserEvent); return pointerMove(mapBrowserEvent);
}; }
/** /**
+2 -2
View File
@@ -11,7 +11,7 @@ import {boundingExtent, createEmpty} from '../extent.js';
import {TRUE, FALSE} from '../functions.js'; import {TRUE, FALSE} from '../functions.js';
import GeometryType from '../geom/GeometryType.js'; import GeometryType from '../geom/GeometryType.js';
import {fromCircle} from '../geom/Polygon.js'; import {fromCircle} from '../geom/Polygon.js';
import PointerInteraction from '../interaction/Pointer.js'; import PointerInteraction, {handleEvent as handlePointerEvent} from '../interaction/Pointer.js';
import {getValues} from '../obj.js'; import {getValues} from '../obj.js';
import VectorSource from '../source/Vector.js'; import VectorSource from '../source/Vector.js';
import VectorEventType from '../source/VectorEventType.js'; import VectorEventType from '../source/VectorEventType.js';
@@ -590,7 +590,7 @@ export function handleEvent(evt) {
evt.coordinate = result.vertex.slice(0, 2); evt.coordinate = result.vertex.slice(0, 2);
evt.pixel = result.vertexPixel; evt.pixel = result.vertexPixel;
} }
return PointerInteraction.handleEvent.call(this, evt); return handlePointerEvent.call(this, evt);
} }
+2 -2
View File
@@ -10,7 +10,7 @@ import {equals} from '../../array.js';
import {asColorLike} from '../../colorlike.js'; import {asColorLike} from '../../colorlike.js';
import {intersects} from '../../extent.js'; import {intersects} from '../../extent.js';
import GeometryType from '../../geom/GeometryType.js'; import GeometryType from '../../geom/GeometryType.js';
import SimpleGeometry from '../../geom/SimpleGeometry.js'; import {transformGeom2D} from '../../geom/SimpleGeometry.js';
import {transform2D} from '../../geom/flat/transform.js'; import {transform2D} from '../../geom/flat/transform.js';
import {CANVAS_LINE_DASH} from '../../has.js'; import {CANVAS_LINE_DASH} from '../../has.js';
import VectorContext from '../VectorContext.js'; import VectorContext from '../VectorContext.js';
@@ -409,7 +409,7 @@ CanvasImmediateRenderer.prototype.drawCircle = function(geometry) {
if (this.strokeState_) { if (this.strokeState_) {
this.setContextStrokeState_(this.strokeState_); this.setContextStrokeState_(this.strokeState_);
} }
const pixelCoordinates = SimpleGeometry.transform2D( const pixelCoordinates = transformGeom2D(
geometry, this.transform_, this.pixelCoordinates_); geometry, this.transform_, this.pixelCoordinates_);
const dx = pixelCoordinates[2] - pixelCoordinates[0]; const dx = pixelCoordinates[2] - pixelCoordinates[0];
const dy = pixelCoordinates[3] - pixelCoordinates[1]; const dy = pixelCoordinates[3] - pixelCoordinates[1];
+3 -4
View File
@@ -1,13 +1,12 @@
import XSD from '../../../../src/ol/format/XSD.js'; import {readDateTime} from '../../../../src/ol/format/xsd.js';
describe('ol/format/xsd', function() {
describe('ol.format.XSD', function() {
describe('readDateTime', function() { describe('readDateTime', function() {
it('can handle non-Zulu time zones', function() { it('can handle non-Zulu time zones', function() {
const node = document.createElement('time'); const node = document.createElement('time');
node.textContent = '2016-07-12T15:00:00+03:00'; node.textContent = '2016-07-12T15:00:00+03:00';
expect(new Date(XSD.readDateTime(node) * 1000).toISOString()).to.eql('2016-07-12T12:00:00.000Z'); expect(new Date(readDateTime(node) * 1000).toISOString()).to.eql('2016-07-12T12:00:00.000Z');
}); });
}); });
+2 -3
View File
@@ -1,5 +1,5 @@
import MultiPolygon from '../../../../../src/ol/geom/MultiPolygon.js'; import MultiPolygon from '../../../../../src/ol/geom/MultiPolygon.js';
import SimpleGeometry from '../../../../../src/ol/geom/SimpleGeometry.js'; import {transformGeom2D} from '../../../../../src/ol/geom/SimpleGeometry.js';
import {rotate, translate} from '../../../../../src/ol/geom/flat/transform.js'; import {rotate, translate} from '../../../../../src/ol/geom/flat/transform.js';
@@ -31,8 +31,7 @@ describe('ol.geom.flat.transform', function() {
0, -0.0004088332670837288, 0, -0.0004088332670837288,
4480.991370439071, 1529.5752568707105 4480.991370439071, 1529.5752568707105
]; ];
const pixelCoordinates = SimpleGeometry.transform2D( const pixelCoordinates = transformGeom2D(multiPolygonGeometry, transform, []);
multiPolygonGeometry, transform, []);
expect(pixelCoordinates[0]).to.roughlyEqual(806.6035275946265, 1e-9); expect(pixelCoordinates[0]).to.roughlyEqual(806.6035275946265, 1e-9);
expect(pixelCoordinates[1]).to.roughlyEqual(160.48916296287916, 1e-9); expect(pixelCoordinates[1]).to.roughlyEqual(160.48916296287916, 1e-9);
expect(pixelCoordinates[2]).to.roughlyEqual(805.3521540835154, 1e-9); expect(pixelCoordinates[2]).to.roughlyEqual(805.3521540835154, 1e-9);