Skip to content

Commit

Permalink
Simplify cast
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed May 10, 2019
1 parent 321b708 commit 1997a3d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 71 deletions.
24 changes: 3 additions & 21 deletions contribs/gmf/src/editing/EditFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ EditingEditFeature.prototype.getFeaturesInExtent = function(layerIds, extent) {
const url = olUriAppendParams(`${this.baseUrl_}/${layerIds.join(',')}`, {
'bbox': extent.join(',')
});
return /** @type {angular.IPromise<import("ol/Feature.js").default[]>} */(
/** @type {angular.IPromise<unknown>} */(
this.http_.get(url).then(this.handleGetFeatures_.bind(this))
)
);
return this.http_.get(url).then(new olFormatGeoJSON().readFeatures);
};


Expand Down Expand Up @@ -92,27 +88,13 @@ EditingEditFeature.prototype.getFeaturesWithComparisonFilters = function(layerId

const url = olUriAppendParams(`${this.baseUrl_}/${layerIds.join(',')}`, params);

return /** @type {angular.IPromise<import("ol/Feature.js").default[]>} */(
/** @type {angular.IPromise<unknown>} */(
this.http_.get(url).then(this.handleGetFeatures_.bind(this))
)
);
};


/**
* @param {angular.IHttpResponse<ArrayBuffer|Document|Node|Object|string>} resp Ajax response.
* @return {import("ol/Feature.js").default[]} List of features.
* @private
*/
EditingEditFeature.prototype.handleGetFeatures_ = function(resp) {
return new olFormatGeoJSON().readFeatures(resp.data);
return this.http_.get(url).then(new olFormatGeoJSON().readFeatures);
};


/**
* @param {number} layerId The layer id that contains the feature.
* @param {Array.<import("ol/Feature.js").default>} features List of features to insert.
* @param {Array<import("ol/Feature.js").default>} features List of features to insert.
* @return {angular.IPromise<ArrayBuffer|Document|Node|Object|string>} Promise.
*/
EditingEditFeature.prototype.insertFeatures = function(layerId, features) {
Expand Down
18 changes: 1 addition & 17 deletions contribs/gmf/src/editing/EnumerateAttribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,10 @@ export class EditingEnumerateAttributeService {
const name = dataSource.name;
if (!this.promises_[promiseId]) {
const url = `${this.baseUrl_}/${name}/values/${attribute}`;
this.promises_[promiseId] =
/** @type {angular.IPromise<import('gmf/themes.js').GmfLayerAttributeValue[]>} */(
/** @type {angular.IPromise<unknown>} */(
this.http_.get(url).then(this.handleGetAttributeValues_.bind(this))
)
);
this.promises_[promiseId] = this.http_.get(url).then(resp => resp.data.items);
}
return this.promises_[promiseId];
}

/**
* @param {angular.IHttpResponse<import('gmf/themes.js').GmfLayerAttributeValuesResponse>} resp Ajax
* response.
* @return {import('gmf/themes.js').GmfLayerAttributeValue[]} List of the attribute
* values.
*/
handleGetAttributeValues_(resp) {
return resp.data.items;
}

}


Expand Down
14 changes: 1 addition & 13 deletions contribs/gmf/src/editing/XSDAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,11 @@ export function EditingXSDAttributeService($http, gmfLayersUrl) {
EditingXSDAttributeService.prototype.getAttributes = function(id) {
if (!this.promises_[id]) {
const url = `${this.baseUrl_}/${id}/md.xsd`;
this.promises_[id] = /** @type {angular.IPromise<import('ngeo/format/Attribute.js').Attribute[]>} */(
/** @type {angular.IPromise<unknown>} */(
this.http_.get(url).then(this.handleGetAttributes_.bind(this))
)
);
this.promises_[id] = this.http_.get(url).then(resp => new ngeoFormatXSDAttribute().read(resp.data));
}
return this.promises_[id];
};

/**
* @param {angular.IHttpResponse<any>} resp Ajax response.
* @return {import('ngeo/format/Attribute.js').Attribute[]} List of attributes.
*/
EditingXSDAttributeService.prototype.handleGetAttributes_ = function(resp) {
return new ngeoFormatXSDAttribute().read(resp.data);
};


/**
* @type {!angular.IModule}
Expand Down
8 changes: 1 addition & 7 deletions contribs/gmf/src/raster/RasterService.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,7 @@ RasterService.prototype.getRaster = function(coordinate, opt_params) {
params[Param.X] = coordinate[0];
params[Param.Y] = coordinate[1];

return /** @type {angular.IPromise<Object<string, number>>} */(
/** @type {angular.IPromise<unknown>} */(
this.$http_.get(this.url_, {
params
}).then(this.handleGetRaster_.bind(this))
)
);
return this.$http_.get(this.url_, {params}).then(resp => resp.data);
};


Expand Down
19 changes: 6 additions & 13 deletions src/query/Querent.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,7 @@ export class Querent {
promises.push(this.issueCombinedWMS_(combinedWMSDataSources, options));
}

return /** @type {angular.IPromise<QuerentResult>} */(
/** @type {angular.IPromise<unknown>} */(
/** @type {angular.IPromise<QuerentResult[]>} */(this.q_.all(promises))
.then(this.handleCombinedQueryResult_.bind(this))
)
);
return this.q_.all(promises).then(this.handleCombinedQueryResult_);
}

/**
Expand Down Expand Up @@ -780,7 +775,7 @@ export class Querent {
countPromise.then(afterCount_);
}

return this.q_.all(promises).then(this.handleCombinedQueryResult_.bind(this));
return this.q_.all(promises).then(this.handleCombinedQueryResult_);
}

/**
Expand All @@ -794,6 +789,7 @@ export class Querent {
*/
issueCombinedWMS_(combinedDataSources, options) {

/** @type {angular.IPromise<QuerentResult>[]} */
const promises = [];

// The 'limit' option is mandatory in the querent service
Expand Down Expand Up @@ -930,16 +926,13 @@ export class Querent {
timeout: canceler.promise
}
).then(
this.handleQueryResult_.bind(this, dataSources, FEATURE_COUNT, false)
/** @type {function(angular.IHttpResponse<Document|Element|string>|number): QuerentResult} */
(this.handleQueryResult_.bind(this, dataSources, FEATURE_COUNT, false))
)
);
}

return /** @type {angular.IPromise<QuerentResult>} */(
/** @type {angular.IPromise<unknown>} */(
this.q_.all(promises).then(this.handleCombinedQueryResult_.bind(this))
)
);
return this.q_.all(promises).then(this.handleCombinedQueryResult_);
}

/**
Expand Down

0 comments on commit 1997a3d

Please sign in to comment.