Remove goog.asserts.*
This pull requests replaces type check hint assertions with type casts, library sanity check assertions with conditional console.assert statements in debug mode, and runtime sanity checks with assertions that throw an ol.AssertionError with an error code for lookup outside the library.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.format.EsriJSON');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.extent');
|
||||
@@ -56,6 +55,7 @@ ol.format.EsriJSON.readGeometry_ = function(object, opt_options) {
|
||||
if (!object) {
|
||||
return null;
|
||||
}
|
||||
/** @type {ol.geom.GeometryType} */
|
||||
var type;
|
||||
if (typeof object.x === 'number' && typeof object.y === 'number') {
|
||||
type = ol.geom.GeometryType.POINT;
|
||||
@@ -79,9 +79,8 @@ ol.format.EsriJSON.readGeometry_ = function(object, opt_options) {
|
||||
object.rings = rings;
|
||||
}
|
||||
}
|
||||
goog.asserts.assert(type, 'geometry type should be defined');
|
||||
var geometryReader = ol.format.EsriJSON.GEOMETRY_READERS_[type];
|
||||
goog.asserts.assert(geometryReader,
|
||||
ol.DEBUG && console.assert(geometryReader,
|
||||
'geometryReader should be defined');
|
||||
return /** @type {ol.geom.Geometry} */ (
|
||||
ol.format.Feature.transformWithOptions(
|
||||
@@ -145,8 +144,8 @@ ol.format.EsriJSON.convertRings_ = function(rings, layout) {
|
||||
* @return {ol.geom.Geometry} Point.
|
||||
*/
|
||||
ol.format.EsriJSON.readPointGeometry_ = function(object) {
|
||||
goog.asserts.assert(typeof object.x === 'number', 'object.x should be number');
|
||||
goog.asserts.assert(typeof object.y === 'number', 'object.y should be number');
|
||||
ol.DEBUG && console.assert(typeof object.x === 'number', 'object.x should be number');
|
||||
ol.DEBUG && console.assert(typeof object.y === 'number', 'object.y should be number');
|
||||
var point;
|
||||
if (object.m !== undefined && object.z !== undefined) {
|
||||
point = new ol.geom.Point([object.x, object.y, object.z, object.m],
|
||||
@@ -170,9 +169,9 @@ ol.format.EsriJSON.readPointGeometry_ = function(object) {
|
||||
* @return {ol.geom.Geometry} LineString.
|
||||
*/
|
||||
ol.format.EsriJSON.readLineStringGeometry_ = function(object) {
|
||||
goog.asserts.assert(Array.isArray(object.paths),
|
||||
ol.DEBUG && console.assert(Array.isArray(object.paths),
|
||||
'object.paths should be an array');
|
||||
goog.asserts.assert(object.paths.length === 1,
|
||||
ol.DEBUG && console.assert(object.paths.length === 1,
|
||||
'object.paths array length should be 1');
|
||||
var layout = ol.format.EsriJSON.getGeometryLayout_(object);
|
||||
return new ol.geom.LineString(object.paths[0], layout);
|
||||
@@ -185,9 +184,9 @@ ol.format.EsriJSON.readLineStringGeometry_ = function(object) {
|
||||
* @return {ol.geom.Geometry} MultiLineString.
|
||||
*/
|
||||
ol.format.EsriJSON.readMultiLineStringGeometry_ = function(object) {
|
||||
goog.asserts.assert(Array.isArray(object.paths),
|
||||
ol.DEBUG && console.assert(Array.isArray(object.paths),
|
||||
'object.paths should be an array');
|
||||
goog.asserts.assert(object.paths.length > 1,
|
||||
ol.DEBUG && console.assert(object.paths.length > 1,
|
||||
'object.paths array length should be more than 1');
|
||||
var layout = ol.format.EsriJSON.getGeometryLayout_(object);
|
||||
return new ol.geom.MultiLineString(object.paths, layout);
|
||||
@@ -218,7 +217,7 @@ ol.format.EsriJSON.getGeometryLayout_ = function(object) {
|
||||
* @return {ol.geom.Geometry} MultiPoint.
|
||||
*/
|
||||
ol.format.EsriJSON.readMultiPointGeometry_ = function(object) {
|
||||
goog.asserts.assert(object.points, 'object.points should be defined');
|
||||
ol.DEBUG && console.assert(object.points, 'object.points should be defined');
|
||||
var layout = ol.format.EsriJSON.getGeometryLayout_(object);
|
||||
return new ol.geom.MultiPoint(object.points, layout);
|
||||
};
|
||||
@@ -230,8 +229,8 @@ ol.format.EsriJSON.readMultiPointGeometry_ = function(object) {
|
||||
* @return {ol.geom.Geometry} MultiPolygon.
|
||||
*/
|
||||
ol.format.EsriJSON.readMultiPolygonGeometry_ = function(object) {
|
||||
goog.asserts.assert(object.rings);
|
||||
goog.asserts.assert(object.rings.length > 1,
|
||||
ol.DEBUG && console.assert(object.rings);
|
||||
ol.DEBUG && console.assert(object.rings.length > 1,
|
||||
'object.rings should have length larger than 1');
|
||||
var layout = ol.format.EsriJSON.getGeometryLayout_(object);
|
||||
return new ol.geom.MultiPolygon(
|
||||
@@ -246,7 +245,7 @@ ol.format.EsriJSON.readMultiPolygonGeometry_ = function(object) {
|
||||
* @return {ol.geom.Geometry} Polygon.
|
||||
*/
|
||||
ol.format.EsriJSON.readPolygonGeometry_ = function(object) {
|
||||
goog.asserts.assert(object.rings);
|
||||
ol.DEBUG && console.assert(object.rings);
|
||||
var layout = ol.format.EsriJSON.getGeometryLayout_(object);
|
||||
return new ol.geom.Polygon(object.rings, layout);
|
||||
};
|
||||
@@ -259,37 +258,37 @@ ol.format.EsriJSON.readPolygonGeometry_ = function(object) {
|
||||
* @return {EsriJSONGeometry} EsriJSON geometry.
|
||||
*/
|
||||
ol.format.EsriJSON.writePointGeometry_ = function(geometry, opt_options) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.Point,
|
||||
'geometry should be an ol.geom.Point');
|
||||
var coordinates = geometry.getCoordinates();
|
||||
var layout = geometry.getLayout();
|
||||
var coordinates = /** @type ol.geom.Point */ (geometry).getCoordinates();
|
||||
var esriJSON;
|
||||
var layout = /** @type ol.geom.Point */ (geometry).getLayout();
|
||||
if (layout === ol.geom.GeometryLayout.XYZ) {
|
||||
return /** @type {EsriJSONPoint} */ ({
|
||||
esriJSON = /** @type {EsriJSONPoint} */ ({
|
||||
x: coordinates[0],
|
||||
y: coordinates[1],
|
||||
z: coordinates[2]
|
||||
});
|
||||
} else if (layout === ol.geom.GeometryLayout.XYM) {
|
||||
return /** @type {EsriJSONPoint} */ ({
|
||||
esriJSON = /** @type {EsriJSONPoint} */ ({
|
||||
x: coordinates[0],
|
||||
y: coordinates[1],
|
||||
m: coordinates[2]
|
||||
});
|
||||
} else if (layout === ol.geom.GeometryLayout.XYZM) {
|
||||
return /** @type {EsriJSONPoint} */ ({
|
||||
esriJSON = /** @type {EsriJSONPoint} */ ({
|
||||
x: coordinates[0],
|
||||
y: coordinates[1],
|
||||
z: coordinates[2],
|
||||
m: coordinates[3]
|
||||
});
|
||||
} else if (layout === ol.geom.GeometryLayout.XY) {
|
||||
return /** @type {EsriJSONPoint} */ ({
|
||||
esriJSON = /** @type {EsriJSONPoint} */ ({
|
||||
x: coordinates[0],
|
||||
y: coordinates[1]
|
||||
});
|
||||
} else {
|
||||
goog.asserts.fail('Unknown geometry layout');
|
||||
ol.assert(false, 34); // Invalid geometry layout
|
||||
}
|
||||
return /** @type {EsriJSONGeometry} */ (esriJSON);
|
||||
};
|
||||
|
||||
|
||||
@@ -316,13 +315,11 @@ ol.format.EsriJSON.getHasZM_ = function(geometry) {
|
||||
* @return {EsriJSONPolyline} EsriJSON geometry.
|
||||
*/
|
||||
ol.format.EsriJSON.writeLineStringGeometry_ = function(geometry, opt_options) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.LineString,
|
||||
'geometry should be an ol.geom.LineString');
|
||||
var hasZM = ol.format.EsriJSON.getHasZM_(geometry);
|
||||
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.LineString} */ (geometry));
|
||||
return /** @type {EsriJSONPolyline} */ ({
|
||||
hasZ: hasZM.hasZ,
|
||||
hasM: hasZM.hasM,
|
||||
paths: [geometry.getCoordinates()]
|
||||
paths: [/** @type {ol.geom.LineString} */ (geometry).getCoordinates()]
|
||||
});
|
||||
};
|
||||
|
||||
@@ -334,14 +331,12 @@ ol.format.EsriJSON.writeLineStringGeometry_ = function(geometry, opt_options) {
|
||||
* @return {EsriJSONPolygon} EsriJSON geometry.
|
||||
*/
|
||||
ol.format.EsriJSON.writePolygonGeometry_ = function(geometry, opt_options) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.Polygon,
|
||||
'geometry should be an ol.geom.Polygon');
|
||||
// Esri geometries use the left-hand rule
|
||||
var hasZM = ol.format.EsriJSON.getHasZM_(geometry);
|
||||
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.Polygon} */ (geometry));
|
||||
return /** @type {EsriJSONPolygon} */ ({
|
||||
hasZ: hasZM.hasZ,
|
||||
hasM: hasZM.hasM,
|
||||
rings: geometry.getCoordinates(false)
|
||||
rings: /** @type {ol.geom.Polygon} */ (geometry).getCoordinates(false)
|
||||
});
|
||||
};
|
||||
|
||||
@@ -353,13 +348,11 @@ ol.format.EsriJSON.writePolygonGeometry_ = function(geometry, opt_options) {
|
||||
* @return {EsriJSONPolyline} EsriJSON geometry.
|
||||
*/
|
||||
ol.format.EsriJSON.writeMultiLineStringGeometry_ = function(geometry, opt_options) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.MultiLineString,
|
||||
'geometry should be an ol.geom.MultiLineString');
|
||||
var hasZM = ol.format.EsriJSON.getHasZM_(geometry);
|
||||
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.MultiLineString} */ (geometry));
|
||||
return /** @type {EsriJSONPolyline} */ ({
|
||||
hasZ: hasZM.hasZ,
|
||||
hasM: hasZM.hasM,
|
||||
paths: geometry.getCoordinates()
|
||||
paths: /** @type {ol.geom.MultiLineString} */ (geometry).getCoordinates()
|
||||
});
|
||||
};
|
||||
|
||||
@@ -371,13 +364,11 @@ ol.format.EsriJSON.writeMultiLineStringGeometry_ = function(geometry, opt_option
|
||||
* @return {EsriJSONMultipoint} EsriJSON geometry.
|
||||
*/
|
||||
ol.format.EsriJSON.writeMultiPointGeometry_ = function(geometry, opt_options) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.MultiPoint,
|
||||
'geometry should be an ol.geom.MultiPoint');
|
||||
var hasZM = ol.format.EsriJSON.getHasZM_(geometry);
|
||||
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.MultiPoint} */ (geometry));
|
||||
return /** @type {EsriJSONMultipoint} */ ({
|
||||
hasZ: hasZM.hasZ,
|
||||
hasM: hasZM.hasM,
|
||||
points: geometry.getCoordinates()
|
||||
points: /** @type {ol.geom.MultiPoint} */ (geometry).getCoordinates()
|
||||
});
|
||||
};
|
||||
|
||||
@@ -390,10 +381,8 @@ ol.format.EsriJSON.writeMultiPointGeometry_ = function(geometry, opt_options) {
|
||||
*/
|
||||
ol.format.EsriJSON.writeMultiPolygonGeometry_ = function(geometry,
|
||||
opt_options) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.MultiPolygon,
|
||||
'geometry should be an ol.geom.MultiPolygon');
|
||||
var hasZM = ol.format.EsriJSON.getHasZM_(geometry);
|
||||
var coordinates = geometry.getCoordinates(false);
|
||||
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.MultiPolygon} */ (geometry));
|
||||
var coordinates = /** @type {ol.geom.MultiPolygon} */ (geometry).getCoordinates(false);
|
||||
var output = [];
|
||||
for (var i = 0; i < coordinates.length; i++) {
|
||||
for (var x = coordinates[i].length - 1; x >= 0; x--) {
|
||||
@@ -480,7 +469,7 @@ ol.format.EsriJSON.prototype.readFeatures;
|
||||
ol.format.EsriJSON.prototype.readFeatureFromObject = function(
|
||||
object, opt_options) {
|
||||
var esriJSONFeature = /** @type {EsriJSONFeature} */ (object);
|
||||
goog.asserts.assert(esriJSONFeature.geometry ||
|
||||
ol.DEBUG && console.assert(esriJSONFeature.geometry ||
|
||||
esriJSONFeature.attributes,
|
||||
'geometry or attributes should be defined');
|
||||
var geometry = ol.format.EsriJSON.readGeometry_(esriJSONFeature.geometry,
|
||||
@@ -492,7 +481,7 @@ ol.format.EsriJSON.prototype.readFeatureFromObject = function(
|
||||
feature.setGeometry(geometry);
|
||||
if (opt_options && opt_options.idField &&
|
||||
esriJSONFeature.attributes[opt_options.idField]) {
|
||||
goog.asserts.assert(
|
||||
ol.DEBUG && console.assert(
|
||||
typeof esriJSONFeature.attributes[opt_options.idField] === 'number',
|
||||
'objectIdFieldName value should be a number');
|
||||
feature.setId(/** @type {number} */(
|
||||
@@ -586,7 +575,7 @@ ol.format.EsriJSON.prototype.readProjectionFromObject = function(object) {
|
||||
*/
|
||||
ol.format.EsriJSON.writeGeometry_ = function(geometry, opt_options) {
|
||||
var geometryWriter = ol.format.EsriJSON.GEOMETRY_WRITERS_[geometry.getType()];
|
||||
goog.asserts.assert(geometryWriter, 'geometryWriter should be defined');
|
||||
ol.DEBUG && console.assert(geometryWriter, 'geometryWriter should be defined');
|
||||
return geometryWriter(/** @type {ol.geom.Geometry} */ (
|
||||
ol.format.Feature.transformWithOptions(geometry, true, opt_options)),
|
||||
opt_options);
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
goog.provide('ol.format.GeoJSON');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.format.Feature');
|
||||
goog.require('ol.format.JSONFeature');
|
||||
@@ -71,7 +70,7 @@ ol.format.GeoJSON.readGeometry_ = function(object, opt_options) {
|
||||
return null;
|
||||
}
|
||||
var geometryReader = ol.format.GeoJSON.GEOMETRY_READERS_[object.type];
|
||||
goog.asserts.assert(geometryReader, 'geometryReader should be defined');
|
||||
ol.DEBUG && console.assert(geometryReader, 'geometryReader should be defined');
|
||||
return /** @type {ol.geom.Geometry} */ (
|
||||
ol.format.Feature.transformWithOptions(
|
||||
geometryReader(object), false, opt_options));
|
||||
@@ -86,7 +85,7 @@ ol.format.GeoJSON.readGeometry_ = function(object, opt_options) {
|
||||
*/
|
||||
ol.format.GeoJSON.readGeometryCollectionGeometry_ = function(
|
||||
object, opt_options) {
|
||||
goog.asserts.assert(object.type == 'GeometryCollection',
|
||||
ol.DEBUG && console.assert(object.type == 'GeometryCollection',
|
||||
'object.type should be GeometryCollection');
|
||||
var geometries = object.geometries.map(
|
||||
/**
|
||||
@@ -106,7 +105,7 @@ ol.format.GeoJSON.readGeometryCollectionGeometry_ = function(
|
||||
* @return {ol.geom.Point} Point.
|
||||
*/
|
||||
ol.format.GeoJSON.readPointGeometry_ = function(object) {
|
||||
goog.asserts.assert(object.type == 'Point',
|
||||
ol.DEBUG && console.assert(object.type == 'Point',
|
||||
'object.type should be Point');
|
||||
return new ol.geom.Point(object.coordinates);
|
||||
};
|
||||
@@ -118,7 +117,7 @@ ol.format.GeoJSON.readPointGeometry_ = function(object) {
|
||||
* @return {ol.geom.LineString} LineString.
|
||||
*/
|
||||
ol.format.GeoJSON.readLineStringGeometry_ = function(object) {
|
||||
goog.asserts.assert(object.type == 'LineString',
|
||||
ol.DEBUG && console.assert(object.type == 'LineString',
|
||||
'object.type should be LineString');
|
||||
return new ol.geom.LineString(object.coordinates);
|
||||
};
|
||||
@@ -130,7 +129,7 @@ ol.format.GeoJSON.readLineStringGeometry_ = function(object) {
|
||||
* @return {ol.geom.MultiLineString} MultiLineString.
|
||||
*/
|
||||
ol.format.GeoJSON.readMultiLineStringGeometry_ = function(object) {
|
||||
goog.asserts.assert(object.type == 'MultiLineString',
|
||||
ol.DEBUG && console.assert(object.type == 'MultiLineString',
|
||||
'object.type should be MultiLineString');
|
||||
return new ol.geom.MultiLineString(object.coordinates);
|
||||
};
|
||||
@@ -142,7 +141,7 @@ ol.format.GeoJSON.readMultiLineStringGeometry_ = function(object) {
|
||||
* @return {ol.geom.MultiPoint} MultiPoint.
|
||||
*/
|
||||
ol.format.GeoJSON.readMultiPointGeometry_ = function(object) {
|
||||
goog.asserts.assert(object.type == 'MultiPoint',
|
||||
ol.DEBUG && console.assert(object.type == 'MultiPoint',
|
||||
'object.type should be MultiPoint');
|
||||
return new ol.geom.MultiPoint(object.coordinates);
|
||||
};
|
||||
@@ -154,7 +153,7 @@ ol.format.GeoJSON.readMultiPointGeometry_ = function(object) {
|
||||
* @return {ol.geom.MultiPolygon} MultiPolygon.
|
||||
*/
|
||||
ol.format.GeoJSON.readMultiPolygonGeometry_ = function(object) {
|
||||
goog.asserts.assert(object.type == 'MultiPolygon',
|
||||
ol.DEBUG && console.assert(object.type == 'MultiPolygon',
|
||||
'object.type should be MultiPolygon');
|
||||
return new ol.geom.MultiPolygon(object.coordinates);
|
||||
};
|
||||
@@ -166,7 +165,7 @@ ol.format.GeoJSON.readMultiPolygonGeometry_ = function(object) {
|
||||
* @return {ol.geom.Polygon} Polygon.
|
||||
*/
|
||||
ol.format.GeoJSON.readPolygonGeometry_ = function(object) {
|
||||
goog.asserts.assert(object.type == 'Polygon',
|
||||
ol.DEBUG && console.assert(object.type == 'Polygon',
|
||||
'object.type should be Polygon');
|
||||
return new ol.geom.Polygon(object.coordinates);
|
||||
};
|
||||
@@ -180,7 +179,7 @@ ol.format.GeoJSON.readPolygonGeometry_ = function(object) {
|
||||
*/
|
||||
ol.format.GeoJSON.writeGeometry_ = function(geometry, opt_options) {
|
||||
var geometryWriter = ol.format.GeoJSON.GEOMETRY_WRITERS_[geometry.getType()];
|
||||
goog.asserts.assert(geometryWriter, 'geometryWriter should be defined');
|
||||
ol.DEBUG && console.assert(geometryWriter, 'geometryWriter should be defined');
|
||||
return geometryWriter(/** @type {ol.geom.Geometry} */ (
|
||||
ol.format.Feature.transformWithOptions(geometry, true, opt_options)),
|
||||
opt_options);
|
||||
@@ -201,15 +200,13 @@ ol.format.GeoJSON.writeEmptyGeometryCollectionGeometry_ = function(geometry) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Geometry} geometry Geometry.
|
||||
* @param {ol.geom.GeometryCollection} geometry Geometry.
|
||||
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||
* @private
|
||||
* @return {GeoJSONGeometryCollection} GeoJSON geometry collection.
|
||||
*/
|
||||
ol.format.GeoJSON.writeGeometryCollectionGeometry_ = function(
|
||||
geometry, opt_options) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.GeometryCollection,
|
||||
'geometry should be an ol.geom.GeometryCollection');
|
||||
var geometries = geometry.getGeometriesArray().map(function(geometry) {
|
||||
var options = ol.object.assign({}, opt_options);
|
||||
delete options.featureProjection;
|
||||
@@ -223,14 +220,12 @@ ol.format.GeoJSON.writeGeometryCollectionGeometry_ = function(
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Geometry} geometry Geometry.
|
||||
* @param {ol.geom.LineString} geometry Geometry.
|
||||
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||
* @private
|
||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||
*/
|
||||
ol.format.GeoJSON.writeLineStringGeometry_ = function(geometry, opt_options) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.LineString,
|
||||
'geometry should be an ol.geom.LineString');
|
||||
return /** @type {GeoJSONGeometry} */ ({
|
||||
type: 'LineString',
|
||||
coordinates: geometry.getCoordinates()
|
||||
@@ -239,14 +234,12 @@ ol.format.GeoJSON.writeLineStringGeometry_ = function(geometry, opt_options) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Geometry} geometry Geometry.
|
||||
* @param {ol.geom.MultiLineString} geometry Geometry.
|
||||
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||
* @private
|
||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||
*/
|
||||
ol.format.GeoJSON.writeMultiLineStringGeometry_ = function(geometry, opt_options) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.MultiLineString,
|
||||
'geometry should be an ol.geom.MultiLineString');
|
||||
return /** @type {GeoJSONGeometry} */ ({
|
||||
type: 'MultiLineString',
|
||||
coordinates: geometry.getCoordinates()
|
||||
@@ -255,14 +248,12 @@ ol.format.GeoJSON.writeMultiLineStringGeometry_ = function(geometry, opt_options
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Geometry} geometry Geometry.
|
||||
* @param {ol.geom.MultiPoint} geometry Geometry.
|
||||
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||
* @private
|
||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||
*/
|
||||
ol.format.GeoJSON.writeMultiPointGeometry_ = function(geometry, opt_options) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.MultiPoint,
|
||||
'geometry should be an ol.geom.MultiPoint');
|
||||
return /** @type {GeoJSONGeometry} */ ({
|
||||
type: 'MultiPoint',
|
||||
coordinates: geometry.getCoordinates()
|
||||
@@ -271,14 +262,12 @@ ol.format.GeoJSON.writeMultiPointGeometry_ = function(geometry, opt_options) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Geometry} geometry Geometry.
|
||||
* @param {ol.geom.MultiPolygon} geometry Geometry.
|
||||
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||
* @private
|
||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||
*/
|
||||
ol.format.GeoJSON.writeMultiPolygonGeometry_ = function(geometry, opt_options) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.MultiPolygon,
|
||||
'geometry should be an ol.geom.MultiPolygon');
|
||||
var right;
|
||||
if (opt_options) {
|
||||
right = opt_options.rightHanded;
|
||||
@@ -291,14 +280,12 @@ ol.format.GeoJSON.writeMultiPolygonGeometry_ = function(geometry, opt_options) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Geometry} geometry Geometry.
|
||||
* @param {ol.geom.Point} geometry Geometry.
|
||||
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||
* @private
|
||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||
*/
|
||||
ol.format.GeoJSON.writePointGeometry_ = function(geometry, opt_options) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.Point,
|
||||
'geometry should be an ol.geom.Point');
|
||||
return /** @type {GeoJSONGeometry} */ ({
|
||||
type: 'Point',
|
||||
coordinates: geometry.getCoordinates()
|
||||
@@ -307,14 +294,12 @@ ol.format.GeoJSON.writePointGeometry_ = function(geometry, opt_options) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Geometry} geometry Geometry.
|
||||
* @param {ol.geom.Polygon} geometry Geometry.
|
||||
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||
* @private
|
||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||
*/
|
||||
ol.format.GeoJSON.writePolygonGeometry_ = function(geometry, opt_options) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.Polygon,
|
||||
'geometry should be an ol.geom.Polygon');
|
||||
var right;
|
||||
if (opt_options) {
|
||||
right = opt_options.rightHanded;
|
||||
@@ -399,7 +384,7 @@ ol.format.GeoJSON.prototype.readFeatures;
|
||||
ol.format.GeoJSON.prototype.readFeatureFromObject = function(
|
||||
object, opt_options) {
|
||||
var geoJSONFeature = /** @type {GeoJSONFeature} */ (object);
|
||||
goog.asserts.assert(geoJSONFeature.type == 'Feature',
|
||||
ol.DEBUG && console.assert(geoJSONFeature.type == 'Feature',
|
||||
'geoJSONFeature.type should be Feature');
|
||||
var geometry = ol.format.GeoJSON.readGeometry_(geoJSONFeature.geometry,
|
||||
opt_options);
|
||||
@@ -424,24 +409,24 @@ ol.format.GeoJSON.prototype.readFeatureFromObject = function(
|
||||
ol.format.GeoJSON.prototype.readFeaturesFromObject = function(
|
||||
object, opt_options) {
|
||||
var geoJSONObject = /** @type {GeoJSONObject} */ (object);
|
||||
/** @type {Array.<ol.Feature>} */
|
||||
var features;
|
||||
if (geoJSONObject.type == 'Feature') {
|
||||
return [this.readFeatureFromObject(object, opt_options)];
|
||||
features = [this.readFeatureFromObject(object, opt_options)];
|
||||
} else if (geoJSONObject.type == 'FeatureCollection') {
|
||||
var geoJSONFeatureCollection = /** @type {GeoJSONFeatureCollection} */
|
||||
(object);
|
||||
/** @type {Array.<ol.Feature>} */
|
||||
var features = [];
|
||||
features = [];
|
||||
var geoJSONFeatures = geoJSONFeatureCollection.features;
|
||||
var i, ii;
|
||||
for (i = 0, ii = geoJSONFeatures.length; i < ii; ++i) {
|
||||
features.push(this.readFeatureFromObject(geoJSONFeatures[i],
|
||||
opt_options));
|
||||
}
|
||||
return features;
|
||||
} else {
|
||||
goog.asserts.fail('Unknown geoJSONObject.type: ' + geoJSONObject.type);
|
||||
return [];
|
||||
ol.assert(false, 35); // Unknown GeoJSON object type
|
||||
}
|
||||
return /** Array.<ol.Feature> */ (features);
|
||||
};
|
||||
|
||||
|
||||
@@ -484,22 +469,23 @@ ol.format.GeoJSON.prototype.readProjection;
|
||||
ol.format.GeoJSON.prototype.readProjectionFromObject = function(object) {
|
||||
var geoJSONObject = /** @type {GeoJSONObject} */ (object);
|
||||
var crs = geoJSONObject.crs;
|
||||
var projection;
|
||||
if (crs) {
|
||||
if (crs.type == 'name') {
|
||||
return ol.proj.get(crs.properties.name);
|
||||
projection = ol.proj.get(crs.properties.name);
|
||||
} else if (crs.type == 'EPSG') {
|
||||
// 'EPSG' is not part of the GeoJSON specification, but is generated by
|
||||
// GeoServer.
|
||||
// TODO: remove this when http://jira.codehaus.org/browse/GEOS-5996
|
||||
// is fixed and widely deployed.
|
||||
return ol.proj.get('EPSG:' + crs.properties.code);
|
||||
projection = ol.proj.get('EPSG:' + crs.properties.code);
|
||||
} else {
|
||||
goog.asserts.fail('Unknown crs.type: ' + crs.type);
|
||||
return null;
|
||||
ol.assert(false, 36); // Unknown SRS type
|
||||
}
|
||||
} else {
|
||||
return this.defaultDataProjection;
|
||||
projection = this.defaultDataProjection;
|
||||
}
|
||||
return /** @type {ol.proj.Projection} */ (projection);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.format.GML2');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.format.GMLBase');
|
||||
goog.require('ol.format.XSD');
|
||||
@@ -56,7 +55,6 @@ ol.format.GML2.schemaLocation_ = ol.format.GMLBase.GMLNS +
|
||||
ol.format.GML2.prototype.readFlatCoordinates_ = function(node, objectStack) {
|
||||
var s = ol.xml.getAllTextContent(node, false).replace(/^\s*|\s*$/g, '');
|
||||
var context = /** @type {ol.XmlNodeStackItem} */ (objectStack[0]);
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var containerSrs = context['srsName'];
|
||||
var containerDimension = node.parentNode.getAttribute('srsDimension');
|
||||
var axisOrientation = 'enu';
|
||||
@@ -101,9 +99,9 @@ ol.format.GML2.prototype.readFlatCoordinates_ = function(node, objectStack) {
|
||||
* @return {ol.Extent|undefined} Envelope.
|
||||
*/
|
||||
ol.format.GML2.prototype.readBox_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Box', 'localName should be Box');
|
||||
ol.DEBUG && console.assert(node.localName == 'Box', 'localName should be Box');
|
||||
/** @type {Array.<number>} */
|
||||
var flatCoordinates = ol.xml.pushParseAndPop([null],
|
||||
this.BOX_PARSERS_, node, objectStack, this);
|
||||
@@ -119,9 +117,9 @@ ol.format.GML2.prototype.readBox_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.GML2.prototype.innerBoundaryIsParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'innerBoundaryIs',
|
||||
ol.DEBUG && console.assert(node.localName == 'innerBoundaryIs',
|
||||
'localName should be innerBoundaryIs');
|
||||
/** @type {Array.<number>|undefined} */
|
||||
var flatLinearRing = ol.xml.pushParseAndPop(undefined,
|
||||
@@ -129,9 +127,9 @@ ol.format.GML2.prototype.innerBoundaryIsParser_ = function(node, objectStack) {
|
||||
if (flatLinearRing) {
|
||||
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
||||
(objectStack[objectStack.length - 1]);
|
||||
goog.asserts.assert(Array.isArray(flatLinearRings),
|
||||
ol.DEBUG && console.assert(Array.isArray(flatLinearRings),
|
||||
'flatLinearRings should be an array');
|
||||
goog.asserts.assert(flatLinearRings.length > 0,
|
||||
ol.DEBUG && console.assert(flatLinearRings.length > 0,
|
||||
'flatLinearRings should have an array length larger than 0');
|
||||
flatLinearRings.push(flatLinearRing);
|
||||
}
|
||||
@@ -144,9 +142,9 @@ ol.format.GML2.prototype.innerBoundaryIsParser_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.GML2.prototype.outerBoundaryIsParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'outerBoundaryIs',
|
||||
ol.DEBUG && console.assert(node.localName == 'outerBoundaryIs',
|
||||
'localName should be outerBoundaryIs');
|
||||
/** @type {Array.<number>|undefined} */
|
||||
var flatLinearRing = ol.xml.pushParseAndPop(undefined,
|
||||
@@ -154,9 +152,9 @@ ol.format.GML2.prototype.outerBoundaryIsParser_ = function(node, objectStack) {
|
||||
if (flatLinearRing) {
|
||||
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
||||
(objectStack[objectStack.length - 1]);
|
||||
goog.asserts.assert(Array.isArray(flatLinearRings),
|
||||
ol.DEBUG && console.assert(Array.isArray(flatLinearRings),
|
||||
'flatLinearRings should be an array');
|
||||
goog.asserts.assert(flatLinearRings.length > 0,
|
||||
ol.DEBUG && console.assert(flatLinearRings.length > 0,
|
||||
'flatLinearRings should have an array length larger than 0');
|
||||
flatLinearRings[0] = flatLinearRing;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
goog.provide('ol.format.GML');
|
||||
goog.provide('ol.format.GML3');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.Feature');
|
||||
@@ -93,9 +92,9 @@ ol.format.GML3.schemaLocation_ = ol.format.GMLBase.GMLNS +
|
||||
* @return {ol.geom.MultiLineString|undefined} MultiLineString.
|
||||
*/
|
||||
ol.format.GML3.prototype.readMultiCurve_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'MultiCurve',
|
||||
ol.DEBUG && console.assert(node.localName == 'MultiCurve',
|
||||
'localName should be MultiCurve');
|
||||
/** @type {Array.<ol.geom.LineString>} */
|
||||
var lineStrings = ol.xml.pushParseAndPop([],
|
||||
@@ -117,9 +116,9 @@ ol.format.GML3.prototype.readMultiCurve_ = function(node, objectStack) {
|
||||
* @return {ol.geom.MultiPolygon|undefined} MultiPolygon.
|
||||
*/
|
||||
ol.format.GML3.prototype.readMultiSurface_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'MultiSurface',
|
||||
ol.DEBUG && console.assert(node.localName == 'MultiSurface',
|
||||
'localName should be MultiSurface');
|
||||
/** @type {Array.<ol.geom.Polygon>} */
|
||||
var polygons = ol.xml.pushParseAndPop([],
|
||||
@@ -140,9 +139,9 @@ ol.format.GML3.prototype.readMultiSurface_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.GML3.prototype.curveMemberParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'curveMember' ||
|
||||
ol.DEBUG && console.assert(node.localName == 'curveMember' ||
|
||||
node.localName == 'curveMembers',
|
||||
'localName should be curveMember or curveMembers');
|
||||
ol.xml.parseNode(this.CURVEMEMBER_PARSERS_, node, objectStack, this);
|
||||
@@ -155,9 +154,9 @@ ol.format.GML3.prototype.curveMemberParser_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.GML3.prototype.surfaceMemberParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'surfaceMember' ||
|
||||
ol.DEBUG && console.assert(node.localName == 'surfaceMember' ||
|
||||
node.localName == 'surfaceMembers',
|
||||
'localName should be surfaceMember or surfaceMembers');
|
||||
ol.xml.parseNode(this.SURFACEMEMBER_PARSERS_,
|
||||
@@ -172,9 +171,9 @@ ol.format.GML3.prototype.surfaceMemberParser_ = function(node, objectStack) {
|
||||
* @return {Array.<(Array.<number>)>|undefined} flat coordinates.
|
||||
*/
|
||||
ol.format.GML3.prototype.readPatch_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'patches',
|
||||
ol.DEBUG && console.assert(node.localName == 'patches',
|
||||
'localName should be patches');
|
||||
return ol.xml.pushParseAndPop([null],
|
||||
this.PATCHES_PARSERS_, node, objectStack, this);
|
||||
@@ -188,9 +187,9 @@ ol.format.GML3.prototype.readPatch_ = function(node, objectStack) {
|
||||
* @return {Array.<number>|undefined} flat coordinates.
|
||||
*/
|
||||
ol.format.GML3.prototype.readSegment_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'segments',
|
||||
ol.DEBUG && console.assert(node.localName == 'segments',
|
||||
'localName should be segments');
|
||||
return ol.xml.pushParseAndPop([null],
|
||||
this.SEGMENTS_PARSERS_, node, objectStack, this);
|
||||
@@ -204,9 +203,9 @@ ol.format.GML3.prototype.readSegment_ = function(node, objectStack) {
|
||||
* @return {Array.<(Array.<number>)>|undefined} flat coordinates.
|
||||
*/
|
||||
ol.format.GML3.prototype.readPolygonPatch_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'npde.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'PolygonPatch',
|
||||
ol.DEBUG && console.assert(node.localName == 'PolygonPatch',
|
||||
'localName should be PolygonPatch');
|
||||
return ol.xml.pushParseAndPop([null],
|
||||
this.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack, this);
|
||||
@@ -220,9 +219,9 @@ ol.format.GML3.prototype.readPolygonPatch_ = function(node, objectStack) {
|
||||
* @return {Array.<number>|undefined} flat coordinates.
|
||||
*/
|
||||
ol.format.GML3.prototype.readLineStringSegment_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'LineStringSegment',
|
||||
ol.DEBUG && console.assert(node.localName == 'LineStringSegment',
|
||||
'localName should be LineStringSegment');
|
||||
return ol.xml.pushParseAndPop([null],
|
||||
this.GEOMETRY_FLAT_COORDINATES_PARSERS_,
|
||||
@@ -236,9 +235,9 @@ ol.format.GML3.prototype.readLineStringSegment_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.GML3.prototype.interiorParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'interior',
|
||||
ol.DEBUG && console.assert(node.localName == 'interior',
|
||||
'localName should be interior');
|
||||
/** @type {Array.<number>|undefined} */
|
||||
var flatLinearRing = ol.xml.pushParseAndPop(undefined,
|
||||
@@ -246,9 +245,9 @@ ol.format.GML3.prototype.interiorParser_ = function(node, objectStack) {
|
||||
if (flatLinearRing) {
|
||||
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
||||
(objectStack[objectStack.length - 1]);
|
||||
goog.asserts.assert(Array.isArray(flatLinearRings),
|
||||
ol.DEBUG && console.assert(Array.isArray(flatLinearRings),
|
||||
'flatLinearRings should be an array');
|
||||
goog.asserts.assert(flatLinearRings.length > 0,
|
||||
ol.DEBUG && console.assert(flatLinearRings.length > 0,
|
||||
'flatLinearRings should have an array length of 1 or more');
|
||||
flatLinearRings.push(flatLinearRing);
|
||||
}
|
||||
@@ -261,9 +260,9 @@ ol.format.GML3.prototype.interiorParser_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.GML3.prototype.exteriorParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'exterior',
|
||||
ol.DEBUG && console.assert(node.localName == 'exterior',
|
||||
'localName should be exterior');
|
||||
/** @type {Array.<number>|undefined} */
|
||||
var flatLinearRing = ol.xml.pushParseAndPop(undefined,
|
||||
@@ -271,9 +270,9 @@ ol.format.GML3.prototype.exteriorParser_ = function(node, objectStack) {
|
||||
if (flatLinearRing) {
|
||||
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
||||
(objectStack[objectStack.length - 1]);
|
||||
goog.asserts.assert(Array.isArray(flatLinearRings),
|
||||
ol.DEBUG && console.assert(Array.isArray(flatLinearRings),
|
||||
'flatLinearRings should be an array');
|
||||
goog.asserts.assert(flatLinearRings.length > 0,
|
||||
ol.DEBUG && console.assert(flatLinearRings.length > 0,
|
||||
'flatLinearRings should have an array length of 1 or more');
|
||||
flatLinearRings[0] = flatLinearRing;
|
||||
}
|
||||
@@ -287,9 +286,9 @@ ol.format.GML3.prototype.exteriorParser_ = function(node, objectStack) {
|
||||
* @return {ol.geom.Polygon|undefined} Polygon.
|
||||
*/
|
||||
ol.format.GML3.prototype.readSurface_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Surface',
|
||||
ol.DEBUG && console.assert(node.localName == 'Surface',
|
||||
'localName should be Surface');
|
||||
/** @type {Array.<Array.<number>>} */
|
||||
var flatLinearRings = ol.xml.pushParseAndPop([null],
|
||||
@@ -319,9 +318,9 @@ ol.format.GML3.prototype.readSurface_ = function(node, objectStack) {
|
||||
* @return {ol.geom.LineString|undefined} LineString.
|
||||
*/
|
||||
ol.format.GML3.prototype.readCurve_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Curve', 'localName should be Curve');
|
||||
ol.DEBUG && console.assert(node.localName == 'Curve', 'localName should be Curve');
|
||||
/** @type {Array.<number>} */
|
||||
var flatCoordinates = ol.xml.pushParseAndPop([null],
|
||||
this.CURVE_PARSERS_, node, objectStack, this);
|
||||
@@ -342,9 +341,9 @@ ol.format.GML3.prototype.readCurve_ = function(node, objectStack) {
|
||||
* @return {ol.Extent|undefined} Envelope.
|
||||
*/
|
||||
ol.format.GML3.prototype.readEnvelope_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Envelope',
|
||||
ol.DEBUG && console.assert(node.localName == 'Envelope',
|
||||
'localName should be Envelope');
|
||||
/** @type {Array.<number>} */
|
||||
var flatCoordinates = ol.xml.pushParseAndPop([null],
|
||||
@@ -375,7 +374,6 @@ ol.format.GML3.prototype.readFlatPos_ = function(node, objectStack) {
|
||||
return undefined;
|
||||
}
|
||||
var context = objectStack[0];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var containerSrs = context['srsName'];
|
||||
var axisOrientation = 'enu';
|
||||
if (containerSrs) {
|
||||
@@ -411,7 +409,6 @@ ol.format.GML3.prototype.readFlatPos_ = function(node, objectStack) {
|
||||
ol.format.GML3.prototype.readFlatPosList_ = function(node, objectStack) {
|
||||
var s = ol.xml.getAllTextContent(node, false).replace(/^\s*|\s*$/g, '');
|
||||
var context = objectStack[0];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var containerSrs = context['srsName'];
|
||||
var containerDimension = node.parentNode.getAttribute('srsDimension');
|
||||
var axisOrientation = 'enu';
|
||||
@@ -633,7 +630,6 @@ ol.format.GML3.prototype.SEGMENTS_PARSERS_ = {
|
||||
*/
|
||||
ol.format.GML3.prototype.writePos_ = function(node, value, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var srsName = context['srsName'];
|
||||
var axisOrientation = 'enu';
|
||||
if (srsName) {
|
||||
@@ -676,7 +672,6 @@ ol.format.GML3.prototype.getCoords_ = function(point, opt_srsName) {
|
||||
*/
|
||||
ol.format.GML3.prototype.writePosList_ = function(node, value, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var srsName = context['srsName'];
|
||||
// only 2d for simple features profile
|
||||
var points = value.getCoordinates();
|
||||
@@ -699,7 +694,6 @@ ol.format.GML3.prototype.writePosList_ = function(node, value, objectStack) {
|
||||
*/
|
||||
ol.format.GML3.prototype.writePoint_ = function(node, geometry, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var srsName = context['srsName'];
|
||||
if (srsName) {
|
||||
node.setAttribute('srsName', srsName);
|
||||
@@ -728,9 +722,8 @@ ol.format.GML3.ENVELOPE_SERIALIZERS_ = {
|
||||
* @param {Array.<*>} objectStack Node stack.
|
||||
*/
|
||||
ol.format.GML3.prototype.writeEnvelope = function(node, extent, objectStack) {
|
||||
goog.asserts.assert(extent.length == 4, 'extent should have 4 items');
|
||||
ol.DEBUG && console.assert(extent.length == 4, 'extent should have 4 items');
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var srsName = context['srsName'];
|
||||
if (srsName) {
|
||||
node.setAttribute('srsName', srsName);
|
||||
@@ -753,7 +746,6 @@ ol.format.GML3.prototype.writeEnvelope = function(node, extent, objectStack) {
|
||||
*/
|
||||
ol.format.GML3.prototype.writeLinearRing_ = function(node, geometry, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var srsName = context['srsName'];
|
||||
if (srsName) {
|
||||
node.setAttribute('srsName', srsName);
|
||||
@@ -774,7 +766,6 @@ ol.format.GML3.prototype.writeLinearRing_ = function(node, geometry, objectStack
|
||||
ol.format.GML3.prototype.RING_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
var parentNode = context.node;
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var exteriorWritten = context['exteriorWritten'];
|
||||
if (exteriorWritten === undefined) {
|
||||
context['exteriorWritten'] = true;
|
||||
@@ -792,7 +783,6 @@ ol.format.GML3.prototype.RING_NODE_FACTORY_ = function(value, objectStack, opt_n
|
||||
*/
|
||||
ol.format.GML3.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var srsName = context['srsName'];
|
||||
if (node.nodeName !== 'PolygonPatch' && srsName) {
|
||||
node.setAttribute('srsName', srsName);
|
||||
@@ -821,7 +811,6 @@ ol.format.GML3.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objec
|
||||
*/
|
||||
ol.format.GML3.prototype.writeCurveOrLineString_ = function(node, geometry, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var srsName = context['srsName'];
|
||||
if (node.nodeName !== 'LineStringSegment' && srsName) {
|
||||
node.setAttribute('srsName', srsName);
|
||||
@@ -848,7 +837,6 @@ ol.format.GML3.prototype.writeCurveOrLineString_ = function(node, geometry, obje
|
||||
*/
|
||||
ol.format.GML3.prototype.writeMultiSurfaceOrPolygon_ = function(node, geometry, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var srsName = context['srsName'];
|
||||
var surface = context['surface'];
|
||||
if (srsName) {
|
||||
@@ -871,7 +859,6 @@ ol.format.GML3.prototype.writeMultiSurfaceOrPolygon_ = function(node, geometry,
|
||||
ol.format.GML3.prototype.writeMultiPoint_ = function(node, geometry,
|
||||
objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var srsName = context['srsName'];
|
||||
if (srsName) {
|
||||
node.setAttribute('srsName', srsName);
|
||||
@@ -892,7 +879,6 @@ ol.format.GML3.prototype.writeMultiPoint_ = function(node, geometry,
|
||||
*/
|
||||
ol.format.GML3.prototype.writeMultiCurveOrLineString_ = function(node, geometry, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var srsName = context['srsName'];
|
||||
var curve = context['curve'];
|
||||
if (srsName) {
|
||||
@@ -927,7 +913,6 @@ ol.format.GML3.prototype.writeRing_ = function(node, ring, objectStack) {
|
||||
*/
|
||||
ol.format.GML3.prototype.writeSurfaceOrPolygonMember_ = function(node, polygon, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var child = this.GEOMETRY_NODE_FACTORY_(
|
||||
polygon, objectStack);
|
||||
if (child) {
|
||||
@@ -958,7 +943,6 @@ ol.format.GML3.prototype.writePointMember_ = function(node, point, objectStack)
|
||||
*/
|
||||
ol.format.GML3.prototype.writeLineStringOrCurveMember_ = function(node, line, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var child = this.GEOMETRY_NODE_FACTORY_(line, objectStack);
|
||||
if (child) {
|
||||
node.appendChild(child);
|
||||
@@ -1000,8 +984,7 @@ ol.format.GML3.prototype.writeCurveSegments_ = function(node, line, objectStack)
|
||||
* @param {Array.<*>} objectStack Node stack.
|
||||
*/
|
||||
ol.format.GML3.prototype.writeGeometryElement = function(node, geometry, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var context = /** @type {olx.format.WriteOptions} */ (objectStack[objectStack.length - 1]);
|
||||
var item = ol.object.assign({}, context);
|
||||
item.node = node;
|
||||
var value;
|
||||
@@ -1013,10 +996,8 @@ ol.format.GML3.prototype.writeGeometryElement = function(node, geometry, objectS
|
||||
value = geometry;
|
||||
}
|
||||
} else {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.Geometry,
|
||||
'geometry should be an ol.geom.Geometry');
|
||||
value =
|
||||
ol.format.Feature.transformWithOptions(geometry, true, context);
|
||||
ol.format.Feature.transformWithOptions(/** @type {ol.geom.Geometry} */ (geometry), true, context);
|
||||
}
|
||||
ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */
|
||||
(item), ol.format.GML3.GEOMETRY_SERIALIZERS_,
|
||||
@@ -1035,8 +1016,7 @@ ol.format.GML3.prototype.writeFeatureElement = function(node, feature, objectSta
|
||||
if (fid) {
|
||||
node.setAttribute('fid', fid);
|
||||
}
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||
var featureNS = context['featureNS'];
|
||||
var geometryName = feature.getGeometryName();
|
||||
if (!context.serializers) {
|
||||
@@ -1080,8 +1060,7 @@ ol.format.GML3.prototype.writeFeatureElement = function(node, feature, objectSta
|
||||
* @private
|
||||
*/
|
||||
ol.format.GML3.prototype.writeFeatureMembers_ = function(node, features, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||
var featureType = context['featureType'];
|
||||
var featureNS = context['featureNS'];
|
||||
var serializers = {};
|
||||
@@ -1206,7 +1185,7 @@ ol.format.GML3.MULTIGEOMETRY_TO_MEMBER_NODENAME_ = {
|
||||
*/
|
||||
ol.format.GML3.prototype.MULTIGEOMETRY_MEMBER_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) {
|
||||
var parentNode = objectStack[objectStack.length - 1].node;
|
||||
goog.asserts.assert(ol.xml.isNode(parentNode),
|
||||
ol.DEBUG && console.assert(ol.xml.isNode(parentNode),
|
||||
'parentNode should be a node');
|
||||
return ol.xml.createElementNS('http://www.opengis.net/gml',
|
||||
ol.format.GML3.MULTIGEOMETRY_TO_MEMBER_NODENAME_[parentNode.nodeName]);
|
||||
@@ -1223,19 +1202,16 @@ ol.format.GML3.prototype.MULTIGEOMETRY_MEMBER_NODE_FACTORY_ = function(value, ob
|
||||
*/
|
||||
ol.format.GML3.prototype.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var multiSurface = context['multiSurface'];
|
||||
var surface = context['surface'];
|
||||
var curve = context['curve'];
|
||||
var multiCurve = context['multiCurve'];
|
||||
var parentNode = objectStack[objectStack.length - 1].node;
|
||||
goog.asserts.assert(ol.xml.isNode(parentNode),
|
||||
ol.DEBUG && console.assert(ol.xml.isNode(parentNode),
|
||||
'parentNode should be a node');
|
||||
var nodeName;
|
||||
if (!Array.isArray(value)) {
|
||||
goog.asserts.assertInstanceof(value, ol.geom.Geometry,
|
||||
'value should be an ol.geom.Geometry');
|
||||
nodeName = value.getType();
|
||||
nodeName = /** @type {ol.geom.Geometry} */ (value).getType();
|
||||
if (nodeName === 'MultiPolygon' && multiSurface === true) {
|
||||
nodeName = 'MultiSurface';
|
||||
} else if (nodeName === 'Polygon' && surface === true) {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// envelopes/extents, only geometries!
|
||||
goog.provide('ol.format.GMLBase');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.format.Feature');
|
||||
@@ -108,7 +107,7 @@ ol.format.GMLBase.ONLY_WHITESPACE_RE_ = /^[\s\xa0]*$/;
|
||||
* @return {Array.<ol.Feature> | undefined} Features.
|
||||
*/
|
||||
ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
var localName = node.localName;
|
||||
var features = null;
|
||||
@@ -124,7 +123,6 @@ ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) {
|
||||
}
|
||||
} else if (localName == 'featureMembers' || localName == 'featureMember') {
|
||||
var context = objectStack[0];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var featureType = context['featureType'];
|
||||
var featureNS = context['featureNS'];
|
||||
var i, ii, prefix = 'p', defaultPrefix = 'p0';
|
||||
@@ -199,8 +197,7 @@ ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) {
|
||||
* @return {ol.geom.Geometry|undefined} Geometry.
|
||||
*/
|
||||
ol.format.GMLBase.prototype.readGeometryElement = function(node, objectStack) {
|
||||
var context = objectStack[0];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var context = /** @type {Object} */ (objectStack[0]);
|
||||
context['srsName'] = node.firstElementChild.getAttribute('srsName');
|
||||
/** @type {ol.geom.Geometry} */
|
||||
var geometry = ol.xml.pushParseAndPop(null,
|
||||
@@ -262,14 +259,14 @@ ol.format.GMLBase.prototype.readFeatureElement = function(node, objectStack) {
|
||||
* @return {ol.geom.Point|undefined} Point.
|
||||
*/
|
||||
ol.format.GMLBase.prototype.readPoint = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Point', 'localName should be Point');
|
||||
ol.DEBUG && console.assert(node.localName == 'Point', 'localName should be Point');
|
||||
var flatCoordinates =
|
||||
this.readFlatCoordinatesFromNode_(node, objectStack);
|
||||
if (flatCoordinates) {
|
||||
var point = new ol.geom.Point(null);
|
||||
goog.asserts.assert(flatCoordinates.length == 3,
|
||||
ol.DEBUG && console.assert(flatCoordinates.length == 3,
|
||||
'flatCoordinates should have a length of 3');
|
||||
point.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates);
|
||||
return point;
|
||||
@@ -283,9 +280,9 @@ ol.format.GMLBase.prototype.readPoint = function(node, objectStack) {
|
||||
* @return {ol.geom.MultiPoint|undefined} MultiPoint.
|
||||
*/
|
||||
ol.format.GMLBase.prototype.readMultiPoint = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'MultiPoint',
|
||||
ol.DEBUG && console.assert(node.localName == 'MultiPoint',
|
||||
'localName should be MultiPoint');
|
||||
/** @type {Array.<Array.<number>>} */
|
||||
var coordinates = ol.xml.pushParseAndPop([],
|
||||
@@ -304,9 +301,9 @@ ol.format.GMLBase.prototype.readMultiPoint = function(node, objectStack) {
|
||||
* @return {ol.geom.MultiLineString|undefined} MultiLineString.
|
||||
*/
|
||||
ol.format.GMLBase.prototype.readMultiLineString = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'MultiLineString',
|
||||
ol.DEBUG && console.assert(node.localName == 'MultiLineString',
|
||||
'localName should be MultiLineString');
|
||||
/** @type {Array.<ol.geom.LineString>} */
|
||||
var lineStrings = ol.xml.pushParseAndPop([],
|
||||
@@ -327,9 +324,9 @@ ol.format.GMLBase.prototype.readMultiLineString = function(node, objectStack) {
|
||||
* @return {ol.geom.MultiPolygon|undefined} MultiPolygon.
|
||||
*/
|
||||
ol.format.GMLBase.prototype.readMultiPolygon = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'MultiPolygon',
|
||||
ol.DEBUG && console.assert(node.localName == 'MultiPolygon',
|
||||
'localName should be MultiPolygon');
|
||||
/** @type {Array.<ol.geom.Polygon>} */
|
||||
var polygons = ol.xml.pushParseAndPop([],
|
||||
@@ -350,9 +347,9 @@ ol.format.GMLBase.prototype.readMultiPolygon = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.GMLBase.prototype.pointMemberParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'pointMember' ||
|
||||
ol.DEBUG && console.assert(node.localName == 'pointMember' ||
|
||||
node.localName == 'pointMembers',
|
||||
'localName should be pointMember or pointMembers');
|
||||
ol.xml.parseNode(this.POINTMEMBER_PARSERS_,
|
||||
@@ -366,9 +363,9 @@ ol.format.GMLBase.prototype.pointMemberParser_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.GMLBase.prototype.lineStringMemberParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'lineStringMember' ||
|
||||
ol.DEBUG && console.assert(node.localName == 'lineStringMember' ||
|
||||
node.localName == 'lineStringMembers',
|
||||
'localName should be LineStringMember or LineStringMembers');
|
||||
ol.xml.parseNode(this.LINESTRINGMEMBER_PARSERS_,
|
||||
@@ -382,9 +379,9 @@ ol.format.GMLBase.prototype.lineStringMemberParser_ = function(node, objectStack
|
||||
* @private
|
||||
*/
|
||||
ol.format.GMLBase.prototype.polygonMemberParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'polygonMember' ||
|
||||
ol.DEBUG && console.assert(node.localName == 'polygonMember' ||
|
||||
node.localName == 'polygonMembers',
|
||||
'localName should be polygonMember or polygonMembers');
|
||||
ol.xml.parseNode(this.POLYGONMEMBER_PARSERS_, node,
|
||||
@@ -398,9 +395,9 @@ ol.format.GMLBase.prototype.polygonMemberParser_ = function(node, objectStack) {
|
||||
* @return {ol.geom.LineString|undefined} LineString.
|
||||
*/
|
||||
ol.format.GMLBase.prototype.readLineString = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'LineString',
|
||||
ol.DEBUG && console.assert(node.localName == 'LineString',
|
||||
'localName should be LineString');
|
||||
var flatCoordinates =
|
||||
this.readFlatCoordinatesFromNode_(node, objectStack);
|
||||
@@ -421,9 +418,9 @@ ol.format.GMLBase.prototype.readLineString = function(node, objectStack) {
|
||||
* @return {Array.<number>|undefined} LinearRing flat coordinates.
|
||||
*/
|
||||
ol.format.GMLBase.prototype.readFlatLinearRing_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'LinearRing',
|
||||
ol.DEBUG && console.assert(node.localName == 'LinearRing',
|
||||
'localName should be LinearRing');
|
||||
var ring = ol.xml.pushParseAndPop(null,
|
||||
this.GEOMETRY_FLAT_COORDINATES_PARSERS_, node,
|
||||
@@ -442,9 +439,9 @@ ol.format.GMLBase.prototype.readFlatLinearRing_ = function(node, objectStack) {
|
||||
* @return {ol.geom.LinearRing|undefined} LinearRing.
|
||||
*/
|
||||
ol.format.GMLBase.prototype.readLinearRing = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'LinearRing',
|
||||
ol.DEBUG && console.assert(node.localName == 'LinearRing',
|
||||
'localName should be LinearRing');
|
||||
var flatCoordinates =
|
||||
this.readFlatCoordinatesFromNode_(node, objectStack);
|
||||
@@ -464,9 +461,9 @@ ol.format.GMLBase.prototype.readLinearRing = function(node, objectStack) {
|
||||
* @return {ol.geom.Polygon|undefined} Polygon.
|
||||
*/
|
||||
ol.format.GMLBase.prototype.readPolygon = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Polygon',
|
||||
ol.DEBUG && console.assert(node.localName == 'Polygon',
|
||||
'localName should be Polygon');
|
||||
/** @type {Array.<Array.<number>>} */
|
||||
var flatLinearRings = ol.xml.pushParseAndPop([null],
|
||||
@@ -496,7 +493,7 @@ ol.format.GMLBase.prototype.readPolygon = function(node, objectStack) {
|
||||
* @return {Array.<number>} Flat coordinates.
|
||||
*/
|
||||
ol.format.GMLBase.prototype.readFlatCoordinatesFromNode_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
return ol.xml.pushParseAndPop(null,
|
||||
this.GEOMETRY_FLAT_COORDINATES_PARSERS_, node,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.format.GPX');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.format.Feature');
|
||||
@@ -72,7 +71,7 @@ ol.format.GPX.SCHEMA_LOCATION_ = 'http://www.topografix.com/GPX/1/1 ' +
|
||||
* @return {Array.<number>} Flat coordinates.
|
||||
*/
|
||||
ol.format.GPX.appendCoordinate_ = function(flatCoordinates, node, values) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
flatCoordinates.push(
|
||||
parseFloat(node.getAttribute('lon')),
|
||||
@@ -99,9 +98,9 @@ ol.format.GPX.appendCoordinate_ = function(flatCoordinates, node, values) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.GPX.parseLink_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'link', 'localName should be link');
|
||||
ol.DEBUG && console.assert(node.localName == 'link', 'localName should be link');
|
||||
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||
var href = node.getAttribute('href');
|
||||
if (href !== null) {
|
||||
@@ -117,9 +116,9 @@ ol.format.GPX.parseLink_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.GPX.parseExtensions_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'extensions',
|
||||
ol.DEBUG && console.assert(node.localName == 'extensions',
|
||||
'localName should be extensions');
|
||||
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||
values['extensionsNode_'] = node;
|
||||
@@ -132,9 +131,9 @@ ol.format.GPX.parseExtensions_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.GPX.parseRtePt_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'rtept', 'localName should be rtept');
|
||||
ol.DEBUG && console.assert(node.localName == 'rtept', 'localName should be rtept');
|
||||
var values = ol.xml.pushParseAndPop(
|
||||
{}, ol.format.GPX.RTEPT_PARSERS_, node, objectStack);
|
||||
if (values) {
|
||||
@@ -152,9 +151,9 @@ ol.format.GPX.parseRtePt_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.GPX.parseTrkPt_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'trkpt', 'localName should be trkpt');
|
||||
ol.DEBUG && console.assert(node.localName == 'trkpt', 'localName should be trkpt');
|
||||
var values = ol.xml.pushParseAndPop(
|
||||
{}, ol.format.GPX.TRKPT_PARSERS_, node, objectStack);
|
||||
if (values) {
|
||||
@@ -172,9 +171,9 @@ ol.format.GPX.parseTrkPt_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.GPX.parseTrkSeg_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'trkseg',
|
||||
ol.DEBUG && console.assert(node.localName == 'trkseg',
|
||||
'localName should be trkseg');
|
||||
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||
ol.xml.parseNode(ol.format.GPX.TRKSEG_PARSERS_, node, objectStack);
|
||||
@@ -192,9 +191,9 @@ ol.format.GPX.parseTrkSeg_ = function(node, objectStack) {
|
||||
* @return {ol.Feature|undefined} Track.
|
||||
*/
|
||||
ol.format.GPX.readRte_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'rte', 'localName should be rte');
|
||||
ol.DEBUG && console.assert(node.localName == 'rte', 'localName should be rte');
|
||||
var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
|
||||
var values = ol.xml.pushParseAndPop({
|
||||
'flatCoordinates': []
|
||||
@@ -221,9 +220,9 @@ ol.format.GPX.readRte_ = function(node, objectStack) {
|
||||
* @return {ol.Feature|undefined} Track.
|
||||
*/
|
||||
ol.format.GPX.readTrk_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'trk', 'localName should be trk');
|
||||
ol.DEBUG && console.assert(node.localName == 'trk', 'localName should be trk');
|
||||
var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
|
||||
var values = ol.xml.pushParseAndPop({
|
||||
'flatCoordinates': [],
|
||||
@@ -254,9 +253,9 @@ ol.format.GPX.readTrk_ = function(node, objectStack) {
|
||||
* @return {ol.Feature|undefined} Waypoint.
|
||||
*/
|
||||
ol.format.GPX.readWpt_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'wpt', 'localName should be wpt');
|
||||
ol.DEBUG && console.assert(node.localName == 'wpt', 'localName should be wpt');
|
||||
var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
|
||||
var values = ol.xml.pushParseAndPop(
|
||||
{}, ol.format.GPX.WPT_PARSERS_, node, objectStack);
|
||||
@@ -456,7 +455,7 @@ ol.format.GPX.prototype.readFeature;
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.GPX.prototype.readFeatureFromNode = function(node, opt_options) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
if (!ol.array.includes(ol.format.GPX.NAMESPACE_URIS_, node.namespaceURI)) {
|
||||
return null;
|
||||
@@ -492,7 +491,7 @@ ol.format.GPX.prototype.readFeatures;
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.GPX.prototype.readFeaturesFromNode = function(node, opt_options) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
if (!ol.array.includes(ol.format.GPX.NAMESPACE_URIS_, node.namespaceURI)) {
|
||||
return [];
|
||||
@@ -532,7 +531,6 @@ ol.format.GPX.prototype.readProjection;
|
||||
ol.format.GPX.writeLink_ = function(node, value, objectStack) {
|
||||
node.setAttribute('href', value);
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var properties = context['properties'];
|
||||
var link = [
|
||||
properties['linkText'],
|
||||
@@ -552,9 +550,8 @@ ol.format.GPX.writeLink_ = function(node, value, objectStack) {
|
||||
*/
|
||||
ol.format.GPX.writeWptType_ = function(node, coordinate, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var parentNode = context.node;
|
||||
goog.asserts.assert(ol.xml.isNode(parentNode),
|
||||
ol.DEBUG && console.assert(ol.xml.isNode(parentNode),
|
||||
'parentNode should be an XML node');
|
||||
var namespaceURI = parentNode.namespaceURI;
|
||||
var properties = context['properties'];
|
||||
@@ -604,8 +601,6 @@ ol.format.GPX.writeRte_ = function(node, feature, objectStack) {
|
||||
var context = {node: node, 'properties': properties};
|
||||
var geometry = feature.getGeometry();
|
||||
if (geometry) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.LineString,
|
||||
'geometry should be an ol.geom.LineString');
|
||||
geometry = /** @type {ol.geom.LineString} */
|
||||
(ol.format.Feature.transformWithOptions(geometry, true, options));
|
||||
context['geometryLayout'] = geometry.getLayout();
|
||||
@@ -633,8 +628,6 @@ ol.format.GPX.writeTrk_ = function(node, feature, objectStack) {
|
||||
var context = {node: node, 'properties': properties};
|
||||
var geometry = feature.getGeometry();
|
||||
if (geometry) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.MultiLineString,
|
||||
'geometry should be an ol.geom.MultiLineString');
|
||||
geometry = /** @type {ol.geom.MultiLineString} */
|
||||
(ol.format.Feature.transformWithOptions(geometry, true, options));
|
||||
properties['trkseg'] = geometry.getLineStrings();
|
||||
@@ -673,12 +666,9 @@ ol.format.GPX.writeTrkSeg_ = function(node, lineString, objectStack) {
|
||||
ol.format.GPX.writeWpt_ = function(node, feature, objectStack) {
|
||||
var options = /** @type {olx.format.WriteOptions} */ (objectStack[0]);
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
context['properties'] = feature.getProperties();
|
||||
var geometry = feature.getGeometry();
|
||||
if (geometry) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.Point,
|
||||
'geometry should be an ol.geom.Point');
|
||||
geometry = /** @type {ol.geom.Point} */
|
||||
(ol.format.Feature.transformWithOptions(geometry, true, options));
|
||||
context['geometryLayout'] = geometry.getLayout();
|
||||
@@ -863,14 +853,12 @@ ol.format.GPX.GEOMETRY_TYPE_TO_NODENAME_ = {
|
||||
* @private
|
||||
*/
|
||||
ol.format.GPX.GPX_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) {
|
||||
goog.asserts.assertInstanceof(value, ol.Feature,
|
||||
'value should be an ol.Feature');
|
||||
var geometry = value.getGeometry();
|
||||
var geometry = /** @type {ol.Feature} */ (value).getGeometry();
|
||||
if (geometry) {
|
||||
var nodeName = ol.format.GPX.GEOMETRY_TYPE_TO_NODENAME_[geometry.getType()];
|
||||
if (nodeName) {
|
||||
var parentNode = objectStack[objectStack.length - 1].node;
|
||||
goog.asserts.assert(ol.xml.isNode(parentNode),
|
||||
ol.DEBUG && console.assert(ol.xml.isNode(parentNode),
|
||||
'parentNode should be an XML node');
|
||||
return ol.xml.createElementNS(parentNode.namespaceURI, nodeName);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
goog.provide('ol.format.IGC');
|
||||
goog.provide('ol.format.IGCZ');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.format.Feature');
|
||||
goog.require('ol.format.TextFeature');
|
||||
@@ -154,7 +153,7 @@ ol.format.IGC.prototype.readFeatureFromText = function(text, opt_options) {
|
||||
} else if (altitudeMode == ol.format.IGCZ.BAROMETRIC) {
|
||||
z = parseInt(m[12], 10);
|
||||
} else {
|
||||
goog.asserts.fail();
|
||||
ol.DEBUG && console.assert(false, 'Unknown altitude mode.');
|
||||
z = 0;
|
||||
}
|
||||
flatCoordinates.push(z);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.format.JSONFeature');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.format.Feature');
|
||||
goog.require('ol.format.FormatType');
|
||||
|
||||
@@ -32,7 +31,6 @@ ol.format.JSONFeature.prototype.getObject_ = function(source) {
|
||||
} else if (source !== null) {
|
||||
return source;
|
||||
} else {
|
||||
goog.asserts.fail();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
goog.provide('ol.format.KML');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol');
|
||||
goog.require('ol.Feature');
|
||||
@@ -543,9 +542,9 @@ ol.format.KML.readStyleMapValue_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.KML.IconStyleParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be an ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'IconStyle',
|
||||
ol.DEBUG && console.assert(node.localName == 'IconStyle',
|
||||
'localName should be IconStyle');
|
||||
// FIXME refreshMode
|
||||
// FIXME refreshInterval
|
||||
@@ -559,8 +558,6 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
|
||||
return;
|
||||
}
|
||||
var styleObject = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||
goog.asserts.assert(goog.isObject(styleObject),
|
||||
'styleObject should be an Object');
|
||||
var IconObject = 'Icon' in object ? object['Icon'] : {};
|
||||
var src;
|
||||
var href = /** @type {string|undefined} */
|
||||
@@ -644,9 +641,9 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.KML.LabelStyleParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'LabelStyle',
|
||||
ol.DEBUG && console.assert(node.localName == 'LabelStyle',
|
||||
'localName should be LabelStyle');
|
||||
// FIXME colorMode
|
||||
var object = ol.xml.pushParseAndPop(
|
||||
@@ -655,8 +652,6 @@ ol.format.KML.LabelStyleParser_ = function(node, objectStack) {
|
||||
return;
|
||||
}
|
||||
var styleObject = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(styleObject),
|
||||
'styleObject should be an Object');
|
||||
var textStyle = new ol.style.Text({
|
||||
fill: new ol.style.Fill({
|
||||
color: /** @type {ol.Color} */
|
||||
@@ -675,9 +670,9 @@ ol.format.KML.LabelStyleParser_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.KML.LineStyleParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'LineStyle',
|
||||
ol.DEBUG && console.assert(node.localName == 'LineStyle',
|
||||
'localName should be LineStyle');
|
||||
// FIXME colorMode
|
||||
// FIXME gx:outerColor
|
||||
@@ -690,8 +685,6 @@ ol.format.KML.LineStyleParser_ = function(node, objectStack) {
|
||||
return;
|
||||
}
|
||||
var styleObject = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(styleObject),
|
||||
'styleObject should be an Object');
|
||||
var strokeStyle = new ol.style.Stroke({
|
||||
color: /** @type {ol.Color} */
|
||||
('color' in object ? object['color'] : ol.format.KML.DEFAULT_COLOR_),
|
||||
@@ -707,9 +700,9 @@ ol.format.KML.LineStyleParser_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.KML.PolyStyleParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'PolyStyle',
|
||||
ol.DEBUG && console.assert(node.localName == 'PolyStyle',
|
||||
'localName should be PolyStyle');
|
||||
// FIXME colorMode
|
||||
var object = ol.xml.pushParseAndPop(
|
||||
@@ -718,8 +711,6 @@ ol.format.KML.PolyStyleParser_ = function(node, objectStack) {
|
||||
return;
|
||||
}
|
||||
var styleObject = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(styleObject),
|
||||
'styleObject should be an Object');
|
||||
var fillStyle = new ol.style.Fill({
|
||||
color: /** @type {ol.Color} */
|
||||
('color' in object ? object['color'] : ol.format.KML.DEFAULT_COLOR_)
|
||||
@@ -744,9 +735,9 @@ ol.format.KML.PolyStyleParser_ = function(node, objectStack) {
|
||||
* @return {Array.<number>} LinearRing flat coordinates.
|
||||
*/
|
||||
ol.format.KML.readFlatLinearRing_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'LinearRing',
|
||||
ol.DEBUG && console.assert(node.localName == 'LinearRing',
|
||||
'localName should be LinearRing');
|
||||
return ol.xml.pushParseAndPop(null,
|
||||
ol.format.KML.FLAT_LINEAR_RING_PARSERS_, node, objectStack);
|
||||
@@ -759,16 +750,14 @@ ol.format.KML.readFlatLinearRing_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.KML.gxCoordParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(ol.array.includes(
|
||||
ol.DEBUG && console.assert(ol.array.includes(
|
||||
ol.format.KML.GX_NAMESPACE_URIS_, node.namespaceURI),
|
||||
'namespaceURI of the node should be known to the KML parser');
|
||||
goog.asserts.assert(node.localName == 'coord', 'localName should be coord');
|
||||
ol.DEBUG && console.assert(node.localName == 'coord', 'localName should be coord');
|
||||
var gxTrackObject = /** @type {ol.KMLGxTrackObject_} */
|
||||
(objectStack[objectStack.length - 1]);
|
||||
goog.asserts.assert(goog.isObject(gxTrackObject),
|
||||
'gxTrackObject should be an Object');
|
||||
var flatCoordinates = gxTrackObject.flatCoordinates;
|
||||
var s = ol.xml.getAllTextContent(node, false);
|
||||
var re =
|
||||
@@ -792,12 +781,12 @@ ol.format.KML.gxCoordParser_ = function(node, objectStack) {
|
||||
* @return {ol.geom.MultiLineString|undefined} MultiLineString.
|
||||
*/
|
||||
ol.format.KML.readGxMultiTrack_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(ol.array.includes(
|
||||
ol.DEBUG && console.assert(ol.array.includes(
|
||||
ol.format.KML.GX_NAMESPACE_URIS_, node.namespaceURI),
|
||||
'namespaceURI of the node should be known to the KML parser');
|
||||
goog.asserts.assert(node.localName == 'MultiTrack',
|
||||
ol.DEBUG && console.assert(node.localName == 'MultiTrack',
|
||||
'localName should be MultiTrack');
|
||||
var lineStrings = ol.xml.pushParseAndPop([],
|
||||
ol.format.KML.GX_MULTITRACK_GEOMETRY_PARSERS_, node, objectStack);
|
||||
@@ -817,12 +806,12 @@ ol.format.KML.readGxMultiTrack_ = function(node, objectStack) {
|
||||
* @return {ol.geom.LineString|undefined} LineString.
|
||||
*/
|
||||
ol.format.KML.readGxTrack_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(ol.array.includes(
|
||||
ol.DEBUG && console.assert(ol.array.includes(
|
||||
ol.format.KML.GX_NAMESPACE_URIS_, node.namespaceURI),
|
||||
'namespaceURI of the node should be known to the KML parser');
|
||||
goog.asserts.assert(node.localName == 'Track', 'localName should be Track');
|
||||
ol.DEBUG && console.assert(node.localName == 'Track', 'localName should be Track');
|
||||
var gxTrackObject = ol.xml.pushParseAndPop(
|
||||
/** @type {ol.KMLGxTrackObject_} */ ({
|
||||
flatCoordinates: [],
|
||||
@@ -833,7 +822,7 @@ ol.format.KML.readGxTrack_ = function(node, objectStack) {
|
||||
}
|
||||
var flatCoordinates = gxTrackObject.flatCoordinates;
|
||||
var whens = gxTrackObject.whens;
|
||||
goog.asserts.assert(flatCoordinates.length / 4 == whens.length,
|
||||
ol.DEBUG && console.assert(flatCoordinates.length / 4 == whens.length,
|
||||
'the length of the flatCoordinates array divided by 4 should be the ' +
|
||||
'length of the whens array');
|
||||
var i, ii;
|
||||
@@ -854,9 +843,9 @@ ol.format.KML.readGxTrack_ = function(node, objectStack) {
|
||||
* @return {Object} Icon object.
|
||||
*/
|
||||
ol.format.KML.readIcon_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Icon', 'localName should be Icon');
|
||||
ol.DEBUG && console.assert(node.localName == 'Icon', 'localName should be Icon');
|
||||
var iconObject = ol.xml.pushParseAndPop(
|
||||
{}, ol.format.KML.ICON_PARSERS_, node, objectStack);
|
||||
if (iconObject) {
|
||||
@@ -874,7 +863,7 @@ ol.format.KML.readIcon_ = function(node, objectStack) {
|
||||
* @return {Array.<number>} Flat coordinates.
|
||||
*/
|
||||
ol.format.KML.readFlatCoordinatesFromNode_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
return ol.xml.pushParseAndPop(null,
|
||||
ol.format.KML.GEOMETRY_FLAT_COORDINATES_PARSERS_, node, objectStack);
|
||||
@@ -888,9 +877,9 @@ ol.format.KML.readFlatCoordinatesFromNode_ = function(node, objectStack) {
|
||||
* @return {ol.geom.LineString|undefined} LineString.
|
||||
*/
|
||||
ol.format.KML.readLineString_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'LineString',
|
||||
ol.DEBUG && console.assert(node.localName == 'LineString',
|
||||
'localName should be LineString');
|
||||
var properties = ol.xml.pushParseAndPop({},
|
||||
ol.format.KML.EXTRUDE_AND_ALTITUDE_MODE_PARSERS_, node,
|
||||
@@ -915,9 +904,9 @@ ol.format.KML.readLineString_ = function(node, objectStack) {
|
||||
* @return {ol.geom.Polygon|undefined} Polygon.
|
||||
*/
|
||||
ol.format.KML.readLinearRing_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'LinearRing',
|
||||
ol.DEBUG && console.assert(node.localName == 'LinearRing',
|
||||
'localName should be LinearRing');
|
||||
var properties = ol.xml.pushParseAndPop({},
|
||||
ol.format.KML.EXTRUDE_AND_ALTITUDE_MODE_PARSERS_, node,
|
||||
@@ -943,9 +932,9 @@ ol.format.KML.readLinearRing_ = function(node, objectStack) {
|
||||
* @return {ol.geom.Geometry} Geometry.
|
||||
*/
|
||||
ol.format.KML.readMultiGeometry_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'MultiGeometry',
|
||||
ol.DEBUG && console.assert(node.localName == 'MultiGeometry',
|
||||
'localName should be MultiGeometry');
|
||||
var geometries = ol.xml.pushParseAndPop([],
|
||||
ol.format.KML.MULTI_GEOMETRY_PARSERS_, node, objectStack);
|
||||
@@ -955,6 +944,8 @@ ol.format.KML.readMultiGeometry_ = function(node, objectStack) {
|
||||
if (geometries.length === 0) {
|
||||
return new ol.geom.GeometryCollection(geometries);
|
||||
}
|
||||
/** @type {ol.geom.Geometry} */
|
||||
var multiGeometry;
|
||||
var homogeneous = true;
|
||||
var type = geometries[0].getType();
|
||||
var geometry, i, ii;
|
||||
@@ -970,41 +961,34 @@ ol.format.KML.readMultiGeometry_ = function(node, objectStack) {
|
||||
var flatCoordinates;
|
||||
if (type == ol.geom.GeometryType.POINT) {
|
||||
var point = geometries[0];
|
||||
goog.asserts.assertInstanceof(point, ol.geom.Point,
|
||||
'point should be an ol.geom.Point');
|
||||
layout = point.getLayout();
|
||||
flatCoordinates = point.getFlatCoordinates();
|
||||
for (i = 1, ii = geometries.length; i < ii; ++i) {
|
||||
geometry = geometries[i];
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.Point,
|
||||
'geometry should be an ol.geom.Point');
|
||||
goog.asserts.assert(geometry.getLayout() == layout,
|
||||
ol.DEBUG && console.assert(geometry.getLayout() == layout,
|
||||
'geometry layout should be consistent');
|
||||
ol.array.extend(flatCoordinates, geometry.getFlatCoordinates());
|
||||
}
|
||||
var multiPoint = new ol.geom.MultiPoint(null);
|
||||
multiPoint.setFlatCoordinates(layout, flatCoordinates);
|
||||
ol.format.KML.setCommonGeometryProperties_(multiPoint, geometries);
|
||||
return multiPoint;
|
||||
multiGeometry = new ol.geom.MultiPoint(null);
|
||||
multiGeometry.setFlatCoordinates(layout, flatCoordinates);
|
||||
ol.format.KML.setCommonGeometryProperties_(multiGeometry, geometries);
|
||||
} else if (type == ol.geom.GeometryType.LINE_STRING) {
|
||||
var multiLineString = new ol.geom.MultiLineString(null);
|
||||
multiLineString.setLineStrings(geometries);
|
||||
ol.format.KML.setCommonGeometryProperties_(multiLineString, geometries);
|
||||
return multiLineString;
|
||||
multiGeometry = new ol.geom.MultiLineString(null);
|
||||
multiGeometry.setLineStrings(geometries);
|
||||
ol.format.KML.setCommonGeometryProperties_(multiGeometry, geometries);
|
||||
} else if (type == ol.geom.GeometryType.POLYGON) {
|
||||
var multiPolygon = new ol.geom.MultiPolygon(null);
|
||||
multiPolygon.setPolygons(geometries);
|
||||
ol.format.KML.setCommonGeometryProperties_(multiPolygon, geometries);
|
||||
return multiPolygon;
|
||||
multiGeometry = new ol.geom.MultiPolygon(null);
|
||||
multiGeometry.setPolygons(geometries);
|
||||
ol.format.KML.setCommonGeometryProperties_(multiGeometry, geometries);
|
||||
} else if (type == ol.geom.GeometryType.GEOMETRY_COLLECTION) {
|
||||
return new ol.geom.GeometryCollection(geometries);
|
||||
multiGeometry = new ol.geom.GeometryCollection(geometries);
|
||||
} else {
|
||||
goog.asserts.fail('Unexpected type: ' + type);
|
||||
return null;
|
||||
ol.assert(false, 37); // Unknown geometry type found
|
||||
}
|
||||
} else {
|
||||
return new ol.geom.GeometryCollection(geometries);
|
||||
multiGeometry = new ol.geom.GeometryCollection(geometries);
|
||||
}
|
||||
return /** @type {ol.geom.Geometry} */ (multiGeometry);
|
||||
};
|
||||
|
||||
|
||||
@@ -1015,9 +999,9 @@ ol.format.KML.readMultiGeometry_ = function(node, objectStack) {
|
||||
* @return {ol.geom.Point|undefined} Point.
|
||||
*/
|
||||
ol.format.KML.readPoint_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Point', 'localName should be Point');
|
||||
ol.DEBUG && console.assert(node.localName == 'Point', 'localName should be Point');
|
||||
var properties = ol.xml.pushParseAndPop({},
|
||||
ol.format.KML.EXTRUDE_AND_ALTITUDE_MODE_PARSERS_, node,
|
||||
objectStack);
|
||||
@@ -1025,7 +1009,7 @@ ol.format.KML.readPoint_ = function(node, objectStack) {
|
||||
ol.format.KML.readFlatCoordinatesFromNode_(node, objectStack);
|
||||
if (flatCoordinates) {
|
||||
var point = new ol.geom.Point(null);
|
||||
goog.asserts.assert(flatCoordinates.length == 3,
|
||||
ol.DEBUG && console.assert(flatCoordinates.length == 3,
|
||||
'flatCoordinates should have a length of 3');
|
||||
point.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates);
|
||||
point.setProperties(properties);
|
||||
@@ -1043,9 +1027,9 @@ ol.format.KML.readPoint_ = function(node, objectStack) {
|
||||
* @return {ol.geom.Polygon|undefined} Polygon.
|
||||
*/
|
||||
ol.format.KML.readPolygon_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Polygon',
|
||||
ol.DEBUG && console.assert(node.localName == 'Polygon',
|
||||
'localName should be Polygon');
|
||||
var properties = ol.xml.pushParseAndPop(/** @type {Object<string,*>} */ ({}),
|
||||
ol.format.KML.EXTRUDE_AND_ALTITUDE_MODE_PARSERS_, node,
|
||||
@@ -1078,9 +1062,9 @@ ol.format.KML.readPolygon_ = function(node, objectStack) {
|
||||
* @return {Array.<ol.style.Style>} Style.
|
||||
*/
|
||||
ol.format.KML.readStyle_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Style', 'localName should be Style');
|
||||
ol.DEBUG && console.assert(node.localName == 'Style', 'localName should be Style');
|
||||
var styleObject = ol.xml.pushParseAndPop(
|
||||
{}, ol.format.KML.STYLE_PARSERS_, node, objectStack);
|
||||
if (!styleObject) {
|
||||
@@ -1154,9 +1138,9 @@ ol.format.KML.setCommonGeometryProperties_ = function(multiGeometry,
|
||||
* @private
|
||||
*/
|
||||
ol.format.KML.DataParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Data', 'localName should be Data');
|
||||
ol.DEBUG && console.assert(node.localName == 'Data', 'localName should be Data');
|
||||
var name = node.getAttribute('name');
|
||||
if (name !== null) {
|
||||
var data = ol.xml.pushParseAndPop(
|
||||
@@ -1164,8 +1148,6 @@ ol.format.KML.DataParser_ = function(node, objectStack) {
|
||||
if (data) {
|
||||
var featureObject =
|
||||
/** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||
goog.asserts.assert(goog.isObject(featureObject),
|
||||
'featureObject should be an Object');
|
||||
featureObject[name] = data;
|
||||
}
|
||||
}
|
||||
@@ -1178,9 +1160,9 @@ ol.format.KML.DataParser_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.KML.ExtendedDataParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'ExtendedData',
|
||||
ol.DEBUG && console.assert(node.localName == 'ExtendedData',
|
||||
'localName should be ExtendedData');
|
||||
ol.xml.parseNode(ol.format.KML.EXTENDED_DATA_PARSERS_, node, objectStack);
|
||||
};
|
||||
@@ -1192,9 +1174,9 @@ ol.format.KML.ExtendedDataParser_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.KML.PairDataParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Pair', 'localName should be Pair');
|
||||
ol.DEBUG && console.assert(node.localName == 'Pair', 'localName should be Pair');
|
||||
var pairObject = ol.xml.pushParseAndPop(
|
||||
{}, ol.format.KML.PAIR_PARSERS_, node, objectStack);
|
||||
if (!pairObject) {
|
||||
@@ -1223,23 +1205,21 @@ ol.format.KML.PairDataParser_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.KML.PlacemarkStyleMapParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'StyleMap',
|
||||
ol.DEBUG && console.assert(node.localName == 'StyleMap',
|
||||
'localName should be StyleMap');
|
||||
var styleMapValue = ol.format.KML.readStyleMapValue_(node, objectStack);
|
||||
if (!styleMapValue) {
|
||||
return;
|
||||
}
|
||||
var placemarkObject = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(placemarkObject),
|
||||
'placemarkObject should be an Object');
|
||||
if (Array.isArray(styleMapValue)) {
|
||||
placemarkObject['Style'] = styleMapValue;
|
||||
} else if (typeof styleMapValue === 'string') {
|
||||
placemarkObject['styleUrl'] = styleMapValue;
|
||||
} else {
|
||||
goog.asserts.fail('styleMapValue has an unknown type');
|
||||
ol.assert(false, 38); // `styleMapValue` has an unknown type
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1250,9 +1230,9 @@ ol.format.KML.PlacemarkStyleMapParser_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.KML.SchemaDataParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'SchemaData',
|
||||
ol.DEBUG && console.assert(node.localName == 'SchemaData',
|
||||
'localName should be SchemaData');
|
||||
ol.xml.parseNode(ol.format.KML.SCHEMA_DATA_PARSERS_, node, objectStack);
|
||||
};
|
||||
@@ -1264,9 +1244,9 @@ ol.format.KML.SchemaDataParser_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.KML.SimpleDataParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'SimpleData',
|
||||
ol.DEBUG && console.assert(node.localName == 'SimpleData',
|
||||
'localName should be SimpleData');
|
||||
var name = node.getAttribute('name');
|
||||
if (name !== null) {
|
||||
@@ -1284,9 +1264,9 @@ ol.format.KML.SimpleDataParser_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.KML.innerBoundaryIsParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'innerBoundaryIs',
|
||||
ol.DEBUG && console.assert(node.localName == 'innerBoundaryIs',
|
||||
'localName should be innerBoundaryIs');
|
||||
/** @type {Array.<number>|undefined} */
|
||||
var flatLinearRing = ol.xml.pushParseAndPop(undefined,
|
||||
@@ -1294,9 +1274,9 @@ ol.format.KML.innerBoundaryIsParser_ = function(node, objectStack) {
|
||||
if (flatLinearRing) {
|
||||
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
||||
(objectStack[objectStack.length - 1]);
|
||||
goog.asserts.assert(Array.isArray(flatLinearRings),
|
||||
ol.DEBUG && console.assert(Array.isArray(flatLinearRings),
|
||||
'flatLinearRings should be an array');
|
||||
goog.asserts.assert(flatLinearRings.length > 0,
|
||||
ol.DEBUG && console.assert(flatLinearRings.length > 0,
|
||||
'flatLinearRings array should not be empty');
|
||||
flatLinearRings.push(flatLinearRing);
|
||||
}
|
||||
@@ -1309,9 +1289,9 @@ ol.format.KML.innerBoundaryIsParser_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.KML.outerBoundaryIsParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'outerBoundaryIs',
|
||||
ol.DEBUG && console.assert(node.localName == 'outerBoundaryIs',
|
||||
'localName should be outerBoundaryIs');
|
||||
/** @type {Array.<number>|undefined} */
|
||||
var flatLinearRing = ol.xml.pushParseAndPop(undefined,
|
||||
@@ -1319,9 +1299,9 @@ ol.format.KML.outerBoundaryIsParser_ = function(node, objectStack) {
|
||||
if (flatLinearRing) {
|
||||
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
||||
(objectStack[objectStack.length - 1]);
|
||||
goog.asserts.assert(Array.isArray(flatLinearRings),
|
||||
ol.DEBUG && console.assert(Array.isArray(flatLinearRings),
|
||||
'flatLinearRings should be an array');
|
||||
goog.asserts.assert(flatLinearRings.length > 0,
|
||||
ol.DEBUG && console.assert(flatLinearRings.length > 0,
|
||||
'flatLinearRings array should not be empty');
|
||||
flatLinearRings[0] = flatLinearRing;
|
||||
}
|
||||
@@ -1334,9 +1314,9 @@ ol.format.KML.outerBoundaryIsParser_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.KML.LinkParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Link', 'localName should be Link');
|
||||
ol.DEBUG && console.assert(node.localName == 'Link', 'localName should be Link');
|
||||
ol.xml.parseNode(ol.format.KML.LINK_PARSERS_, node, objectStack);
|
||||
};
|
||||
|
||||
@@ -1347,13 +1327,11 @@ ol.format.KML.LinkParser_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.KML.whenParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'when', 'localName should be when');
|
||||
ol.DEBUG && console.assert(node.localName == 'when', 'localName should be when');
|
||||
var gxTrackObject = /** @type {ol.KMLGxTrackObject_} */
|
||||
(objectStack[objectStack.length - 1]);
|
||||
goog.asserts.assert(goog.isObject(gxTrackObject),
|
||||
'gxTrackObject should be an Object');
|
||||
var whens = gxTrackObject.whens;
|
||||
var s = ol.xml.getAllTextContent(node, false);
|
||||
var when = Date.parse(s);
|
||||
@@ -1690,10 +1668,10 @@ ol.format.KML.prototype.getExtensions = function() {
|
||||
* @return {Array.<ol.Feature>|undefined} Features.
|
||||
*/
|
||||
ol.format.KML.prototype.readDocumentOrFolder_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
var localName = node.localName;
|
||||
goog.asserts.assert(localName == 'Document' || localName == 'Folder',
|
||||
ol.DEBUG && console.assert(localName == 'Document' || localName == 'Folder',
|
||||
'localName should be Document or Folder');
|
||||
// FIXME use scope somehow
|
||||
var parsersNS = ol.xml.makeStructureNS(
|
||||
@@ -1721,9 +1699,9 @@ ol.format.KML.prototype.readDocumentOrFolder_ = function(node, objectStack) {
|
||||
* @return {ol.Feature|undefined} Feature.
|
||||
*/
|
||||
ol.format.KML.prototype.readPlacemark_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Placemark',
|
||||
ol.DEBUG && console.assert(node.localName == 'Placemark',
|
||||
'localName should be Placemark');
|
||||
var object = ol.xml.pushParseAndPop({'geometry': null},
|
||||
ol.format.KML.PLACEMARK_PARSERS_, node, objectStack);
|
||||
@@ -1768,9 +1746,9 @@ ol.format.KML.prototype.readPlacemark_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.KML.prototype.readSharedStyle_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Style', 'localName should be Style');
|
||||
ol.DEBUG && console.assert(node.localName == 'Style', 'localName should be Style');
|
||||
var id = node.getAttribute('id');
|
||||
if (id !== null) {
|
||||
var style = ol.format.KML.readStyle_(node, objectStack);
|
||||
@@ -1794,9 +1772,9 @@ ol.format.KML.prototype.readSharedStyle_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.KML.prototype.readSharedStyleMap_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'StyleMap',
|
||||
ol.DEBUG && console.assert(node.localName == 'StyleMap',
|
||||
'localName should be StyleMap');
|
||||
var id = node.getAttribute('id');
|
||||
if (id === null) {
|
||||
@@ -1835,12 +1813,12 @@ ol.format.KML.prototype.readFeature;
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.KML.prototype.readFeatureFromNode = function(node, opt_options) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
if (!ol.array.includes(ol.format.KML.NAMESPACE_URIS_, node.namespaceURI)) {
|
||||
return null;
|
||||
}
|
||||
goog.asserts.assert(node.localName == 'Placemark',
|
||||
ol.DEBUG && console.assert(node.localName == 'Placemark',
|
||||
'localName should be Placemark');
|
||||
var feature = this.readPlacemark_(
|
||||
node, [this.getReadOptions(node, opt_options)]);
|
||||
@@ -1870,7 +1848,7 @@ ol.format.KML.prototype.readFeatures;
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.KML.prototype.readFeaturesFromNode = function(node, opt_options) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
if (!ol.array.includes(ol.format.KML.NAMESPACE_URIS_, node.namespaceURI)) {
|
||||
return [];
|
||||
@@ -1925,7 +1903,6 @@ ol.format.KML.prototype.readName = function(source) {
|
||||
var doc = ol.xml.parse(source);
|
||||
return this.readNameFromDocument(doc);
|
||||
} else {
|
||||
goog.asserts.fail('Unknown type for source');
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
@@ -1996,8 +1973,6 @@ ol.format.KML.prototype.readNetworkLinks = function(source) {
|
||||
} else if (typeof source === 'string') {
|
||||
var doc = ol.xml.parse(source);
|
||||
ol.array.extend(networkLinks, this.readNetworkLinksFromDocument(doc));
|
||||
} else {
|
||||
goog.asserts.fail('unknown type for source');
|
||||
}
|
||||
return networkLinks;
|
||||
};
|
||||
@@ -2082,7 +2057,6 @@ ol.format.KML.writeColorTextNode_ = function(node, color) {
|
||||
*/
|
||||
ol.format.KML.writeCoordinatesTextNode_ = function(node, coordinates, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
|
||||
var layout = context['layout'];
|
||||
var stride = context['stride'];
|
||||
@@ -2095,7 +2069,7 @@ ol.format.KML.writeCoordinatesTextNode_ = function(node, coordinates, objectStac
|
||||
layout == ol.geom.GeometryLayout.XYZM) {
|
||||
dimension = 3;
|
||||
} else {
|
||||
goog.asserts.fail('Unknown geometry layout');
|
||||
ol.assert(false, 34); // Invalid geometry layout
|
||||
}
|
||||
|
||||
var d, i;
|
||||
@@ -2265,13 +2239,6 @@ ol.format.KML.writeLineStyle_ = function(node, style, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.KML.writeMultiGeometry_ = function(node, geometry, objectStack) {
|
||||
goog.asserts.assert(
|
||||
(geometry instanceof ol.geom.GeometryCollection) ||
|
||||
(geometry instanceof ol.geom.MultiPoint) ||
|
||||
(geometry instanceof ol.geom.MultiLineString) ||
|
||||
(geometry instanceof ol.geom.MultiPolygon),
|
||||
'geometry should be one of: ol.geom.GeometryCollection, ' +
|
||||
'ol.geom.MultiPoint, ol.geom.MultiLineString or ol.geom.MultiPolygon');
|
||||
/** @type {ol.XmlNodeStackItem} */
|
||||
var context = {node: node};
|
||||
var type = geometry.getType();
|
||||
@@ -2280,11 +2247,10 @@ ol.format.KML.writeMultiGeometry_ = function(node, geometry, objectStack) {
|
||||
/** @type {function(*, Array.<*>, string=): (Node|undefined)} */
|
||||
var factory;
|
||||
if (type == ol.geom.GeometryType.GEOMETRY_COLLECTION) {
|
||||
geometries = geometry.getGeometries();
|
||||
geometries = /** @type {ol.geom.GeometryCollection} */ (geometry).getGeometries();
|
||||
factory = ol.format.KML.GEOMETRY_NODE_FACTORY_;
|
||||
} else if (type == ol.geom.GeometryType.MULTI_POINT) {
|
||||
geometries =
|
||||
(/** @type {ol.geom.MultiPoint} */ (geometry)).getPoints();
|
||||
geometries = /** @type {ol.geom.MultiPoint} */ (geometry).getPoints();
|
||||
factory = ol.format.KML.POINT_NODE_FACTORY_;
|
||||
} else if (type == ol.geom.GeometryType.MULTI_LINE_STRING) {
|
||||
geometries =
|
||||
@@ -2295,7 +2261,7 @@ ol.format.KML.writeMultiGeometry_ = function(node, geometry, objectStack) {
|
||||
(/** @type {ol.geom.MultiPolygon} */ (geometry)).getPolygons();
|
||||
factory = ol.format.KML.POLYGON_NODE_FACTORY_;
|
||||
} else {
|
||||
goog.asserts.fail('Unknown geometry type: ' + type);
|
||||
ol.assert(false, 39); // Unknown geometry type
|
||||
}
|
||||
ol.xml.pushSerializeAndPop(context,
|
||||
ol.format.KML.MULTI_GEOMETRY_SERIALIZERS_, factory,
|
||||
@@ -2378,7 +2344,7 @@ ol.format.KML.writePlacemark_ = function(node, feature, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.KML.writePrimitiveGeometry_ = function(node, geometry, objectStack) {
|
||||
goog.asserts.assert(
|
||||
ol.DEBUG && console.assert(
|
||||
(geometry instanceof ol.geom.Point) ||
|
||||
(geometry instanceof ol.geom.LineString) ||
|
||||
(geometry instanceof ol.geom.LinearRing),
|
||||
@@ -2402,10 +2368,8 @@ ol.format.KML.writePrimitiveGeometry_ = function(node, geometry, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.KML.writePolygon_ = function(node, polygon, objectStack) {
|
||||
goog.asserts.assertInstanceof(polygon, ol.geom.Polygon,
|
||||
'polygon should be an ol.geom.Polygon');
|
||||
var linearRings = polygon.getLinearRings();
|
||||
goog.asserts.assert(linearRings.length > 0,
|
||||
ol.DEBUG && console.assert(linearRings.length > 0,
|
||||
'linearRings should not be empty');
|
||||
var outerRing = linearRings.shift();
|
||||
var /** @type {ol.XmlNodeStackItem} */ context = {node: node};
|
||||
@@ -2803,10 +2767,8 @@ ol.format.KML.GX_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) {
|
||||
*/
|
||||
ol.format.KML.DOCUMENT_NODE_FACTORY_ = function(value, objectStack,
|
||||
opt_nodeName) {
|
||||
goog.asserts.assertInstanceof(value, ol.Feature,
|
||||
'value should be an ol.Feature');
|
||||
var parentNode = objectStack[objectStack.length - 1].node;
|
||||
goog.asserts.assert(ol.xml.isNode(parentNode),
|
||||
ol.DEBUG && console.assert(ol.xml.isNode(parentNode),
|
||||
'parentNode should be an XML node');
|
||||
return ol.xml.createElementNS(parentNode.namespaceURI, 'Placemark');
|
||||
};
|
||||
@@ -2823,13 +2785,11 @@ ol.format.KML.DOCUMENT_NODE_FACTORY_ = function(value, objectStack,
|
||||
ol.format.KML.GEOMETRY_NODE_FACTORY_ = function(value, objectStack,
|
||||
opt_nodeName) {
|
||||
if (value) {
|
||||
goog.asserts.assertInstanceof(value, ol.geom.Geometry,
|
||||
'value should be an ol.geom.Geometry');
|
||||
var parentNode = objectStack[objectStack.length - 1].node;
|
||||
goog.asserts.assert(ol.xml.isNode(parentNode),
|
||||
ol.DEBUG && console.assert(ol.xml.isNode(parentNode),
|
||||
'parentNode should be an XML node');
|
||||
return ol.xml.createElementNS(parentNode.namespaceURI,
|
||||
ol.format.KML.GEOMETRY_TYPE_TO_NODENAME_[value.getType()]);
|
||||
ol.format.KML.GEOMETRY_TYPE_TO_NODENAME_[/** @type {ol.geom.Geometry} */ (value).getType()]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
goog.provide('ol.format.MVT');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.ext.pbf');
|
||||
goog.require('ol.ext.vectortile');
|
||||
@@ -102,7 +101,6 @@ ol.format.MVT.prototype.readFeature_ = function(
|
||||
ol.format.MVT.readGeometry_(rawFeature), false,
|
||||
this.adaptOptions(opt_options));
|
||||
if (geometry) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.Geometry);
|
||||
values[this.geometryName_] = geometry;
|
||||
}
|
||||
feature.setId(id);
|
||||
@@ -152,11 +150,9 @@ ol.format.MVT.prototype.readRenderFeature_ = function(rawFeature, layer) {
|
||||
* @api
|
||||
*/
|
||||
ol.format.MVT.prototype.readFeatures = function(source, opt_options) {
|
||||
goog.asserts.assertInstanceof(source, ArrayBuffer);
|
||||
|
||||
var layers = this.layers_;
|
||||
|
||||
var pbf = new ol.ext.pbf(source);
|
||||
var pbf = new ol.ext.pbf(/** @type {ArrayBuffer} */ (source));
|
||||
var tile = new ol.ext.vectortile.VectorTile(pbf);
|
||||
var features = [];
|
||||
var featureClass = this.featureClass_;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// FIXME add typedef for stack state objects
|
||||
goog.provide('ol.format.OSMXML');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.format.Feature');
|
||||
@@ -57,9 +56,9 @@ ol.format.OSMXML.prototype.getExtensions = function() {
|
||||
* @private
|
||||
*/
|
||||
ol.format.OSMXML.readNode_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'node', 'localName should be node');
|
||||
ol.DEBUG && console.assert(node.localName == 'node', 'localName should be node');
|
||||
var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
|
||||
var state = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||
var id = node.getAttribute('id');
|
||||
@@ -90,9 +89,9 @@ ol.format.OSMXML.readNode_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.OSMXML.readWay_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'way', 'localName should be way');
|
||||
ol.DEBUG && console.assert(node.localName == 'way', 'localName should be way');
|
||||
var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
|
||||
var id = node.getAttribute('id');
|
||||
var values = ol.xml.pushParseAndPop({
|
||||
@@ -130,9 +129,9 @@ ol.format.OSMXML.readWay_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.OSMXML.readNd_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'nd', 'localName should be nd');
|
||||
ol.DEBUG && console.assert(node.localName == 'nd', 'localName should be nd');
|
||||
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||
values.ndrefs.push(node.getAttribute('ref'));
|
||||
};
|
||||
@@ -144,9 +143,9 @@ ol.format.OSMXML.readNd_ = function(node, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.OSMXML.readTag_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'tag', 'localName should be tag');
|
||||
ol.DEBUG && console.assert(node.localName == 'tag', 'localName should be tag');
|
||||
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||
values.tags[node.getAttribute('k')] = node.getAttribute('v');
|
||||
};
|
||||
@@ -213,7 +212,7 @@ ol.format.OSMXML.prototype.readFeatures;
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.OSMXML.prototype.readFeaturesFromNode = function(node, opt_options) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
var options = this.getReadOptions(node, opt_options);
|
||||
if (node.localName == 'osm') {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.format.OWS');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.format.XLink');
|
||||
goog.require('ol.format.XML');
|
||||
goog.require('ol.format.XSD');
|
||||
@@ -22,7 +21,7 @@ ol.inherits(ol.format.OWS, ol.format.XML);
|
||||
* @return {Object} OWS object.
|
||||
*/
|
||||
ol.format.OWS.prototype.readFromDocument = function(doc) {
|
||||
goog.asserts.assert(doc.nodeType == Node.DOCUMENT_NODE,
|
||||
ol.DEBUG && console.assert(doc.nodeType == Node.DOCUMENT_NODE,
|
||||
'doc.nodeType should be DOCUMENT');
|
||||
for (var n = doc.firstChild; n; n = n.nextSibling) {
|
||||
if (n.nodeType == Node.ELEMENT_NODE) {
|
||||
@@ -38,7 +37,7 @@ ol.format.OWS.prototype.readFromDocument = function(doc) {
|
||||
* @return {Object} OWS object.
|
||||
*/
|
||||
ol.format.OWS.prototype.readFromNode = function(node) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
var owsObject = ol.xml.pushParseAndPop({},
|
||||
ol.format.OWS.PARSERS_, node, []);
|
||||
@@ -53,9 +52,9 @@ ol.format.OWS.prototype.readFromNode = function(node) {
|
||||
* @return {Object|undefined} The address.
|
||||
*/
|
||||
ol.format.OWS.readAddress_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Address',
|
||||
ol.DEBUG && console.assert(node.localName == 'Address',
|
||||
'localName should be Address');
|
||||
return ol.xml.pushParseAndPop({},
|
||||
ol.format.OWS.ADDRESS_PARSERS_, node, objectStack);
|
||||
@@ -69,9 +68,9 @@ ol.format.OWS.readAddress_ = function(node, objectStack) {
|
||||
* @return {Object|undefined} The values.
|
||||
*/
|
||||
ol.format.OWS.readAllowedValues_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'AllowedValues',
|
||||
ol.DEBUG && console.assert(node.localName == 'AllowedValues',
|
||||
'localName should be AllowedValues');
|
||||
return ol.xml.pushParseAndPop({},
|
||||
ol.format.OWS.ALLOWED_VALUES_PARSERS_, node, objectStack);
|
||||
@@ -85,9 +84,9 @@ ol.format.OWS.readAllowedValues_ = function(node, objectStack) {
|
||||
* @return {Object|undefined} The constraint.
|
||||
*/
|
||||
ol.format.OWS.readConstraint_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Constraint',
|
||||
ol.DEBUG && console.assert(node.localName == 'Constraint',
|
||||
'localName should be Constraint');
|
||||
var name = node.getAttribute('name');
|
||||
if (!name) {
|
||||
@@ -106,9 +105,9 @@ ol.format.OWS.readConstraint_ = function(node, objectStack) {
|
||||
* @return {Object|undefined} The contact info.
|
||||
*/
|
||||
ol.format.OWS.readContactInfo_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'ContactInfo',
|
||||
ol.DEBUG && console.assert(node.localName == 'ContactInfo',
|
||||
'localName should be ContactInfo');
|
||||
return ol.xml.pushParseAndPop({},
|
||||
ol.format.OWS.CONTACT_INFO_PARSERS_, node, objectStack);
|
||||
@@ -122,9 +121,9 @@ ol.format.OWS.readContactInfo_ = function(node, objectStack) {
|
||||
* @return {Object|undefined} The DCP.
|
||||
*/
|
||||
ol.format.OWS.readDcp_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'DCP', 'localName should be DCP');
|
||||
ol.DEBUG && console.assert(node.localName == 'DCP', 'localName should be DCP');
|
||||
return ol.xml.pushParseAndPop({},
|
||||
ol.format.OWS.DCP_PARSERS_, node, objectStack);
|
||||
};
|
||||
@@ -137,9 +136,9 @@ ol.format.OWS.readDcp_ = function(node, objectStack) {
|
||||
* @return {Object|undefined} The GET object.
|
||||
*/
|
||||
ol.format.OWS.readGet_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Get', 'localName should be Get');
|
||||
ol.DEBUG && console.assert(node.localName == 'Get', 'localName should be Get');
|
||||
var href = ol.format.XLink.readHref(node);
|
||||
if (!href) {
|
||||
return undefined;
|
||||
@@ -156,9 +155,9 @@ ol.format.OWS.readGet_ = function(node, objectStack) {
|
||||
* @return {Object|undefined} The HTTP object.
|
||||
*/
|
||||
ol.format.OWS.readHttp_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'HTTP', 'localName should be HTTP');
|
||||
ol.DEBUG && console.assert(node.localName == 'HTTP', 'localName should be HTTP');
|
||||
return ol.xml.pushParseAndPop({}, ol.format.OWS.HTTP_PARSERS_,
|
||||
node, objectStack);
|
||||
};
|
||||
@@ -171,9 +170,9 @@ ol.format.OWS.readHttp_ = function(node, objectStack) {
|
||||
* @return {Object|undefined} The operation.
|
||||
*/
|
||||
ol.format.OWS.readOperation_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Operation',
|
||||
ol.DEBUG && console.assert(node.localName == 'Operation',
|
||||
'localName should be Operation');
|
||||
var name = node.getAttribute('name');
|
||||
var value = ol.xml.pushParseAndPop({},
|
||||
@@ -183,7 +182,6 @@ ol.format.OWS.readOperation_ = function(node, objectStack) {
|
||||
}
|
||||
var object = /** @type {Object} */
|
||||
(objectStack[objectStack.length - 1]);
|
||||
goog.asserts.assert(goog.isObject(object), 'object should be an Object');
|
||||
object[name] = value;
|
||||
|
||||
};
|
||||
@@ -197,9 +195,9 @@ ol.format.OWS.readOperation_ = function(node, objectStack) {
|
||||
*/
|
||||
ol.format.OWS.readOperationsMetadata_ = function(node,
|
||||
objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'OperationsMetadata',
|
||||
ol.DEBUG && console.assert(node.localName == 'OperationsMetadata',
|
||||
'localName should be OperationsMetadata');
|
||||
return ol.xml.pushParseAndPop({},
|
||||
ol.format.OWS.OPERATIONS_METADATA_PARSERS_, node,
|
||||
@@ -214,9 +212,9 @@ ol.format.OWS.readOperationsMetadata_ = function(node,
|
||||
* @return {Object|undefined} The phone.
|
||||
*/
|
||||
ol.format.OWS.readPhone_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Phone', 'localName should be Phone');
|
||||
ol.DEBUG && console.assert(node.localName == 'Phone', 'localName should be Phone');
|
||||
return ol.xml.pushParseAndPop({},
|
||||
ol.format.OWS.PHONE_PARSERS_, node, objectStack);
|
||||
};
|
||||
@@ -230,9 +228,9 @@ ol.format.OWS.readPhone_ = function(node, objectStack) {
|
||||
*/
|
||||
ol.format.OWS.readServiceIdentification_ = function(node,
|
||||
objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'ServiceIdentification',
|
||||
ol.DEBUG && console.assert(node.localName == 'ServiceIdentification',
|
||||
'localName should be ServiceIdentification');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.OWS.SERVICE_IDENTIFICATION_PARSERS_, node,
|
||||
@@ -247,9 +245,9 @@ ol.format.OWS.readServiceIdentification_ = function(node,
|
||||
* @return {Object|undefined} The service contact.
|
||||
*/
|
||||
ol.format.OWS.readServiceContact_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'ServiceContact',
|
||||
ol.DEBUG && console.assert(node.localName == 'ServiceContact',
|
||||
'localName should be ServiceContact');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.OWS.SERVICE_CONTACT_PARSERS_, node,
|
||||
@@ -264,9 +262,9 @@ ol.format.OWS.readServiceContact_ = function(node, objectStack) {
|
||||
* @return {Object|undefined} The service provider.
|
||||
*/
|
||||
ol.format.OWS.readServiceProvider_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'ServiceProvider',
|
||||
ol.DEBUG && console.assert(node.localName == 'ServiceProvider',
|
||||
'localName should be ServiceProvider');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.OWS.SERVICE_PROVIDER_PARSERS_, node,
|
||||
@@ -281,9 +279,9 @@ ol.format.OWS.readServiceProvider_ = function(node, objectStack) {
|
||||
* @return {string|undefined} The value.
|
||||
*/
|
||||
ol.format.OWS.readValue_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Value', 'localName should be Value');
|
||||
ol.DEBUG && console.assert(node.localName == 'Value', 'localName should be Value');
|
||||
return ol.format.XSD.readString(node);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.format.Polyline');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.format.Feature');
|
||||
goog.require('ol.format.TextFeature');
|
||||
@@ -356,7 +355,7 @@ ol.format.Polyline.prototype.writeFeatureText = function(feature, opt_options) {
|
||||
if (geometry) {
|
||||
return this.writeGeometryText(geometry, opt_options);
|
||||
} else {
|
||||
goog.asserts.fail('geometry needs to be defined');
|
||||
ol.assert(false, 40); // Expected `feature` to have a geometry
|
||||
return '';
|
||||
}
|
||||
};
|
||||
@@ -366,7 +365,7 @@ ol.format.Polyline.prototype.writeFeatureText = function(feature, opt_options) {
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.Polyline.prototype.writeFeaturesText = function(features, opt_options) {
|
||||
goog.asserts.assert(features.length == 1,
|
||||
ol.DEBUG && console.assert(features.length == 1,
|
||||
'features array should have 1 item');
|
||||
return this.writeFeatureText(features[0], opt_options);
|
||||
};
|
||||
@@ -388,8 +387,6 @@ ol.format.Polyline.prototype.writeGeometry;
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.Polyline.prototype.writeGeometryText = function(geometry, opt_options) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.LineString,
|
||||
'geometry should be an ol.geom.LineString');
|
||||
geometry = /** @type {ol.geom.LineString} */
|
||||
(ol.format.Feature.transformWithOptions(
|
||||
geometry, true, this.adaptOptions(opt_options)));
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.format.TextFeature');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.format.Feature');
|
||||
goog.require('ol.format.FormatType');
|
||||
|
||||
@@ -29,7 +28,6 @@ ol.format.TextFeature.prototype.getText_ = function(source) {
|
||||
if (typeof source === 'string') {
|
||||
return source;
|
||||
} else {
|
||||
goog.asserts.fail();
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.format.TopoJSON');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.format.Feature');
|
||||
goog.require('ol.format.JSONFeature');
|
||||
@@ -250,7 +249,7 @@ ol.format.TopoJSON.readFeatureFromGeometry_ = function(object, arcs,
|
||||
var geometry;
|
||||
var type = object.type;
|
||||
var geometryReader = ol.format.TopoJSON.GEOMETRY_READERS_[type];
|
||||
goog.asserts.assert(geometryReader, 'geometryReader should be defined');
|
||||
ol.DEBUG && console.assert(geometryReader, 'geometryReader should be defined');
|
||||
if ((type === 'Point') || (type === 'MultiPoint')) {
|
||||
geometry = geometryReader(object, scale, translate);
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.format.WFS');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol');
|
||||
goog.require('ol.format.GML3');
|
||||
goog.require('ol.format.GMLBase');
|
||||
@@ -142,7 +141,6 @@ ol.format.WFS.prototype.readTransactionResponse = function(source) {
|
||||
var doc = ol.xml.parse(source);
|
||||
return this.readTransactionResponseFromDocument(doc);
|
||||
} else {
|
||||
goog.asserts.fail('Unknown source type');
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
@@ -167,7 +165,6 @@ ol.format.WFS.prototype.readFeatureCollectionMetadata = function(source) {
|
||||
var doc = ol.xml.parse(source);
|
||||
return this.readFeatureCollectionMetadataFromDocument(doc);
|
||||
} else {
|
||||
goog.asserts.fail('Unknown source type');
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
@@ -179,7 +176,7 @@ ol.format.WFS.prototype.readFeatureCollectionMetadata = function(source) {
|
||||
* FeatureCollection metadata.
|
||||
*/
|
||||
ol.format.WFS.prototype.readFeatureCollectionMetadataFromDocument = function(doc) {
|
||||
goog.asserts.assert(doc.nodeType == Node.DOCUMENT_NODE,
|
||||
ol.DEBUG && console.assert(doc.nodeType == Node.DOCUMENT_NODE,
|
||||
'doc.nodeType should be DOCUMENT');
|
||||
for (var n = doc.firstChild; n; n = n.nextSibling) {
|
||||
if (n.nodeType == Node.ELEMENT_NODE) {
|
||||
@@ -209,9 +206,9 @@ ol.format.WFS.FEATURE_COLLECTION_PARSERS_ = {
|
||||
* FeatureCollection metadata.
|
||||
*/
|
||||
ol.format.WFS.prototype.readFeatureCollectionMetadataFromNode = function(node) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'FeatureCollection',
|
||||
ol.DEBUG && console.assert(node.localName == 'FeatureCollection',
|
||||
'localName should be FeatureCollection');
|
||||
var result = {};
|
||||
var value = ol.format.XSD.readNonNegativeIntegerString(
|
||||
@@ -320,7 +317,7 @@ ol.format.WFS.TRANSACTION_RESPONSE_PARSERS_ = {
|
||||
* @return {ol.WFSTransactionResponse|undefined} Transaction response.
|
||||
*/
|
||||
ol.format.WFS.prototype.readTransactionResponseFromDocument = function(doc) {
|
||||
goog.asserts.assert(doc.nodeType == Node.DOCUMENT_NODE,
|
||||
ol.DEBUG && console.assert(doc.nodeType == Node.DOCUMENT_NODE,
|
||||
'doc.nodeType should be DOCUMENT');
|
||||
for (var n = doc.firstChild; n; n = n.nextSibling) {
|
||||
if (n.nodeType == Node.ELEMENT_NODE) {
|
||||
@@ -336,9 +333,9 @@ ol.format.WFS.prototype.readTransactionResponseFromDocument = function(doc) {
|
||||
* @return {ol.WFSTransactionResponse|undefined} Transaction response.
|
||||
*/
|
||||
ol.format.WFS.prototype.readTransactionResponseFromNode = function(node) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'TransactionResponse',
|
||||
ol.DEBUG && console.assert(node.localName == 'TransactionResponse',
|
||||
'localName should be TransactionResponse');
|
||||
return ol.xml.pushParseAndPop(
|
||||
/** @type {ol.WFSTransactionResponse} */({}),
|
||||
@@ -365,7 +362,6 @@ ol.format.WFS.QUERY_SERIALIZERS_ = {
|
||||
*/
|
||||
ol.format.WFS.writeFeature_ = function(node, feature, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var featureType = context['featureType'];
|
||||
var featureNS = context['featureNS'];
|
||||
var child = ol.xml.createElementNS(featureNS, featureType);
|
||||
@@ -397,8 +393,7 @@ ol.format.WFS.writeOgcFidFilter_ = function(node, fid, objectStack) {
|
||||
*/
|
||||
ol.format.WFS.writeDelete_ = function(node, feature, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
goog.asserts.assert(feature.getId() !== undefined, 'feature should have an id');
|
||||
ol.assert(feature.getId() !== undefined, 26); // Features must have an id set
|
||||
var featureType = context['featureType'];
|
||||
var featurePrefix = context['featurePrefix'];
|
||||
featurePrefix = featurePrefix ? featurePrefix :
|
||||
@@ -422,8 +417,7 @@ ol.format.WFS.writeDelete_ = function(node, feature, objectStack) {
|
||||
*/
|
||||
ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
goog.asserts.assert(feature.getId() !== undefined, 'feature should have an id');
|
||||
ol.assert(feature.getId() !== undefined, 27); // Features must have an id set
|
||||
var featureType = context['featureType'];
|
||||
var featurePrefix = context['featurePrefix'];
|
||||
featurePrefix = featurePrefix ? featurePrefix :
|
||||
@@ -517,8 +511,7 @@ ol.format.WFS.TRANSACTION_SERIALIZERS_ = {
|
||||
* @private
|
||||
*/
|
||||
ol.format.WFS.writeQuery_ = function(node, featureType, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||
var featurePrefix = context['featurePrefix'];
|
||||
var featureNS = context['featureNS'];
|
||||
var propertyNames = context['propertyNames'];
|
||||
@@ -565,16 +558,12 @@ ol.format.WFS.writeFilterCondition_ = function(node, filter, objectStack) {
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {ol.format.ogc.filter.Filter} filter Filter.
|
||||
* @param {ol.format.ogc.filter.Bbox} filter Filter.
|
||||
* @param {Array.<*>} objectStack Node stack.
|
||||
* @private
|
||||
*/
|
||||
ol.format.WFS.writeBboxFilter_ = function(node, filter, objectStack) {
|
||||
goog.asserts.assertInstanceof(filter, ol.format.ogc.filter.Bbox,
|
||||
'must be bbox filter');
|
||||
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
context['srsName'] = filter.srsName;
|
||||
|
||||
ol.format.WFS.writeOgcPropertyName_(node, filter.geometryName);
|
||||
@@ -584,7 +573,7 @@ ol.format.WFS.writeBboxFilter_ = function(node, filter, objectStack) {
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {ol.format.ogc.filter.Filter} filter Filter.
|
||||
* @param {ol.format.ogc.filter.LogicalBinary} filter Filter.
|
||||
* @param {Array.<*>} objectStack Node stack.
|
||||
* @private
|
||||
*/
|
||||
@@ -627,8 +616,6 @@ ol.format.WFS.writeWithinFilter_ = function(node, filter, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.WFS.writeLogicalFilter_ = function(node, filter, objectStack) {
|
||||
goog.asserts.assertInstanceof(filter, ol.format.ogc.filter.LogicalBinary,
|
||||
'must be logical filter');
|
||||
/** @type {ol.XmlNodeStackItem} */
|
||||
var item = {node: node};
|
||||
var conditionA = filter.conditionA;
|
||||
@@ -646,13 +633,11 @@ ol.format.WFS.writeLogicalFilter_ = function(node, filter, objectStack) {
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {ol.format.ogc.filter.Filter} filter Filter.
|
||||
* @param {ol.format.ogc.filter.Not} filter Filter.
|
||||
* @param {Array.<*>} objectStack Node stack.
|
||||
* @private
|
||||
*/
|
||||
ol.format.WFS.writeNotFilter_ = function(node, filter, objectStack) {
|
||||
goog.asserts.assertInstanceof(filter, ol.format.ogc.filter.Not,
|
||||
'must be Not filter');
|
||||
/** @type {ol.XmlNodeStackItem} */
|
||||
var item = {node: node};
|
||||
var condition = filter.condition;
|
||||
@@ -665,13 +650,11 @@ ol.format.WFS.writeNotFilter_ = function(node, filter, objectStack) {
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {ol.format.ogc.filter.Filter} filter Filter.
|
||||
* @param {ol.format.ogc.filter.ComparisonBinary} filter Filter.
|
||||
* @param {Array.<*>} objectStack Node stack.
|
||||
* @private
|
||||
*/
|
||||
ol.format.WFS.writeComparisonFilter_ = function(node, filter, objectStack) {
|
||||
goog.asserts.assertInstanceof(filter, ol.format.ogc.filter.ComparisonBinary,
|
||||
'must be binary comparison filter');
|
||||
if (filter.matchCase !== undefined) {
|
||||
node.setAttribute('matchCase', filter.matchCase.toString());
|
||||
}
|
||||
@@ -682,26 +665,22 @@ ol.format.WFS.writeComparisonFilter_ = function(node, filter, objectStack) {
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {ol.format.ogc.filter.Filter} filter Filter.
|
||||
* @param {ol.format.ogc.filter.IsNull} filter Filter.
|
||||
* @param {Array.<*>} objectStack Node stack.
|
||||
* @private
|
||||
*/
|
||||
ol.format.WFS.writeIsNullFilter_ = function(node, filter, objectStack) {
|
||||
goog.asserts.assertInstanceof(filter, ol.format.ogc.filter.IsNull,
|
||||
'must be IsNull comparison filter');
|
||||
ol.format.WFS.writeOgcPropertyName_(node, filter.propertyName);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {ol.format.ogc.filter.Filter} filter Filter.
|
||||
* @param {ol.format.ogc.filter.IsBetween} filter Filter.
|
||||
* @param {Array.<*>} objectStack Node stack.
|
||||
* @private
|
||||
*/
|
||||
ol.format.WFS.writeIsBetweenFilter_ = function(node, filter, objectStack) {
|
||||
goog.asserts.assertInstanceof(filter, ol.format.ogc.filter.IsBetween,
|
||||
'must be IsBetween comparison filter');
|
||||
ol.format.WFS.writeOgcPropertyName_(node, filter.propertyName);
|
||||
ol.format.WFS.writeOgcExpression_('LowerBoundary', node, '' + filter.lowerBoundary);
|
||||
ol.format.WFS.writeOgcExpression_('UpperBoundary', node, '' + filter.upperBoundary);
|
||||
@@ -710,13 +689,11 @@ ol.format.WFS.writeIsBetweenFilter_ = function(node, filter, objectStack) {
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {ol.format.ogc.filter.Filter} filter Filter.
|
||||
* @param {ol.format.ogc.filter.IsLike} filter Filter.
|
||||
* @param {Array.<*>} objectStack Node stack.
|
||||
* @private
|
||||
*/
|
||||
ol.format.WFS.writeIsLikeFilter_ = function(node, filter, objectStack) {
|
||||
goog.asserts.assertInstanceof(filter, ol.format.ogc.filter.IsLike,
|
||||
'must be IsLike comparison filter');
|
||||
node.setAttribute('wildCard', filter.wildCard);
|
||||
node.setAttribute('singleChar', filter.singleChar);
|
||||
node.setAttribute('escapeChar', filter.escapeChar);
|
||||
@@ -791,13 +768,12 @@ ol.format.WFS.GETFEATURE_SERIALIZERS_ = {
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<{string}>} featureTypes Feature types.
|
||||
* @param {Array.<string>} featureTypes Feature types.
|
||||
* @param {Array.<*>} objectStack Node stack.
|
||||
* @private
|
||||
*/
|
||||
ol.format.WFS.writeGetFeature_ = function(node, featureTypes, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||
var item = /** @type {ol.XmlNodeStackItem} */ (ol.object.assign({}, context));
|
||||
item.node = node;
|
||||
ol.xml.pushSerializeAndPop(item,
|
||||
@@ -841,10 +817,10 @@ ol.format.WFS.prototype.writeGetFeature = function(options) {
|
||||
}
|
||||
filter = options.filter;
|
||||
if (options.bbox) {
|
||||
goog.asserts.assert(options.geometryName,
|
||||
'geometryName must be set when using bbox filter');
|
||||
ol.assert(options.geometryName,
|
||||
12); // `options.geometryName` must also be provided when `options.bbox` is set
|
||||
var bbox = ol.format.ogc.filter.bbox(
|
||||
options.geometryName, options.bbox, options.srsName);
|
||||
/** @type {string} */ (options.geometryName), options.bbox, options.srsName);
|
||||
if (filter) {
|
||||
// if bbox and filter are both set, combine the two into a single filter
|
||||
filter = ol.format.ogc.filter.and(filter, bbox);
|
||||
@@ -865,9 +841,9 @@ ol.format.WFS.prototype.writeGetFeature = function(options) {
|
||||
'filter': filter,
|
||||
'propertyNames': options.propertyNames ? options.propertyNames : []
|
||||
};
|
||||
goog.asserts.assert(Array.isArray(options.featureTypes),
|
||||
'options.featureTypes should be an array');
|
||||
ol.format.WFS.writeGetFeature_(node, options.featureTypes, [context]);
|
||||
ol.assert(Array.isArray(options.featureTypes),
|
||||
11); // `options.featureTypes` should be an Array
|
||||
ol.format.WFS.writeGetFeature_(node, /** @type {!Array.<string>} */ (options.featureTypes), [context]);
|
||||
return node;
|
||||
};
|
||||
|
||||
@@ -955,7 +931,7 @@ ol.format.WFS.prototype.readProjection;
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.WFS.prototype.readProjectionFromDocument = function(doc) {
|
||||
goog.asserts.assert(doc.nodeType == Node.DOCUMENT_NODE,
|
||||
ol.DEBUG && console.assert(doc.nodeType == Node.DOCUMENT_NODE,
|
||||
'doc.nodeType should be a DOCUMENT');
|
||||
for (var n = doc.firstChild; n; n = n.nextSibling) {
|
||||
if (n.nodeType == Node.ELEMENT_NODE) {
|
||||
@@ -970,9 +946,9 @@ ol.format.WFS.prototype.readProjectionFromDocument = function(doc) {
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.WFS.prototype.readProjectionFromNode = function(node) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'FeatureCollection',
|
||||
ol.DEBUG && console.assert(node.localName == 'FeatureCollection',
|
||||
'localName should be FeatureCollection');
|
||||
|
||||
if (node.firstElementChild &&
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.format.WKT');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.format.Feature');
|
||||
@@ -167,7 +166,7 @@ ol.format.WKT.encodeMultiPolygonGeometry_ = function(geom) {
|
||||
ol.format.WKT.encode_ = function(geom) {
|
||||
var type = geom.getType();
|
||||
var geometryEncoder = ol.format.WKT.GeometryEncoder_[type];
|
||||
goog.asserts.assert(geometryEncoder, 'geometryEncoder should be defined');
|
||||
ol.DEBUG && console.assert(geometryEncoder, 'geometryEncoder should be defined');
|
||||
var enc = geometryEncoder(geom);
|
||||
type = type.toUpperCase();
|
||||
if (enc.length === 0) {
|
||||
@@ -574,7 +573,7 @@ ol.format.WKT.Parser.prototype.match = function(type) {
|
||||
ol.format.WKT.Parser.prototype.parse = function() {
|
||||
this.consume_();
|
||||
var geometry = this.parseGeometry_();
|
||||
goog.asserts.assert(this.token_.type == ol.format.WKT.TokenType.EOF,
|
||||
ol.DEBUG && console.assert(this.token_.type == ol.format.WKT.TokenType.EOF,
|
||||
'token type should be end of file');
|
||||
return geometry;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.format.WMSCapabilities');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol');
|
||||
goog.require('ol.format.XLink');
|
||||
goog.require('ol.format.XML');
|
||||
@@ -44,7 +43,7 @@ ol.format.WMSCapabilities.prototype.read;
|
||||
* @return {Object} WMS Capability object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.prototype.readFromDocument = function(doc) {
|
||||
goog.asserts.assert(doc.nodeType == Node.DOCUMENT_NODE,
|
||||
ol.DEBUG && console.assert(doc.nodeType == Node.DOCUMENT_NODE,
|
||||
'doc.nodeType should be DOCUMENT');
|
||||
for (var n = doc.firstChild; n; n = n.nextSibling) {
|
||||
if (n.nodeType == Node.ELEMENT_NODE) {
|
||||
@@ -60,13 +59,12 @@ ol.format.WMSCapabilities.prototype.readFromDocument = function(doc) {
|
||||
* @return {Object} WMS Capability object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.prototype.readFromNode = function(node) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'WMS_Capabilities' ||
|
||||
ol.DEBUG && console.assert(node.localName == 'WMS_Capabilities' ||
|
||||
node.localName == 'WMT_MS_Capabilities',
|
||||
'localName should be WMS_Capabilities or WMT_MS_Capabilities');
|
||||
this.version = node.getAttribute('version').trim();
|
||||
goog.asserts.assertString(this.version, 'this.version should be a string');
|
||||
var wmsCapabilityObject = ol.xml.pushParseAndPop({
|
||||
'version': this.version
|
||||
}, ol.format.WMSCapabilities.PARSERS_, node, []);
|
||||
@@ -81,9 +79,9 @@ ol.format.WMSCapabilities.prototype.readFromNode = function(node) {
|
||||
* @return {Object|undefined} Attribution object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readAttribution_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Attribution',
|
||||
ol.DEBUG && console.assert(node.localName == 'Attribution',
|
||||
'localName should be Attribution');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.ATTRIBUTION_PARSERS_, node, objectStack);
|
||||
@@ -97,9 +95,9 @@ ol.format.WMSCapabilities.readAttribution_ = function(node, objectStack) {
|
||||
* @return {Object} Bounding box object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readBoundingBox_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'BoundingBox',
|
||||
ol.DEBUG && console.assert(node.localName == 'BoundingBox',
|
||||
'localName should be BoundingBox');
|
||||
|
||||
var extent = [
|
||||
@@ -129,9 +127,9 @@ ol.format.WMSCapabilities.readBoundingBox_ = function(node, objectStack) {
|
||||
* @return {ol.Extent|undefined} Bounding box object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readEXGeographicBoundingBox_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'EX_GeographicBoundingBox',
|
||||
ol.DEBUG && console.assert(node.localName == 'EX_GeographicBoundingBox',
|
||||
'localName should be EX_GeographicBoundingBox');
|
||||
var geographicBoundingBox = ol.xml.pushParseAndPop(
|
||||
{},
|
||||
@@ -166,9 +164,9 @@ ol.format.WMSCapabilities.readEXGeographicBoundingBox_ = function(node, objectSt
|
||||
* @return {Object|undefined} Capability object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readCapability_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Capability',
|
||||
ol.DEBUG && console.assert(node.localName == 'Capability',
|
||||
'localName should be Capability');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.CAPABILITY_PARSERS_, node, objectStack);
|
||||
@@ -182,9 +180,9 @@ ol.format.WMSCapabilities.readCapability_ = function(node, objectStack) {
|
||||
* @return {Object|undefined} Service object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readService_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Service',
|
||||
ol.DEBUG && console.assert(node.localName == 'Service',
|
||||
'localName should be Service');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.SERVICE_PARSERS_, node, objectStack);
|
||||
@@ -198,9 +196,9 @@ ol.format.WMSCapabilities.readService_ = function(node, objectStack) {
|
||||
* @return {Object|undefined} Contact information object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readContactInformation_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType shpuld be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'ContactInformation',
|
||||
ol.DEBUG && console.assert(node.localName == 'ContactInformation',
|
||||
'localName should be ContactInformation');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.CONTACT_INFORMATION_PARSERS_,
|
||||
@@ -215,9 +213,9 @@ ol.format.WMSCapabilities.readContactInformation_ = function(node, objectStack)
|
||||
* @return {Object|undefined} Contact person object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readContactPersonPrimary_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'ContactPersonPrimary',
|
||||
ol.DEBUG && console.assert(node.localName == 'ContactPersonPrimary',
|
||||
'localName should be ContactPersonPrimary');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.CONTACT_PERSON_PARSERS_,
|
||||
@@ -232,9 +230,9 @@ ol.format.WMSCapabilities.readContactPersonPrimary_ = function(node, objectStack
|
||||
* @return {Object|undefined} Contact address object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readContactAddress_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'ContactAddress',
|
||||
ol.DEBUG && console.assert(node.localName == 'ContactAddress',
|
||||
'localName should be ContactAddress');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.CONTACT_ADDRESS_PARSERS_,
|
||||
@@ -249,9 +247,9 @@ ol.format.WMSCapabilities.readContactAddress_ = function(node, objectStack) {
|
||||
* @return {Array.<string>|undefined} Format array.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readException_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Exception',
|
||||
ol.DEBUG && console.assert(node.localName == 'Exception',
|
||||
'localName should be Exception');
|
||||
return ol.xml.pushParseAndPop(
|
||||
[], ol.format.WMSCapabilities.EXCEPTION_PARSERS_, node, objectStack);
|
||||
@@ -265,9 +263,9 @@ ol.format.WMSCapabilities.readException_ = function(node, objectStack) {
|
||||
* @return {Object|undefined} Layer object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readCapabilityLayer_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Layer', 'localName should be Layer');
|
||||
ol.DEBUG && console.assert(node.localName == 'Layer', 'localName should be Layer');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.LAYER_PARSERS_, node, objectStack);
|
||||
};
|
||||
@@ -280,9 +278,9 @@ ol.format.WMSCapabilities.readCapabilityLayer_ = function(node, objectStack) {
|
||||
* @return {Object|undefined} Layer object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Layer', 'localName should be Layer');
|
||||
ol.DEBUG && console.assert(node.localName == 'Layer', 'localName should be Layer');
|
||||
var parentLayerObject = /** @type {Object.<string,*>} */
|
||||
(objectStack[objectStack.length - 1]);
|
||||
|
||||
@@ -362,9 +360,9 @@ ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) {
|
||||
* @return {Object} Dimension object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readDimension_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Dimension',
|
||||
ol.DEBUG && console.assert(node.localName == 'Dimension',
|
||||
'localName should be Dimension');
|
||||
var dimensionObject = {
|
||||
'name': node.getAttribute('name'),
|
||||
@@ -389,7 +387,7 @@ ol.format.WMSCapabilities.readDimension_ = function(node, objectStack) {
|
||||
* @return {Object|undefined} Online resource object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readFormatOnlineresource_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.FORMAT_ONLINERESOURCE_PARSERS_,
|
||||
@@ -404,9 +402,9 @@ ol.format.WMSCapabilities.readFormatOnlineresource_ = function(node, objectStack
|
||||
* @return {Object|undefined} Request object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readRequest_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Request',
|
||||
ol.DEBUG && console.assert(node.localName == 'Request',
|
||||
'localName should be Request');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.REQUEST_PARSERS_, node, objectStack);
|
||||
@@ -420,9 +418,9 @@ ol.format.WMSCapabilities.readRequest_ = function(node, objectStack) {
|
||||
* @return {Object|undefined} DCP type object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readDCPType_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'DCPType',
|
||||
ol.DEBUG && console.assert(node.localName == 'DCPType',
|
||||
'localName should be DCPType');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.DCPTYPE_PARSERS_, node, objectStack);
|
||||
@@ -436,9 +434,9 @@ ol.format.WMSCapabilities.readDCPType_ = function(node, objectStack) {
|
||||
* @return {Object|undefined} HTTP object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readHTTP_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'HTTP', 'localName should be HTTP');
|
||||
ol.DEBUG && console.assert(node.localName == 'HTTP', 'localName should be HTTP');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.HTTP_PARSERS_, node, objectStack);
|
||||
};
|
||||
@@ -451,7 +449,7 @@ ol.format.WMSCapabilities.readHTTP_ = function(node, objectStack) {
|
||||
* @return {Object|undefined} Operation type object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readOperationType_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.OPERATIONTYPE_PARSERS_, node, objectStack);
|
||||
@@ -465,7 +463,7 @@ ol.format.WMSCapabilities.readOperationType_ = function(node, objectStack) {
|
||||
* @return {Object|undefined} Online resource object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readSizedFormatOnlineresource_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
var formatOnlineresource =
|
||||
ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack);
|
||||
@@ -488,9 +486,9 @@ ol.format.WMSCapabilities.readSizedFormatOnlineresource_ = function(node, object
|
||||
* @return {Object|undefined} Authority URL object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readAuthorityURL_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'AuthorityURL',
|
||||
ol.DEBUG && console.assert(node.localName == 'AuthorityURL',
|
||||
'localName should be AuthorityURL');
|
||||
var authorityObject =
|
||||
ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack);
|
||||
@@ -509,9 +507,9 @@ ol.format.WMSCapabilities.readAuthorityURL_ = function(node, objectStack) {
|
||||
* @return {Object|undefined} Metadata URL object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readMetadataURL_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'MetadataURL',
|
||||
ol.DEBUG && console.assert(node.localName == 'MetadataURL',
|
||||
'localName should be MetadataURL');
|
||||
var metadataObject =
|
||||
ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack);
|
||||
@@ -530,9 +528,9 @@ ol.format.WMSCapabilities.readMetadataURL_ = function(node, objectStack) {
|
||||
* @return {Object|undefined} Style object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readStyle_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Style', 'localName should be Style');
|
||||
ol.DEBUG && console.assert(node.localName == 'Style', 'localName should be Style');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.STYLE_PARSERS_, node, objectStack);
|
||||
};
|
||||
@@ -545,9 +543,9 @@ ol.format.WMSCapabilities.readStyle_ = function(node, objectStack) {
|
||||
* @return {Array.<string>|undefined} Keyword list.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readKeywordList_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'KeywordList',
|
||||
ol.DEBUG && console.assert(node.localName == 'KeywordList',
|
||||
'localName should be KeywordList');
|
||||
return ol.xml.pushParseAndPop(
|
||||
[], ol.format.WMSCapabilities.KEYWORDLIST_PARSERS_, node, objectStack);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.format.WMSGetFeatureInfo');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.format.GML2');
|
||||
goog.require('ol.format.XMLFeature');
|
||||
@@ -72,7 +71,7 @@ ol.format.WMSGetFeatureInfo.layerIdentifier_ = '_layer';
|
||||
ol.format.WMSGetFeatureInfo.prototype.readFeatures_ = function(node, objectStack) {
|
||||
|
||||
node.setAttribute('namespaceURI', this.featureNS_);
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
var localName = node.localName;
|
||||
/** @type {Array.<ol.Feature>} */
|
||||
@@ -87,10 +86,8 @@ ol.format.WMSGetFeatureInfo.prototype.readFeatures_ = function(node, objectStack
|
||||
continue;
|
||||
}
|
||||
var context = objectStack[0];
|
||||
goog.asserts.assert(goog.isObject(context),
|
||||
'context should be an Object');
|
||||
|
||||
goog.asserts.assert(layer.localName.indexOf(
|
||||
ol.DEBUG && console.assert(layer.localName.indexOf(
|
||||
ol.format.WMSGetFeatureInfo.layerIdentifier_) >= 0,
|
||||
'localName of layer node should match layerIdentifier');
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.format.WMTSCapabilities');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.format.OWS');
|
||||
goog.require('ol.format.XLink');
|
||||
@@ -45,7 +44,7 @@ ol.format.WMTSCapabilities.prototype.read;
|
||||
* @return {Object} WMTS Capability object.
|
||||
*/
|
||||
ol.format.WMTSCapabilities.prototype.readFromDocument = function(doc) {
|
||||
goog.asserts.assert(doc.nodeType == Node.DOCUMENT_NODE,
|
||||
ol.DEBUG && console.assert(doc.nodeType == Node.DOCUMENT_NODE,
|
||||
'doc.nodeType should be DOCUMENT');
|
||||
for (var n = doc.firstChild; n; n = n.nextSibling) {
|
||||
if (n.nodeType == Node.ELEMENT_NODE) {
|
||||
@@ -61,12 +60,11 @@ ol.format.WMTSCapabilities.prototype.readFromDocument = function(doc) {
|
||||
* @return {Object} WMTS Capability object.
|
||||
*/
|
||||
ol.format.WMTSCapabilities.prototype.readFromNode = function(node) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Capabilities',
|
||||
ol.DEBUG && console.assert(node.localName == 'Capabilities',
|
||||
'localName should be Capabilities');
|
||||
var version = node.getAttribute('version').trim();
|
||||
goog.asserts.assertString(version, 'version should be a string');
|
||||
var WMTSCapabilityObject = this.owsParser_.readFromNode(node);
|
||||
if (!WMTSCapabilityObject) {
|
||||
return null;
|
||||
@@ -85,9 +83,9 @@ ol.format.WMTSCapabilities.prototype.readFromNode = function(node) {
|
||||
* @return {Object|undefined} Attribution object.
|
||||
*/
|
||||
ol.format.WMTSCapabilities.readContents_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Contents',
|
||||
ol.DEBUG && console.assert(node.localName == 'Contents',
|
||||
'localName should be Contents');
|
||||
|
||||
return ol.xml.pushParseAndPop({},
|
||||
@@ -102,9 +100,9 @@ ol.format.WMTSCapabilities.readContents_ = function(node, objectStack) {
|
||||
* @return {Object|undefined} Layers object.
|
||||
*/
|
||||
ol.format.WMTSCapabilities.readLayer_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
goog.asserts.assert(node.localName == 'Layer', 'localName should be Layer');
|
||||
ol.DEBUG && console.assert(node.localName == 'Layer', 'localName should be Layer');
|
||||
return ol.xml.pushParseAndPop({},
|
||||
ol.format.WMTSCapabilities.LAYER_PARSERS_, node, objectStack);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.format.XMLFeature');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.format.Feature');
|
||||
goog.require('ol.format.FormatType');
|
||||
@@ -51,7 +50,6 @@ ol.format.XMLFeature.prototype.readFeature = function(source, opt_options) {
|
||||
var doc = ol.xml.parse(source);
|
||||
return this.readFeatureFromDocument(doc, opt_options);
|
||||
} else {
|
||||
goog.asserts.fail('Unknown source type');
|
||||
return null;
|
||||
}
|
||||
};
|
||||
@@ -95,7 +93,6 @@ ol.format.XMLFeature.prototype.readFeatures = function(source, opt_options) {
|
||||
var doc = ol.xml.parse(source);
|
||||
return this.readFeaturesFromDocument(doc, opt_options);
|
||||
} else {
|
||||
goog.asserts.fail('Unknown source type');
|
||||
return [];
|
||||
}
|
||||
};
|
||||
@@ -144,7 +141,6 @@ ol.format.XMLFeature.prototype.readGeometry = function(source, opt_options) {
|
||||
var doc = ol.xml.parse(source);
|
||||
return this.readGeometryFromDocument(doc, opt_options);
|
||||
} else {
|
||||
goog.asserts.fail('Unknown source type');
|
||||
return null;
|
||||
}
|
||||
};
|
||||
@@ -182,7 +178,6 @@ ol.format.XMLFeature.prototype.readProjection = function(source) {
|
||||
var doc = ol.xml.parse(source);
|
||||
return this.readProjectionFromDocument(doc);
|
||||
} else {
|
||||
goog.asserts.fail('Unknown source type');
|
||||
return null;
|
||||
}
|
||||
};
|
||||
@@ -213,7 +208,7 @@ ol.format.XMLFeature.prototype.readProjectionFromNode = function(node) {
|
||||
*/
|
||||
ol.format.XMLFeature.prototype.writeFeature = function(feature, opt_options) {
|
||||
var node = this.writeFeatureNode(feature, opt_options);
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
return this.xmlSerializer_.serializeToString(node);
|
||||
};
|
||||
@@ -234,7 +229,7 @@ ol.format.XMLFeature.prototype.writeFeatureNode = function(feature, opt_options)
|
||||
*/
|
||||
ol.format.XMLFeature.prototype.writeFeatures = function(features, opt_options) {
|
||||
var node = this.writeFeaturesNode(features, opt_options);
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
return this.xmlSerializer_.serializeToString(node);
|
||||
};
|
||||
@@ -254,7 +249,7 @@ ol.format.XMLFeature.prototype.writeFeaturesNode = function(features, opt_option
|
||||
*/
|
||||
ol.format.XMLFeature.prototype.writeGeometry = function(geometry, opt_options) {
|
||||
var node = this.writeGeometryNode(geometry, opt_options);
|
||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||
'node.nodeType should be ELEMENT');
|
||||
return this.xmlSerializer_.serializeToString(node);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.format.XML');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.xml');
|
||||
|
||||
|
||||
@@ -28,7 +27,6 @@ ol.format.XML.prototype.read = function(source) {
|
||||
var doc = ol.xml.parse(source);
|
||||
return this.readFromDocument(doc);
|
||||
} else {
|
||||
goog.asserts.fail();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.format.XSD');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol');
|
||||
goog.require('ol.xml');
|
||||
goog.require('ol.string');
|
||||
@@ -146,8 +145,8 @@ ol.format.XSD.writeDecimalTextNode = function(node, decimal) {
|
||||
* @param {number} nonNegativeInteger Non negative integer.
|
||||
*/
|
||||
ol.format.XSD.writeNonNegativeIntegerTextNode = function(node, nonNegativeInteger) {
|
||||
goog.asserts.assert(nonNegativeInteger >= 0, 'value should be more than 0');
|
||||
goog.asserts.assert(nonNegativeInteger == (nonNegativeInteger | 0),
|
||||
ol.DEBUG && console.assert(nonNegativeInteger >= 0, 'value should be more than 0');
|
||||
ol.DEBUG && console.assert(nonNegativeInteger == (nonNegativeInteger | 0),
|
||||
'value should be an integer value');
|
||||
var string = nonNegativeInteger.toString();
|
||||
node.appendChild(ol.xml.DOCUMENT.createTextNode(string));
|
||||
|
||||
Reference in New Issue
Block a user