Better code indentation
This commit is contained in:
+16
-31
@@ -109,9 +109,8 @@ function readGeometry(object, opt_options) {
|
||||
}
|
||||
}
|
||||
const geometryReader = GEOMETRY_READERS[type];
|
||||
return (
|
||||
/** @type {ol.geom.Geometry} */ transformWithOptions(
|
||||
geometryReader(object), false, opt_options)
|
||||
return /** @type {ol.geom.Geometry} */ (transformWithOptions(
|
||||
geometryReader(object), false, opt_options)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -429,11 +428,9 @@ EsriJSON.prototype.readFeatures;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
EsriJSON.prototype.readFeatureFromObject = function(
|
||||
object, opt_options) {
|
||||
EsriJSON.prototype.readFeatureFromObject = function(object, opt_options) {
|
||||
const esriJSONFeature = /** @type {EsriJSONFeature} */ (object);
|
||||
const geometry = readGeometry(esriJSONFeature.geometry,
|
||||
opt_options);
|
||||
const geometry = readGeometry(esriJSONFeature.geometry, opt_options);
|
||||
const feature = new Feature();
|
||||
if (this.geometryName_) {
|
||||
feature.setGeometryName(this.geometryName_);
|
||||
@@ -441,8 +438,7 @@ EsriJSON.prototype.readFeatureFromObject = function(
|
||||
feature.setGeometry(geometry);
|
||||
if (opt_options && opt_options.idField &&
|
||||
esriJSONFeature.attributes[opt_options.idField]) {
|
||||
feature.setId(/** @type {number} */(
|
||||
esriJSONFeature.attributes[opt_options.idField]));
|
||||
feature.setId(/** @type {number} */(esriJSONFeature.attributes[opt_options.idField]));
|
||||
}
|
||||
if (esriJSONFeature.attributes) {
|
||||
feature.setProperties(esriJSONFeature.attributes);
|
||||
@@ -454,21 +450,17 @@ EsriJSON.prototype.readFeatureFromObject = function(
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
EsriJSON.prototype.readFeaturesFromObject = function(
|
||||
object, opt_options) {
|
||||
EsriJSON.prototype.readFeaturesFromObject = function(object, opt_options) {
|
||||
const esriJSONObject = /** @type {EsriJSONObject} */ (object);
|
||||
const options = opt_options ? opt_options : {};
|
||||
if (esriJSONObject.features) {
|
||||
const esriJSONFeatureCollection = /** @type {EsriJSONFeatureCollection} */
|
||||
(object);
|
||||
const esriJSONFeatureCollection = /** @type {EsriJSONFeatureCollection} */ (object);
|
||||
/** @type {Array.<ol.Feature>} */
|
||||
const features = [];
|
||||
const esriJSONFeatures = esriJSONFeatureCollection.features;
|
||||
let i, ii;
|
||||
options.idField = object.objectIdFieldName;
|
||||
for (i = 0, ii = esriJSONFeatures.length; i < ii; ++i) {
|
||||
features.push(this.readFeatureFromObject(esriJSONFeatures[i],
|
||||
options));
|
||||
for (let i = 0, ii = esriJSONFeatures.length; i < ii; ++i) {
|
||||
features.push(this.readFeatureFromObject(esriJSONFeatures[i], options));
|
||||
}
|
||||
return features;
|
||||
} else {
|
||||
@@ -492,10 +484,8 @@ EsriJSON.prototype.readGeometry;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
EsriJSON.prototype.readGeometryFromObject = function(
|
||||
object, opt_options) {
|
||||
return readGeometry(
|
||||
/** @type {EsriJSONGeometry} */(object), opt_options);
|
||||
EsriJSON.prototype.readGeometryFromObject = function(object, opt_options) {
|
||||
return readGeometry(/** @type {EsriJSONGeometry} */(object), opt_options);
|
||||
};
|
||||
|
||||
|
||||
@@ -557,10 +547,8 @@ EsriJSON.prototype.writeGeometry;
|
||||
* @override
|
||||
* @api
|
||||
*/
|
||||
EsriJSON.prototype.writeGeometryObject = function(geometry,
|
||||
opt_options) {
|
||||
return writeGeometry(geometry,
|
||||
this.adaptOptions(opt_options));
|
||||
EsriJSON.prototype.writeGeometryObject = function(geometry, opt_options) {
|
||||
return writeGeometry(geometry, this.adaptOptions(opt_options));
|
||||
};
|
||||
|
||||
|
||||
@@ -585,14 +573,12 @@ EsriJSON.prototype.writeFeature;
|
||||
* @override
|
||||
* @api
|
||||
*/
|
||||
EsriJSON.prototype.writeFeatureObject = function(
|
||||
feature, opt_options) {
|
||||
EsriJSON.prototype.writeFeatureObject = function(feature, opt_options) {
|
||||
opt_options = this.adaptOptions(opt_options);
|
||||
const object = {};
|
||||
const geometry = feature.getGeometry();
|
||||
if (geometry) {
|
||||
object['geometry'] =
|
||||
writeGeometry(geometry, opt_options);
|
||||
object['geometry'] = writeGeometry(geometry, opt_options);
|
||||
if (opt_options && opt_options.featureProjection) {
|
||||
object['geometry']['spatialReference'] = /** @type {EsriJSONCRS} */({
|
||||
wkid: getProjection(opt_options.featureProjection).getCode().split(':').pop()
|
||||
@@ -634,8 +620,7 @@ EsriJSON.prototype.writeFeatures;
|
||||
EsriJSON.prototype.writeFeaturesObject = function(features, opt_options) {
|
||||
opt_options = this.adaptOptions(opt_options);
|
||||
const objects = [];
|
||||
let i, ii;
|
||||
for (i = 0, ii = features.length; i < ii; ++i) {
|
||||
for (let i = 0, ii = features.length; i < ii; ++i) {
|
||||
objects.push(this.writeFeatureObject(features[i], opt_options));
|
||||
}
|
||||
return /** @type {EsriJSONFeatureCollection} */ ({
|
||||
|
||||
@@ -479,8 +479,7 @@ GML2.prototype.writePoint_ = function(node, geometry, objectStack) {
|
||||
* @param {Array.<*>} objectStack Node stack.
|
||||
* @private
|
||||
*/
|
||||
GML2.prototype.writeMultiPoint_ = function(node, geometry,
|
||||
objectStack) {
|
||||
GML2.prototype.writeMultiPoint_ = function(node, geometry, objectStack) {
|
||||
const context = objectStack[objectStack.length - 1];
|
||||
const hasZ = context['hasZ'];
|
||||
const srsName = context['srsName'];
|
||||
|
||||
@@ -813,8 +813,7 @@ GML3.prototype.writeMultiSurfaceOrPolygon_ = function(node, geometry, objectStac
|
||||
* @param {Array.<*>} objectStack Node stack.
|
||||
* @private
|
||||
*/
|
||||
GML3.prototype.writeMultiPoint_ = function(node, geometry,
|
||||
objectStack) {
|
||||
GML3.prototype.writeMultiPoint_ = function(node, geometry, objectStack) {
|
||||
const context = objectStack[objectStack.length - 1];
|
||||
const srsName = context['srsName'];
|
||||
const hasZ = context['hasZ'];
|
||||
|
||||
@@ -106,9 +106,8 @@ function readGeometry(object, opt_options) {
|
||||
return null;
|
||||
}
|
||||
const geometryReader = GEOMETRY_READERS[object.type];
|
||||
return (
|
||||
/** @type {ol.geom.Geometry} */ transformWithOptions(
|
||||
geometryReader(object), false, opt_options)
|
||||
return /** @type {ol.geom.Geometry} */ (transformWithOptions(
|
||||
geometryReader(object), false, opt_options)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -121,9 +120,9 @@ function readGeometry(object, opt_options) {
|
||||
function readGeometryCollectionGeometry(object, opt_options) {
|
||||
const geometries = object.geometries.map(
|
||||
/**
|
||||
* @param {GeoJSONGeometry} geometry Geometry.
|
||||
* @return {ol.geom.Geometry} geometry Geometry.
|
||||
*/
|
||||
* @param {GeoJSONGeometry} geometry Geometry.
|
||||
* @return {ol.geom.Geometry} geometry Geometry.
|
||||
*/
|
||||
function(geometry) {
|
||||
return readGeometry(geometry, opt_options);
|
||||
});
|
||||
@@ -388,8 +387,7 @@ GeoJSON.prototype.readFeaturesFromObject = function(object, opt_options) {
|
||||
const geoJSONFeatureCollection = /** @type {GeoJSONFeatureCollection} */ (object);
|
||||
features = [];
|
||||
const geoJSONFeatures = geoJSONFeatureCollection.features;
|
||||
let i, ii;
|
||||
for (i = 0, ii = geoJSONFeatures.length; i < ii; ++i) {
|
||||
for (let i = 0, ii = geoJSONFeatures.length; i < ii; ++i) {
|
||||
features.push(this.readFeatureFromObject(geoJSONFeatures[i], opt_options));
|
||||
}
|
||||
} else {
|
||||
@@ -523,8 +521,7 @@ GeoJSON.prototype.writeFeatures;
|
||||
GeoJSON.prototype.writeFeaturesObject = function(features, opt_options) {
|
||||
opt_options = this.adaptOptions(opt_options);
|
||||
const objects = [];
|
||||
let i, ii;
|
||||
for (i = 0, ii = features.length; i < ii; ++i) {
|
||||
for (let i = 0, ii = features.length; i < ii; ++i) {
|
||||
objects.push(this.writeFeatureObject(features[i], opt_options));
|
||||
}
|
||||
return /** @type {GeoJSONFeatureCollection} */ ({
|
||||
|
||||
@@ -2192,8 +2192,7 @@ const DOCUMENT_SERIALIZERS = makeStructureNS(
|
||||
* @param {string=} opt_nodeName Node name.
|
||||
* @return {Node|undefined} Node.
|
||||
*/
|
||||
const DOCUMENT_NODE_FACTORY = function(value, objectStack,
|
||||
opt_nodeName) {
|
||||
const DOCUMENT_NODE_FACTORY = function(value, objectStack, opt_nodeName) {
|
||||
const parentNode = objectStack[objectStack.length - 1].node;
|
||||
return createElementNS(parentNode.namespaceURI, 'Placemark');
|
||||
};
|
||||
|
||||
@@ -319,13 +319,11 @@ Polyline.prototype.readGeometryFromText = function(text, opt_options) {
|
||||
const stride = getStrideForLayout(this.geometryLayout_);
|
||||
const flatCoordinates = decodeDeltas(text, stride, this.factor_);
|
||||
flipXY(flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
|
||||
const coordinates = inflateCoordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, stride);
|
||||
const coordinates = inflateCoordinates(flatCoordinates, 0, flatCoordinates.length, stride);
|
||||
|
||||
return (
|
||||
/** @type {ol.geom.Geometry} */ transformWithOptions(
|
||||
new LineString(coordinates, this.geometryLayout_), false,
|
||||
this.adaptOptions(opt_options))
|
||||
return /** @type {ol.geom.Geometry} */ (transformWithOptions(
|
||||
new LineString(coordinates, this.geometryLayout_), false,
|
||||
this.adaptOptions(opt_options))
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -61,8 +61,7 @@ XMLFeature.prototype.readFeature = function(source, opt_options) {
|
||||
* @param {olx.format.ReadOptions=} opt_options Options.
|
||||
* @return {ol.Feature} Feature.
|
||||
*/
|
||||
XMLFeature.prototype.readFeatureFromDocument = function(
|
||||
doc, opt_options) {
|
||||
XMLFeature.prototype.readFeatureFromDocument = function(doc, opt_options) {
|
||||
const features = this.readFeaturesFromDocument(doc, opt_options);
|
||||
if (features.length > 0) {
|
||||
return features[0];
|
||||
|
||||
Reference in New Issue
Block a user