* @function GeoJSONFormat.prototype.isValidType * @description 检查一个 GeoJSON 对象是否和给定的类型相符的合法的对象。 * @returns {boolean} GeoJSON 是否是给定类型的合法对象。 * @private
(obj, type)
| 591 | * @private |
| 592 | */ |
| 593 | isValidType(obj, type) { |
| 594 | var valid = false; |
| 595 | switch (type) { |
| 596 | case "Geometry": |
| 597 | if (Util.indexOf( |
| 598 | ["Point", "MultiPoint", "LineString", "MultiLineString", |
| 599 | "Polygon", "MultiPolygon", "Box", "GeometryCollection" |
| 600 | ], |
| 601 | obj.type) == -1) { |
| 602 | // unsupported geometry type |
| 603 | //console.error("Unsupported geometry type: " + |
| 604 | // obj.type); |
| 605 | } else { |
| 606 | valid = true; |
| 607 | } |
| 608 | break; |
| 609 | case "FeatureCollection": |
| 610 | // allow for any type to be converted to a feature collection |
| 611 | valid = true; |
| 612 | break; |
| 613 | default: |
| 614 | // for Feature types must match |
| 615 | if (obj.type == type) { |
| 616 | valid = true; |
| 617 | } else { |
| 618 | //console.error("Cannot convert types from " + |
| 619 | //obj.type + " to " + type); |
| 620 | } |
| 621 | } |
| 622 | return valid; |
| 623 | } |
| 624 | /** |
| 625 | * @static |
| 626 | * @version 12.1.0 |
no test coverage detected