* @function GeoJSONFormat.prototype.toGeoJSON * @version 9.1.1 * @description 将 SuperMap iServer Feature JSON 对象转换为 GeoJSON 对象。 * @param {Object} obj - SuperMap iServer Feature JSON。 * @param {Object} [options] - 转换选项。 * @param {boolean} [options.parseProperties] - 是否对查询返回的要
(obj, options)
| 552 | * @returns {GeoJSONObject} GeoJSON 对象。 |
| 553 | */ |
| 554 | toGeoJSON(obj, options) { |
| 555 | var geojson = { |
| 556 | "type": null |
| 557 | }; |
| 558 | if (Util.isArray(obj)) { |
| 559 | geojson.type = "FeatureCollection"; |
| 560 | var numFeatures = obj.length; |
| 561 | geojson.features = new Array(numFeatures); |
| 562 | for (var i = 0; i < numFeatures; ++i) { |
| 563 | var element = obj[i]; |
| 564 | if (isGeometry(element)) { |
| 565 | let feature = {}; |
| 566 | feature.geometry = element; |
| 567 | geojson.features[i] = this.extract.feature.apply(this, [feature, options]); |
| 568 | } else { |
| 569 | geojson.features[i] = this.extract.feature.apply(this, [element, options]); |
| 570 | } |
| 571 | } |
| 572 | } else if (isGeometry(obj)) { |
| 573 | let feature = {}; |
| 574 | feature.geometry = obj; |
| 575 | geojson = this.extract.feature.apply(this, [feature, options]); |
| 576 | } else { |
| 577 | geojson = this.extract.feature.apply(this, [obj, options]); |
| 578 | } |
| 579 | |
| 580 | function isGeometry(input) { |
| 581 | return (input.hasOwnProperty("parts") && input.hasOwnProperty("points")) || input.hasOwnProperty("geoParts"); |
| 582 | } |
| 583 | |
| 584 | return geojson; |
| 585 | |
| 586 | } |
| 587 | /** |
| 588 | * @function GeoJSONFormat.prototype.isValidType |
| 589 | * @description 检查一个 GeoJSON 对象是否和给定的类型相符的合法的对象。 |
no outgoing calls
no test coverage detected