MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / isValidType

Method isValidType

src/common/format/GeoJSON.js:593–623  ·  view source on GitHub ↗

* @function GeoJSONFormat.prototype.isValidType * @description 检查一个 GeoJSON 对象是否和给定的类型相符的合法的对象。 * @returns {boolean} GeoJSON 是否是给定类型的合法对象。 * @private

(obj, type)

Source from the content-addressed store, hash-verified

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

Callers 5

readMethod · 0.95
FDFunction · 0.80
echarts-en.min.jsFile · 0.80
FDFunction · 0.80
echarts.min.jsFile · 0.80

Calls 1

indexOfMethod · 0.80

Tested by

no test coverage detected