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:
6
.eslintrc
Normal file
6
.eslintrc
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"extend": "openlayers",
|
||||||
|
"rules": {
|
||||||
|
"no-console": [2, {"allow": ["assert"]}]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
## Upgrade notes
|
## Upgrade notes
|
||||||
|
|
||||||
|
#### Changes in the way assertions are handled
|
||||||
|
|
||||||
|
Previously, minified builds of the library did not have any assertions. This caused applications to fail silently or with cryptic stack traces. Starting with this release, developers get notified of many runtime errors through the new `ol.AssertionError`. This error has a `code` property. The meaning of the code can be found on http://openlayers.org/en/latest/doc/errors.html. There are additional console assertion checks when in debug mode when the new `ol.DEBUG` compiler flag (previously `goog.DEBUG`) is `true`. As this is `true` by default, it is recommended that those creating custom builds set this to `false` so these assertions are stripped.'
|
||||||
|
|
||||||
#### Removal of `ol.ENABLE_NAMED_COLORS`
|
#### Removal of `ol.ENABLE_NAMED_COLORS`
|
||||||
|
|
||||||
This option was previously needed to use named colors with the WebGL renderer but is no longer needed.
|
This option was previously needed to use named colors with the WebGL renderer but is no longer needed.
|
||||||
|
|||||||
@@ -15,7 +15,8 @@
|
|||||||
"externs/topojson.js"
|
"externs/topojson.js"
|
||||||
],
|
],
|
||||||
"define": [
|
"define": [
|
||||||
"goog.DEBUG=false"
|
"goog.DEBUG=false",
|
||||||
|
"ol.DEBUG=false"
|
||||||
],
|
],
|
||||||
"jscomp_error": [
|
"jscomp_error": [
|
||||||
"*"
|
"*"
|
||||||
|
|||||||
222
doc/errors.md
Normal file
222
doc/errors.md
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
---
|
||||||
|
title: Errors
|
||||||
|
layout: doc.hbs
|
||||||
|
---
|
||||||
|
|
||||||
|
# Errors
|
||||||
|
|
||||||
|
### 1
|
||||||
|
|
||||||
|
The view center is not defined.
|
||||||
|
|
||||||
|
### 2
|
||||||
|
|
||||||
|
The view resolution is not defined.
|
||||||
|
|
||||||
|
### 3
|
||||||
|
|
||||||
|
The view rotation is not defined.
|
||||||
|
|
||||||
|
### 4
|
||||||
|
|
||||||
|
`image` and `src` cannot be provided at the same time.
|
||||||
|
|
||||||
|
### 5
|
||||||
|
|
||||||
|
`imgSize` must be set when `image` is provided.
|
||||||
|
|
||||||
|
### 6
|
||||||
|
|
||||||
|
A defined and non-empty `src` or `image` must be provided.
|
||||||
|
|
||||||
|
### 7
|
||||||
|
|
||||||
|
`format` must be set when `url` is set.
|
||||||
|
|
||||||
|
### 8
|
||||||
|
|
||||||
|
Unknown `serverType` configured.
|
||||||
|
|
||||||
|
### 9
|
||||||
|
|
||||||
|
`url` must be configured or set using `#setUrl()`.
|
||||||
|
|
||||||
|
### 10
|
||||||
|
|
||||||
|
The default `geometryFunction` can only handle `ol.geom.Point` geometries.
|
||||||
|
|
||||||
|
### 11
|
||||||
|
|
||||||
|
`options.featureTypes` should be an Array.
|
||||||
|
|
||||||
|
### 12
|
||||||
|
|
||||||
|
`options.geometryName` must also be provided when `options.bbox` is set.
|
||||||
|
|
||||||
|
### 13
|
||||||
|
|
||||||
|
Invalid corner. Valid corners are `top-left`, `top-right`, `bottom-right` and `bottom-left`.
|
||||||
|
|
||||||
|
### 14
|
||||||
|
|
||||||
|
Invalid color. Valid colors are all [CSS colors](https://developer.mozilla.org/en-US/docs/Web/CSS/color).
|
||||||
|
|
||||||
|
### 15
|
||||||
|
|
||||||
|
Tried to get a value for a key that does not exist in the cache.
|
||||||
|
|
||||||
|
### 16
|
||||||
|
|
||||||
|
Tried to set a value for a key that is used already.
|
||||||
|
|
||||||
|
### 17
|
||||||
|
|
||||||
|
`resolutions` must be sorted in descending order.
|
||||||
|
|
||||||
|
### 18
|
||||||
|
|
||||||
|
Either `origin` or `origins` must be configured, never both.
|
||||||
|
|
||||||
|
### 19
|
||||||
|
|
||||||
|
Number of `tileSizes` and `resolutions` must be equal.
|
||||||
|
|
||||||
|
### 20
|
||||||
|
|
||||||
|
Number of `origins` and `resolutions` must be equal.
|
||||||
|
|
||||||
|
### 21
|
||||||
|
|
||||||
|
Tile range for `extent` must not exceed tilegrid width and height.
|
||||||
|
|
||||||
|
### 22
|
||||||
|
|
||||||
|
Either `tileSize` or `tileSizes` must be configured, never both.
|
||||||
|
|
||||||
|
### 23
|
||||||
|
|
||||||
|
The passed `ol.TileCoord`s must all have the same `z` value.
|
||||||
|
|
||||||
|
### 24
|
||||||
|
|
||||||
|
Invalid extent or geometry provided as `geometry`.
|
||||||
|
|
||||||
|
### 25
|
||||||
|
|
||||||
|
Cannot fit empty extent provided as `geometry`.
|
||||||
|
|
||||||
|
### 26
|
||||||
|
|
||||||
|
Features for `deletes` must have an id set by the feature reader or `ol.Feature#setId()`.
|
||||||
|
|
||||||
|
### 27
|
||||||
|
|
||||||
|
Features for `updates` must have an id set by the feature reader or `ol.Feature#setId()`.
|
||||||
|
|
||||||
|
### 28
|
||||||
|
|
||||||
|
`renderMode` must be `'image'`, `'hybrid'` or `'vector'`.
|
||||||
|
|
||||||
|
### 29
|
||||||
|
|
||||||
|
`x` must be greater than `0`.
|
||||||
|
|
||||||
|
### 30
|
||||||
|
|
||||||
|
The passed `feature` was already added to the source.
|
||||||
|
|
||||||
|
### 31
|
||||||
|
|
||||||
|
Tried to enqueue an `element` that was already added to the queue.
|
||||||
|
|
||||||
|
### 32
|
||||||
|
|
||||||
|
Transformation matrix cannot be inverted.
|
||||||
|
|
||||||
|
### 33
|
||||||
|
|
||||||
|
Invalid `units`. `'degrees'`, `'imperial'`, `'nautical'`, `'metric'` or `'us'` required.
|
||||||
|
|
||||||
|
### 34
|
||||||
|
|
||||||
|
Invalid geometry layout. Must be `XY`, `XYZ`, `XYM` or `XYZM`.
|
||||||
|
|
||||||
|
### 35
|
||||||
|
|
||||||
|
Unknown GeoJSON object type. Expected `"Feature"` or `"FeatureCollection"`.
|
||||||
|
|
||||||
|
### 36
|
||||||
|
|
||||||
|
Unknown SRS type. Expected `"name"` or `"EPSG"`.
|
||||||
|
|
||||||
|
### 37
|
||||||
|
|
||||||
|
Unknown geometry type found. Expected `'Point'`, `'LineString'`, `'Polygon'` or `'GeometryCollection'`.
|
||||||
|
|
||||||
|
### 38
|
||||||
|
|
||||||
|
`styleMapValue` has an unknown type.
|
||||||
|
|
||||||
|
### 39
|
||||||
|
|
||||||
|
Unknown geometry type found. Expected `'GeometryCollection'`, `'MultiPoint'`, `'MultiLineString'` or `'MultiPolygon'`.
|
||||||
|
|
||||||
|
### 40
|
||||||
|
|
||||||
|
Expected `feature` to have a geometry.
|
||||||
|
|
||||||
|
### 41
|
||||||
|
|
||||||
|
Expected an `ol.style.Style` or an array of `ol.style.Style`.
|
||||||
|
|
||||||
|
### 42
|
||||||
|
|
||||||
|
Expected an `ol.Feature`, but got an `ol.RenderFeature`.
|
||||||
|
|
||||||
|
### 43
|
||||||
|
|
||||||
|
Expected `layers` to be an array or an `ol.Collection`.
|
||||||
|
|
||||||
|
### 44
|
||||||
|
|
||||||
|
`logo.href` should be a string.
|
||||||
|
|
||||||
|
### 45
|
||||||
|
|
||||||
|
`logo.src` should be a string.
|
||||||
|
|
||||||
|
### 46
|
||||||
|
|
||||||
|
Incorrect format for `renderer` option.
|
||||||
|
|
||||||
|
### 47
|
||||||
|
|
||||||
|
Expected `controls` to be an array or an `ol.Collection`.
|
||||||
|
|
||||||
|
### 48
|
||||||
|
|
||||||
|
Expected `interactions` to be an array or an `ol.Collection`.
|
||||||
|
|
||||||
|
### 49
|
||||||
|
|
||||||
|
Expected `overlays` to be an array or an `ol.Collection`.
|
||||||
|
|
||||||
|
### 50
|
||||||
|
|
||||||
|
Cannot determine Rest Service from url.
|
||||||
|
|
||||||
|
### 51
|
||||||
|
|
||||||
|
Either `url` or `tileJSON` options must be provided.
|
||||||
|
|
||||||
|
### 52
|
||||||
|
|
||||||
|
Unknown `serverType` configured.
|
||||||
|
|
||||||
|
### 53
|
||||||
|
|
||||||
|
Unknown `tierSizeCalculation` configured.
|
||||||
|
|
||||||
|
### 54
|
||||||
|
|
||||||
|
Hex color should have 3 or 6 digits.
|
||||||
@@ -9,6 +9,18 @@
|
|||||||
var oli;
|
var oli;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @interface
|
||||||
|
*/
|
||||||
|
oli.AssertionError = function() {};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
oli.AssertionError.prototype.code;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interface
|
* @interface
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
goog.provide('ol.array');
|
goog.provide('ol.array');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a binary search on the provided sorted list and returns the index of the item if found. If it can't be found it'll return -1.
|
* Performs a binary search on the provided sorted list and returns the index of the item if found. If it can't be found it'll return -1.
|
||||||
@@ -135,9 +133,6 @@ ol.array.linearFindNearest = function(arr, target, direction) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// We should never get here, but the compiler complains
|
|
||||||
// if it finds a path for which no number is returned.
|
|
||||||
goog.asserts.fail();
|
|
||||||
return n - 1;
|
return n - 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -149,9 +144,9 @@ ol.array.linearFindNearest = function(arr, target, direction) {
|
|||||||
* @param {number} end End index.
|
* @param {number} end End index.
|
||||||
*/
|
*/
|
||||||
ol.array.reverseSubArray = function(arr, begin, end) {
|
ol.array.reverseSubArray = function(arr, begin, end) {
|
||||||
goog.asserts.assert(begin >= 0,
|
ol.DEBUG && console.assert(begin >= 0,
|
||||||
'Array begin index should be equal to or greater than 0');
|
'Array begin index should be equal to or greater than 0');
|
||||||
goog.asserts.assert(end < arr.length,
|
ol.DEBUG && console.assert(end < arr.length,
|
||||||
'Array end index should be less than the array length');
|
'Array end index should be less than the array length');
|
||||||
while (begin < end) {
|
while (begin < end) {
|
||||||
var tmp = arr[begin];
|
var tmp = arr[begin];
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.color');
|
goog.provide('ol.color');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.math');
|
goog.require('ol.math');
|
||||||
|
|
||||||
@@ -55,8 +54,7 @@ ol.color.asArray = function(color) {
|
|||||||
if (Array.isArray(color)) {
|
if (Array.isArray(color)) {
|
||||||
return color;
|
return color;
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assert(typeof color === 'string', 'Color should be a string');
|
return ol.color.fromString(/** @type {string} */ (color));
|
||||||
return ol.color.fromString(color);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -71,7 +69,6 @@ ol.color.asString = function(color) {
|
|||||||
if (typeof color === 'string') {
|
if (typeof color === 'string') {
|
||||||
return color;
|
return color;
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assert(Array.isArray(color), 'Color should be an array');
|
|
||||||
return ol.color.toString(color);
|
return ol.color.toString(color);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -162,8 +159,7 @@ ol.color.fromStringInternal_ = function(s) {
|
|||||||
|
|
||||||
if (ol.color.hexColorRe_.exec(s)) { // hex
|
if (ol.color.hexColorRe_.exec(s)) { // hex
|
||||||
var n = s.length - 1; // number of hex digits
|
var n = s.length - 1; // number of hex digits
|
||||||
goog.asserts.assert(n == 3 || n == 6,
|
ol.assert(n == 3 || n == 6, 54); // Hex color should have 3 or 6 digits
|
||||||
'Color string length should be 3 or 6');
|
|
||||||
var d = n == 3 ? 1 : 2; // number of digits per channel
|
var d = n == 3 ? 1 : 2; // number of digits per channel
|
||||||
r = parseInt(s.substr(1 + 0 * d, d), 16);
|
r = parseInt(s.substr(1 + 0 * d, d), 16);
|
||||||
g = parseInt(s.substr(1 + 1 * d, d), 16);
|
g = parseInt(s.substr(1 + 1 * d, d), 16);
|
||||||
@@ -175,26 +171,21 @@ ol.color.fromStringInternal_ = function(s) {
|
|||||||
}
|
}
|
||||||
a = 1;
|
a = 1;
|
||||||
color = [r, g, b, a];
|
color = [r, g, b, a];
|
||||||
goog.asserts.assert(ol.color.isValid(color),
|
|
||||||
'Color should be a valid color');
|
|
||||||
return color;
|
|
||||||
} else if ((match = ol.color.rgbaColorRe_.exec(s))) { // rgba()
|
} else if ((match = ol.color.rgbaColorRe_.exec(s))) { // rgba()
|
||||||
r = Number(match[1]);
|
r = Number(match[1]);
|
||||||
g = Number(match[2]);
|
g = Number(match[2]);
|
||||||
b = Number(match[3]);
|
b = Number(match[3]);
|
||||||
a = Number(match[4]);
|
a = Number(match[4]);
|
||||||
color = [r, g, b, a];
|
color = ol.color.normalize([r, g, b, a]);
|
||||||
return ol.color.normalize(color, color);
|
|
||||||
} else if ((match = ol.color.rgbColorRe_.exec(s))) { // rgb()
|
} else if ((match = ol.color.rgbColorRe_.exec(s))) { // rgb()
|
||||||
r = Number(match[1]);
|
r = Number(match[1]);
|
||||||
g = Number(match[2]);
|
g = Number(match[2]);
|
||||||
b = Number(match[3]);
|
b = Number(match[3]);
|
||||||
color = [r, g, b, 1];
|
color = ol.color.normalize([r, g, b, 1]);
|
||||||
return ol.color.normalize(color, color);
|
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail(s + ' is not a valid color');
|
ol.assert(false, 14); // Invalid color
|
||||||
}
|
}
|
||||||
|
return /** @type {ol.Color} */ (color);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
goog.provide('ol.control.Attribution');
|
goog.provide('ol.control.Attribution');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.dom');
|
goog.require('ol.dom');
|
||||||
goog.require('ol.Attribution');
|
goog.require('ol.Attribution');
|
||||||
@@ -11,7 +10,6 @@ goog.require('ol.css');
|
|||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
goog.require('ol.object');
|
goog.require('ol.object');
|
||||||
goog.require('ol.source.Tile');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -160,8 +158,7 @@ ol.control.Attribution.prototype.getSourceAttributions = function(frameState) {
|
|||||||
var attributions = ol.object.assign({}, frameState.attributions);
|
var attributions = ol.object.assign({}, frameState.attributions);
|
||||||
/** @type {Object.<string, ol.Attribution>} */
|
/** @type {Object.<string, ol.Attribution>} */
|
||||||
var hiddenAttributions = {};
|
var hiddenAttributions = {};
|
||||||
var projection = frameState.viewState.projection;
|
var projection = /** @type {!ol.proj.Projection} */ (frameState.viewState.projection);
|
||||||
goog.asserts.assert(projection, 'projection of viewState required');
|
|
||||||
for (i = 0, ii = layerStatesArray.length; i < ii; i++) {
|
for (i = 0, ii = layerStatesArray.length; i < ii; i++) {
|
||||||
source = layerStatesArray[i].layer.getSource();
|
source = layerStatesArray[i].layer.getSource();
|
||||||
if (!source) {
|
if (!source) {
|
||||||
@@ -180,10 +177,7 @@ ol.control.Attribution.prototype.getSourceAttributions = function(frameState) {
|
|||||||
}
|
}
|
||||||
tileRanges = frameState.usedTiles[sourceKey];
|
tileRanges = frameState.usedTiles[sourceKey];
|
||||||
if (tileRanges) {
|
if (tileRanges) {
|
||||||
goog.asserts.assertInstanceof(source, ol.source.Tile,
|
var tileGrid = /** @type {ol.source.Tile} */ (source).getTileGridForProjection(projection);
|
||||||
'source should be an ol.source.Tile');
|
|
||||||
var tileGrid = source.getTileGridForProjection(projection);
|
|
||||||
goog.asserts.assert(tileGrid, 'tileGrid required for projection');
|
|
||||||
intersectsTileRange = sourceAttribution.intersectsAnyTileRange(
|
intersectsTileRange = sourceAttribution.intersectsAnyTileRange(
|
||||||
tileRanges, tileGrid, projection);
|
tileRanges, tileGrid, projection);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.control.FullScreen');
|
goog.provide('ol.control.FullScreen');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
@@ -125,7 +124,6 @@ ol.control.FullScreen.prototype.handleFullScreen_ = function() {
|
|||||||
} else {
|
} else {
|
||||||
element = map.getTargetElement();
|
element = map.getTargetElement();
|
||||||
}
|
}
|
||||||
goog.asserts.assert(element, 'element should be defined');
|
|
||||||
if (this.keys_) {
|
if (this.keys_) {
|
||||||
ol.control.FullScreen.requestFullScreenWithKeys(element);
|
ol.control.FullScreen.requestFullScreenWithKeys(element);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.control.OverviewMap');
|
goog.provide('ol.control.OverviewMap');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
@@ -272,18 +271,14 @@ ol.control.OverviewMap.prototype.validateExtent_ = function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var mapSize = map.getSize();
|
var mapSize = /** @type {ol.Size} */ (map.getSize());
|
||||||
goog.asserts.assertArray(mapSize, 'mapSize should be an array');
|
|
||||||
|
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assert(view, 'view should be defined');
|
|
||||||
var extent = view.calculateExtent(mapSize);
|
var extent = view.calculateExtent(mapSize);
|
||||||
|
|
||||||
var ovmapSize = ovmap.getSize();
|
var ovmapSize = /** @type {ol.Size} */ (ovmap.getSize());
|
||||||
goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array');
|
|
||||||
|
|
||||||
var ovview = ovmap.getView();
|
var ovview = ovmap.getView();
|
||||||
goog.asserts.assert(ovview, 'ovview should be defined');
|
|
||||||
var ovextent = ovview.calculateExtent(ovmapSize);
|
var ovextent = ovview.calculateExtent(ovmapSize);
|
||||||
|
|
||||||
var topLeftPixel =
|
var topLeftPixel =
|
||||||
@@ -321,18 +316,14 @@ ol.control.OverviewMap.prototype.resetExtent_ = function() {
|
|||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
var ovmap = this.ovmap_;
|
var ovmap = this.ovmap_;
|
||||||
|
|
||||||
var mapSize = map.getSize();
|
var mapSize = /** @type {ol.Size} */ (map.getSize());
|
||||||
goog.asserts.assertArray(mapSize, 'mapSize should be an array');
|
|
||||||
|
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assert(view, 'view should be defined');
|
|
||||||
var extent = view.calculateExtent(mapSize);
|
var extent = view.calculateExtent(mapSize);
|
||||||
|
|
||||||
var ovmapSize = ovmap.getSize();
|
var ovmapSize = /** @type {ol.Size} */ (ovmap.getSize());
|
||||||
goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array');
|
|
||||||
|
|
||||||
var ovview = ovmap.getView();
|
var ovview = ovmap.getView();
|
||||||
goog.asserts.assert(ovview, 'ovview should be defined');
|
|
||||||
|
|
||||||
// get how many times the current map overview could hold different
|
// get how many times the current map overview could hold different
|
||||||
// box sizes using the min and max ratio, pick the step in the middle used
|
// box sizes using the min and max ratio, pick the step in the middle used
|
||||||
@@ -355,10 +346,8 @@ ol.control.OverviewMap.prototype.recenter_ = function() {
|
|||||||
var ovmap = this.ovmap_;
|
var ovmap = this.ovmap_;
|
||||||
|
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assert(view, 'view should be defined');
|
|
||||||
|
|
||||||
var ovview = ovmap.getView();
|
var ovview = ovmap.getView();
|
||||||
goog.asserts.assert(ovview, 'ovview should be defined');
|
|
||||||
|
|
||||||
ovview.setCenter(view.getCenter());
|
ovview.setCenter(view.getCenter());
|
||||||
};
|
};
|
||||||
@@ -376,20 +365,15 @@ ol.control.OverviewMap.prototype.updateBox_ = function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var mapSize = map.getSize();
|
var mapSize = /** @type {ol.Size} */ (map.getSize());
|
||||||
goog.asserts.assertArray(mapSize, 'mapSize should be an array');
|
|
||||||
|
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assert(view, 'view should be defined');
|
|
||||||
|
|
||||||
var ovview = ovmap.getView();
|
var ovview = ovmap.getView();
|
||||||
goog.asserts.assert(ovview, 'ovview should be defined');
|
|
||||||
|
|
||||||
var ovmapSize = ovmap.getSize();
|
var ovmapSize = ovmap.getSize();
|
||||||
goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array');
|
|
||||||
|
|
||||||
var rotation = view.getRotation();
|
var rotation = view.getRotation();
|
||||||
goog.asserts.assert(rotation !== undefined, 'rotation should be defined');
|
|
||||||
|
|
||||||
var overlay = this.boxOverlay_;
|
var overlay = this.boxOverlay_;
|
||||||
var box = this.boxOverlay_.getElement();
|
var box = this.boxOverlay_.getElement();
|
||||||
@@ -422,7 +406,6 @@ ol.control.OverviewMap.prototype.calculateCoordinateRotate_ = function(
|
|||||||
|
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assert(view, 'view should be defined');
|
|
||||||
|
|
||||||
var currentCenter = view.getCenter();
|
var currentCenter = view.getCenter();
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
goog.provide('ol.control.ScaleLine');
|
goog.provide('ol.control.ScaleLine');
|
||||||
goog.provide('ol.control.ScaleLineUnits');
|
goog.provide('ol.control.ScaleLineUnits');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Object');
|
goog.require('ol.Object');
|
||||||
@@ -246,7 +245,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
|
|||||||
pointResolution /= 1609.3472;
|
pointResolution /= 1609.3472;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail('Scale line element cannot be updated');
|
ol.assert(false, 33); // Invalid units
|
||||||
}
|
}
|
||||||
|
|
||||||
var i = 3 * Math.floor(
|
var i = 3 * Math.floor(
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
goog.provide('ol.control.ZoomSlider');
|
goog.provide('ol.control.ZoomSlider');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.Event');
|
goog.require('ol.events.Event');
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
@@ -216,8 +215,6 @@ ol.control.ZoomSlider.render = function(mapEvent) {
|
|||||||
if (!mapEvent.frameState) {
|
if (!mapEvent.frameState) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
goog.asserts.assert(mapEvent.frameState.viewState,
|
|
||||||
'viewState should be defined');
|
|
||||||
if (!this.sliderInitialized_) {
|
if (!this.sliderInitialized_) {
|
||||||
this.initSlider_();
|
this.initSlider_();
|
||||||
}
|
}
|
||||||
@@ -237,10 +234,8 @@ ol.control.ZoomSlider.prototype.handleContainerClick_ = function(event) {
|
|||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
var currentResolution = view.getResolution();
|
var currentResolution = view.getResolution();
|
||||||
goog.asserts.assert(currentResolution,
|
|
||||||
'currentResolution should be defined');
|
|
||||||
map.beforeRender(ol.animation.zoom({
|
map.beforeRender(ol.animation.zoom({
|
||||||
resolution: currentResolution,
|
resolution: /** @type {number} */ (currentResolution),
|
||||||
duration: this.duration_,
|
duration: this.duration_,
|
||||||
easing: ol.easing.easeOut
|
easing: ol.easing.easeOut
|
||||||
}));
|
}));
|
||||||
@@ -312,10 +307,8 @@ ol.control.ZoomSlider.prototype.handleDraggerEnd_ = function(event) {
|
|||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
view.setHint(ol.ViewHint.INTERACTING, -1);
|
view.setHint(ol.ViewHint.INTERACTING, -1);
|
||||||
goog.asserts.assert(this.currentResolution_,
|
|
||||||
'this.currentResolution_ should be defined');
|
|
||||||
map.beforeRender(ol.animation.zoom({
|
map.beforeRender(ol.animation.zoom({
|
||||||
resolution: this.currentResolution_,
|
resolution: /** @type {number} */ (this.currentResolution_),
|
||||||
duration: this.duration_,
|
duration: this.duration_,
|
||||||
easing: ol.easing.easeOut
|
easing: ol.easing.easeOut
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.control.ZoomToExtent');
|
goog.provide('ol.control.ZoomToExtent');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
goog.require('ol.control.Control');
|
goog.require('ol.control.Control');
|
||||||
@@ -73,7 +72,6 @@ ol.control.ZoomToExtent.prototype.handleZoomToExtent_ = function() {
|
|||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
var extent = !this.extent_ ? view.getProjection().getExtent() : this.extent_;
|
var extent = !this.extent_ ? view.getProjection().getExtent() : this.extent_;
|
||||||
var size = map.getSize();
|
var size = /** @type {ol.Size} */ (map.getSize());
|
||||||
goog.asserts.assert(size, 'size should be defined');
|
|
||||||
view.fit(extent, size);
|
view.fit(extent, size);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.dom');
|
goog.provide('ol.dom');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('goog.userAgent');
|
goog.require('goog.userAgent');
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.vec.Mat4');
|
goog.require('ol.vec.Mat4');
|
||||||
@@ -41,11 +40,6 @@ ol.dom.canUseCssTransform = (function() {
|
|||||||
var canUseCssTransform;
|
var canUseCssTransform;
|
||||||
return function() {
|
return function() {
|
||||||
if (canUseCssTransform === undefined) {
|
if (canUseCssTransform === undefined) {
|
||||||
goog.asserts.assert(document.body,
|
|
||||||
'document.body should not be null');
|
|
||||||
goog.asserts.assert(ol.global.getComputedStyle,
|
|
||||||
'getComputedStyle is required (unsupported browser?)');
|
|
||||||
|
|
||||||
var el = document.createElement('P'),
|
var el = document.createElement('P'),
|
||||||
has2d,
|
has2d,
|
||||||
transforms = {
|
transforms = {
|
||||||
@@ -82,11 +76,6 @@ ol.dom.canUseCssTransform3D = (function() {
|
|||||||
var canUseCssTransform3D;
|
var canUseCssTransform3D;
|
||||||
return function() {
|
return function() {
|
||||||
if (canUseCssTransform3D === undefined) {
|
if (canUseCssTransform3D === undefined) {
|
||||||
goog.asserts.assert(document.body,
|
|
||||||
'document.body should not be null');
|
|
||||||
goog.asserts.assert(ol.global.getComputedStyle,
|
|
||||||
'getComputedStyle is required (unsupported browser?)');
|
|
||||||
|
|
||||||
var el = document.createElement('P'),
|
var el = document.createElement('P'),
|
||||||
has3d,
|
has3d,
|
||||||
transforms = {
|
transforms = {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.events.condition');
|
goog.provide('ol.events.condition');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.functions');
|
goog.require('ol.functions');
|
||||||
goog.require('ol.MapBrowserEvent.EventType');
|
goog.require('ol.MapBrowserEvent.EventType');
|
||||||
goog.require('ol.MapBrowserPointerEvent');
|
goog.require('ol.MapBrowserPointerEvent');
|
||||||
@@ -189,8 +188,6 @@ ol.events.condition.shiftKeyOnly = function(mapBrowserEvent) {
|
|||||||
*/
|
*/
|
||||||
ol.events.condition.targetNotEditable = function(mapBrowserEvent) {
|
ol.events.condition.targetNotEditable = function(mapBrowserEvent) {
|
||||||
var target = mapBrowserEvent.originalEvent.target;
|
var target = mapBrowserEvent.originalEvent.target;
|
||||||
goog.asserts.assertInstanceof(target, Element,
|
|
||||||
'target should be an Element');
|
|
||||||
var tagName = target.tagName;
|
var tagName = target.tagName;
|
||||||
return (
|
return (
|
||||||
tagName !== 'INPUT' &&
|
tagName !== 'INPUT' &&
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.events.EventTarget');
|
goog.provide('ol.events.EventTarget');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.Disposable');
|
goog.require('ol.Disposable');
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.Event');
|
goog.require('ol.events.Event');
|
||||||
@@ -144,7 +143,7 @@ ol.events.EventTarget.prototype.removeEventListener = function(type, listener) {
|
|||||||
var listeners = this.listeners_[type];
|
var listeners = this.listeners_[type];
|
||||||
if (listeners) {
|
if (listeners) {
|
||||||
var index = listeners.indexOf(listener);
|
var index = listeners.indexOf(listener);
|
||||||
goog.asserts.assert(index != -1, 'listener not found');
|
ol.DEBUG && console.assert(index != -1, 'listener not found');
|
||||||
if (type in this.pendingRemovals_) {
|
if (type in this.pendingRemovals_) {
|
||||||
// make listener a no-op, and remove later in #dispatchEvent()
|
// make listener a no-op, and remove later in #dispatchEvent()
|
||||||
listeners[index] = ol.nullFunction;
|
listeners[index] = ol.nullFunction;
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ goog.provide('ol.extent');
|
|||||||
goog.provide('ol.extent.Corner');
|
goog.provide('ol.extent.Corner');
|
||||||
goog.provide('ol.extent.Relationship');
|
goog.provide('ol.extent.Relationship');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extent corner.
|
* Extent corner.
|
||||||
@@ -55,8 +53,8 @@ ol.extent.boundingExtent = function(coordinates) {
|
|||||||
* @return {ol.Extent} Extent.
|
* @return {ol.Extent} Extent.
|
||||||
*/
|
*/
|
||||||
ol.extent.boundingExtentXYs_ = function(xs, ys, opt_extent) {
|
ol.extent.boundingExtentXYs_ = function(xs, ys, opt_extent) {
|
||||||
goog.asserts.assert(xs.length > 0, 'xs length should be larger than 0');
|
ol.DEBUG && console.assert(xs.length > 0, 'xs length should be larger than 0');
|
||||||
goog.asserts.assert(ys.length > 0, 'ys length should be larger than 0');
|
ol.DEBUG && console.assert(ys.length > 0, 'ys length should be larger than 0');
|
||||||
var minX = Math.min.apply(null, xs);
|
var minX = Math.min.apply(null, xs);
|
||||||
var minY = Math.min.apply(null, ys);
|
var minY = Math.min.apply(null, ys);
|
||||||
var maxX = Math.max.apply(null, xs);
|
var maxX = Math.max.apply(null, xs);
|
||||||
@@ -528,10 +526,9 @@ ol.extent.getCorner = function(extent, corner) {
|
|||||||
} else if (corner === ol.extent.Corner.TOP_RIGHT) {
|
} else if (corner === ol.extent.Corner.TOP_RIGHT) {
|
||||||
coordinate = ol.extent.getTopRight(extent);
|
coordinate = ol.extent.getTopRight(extent);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail('Invalid corner: %s', corner);
|
ol.assert(false, 13); // Invalid corner
|
||||||
}
|
}
|
||||||
goog.asserts.assert(coordinate, 'coordinate should be defined');
|
return /** @type {!ol.Coordinate} */ (coordinate);
|
||||||
return coordinate;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.Feature');
|
goog.provide('ol.Feature');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
@@ -100,8 +99,6 @@ ol.Feature = function(opt_geometryOrProperties) {
|
|||||||
var geometry = opt_geometryOrProperties;
|
var geometry = opt_geometryOrProperties;
|
||||||
this.setGeometry(geometry);
|
this.setGeometry(geometry);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assert(goog.isObject(opt_geometryOrProperties),
|
|
||||||
'opt_geometryOrProperties should be an Object');
|
|
||||||
/** @type {Object.<string, *>} */
|
/** @type {Object.<string, *>} */
|
||||||
var properties = opt_geometryOrProperties;
|
var properties = opt_geometryOrProperties;
|
||||||
this.setProperties(properties);
|
this.setProperties(properties);
|
||||||
@@ -304,8 +301,8 @@ ol.Feature.createStyleFunction = function(obj) {
|
|||||||
if (Array.isArray(obj)) {
|
if (Array.isArray(obj)) {
|
||||||
styles = obj;
|
styles = obj;
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assertInstanceof(obj, ol.style.Style,
|
ol.assert(obj instanceof ol.style.Style,
|
||||||
'obj should be an ol.style.Style');
|
41); // Expected an `ol.style.Style` or an array of `ol.style.Style`
|
||||||
styles = [obj];
|
styles = [obj];
|
||||||
}
|
}
|
||||||
styleFunction = function() {
|
styleFunction = function() {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.featureloader');
|
goog.provide('ol.featureloader');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.TileState');
|
goog.require('ol.TileState');
|
||||||
goog.require('ol.VectorTile');
|
goog.require('ol.VectorTile');
|
||||||
goog.require('ol.format.FormatType');
|
goog.require('ol.format.FormatType');
|
||||||
@@ -56,15 +55,13 @@ ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) {
|
|||||||
}
|
}
|
||||||
} else if (type == ol.format.FormatType.ARRAY_BUFFER) {
|
} else if (type == ol.format.FormatType.ARRAY_BUFFER) {
|
||||||
source = /** @type {ArrayBuffer} */ (xhr.response);
|
source = /** @type {ArrayBuffer} */ (xhr.response);
|
||||||
} else {
|
|
||||||
goog.asserts.fail('unexpected format type');
|
|
||||||
}
|
}
|
||||||
if (source) {
|
if (source) {
|
||||||
success.call(this, format.readFeatures(source,
|
success.call(this, format.readFeatures(source,
|
||||||
{featureProjection: projection}),
|
{featureProjection: projection}),
|
||||||
format.readProjection(source));
|
format.readProjection(source));
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail('undefined or null source');
|
failure.call(this);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
failure.call(this);
|
failure.call(this);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.format.EsriJSON');
|
goog.provide('ol.format.EsriJSON');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
@@ -56,6 +55,7 @@ ol.format.EsriJSON.readGeometry_ = function(object, opt_options) {
|
|||||||
if (!object) {
|
if (!object) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
/** @type {ol.geom.GeometryType} */
|
||||||
var type;
|
var type;
|
||||||
if (typeof object.x === 'number' && typeof object.y === 'number') {
|
if (typeof object.x === 'number' && typeof object.y === 'number') {
|
||||||
type = ol.geom.GeometryType.POINT;
|
type = ol.geom.GeometryType.POINT;
|
||||||
@@ -79,9 +79,8 @@ ol.format.EsriJSON.readGeometry_ = function(object, opt_options) {
|
|||||||
object.rings = rings;
|
object.rings = rings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goog.asserts.assert(type, 'geometry type should be defined');
|
|
||||||
var geometryReader = ol.format.EsriJSON.GEOMETRY_READERS_[type];
|
var geometryReader = ol.format.EsriJSON.GEOMETRY_READERS_[type];
|
||||||
goog.asserts.assert(geometryReader,
|
ol.DEBUG && console.assert(geometryReader,
|
||||||
'geometryReader should be defined');
|
'geometryReader should be defined');
|
||||||
return /** @type {ol.geom.Geometry} */ (
|
return /** @type {ol.geom.Geometry} */ (
|
||||||
ol.format.Feature.transformWithOptions(
|
ol.format.Feature.transformWithOptions(
|
||||||
@@ -145,8 +144,8 @@ ol.format.EsriJSON.convertRings_ = function(rings, layout) {
|
|||||||
* @return {ol.geom.Geometry} Point.
|
* @return {ol.geom.Geometry} Point.
|
||||||
*/
|
*/
|
||||||
ol.format.EsriJSON.readPointGeometry_ = function(object) {
|
ol.format.EsriJSON.readPointGeometry_ = function(object) {
|
||||||
goog.asserts.assert(typeof object.x === 'number', 'object.x should be number');
|
ol.DEBUG && console.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.y === 'number', 'object.y should be number');
|
||||||
var point;
|
var point;
|
||||||
if (object.m !== undefined && object.z !== undefined) {
|
if (object.m !== undefined && object.z !== undefined) {
|
||||||
point = new ol.geom.Point([object.x, object.y, object.z, object.m],
|
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.
|
* @return {ol.geom.Geometry} LineString.
|
||||||
*/
|
*/
|
||||||
ol.format.EsriJSON.readLineStringGeometry_ = function(object) {
|
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');
|
'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');
|
'object.paths array length should be 1');
|
||||||
var layout = ol.format.EsriJSON.getGeometryLayout_(object);
|
var layout = ol.format.EsriJSON.getGeometryLayout_(object);
|
||||||
return new ol.geom.LineString(object.paths[0], layout);
|
return new ol.geom.LineString(object.paths[0], layout);
|
||||||
@@ -185,9 +184,9 @@ ol.format.EsriJSON.readLineStringGeometry_ = function(object) {
|
|||||||
* @return {ol.geom.Geometry} MultiLineString.
|
* @return {ol.geom.Geometry} MultiLineString.
|
||||||
*/
|
*/
|
||||||
ol.format.EsriJSON.readMultiLineStringGeometry_ = function(object) {
|
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');
|
'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');
|
'object.paths array length should be more than 1');
|
||||||
var layout = ol.format.EsriJSON.getGeometryLayout_(object);
|
var layout = ol.format.EsriJSON.getGeometryLayout_(object);
|
||||||
return new ol.geom.MultiLineString(object.paths, layout);
|
return new ol.geom.MultiLineString(object.paths, layout);
|
||||||
@@ -218,7 +217,7 @@ ol.format.EsriJSON.getGeometryLayout_ = function(object) {
|
|||||||
* @return {ol.geom.Geometry} MultiPoint.
|
* @return {ol.geom.Geometry} MultiPoint.
|
||||||
*/
|
*/
|
||||||
ol.format.EsriJSON.readMultiPointGeometry_ = function(object) {
|
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);
|
var layout = ol.format.EsriJSON.getGeometryLayout_(object);
|
||||||
return new ol.geom.MultiPoint(object.points, layout);
|
return new ol.geom.MultiPoint(object.points, layout);
|
||||||
};
|
};
|
||||||
@@ -230,8 +229,8 @@ ol.format.EsriJSON.readMultiPointGeometry_ = function(object) {
|
|||||||
* @return {ol.geom.Geometry} MultiPolygon.
|
* @return {ol.geom.Geometry} MultiPolygon.
|
||||||
*/
|
*/
|
||||||
ol.format.EsriJSON.readMultiPolygonGeometry_ = function(object) {
|
ol.format.EsriJSON.readMultiPolygonGeometry_ = function(object) {
|
||||||
goog.asserts.assert(object.rings);
|
ol.DEBUG && console.assert(object.rings);
|
||||||
goog.asserts.assert(object.rings.length > 1,
|
ol.DEBUG && console.assert(object.rings.length > 1,
|
||||||
'object.rings should have length larger than 1');
|
'object.rings should have length larger than 1');
|
||||||
var layout = ol.format.EsriJSON.getGeometryLayout_(object);
|
var layout = ol.format.EsriJSON.getGeometryLayout_(object);
|
||||||
return new ol.geom.MultiPolygon(
|
return new ol.geom.MultiPolygon(
|
||||||
@@ -246,7 +245,7 @@ ol.format.EsriJSON.readMultiPolygonGeometry_ = function(object) {
|
|||||||
* @return {ol.geom.Geometry} Polygon.
|
* @return {ol.geom.Geometry} Polygon.
|
||||||
*/
|
*/
|
||||||
ol.format.EsriJSON.readPolygonGeometry_ = function(object) {
|
ol.format.EsriJSON.readPolygonGeometry_ = function(object) {
|
||||||
goog.asserts.assert(object.rings);
|
ol.DEBUG && console.assert(object.rings);
|
||||||
var layout = ol.format.EsriJSON.getGeometryLayout_(object);
|
var layout = ol.format.EsriJSON.getGeometryLayout_(object);
|
||||||
return new ol.geom.Polygon(object.rings, layout);
|
return new ol.geom.Polygon(object.rings, layout);
|
||||||
};
|
};
|
||||||
@@ -259,37 +258,37 @@ ol.format.EsriJSON.readPolygonGeometry_ = function(object) {
|
|||||||
* @return {EsriJSONGeometry} EsriJSON geometry.
|
* @return {EsriJSONGeometry} EsriJSON geometry.
|
||||||
*/
|
*/
|
||||||
ol.format.EsriJSON.writePointGeometry_ = function(geometry, opt_options) {
|
ol.format.EsriJSON.writePointGeometry_ = function(geometry, opt_options) {
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.Point,
|
var coordinates = /** @type ol.geom.Point */ (geometry).getCoordinates();
|
||||||
'geometry should be an ol.geom.Point');
|
var esriJSON;
|
||||||
var coordinates = geometry.getCoordinates();
|
var layout = /** @type ol.geom.Point */ (geometry).getLayout();
|
||||||
var layout = geometry.getLayout();
|
|
||||||
if (layout === ol.geom.GeometryLayout.XYZ) {
|
if (layout === ol.geom.GeometryLayout.XYZ) {
|
||||||
return /** @type {EsriJSONPoint} */ ({
|
esriJSON = /** @type {EsriJSONPoint} */ ({
|
||||||
x: coordinates[0],
|
x: coordinates[0],
|
||||||
y: coordinates[1],
|
y: coordinates[1],
|
||||||
z: coordinates[2]
|
z: coordinates[2]
|
||||||
});
|
});
|
||||||
} else if (layout === ol.geom.GeometryLayout.XYM) {
|
} else if (layout === ol.geom.GeometryLayout.XYM) {
|
||||||
return /** @type {EsriJSONPoint} */ ({
|
esriJSON = /** @type {EsriJSONPoint} */ ({
|
||||||
x: coordinates[0],
|
x: coordinates[0],
|
||||||
y: coordinates[1],
|
y: coordinates[1],
|
||||||
m: coordinates[2]
|
m: coordinates[2]
|
||||||
});
|
});
|
||||||
} else if (layout === ol.geom.GeometryLayout.XYZM) {
|
} else if (layout === ol.geom.GeometryLayout.XYZM) {
|
||||||
return /** @type {EsriJSONPoint} */ ({
|
esriJSON = /** @type {EsriJSONPoint} */ ({
|
||||||
x: coordinates[0],
|
x: coordinates[0],
|
||||||
y: coordinates[1],
|
y: coordinates[1],
|
||||||
z: coordinates[2],
|
z: coordinates[2],
|
||||||
m: coordinates[3]
|
m: coordinates[3]
|
||||||
});
|
});
|
||||||
} else if (layout === ol.geom.GeometryLayout.XY) {
|
} else if (layout === ol.geom.GeometryLayout.XY) {
|
||||||
return /** @type {EsriJSONPoint} */ ({
|
esriJSON = /** @type {EsriJSONPoint} */ ({
|
||||||
x: coordinates[0],
|
x: coordinates[0],
|
||||||
y: coordinates[1]
|
y: coordinates[1]
|
||||||
});
|
});
|
||||||
} else {
|
} 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.
|
* @return {EsriJSONPolyline} EsriJSON geometry.
|
||||||
*/
|
*/
|
||||||
ol.format.EsriJSON.writeLineStringGeometry_ = function(geometry, opt_options) {
|
ol.format.EsriJSON.writeLineStringGeometry_ = function(geometry, opt_options) {
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.LineString,
|
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.LineString} */ (geometry));
|
||||||
'geometry should be an ol.geom.LineString');
|
|
||||||
var hasZM = ol.format.EsriJSON.getHasZM_(geometry);
|
|
||||||
return /** @type {EsriJSONPolyline} */ ({
|
return /** @type {EsriJSONPolyline} */ ({
|
||||||
hasZ: hasZM.hasZ,
|
hasZ: hasZM.hasZ,
|
||||||
hasM: hasZM.hasM,
|
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.
|
* @return {EsriJSONPolygon} EsriJSON geometry.
|
||||||
*/
|
*/
|
||||||
ol.format.EsriJSON.writePolygonGeometry_ = function(geometry, opt_options) {
|
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
|
// 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} */ ({
|
return /** @type {EsriJSONPolygon} */ ({
|
||||||
hasZ: hasZM.hasZ,
|
hasZ: hasZM.hasZ,
|
||||||
hasM: hasZM.hasM,
|
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.
|
* @return {EsriJSONPolyline} EsriJSON geometry.
|
||||||
*/
|
*/
|
||||||
ol.format.EsriJSON.writeMultiLineStringGeometry_ = function(geometry, opt_options) {
|
ol.format.EsriJSON.writeMultiLineStringGeometry_ = function(geometry, opt_options) {
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.MultiLineString,
|
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.MultiLineString} */ (geometry));
|
||||||
'geometry should be an ol.geom.MultiLineString');
|
|
||||||
var hasZM = ol.format.EsriJSON.getHasZM_(geometry);
|
|
||||||
return /** @type {EsriJSONPolyline} */ ({
|
return /** @type {EsriJSONPolyline} */ ({
|
||||||
hasZ: hasZM.hasZ,
|
hasZ: hasZM.hasZ,
|
||||||
hasM: hasZM.hasM,
|
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.
|
* @return {EsriJSONMultipoint} EsriJSON geometry.
|
||||||
*/
|
*/
|
||||||
ol.format.EsriJSON.writeMultiPointGeometry_ = function(geometry, opt_options) {
|
ol.format.EsriJSON.writeMultiPointGeometry_ = function(geometry, opt_options) {
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.MultiPoint,
|
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.MultiPoint} */ (geometry));
|
||||||
'geometry should be an ol.geom.MultiPoint');
|
|
||||||
var hasZM = ol.format.EsriJSON.getHasZM_(geometry);
|
|
||||||
return /** @type {EsriJSONMultipoint} */ ({
|
return /** @type {EsriJSONMultipoint} */ ({
|
||||||
hasZ: hasZM.hasZ,
|
hasZ: hasZM.hasZ,
|
||||||
hasM: hasZM.hasM,
|
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,
|
ol.format.EsriJSON.writeMultiPolygonGeometry_ = function(geometry,
|
||||||
opt_options) {
|
opt_options) {
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.MultiPolygon,
|
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.MultiPolygon} */ (geometry));
|
||||||
'geometry should be an ol.geom.MultiPolygon');
|
var coordinates = /** @type {ol.geom.MultiPolygon} */ (geometry).getCoordinates(false);
|
||||||
var hasZM = ol.format.EsriJSON.getHasZM_(geometry);
|
|
||||||
var coordinates = geometry.getCoordinates(false);
|
|
||||||
var output = [];
|
var output = [];
|
||||||
for (var i = 0; i < coordinates.length; i++) {
|
for (var i = 0; i < coordinates.length; i++) {
|
||||||
for (var x = coordinates[i].length - 1; x >= 0; x--) {
|
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(
|
ol.format.EsriJSON.prototype.readFeatureFromObject = function(
|
||||||
object, opt_options) {
|
object, opt_options) {
|
||||||
var esriJSONFeature = /** @type {EsriJSONFeature} */ (object);
|
var esriJSONFeature = /** @type {EsriJSONFeature} */ (object);
|
||||||
goog.asserts.assert(esriJSONFeature.geometry ||
|
ol.DEBUG && console.assert(esriJSONFeature.geometry ||
|
||||||
esriJSONFeature.attributes,
|
esriJSONFeature.attributes,
|
||||||
'geometry or attributes should be defined');
|
'geometry or attributes should be defined');
|
||||||
var geometry = ol.format.EsriJSON.readGeometry_(esriJSONFeature.geometry,
|
var geometry = ol.format.EsriJSON.readGeometry_(esriJSONFeature.geometry,
|
||||||
@@ -492,7 +481,7 @@ ol.format.EsriJSON.prototype.readFeatureFromObject = function(
|
|||||||
feature.setGeometry(geometry);
|
feature.setGeometry(geometry);
|
||||||
if (opt_options && opt_options.idField &&
|
if (opt_options && opt_options.idField &&
|
||||||
esriJSONFeature.attributes[opt_options.idField]) {
|
esriJSONFeature.attributes[opt_options.idField]) {
|
||||||
goog.asserts.assert(
|
ol.DEBUG && console.assert(
|
||||||
typeof esriJSONFeature.attributes[opt_options.idField] === 'number',
|
typeof esriJSONFeature.attributes[opt_options.idField] === 'number',
|
||||||
'objectIdFieldName value should be a number');
|
'objectIdFieldName value should be a number');
|
||||||
feature.setId(/** @type {number} */(
|
feature.setId(/** @type {number} */(
|
||||||
@@ -586,7 +575,7 @@ ol.format.EsriJSON.prototype.readProjectionFromObject = function(object) {
|
|||||||
*/
|
*/
|
||||||
ol.format.EsriJSON.writeGeometry_ = function(geometry, opt_options) {
|
ol.format.EsriJSON.writeGeometry_ = function(geometry, opt_options) {
|
||||||
var geometryWriter = ol.format.EsriJSON.GEOMETRY_WRITERS_[geometry.getType()];
|
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} */ (
|
return geometryWriter(/** @type {ol.geom.Geometry} */ (
|
||||||
ol.format.Feature.transformWithOptions(geometry, true, opt_options)),
|
ol.format.Feature.transformWithOptions(geometry, true, opt_options)),
|
||||||
opt_options);
|
opt_options);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
goog.provide('ol.format.GeoJSON');
|
goog.provide('ol.format.GeoJSON');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
goog.require('ol.format.Feature');
|
goog.require('ol.format.Feature');
|
||||||
goog.require('ol.format.JSONFeature');
|
goog.require('ol.format.JSONFeature');
|
||||||
@@ -71,7 +70,7 @@ ol.format.GeoJSON.readGeometry_ = function(object, opt_options) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var geometryReader = ol.format.GeoJSON.GEOMETRY_READERS_[object.type];
|
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} */ (
|
return /** @type {ol.geom.Geometry} */ (
|
||||||
ol.format.Feature.transformWithOptions(
|
ol.format.Feature.transformWithOptions(
|
||||||
geometryReader(object), false, opt_options));
|
geometryReader(object), false, opt_options));
|
||||||
@@ -86,7 +85,7 @@ ol.format.GeoJSON.readGeometry_ = function(object, opt_options) {
|
|||||||
*/
|
*/
|
||||||
ol.format.GeoJSON.readGeometryCollectionGeometry_ = function(
|
ol.format.GeoJSON.readGeometryCollectionGeometry_ = function(
|
||||||
object, opt_options) {
|
object, opt_options) {
|
||||||
goog.asserts.assert(object.type == 'GeometryCollection',
|
ol.DEBUG && console.assert(object.type == 'GeometryCollection',
|
||||||
'object.type should be GeometryCollection');
|
'object.type should be GeometryCollection');
|
||||||
var geometries = object.geometries.map(
|
var geometries = object.geometries.map(
|
||||||
/**
|
/**
|
||||||
@@ -106,7 +105,7 @@ ol.format.GeoJSON.readGeometryCollectionGeometry_ = function(
|
|||||||
* @return {ol.geom.Point} Point.
|
* @return {ol.geom.Point} Point.
|
||||||
*/
|
*/
|
||||||
ol.format.GeoJSON.readPointGeometry_ = function(object) {
|
ol.format.GeoJSON.readPointGeometry_ = function(object) {
|
||||||
goog.asserts.assert(object.type == 'Point',
|
ol.DEBUG && console.assert(object.type == 'Point',
|
||||||
'object.type should be Point');
|
'object.type should be Point');
|
||||||
return new ol.geom.Point(object.coordinates);
|
return new ol.geom.Point(object.coordinates);
|
||||||
};
|
};
|
||||||
@@ -118,7 +117,7 @@ ol.format.GeoJSON.readPointGeometry_ = function(object) {
|
|||||||
* @return {ol.geom.LineString} LineString.
|
* @return {ol.geom.LineString} LineString.
|
||||||
*/
|
*/
|
||||||
ol.format.GeoJSON.readLineStringGeometry_ = function(object) {
|
ol.format.GeoJSON.readLineStringGeometry_ = function(object) {
|
||||||
goog.asserts.assert(object.type == 'LineString',
|
ol.DEBUG && console.assert(object.type == 'LineString',
|
||||||
'object.type should be LineString');
|
'object.type should be LineString');
|
||||||
return new ol.geom.LineString(object.coordinates);
|
return new ol.geom.LineString(object.coordinates);
|
||||||
};
|
};
|
||||||
@@ -130,7 +129,7 @@ ol.format.GeoJSON.readLineStringGeometry_ = function(object) {
|
|||||||
* @return {ol.geom.MultiLineString} MultiLineString.
|
* @return {ol.geom.MultiLineString} MultiLineString.
|
||||||
*/
|
*/
|
||||||
ol.format.GeoJSON.readMultiLineStringGeometry_ = function(object) {
|
ol.format.GeoJSON.readMultiLineStringGeometry_ = function(object) {
|
||||||
goog.asserts.assert(object.type == 'MultiLineString',
|
ol.DEBUG && console.assert(object.type == 'MultiLineString',
|
||||||
'object.type should be MultiLineString');
|
'object.type should be MultiLineString');
|
||||||
return new ol.geom.MultiLineString(object.coordinates);
|
return new ol.geom.MultiLineString(object.coordinates);
|
||||||
};
|
};
|
||||||
@@ -142,7 +141,7 @@ ol.format.GeoJSON.readMultiLineStringGeometry_ = function(object) {
|
|||||||
* @return {ol.geom.MultiPoint} MultiPoint.
|
* @return {ol.geom.MultiPoint} MultiPoint.
|
||||||
*/
|
*/
|
||||||
ol.format.GeoJSON.readMultiPointGeometry_ = function(object) {
|
ol.format.GeoJSON.readMultiPointGeometry_ = function(object) {
|
||||||
goog.asserts.assert(object.type == 'MultiPoint',
|
ol.DEBUG && console.assert(object.type == 'MultiPoint',
|
||||||
'object.type should be MultiPoint');
|
'object.type should be MultiPoint');
|
||||||
return new ol.geom.MultiPoint(object.coordinates);
|
return new ol.geom.MultiPoint(object.coordinates);
|
||||||
};
|
};
|
||||||
@@ -154,7 +153,7 @@ ol.format.GeoJSON.readMultiPointGeometry_ = function(object) {
|
|||||||
* @return {ol.geom.MultiPolygon} MultiPolygon.
|
* @return {ol.geom.MultiPolygon} MultiPolygon.
|
||||||
*/
|
*/
|
||||||
ol.format.GeoJSON.readMultiPolygonGeometry_ = function(object) {
|
ol.format.GeoJSON.readMultiPolygonGeometry_ = function(object) {
|
||||||
goog.asserts.assert(object.type == 'MultiPolygon',
|
ol.DEBUG && console.assert(object.type == 'MultiPolygon',
|
||||||
'object.type should be MultiPolygon');
|
'object.type should be MultiPolygon');
|
||||||
return new ol.geom.MultiPolygon(object.coordinates);
|
return new ol.geom.MultiPolygon(object.coordinates);
|
||||||
};
|
};
|
||||||
@@ -166,7 +165,7 @@ ol.format.GeoJSON.readMultiPolygonGeometry_ = function(object) {
|
|||||||
* @return {ol.geom.Polygon} Polygon.
|
* @return {ol.geom.Polygon} Polygon.
|
||||||
*/
|
*/
|
||||||
ol.format.GeoJSON.readPolygonGeometry_ = function(object) {
|
ol.format.GeoJSON.readPolygonGeometry_ = function(object) {
|
||||||
goog.asserts.assert(object.type == 'Polygon',
|
ol.DEBUG && console.assert(object.type == 'Polygon',
|
||||||
'object.type should be Polygon');
|
'object.type should be Polygon');
|
||||||
return new ol.geom.Polygon(object.coordinates);
|
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) {
|
ol.format.GeoJSON.writeGeometry_ = function(geometry, opt_options) {
|
||||||
var geometryWriter = ol.format.GeoJSON.GEOMETRY_WRITERS_[geometry.getType()];
|
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} */ (
|
return geometryWriter(/** @type {ol.geom.Geometry} */ (
|
||||||
ol.format.Feature.transformWithOptions(geometry, true, opt_options)),
|
ol.format.Feature.transformWithOptions(geometry, true, opt_options)),
|
||||||
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.
|
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||||
* @private
|
* @private
|
||||||
* @return {GeoJSONGeometryCollection} GeoJSON geometry collection.
|
* @return {GeoJSONGeometryCollection} GeoJSON geometry collection.
|
||||||
*/
|
*/
|
||||||
ol.format.GeoJSON.writeGeometryCollectionGeometry_ = function(
|
ol.format.GeoJSON.writeGeometryCollectionGeometry_ = function(
|
||||||
geometry, opt_options) {
|
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 geometries = geometry.getGeometriesArray().map(function(geometry) {
|
||||||
var options = ol.object.assign({}, opt_options);
|
var options = ol.object.assign({}, opt_options);
|
||||||
delete options.featureProjection;
|
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.
|
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||||
* @private
|
* @private
|
||||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||||
*/
|
*/
|
||||||
ol.format.GeoJSON.writeLineStringGeometry_ = function(geometry, opt_options) {
|
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} */ ({
|
return /** @type {GeoJSONGeometry} */ ({
|
||||||
type: 'LineString',
|
type: 'LineString',
|
||||||
coordinates: geometry.getCoordinates()
|
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.
|
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||||
* @private
|
* @private
|
||||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||||
*/
|
*/
|
||||||
ol.format.GeoJSON.writeMultiLineStringGeometry_ = function(geometry, opt_options) {
|
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} */ ({
|
return /** @type {GeoJSONGeometry} */ ({
|
||||||
type: 'MultiLineString',
|
type: 'MultiLineString',
|
||||||
coordinates: geometry.getCoordinates()
|
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.
|
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||||
* @private
|
* @private
|
||||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||||
*/
|
*/
|
||||||
ol.format.GeoJSON.writeMultiPointGeometry_ = function(geometry, opt_options) {
|
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} */ ({
|
return /** @type {GeoJSONGeometry} */ ({
|
||||||
type: 'MultiPoint',
|
type: 'MultiPoint',
|
||||||
coordinates: geometry.getCoordinates()
|
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.
|
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||||
* @private
|
* @private
|
||||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||||
*/
|
*/
|
||||||
ol.format.GeoJSON.writeMultiPolygonGeometry_ = function(geometry, opt_options) {
|
ol.format.GeoJSON.writeMultiPolygonGeometry_ = function(geometry, opt_options) {
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.MultiPolygon,
|
|
||||||
'geometry should be an ol.geom.MultiPolygon');
|
|
||||||
var right;
|
var right;
|
||||||
if (opt_options) {
|
if (opt_options) {
|
||||||
right = opt_options.rightHanded;
|
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.
|
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||||
* @private
|
* @private
|
||||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||||
*/
|
*/
|
||||||
ol.format.GeoJSON.writePointGeometry_ = function(geometry, opt_options) {
|
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} */ ({
|
return /** @type {GeoJSONGeometry} */ ({
|
||||||
type: 'Point',
|
type: 'Point',
|
||||||
coordinates: geometry.getCoordinates()
|
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.
|
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||||
* @private
|
* @private
|
||||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||||
*/
|
*/
|
||||||
ol.format.GeoJSON.writePolygonGeometry_ = function(geometry, opt_options) {
|
ol.format.GeoJSON.writePolygonGeometry_ = function(geometry, opt_options) {
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.Polygon,
|
|
||||||
'geometry should be an ol.geom.Polygon');
|
|
||||||
var right;
|
var right;
|
||||||
if (opt_options) {
|
if (opt_options) {
|
||||||
right = opt_options.rightHanded;
|
right = opt_options.rightHanded;
|
||||||
@@ -399,7 +384,7 @@ ol.format.GeoJSON.prototype.readFeatures;
|
|||||||
ol.format.GeoJSON.prototype.readFeatureFromObject = function(
|
ol.format.GeoJSON.prototype.readFeatureFromObject = function(
|
||||||
object, opt_options) {
|
object, opt_options) {
|
||||||
var geoJSONFeature = /** @type {GeoJSONFeature} */ (object);
|
var geoJSONFeature = /** @type {GeoJSONFeature} */ (object);
|
||||||
goog.asserts.assert(geoJSONFeature.type == 'Feature',
|
ol.DEBUG && console.assert(geoJSONFeature.type == 'Feature',
|
||||||
'geoJSONFeature.type should be Feature');
|
'geoJSONFeature.type should be Feature');
|
||||||
var geometry = ol.format.GeoJSON.readGeometry_(geoJSONFeature.geometry,
|
var geometry = ol.format.GeoJSON.readGeometry_(geoJSONFeature.geometry,
|
||||||
opt_options);
|
opt_options);
|
||||||
@@ -424,24 +409,24 @@ ol.format.GeoJSON.prototype.readFeatureFromObject = function(
|
|||||||
ol.format.GeoJSON.prototype.readFeaturesFromObject = function(
|
ol.format.GeoJSON.prototype.readFeaturesFromObject = function(
|
||||||
object, opt_options) {
|
object, opt_options) {
|
||||||
var geoJSONObject = /** @type {GeoJSONObject} */ (object);
|
var geoJSONObject = /** @type {GeoJSONObject} */ (object);
|
||||||
|
/** @type {Array.<ol.Feature>} */
|
||||||
|
var features;
|
||||||
if (geoJSONObject.type == 'Feature') {
|
if (geoJSONObject.type == 'Feature') {
|
||||||
return [this.readFeatureFromObject(object, opt_options)];
|
features = [this.readFeatureFromObject(object, opt_options)];
|
||||||
} else if (geoJSONObject.type == 'FeatureCollection') {
|
} else if (geoJSONObject.type == 'FeatureCollection') {
|
||||||
var geoJSONFeatureCollection = /** @type {GeoJSONFeatureCollection} */
|
var geoJSONFeatureCollection = /** @type {GeoJSONFeatureCollection} */
|
||||||
(object);
|
(object);
|
||||||
/** @type {Array.<ol.Feature>} */
|
features = [];
|
||||||
var features = [];
|
|
||||||
var geoJSONFeatures = geoJSONFeatureCollection.features;
|
var geoJSONFeatures = geoJSONFeatureCollection.features;
|
||||||
var i, ii;
|
var i, ii;
|
||||||
for (i = 0, ii = geoJSONFeatures.length; i < ii; ++i) {
|
for (i = 0, ii = geoJSONFeatures.length; i < ii; ++i) {
|
||||||
features.push(this.readFeatureFromObject(geoJSONFeatures[i],
|
features.push(this.readFeatureFromObject(geoJSONFeatures[i],
|
||||||
opt_options));
|
opt_options));
|
||||||
}
|
}
|
||||||
return features;
|
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail('Unknown geoJSONObject.type: ' + geoJSONObject.type);
|
ol.assert(false, 35); // Unknown GeoJSON object type
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
|
return /** Array.<ol.Feature> */ (features);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -484,22 +469,23 @@ ol.format.GeoJSON.prototype.readProjection;
|
|||||||
ol.format.GeoJSON.prototype.readProjectionFromObject = function(object) {
|
ol.format.GeoJSON.prototype.readProjectionFromObject = function(object) {
|
||||||
var geoJSONObject = /** @type {GeoJSONObject} */ (object);
|
var geoJSONObject = /** @type {GeoJSONObject} */ (object);
|
||||||
var crs = geoJSONObject.crs;
|
var crs = geoJSONObject.crs;
|
||||||
|
var projection;
|
||||||
if (crs) {
|
if (crs) {
|
||||||
if (crs.type == 'name') {
|
if (crs.type == 'name') {
|
||||||
return ol.proj.get(crs.properties.name);
|
projection = ol.proj.get(crs.properties.name);
|
||||||
} else if (crs.type == 'EPSG') {
|
} else if (crs.type == 'EPSG') {
|
||||||
// 'EPSG' is not part of the GeoJSON specification, but is generated by
|
// 'EPSG' is not part of the GeoJSON specification, but is generated by
|
||||||
// GeoServer.
|
// GeoServer.
|
||||||
// TODO: remove this when http://jira.codehaus.org/browse/GEOS-5996
|
// TODO: remove this when http://jira.codehaus.org/browse/GEOS-5996
|
||||||
// is fixed and widely deployed.
|
// is fixed and widely deployed.
|
||||||
return ol.proj.get('EPSG:' + crs.properties.code);
|
projection = ol.proj.get('EPSG:' + crs.properties.code);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail('Unknown crs.type: ' + crs.type);
|
ol.assert(false, 36); // Unknown SRS type
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return this.defaultDataProjection;
|
projection = this.defaultDataProjection;
|
||||||
}
|
}
|
||||||
|
return /** @type {ol.proj.Projection} */ (projection);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.format.GML2');
|
goog.provide('ol.format.GML2');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.format.GMLBase');
|
goog.require('ol.format.GMLBase');
|
||||||
goog.require('ol.format.XSD');
|
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) {
|
ol.format.GML2.prototype.readFlatCoordinates_ = function(node, objectStack) {
|
||||||
var s = ol.xml.getAllTextContent(node, false).replace(/^\s*|\s*$/g, '');
|
var s = ol.xml.getAllTextContent(node, false).replace(/^\s*|\s*$/g, '');
|
||||||
var context = /** @type {ol.XmlNodeStackItem} */ (objectStack[0]);
|
var context = /** @type {ol.XmlNodeStackItem} */ (objectStack[0]);
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var containerSrs = context['srsName'];
|
var containerSrs = context['srsName'];
|
||||||
var containerDimension = node.parentNode.getAttribute('srsDimension');
|
var containerDimension = node.parentNode.getAttribute('srsDimension');
|
||||||
var axisOrientation = 'enu';
|
var axisOrientation = 'enu';
|
||||||
@@ -101,9 +99,9 @@ ol.format.GML2.prototype.readFlatCoordinates_ = function(node, objectStack) {
|
|||||||
* @return {ol.Extent|undefined} Envelope.
|
* @return {ol.Extent|undefined} Envelope.
|
||||||
*/
|
*/
|
||||||
ol.format.GML2.prototype.readBox_ = function(node, objectStack) {
|
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');
|
'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>} */
|
/** @type {Array.<number>} */
|
||||||
var flatCoordinates = ol.xml.pushParseAndPop([null],
|
var flatCoordinates = ol.xml.pushParseAndPop([null],
|
||||||
this.BOX_PARSERS_, node, objectStack, this);
|
this.BOX_PARSERS_, node, objectStack, this);
|
||||||
@@ -119,9 +117,9 @@ ol.format.GML2.prototype.readBox_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.GML2.prototype.innerBoundaryIsParser_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'innerBoundaryIs',
|
ol.DEBUG && console.assert(node.localName == 'innerBoundaryIs',
|
||||||
'localName should be innerBoundaryIs');
|
'localName should be innerBoundaryIs');
|
||||||
/** @type {Array.<number>|undefined} */
|
/** @type {Array.<number>|undefined} */
|
||||||
var flatLinearRing = ol.xml.pushParseAndPop(undefined,
|
var flatLinearRing = ol.xml.pushParseAndPop(undefined,
|
||||||
@@ -129,9 +127,9 @@ ol.format.GML2.prototype.innerBoundaryIsParser_ = function(node, objectStack) {
|
|||||||
if (flatLinearRing) {
|
if (flatLinearRing) {
|
||||||
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
||||||
(objectStack[objectStack.length - 1]);
|
(objectStack[objectStack.length - 1]);
|
||||||
goog.asserts.assert(Array.isArray(flatLinearRings),
|
ol.DEBUG && console.assert(Array.isArray(flatLinearRings),
|
||||||
'flatLinearRings should be an array');
|
'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 should have an array length larger than 0');
|
||||||
flatLinearRings.push(flatLinearRing);
|
flatLinearRings.push(flatLinearRing);
|
||||||
}
|
}
|
||||||
@@ -144,9 +142,9 @@ ol.format.GML2.prototype.innerBoundaryIsParser_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.GML2.prototype.outerBoundaryIsParser_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'outerBoundaryIs',
|
ol.DEBUG && console.assert(node.localName == 'outerBoundaryIs',
|
||||||
'localName should be outerBoundaryIs');
|
'localName should be outerBoundaryIs');
|
||||||
/** @type {Array.<number>|undefined} */
|
/** @type {Array.<number>|undefined} */
|
||||||
var flatLinearRing = ol.xml.pushParseAndPop(undefined,
|
var flatLinearRing = ol.xml.pushParseAndPop(undefined,
|
||||||
@@ -154,9 +152,9 @@ ol.format.GML2.prototype.outerBoundaryIsParser_ = function(node, objectStack) {
|
|||||||
if (flatLinearRing) {
|
if (flatLinearRing) {
|
||||||
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
||||||
(objectStack[objectStack.length - 1]);
|
(objectStack[objectStack.length - 1]);
|
||||||
goog.asserts.assert(Array.isArray(flatLinearRings),
|
ol.DEBUG && console.assert(Array.isArray(flatLinearRings),
|
||||||
'flatLinearRings should be an array');
|
'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 should have an array length larger than 0');
|
||||||
flatLinearRings[0] = flatLinearRing;
|
flatLinearRings[0] = flatLinearRing;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
goog.provide('ol.format.GML');
|
goog.provide('ol.format.GML');
|
||||||
goog.provide('ol.format.GML3');
|
goog.provide('ol.format.GML3');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
@@ -93,9 +92,9 @@ ol.format.GML3.schemaLocation_ = ol.format.GMLBase.GMLNS +
|
|||||||
* @return {ol.geom.MultiLineString|undefined} MultiLineString.
|
* @return {ol.geom.MultiLineString|undefined} MultiLineString.
|
||||||
*/
|
*/
|
||||||
ol.format.GML3.prototype.readMultiCurve_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'MultiCurve',
|
ol.DEBUG && console.assert(node.localName == 'MultiCurve',
|
||||||
'localName should be MultiCurve');
|
'localName should be MultiCurve');
|
||||||
/** @type {Array.<ol.geom.LineString>} */
|
/** @type {Array.<ol.geom.LineString>} */
|
||||||
var lineStrings = ol.xml.pushParseAndPop([],
|
var lineStrings = ol.xml.pushParseAndPop([],
|
||||||
@@ -117,9 +116,9 @@ ol.format.GML3.prototype.readMultiCurve_ = function(node, objectStack) {
|
|||||||
* @return {ol.geom.MultiPolygon|undefined} MultiPolygon.
|
* @return {ol.geom.MultiPolygon|undefined} MultiPolygon.
|
||||||
*/
|
*/
|
||||||
ol.format.GML3.prototype.readMultiSurface_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'MultiSurface',
|
ol.DEBUG && console.assert(node.localName == 'MultiSurface',
|
||||||
'localName should be MultiSurface');
|
'localName should be MultiSurface');
|
||||||
/** @type {Array.<ol.geom.Polygon>} */
|
/** @type {Array.<ol.geom.Polygon>} */
|
||||||
var polygons = ol.xml.pushParseAndPop([],
|
var polygons = ol.xml.pushParseAndPop([],
|
||||||
@@ -140,9 +139,9 @@ ol.format.GML3.prototype.readMultiSurface_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.GML3.prototype.curveMemberParser_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'curveMember' ||
|
ol.DEBUG && console.assert(node.localName == 'curveMember' ||
|
||||||
node.localName == 'curveMembers',
|
node.localName == 'curveMembers',
|
||||||
'localName should be curveMember or curveMembers');
|
'localName should be curveMember or curveMembers');
|
||||||
ol.xml.parseNode(this.CURVEMEMBER_PARSERS_, node, objectStack, this);
|
ol.xml.parseNode(this.CURVEMEMBER_PARSERS_, node, objectStack, this);
|
||||||
@@ -155,9 +154,9 @@ ol.format.GML3.prototype.curveMemberParser_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.GML3.prototype.surfaceMemberParser_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'surfaceMember' ||
|
ol.DEBUG && console.assert(node.localName == 'surfaceMember' ||
|
||||||
node.localName == 'surfaceMembers',
|
node.localName == 'surfaceMembers',
|
||||||
'localName should be surfaceMember or surfaceMembers');
|
'localName should be surfaceMember or surfaceMembers');
|
||||||
ol.xml.parseNode(this.SURFACEMEMBER_PARSERS_,
|
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.
|
* @return {Array.<(Array.<number>)>|undefined} flat coordinates.
|
||||||
*/
|
*/
|
||||||
ol.format.GML3.prototype.readPatch_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'patches',
|
ol.DEBUG && console.assert(node.localName == 'patches',
|
||||||
'localName should be patches');
|
'localName should be patches');
|
||||||
return ol.xml.pushParseAndPop([null],
|
return ol.xml.pushParseAndPop([null],
|
||||||
this.PATCHES_PARSERS_, node, objectStack, this);
|
this.PATCHES_PARSERS_, node, objectStack, this);
|
||||||
@@ -188,9 +187,9 @@ ol.format.GML3.prototype.readPatch_ = function(node, objectStack) {
|
|||||||
* @return {Array.<number>|undefined} flat coordinates.
|
* @return {Array.<number>|undefined} flat coordinates.
|
||||||
*/
|
*/
|
||||||
ol.format.GML3.prototype.readSegment_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'segments',
|
ol.DEBUG && console.assert(node.localName == 'segments',
|
||||||
'localName should be segments');
|
'localName should be segments');
|
||||||
return ol.xml.pushParseAndPop([null],
|
return ol.xml.pushParseAndPop([null],
|
||||||
this.SEGMENTS_PARSERS_, node, objectStack, this);
|
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.
|
* @return {Array.<(Array.<number>)>|undefined} flat coordinates.
|
||||||
*/
|
*/
|
||||||
ol.format.GML3.prototype.readPolygonPatch_ = function(node, objectStack) {
|
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');
|
'npde.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'PolygonPatch',
|
ol.DEBUG && console.assert(node.localName == 'PolygonPatch',
|
||||||
'localName should be PolygonPatch');
|
'localName should be PolygonPatch');
|
||||||
return ol.xml.pushParseAndPop([null],
|
return ol.xml.pushParseAndPop([null],
|
||||||
this.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack, this);
|
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.
|
* @return {Array.<number>|undefined} flat coordinates.
|
||||||
*/
|
*/
|
||||||
ol.format.GML3.prototype.readLineStringSegment_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'LineStringSegment',
|
ol.DEBUG && console.assert(node.localName == 'LineStringSegment',
|
||||||
'localName should be LineStringSegment');
|
'localName should be LineStringSegment');
|
||||||
return ol.xml.pushParseAndPop([null],
|
return ol.xml.pushParseAndPop([null],
|
||||||
this.GEOMETRY_FLAT_COORDINATES_PARSERS_,
|
this.GEOMETRY_FLAT_COORDINATES_PARSERS_,
|
||||||
@@ -236,9 +235,9 @@ ol.format.GML3.prototype.readLineStringSegment_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.GML3.prototype.interiorParser_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'interior',
|
ol.DEBUG && console.assert(node.localName == 'interior',
|
||||||
'localName should be interior');
|
'localName should be interior');
|
||||||
/** @type {Array.<number>|undefined} */
|
/** @type {Array.<number>|undefined} */
|
||||||
var flatLinearRing = ol.xml.pushParseAndPop(undefined,
|
var flatLinearRing = ol.xml.pushParseAndPop(undefined,
|
||||||
@@ -246,9 +245,9 @@ ol.format.GML3.prototype.interiorParser_ = function(node, objectStack) {
|
|||||||
if (flatLinearRing) {
|
if (flatLinearRing) {
|
||||||
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
||||||
(objectStack[objectStack.length - 1]);
|
(objectStack[objectStack.length - 1]);
|
||||||
goog.asserts.assert(Array.isArray(flatLinearRings),
|
ol.DEBUG && console.assert(Array.isArray(flatLinearRings),
|
||||||
'flatLinearRings should be an array');
|
'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 should have an array length of 1 or more');
|
||||||
flatLinearRings.push(flatLinearRing);
|
flatLinearRings.push(flatLinearRing);
|
||||||
}
|
}
|
||||||
@@ -261,9 +260,9 @@ ol.format.GML3.prototype.interiorParser_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.GML3.prototype.exteriorParser_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'exterior',
|
ol.DEBUG && console.assert(node.localName == 'exterior',
|
||||||
'localName should be exterior');
|
'localName should be exterior');
|
||||||
/** @type {Array.<number>|undefined} */
|
/** @type {Array.<number>|undefined} */
|
||||||
var flatLinearRing = ol.xml.pushParseAndPop(undefined,
|
var flatLinearRing = ol.xml.pushParseAndPop(undefined,
|
||||||
@@ -271,9 +270,9 @@ ol.format.GML3.prototype.exteriorParser_ = function(node, objectStack) {
|
|||||||
if (flatLinearRing) {
|
if (flatLinearRing) {
|
||||||
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
||||||
(objectStack[objectStack.length - 1]);
|
(objectStack[objectStack.length - 1]);
|
||||||
goog.asserts.assert(Array.isArray(flatLinearRings),
|
ol.DEBUG && console.assert(Array.isArray(flatLinearRings),
|
||||||
'flatLinearRings should be an array');
|
'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 should have an array length of 1 or more');
|
||||||
flatLinearRings[0] = flatLinearRing;
|
flatLinearRings[0] = flatLinearRing;
|
||||||
}
|
}
|
||||||
@@ -287,9 +286,9 @@ ol.format.GML3.prototype.exteriorParser_ = function(node, objectStack) {
|
|||||||
* @return {ol.geom.Polygon|undefined} Polygon.
|
* @return {ol.geom.Polygon|undefined} Polygon.
|
||||||
*/
|
*/
|
||||||
ol.format.GML3.prototype.readSurface_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'Surface',
|
ol.DEBUG && console.assert(node.localName == 'Surface',
|
||||||
'localName should be Surface');
|
'localName should be Surface');
|
||||||
/** @type {Array.<Array.<number>>} */
|
/** @type {Array.<Array.<number>>} */
|
||||||
var flatLinearRings = ol.xml.pushParseAndPop([null],
|
var flatLinearRings = ol.xml.pushParseAndPop([null],
|
||||||
@@ -319,9 +318,9 @@ ol.format.GML3.prototype.readSurface_ = function(node, objectStack) {
|
|||||||
* @return {ol.geom.LineString|undefined} LineString.
|
* @return {ol.geom.LineString|undefined} LineString.
|
||||||
*/
|
*/
|
||||||
ol.format.GML3.prototype.readCurve_ = function(node, objectStack) {
|
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');
|
'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>} */
|
/** @type {Array.<number>} */
|
||||||
var flatCoordinates = ol.xml.pushParseAndPop([null],
|
var flatCoordinates = ol.xml.pushParseAndPop([null],
|
||||||
this.CURVE_PARSERS_, node, objectStack, this);
|
this.CURVE_PARSERS_, node, objectStack, this);
|
||||||
@@ -342,9 +341,9 @@ ol.format.GML3.prototype.readCurve_ = function(node, objectStack) {
|
|||||||
* @return {ol.Extent|undefined} Envelope.
|
* @return {ol.Extent|undefined} Envelope.
|
||||||
*/
|
*/
|
||||||
ol.format.GML3.prototype.readEnvelope_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'Envelope',
|
ol.DEBUG && console.assert(node.localName == 'Envelope',
|
||||||
'localName should be Envelope');
|
'localName should be Envelope');
|
||||||
/** @type {Array.<number>} */
|
/** @type {Array.<number>} */
|
||||||
var flatCoordinates = ol.xml.pushParseAndPop([null],
|
var flatCoordinates = ol.xml.pushParseAndPop([null],
|
||||||
@@ -375,7 +374,6 @@ ol.format.GML3.prototype.readFlatPos_ = function(node, objectStack) {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
var context = objectStack[0];
|
var context = objectStack[0];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var containerSrs = context['srsName'];
|
var containerSrs = context['srsName'];
|
||||||
var axisOrientation = 'enu';
|
var axisOrientation = 'enu';
|
||||||
if (containerSrs) {
|
if (containerSrs) {
|
||||||
@@ -411,7 +409,6 @@ ol.format.GML3.prototype.readFlatPos_ = function(node, objectStack) {
|
|||||||
ol.format.GML3.prototype.readFlatPosList_ = function(node, objectStack) {
|
ol.format.GML3.prototype.readFlatPosList_ = function(node, objectStack) {
|
||||||
var s = ol.xml.getAllTextContent(node, false).replace(/^\s*|\s*$/g, '');
|
var s = ol.xml.getAllTextContent(node, false).replace(/^\s*|\s*$/g, '');
|
||||||
var context = objectStack[0];
|
var context = objectStack[0];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var containerSrs = context['srsName'];
|
var containerSrs = context['srsName'];
|
||||||
var containerDimension = node.parentNode.getAttribute('srsDimension');
|
var containerDimension = node.parentNode.getAttribute('srsDimension');
|
||||||
var axisOrientation = 'enu';
|
var axisOrientation = 'enu';
|
||||||
@@ -633,7 +630,6 @@ ol.format.GML3.prototype.SEGMENTS_PARSERS_ = {
|
|||||||
*/
|
*/
|
||||||
ol.format.GML3.prototype.writePos_ = function(node, value, objectStack) {
|
ol.format.GML3.prototype.writePos_ = function(node, value, objectStack) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var srsName = context['srsName'];
|
var srsName = context['srsName'];
|
||||||
var axisOrientation = 'enu';
|
var axisOrientation = 'enu';
|
||||||
if (srsName) {
|
if (srsName) {
|
||||||
@@ -676,7 +672,6 @@ ol.format.GML3.prototype.getCoords_ = function(point, opt_srsName) {
|
|||||||
*/
|
*/
|
||||||
ol.format.GML3.prototype.writePosList_ = function(node, value, objectStack) {
|
ol.format.GML3.prototype.writePosList_ = function(node, value, objectStack) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var srsName = context['srsName'];
|
var srsName = context['srsName'];
|
||||||
// only 2d for simple features profile
|
// only 2d for simple features profile
|
||||||
var points = value.getCoordinates();
|
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) {
|
ol.format.GML3.prototype.writePoint_ = function(node, geometry, objectStack) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var srsName = context['srsName'];
|
var srsName = context['srsName'];
|
||||||
if (srsName) {
|
if (srsName) {
|
||||||
node.setAttribute('srsName', srsName);
|
node.setAttribute('srsName', srsName);
|
||||||
@@ -728,9 +722,8 @@ ol.format.GML3.ENVELOPE_SERIALIZERS_ = {
|
|||||||
* @param {Array.<*>} objectStack Node stack.
|
* @param {Array.<*>} objectStack Node stack.
|
||||||
*/
|
*/
|
||||||
ol.format.GML3.prototype.writeEnvelope = function(node, extent, objectStack) {
|
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];
|
var context = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var srsName = context['srsName'];
|
var srsName = context['srsName'];
|
||||||
if (srsName) {
|
if (srsName) {
|
||||||
node.setAttribute('srsName', 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) {
|
ol.format.GML3.prototype.writeLinearRing_ = function(node, geometry, objectStack) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var srsName = context['srsName'];
|
var srsName = context['srsName'];
|
||||||
if (srsName) {
|
if (srsName) {
|
||||||
node.setAttribute('srsName', 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) {
|
ol.format.GML3.prototype.RING_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = objectStack[objectStack.length - 1];
|
||||||
var parentNode = context.node;
|
var parentNode = context.node;
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var exteriorWritten = context['exteriorWritten'];
|
var exteriorWritten = context['exteriorWritten'];
|
||||||
if (exteriorWritten === undefined) {
|
if (exteriorWritten === undefined) {
|
||||||
context['exteriorWritten'] = true;
|
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) {
|
ol.format.GML3.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objectStack) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var srsName = context['srsName'];
|
var srsName = context['srsName'];
|
||||||
if (node.nodeName !== 'PolygonPatch' && srsName) {
|
if (node.nodeName !== 'PolygonPatch' && srsName) {
|
||||||
node.setAttribute('srsName', 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) {
|
ol.format.GML3.prototype.writeCurveOrLineString_ = function(node, geometry, objectStack) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var srsName = context['srsName'];
|
var srsName = context['srsName'];
|
||||||
if (node.nodeName !== 'LineStringSegment' && srsName) {
|
if (node.nodeName !== 'LineStringSegment' && srsName) {
|
||||||
node.setAttribute('srsName', 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) {
|
ol.format.GML3.prototype.writeMultiSurfaceOrPolygon_ = function(node, geometry, objectStack) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var srsName = context['srsName'];
|
var srsName = context['srsName'];
|
||||||
var surface = context['surface'];
|
var surface = context['surface'];
|
||||||
if (srsName) {
|
if (srsName) {
|
||||||
@@ -871,7 +859,6 @@ ol.format.GML3.prototype.writeMultiSurfaceOrPolygon_ = function(node, geometry,
|
|||||||
ol.format.GML3.prototype.writeMultiPoint_ = function(node, geometry,
|
ol.format.GML3.prototype.writeMultiPoint_ = function(node, geometry,
|
||||||
objectStack) {
|
objectStack) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var srsName = context['srsName'];
|
var srsName = context['srsName'];
|
||||||
if (srsName) {
|
if (srsName) {
|
||||||
node.setAttribute('srsName', 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) {
|
ol.format.GML3.prototype.writeMultiCurveOrLineString_ = function(node, geometry, objectStack) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var srsName = context['srsName'];
|
var srsName = context['srsName'];
|
||||||
var curve = context['curve'];
|
var curve = context['curve'];
|
||||||
if (srsName) {
|
if (srsName) {
|
||||||
@@ -927,7 +913,6 @@ ol.format.GML3.prototype.writeRing_ = function(node, ring, objectStack) {
|
|||||||
*/
|
*/
|
||||||
ol.format.GML3.prototype.writeSurfaceOrPolygonMember_ = function(node, polygon, objectStack) {
|
ol.format.GML3.prototype.writeSurfaceOrPolygonMember_ = function(node, polygon, objectStack) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var child = this.GEOMETRY_NODE_FACTORY_(
|
var child = this.GEOMETRY_NODE_FACTORY_(
|
||||||
polygon, objectStack);
|
polygon, objectStack);
|
||||||
if (child) {
|
if (child) {
|
||||||
@@ -958,7 +943,6 @@ ol.format.GML3.prototype.writePointMember_ = function(node, point, objectStack)
|
|||||||
*/
|
*/
|
||||||
ol.format.GML3.prototype.writeLineStringOrCurveMember_ = function(node, line, objectStack) {
|
ol.format.GML3.prototype.writeLineStringOrCurveMember_ = function(node, line, objectStack) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
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);
|
var child = this.GEOMETRY_NODE_FACTORY_(line, objectStack);
|
||||||
if (child) {
|
if (child) {
|
||||||
node.appendChild(child);
|
node.appendChild(child);
|
||||||
@@ -1000,8 +984,7 @@ ol.format.GML3.prototype.writeCurveSegments_ = function(node, line, objectStack)
|
|||||||
* @param {Array.<*>} objectStack Node stack.
|
* @param {Array.<*>} objectStack Node stack.
|
||||||
*/
|
*/
|
||||||
ol.format.GML3.prototype.writeGeometryElement = function(node, geometry, objectStack) {
|
ol.format.GML3.prototype.writeGeometryElement = function(node, geometry, objectStack) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = /** @type {olx.format.WriteOptions} */ (objectStack[objectStack.length - 1]);
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var item = ol.object.assign({}, context);
|
var item = ol.object.assign({}, context);
|
||||||
item.node = node;
|
item.node = node;
|
||||||
var value;
|
var value;
|
||||||
@@ -1013,10 +996,8 @@ ol.format.GML3.prototype.writeGeometryElement = function(node, geometry, objectS
|
|||||||
value = geometry;
|
value = geometry;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.Geometry,
|
|
||||||
'geometry should be an ol.geom.Geometry');
|
|
||||||
value =
|
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} */
|
ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */
|
||||||
(item), ol.format.GML3.GEOMETRY_SERIALIZERS_,
|
(item), ol.format.GML3.GEOMETRY_SERIALIZERS_,
|
||||||
@@ -1035,8 +1016,7 @@ ol.format.GML3.prototype.writeFeatureElement = function(node, feature, objectSta
|
|||||||
if (fid) {
|
if (fid) {
|
||||||
node.setAttribute('fid', fid);
|
node.setAttribute('fid', fid);
|
||||||
}
|
}
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var featureNS = context['featureNS'];
|
var featureNS = context['featureNS'];
|
||||||
var geometryName = feature.getGeometryName();
|
var geometryName = feature.getGeometryName();
|
||||||
if (!context.serializers) {
|
if (!context.serializers) {
|
||||||
@@ -1080,8 +1060,7 @@ ol.format.GML3.prototype.writeFeatureElement = function(node, feature, objectSta
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.GML3.prototype.writeFeatureMembers_ = function(node, features, objectStack) {
|
ol.format.GML3.prototype.writeFeatureMembers_ = function(node, features, objectStack) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var featureType = context['featureType'];
|
var featureType = context['featureType'];
|
||||||
var featureNS = context['featureNS'];
|
var featureNS = context['featureNS'];
|
||||||
var serializers = {};
|
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) {
|
ol.format.GML3.prototype.MULTIGEOMETRY_MEMBER_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) {
|
||||||
var parentNode = objectStack[objectStack.length - 1].node;
|
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');
|
'parentNode should be a node');
|
||||||
return ol.xml.createElementNS('http://www.opengis.net/gml',
|
return ol.xml.createElementNS('http://www.opengis.net/gml',
|
||||||
ol.format.GML3.MULTIGEOMETRY_TO_MEMBER_NODENAME_[parentNode.nodeName]);
|
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) {
|
ol.format.GML3.prototype.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var multiSurface = context['multiSurface'];
|
var multiSurface = context['multiSurface'];
|
||||||
var surface = context['surface'];
|
var surface = context['surface'];
|
||||||
var curve = context['curve'];
|
var curve = context['curve'];
|
||||||
var multiCurve = context['multiCurve'];
|
var multiCurve = context['multiCurve'];
|
||||||
var parentNode = objectStack[objectStack.length - 1].node;
|
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');
|
'parentNode should be a node');
|
||||||
var nodeName;
|
var nodeName;
|
||||||
if (!Array.isArray(value)) {
|
if (!Array.isArray(value)) {
|
||||||
goog.asserts.assertInstanceof(value, ol.geom.Geometry,
|
nodeName = /** @type {ol.geom.Geometry} */ (value).getType();
|
||||||
'value should be an ol.geom.Geometry');
|
|
||||||
nodeName = value.getType();
|
|
||||||
if (nodeName === 'MultiPolygon' && multiSurface === true) {
|
if (nodeName === 'MultiPolygon' && multiSurface === true) {
|
||||||
nodeName = 'MultiSurface';
|
nodeName = 'MultiSurface';
|
||||||
} else if (nodeName === 'Polygon' && surface === true) {
|
} else if (nodeName === 'Polygon' && surface === true) {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
// envelopes/extents, only geometries!
|
// envelopes/extents, only geometries!
|
||||||
goog.provide('ol.format.GMLBase');
|
goog.provide('ol.format.GMLBase');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
goog.require('ol.format.Feature');
|
goog.require('ol.format.Feature');
|
||||||
@@ -108,7 +107,7 @@ ol.format.GMLBase.ONLY_WHITESPACE_RE_ = /^[\s\xa0]*$/;
|
|||||||
* @return {Array.<ol.Feature> | undefined} Features.
|
* @return {Array.<ol.Feature> | undefined} Features.
|
||||||
*/
|
*/
|
||||||
ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
var localName = node.localName;
|
var localName = node.localName;
|
||||||
var features = null;
|
var features = null;
|
||||||
@@ -124,7 +123,6 @@ ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) {
|
|||||||
}
|
}
|
||||||
} else if (localName == 'featureMembers' || localName == 'featureMember') {
|
} else if (localName == 'featureMembers' || localName == 'featureMember') {
|
||||||
var context = objectStack[0];
|
var context = objectStack[0];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var featureType = context['featureType'];
|
var featureType = context['featureType'];
|
||||||
var featureNS = context['featureNS'];
|
var featureNS = context['featureNS'];
|
||||||
var i, ii, prefix = 'p', defaultPrefix = 'p0';
|
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.
|
* @return {ol.geom.Geometry|undefined} Geometry.
|
||||||
*/
|
*/
|
||||||
ol.format.GMLBase.prototype.readGeometryElement = function(node, objectStack) {
|
ol.format.GMLBase.prototype.readGeometryElement = function(node, objectStack) {
|
||||||
var context = objectStack[0];
|
var context = /** @type {Object} */ (objectStack[0]);
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
context['srsName'] = node.firstElementChild.getAttribute('srsName');
|
context['srsName'] = node.firstElementChild.getAttribute('srsName');
|
||||||
/** @type {ol.geom.Geometry} */
|
/** @type {ol.geom.Geometry} */
|
||||||
var geometry = ol.xml.pushParseAndPop(null,
|
var geometry = ol.xml.pushParseAndPop(null,
|
||||||
@@ -262,14 +259,14 @@ ol.format.GMLBase.prototype.readFeatureElement = function(node, objectStack) {
|
|||||||
* @return {ol.geom.Point|undefined} Point.
|
* @return {ol.geom.Point|undefined} Point.
|
||||||
*/
|
*/
|
||||||
ol.format.GMLBase.prototype.readPoint = function(node, objectStack) {
|
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');
|
'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 =
|
var flatCoordinates =
|
||||||
this.readFlatCoordinatesFromNode_(node, objectStack);
|
this.readFlatCoordinatesFromNode_(node, objectStack);
|
||||||
if (flatCoordinates) {
|
if (flatCoordinates) {
|
||||||
var point = new ol.geom.Point(null);
|
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');
|
'flatCoordinates should have a length of 3');
|
||||||
point.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates);
|
point.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates);
|
||||||
return point;
|
return point;
|
||||||
@@ -283,9 +280,9 @@ ol.format.GMLBase.prototype.readPoint = function(node, objectStack) {
|
|||||||
* @return {ol.geom.MultiPoint|undefined} MultiPoint.
|
* @return {ol.geom.MultiPoint|undefined} MultiPoint.
|
||||||
*/
|
*/
|
||||||
ol.format.GMLBase.prototype.readMultiPoint = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'MultiPoint',
|
ol.DEBUG && console.assert(node.localName == 'MultiPoint',
|
||||||
'localName should be MultiPoint');
|
'localName should be MultiPoint');
|
||||||
/** @type {Array.<Array.<number>>} */
|
/** @type {Array.<Array.<number>>} */
|
||||||
var coordinates = ol.xml.pushParseAndPop([],
|
var coordinates = ol.xml.pushParseAndPop([],
|
||||||
@@ -304,9 +301,9 @@ ol.format.GMLBase.prototype.readMultiPoint = function(node, objectStack) {
|
|||||||
* @return {ol.geom.MultiLineString|undefined} MultiLineString.
|
* @return {ol.geom.MultiLineString|undefined} MultiLineString.
|
||||||
*/
|
*/
|
||||||
ol.format.GMLBase.prototype.readMultiLineString = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'MultiLineString',
|
ol.DEBUG && console.assert(node.localName == 'MultiLineString',
|
||||||
'localName should be MultiLineString');
|
'localName should be MultiLineString');
|
||||||
/** @type {Array.<ol.geom.LineString>} */
|
/** @type {Array.<ol.geom.LineString>} */
|
||||||
var lineStrings = ol.xml.pushParseAndPop([],
|
var lineStrings = ol.xml.pushParseAndPop([],
|
||||||
@@ -327,9 +324,9 @@ ol.format.GMLBase.prototype.readMultiLineString = function(node, objectStack) {
|
|||||||
* @return {ol.geom.MultiPolygon|undefined} MultiPolygon.
|
* @return {ol.geom.MultiPolygon|undefined} MultiPolygon.
|
||||||
*/
|
*/
|
||||||
ol.format.GMLBase.prototype.readMultiPolygon = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'MultiPolygon',
|
ol.DEBUG && console.assert(node.localName == 'MultiPolygon',
|
||||||
'localName should be MultiPolygon');
|
'localName should be MultiPolygon');
|
||||||
/** @type {Array.<ol.geom.Polygon>} */
|
/** @type {Array.<ol.geom.Polygon>} */
|
||||||
var polygons = ol.xml.pushParseAndPop([],
|
var polygons = ol.xml.pushParseAndPop([],
|
||||||
@@ -350,9 +347,9 @@ ol.format.GMLBase.prototype.readMultiPolygon = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.GMLBase.prototype.pointMemberParser_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'pointMember' ||
|
ol.DEBUG && console.assert(node.localName == 'pointMember' ||
|
||||||
node.localName == 'pointMembers',
|
node.localName == 'pointMembers',
|
||||||
'localName should be pointMember or pointMembers');
|
'localName should be pointMember or pointMembers');
|
||||||
ol.xml.parseNode(this.POINTMEMBER_PARSERS_,
|
ol.xml.parseNode(this.POINTMEMBER_PARSERS_,
|
||||||
@@ -366,9 +363,9 @@ ol.format.GMLBase.prototype.pointMemberParser_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.GMLBase.prototype.lineStringMemberParser_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'lineStringMember' ||
|
ol.DEBUG && console.assert(node.localName == 'lineStringMember' ||
|
||||||
node.localName == 'lineStringMembers',
|
node.localName == 'lineStringMembers',
|
||||||
'localName should be LineStringMember or LineStringMembers');
|
'localName should be LineStringMember or LineStringMembers');
|
||||||
ol.xml.parseNode(this.LINESTRINGMEMBER_PARSERS_,
|
ol.xml.parseNode(this.LINESTRINGMEMBER_PARSERS_,
|
||||||
@@ -382,9 +379,9 @@ ol.format.GMLBase.prototype.lineStringMemberParser_ = function(node, objectStack
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.GMLBase.prototype.polygonMemberParser_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'polygonMember' ||
|
ol.DEBUG && console.assert(node.localName == 'polygonMember' ||
|
||||||
node.localName == 'polygonMembers',
|
node.localName == 'polygonMembers',
|
||||||
'localName should be polygonMember or polygonMembers');
|
'localName should be polygonMember or polygonMembers');
|
||||||
ol.xml.parseNode(this.POLYGONMEMBER_PARSERS_, node,
|
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.
|
* @return {ol.geom.LineString|undefined} LineString.
|
||||||
*/
|
*/
|
||||||
ol.format.GMLBase.prototype.readLineString = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'LineString',
|
ol.DEBUG && console.assert(node.localName == 'LineString',
|
||||||
'localName should be LineString');
|
'localName should be LineString');
|
||||||
var flatCoordinates =
|
var flatCoordinates =
|
||||||
this.readFlatCoordinatesFromNode_(node, objectStack);
|
this.readFlatCoordinatesFromNode_(node, objectStack);
|
||||||
@@ -421,9 +418,9 @@ ol.format.GMLBase.prototype.readLineString = function(node, objectStack) {
|
|||||||
* @return {Array.<number>|undefined} LinearRing flat coordinates.
|
* @return {Array.<number>|undefined} LinearRing flat coordinates.
|
||||||
*/
|
*/
|
||||||
ol.format.GMLBase.prototype.readFlatLinearRing_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'LinearRing',
|
ol.DEBUG && console.assert(node.localName == 'LinearRing',
|
||||||
'localName should be LinearRing');
|
'localName should be LinearRing');
|
||||||
var ring = ol.xml.pushParseAndPop(null,
|
var ring = ol.xml.pushParseAndPop(null,
|
||||||
this.GEOMETRY_FLAT_COORDINATES_PARSERS_, node,
|
this.GEOMETRY_FLAT_COORDINATES_PARSERS_, node,
|
||||||
@@ -442,9 +439,9 @@ ol.format.GMLBase.prototype.readFlatLinearRing_ = function(node, objectStack) {
|
|||||||
* @return {ol.geom.LinearRing|undefined} LinearRing.
|
* @return {ol.geom.LinearRing|undefined} LinearRing.
|
||||||
*/
|
*/
|
||||||
ol.format.GMLBase.prototype.readLinearRing = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'LinearRing',
|
ol.DEBUG && console.assert(node.localName == 'LinearRing',
|
||||||
'localName should be LinearRing');
|
'localName should be LinearRing');
|
||||||
var flatCoordinates =
|
var flatCoordinates =
|
||||||
this.readFlatCoordinatesFromNode_(node, objectStack);
|
this.readFlatCoordinatesFromNode_(node, objectStack);
|
||||||
@@ -464,9 +461,9 @@ ol.format.GMLBase.prototype.readLinearRing = function(node, objectStack) {
|
|||||||
* @return {ol.geom.Polygon|undefined} Polygon.
|
* @return {ol.geom.Polygon|undefined} Polygon.
|
||||||
*/
|
*/
|
||||||
ol.format.GMLBase.prototype.readPolygon = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'Polygon',
|
ol.DEBUG && console.assert(node.localName == 'Polygon',
|
||||||
'localName should be Polygon');
|
'localName should be Polygon');
|
||||||
/** @type {Array.<Array.<number>>} */
|
/** @type {Array.<Array.<number>>} */
|
||||||
var flatLinearRings = ol.xml.pushParseAndPop([null],
|
var flatLinearRings = ol.xml.pushParseAndPop([null],
|
||||||
@@ -496,7 +493,7 @@ ol.format.GMLBase.prototype.readPolygon = function(node, objectStack) {
|
|||||||
* @return {Array.<number>} Flat coordinates.
|
* @return {Array.<number>} Flat coordinates.
|
||||||
*/
|
*/
|
||||||
ol.format.GMLBase.prototype.readFlatCoordinatesFromNode_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
return ol.xml.pushParseAndPop(null,
|
return ol.xml.pushParseAndPop(null,
|
||||||
this.GEOMETRY_FLAT_COORDINATES_PARSERS_, node,
|
this.GEOMETRY_FLAT_COORDINATES_PARSERS_, node,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.format.GPX');
|
goog.provide('ol.format.GPX');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
goog.require('ol.format.Feature');
|
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.
|
* @return {Array.<number>} Flat coordinates.
|
||||||
*/
|
*/
|
||||||
ol.format.GPX.appendCoordinate_ = function(flatCoordinates, node, values) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
flatCoordinates.push(
|
flatCoordinates.push(
|
||||||
parseFloat(node.getAttribute('lon')),
|
parseFloat(node.getAttribute('lon')),
|
||||||
@@ -99,9 +98,9 @@ ol.format.GPX.appendCoordinate_ = function(flatCoordinates, node, values) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.GPX.parseLink_ = function(node, objectStack) {
|
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');
|
'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 values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||||
var href = node.getAttribute('href');
|
var href = node.getAttribute('href');
|
||||||
if (href !== null) {
|
if (href !== null) {
|
||||||
@@ -117,9 +116,9 @@ ol.format.GPX.parseLink_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.GPX.parseExtensions_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'extensions',
|
ol.DEBUG && console.assert(node.localName == 'extensions',
|
||||||
'localName should be extensions');
|
'localName should be extensions');
|
||||||
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||||
values['extensionsNode_'] = node;
|
values['extensionsNode_'] = node;
|
||||||
@@ -132,9 +131,9 @@ ol.format.GPX.parseExtensions_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.GPX.parseRtePt_ = function(node, objectStack) {
|
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');
|
'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(
|
var values = ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.GPX.RTEPT_PARSERS_, node, objectStack);
|
{}, ol.format.GPX.RTEPT_PARSERS_, node, objectStack);
|
||||||
if (values) {
|
if (values) {
|
||||||
@@ -152,9 +151,9 @@ ol.format.GPX.parseRtePt_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.GPX.parseTrkPt_ = function(node, objectStack) {
|
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');
|
'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(
|
var values = ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.GPX.TRKPT_PARSERS_, node, objectStack);
|
{}, ol.format.GPX.TRKPT_PARSERS_, node, objectStack);
|
||||||
if (values) {
|
if (values) {
|
||||||
@@ -172,9 +171,9 @@ ol.format.GPX.parseTrkPt_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.GPX.parseTrkSeg_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'trkseg',
|
ol.DEBUG && console.assert(node.localName == 'trkseg',
|
||||||
'localName should be trkseg');
|
'localName should be trkseg');
|
||||||
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||||
ol.xml.parseNode(ol.format.GPX.TRKSEG_PARSERS_, node, objectStack);
|
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.
|
* @return {ol.Feature|undefined} Track.
|
||||||
*/
|
*/
|
||||||
ol.format.GPX.readRte_ = function(node, objectStack) {
|
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');
|
'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 options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
|
||||||
var values = ol.xml.pushParseAndPop({
|
var values = ol.xml.pushParseAndPop({
|
||||||
'flatCoordinates': []
|
'flatCoordinates': []
|
||||||
@@ -221,9 +220,9 @@ ol.format.GPX.readRte_ = function(node, objectStack) {
|
|||||||
* @return {ol.Feature|undefined} Track.
|
* @return {ol.Feature|undefined} Track.
|
||||||
*/
|
*/
|
||||||
ol.format.GPX.readTrk_ = function(node, objectStack) {
|
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');
|
'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 options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
|
||||||
var values = ol.xml.pushParseAndPop({
|
var values = ol.xml.pushParseAndPop({
|
||||||
'flatCoordinates': [],
|
'flatCoordinates': [],
|
||||||
@@ -254,9 +253,9 @@ ol.format.GPX.readTrk_ = function(node, objectStack) {
|
|||||||
* @return {ol.Feature|undefined} Waypoint.
|
* @return {ol.Feature|undefined} Waypoint.
|
||||||
*/
|
*/
|
||||||
ol.format.GPX.readWpt_ = function(node, objectStack) {
|
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');
|
'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 options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
|
||||||
var values = ol.xml.pushParseAndPop(
|
var values = ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.GPX.WPT_PARSERS_, node, objectStack);
|
{}, ol.format.GPX.WPT_PARSERS_, node, objectStack);
|
||||||
@@ -456,7 +455,7 @@ ol.format.GPX.prototype.readFeature;
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.format.GPX.prototype.readFeatureFromNode = function(node, opt_options) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
if (!ol.array.includes(ol.format.GPX.NAMESPACE_URIS_, node.namespaceURI)) {
|
if (!ol.array.includes(ol.format.GPX.NAMESPACE_URIS_, node.namespaceURI)) {
|
||||||
return null;
|
return null;
|
||||||
@@ -492,7 +491,7 @@ ol.format.GPX.prototype.readFeatures;
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.format.GPX.prototype.readFeaturesFromNode = function(node, opt_options) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
if (!ol.array.includes(ol.format.GPX.NAMESPACE_URIS_, node.namespaceURI)) {
|
if (!ol.array.includes(ol.format.GPX.NAMESPACE_URIS_, node.namespaceURI)) {
|
||||||
return [];
|
return [];
|
||||||
@@ -532,7 +531,6 @@ ol.format.GPX.prototype.readProjection;
|
|||||||
ol.format.GPX.writeLink_ = function(node, value, objectStack) {
|
ol.format.GPX.writeLink_ = function(node, value, objectStack) {
|
||||||
node.setAttribute('href', value);
|
node.setAttribute('href', value);
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var properties = context['properties'];
|
var properties = context['properties'];
|
||||||
var link = [
|
var link = [
|
||||||
properties['linkText'],
|
properties['linkText'],
|
||||||
@@ -552,9 +550,8 @@ ol.format.GPX.writeLink_ = function(node, value, objectStack) {
|
|||||||
*/
|
*/
|
||||||
ol.format.GPX.writeWptType_ = function(node, coordinate, objectStack) {
|
ol.format.GPX.writeWptType_ = function(node, coordinate, objectStack) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var parentNode = context.node;
|
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');
|
'parentNode should be an XML node');
|
||||||
var namespaceURI = parentNode.namespaceURI;
|
var namespaceURI = parentNode.namespaceURI;
|
||||||
var properties = context['properties'];
|
var properties = context['properties'];
|
||||||
@@ -604,8 +601,6 @@ ol.format.GPX.writeRte_ = function(node, feature, objectStack) {
|
|||||||
var context = {node: node, 'properties': properties};
|
var context = {node: node, 'properties': properties};
|
||||||
var geometry = feature.getGeometry();
|
var geometry = feature.getGeometry();
|
||||||
if (geometry) {
|
if (geometry) {
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.LineString,
|
|
||||||
'geometry should be an ol.geom.LineString');
|
|
||||||
geometry = /** @type {ol.geom.LineString} */
|
geometry = /** @type {ol.geom.LineString} */
|
||||||
(ol.format.Feature.transformWithOptions(geometry, true, options));
|
(ol.format.Feature.transformWithOptions(geometry, true, options));
|
||||||
context['geometryLayout'] = geometry.getLayout();
|
context['geometryLayout'] = geometry.getLayout();
|
||||||
@@ -633,8 +628,6 @@ ol.format.GPX.writeTrk_ = function(node, feature, objectStack) {
|
|||||||
var context = {node: node, 'properties': properties};
|
var context = {node: node, 'properties': properties};
|
||||||
var geometry = feature.getGeometry();
|
var geometry = feature.getGeometry();
|
||||||
if (geometry) {
|
if (geometry) {
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.MultiLineString,
|
|
||||||
'geometry should be an ol.geom.MultiLineString');
|
|
||||||
geometry = /** @type {ol.geom.MultiLineString} */
|
geometry = /** @type {ol.geom.MultiLineString} */
|
||||||
(ol.format.Feature.transformWithOptions(geometry, true, options));
|
(ol.format.Feature.transformWithOptions(geometry, true, options));
|
||||||
properties['trkseg'] = geometry.getLineStrings();
|
properties['trkseg'] = geometry.getLineStrings();
|
||||||
@@ -673,12 +666,9 @@ ol.format.GPX.writeTrkSeg_ = function(node, lineString, objectStack) {
|
|||||||
ol.format.GPX.writeWpt_ = function(node, feature, objectStack) {
|
ol.format.GPX.writeWpt_ = function(node, feature, objectStack) {
|
||||||
var options = /** @type {olx.format.WriteOptions} */ (objectStack[0]);
|
var options = /** @type {olx.format.WriteOptions} */ (objectStack[0]);
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
context['properties'] = feature.getProperties();
|
context['properties'] = feature.getProperties();
|
||||||
var geometry = feature.getGeometry();
|
var geometry = feature.getGeometry();
|
||||||
if (geometry) {
|
if (geometry) {
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.Point,
|
|
||||||
'geometry should be an ol.geom.Point');
|
|
||||||
geometry = /** @type {ol.geom.Point} */
|
geometry = /** @type {ol.geom.Point} */
|
||||||
(ol.format.Feature.transformWithOptions(geometry, true, options));
|
(ol.format.Feature.transformWithOptions(geometry, true, options));
|
||||||
context['geometryLayout'] = geometry.getLayout();
|
context['geometryLayout'] = geometry.getLayout();
|
||||||
@@ -863,14 +853,12 @@ ol.format.GPX.GEOMETRY_TYPE_TO_NODENAME_ = {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.GPX.GPX_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) {
|
ol.format.GPX.GPX_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) {
|
||||||
goog.asserts.assertInstanceof(value, ol.Feature,
|
var geometry = /** @type {ol.Feature} */ (value).getGeometry();
|
||||||
'value should be an ol.Feature');
|
|
||||||
var geometry = value.getGeometry();
|
|
||||||
if (geometry) {
|
if (geometry) {
|
||||||
var nodeName = ol.format.GPX.GEOMETRY_TYPE_TO_NODENAME_[geometry.getType()];
|
var nodeName = ol.format.GPX.GEOMETRY_TYPE_TO_NODENAME_[geometry.getType()];
|
||||||
if (nodeName) {
|
if (nodeName) {
|
||||||
var parentNode = objectStack[objectStack.length - 1].node;
|
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');
|
'parentNode should be an XML node');
|
||||||
return ol.xml.createElementNS(parentNode.namespaceURI, nodeName);
|
return ol.xml.createElementNS(parentNode.namespaceURI, nodeName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
goog.provide('ol.format.IGC');
|
goog.provide('ol.format.IGC');
|
||||||
goog.provide('ol.format.IGCZ');
|
goog.provide('ol.format.IGCZ');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
goog.require('ol.format.Feature');
|
goog.require('ol.format.Feature');
|
||||||
goog.require('ol.format.TextFeature');
|
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) {
|
} else if (altitudeMode == ol.format.IGCZ.BAROMETRIC) {
|
||||||
z = parseInt(m[12], 10);
|
z = parseInt(m[12], 10);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail();
|
ol.DEBUG && console.assert(false, 'Unknown altitude mode.');
|
||||||
z = 0;
|
z = 0;
|
||||||
}
|
}
|
||||||
flatCoordinates.push(z);
|
flatCoordinates.push(z);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.format.JSONFeature');
|
goog.provide('ol.format.JSONFeature');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.format.Feature');
|
goog.require('ol.format.Feature');
|
||||||
goog.require('ol.format.FormatType');
|
goog.require('ol.format.FormatType');
|
||||||
|
|
||||||
@@ -32,7 +31,6 @@ ol.format.JSONFeature.prototype.getObject_ = function(source) {
|
|||||||
} else if (source !== null) {
|
} else if (source !== null) {
|
||||||
return source;
|
return source;
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
goog.provide('ol.format.KML');
|
goog.provide('ol.format.KML');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('goog.object');
|
goog.require('goog.object');
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
@@ -543,9 +542,9 @@ ol.format.KML.readStyleMapValue_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.KML.IconStyleParser_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be an ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'IconStyle',
|
ol.DEBUG && console.assert(node.localName == 'IconStyle',
|
||||||
'localName should be IconStyle');
|
'localName should be IconStyle');
|
||||||
// FIXME refreshMode
|
// FIXME refreshMode
|
||||||
// FIXME refreshInterval
|
// FIXME refreshInterval
|
||||||
@@ -559,8 +558,6 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var styleObject = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
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 IconObject = 'Icon' in object ? object['Icon'] : {};
|
||||||
var src;
|
var src;
|
||||||
var href = /** @type {string|undefined} */
|
var href = /** @type {string|undefined} */
|
||||||
@@ -644,9 +641,9 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.KML.LabelStyleParser_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'LabelStyle',
|
ol.DEBUG && console.assert(node.localName == 'LabelStyle',
|
||||||
'localName should be LabelStyle');
|
'localName should be LabelStyle');
|
||||||
// FIXME colorMode
|
// FIXME colorMode
|
||||||
var object = ol.xml.pushParseAndPop(
|
var object = ol.xml.pushParseAndPop(
|
||||||
@@ -655,8 +652,6 @@ ol.format.KML.LabelStyleParser_ = function(node, objectStack) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var styleObject = objectStack[objectStack.length - 1];
|
var styleObject = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(styleObject),
|
|
||||||
'styleObject should be an Object');
|
|
||||||
var textStyle = new ol.style.Text({
|
var textStyle = new ol.style.Text({
|
||||||
fill: new ol.style.Fill({
|
fill: new ol.style.Fill({
|
||||||
color: /** @type {ol.Color} */
|
color: /** @type {ol.Color} */
|
||||||
@@ -675,9 +670,9 @@ ol.format.KML.LabelStyleParser_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.KML.LineStyleParser_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'LineStyle',
|
ol.DEBUG && console.assert(node.localName == 'LineStyle',
|
||||||
'localName should be LineStyle');
|
'localName should be LineStyle');
|
||||||
// FIXME colorMode
|
// FIXME colorMode
|
||||||
// FIXME gx:outerColor
|
// FIXME gx:outerColor
|
||||||
@@ -690,8 +685,6 @@ ol.format.KML.LineStyleParser_ = function(node, objectStack) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var styleObject = objectStack[objectStack.length - 1];
|
var styleObject = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(styleObject),
|
|
||||||
'styleObject should be an Object');
|
|
||||||
var strokeStyle = new ol.style.Stroke({
|
var strokeStyle = new ol.style.Stroke({
|
||||||
color: /** @type {ol.Color} */
|
color: /** @type {ol.Color} */
|
||||||
('color' in object ? object['color'] : ol.format.KML.DEFAULT_COLOR_),
|
('color' in object ? object['color'] : ol.format.KML.DEFAULT_COLOR_),
|
||||||
@@ -707,9 +700,9 @@ ol.format.KML.LineStyleParser_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.KML.PolyStyleParser_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'PolyStyle',
|
ol.DEBUG && console.assert(node.localName == 'PolyStyle',
|
||||||
'localName should be PolyStyle');
|
'localName should be PolyStyle');
|
||||||
// FIXME colorMode
|
// FIXME colorMode
|
||||||
var object = ol.xml.pushParseAndPop(
|
var object = ol.xml.pushParseAndPop(
|
||||||
@@ -718,8 +711,6 @@ ol.format.KML.PolyStyleParser_ = function(node, objectStack) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var styleObject = objectStack[objectStack.length - 1];
|
var styleObject = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(styleObject),
|
|
||||||
'styleObject should be an Object');
|
|
||||||
var fillStyle = new ol.style.Fill({
|
var fillStyle = new ol.style.Fill({
|
||||||
color: /** @type {ol.Color} */
|
color: /** @type {ol.Color} */
|
||||||
('color' in object ? object['color'] : ol.format.KML.DEFAULT_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.
|
* @return {Array.<number>} LinearRing flat coordinates.
|
||||||
*/
|
*/
|
||||||
ol.format.KML.readFlatLinearRing_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'LinearRing',
|
ol.DEBUG && console.assert(node.localName == 'LinearRing',
|
||||||
'localName should be LinearRing');
|
'localName should be LinearRing');
|
||||||
return ol.xml.pushParseAndPop(null,
|
return ol.xml.pushParseAndPop(null,
|
||||||
ol.format.KML.FLAT_LINEAR_RING_PARSERS_, node, objectStack);
|
ol.format.KML.FLAT_LINEAR_RING_PARSERS_, node, objectStack);
|
||||||
@@ -759,16 +750,14 @@ ol.format.KML.readFlatLinearRing_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.KML.gxCoordParser_ = function(node, objectStack) {
|
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');
|
'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),
|
ol.format.KML.GX_NAMESPACE_URIS_, node.namespaceURI),
|
||||||
'namespaceURI of the node should be known to the KML parser');
|
'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_} */
|
var gxTrackObject = /** @type {ol.KMLGxTrackObject_} */
|
||||||
(objectStack[objectStack.length - 1]);
|
(objectStack[objectStack.length - 1]);
|
||||||
goog.asserts.assert(goog.isObject(gxTrackObject),
|
|
||||||
'gxTrackObject should be an Object');
|
|
||||||
var flatCoordinates = gxTrackObject.flatCoordinates;
|
var flatCoordinates = gxTrackObject.flatCoordinates;
|
||||||
var s = ol.xml.getAllTextContent(node, false);
|
var s = ol.xml.getAllTextContent(node, false);
|
||||||
var re =
|
var re =
|
||||||
@@ -792,12 +781,12 @@ ol.format.KML.gxCoordParser_ = function(node, objectStack) {
|
|||||||
* @return {ol.geom.MultiLineString|undefined} MultiLineString.
|
* @return {ol.geom.MultiLineString|undefined} MultiLineString.
|
||||||
*/
|
*/
|
||||||
ol.format.KML.readGxMultiTrack_ = function(node, objectStack) {
|
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');
|
'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),
|
ol.format.KML.GX_NAMESPACE_URIS_, node.namespaceURI),
|
||||||
'namespaceURI of the node should be known to the KML parser');
|
'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');
|
'localName should be MultiTrack');
|
||||||
var lineStrings = ol.xml.pushParseAndPop([],
|
var lineStrings = ol.xml.pushParseAndPop([],
|
||||||
ol.format.KML.GX_MULTITRACK_GEOMETRY_PARSERS_, node, objectStack);
|
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.
|
* @return {ol.geom.LineString|undefined} LineString.
|
||||||
*/
|
*/
|
||||||
ol.format.KML.readGxTrack_ = function(node, objectStack) {
|
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');
|
'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),
|
ol.format.KML.GX_NAMESPACE_URIS_, node.namespaceURI),
|
||||||
'namespaceURI of the node should be known to the KML parser');
|
'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(
|
var gxTrackObject = ol.xml.pushParseAndPop(
|
||||||
/** @type {ol.KMLGxTrackObject_} */ ({
|
/** @type {ol.KMLGxTrackObject_} */ ({
|
||||||
flatCoordinates: [],
|
flatCoordinates: [],
|
||||||
@@ -833,7 +822,7 @@ ol.format.KML.readGxTrack_ = function(node, objectStack) {
|
|||||||
}
|
}
|
||||||
var flatCoordinates = gxTrackObject.flatCoordinates;
|
var flatCoordinates = gxTrackObject.flatCoordinates;
|
||||||
var whens = gxTrackObject.whens;
|
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 ' +
|
'the length of the flatCoordinates array divided by 4 should be the ' +
|
||||||
'length of the whens array');
|
'length of the whens array');
|
||||||
var i, ii;
|
var i, ii;
|
||||||
@@ -854,9 +843,9 @@ ol.format.KML.readGxTrack_ = function(node, objectStack) {
|
|||||||
* @return {Object} Icon object.
|
* @return {Object} Icon object.
|
||||||
*/
|
*/
|
||||||
ol.format.KML.readIcon_ = function(node, objectStack) {
|
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');
|
'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(
|
var iconObject = ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.KML.ICON_PARSERS_, node, objectStack);
|
{}, ol.format.KML.ICON_PARSERS_, node, objectStack);
|
||||||
if (iconObject) {
|
if (iconObject) {
|
||||||
@@ -874,7 +863,7 @@ ol.format.KML.readIcon_ = function(node, objectStack) {
|
|||||||
* @return {Array.<number>} Flat coordinates.
|
* @return {Array.<number>} Flat coordinates.
|
||||||
*/
|
*/
|
||||||
ol.format.KML.readFlatCoordinatesFromNode_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
return ol.xml.pushParseAndPop(null,
|
return ol.xml.pushParseAndPop(null,
|
||||||
ol.format.KML.GEOMETRY_FLAT_COORDINATES_PARSERS_, node, objectStack);
|
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.
|
* @return {ol.geom.LineString|undefined} LineString.
|
||||||
*/
|
*/
|
||||||
ol.format.KML.readLineString_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'LineString',
|
ol.DEBUG && console.assert(node.localName == 'LineString',
|
||||||
'localName should be LineString');
|
'localName should be LineString');
|
||||||
var properties = ol.xml.pushParseAndPop({},
|
var properties = ol.xml.pushParseAndPop({},
|
||||||
ol.format.KML.EXTRUDE_AND_ALTITUDE_MODE_PARSERS_, node,
|
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.
|
* @return {ol.geom.Polygon|undefined} Polygon.
|
||||||
*/
|
*/
|
||||||
ol.format.KML.readLinearRing_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'LinearRing',
|
ol.DEBUG && console.assert(node.localName == 'LinearRing',
|
||||||
'localName should be LinearRing');
|
'localName should be LinearRing');
|
||||||
var properties = ol.xml.pushParseAndPop({},
|
var properties = ol.xml.pushParseAndPop({},
|
||||||
ol.format.KML.EXTRUDE_AND_ALTITUDE_MODE_PARSERS_, node,
|
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.
|
* @return {ol.geom.Geometry} Geometry.
|
||||||
*/
|
*/
|
||||||
ol.format.KML.readMultiGeometry_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'MultiGeometry',
|
ol.DEBUG && console.assert(node.localName == 'MultiGeometry',
|
||||||
'localName should be MultiGeometry');
|
'localName should be MultiGeometry');
|
||||||
var geometries = ol.xml.pushParseAndPop([],
|
var geometries = ol.xml.pushParseAndPop([],
|
||||||
ol.format.KML.MULTI_GEOMETRY_PARSERS_, node, objectStack);
|
ol.format.KML.MULTI_GEOMETRY_PARSERS_, node, objectStack);
|
||||||
@@ -955,6 +944,8 @@ ol.format.KML.readMultiGeometry_ = function(node, objectStack) {
|
|||||||
if (geometries.length === 0) {
|
if (geometries.length === 0) {
|
||||||
return new ol.geom.GeometryCollection(geometries);
|
return new ol.geom.GeometryCollection(geometries);
|
||||||
}
|
}
|
||||||
|
/** @type {ol.geom.Geometry} */
|
||||||
|
var multiGeometry;
|
||||||
var homogeneous = true;
|
var homogeneous = true;
|
||||||
var type = geometries[0].getType();
|
var type = geometries[0].getType();
|
||||||
var geometry, i, ii;
|
var geometry, i, ii;
|
||||||
@@ -970,41 +961,34 @@ ol.format.KML.readMultiGeometry_ = function(node, objectStack) {
|
|||||||
var flatCoordinates;
|
var flatCoordinates;
|
||||||
if (type == ol.geom.GeometryType.POINT) {
|
if (type == ol.geom.GeometryType.POINT) {
|
||||||
var point = geometries[0];
|
var point = geometries[0];
|
||||||
goog.asserts.assertInstanceof(point, ol.geom.Point,
|
|
||||||
'point should be an ol.geom.Point');
|
|
||||||
layout = point.getLayout();
|
layout = point.getLayout();
|
||||||
flatCoordinates = point.getFlatCoordinates();
|
flatCoordinates = point.getFlatCoordinates();
|
||||||
for (i = 1, ii = geometries.length; i < ii; ++i) {
|
for (i = 1, ii = geometries.length; i < ii; ++i) {
|
||||||
geometry = geometries[i];
|
geometry = geometries[i];
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.Point,
|
ol.DEBUG && console.assert(geometry.getLayout() == layout,
|
||||||
'geometry should be an ol.geom.Point');
|
|
||||||
goog.asserts.assert(geometry.getLayout() == layout,
|
|
||||||
'geometry layout should be consistent');
|
'geometry layout should be consistent');
|
||||||
ol.array.extend(flatCoordinates, geometry.getFlatCoordinates());
|
ol.array.extend(flatCoordinates, geometry.getFlatCoordinates());
|
||||||
}
|
}
|
||||||
var multiPoint = new ol.geom.MultiPoint(null);
|
multiGeometry = new ol.geom.MultiPoint(null);
|
||||||
multiPoint.setFlatCoordinates(layout, flatCoordinates);
|
multiGeometry.setFlatCoordinates(layout, flatCoordinates);
|
||||||
ol.format.KML.setCommonGeometryProperties_(multiPoint, geometries);
|
ol.format.KML.setCommonGeometryProperties_(multiGeometry, geometries);
|
||||||
return multiPoint;
|
|
||||||
} else if (type == ol.geom.GeometryType.LINE_STRING) {
|
} else if (type == ol.geom.GeometryType.LINE_STRING) {
|
||||||
var multiLineString = new ol.geom.MultiLineString(null);
|
multiGeometry = new ol.geom.MultiLineString(null);
|
||||||
multiLineString.setLineStrings(geometries);
|
multiGeometry.setLineStrings(geometries);
|
||||||
ol.format.KML.setCommonGeometryProperties_(multiLineString, geometries);
|
ol.format.KML.setCommonGeometryProperties_(multiGeometry, geometries);
|
||||||
return multiLineString;
|
|
||||||
} else if (type == ol.geom.GeometryType.POLYGON) {
|
} else if (type == ol.geom.GeometryType.POLYGON) {
|
||||||
var multiPolygon = new ol.geom.MultiPolygon(null);
|
multiGeometry = new ol.geom.MultiPolygon(null);
|
||||||
multiPolygon.setPolygons(geometries);
|
multiGeometry.setPolygons(geometries);
|
||||||
ol.format.KML.setCommonGeometryProperties_(multiPolygon, geometries);
|
ol.format.KML.setCommonGeometryProperties_(multiGeometry, geometries);
|
||||||
return multiPolygon;
|
|
||||||
} else if (type == ol.geom.GeometryType.GEOMETRY_COLLECTION) {
|
} else if (type == ol.geom.GeometryType.GEOMETRY_COLLECTION) {
|
||||||
return new ol.geom.GeometryCollection(geometries);
|
multiGeometry = new ol.geom.GeometryCollection(geometries);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail('Unexpected type: ' + type);
|
ol.assert(false, 37); // Unknown geometry type found
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
} else {
|
} 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.
|
* @return {ol.geom.Point|undefined} Point.
|
||||||
*/
|
*/
|
||||||
ol.format.KML.readPoint_ = function(node, objectStack) {
|
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');
|
'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({},
|
var properties = ol.xml.pushParseAndPop({},
|
||||||
ol.format.KML.EXTRUDE_AND_ALTITUDE_MODE_PARSERS_, node,
|
ol.format.KML.EXTRUDE_AND_ALTITUDE_MODE_PARSERS_, node,
|
||||||
objectStack);
|
objectStack);
|
||||||
@@ -1025,7 +1009,7 @@ ol.format.KML.readPoint_ = function(node, objectStack) {
|
|||||||
ol.format.KML.readFlatCoordinatesFromNode_(node, objectStack);
|
ol.format.KML.readFlatCoordinatesFromNode_(node, objectStack);
|
||||||
if (flatCoordinates) {
|
if (flatCoordinates) {
|
||||||
var point = new ol.geom.Point(null);
|
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');
|
'flatCoordinates should have a length of 3');
|
||||||
point.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates);
|
point.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates);
|
||||||
point.setProperties(properties);
|
point.setProperties(properties);
|
||||||
@@ -1043,9 +1027,9 @@ ol.format.KML.readPoint_ = function(node, objectStack) {
|
|||||||
* @return {ol.geom.Polygon|undefined} Polygon.
|
* @return {ol.geom.Polygon|undefined} Polygon.
|
||||||
*/
|
*/
|
||||||
ol.format.KML.readPolygon_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'Polygon',
|
ol.DEBUG && console.assert(node.localName == 'Polygon',
|
||||||
'localName should be Polygon');
|
'localName should be Polygon');
|
||||||
var properties = ol.xml.pushParseAndPop(/** @type {Object<string,*>} */ ({}),
|
var properties = ol.xml.pushParseAndPop(/** @type {Object<string,*>} */ ({}),
|
||||||
ol.format.KML.EXTRUDE_AND_ALTITUDE_MODE_PARSERS_, node,
|
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.
|
* @return {Array.<ol.style.Style>} Style.
|
||||||
*/
|
*/
|
||||||
ol.format.KML.readStyle_ = function(node, objectStack) {
|
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');
|
'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(
|
var styleObject = ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.KML.STYLE_PARSERS_, node, objectStack);
|
{}, ol.format.KML.STYLE_PARSERS_, node, objectStack);
|
||||||
if (!styleObject) {
|
if (!styleObject) {
|
||||||
@@ -1154,9 +1138,9 @@ ol.format.KML.setCommonGeometryProperties_ = function(multiGeometry,
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.KML.DataParser_ = function(node, objectStack) {
|
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');
|
'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');
|
var name = node.getAttribute('name');
|
||||||
if (name !== null) {
|
if (name !== null) {
|
||||||
var data = ol.xml.pushParseAndPop(
|
var data = ol.xml.pushParseAndPop(
|
||||||
@@ -1164,8 +1148,6 @@ ol.format.KML.DataParser_ = function(node, objectStack) {
|
|||||||
if (data) {
|
if (data) {
|
||||||
var featureObject =
|
var featureObject =
|
||||||
/** @type {Object} */ (objectStack[objectStack.length - 1]);
|
/** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||||
goog.asserts.assert(goog.isObject(featureObject),
|
|
||||||
'featureObject should be an Object');
|
|
||||||
featureObject[name] = data;
|
featureObject[name] = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1178,9 +1160,9 @@ ol.format.KML.DataParser_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.KML.ExtendedDataParser_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'ExtendedData',
|
ol.DEBUG && console.assert(node.localName == 'ExtendedData',
|
||||||
'localName should be ExtendedData');
|
'localName should be ExtendedData');
|
||||||
ol.xml.parseNode(ol.format.KML.EXTENDED_DATA_PARSERS_, node, objectStack);
|
ol.xml.parseNode(ol.format.KML.EXTENDED_DATA_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
@@ -1192,9 +1174,9 @@ ol.format.KML.ExtendedDataParser_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.KML.PairDataParser_ = function(node, objectStack) {
|
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');
|
'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(
|
var pairObject = ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.KML.PAIR_PARSERS_, node, objectStack);
|
{}, ol.format.KML.PAIR_PARSERS_, node, objectStack);
|
||||||
if (!pairObject) {
|
if (!pairObject) {
|
||||||
@@ -1223,23 +1205,21 @@ ol.format.KML.PairDataParser_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.KML.PlacemarkStyleMapParser_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'StyleMap',
|
ol.DEBUG && console.assert(node.localName == 'StyleMap',
|
||||||
'localName should be StyleMap');
|
'localName should be StyleMap');
|
||||||
var styleMapValue = ol.format.KML.readStyleMapValue_(node, objectStack);
|
var styleMapValue = ol.format.KML.readStyleMapValue_(node, objectStack);
|
||||||
if (!styleMapValue) {
|
if (!styleMapValue) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var placemarkObject = objectStack[objectStack.length - 1];
|
var placemarkObject = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(placemarkObject),
|
|
||||||
'placemarkObject should be an Object');
|
|
||||||
if (Array.isArray(styleMapValue)) {
|
if (Array.isArray(styleMapValue)) {
|
||||||
placemarkObject['Style'] = styleMapValue;
|
placemarkObject['Style'] = styleMapValue;
|
||||||
} else if (typeof styleMapValue === 'string') {
|
} else if (typeof styleMapValue === 'string') {
|
||||||
placemarkObject['styleUrl'] = styleMapValue;
|
placemarkObject['styleUrl'] = styleMapValue;
|
||||||
} else {
|
} 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
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.KML.SchemaDataParser_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'SchemaData',
|
ol.DEBUG && console.assert(node.localName == 'SchemaData',
|
||||||
'localName should be SchemaData');
|
'localName should be SchemaData');
|
||||||
ol.xml.parseNode(ol.format.KML.SCHEMA_DATA_PARSERS_, node, objectStack);
|
ol.xml.parseNode(ol.format.KML.SCHEMA_DATA_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
@@ -1264,9 +1244,9 @@ ol.format.KML.SchemaDataParser_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.KML.SimpleDataParser_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'SimpleData',
|
ol.DEBUG && console.assert(node.localName == 'SimpleData',
|
||||||
'localName should be SimpleData');
|
'localName should be SimpleData');
|
||||||
var name = node.getAttribute('name');
|
var name = node.getAttribute('name');
|
||||||
if (name !== null) {
|
if (name !== null) {
|
||||||
@@ -1284,9 +1264,9 @@ ol.format.KML.SimpleDataParser_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.KML.innerBoundaryIsParser_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'innerBoundaryIs',
|
ol.DEBUG && console.assert(node.localName == 'innerBoundaryIs',
|
||||||
'localName should be innerBoundaryIs');
|
'localName should be innerBoundaryIs');
|
||||||
/** @type {Array.<number>|undefined} */
|
/** @type {Array.<number>|undefined} */
|
||||||
var flatLinearRing = ol.xml.pushParseAndPop(undefined,
|
var flatLinearRing = ol.xml.pushParseAndPop(undefined,
|
||||||
@@ -1294,9 +1274,9 @@ ol.format.KML.innerBoundaryIsParser_ = function(node, objectStack) {
|
|||||||
if (flatLinearRing) {
|
if (flatLinearRing) {
|
||||||
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
||||||
(objectStack[objectStack.length - 1]);
|
(objectStack[objectStack.length - 1]);
|
||||||
goog.asserts.assert(Array.isArray(flatLinearRings),
|
ol.DEBUG && console.assert(Array.isArray(flatLinearRings),
|
||||||
'flatLinearRings should be an array');
|
'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 array should not be empty');
|
||||||
flatLinearRings.push(flatLinearRing);
|
flatLinearRings.push(flatLinearRing);
|
||||||
}
|
}
|
||||||
@@ -1309,9 +1289,9 @@ ol.format.KML.innerBoundaryIsParser_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.KML.outerBoundaryIsParser_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'outerBoundaryIs',
|
ol.DEBUG && console.assert(node.localName == 'outerBoundaryIs',
|
||||||
'localName should be outerBoundaryIs');
|
'localName should be outerBoundaryIs');
|
||||||
/** @type {Array.<number>|undefined} */
|
/** @type {Array.<number>|undefined} */
|
||||||
var flatLinearRing = ol.xml.pushParseAndPop(undefined,
|
var flatLinearRing = ol.xml.pushParseAndPop(undefined,
|
||||||
@@ -1319,9 +1299,9 @@ ol.format.KML.outerBoundaryIsParser_ = function(node, objectStack) {
|
|||||||
if (flatLinearRing) {
|
if (flatLinearRing) {
|
||||||
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
||||||
(objectStack[objectStack.length - 1]);
|
(objectStack[objectStack.length - 1]);
|
||||||
goog.asserts.assert(Array.isArray(flatLinearRings),
|
ol.DEBUG && console.assert(Array.isArray(flatLinearRings),
|
||||||
'flatLinearRings should be an array');
|
'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 array should not be empty');
|
||||||
flatLinearRings[0] = flatLinearRing;
|
flatLinearRings[0] = flatLinearRing;
|
||||||
}
|
}
|
||||||
@@ -1334,9 +1314,9 @@ ol.format.KML.outerBoundaryIsParser_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.KML.LinkParser_ = function(node, objectStack) {
|
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');
|
'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);
|
ol.xml.parseNode(ol.format.KML.LINK_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1347,13 +1327,11 @@ ol.format.KML.LinkParser_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.KML.whenParser_ = function(node, objectStack) {
|
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');
|
'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_} */
|
var gxTrackObject = /** @type {ol.KMLGxTrackObject_} */
|
||||||
(objectStack[objectStack.length - 1]);
|
(objectStack[objectStack.length - 1]);
|
||||||
goog.asserts.assert(goog.isObject(gxTrackObject),
|
|
||||||
'gxTrackObject should be an Object');
|
|
||||||
var whens = gxTrackObject.whens;
|
var whens = gxTrackObject.whens;
|
||||||
var s = ol.xml.getAllTextContent(node, false);
|
var s = ol.xml.getAllTextContent(node, false);
|
||||||
var when = Date.parse(s);
|
var when = Date.parse(s);
|
||||||
@@ -1690,10 +1668,10 @@ ol.format.KML.prototype.getExtensions = function() {
|
|||||||
* @return {Array.<ol.Feature>|undefined} Features.
|
* @return {Array.<ol.Feature>|undefined} Features.
|
||||||
*/
|
*/
|
||||||
ol.format.KML.prototype.readDocumentOrFolder_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
var localName = node.localName;
|
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');
|
'localName should be Document or Folder');
|
||||||
// FIXME use scope somehow
|
// FIXME use scope somehow
|
||||||
var parsersNS = ol.xml.makeStructureNS(
|
var parsersNS = ol.xml.makeStructureNS(
|
||||||
@@ -1721,9 +1699,9 @@ ol.format.KML.prototype.readDocumentOrFolder_ = function(node, objectStack) {
|
|||||||
* @return {ol.Feature|undefined} Feature.
|
* @return {ol.Feature|undefined} Feature.
|
||||||
*/
|
*/
|
||||||
ol.format.KML.prototype.readPlacemark_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'Placemark',
|
ol.DEBUG && console.assert(node.localName == 'Placemark',
|
||||||
'localName should be Placemark');
|
'localName should be Placemark');
|
||||||
var object = ol.xml.pushParseAndPop({'geometry': null},
|
var object = ol.xml.pushParseAndPop({'geometry': null},
|
||||||
ol.format.KML.PLACEMARK_PARSERS_, node, objectStack);
|
ol.format.KML.PLACEMARK_PARSERS_, node, objectStack);
|
||||||
@@ -1768,9 +1746,9 @@ ol.format.KML.prototype.readPlacemark_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.KML.prototype.readSharedStyle_ = function(node, objectStack) {
|
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');
|
'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');
|
var id = node.getAttribute('id');
|
||||||
if (id !== null) {
|
if (id !== null) {
|
||||||
var style = ol.format.KML.readStyle_(node, objectStack);
|
var style = ol.format.KML.readStyle_(node, objectStack);
|
||||||
@@ -1794,9 +1772,9 @@ ol.format.KML.prototype.readSharedStyle_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.KML.prototype.readSharedStyleMap_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'StyleMap',
|
ol.DEBUG && console.assert(node.localName == 'StyleMap',
|
||||||
'localName should be StyleMap');
|
'localName should be StyleMap');
|
||||||
var id = node.getAttribute('id');
|
var id = node.getAttribute('id');
|
||||||
if (id === null) {
|
if (id === null) {
|
||||||
@@ -1835,12 +1813,12 @@ ol.format.KML.prototype.readFeature;
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.format.KML.prototype.readFeatureFromNode = function(node, opt_options) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
if (!ol.array.includes(ol.format.KML.NAMESPACE_URIS_, node.namespaceURI)) {
|
if (!ol.array.includes(ol.format.KML.NAMESPACE_URIS_, node.namespaceURI)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
goog.asserts.assert(node.localName == 'Placemark',
|
ol.DEBUG && console.assert(node.localName == 'Placemark',
|
||||||
'localName should be Placemark');
|
'localName should be Placemark');
|
||||||
var feature = this.readPlacemark_(
|
var feature = this.readPlacemark_(
|
||||||
node, [this.getReadOptions(node, opt_options)]);
|
node, [this.getReadOptions(node, opt_options)]);
|
||||||
@@ -1870,7 +1848,7 @@ ol.format.KML.prototype.readFeatures;
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.format.KML.prototype.readFeaturesFromNode = function(node, opt_options) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
if (!ol.array.includes(ol.format.KML.NAMESPACE_URIS_, node.namespaceURI)) {
|
if (!ol.array.includes(ol.format.KML.NAMESPACE_URIS_, node.namespaceURI)) {
|
||||||
return [];
|
return [];
|
||||||
@@ -1925,7 +1903,6 @@ ol.format.KML.prototype.readName = function(source) {
|
|||||||
var doc = ol.xml.parse(source);
|
var doc = ol.xml.parse(source);
|
||||||
return this.readNameFromDocument(doc);
|
return this.readNameFromDocument(doc);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail('Unknown type for source');
|
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1996,8 +1973,6 @@ ol.format.KML.prototype.readNetworkLinks = function(source) {
|
|||||||
} else if (typeof source === 'string') {
|
} else if (typeof source === 'string') {
|
||||||
var doc = ol.xml.parse(source);
|
var doc = ol.xml.parse(source);
|
||||||
ol.array.extend(networkLinks, this.readNetworkLinksFromDocument(doc));
|
ol.array.extend(networkLinks, this.readNetworkLinksFromDocument(doc));
|
||||||
} else {
|
|
||||||
goog.asserts.fail('unknown type for source');
|
|
||||||
}
|
}
|
||||||
return networkLinks;
|
return networkLinks;
|
||||||
};
|
};
|
||||||
@@ -2082,7 +2057,6 @@ ol.format.KML.writeColorTextNode_ = function(node, color) {
|
|||||||
*/
|
*/
|
||||||
ol.format.KML.writeCoordinatesTextNode_ = function(node, coordinates, objectStack) {
|
ol.format.KML.writeCoordinatesTextNode_ = function(node, coordinates, objectStack) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
|
|
||||||
var layout = context['layout'];
|
var layout = context['layout'];
|
||||||
var stride = context['stride'];
|
var stride = context['stride'];
|
||||||
@@ -2095,7 +2069,7 @@ ol.format.KML.writeCoordinatesTextNode_ = function(node, coordinates, objectStac
|
|||||||
layout == ol.geom.GeometryLayout.XYZM) {
|
layout == ol.geom.GeometryLayout.XYZM) {
|
||||||
dimension = 3;
|
dimension = 3;
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail('Unknown geometry layout');
|
ol.assert(false, 34); // Invalid geometry layout
|
||||||
}
|
}
|
||||||
|
|
||||||
var d, i;
|
var d, i;
|
||||||
@@ -2265,13 +2239,6 @@ ol.format.KML.writeLineStyle_ = function(node, style, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.KML.writeMultiGeometry_ = function(node, geometry, objectStack) {
|
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} */
|
/** @type {ol.XmlNodeStackItem} */
|
||||||
var context = {node: node};
|
var context = {node: node};
|
||||||
var type = geometry.getType();
|
var type = geometry.getType();
|
||||||
@@ -2280,11 +2247,10 @@ ol.format.KML.writeMultiGeometry_ = function(node, geometry, objectStack) {
|
|||||||
/** @type {function(*, Array.<*>, string=): (Node|undefined)} */
|
/** @type {function(*, Array.<*>, string=): (Node|undefined)} */
|
||||||
var factory;
|
var factory;
|
||||||
if (type == ol.geom.GeometryType.GEOMETRY_COLLECTION) {
|
if (type == ol.geom.GeometryType.GEOMETRY_COLLECTION) {
|
||||||
geometries = geometry.getGeometries();
|
geometries = /** @type {ol.geom.GeometryCollection} */ (geometry).getGeometries();
|
||||||
factory = ol.format.KML.GEOMETRY_NODE_FACTORY_;
|
factory = ol.format.KML.GEOMETRY_NODE_FACTORY_;
|
||||||
} else if (type == ol.geom.GeometryType.MULTI_POINT) {
|
} else if (type == ol.geom.GeometryType.MULTI_POINT) {
|
||||||
geometries =
|
geometries = /** @type {ol.geom.MultiPoint} */ (geometry).getPoints();
|
||||||
(/** @type {ol.geom.MultiPoint} */ (geometry)).getPoints();
|
|
||||||
factory = ol.format.KML.POINT_NODE_FACTORY_;
|
factory = ol.format.KML.POINT_NODE_FACTORY_;
|
||||||
} else if (type == ol.geom.GeometryType.MULTI_LINE_STRING) {
|
} else if (type == ol.geom.GeometryType.MULTI_LINE_STRING) {
|
||||||
geometries =
|
geometries =
|
||||||
@@ -2295,7 +2261,7 @@ ol.format.KML.writeMultiGeometry_ = function(node, geometry, objectStack) {
|
|||||||
(/** @type {ol.geom.MultiPolygon} */ (geometry)).getPolygons();
|
(/** @type {ol.geom.MultiPolygon} */ (geometry)).getPolygons();
|
||||||
factory = ol.format.KML.POLYGON_NODE_FACTORY_;
|
factory = ol.format.KML.POLYGON_NODE_FACTORY_;
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail('Unknown geometry type: ' + type);
|
ol.assert(false, 39); // Unknown geometry type
|
||||||
}
|
}
|
||||||
ol.xml.pushSerializeAndPop(context,
|
ol.xml.pushSerializeAndPop(context,
|
||||||
ol.format.KML.MULTI_GEOMETRY_SERIALIZERS_, factory,
|
ol.format.KML.MULTI_GEOMETRY_SERIALIZERS_, factory,
|
||||||
@@ -2378,7 +2344,7 @@ ol.format.KML.writePlacemark_ = function(node, feature, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.KML.writePrimitiveGeometry_ = function(node, geometry, objectStack) {
|
ol.format.KML.writePrimitiveGeometry_ = function(node, geometry, objectStack) {
|
||||||
goog.asserts.assert(
|
ol.DEBUG && console.assert(
|
||||||
(geometry instanceof ol.geom.Point) ||
|
(geometry instanceof ol.geom.Point) ||
|
||||||
(geometry instanceof ol.geom.LineString) ||
|
(geometry instanceof ol.geom.LineString) ||
|
||||||
(geometry instanceof ol.geom.LinearRing),
|
(geometry instanceof ol.geom.LinearRing),
|
||||||
@@ -2402,10 +2368,8 @@ ol.format.KML.writePrimitiveGeometry_ = function(node, geometry, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.KML.writePolygon_ = function(node, polygon, objectStack) {
|
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();
|
var linearRings = polygon.getLinearRings();
|
||||||
goog.asserts.assert(linearRings.length > 0,
|
ol.DEBUG && console.assert(linearRings.length > 0,
|
||||||
'linearRings should not be empty');
|
'linearRings should not be empty');
|
||||||
var outerRing = linearRings.shift();
|
var outerRing = linearRings.shift();
|
||||||
var /** @type {ol.XmlNodeStackItem} */ context = {node: node};
|
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,
|
ol.format.KML.DOCUMENT_NODE_FACTORY_ = function(value, objectStack,
|
||||||
opt_nodeName) {
|
opt_nodeName) {
|
||||||
goog.asserts.assertInstanceof(value, ol.Feature,
|
|
||||||
'value should be an ol.Feature');
|
|
||||||
var parentNode = objectStack[objectStack.length - 1].node;
|
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');
|
'parentNode should be an XML node');
|
||||||
return ol.xml.createElementNS(parentNode.namespaceURI, 'Placemark');
|
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,
|
ol.format.KML.GEOMETRY_NODE_FACTORY_ = function(value, objectStack,
|
||||||
opt_nodeName) {
|
opt_nodeName) {
|
||||||
if (value) {
|
if (value) {
|
||||||
goog.asserts.assertInstanceof(value, ol.geom.Geometry,
|
|
||||||
'value should be an ol.geom.Geometry');
|
|
||||||
var parentNode = objectStack[objectStack.length - 1].node;
|
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');
|
'parentNode should be an XML node');
|
||||||
return ol.xml.createElementNS(parentNode.namespaceURI,
|
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.provide('ol.format.MVT');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
goog.require('ol.ext.pbf');
|
goog.require('ol.ext.pbf');
|
||||||
goog.require('ol.ext.vectortile');
|
goog.require('ol.ext.vectortile');
|
||||||
@@ -102,7 +101,6 @@ ol.format.MVT.prototype.readFeature_ = function(
|
|||||||
ol.format.MVT.readGeometry_(rawFeature), false,
|
ol.format.MVT.readGeometry_(rawFeature), false,
|
||||||
this.adaptOptions(opt_options));
|
this.adaptOptions(opt_options));
|
||||||
if (geometry) {
|
if (geometry) {
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.Geometry);
|
|
||||||
values[this.geometryName_] = geometry;
|
values[this.geometryName_] = geometry;
|
||||||
}
|
}
|
||||||
feature.setId(id);
|
feature.setId(id);
|
||||||
@@ -152,11 +150,9 @@ ol.format.MVT.prototype.readRenderFeature_ = function(rawFeature, layer) {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.format.MVT.prototype.readFeatures = function(source, opt_options) {
|
ol.format.MVT.prototype.readFeatures = function(source, opt_options) {
|
||||||
goog.asserts.assertInstanceof(source, ArrayBuffer);
|
|
||||||
|
|
||||||
var layers = this.layers_;
|
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 tile = new ol.ext.vectortile.VectorTile(pbf);
|
||||||
var features = [];
|
var features = [];
|
||||||
var featureClass = this.featureClass_;
|
var featureClass = this.featureClass_;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
// FIXME add typedef for stack state objects
|
// FIXME add typedef for stack state objects
|
||||||
goog.provide('ol.format.OSMXML');
|
goog.provide('ol.format.OSMXML');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
goog.require('ol.format.Feature');
|
goog.require('ol.format.Feature');
|
||||||
@@ -57,9 +56,9 @@ ol.format.OSMXML.prototype.getExtensions = function() {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.OSMXML.readNode_ = function(node, objectStack) {
|
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');
|
'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 options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
|
||||||
var state = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
var state = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||||
var id = node.getAttribute('id');
|
var id = node.getAttribute('id');
|
||||||
@@ -90,9 +89,9 @@ ol.format.OSMXML.readNode_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.OSMXML.readWay_ = function(node, objectStack) {
|
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');
|
'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 options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
|
||||||
var id = node.getAttribute('id');
|
var id = node.getAttribute('id');
|
||||||
var values = ol.xml.pushParseAndPop({
|
var values = ol.xml.pushParseAndPop({
|
||||||
@@ -130,9 +129,9 @@ ol.format.OSMXML.readWay_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.OSMXML.readNd_ = function(node, objectStack) {
|
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');
|
'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]);
|
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||||
values.ndrefs.push(node.getAttribute('ref'));
|
values.ndrefs.push(node.getAttribute('ref'));
|
||||||
};
|
};
|
||||||
@@ -144,9 +143,9 @@ ol.format.OSMXML.readNd_ = function(node, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.OSMXML.readTag_ = function(node, objectStack) {
|
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');
|
'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]);
|
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||||
values.tags[node.getAttribute('k')] = node.getAttribute('v');
|
values.tags[node.getAttribute('k')] = node.getAttribute('v');
|
||||||
};
|
};
|
||||||
@@ -213,7 +212,7 @@ ol.format.OSMXML.prototype.readFeatures;
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.format.OSMXML.prototype.readFeaturesFromNode = function(node, opt_options) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
var options = this.getReadOptions(node, opt_options);
|
var options = this.getReadOptions(node, opt_options);
|
||||||
if (node.localName == 'osm') {
|
if (node.localName == 'osm') {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.format.OWS');
|
goog.provide('ol.format.OWS');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.format.XLink');
|
goog.require('ol.format.XLink');
|
||||||
goog.require('ol.format.XML');
|
goog.require('ol.format.XML');
|
||||||
goog.require('ol.format.XSD');
|
goog.require('ol.format.XSD');
|
||||||
@@ -22,7 +21,7 @@ ol.inherits(ol.format.OWS, ol.format.XML);
|
|||||||
* @return {Object} OWS object.
|
* @return {Object} OWS object.
|
||||||
*/
|
*/
|
||||||
ol.format.OWS.prototype.readFromDocument = function(doc) {
|
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');
|
'doc.nodeType should be DOCUMENT');
|
||||||
for (var n = doc.firstChild; n; n = n.nextSibling) {
|
for (var n = doc.firstChild; n; n = n.nextSibling) {
|
||||||
if (n.nodeType == Node.ELEMENT_NODE) {
|
if (n.nodeType == Node.ELEMENT_NODE) {
|
||||||
@@ -38,7 +37,7 @@ ol.format.OWS.prototype.readFromDocument = function(doc) {
|
|||||||
* @return {Object} OWS object.
|
* @return {Object} OWS object.
|
||||||
*/
|
*/
|
||||||
ol.format.OWS.prototype.readFromNode = function(node) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
var owsObject = ol.xml.pushParseAndPop({},
|
var owsObject = ol.xml.pushParseAndPop({},
|
||||||
ol.format.OWS.PARSERS_, node, []);
|
ol.format.OWS.PARSERS_, node, []);
|
||||||
@@ -53,9 +52,9 @@ ol.format.OWS.prototype.readFromNode = function(node) {
|
|||||||
* @return {Object|undefined} The address.
|
* @return {Object|undefined} The address.
|
||||||
*/
|
*/
|
||||||
ol.format.OWS.readAddress_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'Address',
|
ol.DEBUG && console.assert(node.localName == 'Address',
|
||||||
'localName should be Address');
|
'localName should be Address');
|
||||||
return ol.xml.pushParseAndPop({},
|
return ol.xml.pushParseAndPop({},
|
||||||
ol.format.OWS.ADDRESS_PARSERS_, node, objectStack);
|
ol.format.OWS.ADDRESS_PARSERS_, node, objectStack);
|
||||||
@@ -69,9 +68,9 @@ ol.format.OWS.readAddress_ = function(node, objectStack) {
|
|||||||
* @return {Object|undefined} The values.
|
* @return {Object|undefined} The values.
|
||||||
*/
|
*/
|
||||||
ol.format.OWS.readAllowedValues_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'AllowedValues',
|
ol.DEBUG && console.assert(node.localName == 'AllowedValues',
|
||||||
'localName should be AllowedValues');
|
'localName should be AllowedValues');
|
||||||
return ol.xml.pushParseAndPop({},
|
return ol.xml.pushParseAndPop({},
|
||||||
ol.format.OWS.ALLOWED_VALUES_PARSERS_, node, objectStack);
|
ol.format.OWS.ALLOWED_VALUES_PARSERS_, node, objectStack);
|
||||||
@@ -85,9 +84,9 @@ ol.format.OWS.readAllowedValues_ = function(node, objectStack) {
|
|||||||
* @return {Object|undefined} The constraint.
|
* @return {Object|undefined} The constraint.
|
||||||
*/
|
*/
|
||||||
ol.format.OWS.readConstraint_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'Constraint',
|
ol.DEBUG && console.assert(node.localName == 'Constraint',
|
||||||
'localName should be Constraint');
|
'localName should be Constraint');
|
||||||
var name = node.getAttribute('name');
|
var name = node.getAttribute('name');
|
||||||
if (!name) {
|
if (!name) {
|
||||||
@@ -106,9 +105,9 @@ ol.format.OWS.readConstraint_ = function(node, objectStack) {
|
|||||||
* @return {Object|undefined} The contact info.
|
* @return {Object|undefined} The contact info.
|
||||||
*/
|
*/
|
||||||
ol.format.OWS.readContactInfo_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'ContactInfo',
|
ol.DEBUG && console.assert(node.localName == 'ContactInfo',
|
||||||
'localName should be ContactInfo');
|
'localName should be ContactInfo');
|
||||||
return ol.xml.pushParseAndPop({},
|
return ol.xml.pushParseAndPop({},
|
||||||
ol.format.OWS.CONTACT_INFO_PARSERS_, node, objectStack);
|
ol.format.OWS.CONTACT_INFO_PARSERS_, node, objectStack);
|
||||||
@@ -122,9 +121,9 @@ ol.format.OWS.readContactInfo_ = function(node, objectStack) {
|
|||||||
* @return {Object|undefined} The DCP.
|
* @return {Object|undefined} The DCP.
|
||||||
*/
|
*/
|
||||||
ol.format.OWS.readDcp_ = function(node, objectStack) {
|
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');
|
'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({},
|
return ol.xml.pushParseAndPop({},
|
||||||
ol.format.OWS.DCP_PARSERS_, node, objectStack);
|
ol.format.OWS.DCP_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
@@ -137,9 +136,9 @@ ol.format.OWS.readDcp_ = function(node, objectStack) {
|
|||||||
* @return {Object|undefined} The GET object.
|
* @return {Object|undefined} The GET object.
|
||||||
*/
|
*/
|
||||||
ol.format.OWS.readGet_ = function(node, objectStack) {
|
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');
|
'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);
|
var href = ol.format.XLink.readHref(node);
|
||||||
if (!href) {
|
if (!href) {
|
||||||
return undefined;
|
return undefined;
|
||||||
@@ -156,9 +155,9 @@ ol.format.OWS.readGet_ = function(node, objectStack) {
|
|||||||
* @return {Object|undefined} The HTTP object.
|
* @return {Object|undefined} The HTTP object.
|
||||||
*/
|
*/
|
||||||
ol.format.OWS.readHttp_ = function(node, objectStack) {
|
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');
|
'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_,
|
return ol.xml.pushParseAndPop({}, ol.format.OWS.HTTP_PARSERS_,
|
||||||
node, objectStack);
|
node, objectStack);
|
||||||
};
|
};
|
||||||
@@ -171,9 +170,9 @@ ol.format.OWS.readHttp_ = function(node, objectStack) {
|
|||||||
* @return {Object|undefined} The operation.
|
* @return {Object|undefined} The operation.
|
||||||
*/
|
*/
|
||||||
ol.format.OWS.readOperation_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'Operation',
|
ol.DEBUG && console.assert(node.localName == 'Operation',
|
||||||
'localName should be Operation');
|
'localName should be Operation');
|
||||||
var name = node.getAttribute('name');
|
var name = node.getAttribute('name');
|
||||||
var value = ol.xml.pushParseAndPop({},
|
var value = ol.xml.pushParseAndPop({},
|
||||||
@@ -183,7 +182,6 @@ ol.format.OWS.readOperation_ = function(node, objectStack) {
|
|||||||
}
|
}
|
||||||
var object = /** @type {Object} */
|
var object = /** @type {Object} */
|
||||||
(objectStack[objectStack.length - 1]);
|
(objectStack[objectStack.length - 1]);
|
||||||
goog.asserts.assert(goog.isObject(object), 'object should be an Object');
|
|
||||||
object[name] = value;
|
object[name] = value;
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -197,9 +195,9 @@ ol.format.OWS.readOperation_ = function(node, objectStack) {
|
|||||||
*/
|
*/
|
||||||
ol.format.OWS.readOperationsMetadata_ = function(node,
|
ol.format.OWS.readOperationsMetadata_ = function(node,
|
||||||
objectStack) {
|
objectStack) {
|
||||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||||
'node.nodeType should be ELEMENT');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'OperationsMetadata',
|
ol.DEBUG && console.assert(node.localName == 'OperationsMetadata',
|
||||||
'localName should be OperationsMetadata');
|
'localName should be OperationsMetadata');
|
||||||
return ol.xml.pushParseAndPop({},
|
return ol.xml.pushParseAndPop({},
|
||||||
ol.format.OWS.OPERATIONS_METADATA_PARSERS_, node,
|
ol.format.OWS.OPERATIONS_METADATA_PARSERS_, node,
|
||||||
@@ -214,9 +212,9 @@ ol.format.OWS.readOperationsMetadata_ = function(node,
|
|||||||
* @return {Object|undefined} The phone.
|
* @return {Object|undefined} The phone.
|
||||||
*/
|
*/
|
||||||
ol.format.OWS.readPhone_ = function(node, objectStack) {
|
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');
|
'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({},
|
return ol.xml.pushParseAndPop({},
|
||||||
ol.format.OWS.PHONE_PARSERS_, node, objectStack);
|
ol.format.OWS.PHONE_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
@@ -230,9 +228,9 @@ ol.format.OWS.readPhone_ = function(node, objectStack) {
|
|||||||
*/
|
*/
|
||||||
ol.format.OWS.readServiceIdentification_ = function(node,
|
ol.format.OWS.readServiceIdentification_ = function(node,
|
||||||
objectStack) {
|
objectStack) {
|
||||||
goog.asserts.assert(node.nodeType == Node.ELEMENT_NODE,
|
ol.DEBUG && console.assert(node.nodeType == Node.ELEMENT_NODE,
|
||||||
'node.nodeType should be ELEMENT');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'ServiceIdentification',
|
ol.DEBUG && console.assert(node.localName == 'ServiceIdentification',
|
||||||
'localName should be ServiceIdentification');
|
'localName should be ServiceIdentification');
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.OWS.SERVICE_IDENTIFICATION_PARSERS_, node,
|
{}, ol.format.OWS.SERVICE_IDENTIFICATION_PARSERS_, node,
|
||||||
@@ -247,9 +245,9 @@ ol.format.OWS.readServiceIdentification_ = function(node,
|
|||||||
* @return {Object|undefined} The service contact.
|
* @return {Object|undefined} The service contact.
|
||||||
*/
|
*/
|
||||||
ol.format.OWS.readServiceContact_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'ServiceContact',
|
ol.DEBUG && console.assert(node.localName == 'ServiceContact',
|
||||||
'localName should be ServiceContact');
|
'localName should be ServiceContact');
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.OWS.SERVICE_CONTACT_PARSERS_, node,
|
{}, ol.format.OWS.SERVICE_CONTACT_PARSERS_, node,
|
||||||
@@ -264,9 +262,9 @@ ol.format.OWS.readServiceContact_ = function(node, objectStack) {
|
|||||||
* @return {Object|undefined} The service provider.
|
* @return {Object|undefined} The service provider.
|
||||||
*/
|
*/
|
||||||
ol.format.OWS.readServiceProvider_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'ServiceProvider',
|
ol.DEBUG && console.assert(node.localName == 'ServiceProvider',
|
||||||
'localName should be ServiceProvider');
|
'localName should be ServiceProvider');
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.OWS.SERVICE_PROVIDER_PARSERS_, node,
|
{}, ol.format.OWS.SERVICE_PROVIDER_PARSERS_, node,
|
||||||
@@ -281,9 +279,9 @@ ol.format.OWS.readServiceProvider_ = function(node, objectStack) {
|
|||||||
* @return {string|undefined} The value.
|
* @return {string|undefined} The value.
|
||||||
*/
|
*/
|
||||||
ol.format.OWS.readValue_ = function(node, objectStack) {
|
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');
|
'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);
|
return ol.format.XSD.readString(node);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.format.Polyline');
|
goog.provide('ol.format.Polyline');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
goog.require('ol.format.Feature');
|
goog.require('ol.format.Feature');
|
||||||
goog.require('ol.format.TextFeature');
|
goog.require('ol.format.TextFeature');
|
||||||
@@ -356,7 +355,7 @@ ol.format.Polyline.prototype.writeFeatureText = function(feature, opt_options) {
|
|||||||
if (geometry) {
|
if (geometry) {
|
||||||
return this.writeGeometryText(geometry, opt_options);
|
return this.writeGeometryText(geometry, opt_options);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail('geometry needs to be defined');
|
ol.assert(false, 40); // Expected `feature` to have a geometry
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -366,7 +365,7 @@ ol.format.Polyline.prototype.writeFeatureText = function(feature, opt_options) {
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.format.Polyline.prototype.writeFeaturesText = function(features, opt_options) {
|
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');
|
'features array should have 1 item');
|
||||||
return this.writeFeatureText(features[0], opt_options);
|
return this.writeFeatureText(features[0], opt_options);
|
||||||
};
|
};
|
||||||
@@ -388,8 +387,6 @@ ol.format.Polyline.prototype.writeGeometry;
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.format.Polyline.prototype.writeGeometryText = function(geometry, opt_options) {
|
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} */
|
geometry = /** @type {ol.geom.LineString} */
|
||||||
(ol.format.Feature.transformWithOptions(
|
(ol.format.Feature.transformWithOptions(
|
||||||
geometry, true, this.adaptOptions(opt_options)));
|
geometry, true, this.adaptOptions(opt_options)));
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.format.TextFeature');
|
goog.provide('ol.format.TextFeature');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.format.Feature');
|
goog.require('ol.format.Feature');
|
||||||
goog.require('ol.format.FormatType');
|
goog.require('ol.format.FormatType');
|
||||||
|
|
||||||
@@ -29,7 +28,6 @@ ol.format.TextFeature.prototype.getText_ = function(source) {
|
|||||||
if (typeof source === 'string') {
|
if (typeof source === 'string') {
|
||||||
return source;
|
return source;
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail();
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.format.TopoJSON');
|
goog.provide('ol.format.TopoJSON');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
goog.require('ol.format.Feature');
|
goog.require('ol.format.Feature');
|
||||||
goog.require('ol.format.JSONFeature');
|
goog.require('ol.format.JSONFeature');
|
||||||
@@ -250,7 +249,7 @@ ol.format.TopoJSON.readFeatureFromGeometry_ = function(object, arcs,
|
|||||||
var geometry;
|
var geometry;
|
||||||
var type = object.type;
|
var type = object.type;
|
||||||
var geometryReader = ol.format.TopoJSON.GEOMETRY_READERS_[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')) {
|
if ((type === 'Point') || (type === 'MultiPoint')) {
|
||||||
geometry = geometryReader(object, scale, translate);
|
geometry = geometryReader(object, scale, translate);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.format.WFS');
|
goog.provide('ol.format.WFS');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.format.GML3');
|
goog.require('ol.format.GML3');
|
||||||
goog.require('ol.format.GMLBase');
|
goog.require('ol.format.GMLBase');
|
||||||
@@ -142,7 +141,6 @@ ol.format.WFS.prototype.readTransactionResponse = function(source) {
|
|||||||
var doc = ol.xml.parse(source);
|
var doc = ol.xml.parse(source);
|
||||||
return this.readTransactionResponseFromDocument(doc);
|
return this.readTransactionResponseFromDocument(doc);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail('Unknown source type');
|
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -167,7 +165,6 @@ ol.format.WFS.prototype.readFeatureCollectionMetadata = function(source) {
|
|||||||
var doc = ol.xml.parse(source);
|
var doc = ol.xml.parse(source);
|
||||||
return this.readFeatureCollectionMetadataFromDocument(doc);
|
return this.readFeatureCollectionMetadataFromDocument(doc);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail('Unknown source type');
|
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -179,7 +176,7 @@ ol.format.WFS.prototype.readFeatureCollectionMetadata = function(source) {
|
|||||||
* FeatureCollection metadata.
|
* FeatureCollection metadata.
|
||||||
*/
|
*/
|
||||||
ol.format.WFS.prototype.readFeatureCollectionMetadataFromDocument = function(doc) {
|
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');
|
'doc.nodeType should be DOCUMENT');
|
||||||
for (var n = doc.firstChild; n; n = n.nextSibling) {
|
for (var n = doc.firstChild; n; n = n.nextSibling) {
|
||||||
if (n.nodeType == Node.ELEMENT_NODE) {
|
if (n.nodeType == Node.ELEMENT_NODE) {
|
||||||
@@ -209,9 +206,9 @@ ol.format.WFS.FEATURE_COLLECTION_PARSERS_ = {
|
|||||||
* FeatureCollection metadata.
|
* FeatureCollection metadata.
|
||||||
*/
|
*/
|
||||||
ol.format.WFS.prototype.readFeatureCollectionMetadataFromNode = function(node) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'FeatureCollection',
|
ol.DEBUG && console.assert(node.localName == 'FeatureCollection',
|
||||||
'localName should be FeatureCollection');
|
'localName should be FeatureCollection');
|
||||||
var result = {};
|
var result = {};
|
||||||
var value = ol.format.XSD.readNonNegativeIntegerString(
|
var value = ol.format.XSD.readNonNegativeIntegerString(
|
||||||
@@ -320,7 +317,7 @@ ol.format.WFS.TRANSACTION_RESPONSE_PARSERS_ = {
|
|||||||
* @return {ol.WFSTransactionResponse|undefined} Transaction response.
|
* @return {ol.WFSTransactionResponse|undefined} Transaction response.
|
||||||
*/
|
*/
|
||||||
ol.format.WFS.prototype.readTransactionResponseFromDocument = function(doc) {
|
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');
|
'doc.nodeType should be DOCUMENT');
|
||||||
for (var n = doc.firstChild; n; n = n.nextSibling) {
|
for (var n = doc.firstChild; n; n = n.nextSibling) {
|
||||||
if (n.nodeType == Node.ELEMENT_NODE) {
|
if (n.nodeType == Node.ELEMENT_NODE) {
|
||||||
@@ -336,9 +333,9 @@ ol.format.WFS.prototype.readTransactionResponseFromDocument = function(doc) {
|
|||||||
* @return {ol.WFSTransactionResponse|undefined} Transaction response.
|
* @return {ol.WFSTransactionResponse|undefined} Transaction response.
|
||||||
*/
|
*/
|
||||||
ol.format.WFS.prototype.readTransactionResponseFromNode = function(node) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'TransactionResponse',
|
ol.DEBUG && console.assert(node.localName == 'TransactionResponse',
|
||||||
'localName should be TransactionResponse');
|
'localName should be TransactionResponse');
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
/** @type {ol.WFSTransactionResponse} */({}),
|
/** @type {ol.WFSTransactionResponse} */({}),
|
||||||
@@ -365,7 +362,6 @@ ol.format.WFS.QUERY_SERIALIZERS_ = {
|
|||||||
*/
|
*/
|
||||||
ol.format.WFS.writeFeature_ = function(node, feature, objectStack) {
|
ol.format.WFS.writeFeature_ = function(node, feature, objectStack) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var featureType = context['featureType'];
|
var featureType = context['featureType'];
|
||||||
var featureNS = context['featureNS'];
|
var featureNS = context['featureNS'];
|
||||||
var child = ol.xml.createElementNS(featureNS, featureType);
|
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) {
|
ol.format.WFS.writeDelete_ = function(node, feature, objectStack) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
ol.assert(feature.getId() !== undefined, 26); // Features must have an id set
|
||||||
goog.asserts.assert(feature.getId() !== undefined, 'feature should have an id');
|
|
||||||
var featureType = context['featureType'];
|
var featureType = context['featureType'];
|
||||||
var featurePrefix = context['featurePrefix'];
|
var featurePrefix = context['featurePrefix'];
|
||||||
featurePrefix = featurePrefix ? featurePrefix :
|
featurePrefix = featurePrefix ? featurePrefix :
|
||||||
@@ -422,8 +417,7 @@ ol.format.WFS.writeDelete_ = function(node, feature, objectStack) {
|
|||||||
*/
|
*/
|
||||||
ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) {
|
ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
ol.assert(feature.getId() !== undefined, 27); // Features must have an id set
|
||||||
goog.asserts.assert(feature.getId() !== undefined, 'feature should have an id');
|
|
||||||
var featureType = context['featureType'];
|
var featureType = context['featureType'];
|
||||||
var featurePrefix = context['featurePrefix'];
|
var featurePrefix = context['featurePrefix'];
|
||||||
featurePrefix = featurePrefix ? featurePrefix :
|
featurePrefix = featurePrefix ? featurePrefix :
|
||||||
@@ -517,8 +511,7 @@ ol.format.WFS.TRANSACTION_SERIALIZERS_ = {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.WFS.writeQuery_ = function(node, featureType, objectStack) {
|
ol.format.WFS.writeQuery_ = function(node, featureType, objectStack) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var featurePrefix = context['featurePrefix'];
|
var featurePrefix = context['featurePrefix'];
|
||||||
var featureNS = context['featureNS'];
|
var featureNS = context['featureNS'];
|
||||||
var propertyNames = context['propertyNames'];
|
var propertyNames = context['propertyNames'];
|
||||||
@@ -565,16 +558,12 @@ ol.format.WFS.writeFilterCondition_ = function(node, filter, objectStack) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Node} node Node.
|
* @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.
|
* @param {Array.<*>} objectStack Node stack.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.WFS.writeBboxFilter_ = function(node, filter, objectStack) {
|
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];
|
var context = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
context['srsName'] = filter.srsName;
|
context['srsName'] = filter.srsName;
|
||||||
|
|
||||||
ol.format.WFS.writeOgcPropertyName_(node, filter.geometryName);
|
ol.format.WFS.writeOgcPropertyName_(node, filter.geometryName);
|
||||||
@@ -584,7 +573,7 @@ ol.format.WFS.writeBboxFilter_ = function(node, filter, objectStack) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Node} node Node.
|
* @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.
|
* @param {Array.<*>} objectStack Node stack.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
@@ -627,8 +616,6 @@ ol.format.WFS.writeWithinFilter_ = function(node, filter, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.WFS.writeLogicalFilter_ = function(node, filter, objectStack) {
|
ol.format.WFS.writeLogicalFilter_ = function(node, filter, objectStack) {
|
||||||
goog.asserts.assertInstanceof(filter, ol.format.ogc.filter.LogicalBinary,
|
|
||||||
'must be logical filter');
|
|
||||||
/** @type {ol.XmlNodeStackItem} */
|
/** @type {ol.XmlNodeStackItem} */
|
||||||
var item = {node: node};
|
var item = {node: node};
|
||||||
var conditionA = filter.conditionA;
|
var conditionA = filter.conditionA;
|
||||||
@@ -646,13 +633,11 @@ ol.format.WFS.writeLogicalFilter_ = function(node, filter, objectStack) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Node} node Node.
|
* @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.
|
* @param {Array.<*>} objectStack Node stack.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.WFS.writeNotFilter_ = function(node, filter, objectStack) {
|
ol.format.WFS.writeNotFilter_ = function(node, filter, objectStack) {
|
||||||
goog.asserts.assertInstanceof(filter, ol.format.ogc.filter.Not,
|
|
||||||
'must be Not filter');
|
|
||||||
/** @type {ol.XmlNodeStackItem} */
|
/** @type {ol.XmlNodeStackItem} */
|
||||||
var item = {node: node};
|
var item = {node: node};
|
||||||
var condition = filter.condition;
|
var condition = filter.condition;
|
||||||
@@ -665,13 +650,11 @@ ol.format.WFS.writeNotFilter_ = function(node, filter, objectStack) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Node} node Node.
|
* @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.
|
* @param {Array.<*>} objectStack Node stack.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.WFS.writeComparisonFilter_ = function(node, filter, objectStack) {
|
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) {
|
if (filter.matchCase !== undefined) {
|
||||||
node.setAttribute('matchCase', filter.matchCase.toString());
|
node.setAttribute('matchCase', filter.matchCase.toString());
|
||||||
}
|
}
|
||||||
@@ -682,26 +665,22 @@ ol.format.WFS.writeComparisonFilter_ = function(node, filter, objectStack) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Node} node Node.
|
* @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.
|
* @param {Array.<*>} objectStack Node stack.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.WFS.writeIsNullFilter_ = function(node, filter, objectStack) {
|
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);
|
ol.format.WFS.writeOgcPropertyName_(node, filter.propertyName);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Node} node Node.
|
* @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.
|
* @param {Array.<*>} objectStack Node stack.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.WFS.writeIsBetweenFilter_ = function(node, filter, objectStack) {
|
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.writeOgcPropertyName_(node, filter.propertyName);
|
||||||
ol.format.WFS.writeOgcExpression_('LowerBoundary', node, '' + filter.lowerBoundary);
|
ol.format.WFS.writeOgcExpression_('LowerBoundary', node, '' + filter.lowerBoundary);
|
||||||
ol.format.WFS.writeOgcExpression_('UpperBoundary', node, '' + filter.upperBoundary);
|
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 {Node} node Node.
|
||||||
* @param {ol.format.ogc.filter.Filter} filter Filter.
|
* @param {ol.format.ogc.filter.IsLike} filter Filter.
|
||||||
* @param {Array.<*>} objectStack Node stack.
|
* @param {Array.<*>} objectStack Node stack.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.WFS.writeIsLikeFilter_ = function(node, filter, objectStack) {
|
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('wildCard', filter.wildCard);
|
||||||
node.setAttribute('singleChar', filter.singleChar);
|
node.setAttribute('singleChar', filter.singleChar);
|
||||||
node.setAttribute('escapeChar', filter.escapeChar);
|
node.setAttribute('escapeChar', filter.escapeChar);
|
||||||
@@ -791,13 +768,12 @@ ol.format.WFS.GETFEATURE_SERIALIZERS_ = {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Node} node Node.
|
* @param {Node} node Node.
|
||||||
* @param {Array.<{string}>} featureTypes Feature types.
|
* @param {Array.<string>} featureTypes Feature types.
|
||||||
* @param {Array.<*>} objectStack Node stack.
|
* @param {Array.<*>} objectStack Node stack.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.WFS.writeGetFeature_ = function(node, featureTypes, objectStack) {
|
ol.format.WFS.writeGetFeature_ = function(node, featureTypes, objectStack) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
|
||||||
var item = /** @type {ol.XmlNodeStackItem} */ (ol.object.assign({}, context));
|
var item = /** @type {ol.XmlNodeStackItem} */ (ol.object.assign({}, context));
|
||||||
item.node = node;
|
item.node = node;
|
||||||
ol.xml.pushSerializeAndPop(item,
|
ol.xml.pushSerializeAndPop(item,
|
||||||
@@ -841,10 +817,10 @@ ol.format.WFS.prototype.writeGetFeature = function(options) {
|
|||||||
}
|
}
|
||||||
filter = options.filter;
|
filter = options.filter;
|
||||||
if (options.bbox) {
|
if (options.bbox) {
|
||||||
goog.asserts.assert(options.geometryName,
|
ol.assert(options.geometryName,
|
||||||
'geometryName must be set when using bbox filter');
|
12); // `options.geometryName` must also be provided when `options.bbox` is set
|
||||||
var bbox = ol.format.ogc.filter.bbox(
|
var bbox = ol.format.ogc.filter.bbox(
|
||||||
options.geometryName, options.bbox, options.srsName);
|
/** @type {string} */ (options.geometryName), options.bbox, options.srsName);
|
||||||
if (filter) {
|
if (filter) {
|
||||||
// if bbox and filter are both set, combine the two into a single filter
|
// if bbox and filter are both set, combine the two into a single filter
|
||||||
filter = ol.format.ogc.filter.and(filter, bbox);
|
filter = ol.format.ogc.filter.and(filter, bbox);
|
||||||
@@ -865,9 +841,9 @@ ol.format.WFS.prototype.writeGetFeature = function(options) {
|
|||||||
'filter': filter,
|
'filter': filter,
|
||||||
'propertyNames': options.propertyNames ? options.propertyNames : []
|
'propertyNames': options.propertyNames ? options.propertyNames : []
|
||||||
};
|
};
|
||||||
goog.asserts.assert(Array.isArray(options.featureTypes),
|
ol.assert(Array.isArray(options.featureTypes),
|
||||||
'options.featureTypes should be an array');
|
11); // `options.featureTypes` should be an Array
|
||||||
ol.format.WFS.writeGetFeature_(node, options.featureTypes, [context]);
|
ol.format.WFS.writeGetFeature_(node, /** @type {!Array.<string>} */ (options.featureTypes), [context]);
|
||||||
return node;
|
return node;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -955,7 +931,7 @@ ol.format.WFS.prototype.readProjection;
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.format.WFS.prototype.readProjectionFromDocument = function(doc) {
|
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');
|
'doc.nodeType should be a DOCUMENT');
|
||||||
for (var n = doc.firstChild; n; n = n.nextSibling) {
|
for (var n = doc.firstChild; n; n = n.nextSibling) {
|
||||||
if (n.nodeType == Node.ELEMENT_NODE) {
|
if (n.nodeType == Node.ELEMENT_NODE) {
|
||||||
@@ -970,9 +946,9 @@ ol.format.WFS.prototype.readProjectionFromDocument = function(doc) {
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.format.WFS.prototype.readProjectionFromNode = function(node) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'FeatureCollection',
|
ol.DEBUG && console.assert(node.localName == 'FeatureCollection',
|
||||||
'localName should be FeatureCollection');
|
'localName should be FeatureCollection');
|
||||||
|
|
||||||
if (node.firstElementChild &&
|
if (node.firstElementChild &&
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.format.WKT');
|
goog.provide('ol.format.WKT');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
goog.require('ol.format.Feature');
|
goog.require('ol.format.Feature');
|
||||||
@@ -167,7 +166,7 @@ ol.format.WKT.encodeMultiPolygonGeometry_ = function(geom) {
|
|||||||
ol.format.WKT.encode_ = function(geom) {
|
ol.format.WKT.encode_ = function(geom) {
|
||||||
var type = geom.getType();
|
var type = geom.getType();
|
||||||
var geometryEncoder = ol.format.WKT.GeometryEncoder_[type];
|
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);
|
var enc = geometryEncoder(geom);
|
||||||
type = type.toUpperCase();
|
type = type.toUpperCase();
|
||||||
if (enc.length === 0) {
|
if (enc.length === 0) {
|
||||||
@@ -574,7 +573,7 @@ ol.format.WKT.Parser.prototype.match = function(type) {
|
|||||||
ol.format.WKT.Parser.prototype.parse = function() {
|
ol.format.WKT.Parser.prototype.parse = function() {
|
||||||
this.consume_();
|
this.consume_();
|
||||||
var geometry = this.parseGeometry_();
|
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');
|
'token type should be end of file');
|
||||||
return geometry;
|
return geometry;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.format.WMSCapabilities');
|
goog.provide('ol.format.WMSCapabilities');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.format.XLink');
|
goog.require('ol.format.XLink');
|
||||||
goog.require('ol.format.XML');
|
goog.require('ol.format.XML');
|
||||||
@@ -44,7 +43,7 @@ ol.format.WMSCapabilities.prototype.read;
|
|||||||
* @return {Object} WMS Capability object.
|
* @return {Object} WMS Capability object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.prototype.readFromDocument = function(doc) {
|
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');
|
'doc.nodeType should be DOCUMENT');
|
||||||
for (var n = doc.firstChild; n; n = n.nextSibling) {
|
for (var n = doc.firstChild; n; n = n.nextSibling) {
|
||||||
if (n.nodeType == Node.ELEMENT_NODE) {
|
if (n.nodeType == Node.ELEMENT_NODE) {
|
||||||
@@ -60,13 +59,12 @@ ol.format.WMSCapabilities.prototype.readFromDocument = function(doc) {
|
|||||||
* @return {Object} WMS Capability object.
|
* @return {Object} WMS Capability object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.prototype.readFromNode = function(node) {
|
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');
|
'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',
|
node.localName == 'WMT_MS_Capabilities',
|
||||||
'localName should be WMS_Capabilities or WMT_MS_Capabilities');
|
'localName should be WMS_Capabilities or WMT_MS_Capabilities');
|
||||||
this.version = node.getAttribute('version').trim();
|
this.version = node.getAttribute('version').trim();
|
||||||
goog.asserts.assertString(this.version, 'this.version should be a string');
|
|
||||||
var wmsCapabilityObject = ol.xml.pushParseAndPop({
|
var wmsCapabilityObject = ol.xml.pushParseAndPop({
|
||||||
'version': this.version
|
'version': this.version
|
||||||
}, ol.format.WMSCapabilities.PARSERS_, node, []);
|
}, ol.format.WMSCapabilities.PARSERS_, node, []);
|
||||||
@@ -81,9 +79,9 @@ ol.format.WMSCapabilities.prototype.readFromNode = function(node) {
|
|||||||
* @return {Object|undefined} Attribution object.
|
* @return {Object|undefined} Attribution object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readAttribution_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'Attribution',
|
ol.DEBUG && console.assert(node.localName == 'Attribution',
|
||||||
'localName should be Attribution');
|
'localName should be Attribution');
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.ATTRIBUTION_PARSERS_, node, objectStack);
|
{}, ol.format.WMSCapabilities.ATTRIBUTION_PARSERS_, node, objectStack);
|
||||||
@@ -97,9 +95,9 @@ ol.format.WMSCapabilities.readAttribution_ = function(node, objectStack) {
|
|||||||
* @return {Object} Bounding box object.
|
* @return {Object} Bounding box object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readBoundingBox_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'BoundingBox',
|
ol.DEBUG && console.assert(node.localName == 'BoundingBox',
|
||||||
'localName should be BoundingBox');
|
'localName should be BoundingBox');
|
||||||
|
|
||||||
var extent = [
|
var extent = [
|
||||||
@@ -129,9 +127,9 @@ ol.format.WMSCapabilities.readBoundingBox_ = function(node, objectStack) {
|
|||||||
* @return {ol.Extent|undefined} Bounding box object.
|
* @return {ol.Extent|undefined} Bounding box object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readEXGeographicBoundingBox_ = function(node, objectStack) {
|
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');
|
'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');
|
'localName should be EX_GeographicBoundingBox');
|
||||||
var geographicBoundingBox = ol.xml.pushParseAndPop(
|
var geographicBoundingBox = ol.xml.pushParseAndPop(
|
||||||
{},
|
{},
|
||||||
@@ -166,9 +164,9 @@ ol.format.WMSCapabilities.readEXGeographicBoundingBox_ = function(node, objectSt
|
|||||||
* @return {Object|undefined} Capability object.
|
* @return {Object|undefined} Capability object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readCapability_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'Capability',
|
ol.DEBUG && console.assert(node.localName == 'Capability',
|
||||||
'localName should be Capability');
|
'localName should be Capability');
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.CAPABILITY_PARSERS_, node, objectStack);
|
{}, ol.format.WMSCapabilities.CAPABILITY_PARSERS_, node, objectStack);
|
||||||
@@ -182,9 +180,9 @@ ol.format.WMSCapabilities.readCapability_ = function(node, objectStack) {
|
|||||||
* @return {Object|undefined} Service object.
|
* @return {Object|undefined} Service object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readService_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'Service',
|
ol.DEBUG && console.assert(node.localName == 'Service',
|
||||||
'localName should be Service');
|
'localName should be Service');
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.SERVICE_PARSERS_, node, objectStack);
|
{}, ol.format.WMSCapabilities.SERVICE_PARSERS_, node, objectStack);
|
||||||
@@ -198,9 +196,9 @@ ol.format.WMSCapabilities.readService_ = function(node, objectStack) {
|
|||||||
* @return {Object|undefined} Contact information object.
|
* @return {Object|undefined} Contact information object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readContactInformation_ = function(node, objectStack) {
|
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');
|
'node.nodeType shpuld be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'ContactInformation',
|
ol.DEBUG && console.assert(node.localName == 'ContactInformation',
|
||||||
'localName should be ContactInformation');
|
'localName should be ContactInformation');
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.CONTACT_INFORMATION_PARSERS_,
|
{}, ol.format.WMSCapabilities.CONTACT_INFORMATION_PARSERS_,
|
||||||
@@ -215,9 +213,9 @@ ol.format.WMSCapabilities.readContactInformation_ = function(node, objectStack)
|
|||||||
* @return {Object|undefined} Contact person object.
|
* @return {Object|undefined} Contact person object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readContactPersonPrimary_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'ContactPersonPrimary',
|
ol.DEBUG && console.assert(node.localName == 'ContactPersonPrimary',
|
||||||
'localName should be ContactPersonPrimary');
|
'localName should be ContactPersonPrimary');
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.CONTACT_PERSON_PARSERS_,
|
{}, ol.format.WMSCapabilities.CONTACT_PERSON_PARSERS_,
|
||||||
@@ -232,9 +230,9 @@ ol.format.WMSCapabilities.readContactPersonPrimary_ = function(node, objectStack
|
|||||||
* @return {Object|undefined} Contact address object.
|
* @return {Object|undefined} Contact address object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readContactAddress_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'ContactAddress',
|
ol.DEBUG && console.assert(node.localName == 'ContactAddress',
|
||||||
'localName should be ContactAddress');
|
'localName should be ContactAddress');
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.CONTACT_ADDRESS_PARSERS_,
|
{}, ol.format.WMSCapabilities.CONTACT_ADDRESS_PARSERS_,
|
||||||
@@ -249,9 +247,9 @@ ol.format.WMSCapabilities.readContactAddress_ = function(node, objectStack) {
|
|||||||
* @return {Array.<string>|undefined} Format array.
|
* @return {Array.<string>|undefined} Format array.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readException_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'Exception',
|
ol.DEBUG && console.assert(node.localName == 'Exception',
|
||||||
'localName should be Exception');
|
'localName should be Exception');
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
[], ol.format.WMSCapabilities.EXCEPTION_PARSERS_, node, objectStack);
|
[], ol.format.WMSCapabilities.EXCEPTION_PARSERS_, node, objectStack);
|
||||||
@@ -265,9 +263,9 @@ ol.format.WMSCapabilities.readException_ = function(node, objectStack) {
|
|||||||
* @return {Object|undefined} Layer object.
|
* @return {Object|undefined} Layer object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readCapabilityLayer_ = function(node, objectStack) {
|
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');
|
'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(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.LAYER_PARSERS_, node, objectStack);
|
{}, ol.format.WMSCapabilities.LAYER_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
@@ -280,9 +278,9 @@ ol.format.WMSCapabilities.readCapabilityLayer_ = function(node, objectStack) {
|
|||||||
* @return {Object|undefined} Layer object.
|
* @return {Object|undefined} Layer object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) {
|
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');
|
'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,*>} */
|
var parentLayerObject = /** @type {Object.<string,*>} */
|
||||||
(objectStack[objectStack.length - 1]);
|
(objectStack[objectStack.length - 1]);
|
||||||
|
|
||||||
@@ -362,9 +360,9 @@ ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) {
|
|||||||
* @return {Object} Dimension object.
|
* @return {Object} Dimension object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readDimension_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'Dimension',
|
ol.DEBUG && console.assert(node.localName == 'Dimension',
|
||||||
'localName should be Dimension');
|
'localName should be Dimension');
|
||||||
var dimensionObject = {
|
var dimensionObject = {
|
||||||
'name': node.getAttribute('name'),
|
'name': node.getAttribute('name'),
|
||||||
@@ -389,7 +387,7 @@ ol.format.WMSCapabilities.readDimension_ = function(node, objectStack) {
|
|||||||
* @return {Object|undefined} Online resource object.
|
* @return {Object|undefined} Online resource object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readFormatOnlineresource_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.FORMAT_ONLINERESOURCE_PARSERS_,
|
{}, ol.format.WMSCapabilities.FORMAT_ONLINERESOURCE_PARSERS_,
|
||||||
@@ -404,9 +402,9 @@ ol.format.WMSCapabilities.readFormatOnlineresource_ = function(node, objectStack
|
|||||||
* @return {Object|undefined} Request object.
|
* @return {Object|undefined} Request object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readRequest_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'Request',
|
ol.DEBUG && console.assert(node.localName == 'Request',
|
||||||
'localName should be Request');
|
'localName should be Request');
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.REQUEST_PARSERS_, node, objectStack);
|
{}, ol.format.WMSCapabilities.REQUEST_PARSERS_, node, objectStack);
|
||||||
@@ -420,9 +418,9 @@ ol.format.WMSCapabilities.readRequest_ = function(node, objectStack) {
|
|||||||
* @return {Object|undefined} DCP type object.
|
* @return {Object|undefined} DCP type object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readDCPType_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'DCPType',
|
ol.DEBUG && console.assert(node.localName == 'DCPType',
|
||||||
'localName should be DCPType');
|
'localName should be DCPType');
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.DCPTYPE_PARSERS_, node, objectStack);
|
{}, ol.format.WMSCapabilities.DCPTYPE_PARSERS_, node, objectStack);
|
||||||
@@ -436,9 +434,9 @@ ol.format.WMSCapabilities.readDCPType_ = function(node, objectStack) {
|
|||||||
* @return {Object|undefined} HTTP object.
|
* @return {Object|undefined} HTTP object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readHTTP_ = function(node, objectStack) {
|
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');
|
'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(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.HTTP_PARSERS_, node, objectStack);
|
{}, ol.format.WMSCapabilities.HTTP_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
@@ -451,7 +449,7 @@ ol.format.WMSCapabilities.readHTTP_ = function(node, objectStack) {
|
|||||||
* @return {Object|undefined} Operation type object.
|
* @return {Object|undefined} Operation type object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readOperationType_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.OPERATIONTYPE_PARSERS_, node, objectStack);
|
{}, ol.format.WMSCapabilities.OPERATIONTYPE_PARSERS_, node, objectStack);
|
||||||
@@ -465,7 +463,7 @@ ol.format.WMSCapabilities.readOperationType_ = function(node, objectStack) {
|
|||||||
* @return {Object|undefined} Online resource object.
|
* @return {Object|undefined} Online resource object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readSizedFormatOnlineresource_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
var formatOnlineresource =
|
var formatOnlineresource =
|
||||||
ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack);
|
ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack);
|
||||||
@@ -488,9 +486,9 @@ ol.format.WMSCapabilities.readSizedFormatOnlineresource_ = function(node, object
|
|||||||
* @return {Object|undefined} Authority URL object.
|
* @return {Object|undefined} Authority URL object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readAuthorityURL_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'AuthorityURL',
|
ol.DEBUG && console.assert(node.localName == 'AuthorityURL',
|
||||||
'localName should be AuthorityURL');
|
'localName should be AuthorityURL');
|
||||||
var authorityObject =
|
var authorityObject =
|
||||||
ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack);
|
ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack);
|
||||||
@@ -509,9 +507,9 @@ ol.format.WMSCapabilities.readAuthorityURL_ = function(node, objectStack) {
|
|||||||
* @return {Object|undefined} Metadata URL object.
|
* @return {Object|undefined} Metadata URL object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readMetadataURL_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'MetadataURL',
|
ol.DEBUG && console.assert(node.localName == 'MetadataURL',
|
||||||
'localName should be MetadataURL');
|
'localName should be MetadataURL');
|
||||||
var metadataObject =
|
var metadataObject =
|
||||||
ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack);
|
ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack);
|
||||||
@@ -530,9 +528,9 @@ ol.format.WMSCapabilities.readMetadataURL_ = function(node, objectStack) {
|
|||||||
* @return {Object|undefined} Style object.
|
* @return {Object|undefined} Style object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readStyle_ = function(node, objectStack) {
|
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');
|
'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(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.STYLE_PARSERS_, node, objectStack);
|
{}, ol.format.WMSCapabilities.STYLE_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
@@ -545,9 +543,9 @@ ol.format.WMSCapabilities.readStyle_ = function(node, objectStack) {
|
|||||||
* @return {Array.<string>|undefined} Keyword list.
|
* @return {Array.<string>|undefined} Keyword list.
|
||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readKeywordList_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'KeywordList',
|
ol.DEBUG && console.assert(node.localName == 'KeywordList',
|
||||||
'localName should be KeywordList');
|
'localName should be KeywordList');
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
[], ol.format.WMSCapabilities.KEYWORDLIST_PARSERS_, node, objectStack);
|
[], ol.format.WMSCapabilities.KEYWORDLIST_PARSERS_, node, objectStack);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.format.WMSGetFeatureInfo');
|
goog.provide('ol.format.WMSGetFeatureInfo');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
goog.require('ol.format.GML2');
|
goog.require('ol.format.GML2');
|
||||||
goog.require('ol.format.XMLFeature');
|
goog.require('ol.format.XMLFeature');
|
||||||
@@ -72,7 +71,7 @@ ol.format.WMSGetFeatureInfo.layerIdentifier_ = '_layer';
|
|||||||
ol.format.WMSGetFeatureInfo.prototype.readFeatures_ = function(node, objectStack) {
|
ol.format.WMSGetFeatureInfo.prototype.readFeatures_ = function(node, objectStack) {
|
||||||
|
|
||||||
node.setAttribute('namespaceURI', this.featureNS_);
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
var localName = node.localName;
|
var localName = node.localName;
|
||||||
/** @type {Array.<ol.Feature>} */
|
/** @type {Array.<ol.Feature>} */
|
||||||
@@ -87,10 +86,8 @@ ol.format.WMSGetFeatureInfo.prototype.readFeatures_ = function(node, objectStack
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var context = objectStack[0];
|
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,
|
ol.format.WMSGetFeatureInfo.layerIdentifier_) >= 0,
|
||||||
'localName of layer node should match layerIdentifier');
|
'localName of layer node should match layerIdentifier');
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.format.WMTSCapabilities');
|
goog.provide('ol.format.WMTSCapabilities');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.format.OWS');
|
goog.require('ol.format.OWS');
|
||||||
goog.require('ol.format.XLink');
|
goog.require('ol.format.XLink');
|
||||||
@@ -45,7 +44,7 @@ ol.format.WMTSCapabilities.prototype.read;
|
|||||||
* @return {Object} WMTS Capability object.
|
* @return {Object} WMTS Capability object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMTSCapabilities.prototype.readFromDocument = function(doc) {
|
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');
|
'doc.nodeType should be DOCUMENT');
|
||||||
for (var n = doc.firstChild; n; n = n.nextSibling) {
|
for (var n = doc.firstChild; n; n = n.nextSibling) {
|
||||||
if (n.nodeType == Node.ELEMENT_NODE) {
|
if (n.nodeType == Node.ELEMENT_NODE) {
|
||||||
@@ -61,12 +60,11 @@ ol.format.WMTSCapabilities.prototype.readFromDocument = function(doc) {
|
|||||||
* @return {Object} WMTS Capability object.
|
* @return {Object} WMTS Capability object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMTSCapabilities.prototype.readFromNode = function(node) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'Capabilities',
|
ol.DEBUG && console.assert(node.localName == 'Capabilities',
|
||||||
'localName should be Capabilities');
|
'localName should be Capabilities');
|
||||||
var version = node.getAttribute('version').trim();
|
var version = node.getAttribute('version').trim();
|
||||||
goog.asserts.assertString(version, 'version should be a string');
|
|
||||||
var WMTSCapabilityObject = this.owsParser_.readFromNode(node);
|
var WMTSCapabilityObject = this.owsParser_.readFromNode(node);
|
||||||
if (!WMTSCapabilityObject) {
|
if (!WMTSCapabilityObject) {
|
||||||
return null;
|
return null;
|
||||||
@@ -85,9 +83,9 @@ ol.format.WMTSCapabilities.prototype.readFromNode = function(node) {
|
|||||||
* @return {Object|undefined} Attribution object.
|
* @return {Object|undefined} Attribution object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMTSCapabilities.readContents_ = function(node, objectStack) {
|
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');
|
'node.nodeType should be ELEMENT');
|
||||||
goog.asserts.assert(node.localName == 'Contents',
|
ol.DEBUG && console.assert(node.localName == 'Contents',
|
||||||
'localName should be Contents');
|
'localName should be Contents');
|
||||||
|
|
||||||
return ol.xml.pushParseAndPop({},
|
return ol.xml.pushParseAndPop({},
|
||||||
@@ -102,9 +100,9 @@ ol.format.WMTSCapabilities.readContents_ = function(node, objectStack) {
|
|||||||
* @return {Object|undefined} Layers object.
|
* @return {Object|undefined} Layers object.
|
||||||
*/
|
*/
|
||||||
ol.format.WMTSCapabilities.readLayer_ = function(node, objectStack) {
|
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');
|
'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({},
|
return ol.xml.pushParseAndPop({},
|
||||||
ol.format.WMTSCapabilities.LAYER_PARSERS_, node, objectStack);
|
ol.format.WMTSCapabilities.LAYER_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.format.XMLFeature');
|
goog.provide('ol.format.XMLFeature');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
goog.require('ol.format.Feature');
|
goog.require('ol.format.Feature');
|
||||||
goog.require('ol.format.FormatType');
|
goog.require('ol.format.FormatType');
|
||||||
@@ -51,7 +50,6 @@ ol.format.XMLFeature.prototype.readFeature = function(source, opt_options) {
|
|||||||
var doc = ol.xml.parse(source);
|
var doc = ol.xml.parse(source);
|
||||||
return this.readFeatureFromDocument(doc, opt_options);
|
return this.readFeatureFromDocument(doc, opt_options);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail('Unknown source type');
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -95,7 +93,6 @@ ol.format.XMLFeature.prototype.readFeatures = function(source, opt_options) {
|
|||||||
var doc = ol.xml.parse(source);
|
var doc = ol.xml.parse(source);
|
||||||
return this.readFeaturesFromDocument(doc, opt_options);
|
return this.readFeaturesFromDocument(doc, opt_options);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail('Unknown source type');
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -144,7 +141,6 @@ ol.format.XMLFeature.prototype.readGeometry = function(source, opt_options) {
|
|||||||
var doc = ol.xml.parse(source);
|
var doc = ol.xml.parse(source);
|
||||||
return this.readGeometryFromDocument(doc, opt_options);
|
return this.readGeometryFromDocument(doc, opt_options);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail('Unknown source type');
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -182,7 +178,6 @@ ol.format.XMLFeature.prototype.readProjection = function(source) {
|
|||||||
var doc = ol.xml.parse(source);
|
var doc = ol.xml.parse(source);
|
||||||
return this.readProjectionFromDocument(doc);
|
return this.readProjectionFromDocument(doc);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail('Unknown source type');
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -213,7 +208,7 @@ ol.format.XMLFeature.prototype.readProjectionFromNode = function(node) {
|
|||||||
*/
|
*/
|
||||||
ol.format.XMLFeature.prototype.writeFeature = function(feature, opt_options) {
|
ol.format.XMLFeature.prototype.writeFeature = function(feature, opt_options) {
|
||||||
var node = this.writeFeatureNode(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');
|
'node.nodeType should be ELEMENT');
|
||||||
return this.xmlSerializer_.serializeToString(node);
|
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) {
|
ol.format.XMLFeature.prototype.writeFeatures = function(features, opt_options) {
|
||||||
var node = this.writeFeaturesNode(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');
|
'node.nodeType should be ELEMENT');
|
||||||
return this.xmlSerializer_.serializeToString(node);
|
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) {
|
ol.format.XMLFeature.prototype.writeGeometry = function(geometry, opt_options) {
|
||||||
var node = this.writeGeometryNode(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');
|
'node.nodeType should be ELEMENT');
|
||||||
return this.xmlSerializer_.serializeToString(node);
|
return this.xmlSerializer_.serializeToString(node);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.format.XML');
|
goog.provide('ol.format.XML');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.xml');
|
goog.require('ol.xml');
|
||||||
|
|
||||||
|
|
||||||
@@ -28,7 +27,6 @@ ol.format.XML.prototype.read = function(source) {
|
|||||||
var doc = ol.xml.parse(source);
|
var doc = ol.xml.parse(source);
|
||||||
return this.readFromDocument(doc);
|
return this.readFromDocument(doc);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.format.XSD');
|
goog.provide('ol.format.XSD');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.xml');
|
goog.require('ol.xml');
|
||||||
goog.require('ol.string');
|
goog.require('ol.string');
|
||||||
@@ -146,8 +145,8 @@ ol.format.XSD.writeDecimalTextNode = function(node, decimal) {
|
|||||||
* @param {number} nonNegativeInteger Non negative integer.
|
* @param {number} nonNegativeInteger Non negative integer.
|
||||||
*/
|
*/
|
||||||
ol.format.XSD.writeNonNegativeIntegerTextNode = function(node, nonNegativeInteger) {
|
ol.format.XSD.writeNonNegativeIntegerTextNode = function(node, nonNegativeInteger) {
|
||||||
goog.asserts.assert(nonNegativeInteger >= 0, 'value should be more than 0');
|
ol.DEBUG && console.assert(nonNegativeInteger >= 0, 'value should be more than 0');
|
||||||
goog.asserts.assert(nonNegativeInteger == (nonNegativeInteger | 0),
|
ol.DEBUG && console.assert(nonNegativeInteger == (nonNegativeInteger | 0),
|
||||||
'value should be an integer value');
|
'value should be an integer value');
|
||||||
var string = nonNegativeInteger.toString();
|
var string = nonNegativeInteger.toString();
|
||||||
node.appendChild(ol.xml.DOCUMENT.createTextNode(string));
|
node.appendChild(ol.xml.DOCUMENT.createTextNode(string));
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.geom.Circle');
|
goog.provide('ol.geom.Circle');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.geom.GeometryLayout');
|
goog.require('ol.geom.GeometryLayout');
|
||||||
goog.require('ol.geom.GeometryType');
|
goog.require('ol.geom.GeometryType');
|
||||||
@@ -163,7 +162,7 @@ ol.geom.Circle.prototype.intersectsExtent = function(extent) {
|
|||||||
*/
|
*/
|
||||||
ol.geom.Circle.prototype.setCenter = function(center) {
|
ol.geom.Circle.prototype.setCenter = function(center) {
|
||||||
var stride = this.stride;
|
var stride = this.stride;
|
||||||
goog.asserts.assert(center.length == stride,
|
ol.DEBUG && console.assert(center.length == stride,
|
||||||
'center array length should match stride');
|
'center array length should match stride');
|
||||||
var radius = this.flatCoordinates[stride] - this.flatCoordinates[0];
|
var radius = this.flatCoordinates[stride] - this.flatCoordinates[0];
|
||||||
var flatCoordinates = center.slice();
|
var flatCoordinates = center.slice();
|
||||||
@@ -223,7 +222,7 @@ ol.geom.Circle.prototype.setFlatCoordinates = function(layout, flatCoordinates)
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.geom.Circle.prototype.setRadius = function(radius) {
|
ol.geom.Circle.prototype.setRadius = function(radius) {
|
||||||
goog.asserts.assert(this.flatCoordinates,
|
ol.DEBUG && console.assert(this.flatCoordinates,
|
||||||
'truthy this.flatCoordinates expected');
|
'truthy this.flatCoordinates expected');
|
||||||
this.flatCoordinates[this.stride] = this.flatCoordinates[0] + radius;
|
this.flatCoordinates[this.stride] = this.flatCoordinates[0] + radius;
|
||||||
this.changed();
|
this.changed();
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.geom.flat.closest');
|
goog.provide('ol.geom.flat.closest');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.math');
|
goog.require('ol.math');
|
||||||
|
|
||||||
|
|
||||||
@@ -148,7 +147,7 @@ ol.geom.flat.closest.getClosestPoint = function(flatCoordinates, offset, end,
|
|||||||
return minSquaredDistance;
|
return minSquaredDistance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goog.asserts.assert(maxDelta > 0, 'maxDelta should be larger than 0');
|
ol.DEBUG && console.assert(maxDelta > 0, 'maxDelta should be larger than 0');
|
||||||
var tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
|
var tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
|
||||||
var index = offset + stride;
|
var index = offset + stride;
|
||||||
while (index < end) {
|
while (index < end) {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.geom.flat.contains');
|
goog.provide('ol.geom.flat.contains');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
|
|
||||||
|
|
||||||
@@ -65,7 +64,7 @@ ol.geom.flat.contains.linearRingContainsXY = function(flatCoordinates, offset, e
|
|||||||
* @return {boolean} Contains (x, y).
|
* @return {boolean} Contains (x, y).
|
||||||
*/
|
*/
|
||||||
ol.geom.flat.contains.linearRingsContainsXY = function(flatCoordinates, offset, ends, stride, x, y) {
|
ol.geom.flat.contains.linearRingsContainsXY = function(flatCoordinates, offset, ends, stride, x, y) {
|
||||||
goog.asserts.assert(ends.length > 0, 'ends should not be an empty array');
|
ol.DEBUG && console.assert(ends.length > 0, 'ends should not be an empty array');
|
||||||
if (ends.length === 0) {
|
if (ends.length === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -94,7 +93,7 @@ ol.geom.flat.contains.linearRingsContainsXY = function(flatCoordinates, offset,
|
|||||||
* @return {boolean} Contains (x, y).
|
* @return {boolean} Contains (x, y).
|
||||||
*/
|
*/
|
||||||
ol.geom.flat.contains.linearRingssContainsXY = function(flatCoordinates, offset, endss, stride, x, y) {
|
ol.geom.flat.contains.linearRingssContainsXY = function(flatCoordinates, offset, endss, stride, x, y) {
|
||||||
goog.asserts.assert(endss.length > 0, 'endss should not be an empty array');
|
ol.DEBUG && console.assert(endss.length > 0, 'endss should not be an empty array');
|
||||||
if (endss.length === 0) {
|
if (endss.length === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
goog.provide('ol.geom.flat.deflate');
|
goog.provide('ol.geom.flat.deflate');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
||||||
@@ -11,7 +9,7 @@ goog.require('goog.asserts');
|
|||||||
* @return {number} offset Offset.
|
* @return {number} offset Offset.
|
||||||
*/
|
*/
|
||||||
ol.geom.flat.deflate.coordinate = function(flatCoordinates, offset, coordinate, stride) {
|
ol.geom.flat.deflate.coordinate = function(flatCoordinates, offset, coordinate, stride) {
|
||||||
goog.asserts.assert(coordinate.length == stride,
|
ol.DEBUG && console.assert(coordinate.length == stride,
|
||||||
'length of the coordinate array should match stride');
|
'length of the coordinate array should match stride');
|
||||||
var i, ii;
|
var i, ii;
|
||||||
for (i = 0, ii = coordinate.length; i < ii; ++i) {
|
for (i = 0, ii = coordinate.length; i < ii; ++i) {
|
||||||
@@ -32,7 +30,7 @@ ol.geom.flat.deflate.coordinates = function(flatCoordinates, offset, coordinates
|
|||||||
var i, ii;
|
var i, ii;
|
||||||
for (i = 0, ii = coordinates.length; i < ii; ++i) {
|
for (i = 0, ii = coordinates.length; i < ii; ++i) {
|
||||||
var coordinate = coordinates[i];
|
var coordinate = coordinates[i];
|
||||||
goog.asserts.assert(coordinate.length == stride,
|
ol.DEBUG && console.assert(coordinate.length == stride,
|
||||||
'length of coordinate array should match stride');
|
'length of coordinate array should match stride');
|
||||||
var j;
|
var j;
|
||||||
for (j = 0; j < stride; ++j) {
|
for (j = 0; j < stride; ++j) {
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
goog.provide('ol.geom.flat.flip');
|
goog.provide('ol.geom.flat.flip');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
||||||
@@ -18,7 +16,7 @@ ol.geom.flat.flip.flipXY = function(flatCoordinates, offset, end, stride, opt_de
|
|||||||
dest = opt_dest;
|
dest = opt_dest;
|
||||||
destOffset = opt_destOffset !== undefined ? opt_destOffset : 0;
|
destOffset = opt_destOffset !== undefined ? opt_destOffset : 0;
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assert(opt_destOffset === undefined,
|
ol.DEBUG && console.assert(opt_destOffset === undefined,
|
||||||
'opt_destOffSet should be defined');
|
'opt_destOffSet should be defined');
|
||||||
dest = [];
|
dest = [];
|
||||||
destOffset = 0;
|
destOffset = 0;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.geom.flat.geodesic');
|
goog.provide('ol.geom.flat.geodesic');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.math');
|
goog.require('ol.math');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
|
|
||||||
@@ -65,7 +64,7 @@ ol.geom.flat.geodesic.line_ = function(interpolate, transform, squaredTolerance)
|
|||||||
// segment.
|
// segment.
|
||||||
flatCoordinates.push(b[0], b[1]);
|
flatCoordinates.push(b[0], b[1]);
|
||||||
key = fracB.toString();
|
key = fracB.toString();
|
||||||
goog.asserts.assert(!(key in fractions),
|
ol.DEBUG && console.assert(!(key in fractions),
|
||||||
'fractions object should contain key : ' + key);
|
'fractions object should contain key : ' + key);
|
||||||
fractions[key] = true;
|
fractions[key] = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -76,7 +75,7 @@ ol.geom.flat.geodesic.line_ = function(interpolate, transform, squaredTolerance)
|
|||||||
geoStack.push(geoB, geoM, geoM, geoA);
|
geoStack.push(geoB, geoM, geoM, geoA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goog.asserts.assert(maxIterations > 0,
|
ol.DEBUG && console.assert(maxIterations > 0,
|
||||||
'maxIterations should be more than 0');
|
'maxIterations should be more than 0');
|
||||||
|
|
||||||
return flatCoordinates;
|
return flatCoordinates;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.geom.flat.interiorpoint');
|
goog.provide('ol.geom.flat.interiorpoint');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
goog.require('ol.geom.flat.contains');
|
goog.require('ol.geom.flat.contains');
|
||||||
|
|
||||||
@@ -79,7 +78,7 @@ ol.geom.flat.interiorpoint.linearRings = function(flatCoordinates, offset,
|
|||||||
* @return {Array.<number>} Interior points.
|
* @return {Array.<number>} Interior points.
|
||||||
*/
|
*/
|
||||||
ol.geom.flat.interiorpoint.linearRingss = function(flatCoordinates, offset, endss, stride, flatCenters) {
|
ol.geom.flat.interiorpoint.linearRingss = function(flatCoordinates, offset, endss, stride, flatCenters) {
|
||||||
goog.asserts.assert(2 * endss.length == flatCenters.length,
|
ol.DEBUG && console.assert(2 * endss.length == flatCenters.length,
|
||||||
'endss.length times 2 should be flatCenters.length');
|
'endss.length times 2 should be flatCenters.length');
|
||||||
var interiorPoints = [];
|
var interiorPoints = [];
|
||||||
var i, ii;
|
var i, ii;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.geom.flat.interpolate');
|
goog.provide('ol.geom.flat.interpolate');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
goog.require('ol.math');
|
goog.require('ol.math');
|
||||||
|
|
||||||
@@ -17,13 +16,13 @@ goog.require('ol.math');
|
|||||||
ol.geom.flat.interpolate.lineString = function(flatCoordinates, offset, end, stride, fraction, opt_dest) {
|
ol.geom.flat.interpolate.lineString = function(flatCoordinates, offset, end, stride, fraction, opt_dest) {
|
||||||
// FIXME does not work when vertices are repeated
|
// FIXME does not work when vertices are repeated
|
||||||
// FIXME interpolate extra dimensions
|
// FIXME interpolate extra dimensions
|
||||||
goog.asserts.assert(0 <= fraction && fraction <= 1,
|
ol.DEBUG && console.assert(0 <= fraction && fraction <= 1,
|
||||||
'fraction should be in between 0 and 1');
|
'fraction should be in between 0 and 1');
|
||||||
var pointX = NaN;
|
var pointX = NaN;
|
||||||
var pointY = NaN;
|
var pointY = NaN;
|
||||||
var n = (end - offset) / stride;
|
var n = (end - offset) / stride;
|
||||||
if (n === 0) {
|
if (n === 0) {
|
||||||
goog.asserts.fail('n cannot be 0');
|
ol.DEBUG && console.assert(false, 'n cannot be 0');
|
||||||
} else if (n == 1) {
|
} else if (n == 1) {
|
||||||
pointX = flatCoordinates[offset];
|
pointX = flatCoordinates[offset];
|
||||||
pointY = flatCoordinates[offset + 1];
|
pointY = flatCoordinates[offset + 1];
|
||||||
@@ -121,8 +120,8 @@ ol.geom.flat.lineStringCoordinateAtM = function(flatCoordinates, offset, end, st
|
|||||||
return flatCoordinates.slice((lo - 1) * stride, (lo - 1) * stride + stride);
|
return flatCoordinates.slice((lo - 1) * stride, (lo - 1) * stride + stride);
|
||||||
}
|
}
|
||||||
var m1 = flatCoordinates[(lo + 1) * stride - 1];
|
var m1 = flatCoordinates[(lo + 1) * stride - 1];
|
||||||
goog.asserts.assert(m0 < m, 'm0 should be less than m');
|
ol.DEBUG && console.assert(m0 < m, 'm0 should be less than m');
|
||||||
goog.asserts.assert(m <= m1, 'm should be less than or equal to m1');
|
ol.DEBUG && console.assert(m <= m1, 'm should be less than or equal to m1');
|
||||||
var t = (m - m0) / (m1 - m0);
|
var t = (m - m0) / (m1 - m0);
|
||||||
coordinate = [];
|
coordinate = [];
|
||||||
var i;
|
var i;
|
||||||
@@ -131,7 +130,7 @@ ol.geom.flat.lineStringCoordinateAtM = function(flatCoordinates, offset, end, st
|
|||||||
flatCoordinates[lo * stride + i], t));
|
flatCoordinates[lo * stride + i], t));
|
||||||
}
|
}
|
||||||
coordinate.push(m);
|
coordinate.push(m);
|
||||||
goog.asserts.assert(coordinate.length == stride,
|
ol.DEBUG && console.assert(coordinate.length == stride,
|
||||||
'length of coordinate array should match stride');
|
'length of coordinate array should match stride');
|
||||||
return coordinate;
|
return coordinate;
|
||||||
};
|
};
|
||||||
@@ -186,7 +185,7 @@ ol.geom.flat.lineStringsCoordinateAtM = function(
|
|||||||
}
|
}
|
||||||
offset = end;
|
offset = end;
|
||||||
}
|
}
|
||||||
goog.asserts.fail(
|
ol.DEBUG && console.assert(false,
|
||||||
'ol.geom.flat.lineStringsCoordinateAtM should have returned');
|
'ol.geom.flat.lineStringsCoordinateAtM should have returned');
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.geom.flat.intersectsextent');
|
goog.provide('ol.geom.flat.intersectsextent');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.geom.flat.contains');
|
goog.require('ol.geom.flat.contains');
|
||||||
goog.require('ol.geom.flat.segments');
|
goog.require('ol.geom.flat.segments');
|
||||||
@@ -107,7 +106,7 @@ ol.geom.flat.intersectsextent.linearRing = function(flatCoordinates, offset, end
|
|||||||
* @return {boolean} True if the geometry and the extent intersect.
|
* @return {boolean} True if the geometry and the extent intersect.
|
||||||
*/
|
*/
|
||||||
ol.geom.flat.intersectsextent.linearRings = function(flatCoordinates, offset, ends, stride, extent) {
|
ol.geom.flat.intersectsextent.linearRings = function(flatCoordinates, offset, ends, stride, extent) {
|
||||||
goog.asserts.assert(ends.length > 0, 'ends should not be an empty array');
|
ol.DEBUG && console.assert(ends.length > 0, 'ends should not be an empty array');
|
||||||
if (!ol.geom.flat.intersectsextent.linearRing(
|
if (!ol.geom.flat.intersectsextent.linearRing(
|
||||||
flatCoordinates, offset, ends[0], stride, extent)) {
|
flatCoordinates, offset, ends[0], stride, extent)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -135,7 +134,7 @@ ol.geom.flat.intersectsextent.linearRings = function(flatCoordinates, offset, en
|
|||||||
* @return {boolean} True if the geometry and the extent intersect.
|
* @return {boolean} True if the geometry and the extent intersect.
|
||||||
*/
|
*/
|
||||||
ol.geom.flat.intersectsextent.linearRingss = function(flatCoordinates, offset, endss, stride, extent) {
|
ol.geom.flat.intersectsextent.linearRingss = function(flatCoordinates, offset, endss, stride, extent) {
|
||||||
goog.asserts.assert(endss.length > 0, 'endss should not be an empty array');
|
ol.DEBUG && console.assert(endss.length > 0, 'endss should not be an empty array');
|
||||||
var i, ii;
|
var i, ii;
|
||||||
for (i = 0, ii = endss.length; i < ii; ++i) {
|
for (i = 0, ii = endss.length; i < ii; ++i) {
|
||||||
var ends = endss[i];
|
var ends = endss[i];
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ goog.provide('ol.geom.Geometry');
|
|||||||
goog.provide('ol.geom.GeometryLayout');
|
goog.provide('ol.geom.GeometryLayout');
|
||||||
goog.provide('ol.geom.GeometryType');
|
goog.provide('ol.geom.GeometryType');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.functions');
|
goog.require('ol.functions');
|
||||||
goog.require('ol.Object');
|
goog.require('ol.Object');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
@@ -262,7 +261,7 @@ ol.geom.Geometry.prototype.translate = function(deltaX, deltaY) {};
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.geom.Geometry.prototype.transform = function(source, destination) {
|
ol.geom.Geometry.prototype.transform = function(source, destination) {
|
||||||
goog.asserts.assert(
|
ol.DEBUG && console.assert(
|
||||||
ol.proj.get(source).getUnits() !== ol.proj.Units.TILE_PIXELS &&
|
ol.proj.get(source).getUnits() !== ol.proj.Units.TILE_PIXELS &&
|
||||||
ol.proj.get(destination).getUnits() !== ol.proj.Units.TILE_PIXELS,
|
ol.proj.get(destination).getUnits() !== ol.proj.Units.TILE_PIXELS,
|
||||||
'cannot transform geometries with TILE_PIXELS units');
|
'cannot transform geometries with TILE_PIXELS units');
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.geom.LineString');
|
goog.provide('ol.geom.LineString');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
@@ -67,7 +66,7 @@ ol.inherits(ol.geom.LineString, ol.geom.SimpleGeometry);
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.geom.LineString.prototype.appendCoordinate = function(coordinate) {
|
ol.geom.LineString.prototype.appendCoordinate = function(coordinate) {
|
||||||
goog.asserts.assert(coordinate.length == this.stride,
|
ol.DEBUG && console.assert(coordinate.length == this.stride,
|
||||||
'length of coordinate array should match stride');
|
'length of coordinate array should match stride');
|
||||||
if (!this.flatCoordinates) {
|
if (!this.flatCoordinates) {
|
||||||
this.flatCoordinates = coordinate.slice();
|
this.flatCoordinates = coordinate.slice();
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.geom.MultiLineString');
|
goog.provide('ol.geom.MultiLineString');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
@@ -60,7 +59,7 @@ ol.inherits(ol.geom.MultiLineString, ol.geom.SimpleGeometry);
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.geom.MultiLineString.prototype.appendLineString = function(lineString) {
|
ol.geom.MultiLineString.prototype.appendLineString = function(lineString) {
|
||||||
goog.asserts.assert(lineString.getLayout() == this.layout,
|
ol.DEBUG && console.assert(lineString.getLayout() == this.layout,
|
||||||
'layout of lineString should match the layout');
|
'layout of lineString should match the layout');
|
||||||
if (!this.flatCoordinates) {
|
if (!this.flatCoordinates) {
|
||||||
this.flatCoordinates = lineString.getFlatCoordinates().slice();
|
this.flatCoordinates = lineString.getFlatCoordinates().slice();
|
||||||
@@ -166,7 +165,7 @@ ol.geom.MultiLineString.prototype.getEnds = function() {
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.geom.MultiLineString.prototype.getLineString = function(index) {
|
ol.geom.MultiLineString.prototype.getLineString = function(index) {
|
||||||
goog.asserts.assert(0 <= index && index < this.ends_.length,
|
ol.DEBUG && console.assert(0 <= index && index < this.ends_.length,
|
||||||
'index should be in between 0 and length of the this.ends_ array');
|
'index should be in between 0 and length of the this.ends_ array');
|
||||||
if (index < 0 || this.ends_.length <= index) {
|
if (index < 0 || this.ends_.length <= index) {
|
||||||
return null;
|
return null;
|
||||||
@@ -287,13 +286,13 @@ ol.geom.MultiLineString.prototype.setCoordinates = function(coordinates, opt_lay
|
|||||||
*/
|
*/
|
||||||
ol.geom.MultiLineString.prototype.setFlatCoordinates = function(layout, flatCoordinates, ends) {
|
ol.geom.MultiLineString.prototype.setFlatCoordinates = function(layout, flatCoordinates, ends) {
|
||||||
if (!flatCoordinates) {
|
if (!flatCoordinates) {
|
||||||
goog.asserts.assert(ends && ends.length === 0,
|
ol.DEBUG && console.assert(ends && ends.length === 0,
|
||||||
'ends must be truthy and ends.length should be 0');
|
'ends must be truthy and ends.length should be 0');
|
||||||
} else if (ends.length === 0) {
|
} else if (ends.length === 0) {
|
||||||
goog.asserts.assert(flatCoordinates.length === 0,
|
ol.DEBUG && console.assert(flatCoordinates.length === 0,
|
||||||
'flatCoordinates should be an empty array');
|
'flatCoordinates should be an empty array');
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assert(flatCoordinates.length == ends[ends.length - 1],
|
ol.DEBUG && console.assert(flatCoordinates.length == ends[ends.length - 1],
|
||||||
'length of flatCoordinates array should match the last value of ends');
|
'length of flatCoordinates array should match the last value of ends');
|
||||||
}
|
}
|
||||||
this.setFlatCoordinatesInternal(layout, flatCoordinates);
|
this.setFlatCoordinatesInternal(layout, flatCoordinates);
|
||||||
@@ -316,7 +315,7 @@ ol.geom.MultiLineString.prototype.setLineStrings = function(lineStrings) {
|
|||||||
layout = lineString.getLayout();
|
layout = lineString.getLayout();
|
||||||
} else {
|
} else {
|
||||||
// FIXME better handle the case of non-matching layouts
|
// FIXME better handle the case of non-matching layouts
|
||||||
goog.asserts.assert(lineString.getLayout() == layout,
|
ol.DEBUG && console.assert(lineString.getLayout() == layout,
|
||||||
'layout of lineString should match layout');
|
'layout of lineString should match layout');
|
||||||
}
|
}
|
||||||
ol.array.extend(flatCoordinates, lineString.getFlatCoordinates());
|
ol.array.extend(flatCoordinates, lineString.getFlatCoordinates());
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.geom.MultiPoint');
|
goog.provide('ol.geom.MultiPoint');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.geom.GeometryLayout');
|
goog.require('ol.geom.GeometryLayout');
|
||||||
@@ -35,7 +34,7 @@ ol.inherits(ol.geom.MultiPoint, ol.geom.SimpleGeometry);
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.geom.MultiPoint.prototype.appendPoint = function(point) {
|
ol.geom.MultiPoint.prototype.appendPoint = function(point) {
|
||||||
goog.asserts.assert(point.getLayout() == this.layout,
|
ol.DEBUG && console.assert(point.getLayout() == this.layout,
|
||||||
'the layout of point should match layout');
|
'the layout of point should match layout');
|
||||||
if (!this.flatCoordinates) {
|
if (!this.flatCoordinates) {
|
||||||
this.flatCoordinates = point.getFlatCoordinates().slice();
|
this.flatCoordinates = point.getFlatCoordinates().slice();
|
||||||
@@ -104,7 +103,7 @@ ol.geom.MultiPoint.prototype.getCoordinates = function() {
|
|||||||
ol.geom.MultiPoint.prototype.getPoint = function(index) {
|
ol.geom.MultiPoint.prototype.getPoint = function(index) {
|
||||||
var n = !this.flatCoordinates ?
|
var n = !this.flatCoordinates ?
|
||||||
0 : this.flatCoordinates.length / this.stride;
|
0 : this.flatCoordinates.length / this.stride;
|
||||||
goog.asserts.assert(0 <= index && index < n,
|
ol.DEBUG && console.assert(0 <= index && index < n,
|
||||||
'index should be in between 0 and n');
|
'index should be in between 0 and n');
|
||||||
if (index < 0 || n <= index) {
|
if (index < 0 || n <= index) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.geom.MultiPolygon');
|
goog.provide('ol.geom.MultiPolygon');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
@@ -89,7 +88,7 @@ ol.inherits(ol.geom.MultiPolygon, ol.geom.SimpleGeometry);
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.geom.MultiPolygon.prototype.appendPolygon = function(polygon) {
|
ol.geom.MultiPolygon.prototype.appendPolygon = function(polygon) {
|
||||||
goog.asserts.assert(polygon.getLayout() == this.layout,
|
ol.DEBUG && console.assert(polygon.getLayout() == this.layout,
|
||||||
'layout of polygon should match layout');
|
'layout of polygon should match layout');
|
||||||
/** @type {Array.<number>} */
|
/** @type {Array.<number>} */
|
||||||
var ends;
|
var ends;
|
||||||
@@ -280,7 +279,7 @@ ol.geom.MultiPolygon.prototype.getSimplifiedGeometryInternal = function(squaredT
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.geom.MultiPolygon.prototype.getPolygon = function(index) {
|
ol.geom.MultiPolygon.prototype.getPolygon = function(index) {
|
||||||
goog.asserts.assert(0 <= index && index < this.endss_.length,
|
ol.DEBUG && console.assert(0 <= index && index < this.endss_.length,
|
||||||
'index should be in between 0 and the length of this.endss_');
|
'index should be in between 0 and the length of this.endss_');
|
||||||
if (index < 0 || this.endss_.length <= index) {
|
if (index < 0 || this.endss_.length <= index) {
|
||||||
return null;
|
return null;
|
||||||
@@ -390,13 +389,13 @@ ol.geom.MultiPolygon.prototype.setCoordinates = function(coordinates, opt_layout
|
|||||||
* @param {Array.<Array.<number>>} endss Endss.
|
* @param {Array.<Array.<number>>} endss Endss.
|
||||||
*/
|
*/
|
||||||
ol.geom.MultiPolygon.prototype.setFlatCoordinates = function(layout, flatCoordinates, endss) {
|
ol.geom.MultiPolygon.prototype.setFlatCoordinates = function(layout, flatCoordinates, endss) {
|
||||||
goog.asserts.assert(endss, 'endss must be truthy');
|
ol.DEBUG && console.assert(endss, 'endss must be truthy');
|
||||||
if (!flatCoordinates || flatCoordinates.length === 0) {
|
if (!flatCoordinates || flatCoordinates.length === 0) {
|
||||||
goog.asserts.assert(endss.length === 0, 'the length of endss should be 0');
|
ol.DEBUG && console.assert(endss.length === 0, 'the length of endss should be 0');
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assert(endss.length > 0, 'endss cannot be an empty array');
|
ol.DEBUG && console.assert(endss.length > 0, 'endss cannot be an empty array');
|
||||||
var ends = endss[endss.length - 1];
|
var ends = endss[endss.length - 1];
|
||||||
goog.asserts.assert(flatCoordinates.length == ends[ends.length - 1],
|
ol.DEBUG && console.assert(flatCoordinates.length == ends[ends.length - 1],
|
||||||
'the length of flatCoordinates should be the last value of ends');
|
'the length of flatCoordinates should be the last value of ends');
|
||||||
}
|
}
|
||||||
this.setFlatCoordinatesInternal(layout, flatCoordinates);
|
this.setFlatCoordinatesInternal(layout, flatCoordinates);
|
||||||
@@ -419,7 +418,7 @@ ol.geom.MultiPolygon.prototype.setPolygons = function(polygons) {
|
|||||||
layout = polygon.getLayout();
|
layout = polygon.getLayout();
|
||||||
} else {
|
} else {
|
||||||
// FIXME better handle the case of non-matching layouts
|
// FIXME better handle the case of non-matching layouts
|
||||||
goog.asserts.assert(polygon.getLayout() == layout,
|
ol.DEBUG && console.assert(polygon.getLayout() == layout,
|
||||||
'layout of polygon should be layout');
|
'layout of polygon should be layout');
|
||||||
}
|
}
|
||||||
var offset = flatCoordinates.length;
|
var offset = flatCoordinates.length;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.geom.Polygon');
|
goog.provide('ol.geom.Polygon');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
@@ -89,7 +88,7 @@ ol.inherits(ol.geom.Polygon, ol.geom.SimpleGeometry);
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.geom.Polygon.prototype.appendLinearRing = function(linearRing) {
|
ol.geom.Polygon.prototype.appendLinearRing = function(linearRing) {
|
||||||
goog.asserts.assert(linearRing.getLayout() == this.layout,
|
ol.DEBUG && console.assert(linearRing.getLayout() == this.layout,
|
||||||
'layout of linearRing should match layout');
|
'layout of linearRing should match layout');
|
||||||
if (!this.flatCoordinates) {
|
if (!this.flatCoordinates) {
|
||||||
this.flatCoordinates = linearRing.getFlatCoordinates().slice();
|
this.flatCoordinates = linearRing.getFlatCoordinates().slice();
|
||||||
@@ -237,7 +236,7 @@ ol.geom.Polygon.prototype.getLinearRingCount = function() {
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.geom.Polygon.prototype.getLinearRing = function(index) {
|
ol.geom.Polygon.prototype.getLinearRing = function(index) {
|
||||||
goog.asserts.assert(0 <= index && index < this.ends_.length,
|
ol.DEBUG && console.assert(0 <= index && index < this.ends_.length,
|
||||||
'index should be in between 0 and and length of this.ends_');
|
'index should be in between 0 and and length of this.ends_');
|
||||||
if (index < 0 || this.ends_.length <= index) {
|
if (index < 0 || this.ends_.length <= index) {
|
||||||
return null;
|
return null;
|
||||||
@@ -358,13 +357,13 @@ ol.geom.Polygon.prototype.setCoordinates = function(coordinates, opt_layout) {
|
|||||||
*/
|
*/
|
||||||
ol.geom.Polygon.prototype.setFlatCoordinates = function(layout, flatCoordinates, ends) {
|
ol.geom.Polygon.prototype.setFlatCoordinates = function(layout, flatCoordinates, ends) {
|
||||||
if (!flatCoordinates) {
|
if (!flatCoordinates) {
|
||||||
goog.asserts.assert(ends && ends.length === 0,
|
ol.DEBUG && console.assert(ends && ends.length === 0,
|
||||||
'ends must be an empty array');
|
'ends must be an empty array');
|
||||||
} else if (ends.length === 0) {
|
} else if (ends.length === 0) {
|
||||||
goog.asserts.assert(flatCoordinates.length === 0,
|
ol.DEBUG && console.assert(flatCoordinates.length === 0,
|
||||||
'flatCoordinates should be an empty array');
|
'flatCoordinates should be an empty array');
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assert(flatCoordinates.length == ends[ends.length - 1],
|
ol.DEBUG && console.assert(flatCoordinates.length == ends[ends.length - 1],
|
||||||
'the length of flatCoordinates should be the last entry of ends');
|
'the length of flatCoordinates should be the last entry of ends');
|
||||||
}
|
}
|
||||||
this.setFlatCoordinatesInternal(layout, flatCoordinates);
|
this.setFlatCoordinatesInternal(layout, flatCoordinates);
|
||||||
@@ -461,7 +460,7 @@ ol.geom.Polygon.makeRegular = function(polygon, center, radius, opt_angle) {
|
|||||||
var layout = polygon.getLayout();
|
var layout = polygon.getLayout();
|
||||||
var stride = polygon.getStride();
|
var stride = polygon.getStride();
|
||||||
var ends = polygon.getEnds();
|
var ends = polygon.getEnds();
|
||||||
goog.asserts.assert(ends.length === 1, 'only 1 ring is supported');
|
ol.DEBUG && console.assert(ends.length === 1, 'only 1 ring is supported');
|
||||||
var sides = flatCoordinates.length / stride - 1;
|
var sides = flatCoordinates.length / stride - 1;
|
||||||
var startAngle = opt_angle ? opt_angle : 0;
|
var startAngle = opt_angle ? opt_angle : 0;
|
||||||
var angle, offset;
|
var angle, offset;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.geom.SimpleGeometry');
|
goog.provide('ol.geom.SimpleGeometry');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.functions');
|
goog.require('ol.functions');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.geom.Geometry');
|
goog.require('ol.geom.Geometry');
|
||||||
@@ -50,15 +49,16 @@ ol.inherits(ol.geom.SimpleGeometry, ol.geom.Geometry);
|
|||||||
* @return {ol.geom.GeometryLayout} layout Layout.
|
* @return {ol.geom.GeometryLayout} layout Layout.
|
||||||
*/
|
*/
|
||||||
ol.geom.SimpleGeometry.getLayoutForStride_ = function(stride) {
|
ol.geom.SimpleGeometry.getLayoutForStride_ = function(stride) {
|
||||||
|
var layout;
|
||||||
if (stride == 2) {
|
if (stride == 2) {
|
||||||
return ol.geom.GeometryLayout.XY;
|
layout = ol.geom.GeometryLayout.XY;
|
||||||
} else if (stride == 3) {
|
} else if (stride == 3) {
|
||||||
return ol.geom.GeometryLayout.XYZ;
|
layout = ol.geom.GeometryLayout.XYZ;
|
||||||
} else if (stride == 4) {
|
} else if (stride == 4) {
|
||||||
return ol.geom.GeometryLayout.XYZM;
|
layout = ol.geom.GeometryLayout.XYZM;
|
||||||
} else {
|
|
||||||
goog.asserts.fail('unsupported stride: ' + stride);
|
|
||||||
}
|
}
|
||||||
|
ol.DEBUG && console.assert(layout, 'unsupported stride: ' + stride);
|
||||||
|
return /** @type {ol.geom.GeometryLayout} */ (layout);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -67,17 +67,16 @@ ol.geom.SimpleGeometry.getLayoutForStride_ = function(stride) {
|
|||||||
* @return {number} Stride.
|
* @return {number} Stride.
|
||||||
*/
|
*/
|
||||||
ol.geom.SimpleGeometry.getStrideForLayout = function(layout) {
|
ol.geom.SimpleGeometry.getStrideForLayout = function(layout) {
|
||||||
|
var stride;
|
||||||
if (layout == ol.geom.GeometryLayout.XY) {
|
if (layout == ol.geom.GeometryLayout.XY) {
|
||||||
return 2;
|
stride = 2;
|
||||||
} else if (layout == ol.geom.GeometryLayout.XYZ) {
|
} else if (layout == ol.geom.GeometryLayout.XYZ || layout == ol.geom.GeometryLayout.XYM) {
|
||||||
return 3;
|
stride = 3;
|
||||||
} else if (layout == ol.geom.GeometryLayout.XYM) {
|
|
||||||
return 3;
|
|
||||||
} else if (layout == ol.geom.GeometryLayout.XYZM) {
|
} else if (layout == ol.geom.GeometryLayout.XYZM) {
|
||||||
return 4;
|
stride = 4;
|
||||||
} else {
|
|
||||||
goog.asserts.fail('unsupported layout: ' + layout);
|
|
||||||
}
|
}
|
||||||
|
ol.DEBUG && console.assert(stride, 'unsupported layout: ' + layout);
|
||||||
|
return /** @type {number} */ (stride);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.Graticule');
|
goog.provide('ol.Graticule');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.geom.GeometryLayout');
|
goog.require('ol.geom.GeometryLayout');
|
||||||
goog.require('ol.geom.LineString');
|
goog.require('ol.geom.LineString');
|
||||||
@@ -93,7 +92,7 @@ ol.Graticule = function(opt_options) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.maxLines_ = options.maxLines !== undefined ? options.maxLines : 100;
|
this.maxLines_ = options.maxLines !== undefined ? options.maxLines : 100;
|
||||||
goog.asserts.assert(this.maxLines_ > 0,
|
ol.DEBUG && console.assert(this.maxLines_ > 0,
|
||||||
'this.maxLines_ should be more than 0');
|
'this.maxLines_ should be more than 0');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -334,13 +333,13 @@ ol.Graticule.prototype.getMap = function() {
|
|||||||
*/
|
*/
|
||||||
ol.Graticule.prototype.getMeridian_ = function(lon, minLat, maxLat,
|
ol.Graticule.prototype.getMeridian_ = function(lon, minLat, maxLat,
|
||||||
squaredTolerance, index) {
|
squaredTolerance, index) {
|
||||||
goog.asserts.assert(lon >= this.minLon_,
|
ol.DEBUG && console.assert(lon >= this.minLon_,
|
||||||
'lon should be larger than or equal to this.minLon_');
|
'lon should be larger than or equal to this.minLon_');
|
||||||
goog.asserts.assert(lon <= this.maxLon_,
|
ol.DEBUG && console.assert(lon <= this.maxLon_,
|
||||||
'lon should be smaller than or equal to this.maxLon_');
|
'lon should be smaller than or equal to this.maxLon_');
|
||||||
var flatCoordinates = ol.geom.flat.geodesic.meridian(lon,
|
var flatCoordinates = ol.geom.flat.geodesic.meridian(lon,
|
||||||
minLat, maxLat, this.projection_, squaredTolerance);
|
minLat, maxLat, this.projection_, squaredTolerance);
|
||||||
goog.asserts.assert(flatCoordinates.length > 0,
|
ol.DEBUG && console.assert(flatCoordinates.length > 0,
|
||||||
'flatCoordinates cannot be empty');
|
'flatCoordinates cannot be empty');
|
||||||
var lineString = this.meridians_[index] !== undefined ?
|
var lineString = this.meridians_[index] !== undefined ?
|
||||||
this.meridians_[index] : new ol.geom.LineString(null);
|
this.meridians_[index] : new ol.geom.LineString(null);
|
||||||
@@ -370,13 +369,13 @@ ol.Graticule.prototype.getMeridians = function() {
|
|||||||
*/
|
*/
|
||||||
ol.Graticule.prototype.getParallel_ = function(lat, minLon, maxLon,
|
ol.Graticule.prototype.getParallel_ = function(lat, minLon, maxLon,
|
||||||
squaredTolerance, index) {
|
squaredTolerance, index) {
|
||||||
goog.asserts.assert(lat >= this.minLat_,
|
ol.DEBUG && console.assert(lat >= this.minLat_,
|
||||||
'lat should be larger than or equal to this.minLat_');
|
'lat should be larger than or equal to this.minLat_');
|
||||||
goog.asserts.assert(lat <= this.maxLat_,
|
ol.DEBUG && console.assert(lat <= this.maxLat_,
|
||||||
'lat should be smaller than or equal to this.maxLat_');
|
'lat should be smaller than or equal to this.maxLat_');
|
||||||
var flatCoordinates = ol.geom.flat.geodesic.parallel(lat,
|
var flatCoordinates = ol.geom.flat.geodesic.parallel(lat,
|
||||||
this.minLon_, this.maxLon_, this.projection_, squaredTolerance);
|
this.minLon_, this.maxLon_, this.projection_, squaredTolerance);
|
||||||
goog.asserts.assert(flatCoordinates.length > 0,
|
ol.DEBUG && console.assert(flatCoordinates.length > 0,
|
||||||
'flatCoordinates cannot be empty');
|
'flatCoordinates cannot be empty');
|
||||||
var lineString = this.parallels_[index] !== undefined ?
|
var lineString = this.parallels_[index] !== undefined ?
|
||||||
this.parallels_[index] : new ol.geom.LineString(null);
|
this.parallels_[index] : new ol.geom.LineString(null);
|
||||||
@@ -456,7 +455,7 @@ ol.Graticule.prototype.handlePostCompose_ = function(e) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.Graticule.prototype.updateProjectionInfo_ = function(projection) {
|
ol.Graticule.prototype.updateProjectionInfo_ = function(projection) {
|
||||||
goog.asserts.assert(projection, 'projection cannot be null');
|
ol.DEBUG && console.assert(projection, 'projection cannot be null');
|
||||||
|
|
||||||
var epsg4326Projection = ol.proj.get('EPSG:4326');
|
var epsg4326Projection = ol.proj.get('EPSG:4326');
|
||||||
|
|
||||||
@@ -475,19 +474,19 @@ ol.Graticule.prototype.updateProjectionInfo_ = function(projection) {
|
|||||||
var minLatP = worldExtentP[1];
|
var minLatP = worldExtentP[1];
|
||||||
var minLonP = worldExtentP[0];
|
var minLonP = worldExtentP[0];
|
||||||
|
|
||||||
goog.asserts.assert(extent, 'extent cannot be null');
|
ol.DEBUG && console.assert(extent, 'extent cannot be null');
|
||||||
goog.asserts.assert(maxLat !== undefined, 'maxLat should be defined');
|
ol.DEBUG && console.assert(maxLat !== undefined, 'maxLat should be defined');
|
||||||
goog.asserts.assert(maxLon !== undefined, 'maxLon should be defined');
|
ol.DEBUG && console.assert(maxLon !== undefined, 'maxLon should be defined');
|
||||||
goog.asserts.assert(minLat !== undefined, 'minLat should be defined');
|
ol.DEBUG && console.assert(minLat !== undefined, 'minLat should be defined');
|
||||||
goog.asserts.assert(minLon !== undefined, 'minLon should be defined');
|
ol.DEBUG && console.assert(minLon !== undefined, 'minLon should be defined');
|
||||||
|
|
||||||
goog.asserts.assert(maxLatP !== undefined,
|
ol.DEBUG && console.assert(maxLatP !== undefined,
|
||||||
'projected maxLat should be defined');
|
'projected maxLat should be defined');
|
||||||
goog.asserts.assert(maxLonP !== undefined,
|
ol.DEBUG && console.assert(maxLonP !== undefined,
|
||||||
'projected maxLon should be defined');
|
'projected maxLon should be defined');
|
||||||
goog.asserts.assert(minLatP !== undefined,
|
ol.DEBUG && console.assert(minLatP !== undefined,
|
||||||
'projected minLat should be defined');
|
'projected minLat should be defined');
|
||||||
goog.asserts.assert(minLonP !== undefined,
|
ol.DEBUG && console.assert(minLonP !== undefined,
|
||||||
'projected minLon should be defined');
|
'projected minLon should be defined');
|
||||||
|
|
||||||
this.maxLat_ = maxLat;
|
this.maxLat_ = maxLat;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.Image');
|
goog.provide('ol.Image');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.ImageBase');
|
goog.require('ol.ImageBase');
|
||||||
goog.require('ol.ImageState');
|
goog.require('ol.ImageState');
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
@@ -131,7 +130,7 @@ ol.Image.prototype.load = function() {
|
|||||||
if (this.state == ol.ImageState.IDLE || this.state == ol.ImageState.ERROR) {
|
if (this.state == ol.ImageState.IDLE || this.state == ol.ImageState.ERROR) {
|
||||||
this.state = ol.ImageState.LOADING;
|
this.state = ol.ImageState.LOADING;
|
||||||
this.changed();
|
this.changed();
|
||||||
goog.asserts.assert(!this.imageListenerKeys_,
|
ol.DEBUG && console.assert(!this.imageListenerKeys_,
|
||||||
'this.imageListenerKeys_ should be null');
|
'this.imageListenerKeys_ should be null');
|
||||||
this.imageListenerKeys_ = [
|
this.imageListenerKeys_ = [
|
||||||
ol.events.listenOnce(this.image_, ol.events.EventType.ERROR,
|
ol.events.listenOnce(this.image_, ol.events.EventType.ERROR,
|
||||||
@@ -158,7 +157,7 @@ ol.Image.prototype.setImage = function(image) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.Image.prototype.unlistenImage_ = function() {
|
ol.Image.prototype.unlistenImage_ = function() {
|
||||||
goog.asserts.assert(this.imageListenerKeys_,
|
ol.DEBUG && console.assert(this.imageListenerKeys_,
|
||||||
'this.imageListenerKeys_ should not be null');
|
'this.imageListenerKeys_ should not be null');
|
||||||
this.imageListenerKeys_.forEach(ol.events.unlistenByKey);
|
this.imageListenerKeys_.forEach(ol.events.unlistenByKey);
|
||||||
this.imageListenerKeys_ = null;
|
this.imageListenerKeys_ = null;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
goog.provide('ol.ImageBase');
|
goog.provide('ol.ImageBase');
|
||||||
goog.provide('ol.ImageState');
|
goog.provide('ol.ImageState');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.events.EventTarget');
|
goog.require('ol.events.EventTarget');
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
goog.require('ol.Attribution');
|
goog.require('ol.Attribution');
|
||||||
@@ -109,8 +108,8 @@ ol.ImageBase.prototype.getPixelRatio = function() {
|
|||||||
* @return {number} Resolution.
|
* @return {number} Resolution.
|
||||||
*/
|
*/
|
||||||
ol.ImageBase.prototype.getResolution = function() {
|
ol.ImageBase.prototype.getResolution = function() {
|
||||||
goog.asserts.assert(this.resolution !== undefined, 'resolution not yet set');
|
ol.DEBUG && console.assert(this.resolution !== undefined, 'resolution not yet set');
|
||||||
return this.resolution;
|
return /** @type {number} */ (this.resolution);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.ImageCanvas');
|
goog.provide('ol.ImageCanvas');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.ImageBase');
|
goog.require('ol.ImageBase');
|
||||||
goog.require('ol.ImageState');
|
goog.require('ol.ImageState');
|
||||||
|
|
||||||
@@ -77,7 +76,7 @@ ol.ImageCanvas.prototype.handleLoad_ = function(err) {
|
|||||||
*/
|
*/
|
||||||
ol.ImageCanvas.prototype.load = function() {
|
ol.ImageCanvas.prototype.load = function() {
|
||||||
if (this.state == ol.ImageState.IDLE) {
|
if (this.state == ol.ImageState.IDLE) {
|
||||||
goog.asserts.assert(this.loader_, 'this.loader_ must be set');
|
ol.DEBUG && console.assert(this.loader_, 'this.loader_ must be set');
|
||||||
this.state = ol.ImageState.LOADING;
|
this.state = ol.ImageState.LOADING;
|
||||||
this.changed();
|
this.changed();
|
||||||
this.loader_(this.handleLoad_.bind(this));
|
this.loader_(this.handleLoad_.bind(this));
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.ImageTile');
|
goog.provide('ol.ImageTile');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.Tile');
|
goog.require('ol.Tile');
|
||||||
goog.require('ol.TileState');
|
goog.require('ol.TileState');
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
@@ -146,7 +145,7 @@ ol.ImageTile.prototype.load = function() {
|
|||||||
if (this.state == ol.TileState.IDLE || this.state == ol.TileState.ERROR) {
|
if (this.state == ol.TileState.IDLE || this.state == ol.TileState.ERROR) {
|
||||||
this.state = ol.TileState.LOADING;
|
this.state = ol.TileState.LOADING;
|
||||||
this.changed();
|
this.changed();
|
||||||
goog.asserts.assert(!this.imageListenerKeys_,
|
ol.DEBUG && console.assert(!this.imageListenerKeys_,
|
||||||
'this.imageListenerKeys_ should be null');
|
'this.imageListenerKeys_ should be null');
|
||||||
this.imageListenerKeys_ = [
|
this.imageListenerKeys_ = [
|
||||||
ol.events.listenOnce(this.image_, ol.events.EventType.ERROR,
|
ol.events.listenOnce(this.image_, ol.events.EventType.ERROR,
|
||||||
@@ -165,7 +164,7 @@ ol.ImageTile.prototype.load = function() {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.ImageTile.prototype.unlistenImage_ = function() {
|
ol.ImageTile.prototype.unlistenImage_ = function() {
|
||||||
goog.asserts.assert(this.imageListenerKeys_,
|
ol.DEBUG && console.assert(this.imageListenerKeys_,
|
||||||
'this.imageListenerKeys_ should not be null');
|
'this.imageListenerKeys_ should not be null');
|
||||||
this.imageListenerKeys_.forEach(ol.events.unlistenByKey);
|
this.imageListenerKeys_.forEach(ol.events.unlistenByKey);
|
||||||
this.imageListenerKeys_ = null;
|
this.imageListenerKeys_ = null;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.interaction.DoubleClickZoom');
|
goog.provide('ol.interaction.DoubleClickZoom');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.MapBrowserEvent');
|
goog.require('ol.MapBrowserEvent');
|
||||||
goog.require('ol.MapBrowserEvent.EventType');
|
goog.require('ol.MapBrowserEvent.EventType');
|
||||||
goog.require('ol.interaction.Interaction');
|
goog.require('ol.interaction.Interaction');
|
||||||
@@ -55,7 +54,7 @@ ol.interaction.DoubleClickZoom.handleEvent = function(mapBrowserEvent) {
|
|||||||
var anchor = mapBrowserEvent.coordinate;
|
var anchor = mapBrowserEvent.coordinate;
|
||||||
var delta = browserEvent.shiftKey ? -this.delta_ : this.delta_;
|
var delta = browserEvent.shiftKey ? -this.delta_ : this.delta_;
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assert(view, 'map must have a view');
|
ol.DEBUG && console.assert(view, 'map must have a view');
|
||||||
ol.interaction.Interaction.zoomByDelta(
|
ol.interaction.Interaction.zoomByDelta(
|
||||||
map, view, delta, anchor, this.duration_);
|
map, view, delta, anchor, this.duration_);
|
||||||
mapBrowserEvent.preventDefault();
|
mapBrowserEvent.preventDefault();
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
goog.provide('ol.interaction.DragAndDrop');
|
goog.provide('ol.interaction.DragAndDrop');
|
||||||
goog.provide('ol.interaction.DragAndDropEvent');
|
goog.provide('ol.interaction.DragAndDropEvent');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.functions');
|
goog.require('ol.functions');
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.Event');
|
goog.require('ol.events.Event');
|
||||||
@@ -97,13 +96,13 @@ ol.interaction.DragAndDrop.handleStop_ = function(event) {
|
|||||||
ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, event) {
|
ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, event) {
|
||||||
var result = event.target.result;
|
var result = event.target.result;
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
goog.asserts.assert(map, 'map must be set');
|
ol.DEBUG && console.assert(map, 'map must be set');
|
||||||
var projection = this.projection_;
|
var projection = this.projection_;
|
||||||
if (!projection) {
|
if (!projection) {
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assert(view, 'map must have view');
|
ol.DEBUG && console.assert(view, 'map must have view');
|
||||||
projection = view.getProjection();
|
projection = view.getProjection();
|
||||||
goog.asserts.assert(projection !== undefined,
|
ol.DEBUG && console.assert(projection !== undefined,
|
||||||
'projection should be defined');
|
'projection should be defined');
|
||||||
}
|
}
|
||||||
var formatConstructors = this.formatConstructors_;
|
var formatConstructors = this.formatConstructors_;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.interaction.DragPan');
|
goog.provide('ol.interaction.DragPan');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.Kinetic');
|
goog.require('ol.Kinetic');
|
||||||
|
|
||||||
goog.require('ol.ViewHint');
|
goog.require('ol.ViewHint');
|
||||||
@@ -69,7 +68,7 @@ ol.inherits(ol.interaction.DragPan, ol.interaction.Pointer);
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.interaction.DragPan.handleDragEvent_ = function(mapBrowserEvent) {
|
ol.interaction.DragPan.handleDragEvent_ = function(mapBrowserEvent) {
|
||||||
goog.asserts.assert(this.targetPointers.length >= 1,
|
ol.DEBUG && console.assert(this.targetPointers.length >= 1,
|
||||||
'the length of this.targetPointers should be more than 1');
|
'the length of this.targetPointers should be more than 1');
|
||||||
var centroid =
|
var centroid =
|
||||||
ol.interaction.Pointer.centroid(this.targetPointers);
|
ol.interaction.Pointer.centroid(this.targetPointers);
|
||||||
@@ -107,8 +106,7 @@ ol.interaction.DragPan.handleUpEvent_ = function(mapBrowserEvent) {
|
|||||||
if (!this.noKinetic_ && this.kinetic_ && this.kinetic_.end()) {
|
if (!this.noKinetic_ && this.kinetic_ && this.kinetic_.end()) {
|
||||||
var distance = this.kinetic_.getDistance();
|
var distance = this.kinetic_.getDistance();
|
||||||
var angle = this.kinetic_.getAngle();
|
var angle = this.kinetic_.getAngle();
|
||||||
var center = view.getCenter();
|
var center = /** @type {!ol.Coordinate} */ (view.getCenter());
|
||||||
goog.asserts.assert(center !== undefined, 'center should be defined');
|
|
||||||
this.kineticPreRenderFn_ = this.kinetic_.pan(center);
|
this.kineticPreRenderFn_ = this.kinetic_.pan(center);
|
||||||
map.beforeRender(this.kineticPreRenderFn_);
|
map.beforeRender(this.kineticPreRenderFn_);
|
||||||
var centerpx = map.getPixelFromCoordinate(center);
|
var centerpx = map.getPixelFromCoordinate(center);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.interaction.DragZoom');
|
goog.provide('ol.interaction.DragZoom');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.animation');
|
goog.require('ol.animation');
|
||||||
goog.require('ol.easing');
|
goog.require('ol.easing');
|
||||||
goog.require('ol.events.condition');
|
goog.require('ol.events.condition');
|
||||||
@@ -55,11 +54,9 @@ ol.inherits(ol.interaction.DragZoom, ol.interaction.DragBox);
|
|||||||
ol.interaction.DragZoom.prototype.onBoxEnd = function() {
|
ol.interaction.DragZoom.prototype.onBoxEnd = function() {
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
|
|
||||||
var view = map.getView();
|
var view = /** @type {!ol.View} */ (map.getView());
|
||||||
goog.asserts.assert(view, 'map must have view');
|
|
||||||
|
|
||||||
var size = map.getSize();
|
var size = /** @type {!ol.Size} */ (map.getSize());
|
||||||
goog.asserts.assert(size !== undefined, 'size should be defined');
|
|
||||||
|
|
||||||
var extent = this.getGeometry().getExtent();
|
var extent = this.getGeometry().getExtent();
|
||||||
|
|
||||||
@@ -77,11 +74,9 @@ ol.interaction.DragZoom.prototype.onBoxEnd = function() {
|
|||||||
var resolution = view.constrainResolution(
|
var resolution = view.constrainResolution(
|
||||||
view.getResolutionForExtent(extent, size));
|
view.getResolutionForExtent(extent, size));
|
||||||
|
|
||||||
var currentResolution = view.getResolution();
|
var currentResolution = /** @type {number} */ (view.getResolution());
|
||||||
goog.asserts.assert(currentResolution !== undefined, 'res should be defined');
|
|
||||||
|
|
||||||
var currentCenter = view.getCenter();
|
var currentCenter = /** @type {!ol.Coordinate} */ (view.getCenter());
|
||||||
goog.asserts.assert(currentCenter !== undefined, 'center should be defined');
|
|
||||||
|
|
||||||
map.beforeRender(ol.animation.zoom({
|
map.beforeRender(ol.animation.zoom({
|
||||||
resolution: currentResolution,
|
resolution: currentResolution,
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ goog.provide('ol.interaction.DrawEvent');
|
|||||||
goog.provide('ol.interaction.DrawEventType');
|
goog.provide('ol.interaction.DrawEventType');
|
||||||
goog.provide('ol.interaction.DrawMode');
|
goog.provide('ol.interaction.DrawMode');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.Event');
|
goog.require('ol.events.Event');
|
||||||
goog.require('ol.Collection');
|
goog.require('ol.Collection');
|
||||||
@@ -175,10 +174,8 @@ ol.interaction.Draw = function(options) {
|
|||||||
* @return {ol.geom.SimpleGeometry} A geometry.
|
* @return {ol.geom.SimpleGeometry} A geometry.
|
||||||
*/
|
*/
|
||||||
geometryFunction = function(coordinates, opt_geometry) {
|
geometryFunction = function(coordinates, opt_geometry) {
|
||||||
var circle = opt_geometry ? opt_geometry :
|
var circle = opt_geometry ? /** @type {ol.geom.Circle} */ (opt_geometry) :
|
||||||
new ol.geom.Circle([NaN, NaN]);
|
new ol.geom.Circle([NaN, NaN]);
|
||||||
goog.asserts.assertInstanceof(circle, ol.geom.Circle,
|
|
||||||
'geometry must be an ol.geom.Circle');
|
|
||||||
var squaredLength = ol.coordinate.squaredDistance(
|
var squaredLength = ol.coordinate.squaredDistance(
|
||||||
coordinates[0], coordinates[1]);
|
coordinates[0], coordinates[1]);
|
||||||
circle.setCenterAndRadius(coordinates[0], Math.sqrt(squaredLength));
|
circle.setCenterAndRadius(coordinates[0], Math.sqrt(squaredLength));
|
||||||
@@ -488,9 +485,7 @@ ol.interaction.Draw.prototype.createOrUpdateSketchPoint_ = function(event) {
|
|||||||
this.sketchPoint_ = new ol.Feature(new ol.geom.Point(coordinates));
|
this.sketchPoint_ = new ol.Feature(new ol.geom.Point(coordinates));
|
||||||
this.updateSketchFeatures_();
|
this.updateSketchFeatures_();
|
||||||
} else {
|
} else {
|
||||||
var sketchPointGeom = this.sketchPoint_.getGeometry();
|
var sketchPointGeom = /** @type {ol.geom.Point} */ (this.sketchPoint_.getGeometry());
|
||||||
goog.asserts.assertInstanceof(sketchPointGeom, ol.geom.Point,
|
|
||||||
'sketchPointGeom should be an ol.geom.Point');
|
|
||||||
sketchPointGeom.setCoordinates(coordinates);
|
sketchPointGeom.setCoordinates(coordinates);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -520,7 +515,7 @@ ol.interaction.Draw.prototype.startDrawing_ = function(event) {
|
|||||||
new ol.geom.LineString(this.sketchLineCoords_));
|
new ol.geom.LineString(this.sketchLineCoords_));
|
||||||
}
|
}
|
||||||
var geometry = this.geometryFunction_(this.sketchCoords_);
|
var geometry = this.geometryFunction_(this.sketchCoords_);
|
||||||
goog.asserts.assert(geometry !== undefined, 'geometry should be defined');
|
ol.DEBUG && console.assert(geometry !== undefined, 'geometry should be defined');
|
||||||
this.sketchFeature_ = new ol.Feature();
|
this.sketchFeature_ = new ol.Feature();
|
||||||
if (this.geometryName_) {
|
if (this.geometryName_) {
|
||||||
this.sketchFeature_.setGeometryName(this.geometryName_);
|
this.sketchFeature_.setGeometryName(this.geometryName_);
|
||||||
@@ -539,9 +534,7 @@ ol.interaction.Draw.prototype.startDrawing_ = function(event) {
|
|||||||
*/
|
*/
|
||||||
ol.interaction.Draw.prototype.modifyDrawing_ = function(event) {
|
ol.interaction.Draw.prototype.modifyDrawing_ = function(event) {
|
||||||
var coordinate = event.coordinate;
|
var coordinate = event.coordinate;
|
||||||
var geometry = this.sketchFeature_.getGeometry();
|
var geometry = /** @type {ol.geom.SimpleGeometry} */ (this.sketchFeature_.getGeometry());
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.SimpleGeometry,
|
|
||||||
'geometry should be ol.geom.SimpleGeometry or subclass');
|
|
||||||
var coordinates, last;
|
var coordinates, last;
|
||||||
if (this.mode_ === ol.interaction.DrawMode.POINT) {
|
if (this.mode_ === ol.interaction.DrawMode.POINT) {
|
||||||
last = this.sketchCoords_;
|
last = this.sketchCoords_;
|
||||||
@@ -558,12 +551,12 @@ ol.interaction.Draw.prototype.modifyDrawing_ = function(event) {
|
|||||||
}
|
}
|
||||||
last[0] = coordinate[0];
|
last[0] = coordinate[0];
|
||||||
last[1] = coordinate[1];
|
last[1] = coordinate[1];
|
||||||
goog.asserts.assert(this.sketchCoords_, 'sketchCoords_ expected');
|
ol.DEBUG && console.assert(this.sketchCoords_, 'sketchCoords_ expected');
|
||||||
this.geometryFunction_(this.sketchCoords_, geometry);
|
this.geometryFunction_(
|
||||||
|
/** @type {!ol.Coordinate|!Array.<ol.Coordinate>|!Array.<Array.<ol.Coordinate>>} */ (this.sketchCoords_),
|
||||||
|
geometry);
|
||||||
if (this.sketchPoint_) {
|
if (this.sketchPoint_) {
|
||||||
var sketchPointGeom = this.sketchPoint_.getGeometry();
|
var sketchPointGeom = /** @type {ol.geom.Point} */ (this.sketchPoint_.getGeometry());
|
||||||
goog.asserts.assertInstanceof(sketchPointGeom, ol.geom.Point,
|
|
||||||
'sketchPointGeom should be an ol.geom.Point');
|
|
||||||
sketchPointGeom.setCoordinates(coordinate);
|
sketchPointGeom.setCoordinates(coordinate);
|
||||||
}
|
}
|
||||||
var sketchLineGeom;
|
var sketchLineGeom;
|
||||||
@@ -573,15 +566,11 @@ ol.interaction.Draw.prototype.modifyDrawing_ = function(event) {
|
|||||||
this.sketchLine_ = new ol.Feature(new ol.geom.LineString(null));
|
this.sketchLine_ = new ol.Feature(new ol.geom.LineString(null));
|
||||||
}
|
}
|
||||||
var ring = geometry.getLinearRing(0);
|
var ring = geometry.getLinearRing(0);
|
||||||
sketchLineGeom = this.sketchLine_.getGeometry();
|
sketchLineGeom = /** @type {ol.geom.LineString} */ (this.sketchLine_.getGeometry());
|
||||||
goog.asserts.assertInstanceof(sketchLineGeom, ol.geom.LineString,
|
|
||||||
'sketchLineGeom must be an ol.geom.LineString');
|
|
||||||
sketchLineGeom.setFlatCoordinates(
|
sketchLineGeom.setFlatCoordinates(
|
||||||
ring.getLayout(), ring.getFlatCoordinates());
|
ring.getLayout(), ring.getFlatCoordinates());
|
||||||
} else if (this.sketchLineCoords_) {
|
} else if (this.sketchLineCoords_) {
|
||||||
sketchLineGeom = this.sketchLine_.getGeometry();
|
sketchLineGeom = /** @type {ol.geom.LineString} */ (this.sketchLine_.getGeometry());
|
||||||
goog.asserts.assertInstanceof(sketchLineGeom, ol.geom.LineString,
|
|
||||||
'sketchLineGeom must be an ol.geom.LineString');
|
|
||||||
sketchLineGeom.setCoordinates(this.sketchLineCoords_);
|
sketchLineGeom.setCoordinates(this.sketchLineCoords_);
|
||||||
}
|
}
|
||||||
this.updateSketchFeatures_();
|
this.updateSketchFeatures_();
|
||||||
@@ -595,9 +584,7 @@ ol.interaction.Draw.prototype.modifyDrawing_ = function(event) {
|
|||||||
*/
|
*/
|
||||||
ol.interaction.Draw.prototype.addToDrawing_ = function(event) {
|
ol.interaction.Draw.prototype.addToDrawing_ = function(event) {
|
||||||
var coordinate = event.coordinate;
|
var coordinate = event.coordinate;
|
||||||
var geometry = this.sketchFeature_.getGeometry();
|
var geometry = /** @type {ol.geom.SimpleGeometry} */ (this.sketchFeature_.getGeometry());
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.SimpleGeometry,
|
|
||||||
'geometry must be an ol.geom.SimpleGeometry');
|
|
||||||
var done;
|
var done;
|
||||||
var coordinates;
|
var coordinates;
|
||||||
if (this.mode_ === ol.interaction.DrawMode.LINE_STRING) {
|
if (this.mode_ === ol.interaction.DrawMode.LINE_STRING) {
|
||||||
@@ -627,9 +614,7 @@ ol.interaction.Draw.prototype.addToDrawing_ = function(event) {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.interaction.Draw.prototype.removeLastPoint = function() {
|
ol.interaction.Draw.prototype.removeLastPoint = function() {
|
||||||
var geometry = this.sketchFeature_.getGeometry();
|
var geometry = /** @type {ol.geom.SimpleGeometry} */ (this.sketchFeature_.getGeometry());
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.SimpleGeometry,
|
|
||||||
'geometry must be an ol.geom.SimpleGeometry');
|
|
||||||
var coordinates, sketchLineGeom;
|
var coordinates, sketchLineGeom;
|
||||||
if (this.mode_ === ol.interaction.DrawMode.LINE_STRING) {
|
if (this.mode_ === ol.interaction.DrawMode.LINE_STRING) {
|
||||||
coordinates = this.sketchCoords_;
|
coordinates = this.sketchCoords_;
|
||||||
@@ -638,9 +623,7 @@ ol.interaction.Draw.prototype.removeLastPoint = function() {
|
|||||||
} else if (this.mode_ === ol.interaction.DrawMode.POLYGON) {
|
} else if (this.mode_ === ol.interaction.DrawMode.POLYGON) {
|
||||||
coordinates = this.sketchCoords_[0];
|
coordinates = this.sketchCoords_[0];
|
||||||
coordinates.splice(-2, 1);
|
coordinates.splice(-2, 1);
|
||||||
sketchLineGeom = this.sketchLine_.getGeometry();
|
sketchLineGeom = /** @type {ol.geom.LineString} */ (this.sketchLine_.getGeometry());
|
||||||
goog.asserts.assertInstanceof(sketchLineGeom, ol.geom.LineString,
|
|
||||||
'sketchLineGeom must be an ol.geom.LineString');
|
|
||||||
sketchLineGeom.setCoordinates(coordinates);
|
sketchLineGeom.setCoordinates(coordinates);
|
||||||
this.geometryFunction_(this.sketchCoords_, geometry);
|
this.geometryFunction_(this.sketchCoords_, geometry);
|
||||||
}
|
}
|
||||||
@@ -661,11 +644,9 @@ ol.interaction.Draw.prototype.removeLastPoint = function() {
|
|||||||
*/
|
*/
|
||||||
ol.interaction.Draw.prototype.finishDrawing = function() {
|
ol.interaction.Draw.prototype.finishDrawing = function() {
|
||||||
var sketchFeature = this.abortDrawing_();
|
var sketchFeature = this.abortDrawing_();
|
||||||
goog.asserts.assert(sketchFeature, 'sketchFeature expected to be truthy');
|
ol.DEBUG && console.assert(sketchFeature, 'sketchFeature expected to be truthy');
|
||||||
var coordinates = this.sketchCoords_;
|
var coordinates = this.sketchCoords_;
|
||||||
var geometry = sketchFeature.getGeometry();
|
var geometry = /** @type {ol.geom.SimpleGeometry} */ (sketchFeature.getGeometry());
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.SimpleGeometry,
|
|
||||||
'geometry must be an ol.geom.SimpleGeometry');
|
|
||||||
if (this.mode_ === ol.interaction.DrawMode.LINE_STRING) {
|
if (this.mode_ === ol.interaction.DrawMode.LINE_STRING) {
|
||||||
// remove the redundant last point
|
// remove the redundant last point
|
||||||
coordinates.pop();
|
coordinates.pop();
|
||||||
@@ -729,10 +710,10 @@ ol.interaction.Draw.prototype.abortDrawing_ = function() {
|
|||||||
*/
|
*/
|
||||||
ol.interaction.Draw.prototype.extend = function(feature) {
|
ol.interaction.Draw.prototype.extend = function(feature) {
|
||||||
var geometry = feature.getGeometry();
|
var geometry = feature.getGeometry();
|
||||||
goog.asserts.assert(this.mode_ == ol.interaction.DrawMode.LINE_STRING,
|
ol.DEBUG && console.assert(this.mode_ == ol.interaction.DrawMode.LINE_STRING,
|
||||||
'interaction mode must be "line"');
|
'interaction mode must be "line"');
|
||||||
goog.asserts.assert(geometry, 'feature must have a geometry');
|
ol.DEBUG && console.assert(geometry, 'feature must have a geometry');
|
||||||
goog.asserts.assert(geometry.getType() == ol.geom.GeometryType.LINE_STRING,
|
ol.DEBUG && console.assert(geometry.getType() == ol.geom.GeometryType.LINE_STRING,
|
||||||
'feature geometry must be a line string');
|
'feature geometry must be a line string');
|
||||||
var lineString = /** @type {ol.geom.LineString} */ (geometry);
|
var lineString = /** @type {ol.geom.LineString} */ (geometry);
|
||||||
this.sketchFeature_ = feature;
|
this.sketchFeature_ = feature;
|
||||||
@@ -811,10 +792,8 @@ ol.interaction.Draw.createRegularPolygon = function(opt_sides, opt_angle) {
|
|||||||
var end = coordinates[1];
|
var end = coordinates[1];
|
||||||
var radius = Math.sqrt(
|
var radius = Math.sqrt(
|
||||||
ol.coordinate.squaredDistance(center, end));
|
ol.coordinate.squaredDistance(center, end));
|
||||||
var geometry = opt_geometry ? opt_geometry :
|
var geometry = opt_geometry ? /** @type {ol.geom.Polygon} */ (opt_geometry) :
|
||||||
ol.geom.Polygon.fromCircle(new ol.geom.Circle(center), opt_sides);
|
ol.geom.Polygon.fromCircle(new ol.geom.Circle(center), opt_sides);
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.Polygon,
|
|
||||||
'geometry must be a polygon');
|
|
||||||
var angle = opt_angle ? opt_angle :
|
var angle = opt_angle ? opt_angle :
|
||||||
Math.atan((end[1] - center[1]) / (end[0] - center[0]));
|
Math.atan((end[1] - center[1]) / (end[0] - center[0]));
|
||||||
ol.geom.Polygon.makeRegular(geometry, center, radius, angle);
|
ol.geom.Polygon.makeRegular(geometry, center, radius, angle);
|
||||||
@@ -845,8 +824,7 @@ ol.interaction.Draw.getMode_ = function(type) {
|
|||||||
} else if (type === ol.geom.GeometryType.CIRCLE) {
|
} else if (type === ol.geom.GeometryType.CIRCLE) {
|
||||||
mode = ol.interaction.DrawMode.CIRCLE;
|
mode = ol.interaction.DrawMode.CIRCLE;
|
||||||
}
|
}
|
||||||
goog.asserts.assert(mode !== undefined, 'mode should be defined');
|
return /** @type {!ol.interaction.DrawMode} */ (mode);
|
||||||
return mode;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.interaction.KeyboardPan');
|
goog.provide('ol.interaction.KeyboardPan');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.coordinate');
|
goog.require('ol.coordinate');
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
@@ -88,7 +87,7 @@ ol.interaction.KeyboardPan.handleEvent = function(mapBrowserEvent) {
|
|||||||
keyCode == ol.events.KeyCode.UP)) {
|
keyCode == ol.events.KeyCode.UP)) {
|
||||||
var map = mapBrowserEvent.map;
|
var map = mapBrowserEvent.map;
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assert(view, 'map must have view');
|
ol.DEBUG && console.assert(view, 'map must have view');
|
||||||
var mapUnitsDelta = view.getResolution() * this.pixelDelta_;
|
var mapUnitsDelta = view.getResolution() * this.pixelDelta_;
|
||||||
var deltaX = 0, deltaY = 0;
|
var deltaX = 0, deltaY = 0;
|
||||||
if (keyCode == ol.events.KeyCode.DOWN) {
|
if (keyCode == ol.events.KeyCode.DOWN) {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.interaction.KeyboardZoom');
|
goog.provide('ol.interaction.KeyboardZoom');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
goog.require('ol.events.condition');
|
goog.require('ol.events.condition');
|
||||||
goog.require('ol.interaction.Interaction');
|
goog.require('ol.interaction.Interaction');
|
||||||
@@ -75,7 +74,7 @@ ol.interaction.KeyboardZoom.handleEvent = function(mapBrowserEvent) {
|
|||||||
var delta = (charCode == '+'.charCodeAt(0)) ? this.delta_ : -this.delta_;
|
var delta = (charCode == '+'.charCodeAt(0)) ? this.delta_ : -this.delta_;
|
||||||
map.render();
|
map.render();
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assert(view, 'map must have view');
|
ol.DEBUG && console.assert(view, 'map must have view');
|
||||||
ol.interaction.Interaction.zoomByDelta(
|
ol.interaction.Interaction.zoomByDelta(
|
||||||
map, view, delta, undefined, this.duration_);
|
map, view, delta, undefined, this.duration_);
|
||||||
mapBrowserEvent.preventDefault();
|
mapBrowserEvent.preventDefault();
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
goog.provide('ol.interaction.Modify');
|
goog.provide('ol.interaction.Modify');
|
||||||
goog.provide('ol.interaction.ModifyEvent');
|
goog.provide('ol.interaction.ModifyEvent');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.Event');
|
goog.require('ol.events.Event');
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
@@ -332,10 +331,7 @@ ol.interaction.Modify.prototype.setMap = function(map) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.interaction.Modify.prototype.handleFeatureAdd_ = function(evt) {
|
ol.interaction.Modify.prototype.handleFeatureAdd_ = function(evt) {
|
||||||
var feature = evt.element;
|
this.addFeature_(/** @type {ol.Feature} */ (evt.element));
|
||||||
goog.asserts.assertInstanceof(feature, ol.Feature,
|
|
||||||
'feature should be an ol.Feature');
|
|
||||||
this.addFeature_(feature);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -714,9 +710,7 @@ ol.interaction.Modify.handleEvent = function(mapBrowserEvent) {
|
|||||||
if (this.vertexFeature_ && this.deleteCondition_(mapBrowserEvent)) {
|
if (this.vertexFeature_ && this.deleteCondition_(mapBrowserEvent)) {
|
||||||
if (mapBrowserEvent.type != ol.MapBrowserEvent.EventType.SINGLECLICK ||
|
if (mapBrowserEvent.type != ol.MapBrowserEvent.EventType.SINGLECLICK ||
|
||||||
!this.ignoreNextSingleClick_) {
|
!this.ignoreNextSingleClick_) {
|
||||||
var geometry = this.vertexFeature_.getGeometry();
|
var geometry = /** @type {ol.geom.Point} */ (this.vertexFeature_.getGeometry());
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.Point,
|
|
||||||
'geometry should be an ol.geom.Point');
|
|
||||||
handled = this.removePoint();
|
handled = this.removePoint();
|
||||||
} else {
|
} else {
|
||||||
handled = true;
|
handled = true;
|
||||||
@@ -817,7 +811,7 @@ ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) {
|
|||||||
var feature = segmentData.feature;
|
var feature = segmentData.feature;
|
||||||
var geometry = segmentData.geometry;
|
var geometry = segmentData.geometry;
|
||||||
var depth = segmentData.depth;
|
var depth = segmentData.depth;
|
||||||
var index = segmentData.index;
|
var index = /** @type {number} */ (segmentData.index);
|
||||||
var coordinates;
|
var coordinates;
|
||||||
|
|
||||||
while (vertex.length < geometry.getStride()) {
|
while (vertex.length < geometry.getStride()) {
|
||||||
@@ -826,26 +820,18 @@ ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) {
|
|||||||
|
|
||||||
switch (geometry.getType()) {
|
switch (geometry.getType()) {
|
||||||
case ol.geom.GeometryType.MULTI_LINE_STRING:
|
case ol.geom.GeometryType.MULTI_LINE_STRING:
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.MultiLineString,
|
|
||||||
'geometry should be an ol.geom.MultiLineString');
|
|
||||||
coordinates = geometry.getCoordinates();
|
coordinates = geometry.getCoordinates();
|
||||||
coordinates[depth[0]].splice(index + 1, 0, vertex);
|
coordinates[depth[0]].splice(index + 1, 0, vertex);
|
||||||
break;
|
break;
|
||||||
case ol.geom.GeometryType.POLYGON:
|
case ol.geom.GeometryType.POLYGON:
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.Polygon,
|
|
||||||
'geometry should be an ol.geom.Polygon');
|
|
||||||
coordinates = geometry.getCoordinates();
|
coordinates = geometry.getCoordinates();
|
||||||
coordinates[depth[0]].splice(index + 1, 0, vertex);
|
coordinates[depth[0]].splice(index + 1, 0, vertex);
|
||||||
break;
|
break;
|
||||||
case ol.geom.GeometryType.MULTI_POLYGON:
|
case ol.geom.GeometryType.MULTI_POLYGON:
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.MultiPolygon,
|
|
||||||
'geometry should be an ol.geom.MultiPolygon');
|
|
||||||
coordinates = geometry.getCoordinates();
|
coordinates = geometry.getCoordinates();
|
||||||
coordinates[depth[1]][depth[0]].splice(index + 1, 0, vertex);
|
coordinates[depth[1]][depth[0]].splice(index + 1, 0, vertex);
|
||||||
break;
|
break;
|
||||||
case ol.geom.GeometryType.LINE_STRING:
|
case ol.geom.GeometryType.LINE_STRING:
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.LineString,
|
|
||||||
'geometry should be an ol.geom.LineString');
|
|
||||||
coordinates = geometry.getCoordinates();
|
coordinates = geometry.getCoordinates();
|
||||||
coordinates.splice(index + 1, 0, vertex);
|
coordinates.splice(index + 1, 0, vertex);
|
||||||
break;
|
break;
|
||||||
@@ -855,9 +841,8 @@ ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) {
|
|||||||
|
|
||||||
this.setGeometryCoordinates_(geometry, coordinates);
|
this.setGeometryCoordinates_(geometry, coordinates);
|
||||||
var rTree = this.rBush_;
|
var rTree = this.rBush_;
|
||||||
goog.asserts.assert(segment !== undefined, 'segment should be defined');
|
ol.DEBUG && console.assert(segment !== undefined, 'segment should be defined');
|
||||||
rTree.remove(segmentData);
|
rTree.remove(segmentData);
|
||||||
goog.asserts.assert(index !== undefined, 'index should be defined');
|
|
||||||
this.updateSegmentIndices_(geometry, index, depth, 1);
|
this.updateSegmentIndices_(geometry, index, depth, 1);
|
||||||
var newSegmentData = /** @type {ol.ModifySegmentDataType} */ ({
|
var newSegmentData = /** @type {ol.ModifySegmentDataType} */ ({
|
||||||
segment: [segment[0], vertex],
|
segment: [segment[0], vertex],
|
||||||
@@ -997,7 +982,7 @@ ol.interaction.Modify.prototype.removeVertex_ = function() {
|
|||||||
segments.push(right.segment[1]);
|
segments.push(right.segment[1]);
|
||||||
}
|
}
|
||||||
if (left !== undefined && right !== undefined) {
|
if (left !== undefined && right !== undefined) {
|
||||||
goog.asserts.assert(newIndex >= 0, 'newIndex should be larger than 0');
|
ol.DEBUG && console.assert(newIndex >= 0, 'newIndex should be larger than 0');
|
||||||
|
|
||||||
var newSegmentData = /** @type {ol.ModifySegmentDataType} */ ({
|
var newSegmentData = /** @type {ol.ModifySegmentDataType} */ ({
|
||||||
depth: segmentData.depth,
|
depth: segmentData.depth,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.interaction.MouseWheelZoom');
|
goog.provide('ol.interaction.MouseWheelZoom');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
goog.require('ol.interaction.Interaction');
|
goog.require('ol.interaction.Interaction');
|
||||||
@@ -132,7 +131,7 @@ ol.interaction.MouseWheelZoom.prototype.doZoom_ = function(map) {
|
|||||||
var delta = ol.math.clamp(this.delta_, -maxDelta, maxDelta);
|
var delta = ol.math.clamp(this.delta_, -maxDelta, maxDelta);
|
||||||
|
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assert(view, 'map must have view');
|
ol.DEBUG && console.assert(view, 'map must have view');
|
||||||
|
|
||||||
map.render();
|
map.render();
|
||||||
ol.interaction.Interaction.zoomByDelta(map, view, -delta, this.lastAnchor_,
|
ol.interaction.Interaction.zoomByDelta(map, view, -delta, this.lastAnchor_,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.interaction.PinchRotate');
|
goog.provide('ol.interaction.PinchRotate');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.functions');
|
goog.require('ol.functions');
|
||||||
goog.require('ol.ViewHint');
|
goog.require('ol.ViewHint');
|
||||||
@@ -74,7 +73,7 @@ ol.inherits(ol.interaction.PinchRotate, ol.interaction.Pointer);
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) {
|
ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) {
|
||||||
goog.asserts.assert(this.targetPointers.length >= 2,
|
ol.DEBUG && console.assert(this.targetPointers.length >= 2,
|
||||||
'length of this.targetPointers should be greater than or equal to 2');
|
'length of this.targetPointers should be greater than or equal to 2');
|
||||||
var rotationDelta = 0.0;
|
var rotationDelta = 0.0;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.interaction.PinchZoom');
|
goog.provide('ol.interaction.PinchZoom');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.functions');
|
goog.require('ol.functions');
|
||||||
goog.require('ol.ViewHint');
|
goog.require('ol.ViewHint');
|
||||||
@@ -62,7 +61,7 @@ ol.inherits(ol.interaction.PinchZoom, ol.interaction.Pointer);
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.interaction.PinchZoom.handleDragEvent_ = function(mapBrowserEvent) {
|
ol.interaction.PinchZoom.handleDragEvent_ = function(mapBrowserEvent) {
|
||||||
goog.asserts.assert(this.targetPointers.length >= 2,
|
ol.DEBUG && console.assert(this.targetPointers.length >= 2,
|
||||||
'length of this.targetPointers should be 2 or more');
|
'length of this.targetPointers should be 2 or more');
|
||||||
var scaleDelta = 1.0;
|
var scaleDelta = 1.0;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ goog.provide('ol.interaction.Select');
|
|||||||
goog.provide('ol.interaction.SelectEvent');
|
goog.provide('ol.interaction.SelectEvent');
|
||||||
goog.provide('ol.interaction.SelectEventType');
|
goog.provide('ol.interaction.SelectEventType');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.functions');
|
goog.require('ol.functions');
|
||||||
goog.require('ol.CollectionEventType');
|
goog.require('ol.CollectionEventType');
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
@@ -156,23 +155,13 @@ ol.interaction.Select = function(opt_options) {
|
|||||||
*/
|
*/
|
||||||
this.featureOverlay_ = featureOverlay;
|
this.featureOverlay_ = featureOverlay;
|
||||||
|
|
||||||
|
/** @type {function(ol.layer.Layer): boolean} */
|
||||||
var layerFilter;
|
var layerFilter;
|
||||||
if (options.layers) {
|
if (options.layers) {
|
||||||
if (typeof options.layers === 'function') {
|
if (typeof options.layers === 'function') {
|
||||||
/**
|
layerFilter = options.layers;
|
||||||
* @param {ol.layer.Layer} layer Layer.
|
|
||||||
* @return {boolean} Include.
|
|
||||||
*/
|
|
||||||
layerFilter = function(layer) {
|
|
||||||
goog.asserts.assertFunction(options.layers);
|
|
||||||
return options.layers(layer);
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
var layers = options.layers;
|
var layers = options.layers;
|
||||||
/**
|
|
||||||
* @param {ol.layer.Layer} layer Layer.
|
|
||||||
* @return {boolean} Include.
|
|
||||||
*/
|
|
||||||
layerFilter = function(layer) {
|
layerFilter = function(layer) {
|
||||||
return ol.array.includes(layers, layer);
|
return ol.array.includes(layers, layer);
|
||||||
};
|
};
|
||||||
@@ -236,8 +225,8 @@ ol.interaction.Select.prototype.getFeatures = function() {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.interaction.Select.prototype.getLayer = function(feature) {
|
ol.interaction.Select.prototype.getLayer = function(feature) {
|
||||||
goog.asserts.assertInstanceof(feature, ol.Feature,
|
ol.assert(feature instanceof ol.Feature,
|
||||||
'feature should be an ol.Feature');
|
42); // Expected an `ol.Feature`, but got an `ol.RenderFeature`
|
||||||
var key = ol.getUid(feature);
|
var key = ol.getUid(feature);
|
||||||
return /** @type {ol.layer.Vector} */ (this.featureLayerAssociation_[key]);
|
return /** @type {ol.layer.Vector} */ (this.featureLayerAssociation_[key]);
|
||||||
};
|
};
|
||||||
@@ -370,12 +359,9 @@ ol.interaction.Select.getDefaultStyleFunction = function() {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.interaction.Select.prototype.addFeature_ = function(evt) {
|
ol.interaction.Select.prototype.addFeature_ = function(evt) {
|
||||||
var feature = evt.element;
|
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
goog.asserts.assertInstanceof(feature, ol.Feature,
|
|
||||||
'feature should be an ol.Feature');
|
|
||||||
if (map) {
|
if (map) {
|
||||||
map.skipFeature(feature);
|
map.skipFeature(/** @type {ol.Feature} */ (evt.element));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -385,12 +371,9 @@ ol.interaction.Select.prototype.addFeature_ = function(evt) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.interaction.Select.prototype.removeFeature_ = function(evt) {
|
ol.interaction.Select.prototype.removeFeature_ = function(evt) {
|
||||||
var feature = evt.element;
|
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
goog.asserts.assertInstanceof(feature, ol.Feature,
|
|
||||||
'feature should be an ol.Feature');
|
|
||||||
if (map) {
|
if (map) {
|
||||||
map.unskipFeature(feature);
|
map.unskipFeature(/** @type {ol.Feature} */ (evt.element));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
goog.provide('ol.interaction.Snap');
|
goog.provide('ol.interaction.Snap');
|
||||||
goog.provide('ol.interaction.SnapProperty');
|
goog.provide('ol.interaction.SnapProperty');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Collection');
|
goog.require('ol.Collection');
|
||||||
goog.require('ol.CollectionEvent');
|
goog.require('ol.CollectionEvent');
|
||||||
@@ -228,8 +227,7 @@ ol.interaction.Snap.prototype.getFeatures_ = function() {
|
|||||||
} else if (this.source_) {
|
} else if (this.source_) {
|
||||||
features = this.source_.getFeatures();
|
features = this.source_.getFeatures();
|
||||||
}
|
}
|
||||||
goog.asserts.assert(features !== undefined, 'features should be defined');
|
return /** @type {!Array.<ol.Feature>|!ol.Collection.<ol.Feature>} */ (features);
|
||||||
return features;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -244,9 +242,7 @@ ol.interaction.Snap.prototype.handleFeatureAdd_ = function(evt) {
|
|||||||
} else if (evt instanceof ol.CollectionEvent) {
|
} else if (evt instanceof ol.CollectionEvent) {
|
||||||
feature = evt.element;
|
feature = evt.element;
|
||||||
}
|
}
|
||||||
goog.asserts.assertInstanceof(feature, ol.Feature,
|
this.addFeature(/** @type {ol.Feature} */ (feature));
|
||||||
'feature should be an ol.Feature');
|
|
||||||
this.addFeature(feature);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -261,9 +257,7 @@ ol.interaction.Snap.prototype.handleFeatureRemove_ = function(evt) {
|
|||||||
} else if (evt instanceof ol.CollectionEvent) {
|
} else if (evt instanceof ol.CollectionEvent) {
|
||||||
feature = evt.element;
|
feature = evt.element;
|
||||||
}
|
}
|
||||||
goog.asserts.assertInstanceof(feature, ol.Feature,
|
this.removeFeature(/** @type {ol.Feature} */ (feature));
|
||||||
'feature should be an ol.Feature');
|
|
||||||
this.removeFeature(feature);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -272,8 +266,7 @@ ol.interaction.Snap.prototype.handleFeatureRemove_ = function(evt) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.interaction.Snap.prototype.handleGeometryChange_ = function(evt) {
|
ol.interaction.Snap.prototype.handleGeometryChange_ = function(evt) {
|
||||||
var feature = evt.target;
|
var feature = /** @type {ol.Feature} */ (evt.target);
|
||||||
goog.asserts.assertInstanceof(feature, ol.Feature);
|
|
||||||
this.removeFeature(feature, true);
|
this.removeFeature(feature, true);
|
||||||
this.addFeature(feature, true);
|
this.addFeature(feature, true);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
goog.provide('ol.interaction.Translate');
|
goog.provide('ol.interaction.Translate');
|
||||||
goog.provide('ol.interaction.TranslateEvent');
|
goog.provide('ol.interaction.TranslateEvent');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.Event');
|
goog.require('ol.events.Event');
|
||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
@@ -107,23 +106,13 @@ ol.interaction.Translate = function(options) {
|
|||||||
*/
|
*/
|
||||||
this.features_ = options.features !== undefined ? options.features : null;
|
this.features_ = options.features !== undefined ? options.features : null;
|
||||||
|
|
||||||
|
/** @type {function(ol.layer.Layer): boolean} */
|
||||||
var layerFilter;
|
var layerFilter;
|
||||||
if (options.layers) {
|
if (options.layers) {
|
||||||
if (typeof options.layers === 'function') {
|
if (typeof options.layers === 'function') {
|
||||||
/**
|
layerFilter = options.layers;
|
||||||
* @param {ol.layer.Layer} layer Layer.
|
|
||||||
* @return {boolean} Include.
|
|
||||||
*/
|
|
||||||
layerFilter = function(layer) {
|
|
||||||
goog.asserts.assertFunction(options.layers);
|
|
||||||
return options.layers(layer);
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
var layers = options.layers;
|
var layers = options.layers;
|
||||||
/**
|
|
||||||
* @param {ol.layer.Layer} layer Layer.
|
|
||||||
* @return {boolean} Include.
|
|
||||||
*/
|
|
||||||
layerFilter = function(layer) {
|
layerFilter = function(layer) {
|
||||||
return ol.array.includes(layers, layer);
|
return ol.array.includes(layers, layer);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.layer.Heatmap');
|
goog.provide('ol.layer.Heatmap');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Object');
|
goog.require('ol.Object');
|
||||||
@@ -101,12 +100,12 @@ ol.layer.Heatmap = function(opt_options) {
|
|||||||
} else {
|
} else {
|
||||||
weightFunction = weight;
|
weightFunction = weight;
|
||||||
}
|
}
|
||||||
goog.asserts.assert(typeof weightFunction === 'function',
|
ol.DEBUG && console.assert(typeof weightFunction === 'function',
|
||||||
'weightFunction should be a function');
|
'weightFunction should be a function');
|
||||||
|
|
||||||
this.setStyle(function(feature, resolution) {
|
this.setStyle(function(feature, resolution) {
|
||||||
goog.asserts.assert(this.styleCache_, 'this.styleCache_ expected');
|
ol.DEBUG && console.assert(this.styleCache_, 'this.styleCache_ expected');
|
||||||
goog.asserts.assert(this.circleImage_ !== undefined,
|
ol.DEBUG && console.assert(this.circleImage_ !== undefined,
|
||||||
'this.circleImage_ should be defined');
|
'this.circleImage_ should be defined');
|
||||||
var weight = weightFunction(feature);
|
var weight = weightFunction(feature);
|
||||||
var opacity = weight !== undefined ? ol.math.clamp(weight, 0, 1) : 1;
|
var opacity = weight !== undefined ? ol.math.clamp(weight, 0, 1) : 1;
|
||||||
@@ -174,7 +173,7 @@ ol.layer.Heatmap.createGradient_ = function(colors) {
|
|||||||
ol.layer.Heatmap.prototype.createCircle_ = function() {
|
ol.layer.Heatmap.prototype.createCircle_ = function() {
|
||||||
var radius = this.getRadius();
|
var radius = this.getRadius();
|
||||||
var blur = this.getBlur();
|
var blur = this.getBlur();
|
||||||
goog.asserts.assert(radius !== undefined && blur !== undefined,
|
ol.DEBUG && console.assert(radius !== undefined && blur !== undefined,
|
||||||
'radius and blur should be defined');
|
'radius and blur should be defined');
|
||||||
var halfSize = radius + blur + 1;
|
var halfSize = radius + blur + 1;
|
||||||
var size = 2 * halfSize;
|
var size = 2 * halfSize;
|
||||||
@@ -247,9 +246,9 @@ ol.layer.Heatmap.prototype.handleStyleChanged_ = function() {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.layer.Heatmap.prototype.handleRender_ = function(event) {
|
ol.layer.Heatmap.prototype.handleRender_ = function(event) {
|
||||||
goog.asserts.assert(event.type == ol.render.EventType.RENDER,
|
ol.DEBUG && console.assert(event.type == ol.render.EventType.RENDER,
|
||||||
'event.type should be RENDER');
|
'event.type should be RENDER');
|
||||||
goog.asserts.assert(this.gradient_, 'this.gradient_ expected');
|
ol.DEBUG && console.assert(this.gradient_, 'this.gradient_ expected');
|
||||||
var context = event.context;
|
var context = event.context;
|
||||||
var canvas = context.canvas;
|
var canvas = context.canvas;
|
||||||
var image = context.getImageData(0, 0, canvas.width, canvas.height);
|
var image = context.getImageData(0, 0, canvas.width, canvas.height);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.layer.Group');
|
goog.provide('ol.layer.Group');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.Collection');
|
goog.require('ol.Collection');
|
||||||
goog.require('ol.CollectionEvent');
|
goog.require('ol.CollectionEvent');
|
||||||
goog.require('ol.CollectionEventType');
|
goog.require('ol.CollectionEventType');
|
||||||
@@ -64,8 +63,8 @@ ol.layer.Group = function(opt_options) {
|
|||||||
if (Array.isArray(layers)) {
|
if (Array.isArray(layers)) {
|
||||||
layers = new ol.Collection(layers.slice());
|
layers = new ol.Collection(layers.slice());
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assertInstanceof(layers, ol.Collection,
|
ol.assert(layers instanceof ol.Collection,
|
||||||
'layers should be an ol.Collection');
|
43); // Expected `layers` to be an array or an `ol.Collection`
|
||||||
layers = layers;
|
layers = layers;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -131,7 +130,7 @@ ol.layer.Group.prototype.handleLayersChanged_ = function(event) {
|
|||||||
ol.layer.Group.prototype.handleLayersAdd_ = function(collectionEvent) {
|
ol.layer.Group.prototype.handleLayersAdd_ = function(collectionEvent) {
|
||||||
var layer = /** @type {ol.layer.Base} */ (collectionEvent.element);
|
var layer = /** @type {ol.layer.Base} */ (collectionEvent.element);
|
||||||
var key = ol.getUid(layer).toString();
|
var key = ol.getUid(layer).toString();
|
||||||
goog.asserts.assert(!(key in this.listenerKeys_),
|
ol.DEBUG && console.assert(!(key in this.listenerKeys_),
|
||||||
'listeners already registered');
|
'listeners already registered');
|
||||||
this.listenerKeys_[key] = [
|
this.listenerKeys_[key] = [
|
||||||
ol.events.listen(layer, ol.ObjectEventType.PROPERTYCHANGE,
|
ol.events.listen(layer, ol.ObjectEventType.PROPERTYCHANGE,
|
||||||
@@ -150,7 +149,7 @@ ol.layer.Group.prototype.handleLayersAdd_ = function(collectionEvent) {
|
|||||||
ol.layer.Group.prototype.handleLayersRemove_ = function(collectionEvent) {
|
ol.layer.Group.prototype.handleLayersRemove_ = function(collectionEvent) {
|
||||||
var layer = /** @type {ol.layer.Base} */ (collectionEvent.element);
|
var layer = /** @type {ol.layer.Base} */ (collectionEvent.element);
|
||||||
var key = ol.getUid(layer).toString();
|
var key = ol.getUid(layer).toString();
|
||||||
goog.asserts.assert(key in this.listenerKeys_, 'no listeners to unregister');
|
ol.DEBUG && console.assert(key in this.listenerKeys_, 'no listeners to unregister');
|
||||||
this.listenerKeys_[key].forEach(ol.events.unlistenByKey);
|
this.listenerKeys_[key].forEach(ol.events.unlistenByKey);
|
||||||
delete this.listenerKeys_[key];
|
delete this.listenerKeys_[key];
|
||||||
this.changed();
|
this.changed();
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.layer.Vector');
|
goog.provide('ol.layer.Vector');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.layer.Layer');
|
goog.require('ol.layer.Layer');
|
||||||
goog.require('ol.object');
|
goog.require('ol.object');
|
||||||
@@ -33,7 +32,7 @@ ol.layer.Vector = function(opt_options) {
|
|||||||
var options = opt_options ?
|
var options = opt_options ?
|
||||||
opt_options : /** @type {olx.layer.VectorOptions} */ ({});
|
opt_options : /** @type {olx.layer.VectorOptions} */ ({});
|
||||||
|
|
||||||
goog.asserts.assert(
|
ol.DEBUG && console.assert(
|
||||||
options.renderOrder === undefined || !options.renderOrder ||
|
options.renderOrder === undefined || !options.renderOrder ||
|
||||||
typeof options.renderOrder === 'function',
|
typeof options.renderOrder === 'function',
|
||||||
'renderOrder must be a comparator function');
|
'renderOrder must be a comparator function');
|
||||||
@@ -159,7 +158,7 @@ ol.layer.Vector.prototype.getUpdateWhileInteracting = function() {
|
|||||||
* Render order.
|
* Render order.
|
||||||
*/
|
*/
|
||||||
ol.layer.Vector.prototype.setRenderOrder = function(renderOrder) {
|
ol.layer.Vector.prototype.setRenderOrder = function(renderOrder) {
|
||||||
goog.asserts.assert(
|
ol.DEBUG && console.assert(
|
||||||
renderOrder === undefined || !renderOrder ||
|
renderOrder === undefined || !renderOrder ||
|
||||||
typeof renderOrder === 'function',
|
typeof renderOrder === 'function',
|
||||||
'renderOrder must be a comparator function');
|
'renderOrder must be a comparator function');
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.layer.VectorTile');
|
goog.provide('ol.layer.VectorTile');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.layer.Vector');
|
goog.require('ol.layer.Vector');
|
||||||
goog.require('ol.object');
|
goog.require('ol.object');
|
||||||
|
|
||||||
@@ -59,11 +58,11 @@ ol.layer.VectorTile = function(opt_options) {
|
|||||||
this.setUseInterimTilesOnError(options.useInterimTilesOnError ?
|
this.setUseInterimTilesOnError(options.useInterimTilesOnError ?
|
||||||
options.useInterimTilesOnError : true);
|
options.useInterimTilesOnError : true);
|
||||||
|
|
||||||
goog.asserts.assert(options.renderMode == undefined ||
|
ol.assert(options.renderMode == undefined ||
|
||||||
options.renderMode == ol.layer.VectorTileRenderType.IMAGE ||
|
options.renderMode == ol.layer.VectorTileRenderType.IMAGE ||
|
||||||
options.renderMode == ol.layer.VectorTileRenderType.HYBRID ||
|
options.renderMode == ol.layer.VectorTileRenderType.HYBRID ||
|
||||||
options.renderMode == ol.layer.VectorTileRenderType.VECTOR,
|
options.renderMode == ol.layer.VectorTileRenderType.VECTOR,
|
||||||
'renderMode needs to be \'image\', \'hybrid\' or \'vector\'');
|
28); // `renderMode` must be `'image'`, `'hybrid'` or `'vector'`
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
goog.provide('ol.Map');
|
goog.provide('ol.Map');
|
||||||
goog.provide('ol.MapProperty');
|
goog.provide('ol.MapProperty');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('goog.async.nextTick');
|
goog.require('goog.async.nextTick');
|
||||||
goog.require('ol.Collection');
|
goog.require('ol.Collection');
|
||||||
goog.require('ol.CollectionEventType');
|
goog.require('ol.CollectionEventType');
|
||||||
@@ -15,7 +14,6 @@ goog.require('ol.MapBrowserEventHandler');
|
|||||||
goog.require('ol.MapEvent');
|
goog.require('ol.MapEvent');
|
||||||
goog.require('ol.MapEventType');
|
goog.require('ol.MapEventType');
|
||||||
goog.require('ol.Object');
|
goog.require('ol.Object');
|
||||||
goog.require('ol.ObjectEvent');
|
|
||||||
goog.require('ol.ObjectEventType');
|
goog.require('ol.ObjectEventType');
|
||||||
goog.require('ol.RendererType');
|
goog.require('ol.RendererType');
|
||||||
goog.require('ol.TileQueue');
|
goog.require('ol.TileQueue');
|
||||||
@@ -481,7 +479,7 @@ ol.inherits(ol.Map, ol.Object);
|
|||||||
*/
|
*/
|
||||||
ol.Map.prototype.addControl = function(control) {
|
ol.Map.prototype.addControl = function(control) {
|
||||||
var controls = this.getControls();
|
var controls = this.getControls();
|
||||||
goog.asserts.assert(controls !== undefined, 'controls should be defined');
|
ol.DEBUG && console.assert(controls !== undefined, 'controls should be defined');
|
||||||
controls.push(control);
|
controls.push(control);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -493,7 +491,7 @@ ol.Map.prototype.addControl = function(control) {
|
|||||||
*/
|
*/
|
||||||
ol.Map.prototype.addInteraction = function(interaction) {
|
ol.Map.prototype.addInteraction = function(interaction) {
|
||||||
var interactions = this.getInteractions();
|
var interactions = this.getInteractions();
|
||||||
goog.asserts.assert(interactions !== undefined,
|
ol.DEBUG && console.assert(interactions !== undefined,
|
||||||
'interactions should be defined');
|
'interactions should be defined');
|
||||||
interactions.push(interaction);
|
interactions.push(interaction);
|
||||||
};
|
};
|
||||||
@@ -519,7 +517,7 @@ ol.Map.prototype.addLayer = function(layer) {
|
|||||||
*/
|
*/
|
||||||
ol.Map.prototype.addOverlay = function(overlay) {
|
ol.Map.prototype.addOverlay = function(overlay) {
|
||||||
var overlays = this.getOverlays();
|
var overlays = this.getOverlays();
|
||||||
goog.asserts.assert(overlays !== undefined, 'overlays should be defined');
|
ol.DEBUG && console.assert(overlays !== undefined, 'overlays should be defined');
|
||||||
overlays.push(overlay);
|
overlays.push(overlay);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -976,7 +974,7 @@ ol.Map.prototype.handleMapBrowserEvent = function(mapBrowserEvent) {
|
|||||||
this.focus_ = mapBrowserEvent.coordinate;
|
this.focus_ = mapBrowserEvent.coordinate;
|
||||||
mapBrowserEvent.frameState = this.frameState_;
|
mapBrowserEvent.frameState = this.frameState_;
|
||||||
var interactions = this.getInteractions();
|
var interactions = this.getInteractions();
|
||||||
goog.asserts.assert(interactions !== undefined,
|
ol.DEBUG && console.assert(interactions !== undefined,
|
||||||
'interactions should be defined');
|
'interactions should be defined');
|
||||||
var interactionsArray = interactions.getArray();
|
var interactionsArray = interactions.getArray();
|
||||||
var i;
|
var i;
|
||||||
@@ -1061,7 +1059,7 @@ ol.Map.prototype.handleTargetChanged_ = function() {
|
|||||||
var targetElement;
|
var targetElement;
|
||||||
if (this.getTarget()) {
|
if (this.getTarget()) {
|
||||||
targetElement = this.getTargetElement();
|
targetElement = this.getTargetElement();
|
||||||
goog.asserts.assert(targetElement !== null,
|
ol.DEBUG && console.assert(targetElement !== null,
|
||||||
'expects a non-null value for targetElement');
|
'expects a non-null value for targetElement');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1138,28 +1136,6 @@ ol.Map.prototype.handleViewChanged_ = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.events.Event} event Event.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
ol.Map.prototype.handleLayerGroupMemberChanged_ = function(event) {
|
|
||||||
goog.asserts.assertInstanceof(event, ol.events.Event,
|
|
||||||
'event should be an Event');
|
|
||||||
this.render();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.ObjectEvent} event Event.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
ol.Map.prototype.handleLayerGroupPropertyChanged_ = function(event) {
|
|
||||||
goog.asserts.assertInstanceof(event, ol.ObjectEvent,
|
|
||||||
'event should be an ol.ObjectEvent');
|
|
||||||
this.render();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
@@ -1173,10 +1149,10 @@ ol.Map.prototype.handleLayerGroupChanged_ = function() {
|
|||||||
this.layerGroupPropertyListenerKeys_ = [
|
this.layerGroupPropertyListenerKeys_ = [
|
||||||
ol.events.listen(
|
ol.events.listen(
|
||||||
layerGroup, ol.ObjectEventType.PROPERTYCHANGE,
|
layerGroup, ol.ObjectEventType.PROPERTYCHANGE,
|
||||||
this.handleLayerGroupPropertyChanged_, this),
|
this.render, this),
|
||||||
ol.events.listen(
|
ol.events.listen(
|
||||||
layerGroup, ol.events.EventType.CHANGE,
|
layerGroup, ol.events.EventType.CHANGE,
|
||||||
this.handleLayerGroupMemberChanged_, this)
|
this.render, this)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
this.render();
|
this.render();
|
||||||
@@ -1224,7 +1200,7 @@ ol.Map.prototype.render = function() {
|
|||||||
*/
|
*/
|
||||||
ol.Map.prototype.removeControl = function(control) {
|
ol.Map.prototype.removeControl = function(control) {
|
||||||
var controls = this.getControls();
|
var controls = this.getControls();
|
||||||
goog.asserts.assert(controls !== undefined, 'controls should be defined');
|
ol.DEBUG && console.assert(controls !== undefined, 'controls should be defined');
|
||||||
return controls.remove(control);
|
return controls.remove(control);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1238,7 +1214,7 @@ ol.Map.prototype.removeControl = function(control) {
|
|||||||
*/
|
*/
|
||||||
ol.Map.prototype.removeInteraction = function(interaction) {
|
ol.Map.prototype.removeInteraction = function(interaction) {
|
||||||
var interactions = this.getInteractions();
|
var interactions = this.getInteractions();
|
||||||
goog.asserts.assert(interactions !== undefined,
|
ol.DEBUG && console.assert(interactions !== undefined,
|
||||||
'interactions should be defined');
|
'interactions should be defined');
|
||||||
return interactions.remove(interaction);
|
return interactions.remove(interaction);
|
||||||
};
|
};
|
||||||
@@ -1266,7 +1242,7 @@ ol.Map.prototype.removeLayer = function(layer) {
|
|||||||
*/
|
*/
|
||||||
ol.Map.prototype.removeOverlay = function(overlay) {
|
ol.Map.prototype.removeOverlay = function(overlay) {
|
||||||
var overlays = this.getOverlays();
|
var overlays = this.getOverlays();
|
||||||
goog.asserts.assert(overlays !== undefined, 'overlays should be defined');
|
ol.DEBUG && console.assert(overlays !== undefined, 'overlays should be defined');
|
||||||
return overlays.remove(overlay);
|
return overlays.remove(overlay);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1486,9 +1462,9 @@ ol.Map.createOptionsInternal = function(options) {
|
|||||||
logos[logo] = '';
|
logos[logo] = '';
|
||||||
} else if (logo instanceof HTMLElement) {
|
} else if (logo instanceof HTMLElement) {
|
||||||
logos[ol.getUid(logo).toString()] = logo;
|
logos[ol.getUid(logo).toString()] = logo;
|
||||||
} else if (logo !== null) {
|
} else if (logo) {
|
||||||
goog.asserts.assertString(logo.href, 'logo.href should be a string');
|
ol.assert(typeof logo.href == 'string', 44); // `logo.href` should be a string.
|
||||||
goog.asserts.assertString(logo.src, 'logo.src should be a string');
|
ol.assert(typeof logo.src == 'string', 45); // `logo.src` should be a string.
|
||||||
logos[logo.src] = logo.href;
|
logos[logo.src] = logo.href;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1517,7 +1493,7 @@ ol.Map.createOptionsInternal = function(options) {
|
|||||||
} else if (typeof options.renderer === 'string') {
|
} else if (typeof options.renderer === 'string') {
|
||||||
rendererTypes = [options.renderer];
|
rendererTypes = [options.renderer];
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail('Incorrect format for renderer option');
|
ol.assert(false, 46); // Incorrect format for `renderer` option
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rendererTypes = ol.DEFAULT_RENDERER_TYPES;
|
rendererTypes = ol.DEFAULT_RENDERER_TYPES;
|
||||||
@@ -1550,8 +1526,8 @@ ol.Map.createOptionsInternal = function(options) {
|
|||||||
if (Array.isArray(options.controls)) {
|
if (Array.isArray(options.controls)) {
|
||||||
controls = new ol.Collection(options.controls.slice());
|
controls = new ol.Collection(options.controls.slice());
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assertInstanceof(options.controls, ol.Collection,
|
ol.assert(options.controls instanceof ol.Collection,
|
||||||
'options.controls should be an ol.Collection');
|
47); // Expected `controls` to be an array or an `ol.Collection`
|
||||||
controls = options.controls;
|
controls = options.controls;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1563,8 +1539,8 @@ ol.Map.createOptionsInternal = function(options) {
|
|||||||
if (Array.isArray(options.interactions)) {
|
if (Array.isArray(options.interactions)) {
|
||||||
interactions = new ol.Collection(options.interactions.slice());
|
interactions = new ol.Collection(options.interactions.slice());
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assertInstanceof(options.interactions, ol.Collection,
|
ol.assert(options.interactions instanceof ol.Collection,
|
||||||
'options.interactions should be an ol.Collection');
|
48); // Expected `interactions` to be an array or an `ol.Collection`
|
||||||
interactions = options.interactions;
|
interactions = options.interactions;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1576,8 +1552,8 @@ ol.Map.createOptionsInternal = function(options) {
|
|||||||
if (Array.isArray(options.overlays)) {
|
if (Array.isArray(options.overlays)) {
|
||||||
overlays = new ol.Collection(options.overlays.slice());
|
overlays = new ol.Collection(options.overlays.slice());
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assertInstanceof(options.overlays, ol.Collection,
|
ol.assert(options.overlays instanceof ol.Collection,
|
||||||
'options.overlays should be an ol.Collection');
|
49); // Expected `overlays` to be an array or an `ol.Collection`
|
||||||
overlays = options.overlays;
|
overlays = options.overlays;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ goog.provide('ol.MapBrowserEvent.EventType');
|
|||||||
goog.provide('ol.MapBrowserEventHandler');
|
goog.provide('ol.MapBrowserEventHandler');
|
||||||
goog.provide('ol.MapBrowserPointerEvent');
|
goog.provide('ol.MapBrowserPointerEvent');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.MapEvent');
|
goog.require('ol.MapEvent');
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
@@ -272,11 +271,11 @@ ol.MapBrowserEventHandler.prototype.handlePointerUp_ = function(pointerEvent) {
|
|||||||
// to 0).
|
// to 0).
|
||||||
// See http://www.w3.org/TR/pointerevents/#button-states
|
// See http://www.w3.org/TR/pointerevents/#button-states
|
||||||
if (!this.dragging_ && this.isMouseActionButton_(pointerEvent)) {
|
if (!this.dragging_ && this.isMouseActionButton_(pointerEvent)) {
|
||||||
goog.asserts.assert(this.down_, 'this.down_ must be truthy');
|
ol.DEBUG && console.assert(this.down_, 'this.down_ must be truthy');
|
||||||
this.emulateClick_(this.down_);
|
this.emulateClick_(this.down_);
|
||||||
}
|
}
|
||||||
|
|
||||||
goog.asserts.assert(this.activePointers_ >= 0,
|
ol.DEBUG && console.assert(this.activePointers_ >= 0,
|
||||||
'this.activePointers_ should be equal to or larger than 0');
|
'this.activePointers_ should be equal to or larger than 0');
|
||||||
if (this.activePointers_ === 0) {
|
if (this.activePointers_ === 0) {
|
||||||
this.dragListenerKeys_.forEach(ol.events.unlistenByKey);
|
this.dragListenerKeys_.forEach(ol.events.unlistenByKey);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.math');
|
goog.provide('ol.math');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,7 +47,7 @@ ol.math.cosh = (function() {
|
|||||||
* @return {number} The smallest power of two greater than or equal to x.
|
* @return {number} The smallest power of two greater than or equal to x.
|
||||||
*/
|
*/
|
||||||
ol.math.roundUpToPowerOfTwo = function(x) {
|
ol.math.roundUpToPowerOfTwo = function(x) {
|
||||||
goog.asserts.assert(0 < x, 'x should be larger than 0');
|
ol.assert(0 < x, 29); // `x` must be greater than `0`
|
||||||
return Math.pow(2, Math.ceil(Math.log(x) / Math.LN2));
|
return Math.pow(2, Math.ceil(Math.log(x) / Math.LN2));
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -106,9 +105,9 @@ ol.math.squaredDistance = function(x1, y1, x2, y2) {
|
|||||||
ol.math.solveLinearSystem = function(mat) {
|
ol.math.solveLinearSystem = function(mat) {
|
||||||
var n = mat.length;
|
var n = mat.length;
|
||||||
|
|
||||||
if (goog.asserts.ENABLE_ASSERTS) {
|
if (ol.DEBUG) {
|
||||||
for (var row = 0; row < n; row++) {
|
for (var row = 0; row < n; row++) {
|
||||||
goog.asserts.assert(mat[row].length == n + 1,
|
console.assert(mat[row].length == n + 1,
|
||||||
'every row should have correct number of columns');
|
'every row should have correct number of columns');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
59
src/ol/ol.js
59
src/ol/ol.js
@@ -14,6 +14,14 @@ goog.provide('ol');
|
|||||||
ol.ASSUME_TOUCH = false;
|
ol.ASSUME_TOUCH = false;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @define {boolean} Debug mode. When set to `false` (recommended for
|
||||||
|
* production), debug assertion checks will be stripped out of the build.
|
||||||
|
* Default is `true`.
|
||||||
|
*/
|
||||||
|
ol.DEBUG = true;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: rename this to something having to do with tile grids
|
* TODO: rename this to something having to do with tile grids
|
||||||
* see https://github.com/openlayers/ol3/issues/2076
|
* see https://github.com/openlayers/ol3/issues/2076
|
||||||
@@ -212,6 +220,12 @@ ol.SIMPLIFY_TOLERANCE = 0.5;
|
|||||||
ol.WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK = 1024;
|
ol.WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK = 1024;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @define {string} OpenLayers version.
|
||||||
|
*/
|
||||||
|
ol.VERSION = '';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum supported WebGL texture size in pixels. If WebGL is not
|
* The maximum supported WebGL texture size in pixels. If WebGL is not
|
||||||
* supported, the value is set to `undefined`.
|
* supported, the value is set to `undefined`.
|
||||||
@@ -297,3 +311,48 @@ if (typeof window !== 'undefined') {
|
|||||||
} else if (typeof self !== 'undefined') {
|
} else if (typeof self !== 'undefined') {
|
||||||
ol.global = self;
|
ol.global = self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error object thrown when an assertion failed. This is an ECMA-262 Error,
|
||||||
|
* extended with a `code` property.
|
||||||
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error}
|
||||||
|
* @constructor
|
||||||
|
* @extends {Error}
|
||||||
|
* @implements {oli.AssertionError}
|
||||||
|
* @param {number} code Error code.
|
||||||
|
*/
|
||||||
|
ol.AssertionError = function(code) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
this.message = 'Assertion failed. See ' +
|
||||||
|
(ol.VERSION ? 'http://openlayers.org/en/' + ol.VERSION.split('-')[0] : '') +
|
||||||
|
'/doc/errors.html#' + code + ' for details.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error code. The meaning of the code can be found on
|
||||||
|
* {@link http://openlayers.org/en/latest/errors.html} (replace `latest` with
|
||||||
|
* the version found in the OpenLayers script's header comment if a version
|
||||||
|
* other than the latest is used).
|
||||||
|
* @type {number}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
this.code = code;
|
||||||
|
|
||||||
|
this.name = 'AssertionError';
|
||||||
|
|
||||||
|
};
|
||||||
|
ol.inherits(ol.AssertionError, Error);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {*} assertion Assertion we expected to be truthy.
|
||||||
|
* @param {number} errorCode Error code.
|
||||||
|
*/
|
||||||
|
ol.assert = function(assertion, errorCode) {
|
||||||
|
if (!assertion) {
|
||||||
|
throw new ol.AssertionError(errorCode);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
goog.provide('ol.Overlay');
|
goog.provide('ol.Overlay');
|
||||||
goog.provide('ol.OverlayPositioning');
|
goog.provide('ol.OverlayPositioning');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.MapEventType');
|
goog.require('ol.MapEventType');
|
||||||
@@ -370,7 +369,6 @@ ol.Overlay.prototype.setPosition = function(position) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.Overlay.prototype.panIntoView_ = function() {
|
ol.Overlay.prototype.panIntoView_ = function() {
|
||||||
goog.asserts.assert(this.autoPan, 'this.autoPan should be true');
|
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
|
|
||||||
if (map === undefined || !map.getTargetElement()) {
|
if (map === undefined || !map.getTargetElement()) {
|
||||||
@@ -378,8 +376,7 @@ ol.Overlay.prototype.panIntoView_ = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var mapRect = this.getRect_(map.getTargetElement(), map.getSize());
|
var mapRect = this.getRect_(map.getTargetElement(), map.getSize());
|
||||||
var element = this.getElement();
|
var element = /** @type {!Element} */ (this.getElement());
|
||||||
goog.asserts.assert(element, 'element should be defined');
|
|
||||||
var overlayRect = this.getRect_(element,
|
var overlayRect = this.getRect_(element,
|
||||||
[ol.dom.outerWidth(element), ol.dom.outerHeight(element)]);
|
[ol.dom.outerWidth(element), ol.dom.outerHeight(element)]);
|
||||||
|
|
||||||
@@ -408,8 +405,7 @@ ol.Overlay.prototype.panIntoView_ = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (delta[0] !== 0 || delta[1] !== 0) {
|
if (delta[0] !== 0 || delta[1] !== 0) {
|
||||||
var center = map.getView().getCenter();
|
var center = /** @type {ol.Coordinate} */ (map.getView().getCenter());
|
||||||
goog.asserts.assert(center !== undefined, 'center should be defined');
|
|
||||||
var centerPx = map.getPixelFromCoordinate(center);
|
var centerPx = map.getPixelFromCoordinate(center);
|
||||||
var newCenterPx = [
|
var newCenterPx = [
|
||||||
centerPx[0] + delta[0],
|
centerPx[0] + delta[0],
|
||||||
@@ -434,8 +430,8 @@ ol.Overlay.prototype.panIntoView_ = function() {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.Overlay.prototype.getRect_ = function(element, size) {
|
ol.Overlay.prototype.getRect_ = function(element, size) {
|
||||||
goog.asserts.assert(element, 'element should be defined');
|
ol.DEBUG && console.assert(element, 'element should be defined');
|
||||||
goog.asserts.assert(size !== undefined, 'size should be defined');
|
ol.DEBUG && console.assert(size !== undefined, 'size should be defined');
|
||||||
|
|
||||||
var box = element.getBoundingClientRect();
|
var box = element.getBoundingClientRect();
|
||||||
var offsetX = box.left + ol.global.pageXOffset;
|
var offsetX = box.left + ol.global.pageXOffset;
|
||||||
@@ -498,14 +494,14 @@ ol.Overlay.prototype.updatePixelPosition = function() {
|
|||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) {
|
ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) {
|
||||||
goog.asserts.assert(pixel, 'pixel should not be null');
|
ol.DEBUG && console.assert(pixel, 'pixel should not be null');
|
||||||
goog.asserts.assert(mapSize !== undefined, 'mapSize should be defined');
|
ol.DEBUG && console.assert(mapSize !== undefined, 'mapSize should be defined');
|
||||||
var style = this.element_.style;
|
var style = this.element_.style;
|
||||||
var offset = this.getOffset();
|
var offset = this.getOffset();
|
||||||
goog.asserts.assert(Array.isArray(offset), 'offset should be an array');
|
ol.DEBUG && console.assert(Array.isArray(offset), 'offset should be an array');
|
||||||
|
|
||||||
var positioning = this.getPositioning();
|
var positioning = this.getPositioning();
|
||||||
goog.asserts.assert(positioning !== undefined,
|
ol.DEBUG && console.assert(positioning !== undefined,
|
||||||
'positioning should be defined');
|
'positioning should be defined');
|
||||||
|
|
||||||
var offsetX = offset[0];
|
var offsetX = offset[0];
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.proj.EPSG3857');
|
goog.provide('ol.proj.EPSG3857');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.math');
|
goog.require('ol.math');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
goog.require('ol.proj.Projection');
|
goog.require('ol.proj.Projection');
|
||||||
@@ -114,7 +113,7 @@ ol.proj.EPSG3857.fromEPSG4326 = function(input, opt_output, opt_dimension) {
|
|||||||
output = new Array(length);
|
output = new Array(length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goog.asserts.assert(output.length % dimension === 0,
|
ol.DEBUG && console.assert(output.length % dimension === 0,
|
||||||
'modulus of output.length with dimension should be 0');
|
'modulus of output.length with dimension should be 0');
|
||||||
for (var i = 0; i < length; i += dimension) {
|
for (var i = 0; i < length; i += dimension) {
|
||||||
output[i] = ol.proj.EPSG3857.RADIUS * Math.PI * input[i] / 180;
|
output[i] = ol.proj.EPSG3857.RADIUS * Math.PI * input[i] / 180;
|
||||||
@@ -145,7 +144,7 @@ ol.proj.EPSG3857.toEPSG4326 = function(input, opt_output, opt_dimension) {
|
|||||||
output = new Array(length);
|
output = new Array(length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goog.asserts.assert(output.length % dimension === 0,
|
ol.DEBUG && console.assert(output.length % dimension === 0,
|
||||||
'modulus of output.length with dimension should be 0');
|
'modulus of output.length with dimension should be 0');
|
||||||
for (var i = 0; i < length; i += dimension) {
|
for (var i = 0; i < length; i += dimension) {
|
||||||
output[i] = 180 * input[i] / (ol.proj.EPSG3857.RADIUS * Math.PI);
|
output[i] = 180 * input[i] / (ol.proj.EPSG3857.RADIUS * Math.PI);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ goog.provide('ol.proj.METERS_PER_UNIT');
|
|||||||
goog.provide('ol.proj.Projection');
|
goog.provide('ol.proj.Projection');
|
||||||
goog.provide('ol.proj.Units');
|
goog.provide('ol.proj.Units');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.object');
|
goog.require('ol.object');
|
||||||
@@ -137,7 +136,7 @@ ol.proj.Projection = function(options) {
|
|||||||
|
|
||||||
var projections = ol.proj.projections_;
|
var projections = ol.proj.projections_;
|
||||||
var code = options.code;
|
var code = options.code;
|
||||||
goog.asserts.assert(code !== undefined,
|
ol.DEBUG && console.assert(code !== undefined,
|
||||||
'Option "code" is required for constructing instance');
|
'Option "code" is required for constructing instance');
|
||||||
if (ol.ENABLE_PROJ4JS) {
|
if (ol.ENABLE_PROJ4JS) {
|
||||||
var proj4js = ol.proj.proj4_ || ol.global['proj4'];
|
var proj4js = ol.proj.proj4_ || ol.global['proj4'];
|
||||||
@@ -417,7 +416,7 @@ if (ol.ENABLE_PROJ4JS) {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.proj.setProj4 = function(proj4) {
|
ol.proj.setProj4 = function(proj4) {
|
||||||
goog.asserts.assert(typeof proj4 == 'function',
|
ol.DEBUG && console.assert(typeof proj4 == 'function',
|
||||||
'proj4 argument should be a function');
|
'proj4 argument should be a function');
|
||||||
ol.proj.proj4_ = proj4;
|
ol.proj.proj4_ = proj4;
|
||||||
};
|
};
|
||||||
@@ -510,9 +509,7 @@ ol.proj.createProjection = function(projection, defaultCode) {
|
|||||||
} else if (typeof projection === 'string') {
|
} else if (typeof projection === 'string') {
|
||||||
return ol.proj.get(projection);
|
return ol.proj.get(projection);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assertInstanceof(projection, ol.proj.Projection,
|
return /** @type {ol.proj.Projection} */ (projection);
|
||||||
'projection should be an ol.proj.Projection');
|
|
||||||
return projection;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -611,9 +608,9 @@ ol.proj.removeTransform = function(source, destination) {
|
|||||||
var sourceCode = source.getCode();
|
var sourceCode = source.getCode();
|
||||||
var destinationCode = destination.getCode();
|
var destinationCode = destination.getCode();
|
||||||
var transforms = ol.proj.transforms_;
|
var transforms = ol.proj.transforms_;
|
||||||
goog.asserts.assert(sourceCode in transforms,
|
ol.DEBUG && console.assert(sourceCode in transforms,
|
||||||
'sourceCode should be in transforms');
|
'sourceCode should be in transforms');
|
||||||
goog.asserts.assert(destinationCode in transforms[sourceCode],
|
ol.DEBUG && console.assert(destinationCode in transforms[sourceCode],
|
||||||
'destinationCode should be in transforms of sourceCode');
|
'destinationCode should be in transforms of sourceCode');
|
||||||
var transform = transforms[sourceCode][destinationCode];
|
var transform = transforms[sourceCode][destinationCode];
|
||||||
delete transforms[sourceCode][destinationCode];
|
delete transforms[sourceCode][destinationCode];
|
||||||
@@ -744,7 +741,7 @@ ol.proj.getTransformFromProjections = function(sourceProjection, destinationProj
|
|||||||
transform = transforms[sourceCode][destinationCode];
|
transform = transforms[sourceCode][destinationCode];
|
||||||
}
|
}
|
||||||
if (transform === undefined) {
|
if (transform === undefined) {
|
||||||
goog.asserts.assert(transform !== undefined, 'transform should be defined');
|
ol.DEBUG && console.assert(transform !== undefined, 'transform should be defined');
|
||||||
transform = ol.proj.identityTransform;
|
transform = ol.proj.identityTransform;
|
||||||
}
|
}
|
||||||
return transform;
|
return transform;
|
||||||
@@ -760,7 +757,7 @@ ol.proj.getTransformFromProjections = function(sourceProjection, destinationProj
|
|||||||
ol.proj.identityTransform = function(input, opt_output, opt_dimension) {
|
ol.proj.identityTransform = function(input, opt_output, opt_dimension) {
|
||||||
if (opt_output !== undefined && input !== opt_output) {
|
if (opt_output !== undefined && input !== opt_output) {
|
||||||
// TODO: consider making this a warning instead
|
// TODO: consider making this a warning instead
|
||||||
goog.asserts.fail('This should not be used internally.');
|
ol.DEBUG && console.assert(false, 'This should not be used internally.');
|
||||||
for (var i = 0, ii = input.length; i < ii; ++i) {
|
for (var i = 0, ii = input.length; i < ii; ++i) {
|
||||||
opt_output[i] = input[i];
|
opt_output[i] = input[i];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
goog.provide('ol.render.Box');
|
goog.provide('ol.render.Box');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.Disposable');
|
goog.require('ol.Disposable');
|
||||||
goog.require('ol.geom.Polygon');
|
goog.require('ol.geom.Polygon');
|
||||||
|
|
||||||
@@ -64,8 +63,8 @@ ol.render.Box.prototype.disposeInternal = function() {
|
|||||||
ol.render.Box.prototype.render_ = function() {
|
ol.render.Box.prototype.render_ = function() {
|
||||||
var startPixel = this.startPixel_;
|
var startPixel = this.startPixel_;
|
||||||
var endPixel = this.endPixel_;
|
var endPixel = this.endPixel_;
|
||||||
goog.asserts.assert(startPixel, 'this.startPixel_ must be truthy');
|
ol.DEBUG && console.assert(startPixel, 'this.startPixel_ must be truthy');
|
||||||
goog.asserts.assert(endPixel, 'this.endPixel_ must be truthy');
|
ol.DEBUG && console.assert(endPixel, 'this.endPixel_ must be truthy');
|
||||||
var px = 'px';
|
var px = 'px';
|
||||||
var style = this.element_.style;
|
var style = this.element_.style;
|
||||||
style.left = Math.min(startPixel[0], endPixel[0]) + px;
|
style.left = Math.min(startPixel[0], endPixel[0]) + px;
|
||||||
@@ -107,11 +106,11 @@ ol.render.Box.prototype.setPixels = function(startPixel, endPixel) {
|
|||||||
* Creates or updates the cached geometry.
|
* Creates or updates the cached geometry.
|
||||||
*/
|
*/
|
||||||
ol.render.Box.prototype.createOrUpdateGeometry = function() {
|
ol.render.Box.prototype.createOrUpdateGeometry = function() {
|
||||||
goog.asserts.assert(this.startPixel_,
|
ol.DEBUG && console.assert(this.startPixel_,
|
||||||
'this.startPixel_ must be truthy');
|
'this.startPixel_ must be truthy');
|
||||||
goog.asserts.assert(this.endPixel_,
|
ol.DEBUG && console.assert(this.endPixel_,
|
||||||
'this.endPixel_ must be truthy');
|
'this.endPixel_ must be truthy');
|
||||||
goog.asserts.assert(this.map_, 'this.map_ must be truthy');
|
ol.DEBUG && console.assert(this.map_, 'this.map_ must be truthy');
|
||||||
var startPixel = this.startPixel_;
|
var startPixel = this.startPixel_;
|
||||||
var endPixel = this.endPixel_;
|
var endPixel = this.endPixel_;
|
||||||
var pixels = [
|
var pixels = [
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
goog.provide('ol.render.canvas.Immediate');
|
goog.provide('ol.render.canvas.Immediate');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.transform');
|
goog.require('ol.transform');
|
||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
goog.require('ol.color');
|
goog.require('ol.color');
|
||||||
@@ -245,8 +244,8 @@ ol.render.canvas.Immediate.prototype.drawImages_ = function(flatCoordinates, off
|
|||||||
if (!this.image_) {
|
if (!this.image_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
goog.asserts.assert(offset === 0, 'offset should be 0');
|
ol.DEBUG && console.assert(offset === 0, 'offset should be 0');
|
||||||
goog.asserts.assert(end == flatCoordinates.length,
|
ol.DEBUG && console.assert(end == flatCoordinates.length,
|
||||||
'end should be equal to the length of flatCoordinates');
|
'end should be equal to the length of flatCoordinates');
|
||||||
var pixelCoordinates = ol.geom.flat.transform.transform2D(
|
var pixelCoordinates = ol.geom.flat.transform.transform2D(
|
||||||
flatCoordinates, offset, end, 2, this.transform_,
|
flatCoordinates, offset, end, 2, this.transform_,
|
||||||
@@ -310,8 +309,8 @@ ol.render.canvas.Immediate.prototype.drawText_ = function(flatCoordinates, offse
|
|||||||
this.setContextStrokeState_(this.textStrokeState_);
|
this.setContextStrokeState_(this.textStrokeState_);
|
||||||
}
|
}
|
||||||
this.setContextTextState_(this.textState_);
|
this.setContextTextState_(this.textState_);
|
||||||
goog.asserts.assert(offset === 0, 'offset should be 0');
|
ol.DEBUG && console.assert(offset === 0, 'offset should be 0');
|
||||||
goog.asserts.assert(end == flatCoordinates.length,
|
ol.DEBUG && console.assert(end == flatCoordinates.length,
|
||||||
'end should be equal to the length of flatCoordinates');
|
'end should be equal to the length of flatCoordinates');
|
||||||
var pixelCoordinates = ol.geom.flat.transform.transform2D(
|
var pixelCoordinates = ol.geom.flat.transform.transform2D(
|
||||||
flatCoordinates, offset, end, stride, this.transform_,
|
flatCoordinates, offset, end, stride, this.transform_,
|
||||||
@@ -477,7 +476,7 @@ ol.render.canvas.Immediate.prototype.drawGeometry = function(geometry) {
|
|||||||
this.drawCircle(/** @type {ol.geom.Circle} */ (geometry));
|
this.drawCircle(/** @type {ol.geom.Circle} */ (geometry));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goog.asserts.fail('Unsupported geometry type: ' + type);
|
ol.DEBUG && console.assert(false, 'Unsupported geometry type: ' + type);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -499,7 +498,7 @@ ol.render.canvas.Immediate.prototype.drawFeature = function(feature, style) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.setStyle(style);
|
this.setStyle(style);
|
||||||
goog.asserts.assert(geometry, 'geometry must be truthy');
|
ol.DEBUG && console.assert(geometry, 'geometry must be truthy');
|
||||||
this.drawGeometry(geometry);
|
this.drawGeometry(geometry);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -853,10 +852,10 @@ ol.render.canvas.Immediate.prototype.setImageStyle = function(imageStyle) {
|
|||||||
var imageImage = imageStyle.getImage(1);
|
var imageImage = imageStyle.getImage(1);
|
||||||
var imageOrigin = imageStyle.getOrigin();
|
var imageOrigin = imageStyle.getOrigin();
|
||||||
var imageSize = imageStyle.getSize();
|
var imageSize = imageStyle.getSize();
|
||||||
goog.asserts.assert(imageAnchor, 'imageAnchor must be truthy');
|
ol.DEBUG && console.assert(imageAnchor, 'imageAnchor must be truthy');
|
||||||
goog.asserts.assert(imageImage, 'imageImage must be truthy');
|
ol.DEBUG && console.assert(imageImage, 'imageImage must be truthy');
|
||||||
goog.asserts.assert(imageOrigin, 'imageOrigin must be truthy');
|
ol.DEBUG && console.assert(imageOrigin, 'imageOrigin must be truthy');
|
||||||
goog.asserts.assert(imageSize, 'imageSize must be truthy');
|
ol.DEBUG && console.assert(imageSize, 'imageSize must be truthy');
|
||||||
this.imageAnchorX_ = imageAnchor[0];
|
this.imageAnchorX_ = imageAnchor[0];
|
||||||
this.imageAnchorY_ = imageAnchor[1];
|
this.imageAnchorY_ = imageAnchor[1];
|
||||||
this.imageHeight_ = imageSize[1];
|
this.imageHeight_ = imageSize[1];
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ goog.provide('ol.render.canvas.Replay');
|
|||||||
goog.provide('ol.render.canvas.ReplayGroup');
|
goog.provide('ol.render.canvas.ReplayGroup');
|
||||||
goog.provide('ol.render.canvas.TextReplay');
|
goog.provide('ol.render.canvas.TextReplay');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.transform');
|
goog.require('ol.transform');
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
@@ -246,7 +245,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
|||||||
this.coordinates, 0, this.coordinates.length, 2,
|
this.coordinates, 0, this.coordinates.length, 2,
|
||||||
transform, this.pixelCoordinates_);
|
transform, this.pixelCoordinates_);
|
||||||
ol.transform.setFromArray(this.renderedTransform_, transform);
|
ol.transform.setFromArray(this.renderedTransform_, transform);
|
||||||
goog.asserts.assert(pixelCoordinates === this.pixelCoordinates_,
|
ol.DEBUG && console.assert(pixelCoordinates === this.pixelCoordinates_,
|
||||||
'pixelCoordinates should be the same as this.pixelCoordinates_');
|
'pixelCoordinates should be the same as this.pixelCoordinates_');
|
||||||
}
|
}
|
||||||
var skipFeatures = !ol.object.isEmpty(skippedFeaturesHash);
|
var skipFeatures = !ol.object.isEmpty(skippedFeaturesHash);
|
||||||
@@ -280,7 +279,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
|||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
case ol.render.canvas.Instruction.CIRCLE:
|
case ol.render.canvas.Instruction.CIRCLE:
|
||||||
goog.asserts.assert(typeof instruction[1] === 'number',
|
ol.DEBUG && console.assert(typeof instruction[1] === 'number',
|
||||||
'second instruction should be a number');
|
'second instruction should be a number');
|
||||||
d = /** @type {number} */ (instruction[1]);
|
d = /** @type {number} */ (instruction[1]);
|
||||||
var x1 = pixelCoordinates[d];
|
var x1 = pixelCoordinates[d];
|
||||||
@@ -298,10 +297,10 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
|||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
case ol.render.canvas.Instruction.DRAW_IMAGE:
|
case ol.render.canvas.Instruction.DRAW_IMAGE:
|
||||||
goog.asserts.assert(typeof instruction[1] === 'number',
|
ol.DEBUG && console.assert(typeof instruction[1] === 'number',
|
||||||
'second instruction should be a number');
|
'second instruction should be a number');
|
||||||
d = /** @type {number} */ (instruction[1]);
|
d = /** @type {number} */ (instruction[1]);
|
||||||
goog.asserts.assert(typeof instruction[2] === 'number',
|
ol.DEBUG && console.assert(typeof instruction[2] === 'number',
|
||||||
'third instruction should be a number');
|
'third instruction should be a number');
|
||||||
dd = /** @type {number} */ (instruction[2]);
|
dd = /** @type {number} */ (instruction[2]);
|
||||||
var image = /** @type {HTMLCanvasElement|HTMLVideoElement|Image} */
|
var image = /** @type {HTMLCanvasElement|HTMLVideoElement|Image} */
|
||||||
@@ -357,31 +356,31 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
|||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
case ol.render.canvas.Instruction.DRAW_TEXT:
|
case ol.render.canvas.Instruction.DRAW_TEXT:
|
||||||
goog.asserts.assert(typeof instruction[1] === 'number',
|
ol.DEBUG && console.assert(typeof instruction[1] === 'number',
|
||||||
'2nd instruction should be a number');
|
'2nd instruction should be a number');
|
||||||
d = /** @type {number} */ (instruction[1]);
|
d = /** @type {number} */ (instruction[1]);
|
||||||
goog.asserts.assert(typeof instruction[2] === 'number',
|
ol.DEBUG && console.assert(typeof instruction[2] === 'number',
|
||||||
'3rd instruction should be a number');
|
'3rd instruction should be a number');
|
||||||
dd = /** @type {number} */ (instruction[2]);
|
dd = /** @type {number} */ (instruction[2]);
|
||||||
goog.asserts.assert(typeof instruction[3] === 'string',
|
ol.DEBUG && console.assert(typeof instruction[3] === 'string',
|
||||||
'4th instruction should be a string');
|
'4th instruction should be a string');
|
||||||
text = /** @type {string} */ (instruction[3]);
|
text = /** @type {string} */ (instruction[3]);
|
||||||
goog.asserts.assert(typeof instruction[4] === 'number',
|
ol.DEBUG && console.assert(typeof instruction[4] === 'number',
|
||||||
'5th instruction should be a number');
|
'5th instruction should be a number');
|
||||||
var offsetX = /** @type {number} */ (instruction[4]) * pixelRatio;
|
var offsetX = /** @type {number} */ (instruction[4]) * pixelRatio;
|
||||||
goog.asserts.assert(typeof instruction[5] === 'number',
|
ol.DEBUG && console.assert(typeof instruction[5] === 'number',
|
||||||
'6th instruction should be a number');
|
'6th instruction should be a number');
|
||||||
var offsetY = /** @type {number} */ (instruction[5]) * pixelRatio;
|
var offsetY = /** @type {number} */ (instruction[5]) * pixelRatio;
|
||||||
goog.asserts.assert(typeof instruction[6] === 'number',
|
ol.DEBUG && console.assert(typeof instruction[6] === 'number',
|
||||||
'7th instruction should be a number');
|
'7th instruction should be a number');
|
||||||
rotation = /** @type {number} */ (instruction[6]);
|
rotation = /** @type {number} */ (instruction[6]);
|
||||||
goog.asserts.assert(typeof instruction[7] === 'number',
|
ol.DEBUG && console.assert(typeof instruction[7] === 'number',
|
||||||
'8th instruction should be a number');
|
'8th instruction should be a number');
|
||||||
scale = /** @type {number} */ (instruction[7]) * pixelRatio;
|
scale = /** @type {number} */ (instruction[7]) * pixelRatio;
|
||||||
goog.asserts.assert(typeof instruction[8] === 'boolean',
|
ol.DEBUG && console.assert(typeof instruction[8] === 'boolean',
|
||||||
'9th instruction should be a boolean');
|
'9th instruction should be a boolean');
|
||||||
fill = /** @type {boolean} */ (instruction[8]);
|
fill = /** @type {boolean} */ (instruction[8]);
|
||||||
goog.asserts.assert(typeof instruction[9] === 'boolean',
|
ol.DEBUG && console.assert(typeof instruction[9] === 'boolean',
|
||||||
'10th instruction should be a boolean');
|
'10th instruction should be a boolean');
|
||||||
stroke = /** @type {boolean} */ (instruction[9]);
|
stroke = /** @type {boolean} */ (instruction[9]);
|
||||||
for (; d < dd; d += 2) {
|
for (; d < dd; d += 2) {
|
||||||
@@ -442,10 +441,10 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
|||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
case ol.render.canvas.Instruction.MOVE_TO_LINE_TO:
|
case ol.render.canvas.Instruction.MOVE_TO_LINE_TO:
|
||||||
goog.asserts.assert(typeof instruction[1] === 'number',
|
ol.DEBUG && console.assert(typeof instruction[1] === 'number',
|
||||||
'2nd instruction should be a number');
|
'2nd instruction should be a number');
|
||||||
d = /** @type {number} */ (instruction[1]);
|
d = /** @type {number} */ (instruction[1]);
|
||||||
goog.asserts.assert(typeof instruction[2] === 'number',
|
ol.DEBUG && console.assert(typeof instruction[2] === 'number',
|
||||||
'3rd instruction should be a number');
|
'3rd instruction should be a number');
|
||||||
dd = /** @type {number} */ (instruction[2]);
|
dd = /** @type {number} */ (instruction[2]);
|
||||||
x = pixelCoordinates[d];
|
x = pixelCoordinates[d];
|
||||||
@@ -471,7 +470,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
|||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
case ol.render.canvas.Instruction.SET_FILL_STYLE:
|
case ol.render.canvas.Instruction.SET_FILL_STYLE:
|
||||||
goog.asserts.assert(
|
ol.DEBUG && console.assert(
|
||||||
ol.colorlike.isColorLike(instruction[1]),
|
ol.colorlike.isColorLike(instruction[1]),
|
||||||
'2nd instruction should be a string, ' +
|
'2nd instruction should be a string, ' +
|
||||||
'CanvasPattern, or CanvasGradient');
|
'CanvasPattern, or CanvasGradient');
|
||||||
@@ -479,17 +478,17 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
|||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
case ol.render.canvas.Instruction.SET_STROKE_STYLE:
|
case ol.render.canvas.Instruction.SET_STROKE_STYLE:
|
||||||
goog.asserts.assert(typeof instruction[1] === 'string',
|
ol.DEBUG && console.assert(typeof instruction[1] === 'string',
|
||||||
'2nd instruction should be a string');
|
'2nd instruction should be a string');
|
||||||
goog.asserts.assert(typeof instruction[2] === 'number',
|
ol.DEBUG && console.assert(typeof instruction[2] === 'number',
|
||||||
'3rd instruction should be a number');
|
'3rd instruction should be a number');
|
||||||
goog.asserts.assert(typeof instruction[3] === 'string',
|
ol.DEBUG && console.assert(typeof instruction[3] === 'string',
|
||||||
'4rd instruction should be a string');
|
'4rd instruction should be a string');
|
||||||
goog.asserts.assert(typeof instruction[4] === 'string',
|
ol.DEBUG && console.assert(typeof instruction[4] === 'string',
|
||||||
'5th instruction should be a string');
|
'5th instruction should be a string');
|
||||||
goog.asserts.assert(typeof instruction[5] === 'number',
|
ol.DEBUG && console.assert(typeof instruction[5] === 'number',
|
||||||
'6th instruction should be a number');
|
'6th instruction should be a number');
|
||||||
goog.asserts.assert(instruction[6],
|
ol.DEBUG && console.assert(instruction[6],
|
||||||
'7th instruction should not be null');
|
'7th instruction should not be null');
|
||||||
var usePixelRatio = instruction[7] !== undefined ?
|
var usePixelRatio = instruction[7] !== undefined ?
|
||||||
instruction[7] : true;
|
instruction[7] : true;
|
||||||
@@ -507,11 +506,11 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
|||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
case ol.render.canvas.Instruction.SET_TEXT_STYLE:
|
case ol.render.canvas.Instruction.SET_TEXT_STYLE:
|
||||||
goog.asserts.assert(typeof instruction[1] === 'string',
|
ol.DEBUG && console.assert(typeof instruction[1] === 'string',
|
||||||
'2nd instruction should be a string');
|
'2nd instruction should be a string');
|
||||||
goog.asserts.assert(typeof instruction[2] === 'string',
|
ol.DEBUG && console.assert(typeof instruction[2] === 'string',
|
||||||
'3rd instruction should be a string');
|
'3rd instruction should be a string');
|
||||||
goog.asserts.assert(typeof instruction[3] === 'string',
|
ol.DEBUG && console.assert(typeof instruction[3] === 'string',
|
||||||
'4th instruction should be a string');
|
'4th instruction should be a string');
|
||||||
context.font = /** @type {string} */ (instruction[1]);
|
context.font = /** @type {string} */ (instruction[1]);
|
||||||
context.textAlign = /** @type {string} */ (instruction[2]);
|
context.textAlign = /** @type {string} */ (instruction[2]);
|
||||||
@@ -523,13 +522,13 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
|||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goog.asserts.fail('Unknown canvas render instruction');
|
ol.DEBUG && console.assert(false, 'Unknown canvas render instruction');
|
||||||
++i; // consume the instruction anyway, to avoid an infinite loop
|
++i; // consume the instruction anyway, to avoid an infinite loop
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// assert that all instructions were consumed
|
// assert that all instructions were consumed
|
||||||
goog.asserts.assert(i == instructions.length,
|
ol.DEBUG && console.assert(i == instructions.length,
|
||||||
'all instructions should be consumed');
|
'all instructions should be consumed');
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
@@ -590,11 +589,11 @@ ol.render.canvas.Replay.prototype.reverseHitDetectionInstructions_ = function()
|
|||||||
instruction = hitDetectionInstructions[i];
|
instruction = hitDetectionInstructions[i];
|
||||||
type = /** @type {ol.render.canvas.Instruction} */ (instruction[0]);
|
type = /** @type {ol.render.canvas.Instruction} */ (instruction[0]);
|
||||||
if (type == ol.render.canvas.Instruction.END_GEOMETRY) {
|
if (type == ol.render.canvas.Instruction.END_GEOMETRY) {
|
||||||
goog.asserts.assert(begin == -1, 'begin should be -1');
|
ol.DEBUG && console.assert(begin == -1, 'begin should be -1');
|
||||||
begin = i;
|
begin = i;
|
||||||
} else if (type == ol.render.canvas.Instruction.BEGIN_GEOMETRY) {
|
} else if (type == ol.render.canvas.Instruction.BEGIN_GEOMETRY) {
|
||||||
instruction[2] = i;
|
instruction[2] = i;
|
||||||
goog.asserts.assert(begin >= 0,
|
ol.DEBUG && console.assert(begin >= 0,
|
||||||
'begin should be larger than or equal to 0');
|
'begin should be larger than or equal to 0');
|
||||||
ol.array.reverseSubArray(this.hitDetectionInstructions, begin, i);
|
ol.array.reverseSubArray(this.hitDetectionInstructions, begin, i);
|
||||||
begin = -1;
|
begin = -1;
|
||||||
@@ -608,11 +607,11 @@ ol.render.canvas.Replay.prototype.reverseHitDetectionInstructions_ = function()
|
|||||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||||
*/
|
*/
|
||||||
ol.render.canvas.Replay.prototype.endGeometry = function(geometry, feature) {
|
ol.render.canvas.Replay.prototype.endGeometry = function(geometry, feature) {
|
||||||
goog.asserts.assert(this.beginGeometryInstruction1_,
|
ol.DEBUG && console.assert(this.beginGeometryInstruction1_,
|
||||||
'this.beginGeometryInstruction1_ should not be null');
|
'this.beginGeometryInstruction1_ should not be null');
|
||||||
this.beginGeometryInstruction1_[2] = this.instructions.length;
|
this.beginGeometryInstruction1_[2] = this.instructions.length;
|
||||||
this.beginGeometryInstruction1_ = null;
|
this.beginGeometryInstruction1_ = null;
|
||||||
goog.asserts.assert(this.beginGeometryInstruction2_,
|
ol.DEBUG && console.assert(this.beginGeometryInstruction2_,
|
||||||
'this.beginGeometryInstruction2_ should not be null');
|
'this.beginGeometryInstruction2_ should not be null');
|
||||||
this.beginGeometryInstruction2_[2] = this.hitDetectionInstructions.length;
|
this.beginGeometryInstruction2_[2] = this.hitDetectionInstructions.length;
|
||||||
this.beginGeometryInstruction2_ = null;
|
this.beginGeometryInstruction2_ = null;
|
||||||
@@ -756,25 +755,25 @@ ol.render.canvas.ImageReplay.prototype.drawPoint = function(pointGeometry, featu
|
|||||||
if (!this.image_) {
|
if (!this.image_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
goog.asserts.assert(this.anchorX_ !== undefined,
|
ol.DEBUG && console.assert(this.anchorX_ !== undefined,
|
||||||
'this.anchorX_ should be defined');
|
'this.anchorX_ should be defined');
|
||||||
goog.asserts.assert(this.anchorY_ !== undefined,
|
ol.DEBUG && console.assert(this.anchorY_ !== undefined,
|
||||||
'this.anchorY_ should be defined');
|
'this.anchorY_ should be defined');
|
||||||
goog.asserts.assert(this.height_ !== undefined,
|
ol.DEBUG && console.assert(this.height_ !== undefined,
|
||||||
'this.height_ should be defined');
|
'this.height_ should be defined');
|
||||||
goog.asserts.assert(this.opacity_ !== undefined,
|
ol.DEBUG && console.assert(this.opacity_ !== undefined,
|
||||||
'this.opacity_ should be defined');
|
'this.opacity_ should be defined');
|
||||||
goog.asserts.assert(this.originX_ !== undefined,
|
ol.DEBUG && console.assert(this.originX_ !== undefined,
|
||||||
'this.originX_ should be defined');
|
'this.originX_ should be defined');
|
||||||
goog.asserts.assert(this.originY_ !== undefined,
|
ol.DEBUG && console.assert(this.originY_ !== undefined,
|
||||||
'this.originY_ should be defined');
|
'this.originY_ should be defined');
|
||||||
goog.asserts.assert(this.rotateWithView_ !== undefined,
|
ol.DEBUG && console.assert(this.rotateWithView_ !== undefined,
|
||||||
'this.rotateWithView_ should be defined');
|
'this.rotateWithView_ should be defined');
|
||||||
goog.asserts.assert(this.rotation_ !== undefined,
|
ol.DEBUG && console.assert(this.rotation_ !== undefined,
|
||||||
'this.rotation_ should be defined');
|
'this.rotation_ should be defined');
|
||||||
goog.asserts.assert(this.scale_ !== undefined,
|
ol.DEBUG && console.assert(this.scale_ !== undefined,
|
||||||
'this.scale_ should be defined');
|
'this.scale_ should be defined');
|
||||||
goog.asserts.assert(this.width_ !== undefined,
|
ol.DEBUG && console.assert(this.width_ !== undefined,
|
||||||
'this.width_ should be defined');
|
'this.width_ should be defined');
|
||||||
this.beginGeometry(pointGeometry, feature);
|
this.beginGeometry(pointGeometry, feature);
|
||||||
var flatCoordinates = pointGeometry.getFlatCoordinates();
|
var flatCoordinates = pointGeometry.getFlatCoordinates();
|
||||||
@@ -808,25 +807,25 @@ ol.render.canvas.ImageReplay.prototype.drawMultiPoint = function(multiPointGeome
|
|||||||
if (!this.image_) {
|
if (!this.image_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
goog.asserts.assert(this.anchorX_ !== undefined,
|
ol.DEBUG && console.assert(this.anchorX_ !== undefined,
|
||||||
'this.anchorX_ should be defined');
|
'this.anchorX_ should be defined');
|
||||||
goog.asserts.assert(this.anchorY_ !== undefined,
|
ol.DEBUG && console.assert(this.anchorY_ !== undefined,
|
||||||
'this.anchorY_ should be defined');
|
'this.anchorY_ should be defined');
|
||||||
goog.asserts.assert(this.height_ !== undefined,
|
ol.DEBUG && console.assert(this.height_ !== undefined,
|
||||||
'this.height_ should be defined');
|
'this.height_ should be defined');
|
||||||
goog.asserts.assert(this.opacity_ !== undefined,
|
ol.DEBUG && console.assert(this.opacity_ !== undefined,
|
||||||
'this.opacity_ should be defined');
|
'this.opacity_ should be defined');
|
||||||
goog.asserts.assert(this.originX_ !== undefined,
|
ol.DEBUG && console.assert(this.originX_ !== undefined,
|
||||||
'this.originX_ should be defined');
|
'this.originX_ should be defined');
|
||||||
goog.asserts.assert(this.originY_ !== undefined,
|
ol.DEBUG && console.assert(this.originY_ !== undefined,
|
||||||
'this.originY_ should be defined');
|
'this.originY_ should be defined');
|
||||||
goog.asserts.assert(this.rotateWithView_ !== undefined,
|
ol.DEBUG && console.assert(this.rotateWithView_ !== undefined,
|
||||||
'this.rotateWithView_ should be defined');
|
'this.rotateWithView_ should be defined');
|
||||||
goog.asserts.assert(this.rotation_ !== undefined,
|
ol.DEBUG && console.assert(this.rotation_ !== undefined,
|
||||||
'this.rotation_ should be defined');
|
'this.rotation_ should be defined');
|
||||||
goog.asserts.assert(this.scale_ !== undefined,
|
ol.DEBUG && console.assert(this.scale_ !== undefined,
|
||||||
'this.scale_ should be defined');
|
'this.scale_ should be defined');
|
||||||
goog.asserts.assert(this.width_ !== undefined,
|
ol.DEBUG && console.assert(this.width_ !== undefined,
|
||||||
'this.width_ should be defined');
|
'this.width_ should be defined');
|
||||||
this.beginGeometry(multiPointGeometry, feature);
|
this.beginGeometry(multiPointGeometry, feature);
|
||||||
var flatCoordinates = multiPointGeometry.getFlatCoordinates();
|
var flatCoordinates = multiPointGeometry.getFlatCoordinates();
|
||||||
@@ -879,18 +878,18 @@ ol.render.canvas.ImageReplay.prototype.finish = function() {
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.canvas.ImageReplay.prototype.setImageStyle = function(imageStyle) {
|
ol.render.canvas.ImageReplay.prototype.setImageStyle = function(imageStyle) {
|
||||||
goog.asserts.assert(imageStyle, 'imageStyle should not be null');
|
ol.DEBUG && console.assert(imageStyle, 'imageStyle should not be null');
|
||||||
var anchor = imageStyle.getAnchor();
|
var anchor = imageStyle.getAnchor();
|
||||||
goog.asserts.assert(anchor, 'anchor should not be null');
|
ol.DEBUG && console.assert(anchor, 'anchor should not be null');
|
||||||
var size = imageStyle.getSize();
|
var size = imageStyle.getSize();
|
||||||
goog.asserts.assert(size, 'size should not be null');
|
ol.DEBUG && console.assert(size, 'size should not be null');
|
||||||
var hitDetectionImage = imageStyle.getHitDetectionImage(1);
|
var hitDetectionImage = imageStyle.getHitDetectionImage(1);
|
||||||
goog.asserts.assert(hitDetectionImage,
|
ol.DEBUG && console.assert(hitDetectionImage,
|
||||||
'hitDetectionImage should not be null');
|
'hitDetectionImage should not be null');
|
||||||
var image = imageStyle.getImage(1);
|
var image = imageStyle.getImage(1);
|
||||||
goog.asserts.assert(image, 'image should not be null');
|
ol.DEBUG && console.assert(image, 'image should not be null');
|
||||||
var origin = imageStyle.getOrigin();
|
var origin = imageStyle.getOrigin();
|
||||||
goog.asserts.assert(origin, 'origin should not be null');
|
ol.DEBUG && console.assert(origin, 'origin should not be null');
|
||||||
this.anchorX_ = anchor[0];
|
this.anchorX_ = anchor[0];
|
||||||
this.anchorY_ = anchor[1];
|
this.anchorY_ = anchor[1];
|
||||||
this.hitDetectionImage_ = hitDetectionImage;
|
this.hitDetectionImage_ = hitDetectionImage;
|
||||||
@@ -1002,13 +1001,13 @@ ol.render.canvas.LineStringReplay.prototype.setStrokeStyle_ = function() {
|
|||||||
var lineJoin = state.lineJoin;
|
var lineJoin = state.lineJoin;
|
||||||
var lineWidth = state.lineWidth;
|
var lineWidth = state.lineWidth;
|
||||||
var miterLimit = state.miterLimit;
|
var miterLimit = state.miterLimit;
|
||||||
goog.asserts.assert(strokeStyle !== undefined,
|
ol.DEBUG && console.assert(strokeStyle !== undefined,
|
||||||
'strokeStyle should be defined');
|
'strokeStyle should be defined');
|
||||||
goog.asserts.assert(lineCap !== undefined, 'lineCap should be defined');
|
ol.DEBUG && console.assert(lineCap !== undefined, 'lineCap should be defined');
|
||||||
goog.asserts.assert(lineDash, 'lineDash should not be null');
|
ol.DEBUG && console.assert(lineDash, 'lineDash should not be null');
|
||||||
goog.asserts.assert(lineJoin !== undefined, 'lineJoin should be defined');
|
ol.DEBUG && console.assert(lineJoin !== undefined, 'lineJoin should be defined');
|
||||||
goog.asserts.assert(lineWidth !== undefined, 'lineWidth should be defined');
|
ol.DEBUG && console.assert(lineWidth !== undefined, 'lineWidth should be defined');
|
||||||
goog.asserts.assert(miterLimit !== undefined, 'miterLimit should be defined');
|
ol.DEBUG && console.assert(miterLimit !== undefined, 'miterLimit should be defined');
|
||||||
if (state.currentStrokeStyle != strokeStyle ||
|
if (state.currentStrokeStyle != strokeStyle ||
|
||||||
state.currentLineCap != lineCap ||
|
state.currentLineCap != lineCap ||
|
||||||
!ol.array.equals(state.currentLineDash, lineDash) ||
|
!ol.array.equals(state.currentLineDash, lineDash) ||
|
||||||
@@ -1039,7 +1038,7 @@ ol.render.canvas.LineStringReplay.prototype.setStrokeStyle_ = function() {
|
|||||||
*/
|
*/
|
||||||
ol.render.canvas.LineStringReplay.prototype.drawLineString = function(lineStringGeometry, feature) {
|
ol.render.canvas.LineStringReplay.prototype.drawLineString = function(lineStringGeometry, feature) {
|
||||||
var state = this.state_;
|
var state = this.state_;
|
||||||
goog.asserts.assert(state, 'state should not be null');
|
ol.DEBUG && console.assert(state, 'state should not be null');
|
||||||
var strokeStyle = state.strokeStyle;
|
var strokeStyle = state.strokeStyle;
|
||||||
var lineWidth = state.lineWidth;
|
var lineWidth = state.lineWidth;
|
||||||
if (strokeStyle === undefined || lineWidth === undefined) {
|
if (strokeStyle === undefined || lineWidth === undefined) {
|
||||||
@@ -1066,7 +1065,7 @@ ol.render.canvas.LineStringReplay.prototype.drawLineString = function(lineString
|
|||||||
*/
|
*/
|
||||||
ol.render.canvas.LineStringReplay.prototype.drawMultiLineString = function(multiLineStringGeometry, feature) {
|
ol.render.canvas.LineStringReplay.prototype.drawMultiLineString = function(multiLineStringGeometry, feature) {
|
||||||
var state = this.state_;
|
var state = this.state_;
|
||||||
goog.asserts.assert(state, 'state should not be null');
|
ol.DEBUG && console.assert(state, 'state should not be null');
|
||||||
var strokeStyle = state.strokeStyle;
|
var strokeStyle = state.strokeStyle;
|
||||||
var lineWidth = state.lineWidth;
|
var lineWidth = state.lineWidth;
|
||||||
if (strokeStyle === undefined || lineWidth === undefined) {
|
if (strokeStyle === undefined || lineWidth === undefined) {
|
||||||
@@ -1098,7 +1097,7 @@ ol.render.canvas.LineStringReplay.prototype.drawMultiLineString = function(multi
|
|||||||
*/
|
*/
|
||||||
ol.render.canvas.LineStringReplay.prototype.finish = function() {
|
ol.render.canvas.LineStringReplay.prototype.finish = function() {
|
||||||
var state = this.state_;
|
var state = this.state_;
|
||||||
goog.asserts.assert(state, 'state should not be null');
|
ol.DEBUG && console.assert(state, 'state should not be null');
|
||||||
if (state.lastStroke != this.coordinates.length) {
|
if (state.lastStroke != this.coordinates.length) {
|
||||||
this.instructions.push([ol.render.canvas.Instruction.STROKE]);
|
this.instructions.push([ol.render.canvas.Instruction.STROKE]);
|
||||||
}
|
}
|
||||||
@@ -1111,9 +1110,9 @@ ol.render.canvas.LineStringReplay.prototype.finish = function() {
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.canvas.LineStringReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
ol.render.canvas.LineStringReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
||||||
goog.asserts.assert(this.state_, 'this.state_ should not be null');
|
ol.DEBUG && console.assert(this.state_, 'this.state_ should not be null');
|
||||||
goog.asserts.assert(!fillStyle, 'fillStyle should be null');
|
ol.DEBUG && console.assert(!fillStyle, 'fillStyle should be null');
|
||||||
goog.asserts.assert(strokeStyle, 'strokeStyle should not be null');
|
ol.DEBUG && console.assert(strokeStyle, 'strokeStyle should not be null');
|
||||||
var strokeStyleColor = strokeStyle.getColor();
|
var strokeStyleColor = strokeStyle.getColor();
|
||||||
this.state_.strokeStyle = ol.color.asString(strokeStyleColor ?
|
this.state_.strokeStyle = ol.color.asString(strokeStyleColor ?
|
||||||
strokeStyleColor : ol.render.canvas.defaultStrokeStyle);
|
strokeStyleColor : ol.render.canvas.defaultStrokeStyle);
|
||||||
@@ -1227,7 +1226,7 @@ ol.render.canvas.PolygonReplay.prototype.drawFlatCoordinatess_ = function(flatCo
|
|||||||
this.instructions.push(fillInstruction);
|
this.instructions.push(fillInstruction);
|
||||||
}
|
}
|
||||||
if (state.strokeStyle !== undefined) {
|
if (state.strokeStyle !== undefined) {
|
||||||
goog.asserts.assert(state.lineWidth !== undefined,
|
ol.DEBUG && console.assert(state.lineWidth !== undefined,
|
||||||
'state.lineWidth should be defined');
|
'state.lineWidth should be defined');
|
||||||
var strokeInstruction = [ol.render.canvas.Instruction.STROKE];
|
var strokeInstruction = [ol.render.canvas.Instruction.STROKE];
|
||||||
this.instructions.push(strokeInstruction);
|
this.instructions.push(strokeInstruction);
|
||||||
@@ -1242,14 +1241,14 @@ ol.render.canvas.PolygonReplay.prototype.drawFlatCoordinatess_ = function(flatCo
|
|||||||
*/
|
*/
|
||||||
ol.render.canvas.PolygonReplay.prototype.drawCircle = function(circleGeometry, feature) {
|
ol.render.canvas.PolygonReplay.prototype.drawCircle = function(circleGeometry, feature) {
|
||||||
var state = this.state_;
|
var state = this.state_;
|
||||||
goog.asserts.assert(state, 'state should not be null');
|
ol.DEBUG && console.assert(state, 'state should not be null');
|
||||||
var fillStyle = state.fillStyle;
|
var fillStyle = state.fillStyle;
|
||||||
var strokeStyle = state.strokeStyle;
|
var strokeStyle = state.strokeStyle;
|
||||||
if (fillStyle === undefined && strokeStyle === undefined) {
|
if (fillStyle === undefined && strokeStyle === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (strokeStyle !== undefined) {
|
if (strokeStyle !== undefined) {
|
||||||
goog.asserts.assert(state.lineWidth !== undefined,
|
ol.DEBUG && console.assert(state.lineWidth !== undefined,
|
||||||
'state.lineWidth should be defined');
|
'state.lineWidth should be defined');
|
||||||
}
|
}
|
||||||
this.setFillStrokeStyles_();
|
this.setFillStrokeStyles_();
|
||||||
@@ -1279,7 +1278,7 @@ ol.render.canvas.PolygonReplay.prototype.drawCircle = function(circleGeometry, f
|
|||||||
this.instructions.push(fillInstruction);
|
this.instructions.push(fillInstruction);
|
||||||
}
|
}
|
||||||
if (state.strokeStyle !== undefined) {
|
if (state.strokeStyle !== undefined) {
|
||||||
goog.asserts.assert(state.lineWidth !== undefined,
|
ol.DEBUG && console.assert(state.lineWidth !== undefined,
|
||||||
'state.lineWidth should be defined');
|
'state.lineWidth should be defined');
|
||||||
var strokeInstruction = [ol.render.canvas.Instruction.STROKE];
|
var strokeInstruction = [ol.render.canvas.Instruction.STROKE];
|
||||||
this.instructions.push(strokeInstruction);
|
this.instructions.push(strokeInstruction);
|
||||||
@@ -1294,14 +1293,14 @@ ol.render.canvas.PolygonReplay.prototype.drawCircle = function(circleGeometry, f
|
|||||||
*/
|
*/
|
||||||
ol.render.canvas.PolygonReplay.prototype.drawPolygon = function(polygonGeometry, feature) {
|
ol.render.canvas.PolygonReplay.prototype.drawPolygon = function(polygonGeometry, feature) {
|
||||||
var state = this.state_;
|
var state = this.state_;
|
||||||
goog.asserts.assert(state, 'state should not be null');
|
ol.DEBUG && console.assert(state, 'state should not be null');
|
||||||
var fillStyle = state.fillStyle;
|
var fillStyle = state.fillStyle;
|
||||||
var strokeStyle = state.strokeStyle;
|
var strokeStyle = state.strokeStyle;
|
||||||
if (fillStyle === undefined && strokeStyle === undefined) {
|
if (fillStyle === undefined && strokeStyle === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (strokeStyle !== undefined) {
|
if (strokeStyle !== undefined) {
|
||||||
goog.asserts.assert(state.lineWidth !== undefined,
|
ol.DEBUG && console.assert(state.lineWidth !== undefined,
|
||||||
'state.lineWidth should be defined');
|
'state.lineWidth should be defined');
|
||||||
}
|
}
|
||||||
this.setFillStrokeStyles_();
|
this.setFillStrokeStyles_();
|
||||||
@@ -1329,14 +1328,14 @@ ol.render.canvas.PolygonReplay.prototype.drawPolygon = function(polygonGeometry,
|
|||||||
*/
|
*/
|
||||||
ol.render.canvas.PolygonReplay.prototype.drawMultiPolygon = function(multiPolygonGeometry, feature) {
|
ol.render.canvas.PolygonReplay.prototype.drawMultiPolygon = function(multiPolygonGeometry, feature) {
|
||||||
var state = this.state_;
|
var state = this.state_;
|
||||||
goog.asserts.assert(state, 'state should not be null');
|
ol.DEBUG && console.assert(state, 'state should not be null');
|
||||||
var fillStyle = state.fillStyle;
|
var fillStyle = state.fillStyle;
|
||||||
var strokeStyle = state.strokeStyle;
|
var strokeStyle = state.strokeStyle;
|
||||||
if (fillStyle === undefined && strokeStyle === undefined) {
|
if (fillStyle === undefined && strokeStyle === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (strokeStyle !== undefined) {
|
if (strokeStyle !== undefined) {
|
||||||
goog.asserts.assert(state.lineWidth !== undefined,
|
ol.DEBUG && console.assert(state.lineWidth !== undefined,
|
||||||
'state.lineWidth should be defined');
|
'state.lineWidth should be defined');
|
||||||
}
|
}
|
||||||
this.setFillStrokeStyles_();
|
this.setFillStrokeStyles_();
|
||||||
@@ -1368,7 +1367,7 @@ ol.render.canvas.PolygonReplay.prototype.drawMultiPolygon = function(multiPolygo
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.canvas.PolygonReplay.prototype.finish = function() {
|
ol.render.canvas.PolygonReplay.prototype.finish = function() {
|
||||||
goog.asserts.assert(this.state_, 'this.state_ should not be null');
|
ol.DEBUG && console.assert(this.state_, 'this.state_ should not be null');
|
||||||
this.reverseHitDetectionInstructions_();
|
this.reverseHitDetectionInstructions_();
|
||||||
this.state_ = null;
|
this.state_ = null;
|
||||||
// We want to preserve topology when drawing polygons. Polygons are
|
// We want to preserve topology when drawing polygons. Polygons are
|
||||||
@@ -1405,8 +1404,8 @@ ol.render.canvas.PolygonReplay.prototype.getBufferedMaxExtent = function() {
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
||||||
goog.asserts.assert(this.state_, 'this.state_ should not be null');
|
ol.DEBUG && console.assert(this.state_, 'this.state_ should not be null');
|
||||||
goog.asserts.assert(fillStyle || strokeStyle,
|
ol.DEBUG && console.assert(fillStyle || strokeStyle,
|
||||||
'fillStyle or strokeStyle should not be null');
|
'fillStyle or strokeStyle should not be null');
|
||||||
var state = this.state_;
|
var state = this.state_;
|
||||||
if (fillStyle) {
|
if (fillStyle) {
|
||||||
@@ -1470,11 +1469,11 @@ ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyles_ = function() {
|
|||||||
state.currentFillStyle = state.fillStyle;
|
state.currentFillStyle = state.fillStyle;
|
||||||
}
|
}
|
||||||
if (strokeStyle !== undefined) {
|
if (strokeStyle !== undefined) {
|
||||||
goog.asserts.assert(lineCap !== undefined, 'lineCap should be defined');
|
ol.DEBUG && console.assert(lineCap !== undefined, 'lineCap should be defined');
|
||||||
goog.asserts.assert(lineDash, 'lineDash should not be null');
|
ol.DEBUG && console.assert(lineDash, 'lineDash should not be null');
|
||||||
goog.asserts.assert(lineJoin !== undefined, 'lineJoin should be defined');
|
ol.DEBUG && console.assert(lineJoin !== undefined, 'lineJoin should be defined');
|
||||||
goog.asserts.assert(lineWidth !== undefined, 'lineWidth should be defined');
|
ol.DEBUG && console.assert(lineWidth !== undefined, 'lineWidth should be defined');
|
||||||
goog.asserts.assert(miterLimit !== undefined,
|
ol.DEBUG && console.assert(miterLimit !== undefined,
|
||||||
'miterLimit should be defined');
|
'miterLimit should be defined');
|
||||||
if (state.currentStrokeStyle != strokeStyle ||
|
if (state.currentStrokeStyle != strokeStyle ||
|
||||||
state.currentLineCap != lineCap ||
|
state.currentLineCap != lineCap ||
|
||||||
@@ -1943,7 +1942,7 @@ ol.render.canvas.ReplayGroup.prototype.getReplay = function(zIndex, replayType)
|
|||||||
var replay = replays[replayType];
|
var replay = replays[replayType];
|
||||||
if (replay === undefined) {
|
if (replay === undefined) {
|
||||||
var Constructor = ol.render.canvas.BATCH_CONSTRUCTORS_[replayType];
|
var Constructor = ol.render.canvas.BATCH_CONSTRUCTORS_[replayType];
|
||||||
goog.asserts.assert(Constructor !== undefined,
|
ol.DEBUG && console.assert(Constructor !== undefined,
|
||||||
replayType +
|
replayType +
|
||||||
' constructor missing from ol.render.canvas.BATCH_CONSTRUCTORS_');
|
' constructor missing from ol.render.canvas.BATCH_CONSTRUCTORS_');
|
||||||
replay = new Constructor(this.tolerance_, this.maxExtent_,
|
replay = new Constructor(this.tolerance_, this.maxExtent_,
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
goog.provide('ol.render.Feature');
|
goog.provide('ol.render.Feature');
|
||||||
|
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.geom.GeometryType');
|
goog.require('ol.geom.GeometryType');
|
||||||
|
|
||||||
@@ -26,7 +25,7 @@ ol.render.Feature = function(type, flatCoordinates, ends, properties) {
|
|||||||
*/
|
*/
|
||||||
this.extent_;
|
this.extent_;
|
||||||
|
|
||||||
goog.asserts.assert(type === ol.geom.GeometryType.POINT ||
|
ol.DEBUG && console.assert(type === ol.geom.GeometryType.POINT ||
|
||||||
type === ol.geom.GeometryType.MULTI_POINT ||
|
type === ol.geom.GeometryType.MULTI_POINT ||
|
||||||
type === ol.geom.GeometryType.LINE_STRING ||
|
type === ol.geom.GeometryType.LINE_STRING ||
|
||||||
type === ol.geom.GeometryType.MULTI_LINE_STRING ||
|
type === ol.geom.GeometryType.MULTI_LINE_STRING ||
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.renderer.vector');
|
goog.provide('ol.renderer.vector');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.render.Feature');
|
goog.require('ol.render.Feature');
|
||||||
goog.require('ol.render.IReplayGroup');
|
goog.require('ol.render.IReplayGroup');
|
||||||
goog.require('ol.style.ImageState');
|
goog.require('ol.style.ImageState');
|
||||||
@@ -89,7 +88,7 @@ ol.renderer.vector.renderFeature = function(
|
|||||||
imageStyle.load();
|
imageStyle.load();
|
||||||
}
|
}
|
||||||
imageState = imageStyle.getImageState();
|
imageState = imageStyle.getImageState();
|
||||||
goog.asserts.assert(imageState == ol.style.ImageState.LOADING,
|
ol.DEBUG && console.assert(imageState == ol.style.ImageState.LOADING,
|
||||||
'imageState should be LOADING');
|
'imageState should be LOADING');
|
||||||
imageStyle.listenImageChange(listener, thisArg);
|
imageStyle.listenImageChange(listener, thisArg);
|
||||||
loading = true;
|
loading = true;
|
||||||
@@ -117,7 +116,7 @@ ol.renderer.vector.renderFeature_ = function(
|
|||||||
var simplifiedGeometry = geometry.getSimplifiedGeometry(squaredTolerance);
|
var simplifiedGeometry = geometry.getSimplifiedGeometry(squaredTolerance);
|
||||||
var geometryRenderer =
|
var geometryRenderer =
|
||||||
ol.renderer.vector.GEOMETRY_RENDERERS_[simplifiedGeometry.getType()];
|
ol.renderer.vector.GEOMETRY_RENDERERS_[simplifiedGeometry.getType()];
|
||||||
goog.asserts.assert(geometryRenderer !== undefined,
|
ol.DEBUG && console.assert(geometryRenderer !== undefined,
|
||||||
'geometryRenderer should be defined');
|
'geometryRenderer should be defined');
|
||||||
geometryRenderer(replayGroup, simplifiedGeometry, style, feature);
|
geometryRenderer(replayGroup, simplifiedGeometry, style, feature);
|
||||||
};
|
};
|
||||||
@@ -136,7 +135,7 @@ ol.renderer.vector.renderGeometryCollectionGeometry_ = function(replayGroup, geo
|
|||||||
for (i = 0, ii = geometries.length; i < ii; ++i) {
|
for (i = 0, ii = geometries.length; i < ii; ++i) {
|
||||||
var geometryRenderer =
|
var geometryRenderer =
|
||||||
ol.renderer.vector.GEOMETRY_RENDERERS_[geometries[i].getType()];
|
ol.renderer.vector.GEOMETRY_RENDERERS_[geometries[i].getType()];
|
||||||
goog.asserts.assert(geometryRenderer !== undefined,
|
ol.DEBUG && console.assert(geometryRenderer !== undefined,
|
||||||
'geometryRenderer should be defined');
|
'geometryRenderer should be defined');
|
||||||
geometryRenderer(replayGroup, geometries[i], style, feature);
|
geometryRenderer(replayGroup, geometries[i], style, feature);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
goog.provide('ol.render.webgl.Immediate');
|
goog.provide('ol.render.webgl.Immediate');
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.geom.GeometryType');
|
goog.require('ol.geom.GeometryType');
|
||||||
goog.require('ol.render.VectorContext');
|
goog.require('ol.render.VectorContext');
|
||||||
@@ -99,7 +98,7 @@ ol.render.webgl.Immediate.prototype.drawGeometry = function(geometry) {
|
|||||||
this.drawGeometryCollection(/** @type {ol.geom.GeometryCollection} */ (geometry), null);
|
this.drawGeometryCollection(/** @type {ol.geom.GeometryCollection} */ (geometry), null);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goog.asserts.fail('Unsupported geometry type: ' + type);
|
ol.DEBUG && console.assert(false, 'Unsupported geometry type: ' + type);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -115,7 +114,7 @@ ol.render.webgl.Immediate.prototype.drawFeature = function(feature, style) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.setStyle(style);
|
this.setStyle(style);
|
||||||
goog.asserts.assert(geometry, 'geometry must be truthy');
|
ol.DEBUG && console.assert(geometry, 'geometry must be truthy');
|
||||||
this.drawGeometry(geometry);
|
this.drawGeometry(geometry);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
goog.provide('ol.render.webgl.ImageReplay');
|
goog.provide('ol.render.webgl.ImageReplay');
|
||||||
goog.provide('ol.render.webgl.ReplayGroup');
|
goog.provide('ol.render.webgl.ReplayGroup');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.transform');
|
goog.require('ol.transform');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.object');
|
goog.require('ol.object');
|
||||||
@@ -226,9 +225,9 @@ ol.render.webgl.ImageReplay.prototype.getDeleteResourcesFunction = function(cont
|
|||||||
// be used by other ImageReplay instances (for other layers). And
|
// be used by other ImageReplay instances (for other layers). And
|
||||||
// they will be deleted when disposing of the ol.webgl.Context
|
// they will be deleted when disposing of the ol.webgl.Context
|
||||||
// object.
|
// object.
|
||||||
goog.asserts.assert(this.verticesBuffer_,
|
ol.DEBUG && console.assert(this.verticesBuffer_,
|
||||||
'verticesBuffer must not be null');
|
'verticesBuffer must not be null');
|
||||||
goog.asserts.assert(this.indicesBuffer_,
|
ol.DEBUG && console.assert(this.indicesBuffer_,
|
||||||
'indicesBuffer must not be null');
|
'indicesBuffer must not be null');
|
||||||
var verticesBuffer = this.verticesBuffer_;
|
var verticesBuffer = this.verticesBuffer_;
|
||||||
var indicesBuffer = this.indicesBuffer_;
|
var indicesBuffer = this.indicesBuffer_;
|
||||||
@@ -260,32 +259,32 @@ ol.render.webgl.ImageReplay.prototype.getDeleteResourcesFunction = function(cont
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ImageReplay.prototype.drawCoordinates_ = function(flatCoordinates, offset, end, stride) {
|
ol.render.webgl.ImageReplay.prototype.drawCoordinates_ = function(flatCoordinates, offset, end, stride) {
|
||||||
goog.asserts.assert(this.anchorX_ !== undefined, 'anchorX is defined');
|
ol.DEBUG && console.assert(this.anchorX_ !== undefined, 'anchorX is defined');
|
||||||
goog.asserts.assert(this.anchorY_ !== undefined, 'anchorY is defined');
|
ol.DEBUG && console.assert(this.anchorY_ !== undefined, 'anchorY is defined');
|
||||||
goog.asserts.assert(this.height_ !== undefined, 'height is defined');
|
ol.DEBUG && console.assert(this.height_ !== undefined, 'height is defined');
|
||||||
goog.asserts.assert(this.imageHeight_ !== undefined,
|
ol.DEBUG && console.assert(this.imageHeight_ !== undefined,
|
||||||
'imageHeight is defined');
|
'imageHeight is defined');
|
||||||
goog.asserts.assert(this.imageWidth_ !== undefined, 'imageWidth is defined');
|
ol.DEBUG && console.assert(this.imageWidth_ !== undefined, 'imageWidth is defined');
|
||||||
goog.asserts.assert(this.opacity_ !== undefined, 'opacity is defined');
|
ol.DEBUG && console.assert(this.opacity_ !== undefined, 'opacity is defined');
|
||||||
goog.asserts.assert(this.originX_ !== undefined, 'originX is defined');
|
ol.DEBUG && console.assert(this.originX_ !== undefined, 'originX is defined');
|
||||||
goog.asserts.assert(this.originY_ !== undefined, 'originY is defined');
|
ol.DEBUG && console.assert(this.originY_ !== undefined, 'originY is defined');
|
||||||
goog.asserts.assert(this.rotateWithView_ !== undefined,
|
ol.DEBUG && console.assert(this.rotateWithView_ !== undefined,
|
||||||
'rotateWithView is defined');
|
'rotateWithView is defined');
|
||||||
goog.asserts.assert(this.rotation_ !== undefined, 'rotation is defined');
|
ol.DEBUG && console.assert(this.rotation_ !== undefined, 'rotation is defined');
|
||||||
goog.asserts.assert(this.scale_ !== undefined, 'scale is defined');
|
ol.DEBUG && console.assert(this.scale_ !== undefined, 'scale is defined');
|
||||||
goog.asserts.assert(this.width_ !== undefined, 'width is defined');
|
ol.DEBUG && console.assert(this.width_ !== undefined, 'width is defined');
|
||||||
var anchorX = this.anchorX_;
|
var anchorX = /** @type {number} */ (this.anchorX_);
|
||||||
var anchorY = this.anchorY_;
|
var anchorY = /** @type {number} */ (this.anchorY_);
|
||||||
var height = this.height_;
|
var height = /** @type {number} */ (this.height_);
|
||||||
var imageHeight = this.imageHeight_;
|
var imageHeight = /** @type {number} */ (this.imageHeight_);
|
||||||
var imageWidth = this.imageWidth_;
|
var imageWidth = /** @type {number} */ (this.imageWidth_);
|
||||||
var opacity = this.opacity_;
|
var opacity = /** @type {number} */ (this.opacity_);
|
||||||
var originX = this.originX_;
|
var originX = /** @type {number} */ (this.originX_);
|
||||||
var originY = this.originY_;
|
var originY = /** @type {number} */ (this.originY_);
|
||||||
var rotateWithView = this.rotateWithView_ ? 1.0 : 0.0;
|
var rotateWithView = this.rotateWithView_ ? 1.0 : 0.0;
|
||||||
var rotation = this.rotation_;
|
var rotation = /** @type {number} */ (this.rotation_);
|
||||||
var scale = this.scale_;
|
var scale = /** @type {number} */ (this.scale_);
|
||||||
var width = this.width_;
|
var width = /** @type {number} */ (this.width_);
|
||||||
var cos = Math.cos(rotation);
|
var cos = Math.cos(rotation);
|
||||||
var sin = Math.sin(rotation);
|
var sin = Math.sin(rotation);
|
||||||
var numIndices = this.indices_.length;
|
var numIndices = this.indices_.length;
|
||||||
@@ -400,10 +399,10 @@ ol.render.webgl.ImageReplay.prototype.finish = function(context) {
|
|||||||
var gl = context.getGL();
|
var gl = context.getGL();
|
||||||
|
|
||||||
this.groupIndices_.push(this.indices_.length);
|
this.groupIndices_.push(this.indices_.length);
|
||||||
goog.asserts.assert(this.images_.length === this.groupIndices_.length,
|
ol.DEBUG && console.assert(this.images_.length === this.groupIndices_.length,
|
||||||
'number of images and groupIndices match');
|
'number of images and groupIndices match');
|
||||||
this.hitDetectionGroupIndices_.push(this.indices_.length);
|
this.hitDetectionGroupIndices_.push(this.indices_.length);
|
||||||
goog.asserts.assert(this.hitDetectionImages_.length ===
|
ol.DEBUG && console.assert(this.hitDetectionImages_.length ===
|
||||||
this.hitDetectionGroupIndices_.length,
|
this.hitDetectionGroupIndices_.length,
|
||||||
'number of hitDetectionImages and hitDetectionGroupIndices match');
|
'number of hitDetectionImages and hitDetectionGroupIndices match');
|
||||||
|
|
||||||
@@ -413,7 +412,7 @@ ol.render.webgl.ImageReplay.prototype.finish = function(context) {
|
|||||||
|
|
||||||
var indices = this.indices_;
|
var indices = this.indices_;
|
||||||
var bits = context.hasOESElementIndexUint ? 32 : 16;
|
var bits = context.hasOESElementIndexUint ? 32 : 16;
|
||||||
goog.asserts.assert(indices[indices.length - 1] < Math.pow(2, bits),
|
ol.DEBUG && console.assert(indices[indices.length - 1] < Math.pow(2, bits),
|
||||||
'Too large element index detected [%s] (OES_element_index_uint "%s")',
|
'Too large element index detected [%s] (OES_element_index_uint "%s")',
|
||||||
indices[indices.length - 1], context.hasOESElementIndexUint);
|
indices[indices.length - 1], context.hasOESElementIndexUint);
|
||||||
|
|
||||||
@@ -426,12 +425,12 @@ ol.render.webgl.ImageReplay.prototype.finish = function(context) {
|
|||||||
var texturePerImage = {};
|
var texturePerImage = {};
|
||||||
|
|
||||||
this.createTextures_(this.textures_, this.images_, texturePerImage, gl);
|
this.createTextures_(this.textures_, this.images_, texturePerImage, gl);
|
||||||
goog.asserts.assert(this.textures_.length === this.groupIndices_.length,
|
ol.DEBUG && console.assert(this.textures_.length === this.groupIndices_.length,
|
||||||
'number of textures and groupIndices match');
|
'number of textures and groupIndices match');
|
||||||
|
|
||||||
this.createTextures_(this.hitDetectionTextures_, this.hitDetectionImages_,
|
this.createTextures_(this.hitDetectionTextures_, this.hitDetectionImages_,
|
||||||
texturePerImage, gl);
|
texturePerImage, gl);
|
||||||
goog.asserts.assert(this.hitDetectionTextures_.length ===
|
ol.DEBUG && console.assert(this.hitDetectionTextures_.length ===
|
||||||
this.hitDetectionGroupIndices_.length,
|
this.hitDetectionGroupIndices_.length,
|
||||||
'number of hitDetectionTextures and hitDetectionGroupIndices match');
|
'number of hitDetectionTextures and hitDetectionGroupIndices match');
|
||||||
|
|
||||||
@@ -463,7 +462,7 @@ ol.render.webgl.ImageReplay.prototype.finish = function(context) {
|
|||||||
* @param {WebGLRenderingContext} gl Gl.
|
* @param {WebGLRenderingContext} gl Gl.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ImageReplay.prototype.createTextures_ = function(textures, images, texturePerImage, gl) {
|
ol.render.webgl.ImageReplay.prototype.createTextures_ = function(textures, images, texturePerImage, gl) {
|
||||||
goog.asserts.assert(textures.length === 0,
|
ol.DEBUG && console.assert(textures.length === 0,
|
||||||
'upon creation, textures is empty');
|
'upon creation, textures is empty');
|
||||||
|
|
||||||
var texture, image, uid, i;
|
var texture, image, uid, i;
|
||||||
@@ -508,12 +507,12 @@ ol.render.webgl.ImageReplay.prototype.replay = function(context,
|
|||||||
var gl = context.getGL();
|
var gl = context.getGL();
|
||||||
|
|
||||||
// bind the vertices buffer
|
// bind the vertices buffer
|
||||||
goog.asserts.assert(this.verticesBuffer_,
|
ol.DEBUG && console.assert(this.verticesBuffer_,
|
||||||
'verticesBuffer must not be null');
|
'verticesBuffer must not be null');
|
||||||
context.bindBuffer(ol.webgl.ARRAY_BUFFER, this.verticesBuffer_);
|
context.bindBuffer(ol.webgl.ARRAY_BUFFER, this.verticesBuffer_);
|
||||||
|
|
||||||
// bind the indices buffer
|
// bind the indices buffer
|
||||||
goog.asserts.assert(this.indicesBuffer_,
|
ol.DEBUG && console.assert(this.indicesBuffer_,
|
||||||
'indecesBuffer must not be null');
|
'indecesBuffer must not be null');
|
||||||
context.bindBuffer(ol.webgl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer_);
|
context.bindBuffer(ol.webgl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer_);
|
||||||
|
|
||||||
@@ -612,7 +611,7 @@ ol.render.webgl.ImageReplay.prototype.replay = function(context,
|
|||||||
* @param {Array.<number>} groupIndices Texture group indices.
|
* @param {Array.<number>} groupIndices Texture group indices.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ImageReplay.prototype.drawReplay_ = function(gl, context, skippedFeaturesHash, textures, groupIndices) {
|
ol.render.webgl.ImageReplay.prototype.drawReplay_ = function(gl, context, skippedFeaturesHash, textures, groupIndices) {
|
||||||
goog.asserts.assert(textures.length === groupIndices.length,
|
ol.DEBUG && console.assert(textures.length === groupIndices.length,
|
||||||
'number of textures and groupIndeces match');
|
'number of textures and groupIndeces match');
|
||||||
var elementType = context.hasOESElementIndexUint ?
|
var elementType = context.hasOESElementIndexUint ?
|
||||||
ol.webgl.UNSIGNED_INT : ol.webgl.UNSIGNED_SHORT;
|
ol.webgl.UNSIGNED_INT : ol.webgl.UNSIGNED_SHORT;
|
||||||
@@ -786,7 +785,7 @@ ol.render.webgl.ImageReplay.prototype.drawHitDetectionReplayAll_ = function(gl,
|
|||||||
*/
|
*/
|
||||||
ol.render.webgl.ImageReplay.prototype.drawHitDetectionReplayOneByOne_ = function(gl, context, skippedFeaturesHash, featureCallback,
|
ol.render.webgl.ImageReplay.prototype.drawHitDetectionReplayOneByOne_ = function(gl, context, skippedFeaturesHash, featureCallback,
|
||||||
opt_hitExtent) {
|
opt_hitExtent) {
|
||||||
goog.asserts.assert(this.hitDetectionTextures_.length ===
|
ol.DEBUG && console.assert(this.hitDetectionTextures_.length ===
|
||||||
this.hitDetectionGroupIndices_.length,
|
this.hitDetectionGroupIndices_.length,
|
||||||
'number of hitDetectionTextures and hitDetectionGroupIndices match');
|
'number of hitDetectionTextures and hitDetectionGroupIndices match');
|
||||||
var elementType = context.hasOESElementIndexUint ?
|
var elementType = context.hasOESElementIndexUint ?
|
||||||
@@ -851,21 +850,21 @@ ol.render.webgl.ImageReplay.prototype.setImageStyle = function(imageStyle) {
|
|||||||
var rotation = imageStyle.getRotation();
|
var rotation = imageStyle.getRotation();
|
||||||
var size = imageStyle.getSize();
|
var size = imageStyle.getSize();
|
||||||
var scale = imageStyle.getScale();
|
var scale = imageStyle.getScale();
|
||||||
goog.asserts.assert(anchor, 'imageStyle anchor is not null');
|
ol.DEBUG && console.assert(anchor, 'imageStyle anchor is not null');
|
||||||
goog.asserts.assert(image, 'imageStyle image is not null');
|
ol.DEBUG && console.assert(image, 'imageStyle image is not null');
|
||||||
goog.asserts.assert(imageSize,
|
ol.DEBUG && console.assert(imageSize,
|
||||||
'imageStyle imageSize is not null');
|
'imageStyle imageSize is not null');
|
||||||
goog.asserts.assert(hitDetectionImage,
|
ol.DEBUG && console.assert(hitDetectionImage,
|
||||||
'imageStyle hitDetectionImage is not null');
|
'imageStyle hitDetectionImage is not null');
|
||||||
goog.asserts.assert(hitDetectionImageSize,
|
ol.DEBUG && console.assert(hitDetectionImageSize,
|
||||||
'imageStyle hitDetectionImageSize is not null');
|
'imageStyle hitDetectionImageSize is not null');
|
||||||
goog.asserts.assert(opacity !== undefined, 'imageStyle opacity is defined');
|
ol.DEBUG && console.assert(opacity !== undefined, 'imageStyle opacity is defined');
|
||||||
goog.asserts.assert(origin, 'imageStyle origin is not null');
|
ol.DEBUG && console.assert(origin, 'imageStyle origin is not null');
|
||||||
goog.asserts.assert(rotateWithView !== undefined,
|
ol.DEBUG && console.assert(rotateWithView !== undefined,
|
||||||
'imageStyle rotateWithView is defined');
|
'imageStyle rotateWithView is defined');
|
||||||
goog.asserts.assert(rotation !== undefined, 'imageStyle rotation is defined');
|
ol.DEBUG && console.assert(rotation !== undefined, 'imageStyle rotation is defined');
|
||||||
goog.asserts.assert(size, 'imageStyle size is not null');
|
ol.DEBUG && console.assert(size, 'imageStyle size is not null');
|
||||||
goog.asserts.assert(scale !== undefined, 'imageStyle scale is defined');
|
ol.DEBUG && console.assert(scale !== undefined, 'imageStyle scale is defined');
|
||||||
|
|
||||||
var currentImage;
|
var currentImage;
|
||||||
if (this.images_.length === 0) {
|
if (this.images_.length === 0) {
|
||||||
@@ -874,7 +873,7 @@ ol.render.webgl.ImageReplay.prototype.setImageStyle = function(imageStyle) {
|
|||||||
currentImage = this.images_[this.images_.length - 1];
|
currentImage = this.images_[this.images_.length - 1];
|
||||||
if (ol.getUid(currentImage) != ol.getUid(image)) {
|
if (ol.getUid(currentImage) != ol.getUid(image)) {
|
||||||
this.groupIndices_.push(this.indices_.length);
|
this.groupIndices_.push(this.indices_.length);
|
||||||
goog.asserts.assert(this.groupIndices_.length === this.images_.length,
|
ol.DEBUG && console.assert(this.groupIndices_.length === this.images_.length,
|
||||||
'number of groupIndices and images match');
|
'number of groupIndices and images match');
|
||||||
this.images_.push(image);
|
this.images_.push(image);
|
||||||
}
|
}
|
||||||
@@ -887,7 +886,7 @@ ol.render.webgl.ImageReplay.prototype.setImageStyle = function(imageStyle) {
|
|||||||
this.hitDetectionImages_[this.hitDetectionImages_.length - 1];
|
this.hitDetectionImages_[this.hitDetectionImages_.length - 1];
|
||||||
if (ol.getUid(currentImage) != ol.getUid(hitDetectionImage)) {
|
if (ol.getUid(currentImage) != ol.getUid(hitDetectionImage)) {
|
||||||
this.hitDetectionGroupIndices_.push(this.indices_.length);
|
this.hitDetectionGroupIndices_.push(this.indices_.length);
|
||||||
goog.asserts.assert(this.hitDetectionGroupIndices_.length ===
|
ol.DEBUG && console.assert(this.hitDetectionGroupIndices_.length ===
|
||||||
this.hitDetectionImages_.length,
|
this.hitDetectionImages_.length,
|
||||||
'number of hitDetectionGroupIndices and hitDetectionImages match');
|
'number of hitDetectionGroupIndices and hitDetectionImages match');
|
||||||
this.hitDetectionImages_.push(hitDetectionImage);
|
this.hitDetectionImages_.push(hitDetectionImage);
|
||||||
@@ -988,7 +987,7 @@ ol.render.webgl.ReplayGroup.prototype.getReplay = function(zIndex, replayType) {
|
|||||||
var replay = this.replays_[replayType];
|
var replay = this.replays_[replayType];
|
||||||
if (replay === undefined) {
|
if (replay === undefined) {
|
||||||
var constructor = ol.render.webgl.BATCH_CONSTRUCTORS_[replayType];
|
var constructor = ol.render.webgl.BATCH_CONSTRUCTORS_[replayType];
|
||||||
goog.asserts.assert(constructor !== undefined,
|
ol.DEBUG && console.assert(constructor !== undefined,
|
||||||
replayType +
|
replayType +
|
||||||
' constructor missing from ol.render.webgl.BATCH_CONSTRUCTORS_');
|
' constructor missing from ol.render.webgl.BATCH_CONSTRUCTORS_');
|
||||||
replay = new constructor(this.tolerance_, this.maxExtent_);
|
replay = new constructor(this.tolerance_, this.maxExtent_);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.renderer.canvas.ImageLayer');
|
goog.provide('ol.renderer.canvas.ImageLayer');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.transform');
|
goog.require('ol.transform');
|
||||||
goog.require('ol.functions');
|
goog.require('ol.functions');
|
||||||
goog.require('ol.ImageBase');
|
goog.require('ol.ImageBase');
|
||||||
@@ -146,9 +145,7 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame = function(frameState, laye
|
|||||||
var viewResolution = viewState.resolution;
|
var viewResolution = viewState.resolution;
|
||||||
|
|
||||||
var image;
|
var image;
|
||||||
var imageLayer = this.getLayer();
|
var imageLayer = /** @type {ol.layer.Image} */ (this.getLayer());
|
||||||
goog.asserts.assertInstanceof(imageLayer, ol.layer.Image,
|
|
||||||
'layer is an instance of ol.layer.Image');
|
|
||||||
var imageSource = imageLayer.getSource();
|
var imageSource = imageLayer.getSource();
|
||||||
|
|
||||||
var hints = frameState.viewHints;
|
var hints = frameState.viewHints;
|
||||||
@@ -165,7 +162,7 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame = function(frameState, laye
|
|||||||
if (!ol.ENABLE_RASTER_REPROJECTION) {
|
if (!ol.ENABLE_RASTER_REPROJECTION) {
|
||||||
var sourceProjection = imageSource.getProjection();
|
var sourceProjection = imageSource.getProjection();
|
||||||
if (sourceProjection) {
|
if (sourceProjection) {
|
||||||
goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection),
|
ol.DEBUG && console.assert(ol.proj.equivalent(projection, sourceProjection),
|
||||||
'projection and sourceProjection are equivalent');
|
'projection and sourceProjection are equivalent');
|
||||||
projection = sourceProjection;
|
projection = sourceProjection;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.renderer.canvas.Layer');
|
goog.provide('ol.renderer.canvas.Layer');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.transform');
|
goog.require('ol.transform');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.layer.Layer');
|
goog.require('ol.layer.Layer');
|
||||||
@@ -46,16 +45,14 @@ ol.renderer.canvas.Layer.prototype.composeFrame = function(frameState, layerStat
|
|||||||
var extent = layerState.extent;
|
var extent = layerState.extent;
|
||||||
var clipped = extent !== undefined;
|
var clipped = extent !== undefined;
|
||||||
if (clipped) {
|
if (clipped) {
|
||||||
goog.asserts.assert(extent !== undefined,
|
|
||||||
'layerState extent is defined');
|
|
||||||
var pixelRatio = frameState.pixelRatio;
|
var pixelRatio = frameState.pixelRatio;
|
||||||
var width = frameState.size[0] * pixelRatio;
|
var width = frameState.size[0] * pixelRatio;
|
||||||
var height = frameState.size[1] * pixelRatio;
|
var height = frameState.size[1] * pixelRatio;
|
||||||
var rotation = frameState.viewState.rotation;
|
var rotation = frameState.viewState.rotation;
|
||||||
var topLeft = ol.extent.getTopLeft(extent);
|
var topLeft = ol.extent.getTopLeft(/** @type {ol.Extent} */ (extent));
|
||||||
var topRight = ol.extent.getTopRight(extent);
|
var topRight = ol.extent.getTopRight(/** @type {ol.Extent} */ (extent));
|
||||||
var bottomRight = ol.extent.getBottomRight(extent);
|
var bottomRight = ol.extent.getBottomRight(/** @type {ol.Extent} */ (extent));
|
||||||
var bottomLeft = ol.extent.getBottomLeft(extent);
|
var bottomLeft = ol.extent.getBottomLeft(/** @type {ol.Extent} */ (extent));
|
||||||
|
|
||||||
ol.transform.apply(frameState.coordinateToPixelTransform, topLeft);
|
ol.transform.apply(frameState.coordinateToPixelTransform, topLeft);
|
||||||
ol.transform.apply(frameState.coordinateToPixelTransform, topRight);
|
ol.transform.apply(frameState.coordinateToPixelTransform, topRight);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
goog.provide('ol.renderer.canvas.Map');
|
goog.provide('ol.renderer.canvas.Map');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.transform');
|
goog.require('ol.transform');
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.RendererType');
|
goog.require('ol.RendererType');
|
||||||
@@ -83,7 +82,7 @@ ol.renderer.canvas.Map.prototype.createLayerRenderer = function(layer) {
|
|||||||
} else if (ol.ENABLE_VECTOR && layer instanceof ol.layer.Vector) {
|
} else if (ol.ENABLE_VECTOR && layer instanceof ol.layer.Vector) {
|
||||||
return new ol.renderer.canvas.VectorLayer(layer);
|
return new ol.renderer.canvas.VectorLayer(layer);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail('unexpected layer configuration');
|
ol.DEBUG && console.assert(false, 'unexpected layer configuration');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -180,9 +179,7 @@ ol.renderer.canvas.Map.prototype.renderFrame = function(frameState) {
|
|||||||
for (i = 0, ii = layerStatesArray.length; i < ii; ++i) {
|
for (i = 0, ii = layerStatesArray.length; i < ii; ++i) {
|
||||||
layerState = layerStatesArray[i];
|
layerState = layerStatesArray[i];
|
||||||
layer = layerState.layer;
|
layer = layerState.layer;
|
||||||
layerRenderer = this.getLayerRenderer(layer);
|
layerRenderer = /** @type {ol.renderer.canvas.Layer} */ (this.getLayerRenderer(layer));
|
||||||
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.canvas.Layer,
|
|
||||||
'layerRenderer is an instance of ol.renderer.canvas.Layer');
|
|
||||||
if (!ol.layer.Layer.visibleAtResolution(layerState, viewResolution) ||
|
if (!ol.layer.Layer.visibleAtResolution(layerState, viewResolution) ||
|
||||||
layerState.sourceState != ol.source.State.READY) {
|
layerState.sourceState != ol.source.State.READY) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
goog.provide('ol.renderer.canvas.TileLayer');
|
goog.provide('ol.renderer.canvas.TileLayer');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.transform');
|
goog.require('ol.transform');
|
||||||
goog.require('ol.TileRange');
|
goog.require('ol.TileRange');
|
||||||
goog.require('ol.TileState');
|
goog.require('ol.TileState');
|
||||||
@@ -87,9 +86,7 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = function(
|
|||||||
var projection = viewState.projection;
|
var projection = viewState.projection;
|
||||||
|
|
||||||
var tileLayer = this.getLayer();
|
var tileLayer = this.getLayer();
|
||||||
var tileSource = tileLayer.getSource();
|
var tileSource = /** @type {ol.source.Tile} */ (tileLayer.getSource());
|
||||||
goog.asserts.assertInstanceof(tileSource, ol.source.Tile,
|
|
||||||
'source is an ol.source.Tile');
|
|
||||||
var tileGrid = tileSource.getTileGridForProjection(projection);
|
var tileGrid = tileSource.getTileGridForProjection(projection);
|
||||||
var z = tileGrid.getZForResolution(viewState.resolution, this.zDirection);
|
var z = tileGrid.getZForResolution(viewState.resolution, this.zDirection);
|
||||||
var tileResolution = tileGrid.getResolution(z);
|
var tileResolution = tileGrid.getResolution(z);
|
||||||
@@ -145,7 +142,7 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = function(
|
|||||||
if (!drawableTile(tile) && tile.interimTile) {
|
if (!drawableTile(tile) && tile.interimTile) {
|
||||||
tile = tile.interimTile;
|
tile = tile.interimTile;
|
||||||
}
|
}
|
||||||
goog.asserts.assert(tile);
|
ol.DEBUG && console.assert(tile);
|
||||||
if (drawableTile(tile)) {
|
if (drawableTile(tile)) {
|
||||||
tilesToDrawByZ[z][tile.tileCoord.toString()] = tile;
|
tilesToDrawByZ[z][tile.tileCoord.toString()] = tile;
|
||||||
continue;
|
continue;
|
||||||
@@ -230,9 +227,7 @@ ol.renderer.canvas.TileLayer.prototype.renderTileImages = function(context, fram
|
|||||||
var offsetY = Math.round(pixelRatio * size[1] / 2);
|
var offsetY = Math.round(pixelRatio * size[1] / 2);
|
||||||
var pixelScale = pixelRatio / resolution;
|
var pixelScale = pixelRatio / resolution;
|
||||||
var layer = this.getLayer();
|
var layer = this.getLayer();
|
||||||
var source = layer.getSource();
|
var source = /** @type {ol.source.Tile} */ (layer.getSource());
|
||||||
goog.asserts.assertInstanceof(source, ol.source.Tile,
|
|
||||||
'source is an ol.source.Tile');
|
|
||||||
var tileGutter = source.getGutter(projection);
|
var tileGutter = source.getGutter(projection);
|
||||||
var tileGrid = source.getTileGridForProjection(projection);
|
var tileGrid = source.getTileGridForProjection(projection);
|
||||||
|
|
||||||
@@ -279,12 +274,10 @@ ol.renderer.canvas.TileLayer.prototype.renderTileImages = function(context, fram
|
|||||||
var extent = layerState.extent;
|
var extent = layerState.extent;
|
||||||
var clipped = extent !== undefined;
|
var clipped = extent !== undefined;
|
||||||
if (clipped) {
|
if (clipped) {
|
||||||
goog.asserts.assert(extent !== undefined,
|
var topLeft = ol.extent.getTopLeft(/** @type {ol.Extent} */ (extent));
|
||||||
'layerState extent is defined');
|
var topRight = ol.extent.getTopRight(/** @type {ol.Extent} */ (extent));
|
||||||
var topLeft = ol.extent.getTopLeft(extent);
|
var bottomRight = ol.extent.getBottomRight(/** @type {ol.Extent} */ (extent));
|
||||||
var topRight = ol.extent.getTopRight(extent);
|
var bottomLeft = ol.extent.getBottomLeft(/** @type {ol.Extent} */ (extent));
|
||||||
var bottomRight = ol.extent.getBottomRight(extent);
|
|
||||||
var bottomLeft = ol.extent.getBottomLeft(extent);
|
|
||||||
|
|
||||||
ol.transform.apply(frameState.coordinateToPixelTransform, topLeft);
|
ol.transform.apply(frameState.coordinateToPixelTransform, topLeft);
|
||||||
ol.transform.apply(frameState.coordinateToPixelTransform, topRight);
|
ol.transform.apply(frameState.coordinateToPixelTransform, topRight);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
goog.provide('ol.renderer.canvas.VectorLayer');
|
goog.provide('ol.renderer.canvas.VectorLayer');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.ViewHint');
|
goog.require('ol.ViewHint');
|
||||||
goog.require('ol.dom');
|
goog.require('ol.dom');
|
||||||
@@ -82,8 +81,7 @@ ol.renderer.canvas.VectorLayer.prototype.composeFrame = function(frameState, lay
|
|||||||
var projection = viewState.projection;
|
var projection = viewState.projection;
|
||||||
var rotation = viewState.rotation;
|
var rotation = viewState.rotation;
|
||||||
var projectionExtent = projection.getExtent();
|
var projectionExtent = projection.getExtent();
|
||||||
var vectorSource = this.getLayer().getSource();
|
var vectorSource = /** @type {ol.source.Vector} */ (this.getLayer().getSource());
|
||||||
goog.asserts.assertInstanceof(vectorSource, ol.source.Vector);
|
|
||||||
|
|
||||||
var transform = this.getTransform(frameState, 0);
|
var transform = this.getTransform(frameState, 0);
|
||||||
|
|
||||||
@@ -174,7 +172,7 @@ ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtCoordinate = function(c
|
|||||||
* @return {?} Callback result.
|
* @return {?} Callback result.
|
||||||
*/
|
*/
|
||||||
function(feature) {
|
function(feature) {
|
||||||
goog.asserts.assert(feature !== undefined, 'received a feature');
|
ol.DEBUG && console.assert(feature !== undefined, 'received a feature');
|
||||||
var key = ol.getUid(feature).toString();
|
var key = ol.getUid(feature).toString();
|
||||||
if (!(key in features)) {
|
if (!(key in features)) {
|
||||||
features[key] = true;
|
features[key] = true;
|
||||||
@@ -201,8 +199,6 @@ ol.renderer.canvas.VectorLayer.prototype.handleStyleImageChange_ = function(even
|
|||||||
ol.renderer.canvas.VectorLayer.prototype.prepareFrame = function(frameState, layerState) {
|
ol.renderer.canvas.VectorLayer.prototype.prepareFrame = function(frameState, layerState) {
|
||||||
|
|
||||||
var vectorLayer = /** @type {ol.layer.Vector} */ (this.getLayer());
|
var vectorLayer = /** @type {ol.layer.Vector} */ (this.getLayer());
|
||||||
goog.asserts.assertInstanceof(vectorLayer, ol.layer.Vector,
|
|
||||||
'layer is an instance of ol.layer.Vector');
|
|
||||||
var vectorSource = vectorLayer.getSource();
|
var vectorSource = vectorLayer.getSource();
|
||||||
|
|
||||||
this.updateAttributions(
|
this.updateAttributions(
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user