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

View File

@@ -68,7 +68,7 @@ inherits(ImageTile, Tile);
ImageTile.prototype.disposeInternal = function() {
if (this.state == TileState.LOADING) {
this.unlistenImage_();
this.image_ = ImageTile.getBlankImage();
this.image_ = getBlankImage();
}
if (this.interimTile) {
this.interimTile.dispose();
@@ -105,7 +105,7 @@ ImageTile.prototype.getKey = function() {
ImageTile.prototype.handleImageError_ = function() {
this.state = TileState.ERROR;
this.unlistenImage_();
this.image_ = ImageTile.getBlankImage();
this.image_ = getBlankImage();
this.changed();
};
@@ -167,10 +167,11 @@ ImageTile.prototype.unlistenImage_ = function() {
* Get a 1-pixel blank image.
* @return {HTMLCanvasElement} Blank image.
*/
ImageTile.getBlankImage = function() {
function getBlankImage() {
const ctx = createCanvasContext2D(1, 1);
ctx.fillStyle = 'rgba(0,0,0,0)';
ctx.fillRect(0, 0, 1, 1);
return ctx.canvas;
};
}
export default ImageTile;

View File

@@ -4,8 +4,8 @@
import {inherits} from '../index.js';
import {createOrUpdate} from '../extent.js';
import {transformWithOptions} from '../format/Feature.js';
import GMLBase from '../format/GMLBase.js';
import XSD from '../format/XSD.js';
import GMLBase, {GMLNS} from '../format/GMLBase.js';
import {writeStringTextNode} from '../format/xsd.js';
import Geometry from '../geom/Geometry.js';
import {assign} from '../obj.js';
import {get as getProjection, transformExtent} from '../proj.js';
@@ -17,7 +17,7 @@ import {createElementNS, getAllTextContent, makeArrayPusher, makeChildAppender,
* @const
* @type {string}
*/
const schemaLocation = GMLBase.GMLNS + ' http://schemas.opengis.net/gml/2.1.2/feature.xsd';
const schemaLocation = GMLNS + ' http://schemas.opengis.net/gml/2.1.2/feature.xsd';
/**
@@ -36,7 +36,7 @@ const GML2 = function(opt_options) {
GMLBase.call(this, options);
this.FEATURE_COLLECTION_PARSERS[GMLBase.GMLNS][
this.FEATURE_COLLECTION_PARSERS[GMLNS][
'featureMember'] =
makeArrayPusher(GMLBase.prototype.readFeaturesInternal);
@@ -199,8 +199,7 @@ GML2.prototype.writeFeatureElement = function(node, feature, objectStack) {
}
} else {
if (!(key in context.serializers[featureNS])) {
context.serializers[featureNS][key] = makeChildAppender(
XSD.writeStringTextNode);
context.serializers[featureNS][key] = makeChildAppender(writeStringTextNode);
}
}
}
@@ -339,7 +338,7 @@ GML2.prototype.writeCoordinates_ = function(node, value, objectStack) {
point = points[i];
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);
const point = geometry.getCoordinates();
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_ = {
'http://www.opengis.net/gml': {
'lowerCorner': makeChildAppender(XSD.writeStringTextNode),
'upperCorner': makeChildAppender(XSD.writeStringTextNode)
'lowerCorner': makeChildAppender(writeStringTextNode),
'upperCorner': makeChildAppender(writeStringTextNode)
}
};

View File

@@ -5,8 +5,8 @@ import {inherits} from '../index.js';
import {extend} from '../array.js';
import {createOrUpdate} from '../extent.js';
import {transformWithOptions} from '../format/Feature.js';
import GMLBase from '../format/GMLBase.js';
import XSD from '../format/XSD.js';
import GMLBase, {GMLNS} from '../format/GMLBase.js';
import {readNonNegativeIntegerString, writeStringTextNode} from '../format/xsd.js';
import Geometry from '../geom/Geometry.js';
import GeometryLayout from '../geom/GeometryLayout.js';
import LineString from '../geom/LineString.js';
@@ -25,7 +25,7 @@ import {createElementNS, getAllTextContent, makeArrayPusher, makeChildAppender,
* @type {string}
* @private
*/
const schemaLocation = GMLBase.GMLNS +
const schemaLocation = GMLNS +
' http://schemas.opengis.net/gml/3.1.1/profiles/gmlsfProfile/' +
'1.0.0/gmlsf.xsd';
@@ -366,16 +366,16 @@ GML3.prototype.readFlatPosList_ = function(node, objectStack) {
// The "dimension" attribute is from the GML 3.0.1 spec.
let dim = 2;
if (node.getAttribute('srsDimension')) {
dim = XSD.readNonNegativeIntegerString(
dim = readNonNegativeIntegerString(
node.getAttribute('srsDimension'));
} else if (node.getAttribute('dimension')) {
dim = XSD.readNonNegativeIntegerString(
dim = readNonNegativeIntegerString(
node.getAttribute('dimension'));
} else if (node.parentNode.getAttribute('srsDimension')) {
dim = XSD.readNonNegativeIntegerString(
dim = readNonNegativeIntegerString(
node.parentNode.getAttribute('srsDimension'));
} else if (contextDimension) {
dim = XSD.readNonNegativeIntegerString(contextDimension);
dim = readNonNegativeIntegerString(contextDimension);
}
let x, y, z;
const flatCoordinates = [];
@@ -600,7 +600,7 @@ GML3.prototype.writePos_ = function(node, value, objectStack) {
const z = point[2] || 0;
coords += ' ' + z;
}
XSD.writeStringTextNode(node, coords);
writeStringTextNode(node, coords);
};
@@ -650,7 +650,7 @@ GML3.prototype.writePosList_ = function(node, value, objectStack) {
point = points[i];
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 {
if (!(key in context.serializers[featureNS])) {
context.serializers[featureNS][key] = makeChildAppender(
XSD.writeStringTextNode);
context.serializers[featureNS][key] = makeChildAppender(writeStringTextNode);
}
}
}
@@ -1181,8 +1180,8 @@ GML3.prototype.RING_SERIALIZERS_ = {
*/
GML3.prototype.ENVELOPE_SERIALIZERS_ = {
'http://www.opengis.net/gml': {
'lowerCorner': makeChildAppender(XSD.writeStringTextNode),
'upperCorner': makeChildAppender(XSD.writeStringTextNode)
'lowerCorner': makeChildAppender(writeStringTextNode),
'upperCorner': makeChildAppender(writeStringTextNode)
}
};

View File

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

View File

@@ -6,7 +6,7 @@ import Feature from '../Feature.js';
import {includes} from '../array.js';
import {transformWithOptions} from '../format/Feature.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 LineString from '../geom/LineString.js';
import MultiLineString from '../geom/MultiLineString.js';
@@ -95,8 +95,8 @@ const GPX_PARSERS = makeStructureNS(
*/
const LINK_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'text': makeObjectPropertySetter(XSD.readString, 'linkText'),
'type': makeObjectPropertySetter(XSD.readString, 'linkType')
'text': makeObjectPropertySetter(readString, 'linkText'),
'type': makeObjectPropertySetter(readString, 'linkType')
});
@@ -106,14 +106,14 @@ const LINK_PARSERS = makeStructureNS(
*/
const RTE_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'name': makeObjectPropertySetter(XSD.readString),
'cmt': makeObjectPropertySetter(XSD.readString),
'desc': makeObjectPropertySetter(XSD.readString),
'src': makeObjectPropertySetter(XSD.readString),
'name': makeObjectPropertySetter(readString),
'cmt': makeObjectPropertySetter(readString),
'desc': makeObjectPropertySetter(readString),
'src': makeObjectPropertySetter(readString),
'link': parseLink,
'number': makeObjectPropertySetter(XSD.readNonNegativeInteger),
'number': makeObjectPropertySetter(readNonNegativeInteger),
'extensions': parseExtensions,
'type': makeObjectPropertySetter(XSD.readString),
'type': makeObjectPropertySetter(readString),
'rtept': parseRtePt
});
@@ -124,8 +124,8 @@ const RTE_PARSERS = makeStructureNS(
*/
const RTEPT_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'ele': makeObjectPropertySetter(XSD.readDecimal),
'time': makeObjectPropertySetter(XSD.readDateTime)
'ele': makeObjectPropertySetter(readDecimal),
'time': makeObjectPropertySetter(readDateTime)
});
@@ -135,13 +135,13 @@ const RTEPT_PARSERS = makeStructureNS(
*/
const TRK_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'name': makeObjectPropertySetter(XSD.readString),
'cmt': makeObjectPropertySetter(XSD.readString),
'desc': makeObjectPropertySetter(XSD.readString),
'src': makeObjectPropertySetter(XSD.readString),
'name': makeObjectPropertySetter(readString),
'cmt': makeObjectPropertySetter(readString),
'desc': makeObjectPropertySetter(readString),
'src': makeObjectPropertySetter(readString),
'link': parseLink,
'number': makeObjectPropertySetter(XSD.readNonNegativeInteger),
'type': makeObjectPropertySetter(XSD.readString),
'number': makeObjectPropertySetter(readNonNegativeInteger),
'type': makeObjectPropertySetter(readString),
'extensions': parseExtensions,
'trkseg': parseTrkSeg
});
@@ -163,8 +163,8 @@ const TRKSEG_PARSERS = makeStructureNS(
*/
const TRKPT_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'ele': makeObjectPropertySetter(XSD.readDecimal),
'time': makeObjectPropertySetter(XSD.readDateTime)
'ele': makeObjectPropertySetter(readDecimal),
'time': makeObjectPropertySetter(readDateTime)
});
@@ -174,24 +174,24 @@ const TRKPT_PARSERS = makeStructureNS(
*/
const WPT_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'ele': makeObjectPropertySetter(XSD.readDecimal),
'time': makeObjectPropertySetter(XSD.readDateTime),
'magvar': makeObjectPropertySetter(XSD.readDecimal),
'geoidheight': makeObjectPropertySetter(XSD.readDecimal),
'name': makeObjectPropertySetter(XSD.readString),
'cmt': makeObjectPropertySetter(XSD.readString),
'desc': makeObjectPropertySetter(XSD.readString),
'src': makeObjectPropertySetter(XSD.readString),
'ele': makeObjectPropertySetter(readDecimal),
'time': makeObjectPropertySetter(readDateTime),
'magvar': makeObjectPropertySetter(readDecimal),
'geoidheight': makeObjectPropertySetter(readDecimal),
'name': makeObjectPropertySetter(readString),
'cmt': makeObjectPropertySetter(readString),
'desc': makeObjectPropertySetter(readString),
'src': makeObjectPropertySetter(readString),
'link': parseLink,
'sym': makeObjectPropertySetter(XSD.readString),
'type': makeObjectPropertySetter(XSD.readString),
'fix': makeObjectPropertySetter(XSD.readString),
'sat': makeObjectPropertySetter(XSD.readNonNegativeInteger),
'hdop': makeObjectPropertySetter(XSD.readDecimal),
'vdop': makeObjectPropertySetter(XSD.readDecimal),
'pdop': makeObjectPropertySetter(XSD.readDecimal),
'ageofdgpsdata': makeObjectPropertySetter(XSD.readDecimal),
'dgpsid': makeObjectPropertySetter(XSD.readNonNegativeInteger),
'sym': makeObjectPropertySetter(readString),
'type': makeObjectPropertySetter(readString),
'fix': makeObjectPropertySetter(readString),
'sat': makeObjectPropertySetter(readNonNegativeInteger),
'hdop': makeObjectPropertySetter(readDecimal),
'vdop': makeObjectPropertySetter(readDecimal),
'pdop': makeObjectPropertySetter(readDecimal),
'ageofdgpsdata': makeObjectPropertySetter(readDecimal),
'dgpsid': makeObjectPropertySetter(readNonNegativeInteger),
'extensions': parseExtensions
});
@@ -209,8 +209,8 @@ const LINK_SEQUENCE = ['text', 'type'];
*/
const LINK_SERIALIZERS = makeStructureNS(
NAMESPACE_URIS, {
'text': makeChildAppender(XSD.writeStringTextNode),
'type': makeChildAppender(XSD.writeStringTextNode)
'text': makeChildAppender(writeStringTextNode),
'type': makeChildAppender(writeStringTextNode)
});
@@ -230,13 +230,13 @@ const RTE_SEQUENCE = makeStructureNS(
*/
const RTE_SERIALIZERS = makeStructureNS(
NAMESPACE_URIS, {
'name': makeChildAppender(XSD.writeStringTextNode),
'cmt': makeChildAppender(XSD.writeStringTextNode),
'desc': makeChildAppender(XSD.writeStringTextNode),
'src': makeChildAppender(XSD.writeStringTextNode),
'name': makeChildAppender(writeStringTextNode),
'cmt': makeChildAppender(writeStringTextNode),
'desc': makeChildAppender(writeStringTextNode),
'src': makeChildAppender(writeStringTextNode),
'link': makeChildAppender(writeLink),
'number': makeChildAppender(XSD.writeNonNegativeIntegerTextNode),
'type': makeChildAppender(XSD.writeStringTextNode),
'number': makeChildAppender(writeNonNegativeIntegerTextNode),
'type': makeChildAppender(writeStringTextNode),
'rtept': makeArraySerializer(makeChildAppender(writeWptType))
});
@@ -267,13 +267,13 @@ const TRK_SEQUENCE = makeStructureNS(
*/
const TRK_SERIALIZERS = makeStructureNS(
NAMESPACE_URIS, {
'name': makeChildAppender(XSD.writeStringTextNode),
'cmt': makeChildAppender(XSD.writeStringTextNode),
'desc': makeChildAppender(XSD.writeStringTextNode),
'src': makeChildAppender(XSD.writeStringTextNode),
'name': makeChildAppender(writeStringTextNode),
'cmt': makeChildAppender(writeStringTextNode),
'desc': makeChildAppender(writeStringTextNode),
'src': makeChildAppender(writeStringTextNode),
'link': makeChildAppender(writeLink),
'number': makeChildAppender(XSD.writeNonNegativeIntegerTextNode),
'type': makeChildAppender(XSD.writeStringTextNode),
'number': makeChildAppender(writeNonNegativeIntegerTextNode),
'type': makeChildAppender(writeStringTextNode),
'trkseg': makeArraySerializer(makeChildAppender(writeTrkSeg))
});
@@ -313,24 +313,24 @@ const WPT_TYPE_SEQUENCE = makeStructureNS(
*/
const WPT_TYPE_SERIALIZERS = makeStructureNS(
NAMESPACE_URIS, {
'ele': makeChildAppender(XSD.writeDecimalTextNode),
'time': makeChildAppender(XSD.writeDateTimeTextNode),
'magvar': makeChildAppender(XSD.writeDecimalTextNode),
'geoidheight': makeChildAppender(XSD.writeDecimalTextNode),
'name': makeChildAppender(XSD.writeStringTextNode),
'cmt': makeChildAppender(XSD.writeStringTextNode),
'desc': makeChildAppender(XSD.writeStringTextNode),
'src': makeChildAppender(XSD.writeStringTextNode),
'ele': makeChildAppender(writeDecimalTextNode),
'time': makeChildAppender(writeDateTimeTextNode),
'magvar': makeChildAppender(writeDecimalTextNode),
'geoidheight': makeChildAppender(writeDecimalTextNode),
'name': makeChildAppender(writeStringTextNode),
'cmt': makeChildAppender(writeStringTextNode),
'desc': makeChildAppender(writeStringTextNode),
'src': makeChildAppender(writeStringTextNode),
'link': makeChildAppender(writeLink),
'sym': makeChildAppender(XSD.writeStringTextNode),
'type': makeChildAppender(XSD.writeStringTextNode),
'fix': makeChildAppender(XSD.writeStringTextNode),
'sat': makeChildAppender(XSD.writeNonNegativeIntegerTextNode),
'hdop': makeChildAppender(XSD.writeDecimalTextNode),
'vdop': makeChildAppender(XSD.writeDecimalTextNode),
'pdop': makeChildAppender(XSD.writeDecimalTextNode),
'ageofdgpsdata': makeChildAppender(XSD.writeDecimalTextNode),
'dgpsid': makeChildAppender(XSD.writeNonNegativeIntegerTextNode)
'sym': makeChildAppender(writeStringTextNode),
'type': makeChildAppender(writeStringTextNode),
'fix': makeChildAppender(writeStringTextNode),
'sat': makeChildAppender(writeNonNegativeIntegerTextNode),
'hdop': makeChildAppender(writeDecimalTextNode),
'vdop': makeChildAppender(writeDecimalTextNode),
'pdop': makeChildAppender(writeDecimalTextNode),
'ageofdgpsdata': makeChildAppender(writeDecimalTextNode),
'dgpsid': makeChildAppender(writeNonNegativeIntegerTextNode)
});
@@ -883,8 +883,7 @@ GPX.prototype.writeFeaturesNode = function(features, opt_options) {
const xmlnsUri = 'http://www.w3.org/2000/xmlns/';
const xmlSchemaInstanceUri = 'http://www.w3.org/2001/XMLSchema-instance';
setAttributeNS(gpx, xmlnsUri, 'xmlns:xsi', xmlSchemaInstanceUri);
setAttributeNS(gpx, xmlSchemaInstanceUri, 'xsi:schemaLocation',
SCHEMA_LOCATION);
setAttributeNS(gpx, xmlSchemaInstanceUri, 'xsi:schemaLocation', SCHEMA_LOCATION);
gpx.setAttribute('version', '1.1');
gpx.setAttribute('creator', 'OpenLayers');

View File

@@ -8,7 +8,7 @@ import {assert} from '../asserts.js';
import {asArray} from '../color.js';
import {transformWithOptions} from '../format/Feature.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 GeometryLayout from '../geom/GeometryLayout.js';
import GeometryType from '../geom/GeometryType.js';
@@ -575,7 +575,7 @@ function readVec2(node) {
* @return {number|undefined} Scale.
*/
function readScale(node) {
return XSD.readDecimal(node);
return readDecimal(node);
}
@@ -607,7 +607,7 @@ function readStyleMapValue(node, objectStack) {
const ICON_STYLE_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'Icon': makeObjectPropertySetter(readIcon),
'heading': makeObjectPropertySetter(XSD.readDecimal),
'heading': makeObjectPropertySetter(readDecimal),
'hotSpot': makeObjectPropertySetter(readVec2),
'scale': makeObjectPropertySetter(readScale)
});
@@ -758,7 +758,7 @@ function labelStyleParser(node, objectStack) {
const LINE_STYLE_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'color': makeObjectPropertySetter(readColor),
'width': makeObjectPropertySetter(XSD.readDecimal)
'width': makeObjectPropertySetter(readDecimal)
});
@@ -794,8 +794,8 @@ function lineStyleParser(node, objectStack) {
const POLY_STYLE_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'color': makeObjectPropertySetter(readColor),
'fill': makeObjectPropertySetter(XSD.readBoolean),
'outline': makeObjectPropertySetter(XSD.readBoolean)
'fill': makeObjectPropertySetter(readBoolean),
'outline': makeObjectPropertySetter(readBoolean)
});
@@ -948,10 +948,10 @@ const ICON_PARSERS = makeStructureNS(
'href': makeObjectPropertySetter(readURI)
}, makeStructureNS(
GX_NAMESPACE_URIS, {
'x': makeObjectPropertySetter(XSD.readDecimal),
'y': makeObjectPropertySetter(XSD.readDecimal),
'w': makeObjectPropertySetter(XSD.readDecimal),
'h': makeObjectPropertySetter(XSD.readDecimal)
'x': makeObjectPropertySetter(readDecimal),
'y': makeObjectPropertySetter(readDecimal),
'w': makeObjectPropertySetter(readDecimal),
'h': makeObjectPropertySetter(readDecimal)
}));
@@ -998,9 +998,9 @@ function readFlatCoordinatesFromNode(node, objectStack) {
*/
const EXTRUDE_AND_ALTITUDE_MODE_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'extrude': makeObjectPropertySetter(XSD.readBoolean),
'tessellate': makeObjectPropertySetter(XSD.readBoolean),
'altitudeMode': makeObjectPropertySetter(XSD.readString)
'extrude': makeObjectPropertySetter(readBoolean),
'tessellate': makeObjectPropertySetter(readBoolean),
'altitudeMode': makeObjectPropertySetter(readString)
});
@@ -1286,8 +1286,8 @@ function setCommonGeometryProperties(multiGeometry,
*/
const DATA_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'displayName': makeObjectPropertySetter(XSD.readString),
'value': makeObjectPropertySetter(XSD.readString)
'displayName': makeObjectPropertySetter(readString),
'value': makeObjectPropertySetter(readString)
});
@@ -1353,7 +1353,7 @@ function regionParser(node, objectStack) {
const PAIR_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'Style': makeObjectPropertySetter(readStyle),
'key': makeObjectPropertySetter(XSD.readString),
'key': makeObjectPropertySetter(readString),
'styleUrl': makeObjectPropertySetter(readURI)
});
@@ -1431,7 +1431,7 @@ function schemaDataParser(node, objectStack) {
function simpleDataParser(node, objectStack) {
const name = node.getAttribute('name');
if (name !== null) {
const data = XSD.readString(node);
const data = readString(node);
const featureObject =
/** @type {Object} */ (objectStack[objectStack.length - 1]);
featureObject[name] = data;
@@ -1445,13 +1445,13 @@ function simpleDataParser(node, objectStack) {
*/
const LAT_LON_ALT_BOX_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'altitudeMode': makeObjectPropertySetter(XSD.readString),
'minAltitude': makeObjectPropertySetter(XSD.readDecimal),
'maxAltitude': makeObjectPropertySetter(XSD.readDecimal),
'north': makeObjectPropertySetter(XSD.readDecimal),
'south': makeObjectPropertySetter(XSD.readDecimal),
'east': makeObjectPropertySetter(XSD.readDecimal),
'west': makeObjectPropertySetter(XSD.readDecimal)
'altitudeMode': makeObjectPropertySetter(readString),
'minAltitude': makeObjectPropertySetter(readDecimal),
'maxAltitude': makeObjectPropertySetter(readDecimal),
'north': makeObjectPropertySetter(readDecimal),
'south': makeObjectPropertySetter(readDecimal),
'east': makeObjectPropertySetter(readDecimal),
'west': makeObjectPropertySetter(readDecimal)
});
@@ -1484,10 +1484,10 @@ function latLonAltBoxParser(node, objectStack) {
*/
const LOD_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'minLodPixels': makeObjectPropertySetter(XSD.readDecimal),
'maxLodPixels': makeObjectPropertySetter(XSD.readDecimal),
'minFadeExtent': makeObjectPropertySetter(XSD.readDecimal),
'maxFadeExtent': makeObjectPropertySetter(XSD.readDecimal)
'minLodPixels': makeObjectPropertySetter(readDecimal),
'maxLodPixels': makeObjectPropertySetter(readDecimal),
'minFadeExtent': makeObjectPropertySetter(readDecimal),
'maxFadeExtent': makeObjectPropertySetter(readDecimal)
});
@@ -1569,12 +1569,12 @@ const NETWORK_LINK_PARSERS = makeStructureNS(
'ExtendedData': extendedDataParser,
'Region': regionParser,
'Link': linkParser,
'address': makeObjectPropertySetter(XSD.readString),
'description': makeObjectPropertySetter(XSD.readString),
'name': makeObjectPropertySetter(XSD.readString),
'open': makeObjectPropertySetter(XSD.readBoolean),
'phoneNumber': makeObjectPropertySetter(XSD.readString),
'visibility': makeObjectPropertySetter(XSD.readBoolean)
'address': makeObjectPropertySetter(readString),
'description': makeObjectPropertySetter(readString),
'name': makeObjectPropertySetter(readString),
'open': makeObjectPropertySetter(readBoolean),
'phoneNumber': makeObjectPropertySetter(readString),
'visibility': makeObjectPropertySetter(readBoolean)
});
@@ -1631,13 +1631,13 @@ const PLACEMARK_PARSERS = makeStructureNS(
readPolygon, 'geometry'),
'Style': makeObjectPropertySetter(readStyle),
'StyleMap': placemarkStyleMapParser,
'address': makeObjectPropertySetter(XSD.readString),
'description': makeObjectPropertySetter(XSD.readString),
'name': makeObjectPropertySetter(XSD.readString),
'open': makeObjectPropertySetter(XSD.readBoolean),
'phoneNumber': makeObjectPropertySetter(XSD.readString),
'address': makeObjectPropertySetter(readString),
'description': makeObjectPropertySetter(readString),
'name': makeObjectPropertySetter(readString),
'open': makeObjectPropertySetter(readBoolean),
'phoneNumber': makeObjectPropertySetter(readString),
'styleUrl': makeObjectPropertySetter(readURI),
'visibility': makeObjectPropertySetter(XSD.readBoolean)
'visibility': makeObjectPropertySetter(readBoolean)
}, makeStructureNS(
GX_NAMESPACE_URIS, {
'MultiTrack': makeObjectPropertySetter(
@@ -1908,7 +1908,7 @@ KML.prototype.readNameFromNode = function(node) {
for (n = node.firstElementChild; n; n = n.nextElementSibling) {
if (includes(NAMESPACE_URIS, n.namespaceURI) &&
n.localName == 'name') {
return XSD.readString(n);
return readString(n);
}
}
for (n = node.firstElementChild; n; n = n.nextElementSibling) {
@@ -2083,7 +2083,7 @@ function writeColorTextNode(node, color) {
const hex = parseInt(abgr[i], 10).toString(16);
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.
*/
function writeDataNodeName(node, name) {
XSD.writeCDATASection(node, name);
writeCDATASection(node, name);
}
@@ -2181,7 +2181,7 @@ function writeDataNodeName(node, name) {
* @param {string} value Value.
*/
function writeDataNodeValue(node, value) {
XSD.writeStringTextNode(node, value);
writeStringTextNode(node, value);
}
@@ -2268,13 +2268,13 @@ const ICON_SEQUENCE = makeStructureNS(
*/
const ICON_SERIALIZERS = makeStructureNS(
NAMESPACE_URIS, {
'href': makeChildAppender(XSD.writeStringTextNode)
'href': makeChildAppender(writeStringTextNode)
}, makeStructureNS(
GX_NAMESPACE_URIS, {
'x': makeChildAppender(XSD.writeDecimalTextNode),
'y': makeChildAppender(XSD.writeDecimalTextNode),
'w': makeChildAppender(XSD.writeDecimalTextNode),
'h': makeChildAppender(XSD.writeDecimalTextNode)
'x': makeChildAppender(writeDecimalTextNode),
'y': makeChildAppender(writeDecimalTextNode),
'w': makeChildAppender(writeDecimalTextNode),
'h': makeChildAppender(writeDecimalTextNode)
}));
@@ -2329,7 +2329,7 @@ const ICON_STYLE_SEQUENCE = makeStructureNS(
const ICON_STYLE_SERIALIZERS = makeStructureNS(
NAMESPACE_URIS, {
'Icon': makeChildAppender(writeIcon),
'heading': makeChildAppender(XSD.writeDecimalTextNode),
'heading': makeChildAppender(writeDecimalTextNode),
'hotSpot': makeChildAppender(writeVec2),
'scale': makeChildAppender(writeScaleTextNode)
});
@@ -2455,7 +2455,7 @@ const LINE_STYLE_SEQUENCE = makeStructureNS(
const LINE_STYLE_SERIALIZERS = makeStructureNS(
NAMESPACE_URIS, {
'color': makeChildAppender(writeColorTextNode),
'width': makeChildAppender(XSD.writeDecimalTextNode)
'width': makeChildAppender(writeDecimalTextNode)
});
@@ -2625,28 +2625,20 @@ function writeBoundaryIs(node, linearRing, objectStack) {
*/
const PLACEMARK_SERIALIZERS = makeStructureNS(
NAMESPACE_URIS, {
'ExtendedData': makeChildAppender(
writeExtendedData),
'MultiGeometry': makeChildAppender(
writeMultiGeometry),
'LineString': makeChildAppender(
writePrimitiveGeometry),
'LinearRing': makeChildAppender(
writePrimitiveGeometry),
'Point': makeChildAppender(
writePrimitiveGeometry),
'ExtendedData': makeChildAppender(writeExtendedData),
'MultiGeometry': makeChildAppender(writeMultiGeometry),
'LineString': makeChildAppender(writePrimitiveGeometry),
'LinearRing': makeChildAppender(writePrimitiveGeometry),
'Point': makeChildAppender(writePrimitiveGeometry),
'Polygon': makeChildAppender(writePolygon),
'Style': makeChildAppender(writeStyle),
'address': makeChildAppender(XSD.writeStringTextNode),
'description': makeChildAppender(
XSD.writeStringTextNode),
'name': makeChildAppender(XSD.writeStringTextNode),
'open': makeChildAppender(XSD.writeBooleanTextNode),
'phoneNumber': makeChildAppender(
XSD.writeStringTextNode),
'styleUrl': makeChildAppender(XSD.writeStringTextNode),
'visibility': makeChildAppender(
XSD.writeBooleanTextNode)
'address': makeChildAppender(writeStringTextNode),
'description': makeChildAppender(writeStringTextNode),
'name': makeChildAppender(writeStringTextNode),
'open': makeChildAppender(writeBooleanTextNode),
'phoneNumber': makeChildAppender(writeStringTextNode),
'styleUrl': makeChildAppender(writeStringTextNode),
'visibility': makeChildAppender(writeBooleanTextNode)
});
@@ -2752,11 +2744,10 @@ const PRIMITIVE_GEOMETRY_SEQUENCE = makeStructureNS(
*/
const PRIMITIVE_GEOMETRY_SERIALIZERS = makeStructureNS(
NAMESPACE_URIS, {
'extrude': makeChildAppender(XSD.writeBooleanTextNode),
'tessellate': makeChildAppender(XSD.writeBooleanTextNode),
'altitudeMode': makeChildAppender(XSD.writeStringTextNode),
'coordinates': makeChildAppender(
writeCoordinatesTextNode)
'extrude': makeChildAppender(writeBooleanTextNode),
'tessellate': makeChildAppender(writeBooleanTextNode),
'altitudeMode': makeChildAppender(writeStringTextNode),
'coordinates': makeChildAppender(writeCoordinatesTextNode)
});
@@ -2870,7 +2861,7 @@ function writePolyStyle(node, style, objectStack) {
*/
function writeScaleTextNode(node, scale) {
// the Math is to remove any excess decimals created by float arithmetic
XSD.writeDecimalTextNode(node,
writeDecimalTextNode(node,
Math.round(scale * 1e6) / 1e6);
}
@@ -3011,4 +3002,5 @@ KML.prototype.writeFeaturesNode = function(features, opt_options) {
this);
return kml;
};
export default KML;

View File

@@ -4,7 +4,7 @@
import {inherits} from '../index.js';
import {readHref} from '../format/XLink.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';
/**
@@ -31,12 +31,9 @@ const NAMESPACE_URIS = [null, 'http://www.opengis.net/ows/1.1'];
*/
const PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'ServiceIdentification': makeObjectPropertySetter(
readServiceIdentification),
'ServiceProvider': makeObjectPropertySetter(
readServiceProvider),
'OperationsMetadata': makeObjectPropertySetter(
readOperationsMetadata)
'ServiceIdentification': makeObjectPropertySetter(readServiceIdentification),
'ServiceProvider': makeObjectPropertySetter(readServiceProvider),
'OperationsMetadata': makeObjectPropertySetter(readOperationsMetadata)
});
@@ -46,15 +43,12 @@ const PARSERS = makeStructureNS(
*/
const ADDRESS_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'DeliveryPoint': makeObjectPropertySetter(
XSD.readString),
'City': makeObjectPropertySetter(XSD.readString),
'AdministrativeArea': makeObjectPropertySetter(
XSD.readString),
'PostalCode': makeObjectPropertySetter(XSD.readString),
'Country': makeObjectPropertySetter(XSD.readString),
'ElectronicMailAddress': makeObjectPropertySetter(
XSD.readString)
'DeliveryPoint': makeObjectPropertySetter(readString),
'City': makeObjectPropertySetter(readString),
'AdministrativeArea': makeObjectPropertySetter(readString),
'PostalCode': makeObjectPropertySetter(readString),
'Country': makeObjectPropertySetter(readString),
'ElectronicMailAddress': makeObjectPropertySetter(readString)
});
@@ -74,8 +68,7 @@ const ALLOWED_VALUES_PARSERS = makeStructureNS(
*/
const CONSTRAINT_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'AllowedValues': makeObjectPropertySetter(
readAllowedValues)
'AllowedValues': makeObjectPropertySetter(readAllowedValues)
});
@@ -137,8 +130,8 @@ const OPERATIONS_METADATA_PARSERS = makeStructureNS(
*/
const PHONE_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'Voice': makeObjectPropertySetter(XSD.readString),
'Facsimile': makeObjectPropertySetter(XSD.readString)
'Voice': makeObjectPropertySetter(readString),
'Facsimile': makeObjectPropertySetter(readString)
});
@@ -148,8 +141,7 @@ const PHONE_PARSERS = makeStructureNS(
*/
const REQUEST_METHOD_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'Constraint': makeObjectPropertyPusher(
readConstraint)
'Constraint': makeObjectPropertyPusher(readConstraint)
});
@@ -160,11 +152,9 @@ const REQUEST_METHOD_PARSERS = makeStructureNS(
const SERVICE_CONTACT_PARSERS =
makeStructureNS(
NAMESPACE_URIS, {
'IndividualName': makeObjectPropertySetter(
XSD.readString),
'PositionName': makeObjectPropertySetter(XSD.readString),
'ContactInfo': makeObjectPropertySetter(
readContactInfo)
'IndividualName': makeObjectPropertySetter(readString),
'PositionName': makeObjectPropertySetter(readString),
'ContactInfo': makeObjectPropertySetter(readContactInfo)
});
@@ -175,13 +165,12 @@ const SERVICE_CONTACT_PARSERS =
const SERVICE_IDENTIFICATION_PARSERS =
makeStructureNS(
NAMESPACE_URIS, {
'Abstract': makeObjectPropertySetter(XSD.readString),
'AccessConstraints': makeObjectPropertySetter(XSD.readString),
'Fees': makeObjectPropertySetter(XSD.readString),
'Title': makeObjectPropertySetter(XSD.readString),
'ServiceTypeVersion': makeObjectPropertySetter(
XSD.readString),
'ServiceType': makeObjectPropertySetter(XSD.readString)
'Abstract': makeObjectPropertySetter(readString),
'AccessConstraints': makeObjectPropertySetter(readString),
'Fees': makeObjectPropertySetter(readString),
'Title': makeObjectPropertySetter(readString),
'ServiceTypeVersion': makeObjectPropertySetter(readString),
'ServiceType': makeObjectPropertySetter(readString)
});
@@ -192,10 +181,9 @@ const SERVICE_IDENTIFICATION_PARSERS =
const SERVICE_PROVIDER_PARSERS =
makeStructureNS(
NAMESPACE_URIS, {
'ProviderName': makeObjectPropertySetter(XSD.readString),
'ProviderName': makeObjectPropertySetter(readString),
'ProviderSite': makeObjectPropertySetter(readHref),
'ServiceContact': makeObjectPropertySetter(
readServiceContact)
'ServiceContact': makeObjectPropertySetter(readServiceContact)
});
@@ -303,8 +291,7 @@ function readGet(node, objectStack) {
* @return {Object|undefined} The HTTP object.
*/
function readHttp(node, objectStack) {
return pushParseAndPop({}, HTTP_PARSERS,
node, objectStack);
return pushParseAndPop({}, HTTP_PARSERS, node, objectStack);
}
@@ -331,8 +318,7 @@ function readOperation(node, objectStack) {
* @param {Array.<*>} objectStack Object stack.
* @return {Object|undefined} The operations metadata.
*/
function readOperationsMetadata(node,
objectStack) {
function readOperationsMetadata(node, objectStack) {
return pushParseAndPop({},
OPERATIONS_METADATA_PARSERS, node,
objectStack);
@@ -355,8 +341,7 @@ function readPhone(node, objectStack) {
* @param {Array.<*>} objectStack Object stack.
* @return {Object|undefined} The service identification.
*/
function readServiceIdentification(node,
objectStack) {
function readServiceIdentification(node, objectStack) {
return pushParseAndPop(
{}, SERVICE_IDENTIFICATION_PARSERS, node,
objectStack);
@@ -393,7 +378,7 @@ function readServiceProvider(node, objectStack) {
* @return {string|undefined} The value.
*/
function readValue(node, objectStack) {
return XSD.readString(node);
return readString(node);
}

View File

@@ -5,10 +5,10 @@ import {inherits} from '../index.js';
import {assert} from '../asserts.js';
import GML2 from '../format/GML2.js';
import GML3 from '../format/GML3.js';
import GMLBase from '../format/GMLBase.js';
import GMLBase, {GMLNS} from '../format/GMLBase.js';
import {and as andFilter, bbox as bboxFilter} from '../format/filter.js';
import XMLFeature from '../format/XMLFeature.js';
import XSD from '../format/XSD.js';
import {readNonNegativeIntegerString, readNonNegativeInteger, writeStringTextNode} from '../format/xsd.js';
import Geometry from '../geom/Geometry.js';
import {assign} from '../obj.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 : {}));
const objectStack = [context];
this.gmlFormat_.FEATURE_COLLECTION_PARSERS[GMLBase.GMLNS][
this.gmlFormat_.FEATURE_COLLECTION_PARSERS[GMLNS][
'featureMember'] =
makeArrayPusher(GMLBase.prototype.readFeaturesInternal);
let features = pushParseAndPop([],
@@ -242,7 +242,7 @@ const FEATURE_COLLECTION_PARSERS = {
*/
WFS.prototype.readFeatureCollectionMetadataFromNode = function(node) {
const result = {};
const value = XSD.readNonNegativeIntegerString(
const value = readNonNegativeIntegerString(
node.getAttribute('numberOfFeatures'));
result['numberOfFeatures'] = value;
return pushParseAndPop(
@@ -257,12 +257,9 @@ WFS.prototype.readFeatureCollectionMetadataFromNode = function(node) {
*/
const TRANSACTION_SUMMARY_PARSERS = {
'http://www.opengis.net/wfs': {
'totalInserted': makeObjectPropertySetter(
XSD.readNonNegativeInteger),
'totalUpdated': makeObjectPropertySetter(
XSD.readNonNegativeInteger),
'totalDeleted': makeObjectPropertySetter(
XSD.readNonNegativeInteger)
'totalInserted': makeObjectPropertySetter(readNonNegativeInteger),
'totalUpdated': makeObjectPropertySetter(readNonNegativeInteger),
'totalDeleted': makeObjectPropertySetter(readNonNegativeInteger)
}
};
@@ -366,7 +363,7 @@ WFS.prototype.readTransactionResponseFromNode = function(node) {
*/
const QUERY_SERIALIZERS = {
'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 gmlVersion = context['gmlVersion'];
node.appendChild(name);
XSD.writeStringTextNode(name, pair.name);
writeStringTextNode(name, pair.name);
if (pair.value !== undefined && pair.value !== null) {
const value = createElementNS(WFSNS, 'Value');
node.appendChild(value);
@@ -520,7 +517,7 @@ function writeProperty(node, pair, objectStack) {
pair.value, objectStack);
}
} else {
XSD.writeStringTextNode(value, pair.value);
writeStringTextNode(value, pair.value);
}
}
}
@@ -540,7 +537,7 @@ function writeNative(node, nativeElement, objectStack) {
node.setAttribute('safeToIgnore', nativeElement.safeToIgnore);
}
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) {
const valueReference = createElementNS(FESNS, 'ValueReference');
XSD.writeStringTextNode(valueReference, filter.propertyName);
writeStringTextNode(valueReference, filter.propertyName);
node.appendChild(valueReference);
const timePeriod = createElementNS(GMLBase.GMLNS, 'TimePeriod');
const timePeriod = createElementNS(GMLNS, 'TimePeriod');
node.appendChild(timePeriod);
const begin = createElementNS(GMLBase.GMLNS, 'begin');
const begin = createElementNS(GMLNS, 'begin');
timePeriod.appendChild(begin);
writeTimeInstant(begin, filter.begin);
const end = createElementNS(GMLBase.GMLNS, 'end');
const end = createElementNS(GMLNS, 'end');
timePeriod.appendChild(end);
writeTimeInstant(end, filter.end);
}
@@ -811,7 +808,7 @@ function writeIsLikeFilter(node, filter, objectStack) {
*/
function writeOgcExpression(tagName, node, value) {
const property = createElementNS(OGCNS, tagName);
XSD.writeStringTextNode(property, value);
writeStringTextNode(property, value);
node.appendChild(property);
}
@@ -839,12 +836,12 @@ function writeOgcLiteral(node, value) {
* @param {string} time PropertyName value.
*/
function writeTimeInstant(node, time) {
const timeInstant = createElementNS(GMLBase.GMLNS, 'TimeInstant');
const timeInstant = createElementNS(GMLNS, 'TimeInstant');
node.appendChild(timeInstant);
const timePosition = createElementNS(GMLBase.GMLNS, 'timePosition');
const timePosition = createElementNS(GMLNS, 'timePosition');
timeInstant.appendChild(timePosition);
XSD.writeStringTextNode(timePosition, time);
writeStringTextNode(timePosition, time);
}

View File

@@ -4,7 +4,7 @@
import {inherits} from '../index.js';
import {readHref} from '../format/XLink.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,
makeStructureNS, pushParseAndPop} from '../xml.js';
@@ -69,17 +69,17 @@ const CAPABILITY_PARSERS = makeStructureNS(
*/
const SERVICE_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'Name': makeObjectPropertySetter(XSD.readString),
'Title': makeObjectPropertySetter(XSD.readString),
'Abstract': makeObjectPropertySetter(XSD.readString),
'Name': makeObjectPropertySetter(readString),
'Title': makeObjectPropertySetter(readString),
'Abstract': makeObjectPropertySetter(readString),
'KeywordList': makeObjectPropertySetter(readKeywordList),
'OnlineResource': makeObjectPropertySetter(readHref),
'ContactInformation': makeObjectPropertySetter(readContactInformation),
'Fees': makeObjectPropertySetter(XSD.readString),
'AccessConstraints': makeObjectPropertySetter(XSD.readString),
'LayerLimit': makeObjectPropertySetter(XSD.readNonNegativeInteger),
'MaxWidth': makeObjectPropertySetter(XSD.readNonNegativeInteger),
'MaxHeight': makeObjectPropertySetter(XSD.readNonNegativeInteger)
'Fees': makeObjectPropertySetter(readString),
'AccessConstraints': makeObjectPropertySetter(readString),
'LayerLimit': makeObjectPropertySetter(readNonNegativeInteger),
'MaxWidth': makeObjectPropertySetter(readNonNegativeInteger),
'MaxHeight': makeObjectPropertySetter(readNonNegativeInteger)
});
@@ -90,11 +90,11 @@ const SERVICE_PARSERS = makeStructureNS(
const CONTACT_INFORMATION_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'ContactPersonPrimary': makeObjectPropertySetter(readContactPersonPrimary),
'ContactPosition': makeObjectPropertySetter(XSD.readString),
'ContactPosition': makeObjectPropertySetter(readString),
'ContactAddress': makeObjectPropertySetter(readContactAddress),
'ContactVoiceTelephone': makeObjectPropertySetter(XSD.readString),
'ContactFacsimileTelephone': makeObjectPropertySetter(XSD.readString),
'ContactElectronicMailAddress': makeObjectPropertySetter(XSD.readString)
'ContactVoiceTelephone': makeObjectPropertySetter(readString),
'ContactFacsimileTelephone': makeObjectPropertySetter(readString),
'ContactElectronicMailAddress': makeObjectPropertySetter(readString)
});
@@ -104,8 +104,8 @@ const CONTACT_INFORMATION_PARSERS = makeStructureNS(
*/
const CONTACT_PERSON_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'ContactPerson': makeObjectPropertySetter(XSD.readString),
'ContactOrganization': makeObjectPropertySetter(XSD.readString)
'ContactPerson': makeObjectPropertySetter(readString),
'ContactOrganization': makeObjectPropertySetter(readString)
});
@@ -115,12 +115,12 @@ const CONTACT_PERSON_PARSERS = makeStructureNS(
*/
const CONTACT_ADDRESS_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'AddressType': makeObjectPropertySetter(XSD.readString),
'Address': makeObjectPropertySetter(XSD.readString),
'City': makeObjectPropertySetter(XSD.readString),
'StateOrProvince': makeObjectPropertySetter(XSD.readString),
'PostCode': makeObjectPropertySetter(XSD.readString),
'Country': makeObjectPropertySetter(XSD.readString)
'AddressType': makeObjectPropertySetter(readString),
'Address': makeObjectPropertySetter(readString),
'City': makeObjectPropertySetter(readString),
'StateOrProvince': makeObjectPropertySetter(readString),
'PostCode': makeObjectPropertySetter(readString),
'Country': makeObjectPropertySetter(readString)
});
@@ -130,7 +130,7 @@ const CONTACT_ADDRESS_PARSERS = makeStructureNS(
*/
const EXCEPTION_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'Format': makeArrayPusher(XSD.readString)
'Format': makeArrayPusher(readString)
});
@@ -140,23 +140,23 @@ const EXCEPTION_PARSERS = makeStructureNS(
*/
const LAYER_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'Name': makeObjectPropertySetter(XSD.readString),
'Title': makeObjectPropertySetter(XSD.readString),
'Abstract': makeObjectPropertySetter(XSD.readString),
'Name': makeObjectPropertySetter(readString),
'Title': makeObjectPropertySetter(readString),
'Abstract': makeObjectPropertySetter(readString),
'KeywordList': makeObjectPropertySetter(readKeywordList),
'CRS': makeObjectPropertyPusher(XSD.readString),
'CRS': makeObjectPropertyPusher(readString),
'EX_GeographicBoundingBox': makeObjectPropertySetter(readEXGeographicBoundingBox),
'BoundingBox': makeObjectPropertyPusher(readBoundingBox),
'Dimension': makeObjectPropertyPusher(readDimension),
'Attribution': makeObjectPropertySetter(readAttribution),
'AuthorityURL': makeObjectPropertyPusher(readAuthorityURL),
'Identifier': makeObjectPropertyPusher(XSD.readString),
'Identifier': makeObjectPropertyPusher(readString),
'MetadataURL': makeObjectPropertyPusher(readMetadataURL),
'DataURL': makeObjectPropertyPusher(readFormatOnlineresource),
'FeatureListURL': makeObjectPropertyPusher(readFormatOnlineresource),
'Style': makeObjectPropertyPusher(readStyle),
'MinScaleDenominator': makeObjectPropertySetter(XSD.readDecimal),
'MaxScaleDenominator': makeObjectPropertySetter(XSD.readDecimal),
'MinScaleDenominator': makeObjectPropertySetter(readDecimal),
'MaxScaleDenominator': makeObjectPropertySetter(readDecimal),
'Layer': makeObjectPropertyPusher(readLayer)
});
@@ -167,7 +167,7 @@ const LAYER_PARSERS = makeStructureNS(
*/
const ATTRIBUTION_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'Title': makeObjectPropertySetter(XSD.readString),
'Title': makeObjectPropertySetter(readString),
'OnlineResource': makeObjectPropertySetter(readHref),
'LogoURL': makeObjectPropertySetter(readSizedFormatOnlineresource)
});
@@ -179,10 +179,10 @@ const ATTRIBUTION_PARSERS = makeStructureNS(
*/
const EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS =
makeStructureNS(NAMESPACE_URIS, {
'westBoundLongitude': makeObjectPropertySetter(XSD.readDecimal),
'eastBoundLongitude': makeObjectPropertySetter(XSD.readDecimal),
'southBoundLatitude': makeObjectPropertySetter(XSD.readDecimal),
'northBoundLatitude': makeObjectPropertySetter(XSD.readDecimal)
'westBoundLongitude': makeObjectPropertySetter(readDecimal),
'eastBoundLongitude': makeObjectPropertySetter(readDecimal),
'southBoundLatitude': makeObjectPropertySetter(readDecimal),
'northBoundLatitude': makeObjectPropertySetter(readDecimal)
});
@@ -204,7 +204,7 @@ const REQUEST_PARSERS = makeStructureNS(
*/
const OPERATIONTYPE_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'Format': makeObjectPropertyPusher(XSD.readString),
'Format': makeObjectPropertyPusher(readString),
'DCPType': makeObjectPropertyPusher(readDCPType)
});
@@ -236,9 +236,9 @@ const HTTP_PARSERS = makeStructureNS(
*/
const STYLE_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'Name': makeObjectPropertySetter(XSD.readString),
'Title': makeObjectPropertySetter(XSD.readString),
'Abstract': makeObjectPropertySetter(XSD.readString),
'Name': makeObjectPropertySetter(readString),
'Title': makeObjectPropertySetter(readString),
'Abstract': makeObjectPropertySetter(readString),
'LegendURL': makeObjectPropertyPusher(readSizedFormatOnlineresource),
'StyleSheetURL': makeObjectPropertySetter(readFormatOnlineresource),
'StyleURL': makeObjectPropertySetter(readFormatOnlineresource)
@@ -251,7 +251,7 @@ const STYLE_PARSERS = makeStructureNS(
*/
const FORMAT_ONLINERESOURCE_PARSERS =
makeStructureNS(NAMESPACE_URIS, {
'Format': makeObjectPropertySetter(XSD.readString),
'Format': makeObjectPropertySetter(readString),
'OnlineResource': makeObjectPropertySetter(readHref)
});
@@ -262,7 +262,7 @@ const FORMAT_ONLINERESOURCE_PARSERS =
*/
const KEYWORDLIST_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'Keyword': makeArrayPusher(XSD.readString)
'Keyword': makeArrayPusher(readString)
});
@@ -319,15 +319,15 @@ function readAttribution(node, objectStack) {
*/
function readBoundingBox(node, objectStack) {
const extent = [
XSD.readDecimalString(node.getAttribute('minx')),
XSD.readDecimalString(node.getAttribute('miny')),
XSD.readDecimalString(node.getAttribute('maxx')),
XSD.readDecimalString(node.getAttribute('maxy'))
readDecimalString(node.getAttribute('minx')),
readDecimalString(node.getAttribute('miny')),
readDecimalString(node.getAttribute('maxx')),
readDecimalString(node.getAttribute('maxy'))
];
const resolutions = [
XSD.readDecimalString(node.getAttribute('resx')),
XSD.readDecimalString(node.getAttribute('resy'))
readDecimalString(node.getAttribute('resx')),
readDecimalString(node.getAttribute('resy'))
];
return {
@@ -454,38 +454,38 @@ function readLayer(node, objectStack) {
if (!layerObject) {
return undefined;
}
let queryable = XSD.readBooleanString(node.getAttribute('queryable'));
let queryable = readBooleanString(node.getAttribute('queryable'));
if (queryable === undefined) {
queryable = parentLayerObject['queryable'];
}
layerObject['queryable'] = queryable !== undefined ? queryable : false;
let cascaded = XSD.readNonNegativeIntegerString(
let cascaded = readNonNegativeIntegerString(
node.getAttribute('cascaded'));
if (cascaded === undefined) {
cascaded = parentLayerObject['cascaded'];
}
layerObject['cascaded'] = cascaded;
let opaque = XSD.readBooleanString(node.getAttribute('opaque'));
let opaque = readBooleanString(node.getAttribute('opaque'));
if (opaque === undefined) {
opaque = parentLayerObject['opaque'];
}
layerObject['opaque'] = opaque !== undefined ? opaque : false;
let noSubsets = XSD.readBooleanString(node.getAttribute('noSubsets'));
let noSubsets = readBooleanString(node.getAttribute('noSubsets'));
if (noSubsets === undefined) {
noSubsets = parentLayerObject['noSubsets'];
}
layerObject['noSubsets'] = noSubsets !== undefined ? noSubsets : false;
let fixedWidth = XSD.readDecimalString(node.getAttribute('fixedWidth'));
let fixedWidth = readDecimalString(node.getAttribute('fixedWidth'));
if (!fixedWidth) {
fixedWidth = parentLayerObject['fixedWidth'];
}
layerObject['fixedWidth'] = fixedWidth;
let fixedHeight = XSD.readDecimalString(node.getAttribute('fixedHeight'));
let fixedHeight = readDecimalString(node.getAttribute('fixedHeight'));
if (!fixedHeight) {
fixedHeight = parentLayerObject['fixedHeight'];
}
@@ -524,10 +524,10 @@ function readDimension(node, objectStack) {
'units': node.getAttribute('units'),
'unitSymbol': node.getAttribute('unitSymbol'),
'default': node.getAttribute('default'),
'multipleValues': XSD.readBooleanString(node.getAttribute('multipleValues')),
'nearestValue': XSD.readBooleanString(node.getAttribute('nearestValue')),
'current': XSD.readBooleanString(node.getAttribute('current')),
'values': XSD.readString(node)
'multipleValues': readBooleanString(node.getAttribute('multipleValues')),
'nearestValue': readBooleanString(node.getAttribute('nearestValue')),
'current': readBooleanString(node.getAttribute('current')),
'values': readString(node)
};
return dimensionObject;
}
@@ -592,8 +592,8 @@ function readSizedFormatOnlineresource(node, objectStack) {
const formatOnlineresource = readFormatOnlineresource(node, objectStack);
if (formatOnlineresource) {
const size = [
XSD.readNonNegativeIntegerString(node.getAttribute('width')),
XSD.readNonNegativeIntegerString(node.getAttribute('height'))
readNonNegativeIntegerString(node.getAttribute('width')),
readNonNegativeIntegerString(node.getAttribute('height'))
];
formatOnlineresource['size'] = size;
return formatOnlineresource;

View File

@@ -6,7 +6,7 @@ import {boundingExtent} from '../extent.js';
import OWS from '../format/OWS.js';
import {readHref} from '../format/XLink.js';
import XML from '../format/XML.js';
import XSD from '../format/XSD.js';
import {readString, readNonNegativeInteger, readDecimal} from '../format/xsd.js';
import {pushParseAndPop, makeStructureNS,
makeObjectPropertySetter, makeObjectPropertyPusher, makeArrayPusher} from '../xml.js';
@@ -79,15 +79,15 @@ const CONTENTS_PARSERS = makeStructureNS(
const LAYER_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'Style': makeObjectPropertyPusher(readStyle),
'Format': makeObjectPropertyPusher(XSD.readString),
'Format': makeObjectPropertyPusher(readString),
'TileMatrixSetLink': makeObjectPropertyPusher(readTileMatrixSetLink),
'Dimension': makeObjectPropertyPusher(readDimensions),
'ResourceURL': makeObjectPropertyPusher(readResourceUrl)
}, makeStructureNS(OWS_NAMESPACE_URIS, {
'Title': makeObjectPropertySetter(XSD.readString),
'Abstract': makeObjectPropertySetter(XSD.readString),
'Title': makeObjectPropertySetter(readString),
'Abstract': makeObjectPropertySetter(readString),
'WGS84BoundingBox': makeObjectPropertySetter(readWgs84BoundingBox),
'Identifier': makeObjectPropertySetter(XSD.readString)
'Identifier': makeObjectPropertySetter(readString)
}));
@@ -99,8 +99,8 @@ const STYLE_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'LegendURL': makeObjectPropertyPusher(readLegendUrl)
}, makeStructureNS(OWS_NAMESPACE_URIS, {
'Title': makeObjectPropertySetter(XSD.readString),
'Identifier': makeObjectPropertySetter(XSD.readString)
'Title': makeObjectPropertySetter(readString),
'Identifier': makeObjectPropertySetter(readString)
}));
@@ -110,7 +110,7 @@ const STYLE_PARSERS = makeStructureNS(
*/
const TMS_LINKS_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'TileMatrixSet': makeObjectPropertySetter(XSD.readString),
'TileMatrixSet': makeObjectPropertySetter(readString),
'TileMatrixSetLimits': makeObjectPropertySetter(readTileMatrixLimitsList)
});
@@ -130,11 +130,11 @@ const TMS_LIMITS_LIST_PARSERS = makeStructureNS(
*/
const TMS_LIMITS_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'TileMatrix': makeObjectPropertySetter(XSD.readString),
'MinTileRow': makeObjectPropertySetter(XSD.readNonNegativeInteger),
'MaxTileRow': makeObjectPropertySetter(XSD.readNonNegativeInteger),
'MinTileCol': makeObjectPropertySetter(XSD.readNonNegativeInteger),
'MaxTileCol': makeObjectPropertySetter(XSD.readNonNegativeInteger)
'TileMatrix': makeObjectPropertySetter(readString),
'MinTileRow': makeObjectPropertySetter(readNonNegativeInteger),
'MaxTileRow': makeObjectPropertySetter(readNonNegativeInteger),
'MinTileCol': makeObjectPropertySetter(readNonNegativeInteger),
'MaxTileCol': makeObjectPropertySetter(readNonNegativeInteger)
});
@@ -144,10 +144,10 @@ const TMS_LIMITS_PARSERS = makeStructureNS(
*/
const DIMENSION_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'Default': makeObjectPropertySetter(XSD.readString),
'Value': makeObjectPropertyPusher(XSD.readString)
'Default': makeObjectPropertySetter(readString),
'Value': makeObjectPropertyPusher(readString)
}, makeStructureNS(OWS_NAMESPACE_URIS, {
'Identifier': makeObjectPropertySetter(XSD.readString)
'Identifier': makeObjectPropertySetter(readString)
}));
@@ -168,11 +168,11 @@ const WGS84_BBOX_READERS = makeStructureNS(
*/
const TMS_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'WellKnownScaleSet': makeObjectPropertySetter(XSD.readString),
'WellKnownScaleSet': makeObjectPropertySetter(readString),
'TileMatrix': makeObjectPropertyPusher(readTileMatrix)
}, makeStructureNS(OWS_NAMESPACE_URIS, {
'SupportedCRS': makeObjectPropertySetter(XSD.readString),
'Identifier': makeObjectPropertySetter(XSD.readString)
'SupportedCRS': makeObjectPropertySetter(readString),
'Identifier': makeObjectPropertySetter(readString)
}));
@@ -183,13 +183,13 @@ const TMS_PARSERS = makeStructureNS(
const TM_PARSERS = makeStructureNS(
NAMESPACE_URIS, {
'TopLeftCorner': makeObjectPropertySetter(readCoordinates),
'ScaleDenominator': makeObjectPropertySetter(XSD.readDecimal),
'TileWidth': makeObjectPropertySetter(XSD.readNonNegativeInteger),
'TileHeight': makeObjectPropertySetter(XSD.readNonNegativeInteger),
'MatrixWidth': makeObjectPropertySetter(XSD.readNonNegativeInteger),
'MatrixHeight': makeObjectPropertySetter(XSD.readNonNegativeInteger)
'ScaleDenominator': makeObjectPropertySetter(readDecimal),
'TileWidth': makeObjectPropertySetter(readNonNegativeInteger),
'TileHeight': makeObjectPropertySetter(readNonNegativeInteger),
'MatrixWidth': makeObjectPropertySetter(readNonNegativeInteger),
'MatrixHeight': makeObjectPropertySetter(readNonNegativeInteger)
}, makeStructureNS(OWS_NAMESPACE_URIS, {
'Identifier': makeObjectPropertySetter(XSD.readString)
'Identifier': makeObjectPropertySetter(readString)
}));
@@ -355,7 +355,7 @@ function readLegendUrl(node, objectStack) {
* @return {Object|undefined} Coordinates object.
*/
function readCoordinates(node, objectStack) {
const coordinates = XSD.readString(node).split(' ');
const coordinates = readString(node).split(' ');
if (!coordinates || coordinates.length != 2) {
return undefined;
}

View File

@@ -1,61 +1,60 @@
/**
* @module ol/format/XSD
* @module ol/format/xsd
*/
import {getAllTextContent, DOCUMENT} from '../xml.js';
import {padNumber} from '../string.js';
const XSD = {};
/**
* @param {Node} node Node.
* @return {boolean|undefined} Boolean.
*/
XSD.readBoolean = function(node) {
export function readBoolean(node) {
const s = getAllTextContent(node, false);
return XSD.readBooleanString(s);
};
return readBooleanString(s);
}
/**
* @param {string} string String.
* @return {boolean|undefined} Boolean.
*/
XSD.readBooleanString = function(string) {
export function readBooleanString(string) {
const m = /^\s*(true|1)|(false|0)\s*$/.exec(string);
if (m) {
return m[1] !== undefined || false;
} else {
return undefined;
}
};
}
/**
* @param {Node} node Node.
* @return {number|undefined} DateTime in seconds.
*/
XSD.readDateTime = function(node) {
export function readDateTime(node) {
const s = getAllTextContent(node, false);
const dateTime = Date.parse(s);
return isNaN(dateTime) ? undefined : dateTime / 1000;
};
}
/**
* @param {Node} node Node.
* @return {number|undefined} Decimal.
*/
XSD.readDecimal = function(node) {
export function readDecimal(node) {
const s = getAllTextContent(node, false);
return XSD.readDecimalString(s);
};
return readDecimalString(s);
}
/**
* @param {string} string String.
* @return {number|undefined} Decimal.
*/
XSD.readDecimalString = function(string) {
export function readDecimalString(string) {
// FIXME check spec
const m = /^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(string);
if (m) {
@@ -63,65 +62,65 @@ XSD.readDecimalString = function(string) {
} else {
return undefined;
}
};
}
/**
* @param {Node} node Node.
* @return {number|undefined} Non negative integer.
*/
XSD.readNonNegativeInteger = function(node) {
export function readNonNegativeInteger(node) {
const s = getAllTextContent(node, false);
return XSD.readNonNegativeIntegerString(s);
};
return readNonNegativeIntegerString(s);
}
/**
* @param {string} string String.
* @return {number|undefined} Non negative integer.
*/
XSD.readNonNegativeIntegerString = function(string) {
export function readNonNegativeIntegerString(string) {
const m = /^\s*(\d+)\s*$/.exec(string);
if (m) {
return parseInt(m[1], 10);
} else {
return undefined;
}
};
}
/**
* @param {Node} node Node.
* @return {string|undefined} String.
*/
XSD.readString = function(node) {
export function readString(node) {
return getAllTextContent(node, false).trim();
};
}
/**
* @param {Node} node Node to append a TextNode with the boolean to.
* @param {boolean} bool Boolean.
*/
XSD.writeBooleanTextNode = function(node, bool) {
XSD.writeStringTextNode(node, (bool) ? '1' : '0');
};
export function writeBooleanTextNode(node, bool) {
writeStringTextNode(node, (bool) ? '1' : '0');
}
/**
* @param {Node} node Node to append a CDATA Section with the string to.
* @param {string} string String.
*/
XSD.writeCDATASection = function(node, string) {
export function writeCDATASection(node, string) {
node.appendChild(DOCUMENT.createCDATASection(string));
};
}
/**
* @param {Node} node Node to append a TextNode with the dateTime to.
* @param {number} dateTime DateTime in seconds.
*/
XSD.writeDateTimeTextNode = function(node, dateTime) {
export function writeDateTimeTextNode(node, dateTime) {
const date = new Date(dateTime * 1000);
const string = date.getUTCFullYear() + '-' +
padNumber(date.getUTCMonth() + 1, 2) + '-' +
@@ -130,34 +129,33 @@ XSD.writeDateTimeTextNode = function(node, dateTime) {
padNumber(date.getUTCMinutes(), 2) + ':' +
padNumber(date.getUTCSeconds(), 2) + 'Z';
node.appendChild(DOCUMENT.createTextNode(string));
};
}
/**
* @param {Node} node Node to append a TextNode with the decimal to.
* @param {number} decimal Decimal.
*/
XSD.writeDecimalTextNode = function(node, decimal) {
export function writeDecimalTextNode(node, decimal) {
const string = decimal.toPrecision();
node.appendChild(DOCUMENT.createTextNode(string));
};
}
/**
* @param {Node} node Node to append a TextNode with the decimal to.
* @param {number} nonNegativeInteger Non negative integer.
*/
XSD.writeNonNegativeIntegerTextNode = function(node, nonNegativeInteger) {
export function writeNonNegativeIntegerTextNode(node, nonNegativeInteger) {
const string = nonNegativeInteger.toString();
node.appendChild(DOCUMENT.createTextNode(string));
};
}
/**
* @param {Node} node Node to append a TextNode with the string to.
* @param {string} string String.
*/
XSD.writeStringTextNode = function(node, string) {
export function writeStringTextNode(node, string) {
node.appendChild(DOCUMENT.createTextNode(string));
};
export default XSD;
}

View File

@@ -321,7 +321,7 @@ SimpleGeometry.prototype.translate = function(deltaX, deltaY) {
* @param {Array.<number>=} opt_dest Destination.
* @return {Array.<number>} Transformed flat coordinates.
*/
SimpleGeometry.transform2D = function(simpleGeometry, transform, opt_dest) {
export function transformGeom2D(simpleGeometry, transform, opt_dest) {
const flatCoordinates = simpleGeometry.getFlatCoordinates();
if (!flatCoordinates) {
return null;
@@ -331,5 +331,6 @@ SimpleGeometry.transform2D = function(simpleGeometry, transform, opt_dest) {
flatCoordinates, 0, flatCoordinates.length, stride,
transform, opt_dest);
}
};
}
export default SimpleGeometry;

View File

@@ -25,7 +25,7 @@ const DoubleClickZoom = function(opt_options) {
this.delta_ = options.delta ? options.delta : 1;
Interaction.call(this, {
handleEvent: DoubleClickZoom.handleEvent
handleEvent: handleEvent
});
/**
@@ -45,9 +45,8 @@ inherits(DoubleClickZoom, Interaction);
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.DoubleClickZoom}
* @api
*/
DoubleClickZoom.handleEvent = function(mapBrowserEvent) {
function handleEvent(mapBrowserEvent) {
let stopEvent = false;
const browserEvent = mapBrowserEvent.originalEvent;
if (mapBrowserEvent.type == MapBrowserEventType.DBLCLICK) {
@@ -60,5 +59,6 @@ DoubleClickZoom.handleEvent = function(mapBrowserEvent) {
stopEvent = true;
}
return !stopEvent;
};
}
export default DoubleClickZoom;

View File

@@ -18,20 +18,62 @@ import {get as getProjection} from '../proj.js';
const DragAndDropEventType = {
/**
* Triggered when features are added
* @event ol.interaction.DragAndDrop.Event#addfeatures
* @event ol.interaction.DragAndDropEvent#addfeatures
* @api
*/
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
* Handles input of vector data by drag and drop.
*
* @constructor
* @extends {ol.interaction.Interaction}
* @fires ol.interaction.DragAndDrop.Event
* @fires ol.interaction.DragAndDropEvent
* @param {olx.interaction.DragAndDropOptions=} opt_options Options.
* @api
*/
@@ -40,7 +82,7 @@ const DragAndDrop = function(opt_options) {
const options = opt_options ? opt_options : {};
Interaction.call(this, {
handleEvent: DragAndDrop.handleEvent
handleEvent: TRUE
});
/**
@@ -146,23 +188,12 @@ DragAndDrop.prototype.handleResult_ = function(file, event) {
this.source_.addFeatures(features);
}
this.dispatchEvent(
new DragAndDrop.Event(
new DragAndDropEvent(
DragAndDropEventType.ADD_FEATURES, file,
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
*/
@@ -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;

View File

@@ -23,7 +23,7 @@ import MouseSource from '../pointer/MouseSource.js';
import Point from '../geom/Point.js';
import Polygon, {fromCircle, makeRegular} from '../geom/Polygon.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 VectorLayer from '../layer/Vector.js';
import VectorSource from '../source/Vector.js';
@@ -398,7 +398,7 @@ export function handleEvent(event) {
pass = false;
}
return PointerInteraction.handleEvent.call(this, event) && pass;
return handlePointerEvent.call(this, event) && pass;
}

View File

@@ -12,7 +12,7 @@ import GeometryType from '../geom/GeometryType.js';
import Point from '../geom/Point.js';
import {fromExtent as polygonFromExtent} from '../geom/Polygon.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 VectorSource from '../source/Vector.js';
import Style from '../style/Style.js';
@@ -139,7 +139,7 @@ function handleEvent(mapBrowserEvent) {
this.handlePointerMove_(mapBrowserEvent);
}
//call pointer to determine up/down/drag
PointerInteraction.handleEvent.call(this, mapBrowserEvent);
handlePointerEvent.call(this, mapBrowserEvent);
//return false to stop propagation
return false;
}

View File

@@ -28,7 +28,7 @@ import Interaction from '../interaction/Interaction.js';
const KeyboardPan = function(opt_options) {
Interaction.call(this, {
handleEvent: KeyboardPan.handleEvent
handleEvent: handleEvent
});
const options = opt_options || {};
@@ -74,9 +74,8 @@ inherits(KeyboardPan, Interaction);
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.KeyboardPan}
* @api
*/
KeyboardPan.handleEvent = function(mapBrowserEvent) {
function handleEvent(mapBrowserEvent) {
let stopEvent = false;
if (mapBrowserEvent.type == EventType.KEYDOWN) {
const keyEvent = mapBrowserEvent.originalEvent;
@@ -107,5 +106,6 @@ KeyboardPan.handleEvent = function(mapBrowserEvent) {
}
}
return !stopEvent;
};
}
export default KeyboardPan;

View File

@@ -26,7 +26,7 @@ import Interaction from '../interaction/Interaction.js';
const KeyboardZoom = function(opt_options) {
Interaction.call(this, {
handleEvent: KeyboardZoom.handleEvent
handleEvent: handleEvent
});
const options = opt_options ? opt_options : {};
@@ -61,9 +61,8 @@ inherits(KeyboardZoom, Interaction);
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.KeyboardZoom}
* @api
*/
KeyboardZoom.handleEvent = function(mapBrowserEvent) {
function handleEvent(mapBrowserEvent) {
let stopEvent = false;
if (mapBrowserEvent.type == EventType.KEYDOWN ||
mapBrowserEvent.type == EventType.KEYPRESS) {
@@ -81,5 +80,6 @@ KeyboardZoom.handleEvent = function(mapBrowserEvent) {
}
}
return !stopEvent;
};
}
export default KeyboardZoom;

View File

@@ -17,7 +17,7 @@ import {boundingExtent, buffer, createOrUpdateFromCoordinate} from '../extent.js
import GeometryType from '../geom/GeometryType.js';
import Point from '../geom/Point.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 VectorSource from '../source/Vector.js';
import VectorEventType from '../source/VectorEventType.js';
@@ -48,7 +48,7 @@ const Modify = function(options) {
PointerInteraction.call(this, {
handleDownEvent: handleDownEvent,
handleDragEvent: handleDragEvent,
handleEvent: Modify.handleEvent,
handleEvent: handleEvent,
handleUpEvent: handleUpEvent
});
@@ -789,9 +789,8 @@ function handleUpEvent(evt) {
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.Modify}
* @api
*/
Modify.handleEvent = function(mapBrowserEvent) {
function handleEvent(mapBrowserEvent) {
if (!(mapBrowserEvent instanceof MapBrowserPointerEvent)) {
return true;
}
@@ -815,8 +814,8 @@ Modify.handleEvent = function(mapBrowserEvent) {
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;
};
inherits(Modify.Event, Event);
export default Modify;

View File

@@ -39,7 +39,7 @@ export const Mode = {
const MouseWheelZoom = function(opt_options) {
Interaction.call(this, {
handleEvent: MouseWheelZoom.handleEvent
handleEvent: handleEvent
});
const options = opt_options || {};
@@ -141,9 +141,8 @@ inherits(MouseWheelZoom, Interaction);
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} Allow event propagation.
* @this {ol.interaction.MouseWheelZoom}
* @api
*/
MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
function handleEvent(mapBrowserEvent) {
if (!this.condition_(mapBrowserEvent)) {
return true;
}
@@ -257,7 +256,7 @@ MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
this.timeoutId_ = setTimeout(this.handleWheelZoom_.bind(this, map), timeLeft);
return false;
};
}
/**

View File

@@ -27,11 +27,8 @@ const PointerInteraction = function(opt_options) {
const options = opt_options ? opt_options : {};
const handleEvent = options.handleEvent ?
options.handleEvent : PointerInteraction.handleEvent;
Interaction.call(this, {
handleEvent: handleEvent
handleEvent: options.handleEvent || handleEvent
});
/**
@@ -177,7 +174,7 @@ PointerInteraction.handleMoveEvent = nullFunction;
* @this {ol.interaction.Pointer}
* @api
*/
PointerInteraction.handleEvent = function(mapBrowserEvent) {
export function handleEvent(mapBrowserEvent) {
if (!(mapBrowserEvent instanceof MapBrowserPointerEvent)) {
return true;
}
@@ -201,7 +198,7 @@ PointerInteraction.handleEvent = function(mapBrowserEvent) {
}
}
return !stopEvent;
};
}
/**

View File

@@ -50,7 +50,7 @@ const SelectEventType = {
const Select = function(opt_options) {
Interaction.call(this, {
handleEvent: Select.handleEvent
handleEvent: handleEvent
});
const options = opt_options ? opt_options : {};
@@ -207,9 +207,8 @@ Select.prototype.getLayer = function(feature) {
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.Select}
* @api
*/
Select.handleEvent = function(mapBrowserEvent) {
function handleEvent(mapBrowserEvent) {
if (!this.condition_(mapBrowserEvent)) {
return true;
}
@@ -294,7 +293,7 @@ Select.handleEvent = function(mapBrowserEvent) {
selected, deselected, mapBrowserEvent));
}
return pointerMove(mapBrowserEvent);
};
}
/**

View File

@@ -11,7 +11,7 @@ import {boundingExtent, createEmpty} from '../extent.js';
import {TRUE, FALSE} from '../functions.js';
import GeometryType from '../geom/GeometryType.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 VectorSource from '../source/Vector.js';
import VectorEventType from '../source/VectorEventType.js';
@@ -590,7 +590,7 @@ export function handleEvent(evt) {
evt.coordinate = result.vertex.slice(0, 2);
evt.pixel = result.vertexPixel;
}
return PointerInteraction.handleEvent.call(this, evt);
return handlePointerEvent.call(this, evt);
}

View File

@@ -10,7 +10,7 @@ import {equals} from '../../array.js';
import {asColorLike} from '../../colorlike.js';
import {intersects} from '../../extent.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 {CANVAS_LINE_DASH} from '../../has.js';
import VectorContext from '../VectorContext.js';
@@ -409,7 +409,7 @@ CanvasImmediateRenderer.prototype.drawCircle = function(geometry) {
if (this.strokeState_) {
this.setContextStrokeState_(this.strokeState_);
}
const pixelCoordinates = SimpleGeometry.transform2D(
const pixelCoordinates = transformGeom2D(
geometry, this.transform_, this.pixelCoordinates_);
const dx = pixelCoordinates[2] - pixelCoordinates[0];
const dy = pixelCoordinates[3] - pixelCoordinates[1];

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() {
it('can handle non-Zulu time zones', function() {
const node = document.createElement('time');
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');
});
});

View File

@@ -1,5 +1,5 @@
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';
@@ -31,8 +31,7 @@ describe('ol.geom.flat.transform', function() {
0, -0.0004088332670837288,
4480.991370439071, 1529.5752568707105
];
const pixelCoordinates = SimpleGeometry.transform2D(
multiPolygonGeometry, transform, []);
const pixelCoordinates = transformGeom2D(multiPolygonGeometry, transform, []);
expect(pixelCoordinates[0]).to.roughlyEqual(806.6035275946265, 1e-9);
expect(pixelCoordinates[1]).to.roughlyEqual(160.48916296287916, 1e-9);
expect(pixelCoordinates[2]).to.roughlyEqual(805.3521540835154, 1e-9);