Remove goog.isDef from formats
This commit is contained in:
@@ -13,6 +13,7 @@ goog.require('goog.dom.NodeType');
|
||||
goog.require('goog.math');
|
||||
goog.require('goog.object');
|
||||
goog.require('goog.string');
|
||||
goog.require('ol');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.FeatureStyleFunction');
|
||||
goog.require('ol.color');
|
||||
@@ -68,7 +69,7 @@ ol.format.KMLGxTrackObject_;
|
||||
*/
|
||||
ol.format.KML = function(opt_options) {
|
||||
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
var options = opt_options ? opt_options : {};
|
||||
|
||||
goog.base(this);
|
||||
|
||||
@@ -81,15 +82,15 @@ ol.format.KML = function(opt_options) {
|
||||
* @private
|
||||
* @type {Array.<ol.style.Style>}
|
||||
*/
|
||||
this.defaultStyle_ = goog.isDef(options.defaultStyle) ?
|
||||
this.defaultStyle_ = options.defaultStyle ?
|
||||
options.defaultStyle : ol.format.KML.DEFAULT_STYLE_ARRAY_;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.extractStyles_ = goog.isDef(options.extractStyles) ?
|
||||
options.extractStyles : true;
|
||||
this.extractStyles_ = ol.isDef(options.extractStyles) ?
|
||||
/** @type {boolean} */ (options.extractStyles) : true;
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -296,10 +297,10 @@ ol.format.KML.createFeatureStyleFunction_ = function(
|
||||
* @this {ol.Feature}
|
||||
*/
|
||||
function(resolution) {
|
||||
if (goog.isDef(style)) {
|
||||
if (style) {
|
||||
return style;
|
||||
}
|
||||
if (goog.isDef(styleUrl)) {
|
||||
if (styleUrl) {
|
||||
return ol.format.KML.findStyle_(styleUrl, defaultStyle, sharedStyles);
|
||||
}
|
||||
return defaultStyle;
|
||||
@@ -440,7 +441,7 @@ ol.format.KML.readVec2_ = function(node) {
|
||||
*/
|
||||
ol.format.KML.readScale_ = function(node) {
|
||||
var number = ol.format.XSD.readDecimal(node);
|
||||
if (goog.isDef(number)) {
|
||||
if (ol.isDef(number)) {
|
||||
return Math.sqrt(number);
|
||||
} else {
|
||||
return undefined;
|
||||
@@ -479,7 +480,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
|
||||
// FIXME httpQuery
|
||||
var object = ol.xml.pushParseAndPop(
|
||||
{}, ol.format.KML.ICON_STYLE_PARSERS_, node, objectStack);
|
||||
if (!goog.isDef(object)) {
|
||||
if (!object) {
|
||||
return;
|
||||
}
|
||||
var styleObject = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||
@@ -489,7 +490,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
|
||||
var src;
|
||||
var href = /** @type {string|undefined} */
|
||||
(IconObject['href']);
|
||||
if (goog.isDef(href)) {
|
||||
if (href) {
|
||||
src = href;
|
||||
} else {
|
||||
src = ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_;
|
||||
@@ -497,7 +498,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
|
||||
var anchor, anchorXUnits, anchorYUnits;
|
||||
var hotSpot = /** @type {ol.format.KMLVec2_|undefined} */
|
||||
(object['hotSpot']);
|
||||
if (goog.isDef(hotSpot)) {
|
||||
if (hotSpot) {
|
||||
anchor = [hotSpot.x, hotSpot.y];
|
||||
anchorXUnits = hotSpot.xunits;
|
||||
anchorYUnits = hotSpot.yunits;
|
||||
@@ -516,7 +517,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
|
||||
(IconObject['x']);
|
||||
var y = /** @type {number|undefined} */
|
||||
(IconObject['y']);
|
||||
if (goog.isDef(x) && goog.isDef(y)) {
|
||||
if (ol.isDef(x) && ol.isDef(y)) {
|
||||
offset = [x, y];
|
||||
}
|
||||
|
||||
@@ -525,14 +526,14 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
|
||||
(IconObject['w']);
|
||||
var h = /** @type {number|undefined} */
|
||||
(IconObject['h']);
|
||||
if (goog.isDef(w) && goog.isDef(h)) {
|
||||
if (ol.isDef(w) && ol.isDef(h)) {
|
||||
size = [w, h];
|
||||
}
|
||||
|
||||
var rotation;
|
||||
var heading = /** @type {number|undefined} */
|
||||
var heading = /** @type {number} */
|
||||
(object['heading']);
|
||||
if (goog.isDef(heading)) {
|
||||
if (ol.isDef(heading)) {
|
||||
rotation = goog.math.toRadians(heading);
|
||||
}
|
||||
|
||||
@@ -572,7 +573,7 @@ ol.format.KML.LabelStyleParser_ = function(node, objectStack) {
|
||||
// FIXME colorMode
|
||||
var object = ol.xml.pushParseAndPop(
|
||||
{}, ol.format.KML.LABEL_STYLE_PARSERS_, node, objectStack);
|
||||
if (!goog.isDef(object)) {
|
||||
if (!object) {
|
||||
return;
|
||||
}
|
||||
var styleObject = objectStack[objectStack.length - 1];
|
||||
@@ -607,7 +608,7 @@ ol.format.KML.LineStyleParser_ = function(node, objectStack) {
|
||||
// FIXME gx:labelVisibility
|
||||
var object = ol.xml.pushParseAndPop(
|
||||
{}, ol.format.KML.LINE_STYLE_PARSERS_, node, objectStack);
|
||||
if (!goog.isDef(object)) {
|
||||
if (!object) {
|
||||
return;
|
||||
}
|
||||
var styleObject = objectStack[objectStack.length - 1];
|
||||
@@ -635,7 +636,7 @@ ol.format.KML.PolyStyleParser_ = function(node, objectStack) {
|
||||
// FIXME colorMode
|
||||
var object = ol.xml.pushParseAndPop(
|
||||
{}, ol.format.KML.POLY_STYLE_PARSERS_, node, objectStack);
|
||||
if (!goog.isDef(object)) {
|
||||
if (!object) {
|
||||
return;
|
||||
}
|
||||
var styleObject = objectStack[objectStack.length - 1];
|
||||
@@ -647,12 +648,12 @@ ol.format.KML.PolyStyleParser_ = function(node, objectStack) {
|
||||
});
|
||||
styleObject['fillStyle'] = fillStyle;
|
||||
var fill = /** @type {boolean|undefined} */ (object['fill']);
|
||||
if (goog.isDef(fill)) {
|
||||
if (ol.isDef(fill)) {
|
||||
styleObject['fill'] = fill;
|
||||
}
|
||||
var outline =
|
||||
/** @type {boolean|undefined} */ (object['outline']);
|
||||
if (goog.isDef(outline)) {
|
||||
if (ol.isDef(outline)) {
|
||||
styleObject['outline'] = outline;
|
||||
}
|
||||
};
|
||||
@@ -723,7 +724,7 @@ ol.format.KML.readGxMultiTrack_ = function(node, objectStack) {
|
||||
var lineStrings = ol.xml.pushParseAndPop(
|
||||
/** @type {Array.<ol.geom.LineString>} */ ([]),
|
||||
ol.format.KML.GX_MULTITRACK_GEOMETRY_PARSERS_, node, objectStack);
|
||||
if (!goog.isDef(lineStrings)) {
|
||||
if (!lineStrings) {
|
||||
return undefined;
|
||||
}
|
||||
var multiLineString = new ol.geom.MultiLineString(null);
|
||||
@@ -750,7 +751,7 @@ ol.format.KML.readGxTrack_ = function(node, objectStack) {
|
||||
flatCoordinates: [],
|
||||
whens: []
|
||||
}), ol.format.KML.GX_TRACK_PARSERS_, node, objectStack);
|
||||
if (!goog.isDef(gxTrackObject)) {
|
||||
if (!gxTrackObject) {
|
||||
return undefined;
|
||||
}
|
||||
var flatCoordinates = gxTrackObject.flatCoordinates;
|
||||
@@ -781,7 +782,7 @@ ol.format.KML.readIcon_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.localName == 'Icon', 'localName should be Icon');
|
||||
var iconObject = ol.xml.pushParseAndPop(
|
||||
{}, ol.format.KML.ICON_PARSERS_, node, objectStack);
|
||||
if (goog.isDef(iconObject)) {
|
||||
if (iconObject) {
|
||||
return iconObject;
|
||||
} else {
|
||||
return null;
|
||||
@@ -819,7 +820,7 @@ ol.format.KML.readLineString_ = function(node, objectStack) {
|
||||
objectStack);
|
||||
var flatCoordinates =
|
||||
ol.format.KML.readFlatCoordinatesFromNode_(node, objectStack);
|
||||
if (goog.isDef(flatCoordinates)) {
|
||||
if (flatCoordinates) {
|
||||
var lineString = new ol.geom.LineString(null);
|
||||
lineString.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates);
|
||||
lineString.setProperties(properties);
|
||||
@@ -846,7 +847,7 @@ ol.format.KML.readLinearRing_ = function(node, objectStack) {
|
||||
objectStack);
|
||||
var flatCoordinates =
|
||||
ol.format.KML.readFlatCoordinatesFromNode_(node, objectStack);
|
||||
if (goog.isDef(flatCoordinates)) {
|
||||
if (flatCoordinates) {
|
||||
var polygon = new ol.geom.Polygon(null);
|
||||
polygon.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates,
|
||||
[flatCoordinates.length]);
|
||||
@@ -872,7 +873,7 @@ ol.format.KML.readMultiGeometry_ = function(node, objectStack) {
|
||||
var geometries = ol.xml.pushParseAndPop(
|
||||
/** @type {Array.<ol.geom.Geometry>} */ ([]),
|
||||
ol.format.KML.MULTI_GEOMETRY_PARSERS_, node, objectStack);
|
||||
if (!goog.isDef(geometries)) {
|
||||
if (!geometries) {
|
||||
return null;
|
||||
}
|
||||
if (geometries.length === 0) {
|
||||
@@ -1010,14 +1011,14 @@ ol.format.KML.readStyle_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.localName == 'Style', 'localName should be Style');
|
||||
var styleObject = ol.xml.pushParseAndPop(
|
||||
{}, ol.format.KML.STYLE_PARSERS_, node, objectStack);
|
||||
if (!goog.isDef(styleObject)) {
|
||||
if (!styleObject) {
|
||||
return null;
|
||||
}
|
||||
var fillStyle = /** @type {ol.style.Fill} */ (goog.object.get(
|
||||
styleObject, 'fillStyle', ol.format.KML.DEFAULT_FILL_STYLE_));
|
||||
var fill = /** @type {boolean|undefined} */
|
||||
(styleObject['fill']);
|
||||
if (goog.isDef(fill) && !fill) {
|
||||
if (ol.isDef(fill) && !fill) {
|
||||
fillStyle = null;
|
||||
}
|
||||
var imageStyle = /** @type {ol.style.Image} */ (goog.object.get(
|
||||
@@ -1028,7 +1029,7 @@ ol.format.KML.readStyle_ = function(node, objectStack) {
|
||||
styleObject, 'strokeStyle', ol.format.KML.DEFAULT_STROKE_STYLE_));
|
||||
var outline = /** @type {boolean|undefined} */
|
||||
(styleObject['outline']);
|
||||
if (goog.isDef(outline) && !outline) {
|
||||
if (ol.isDef(outline) && !outline) {
|
||||
strokeStyle = null;
|
||||
}
|
||||
return [new ol.style.Style({
|
||||
@@ -1060,8 +1061,8 @@ ol.format.KML.setCommonGeometryProperties_ = function(multiGeometry,
|
||||
geometry = geometries[i];
|
||||
extrudes[i] = geometry.get('extrude');
|
||||
altitudeModes[i] = geometry.get('altitudeMode');
|
||||
hasExtrude = hasExtrude || goog.isDef(extrudes[i]);
|
||||
hasAltitudeMode = hasAltitudeMode || goog.isDef(altitudeModes[i]);
|
||||
hasExtrude = hasExtrude || ol.isDef(extrudes[i]);
|
||||
hasAltitudeMode = hasAltitudeMode || altitudeModes[i];
|
||||
}
|
||||
if (hasExtrude) {
|
||||
multiGeometry.set('extrude', extrudes);
|
||||
@@ -1085,7 +1086,7 @@ ol.format.KML.DataParser_ = function(node, objectStack) {
|
||||
if (!goog.isNull(name)) {
|
||||
var data = ol.xml.pushParseAndPop(
|
||||
undefined, ol.format.KML.DATA_PARSERS_, node, objectStack);
|
||||
if (goog.isDef(data)) {
|
||||
if (data) {
|
||||
var featureObject =
|
||||
/** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||
goog.asserts.assert(goog.isObject(featureObject),
|
||||
@@ -1121,20 +1122,20 @@ ol.format.KML.PairDataParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.localName == 'Pair', 'localName should be Pair');
|
||||
var pairObject = ol.xml.pushParseAndPop(
|
||||
{}, ol.format.KML.PAIR_PARSERS_, node, objectStack);
|
||||
if (!goog.isDef(pairObject)) {
|
||||
if (!pairObject) {
|
||||
return;
|
||||
}
|
||||
var key = /** @type {string|undefined} */
|
||||
(pairObject['key']);
|
||||
if (goog.isDef(key) && key == 'normal') {
|
||||
if (key && key == 'normal') {
|
||||
var styleUrl = /** @type {string|undefined} */
|
||||
(pairObject['styleUrl']);
|
||||
if (goog.isDef(styleUrl)) {
|
||||
if (styleUrl) {
|
||||
objectStack[objectStack.length - 1] = styleUrl;
|
||||
}
|
||||
var Style = /** @type {ol.style.Style} */
|
||||
(pairObject['Style']);
|
||||
if (goog.isDef(Style)) {
|
||||
if (Style) {
|
||||
objectStack[objectStack.length - 1] = Style;
|
||||
}
|
||||
}
|
||||
@@ -1152,7 +1153,7 @@ ol.format.KML.PlacemarkStyleMapParser_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.localName == 'StyleMap',
|
||||
'localName should be StyleMap');
|
||||
var styleMapValue = ol.format.KML.readStyleMapValue_(node, objectStack);
|
||||
if (!goog.isDef(styleMapValue)) {
|
||||
if (!styleMapValue) {
|
||||
return;
|
||||
}
|
||||
var placemarkObject = objectStack[objectStack.length - 1];
|
||||
@@ -1215,7 +1216,7 @@ ol.format.KML.innerBoundaryIsParser_ = function(node, objectStack) {
|
||||
var flatLinearRing = ol.xml.pushParseAndPop(
|
||||
/** @type {Array.<number>|undefined} */ (undefined),
|
||||
ol.format.KML.INNER_BOUNDARY_IS_PARSERS_, node, objectStack);
|
||||
if (goog.isDef(flatLinearRing)) {
|
||||
if (flatLinearRing) {
|
||||
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
||||
(objectStack[objectStack.length - 1]);
|
||||
goog.asserts.assert(goog.isArray(flatLinearRings),
|
||||
@@ -1240,7 +1241,7 @@ ol.format.KML.outerBoundaryIsParser_ = function(node, objectStack) {
|
||||
var flatLinearRing = ol.xml.pushParseAndPop(
|
||||
/** @type {Array.<number>|undefined} */ (undefined),
|
||||
ol.format.KML.OUTER_BOUNDARY_IS_PARSERS_, node, objectStack);
|
||||
if (goog.isDef(flatLinearRing)) {
|
||||
if (flatLinearRing) {
|
||||
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
||||
(objectStack[objectStack.length - 1]);
|
||||
goog.asserts.assert(goog.isArray(flatLinearRings),
|
||||
@@ -1285,16 +1286,16 @@ ol.format.KML.whenParser_ = function(node, objectStack) {
|
||||
var m = re.exec(s);
|
||||
if (m) {
|
||||
var year = parseInt(m[1], 10);
|
||||
var month = goog.isDef(m[3]) ? parseInt(m[3], 10) - 1 : 0;
|
||||
var day = goog.isDef(m[5]) ? parseInt(m[5], 10) : 1;
|
||||
var hour = goog.isDef(m[7]) ? parseInt(m[7], 10) : 0;
|
||||
var minute = goog.isDef(m[8]) ? parseInt(m[8], 10) : 0;
|
||||
var second = goog.isDef(m[9]) ? parseInt(m[9], 10) : 0;
|
||||
var month = m[3] ? parseInt(m[3], 10) - 1 : 0;
|
||||
var day = m[5] ? parseInt(m[5], 10) : 1;
|
||||
var hour = m[7] ? parseInt(m[7], 10) : 0;
|
||||
var minute = m[8] ? parseInt(m[8], 10) : 0;
|
||||
var second = m[9] ? parseInt(m[9], 10) : 0;
|
||||
var when = Date.UTC(year, month, day, hour, minute, second);
|
||||
if (goog.isDef(m[10]) && m[10] != 'Z') {
|
||||
if (m[10] && m[10] != 'Z') {
|
||||
var sign = m[11] == '-' ? -1 : 1;
|
||||
when += sign * 60 * parseInt(m[12], 10);
|
||||
if (goog.isDef(m[13])) {
|
||||
if (m[13]) {
|
||||
when += sign * 60 * 60 * parseInt(m[13], 10);
|
||||
}
|
||||
}
|
||||
@@ -1650,7 +1651,7 @@ ol.format.KML.prototype.readDocumentOrFolder_ = function(node, objectStack) {
|
||||
});
|
||||
var features = ol.xml.pushParseAndPop(/** @type {Array.<ol.Feature>} */ ([]),
|
||||
parsersNS, node, objectStack, this);
|
||||
if (goog.isDef(features)) {
|
||||
if (features) {
|
||||
return features;
|
||||
} else {
|
||||
return undefined;
|
||||
@@ -1671,7 +1672,7 @@ ol.format.KML.prototype.readPlacemark_ = function(node, objectStack) {
|
||||
'localName should be Placemark');
|
||||
var object = ol.xml.pushParseAndPop({'geometry': null},
|
||||
ol.format.KML.PLACEMARK_PARSERS_, node, objectStack);
|
||||
if (!goog.isDef(object)) {
|
||||
if (!object) {
|
||||
return undefined;
|
||||
}
|
||||
var feature = new ol.Feature();
|
||||
@@ -1717,7 +1718,7 @@ ol.format.KML.prototype.readSharedStyle_ = function(node, objectStack) {
|
||||
var id = node.getAttribute('id');
|
||||
if (!goog.isNull(id)) {
|
||||
var style = ol.format.KML.readStyle_(node, objectStack);
|
||||
if (goog.isDef(style)) {
|
||||
if (style) {
|
||||
var styleUri;
|
||||
if (goog.isDefAndNotNull(node.baseURI)) {
|
||||
styleUri = goog.Uri.resolve(node.baseURI, '#' + id).toString();
|
||||
@@ -1745,7 +1746,7 @@ ol.format.KML.prototype.readSharedStyleMap_ = function(node, objectStack) {
|
||||
return;
|
||||
}
|
||||
var styleMapValue = ol.format.KML.readStyleMapValue_(node, objectStack);
|
||||
if (!goog.isDef(styleMapValue)) {
|
||||
if (!styleMapValue) {
|
||||
return;
|
||||
}
|
||||
var styleUri;
|
||||
@@ -1783,7 +1784,7 @@ ol.format.KML.prototype.readFeatureFromNode = function(node, opt_options) {
|
||||
'localName should be Placemark');
|
||||
var feature = this.readPlacemark_(
|
||||
node, [this.getReadOptions(node, opt_options)]);
|
||||
if (goog.isDef(feature)) {
|
||||
if (feature) {
|
||||
return feature;
|
||||
} else {
|
||||
return null;
|
||||
@@ -1817,7 +1818,7 @@ ol.format.KML.prototype.readFeaturesFromNode = function(node, opt_options) {
|
||||
if (localName == 'Document' || localName == 'Folder') {
|
||||
features = this.readDocumentOrFolder_(
|
||||
node, [this.getReadOptions(node, opt_options)]);
|
||||
if (goog.isDef(features)) {
|
||||
if (features) {
|
||||
return features;
|
||||
} else {
|
||||
return [];
|
||||
@@ -1825,7 +1826,7 @@ ol.format.KML.prototype.readFeaturesFromNode = function(node, opt_options) {
|
||||
} else if (localName == 'Placemark') {
|
||||
var feature = this.readPlacemark_(
|
||||
node, [this.getReadOptions(node, opt_options)]);
|
||||
if (goog.isDef(feature)) {
|
||||
if (feature) {
|
||||
return [feature];
|
||||
} else {
|
||||
return [];
|
||||
@@ -1836,7 +1837,7 @@ ol.format.KML.prototype.readFeaturesFromNode = function(node, opt_options) {
|
||||
for (n = node.firstElementChild; !goog.isNull(n);
|
||||
n = n.nextElementSibling) {
|
||||
var fs = this.readFeaturesFromNode(n, opt_options);
|
||||
if (goog.isDef(fs)) {
|
||||
if (fs) {
|
||||
goog.array.extend(features, fs);
|
||||
}
|
||||
}
|
||||
@@ -1878,7 +1879,7 @@ ol.format.KML.prototype.readNameFromDocument = function(doc) {
|
||||
for (n = doc.firstChild; !goog.isNull(n); n = n.nextSibling) {
|
||||
if (n.nodeType == goog.dom.NodeType.ELEMENT) {
|
||||
var name = this.readNameFromNode(n);
|
||||
if (goog.isDef(name)) {
|
||||
if (name) {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -1907,7 +1908,7 @@ ol.format.KML.prototype.readNameFromNode = function(node) {
|
||||
localName == 'Placemark' ||
|
||||
localName == 'kml')) {
|
||||
var name = this.readNameFromNode(n);
|
||||
if (goog.isDef(name)) {
|
||||
if (name) {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -2165,7 +2166,7 @@ ol.format.KML.writeLabelStyle_ = function(node, style, objectStack) {
|
||||
properties['color'] = fill.getColor();
|
||||
}
|
||||
var scale = style.getScale();
|
||||
if (goog.isDef(scale) && scale !== 1) {
|
||||
if (scale && scale !== 1) {
|
||||
properties['scale'] = scale;
|
||||
}
|
||||
var parentNode = objectStack[objectStack.length - 1].node;
|
||||
@@ -2272,7 +2273,7 @@ ol.format.KML.writePlacemark_ = function(node, feature, objectStack) {
|
||||
// serialize properties (properties unknown to KML are not serialized)
|
||||
var properties = feature.getProperties();
|
||||
var styleFunction = feature.getStyleFunction();
|
||||
if (goog.isDef(styleFunction)) {
|
||||
if (styleFunction) {
|
||||
// FIXME the styles returned by the style function are supposed to be
|
||||
// resolution-independent here
|
||||
var styles = styleFunction.call(feature, 0);
|
||||
|
||||
Reference in New Issue
Block a user