1 line
15 KiB
JSON
1 line
15 KiB
JSON
{"ast":null,"code":"import \"core-js/modules/es.array.slice.js\";\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n/**\n * Parse and decode geo json\n */\nimport * as zrUtil from 'zrender/lib/core/util.js';\nimport { GeoJSONLineStringGeometry, GeoJSONPolygonGeometry, GeoJSONRegion } from './Region.js';\n\nfunction decode(json) {\n if (!json.UTF8Encoding) {\n return json;\n }\n\n var jsonCompressed = json;\n var encodeScale = jsonCompressed.UTF8Scale;\n\n if (encodeScale == null) {\n encodeScale = 1024;\n }\n\n var features = jsonCompressed.features;\n zrUtil.each(features, function (feature) {\n var geometry = feature.geometry;\n var encodeOffsets = geometry.encodeOffsets;\n var coordinates = geometry.coordinates; // Geometry may be appeded manually in the script after json loaded.\n // In this case this geometry is usually not encoded.\n\n if (!encodeOffsets) {\n return;\n }\n\n switch (geometry.type) {\n case 'LineString':\n geometry.coordinates = decodeRing(coordinates, encodeOffsets, encodeScale);\n break;\n\n case 'Polygon':\n decodeRings(coordinates, encodeOffsets, encodeScale);\n break;\n\n case 'MultiLineString':\n decodeRings(coordinates, encodeOffsets, encodeScale);\n break;\n\n case 'MultiPolygon':\n zrUtil.each(coordinates, function (rings, idx) {\n return decodeRings(rings, encodeOffsets[idx], encodeScale);\n });\n }\n }); // Has been decoded\n\n jsonCompressed.UTF8Encoding = false;\n return jsonCompressed;\n}\n\nfunction decodeRings(rings, encodeOffsets, encodeScale) {\n for (var c = 0; c < rings.length; c++) {\n rings[c] = decodeRing(rings[c], encodeOffsets[c], encodeScale);\n }\n}\n\nfunction decodeRing(coordinate, encodeOffsets, encodeScale) {\n var result = [];\n var prevX = encodeOffsets[0];\n var prevY = encodeOffsets[1];\n\n for (var i = 0; i < coordinate.length; i += 2) {\n var x = coordinate.charCodeAt(i) - 64;\n var y = coordinate.charCodeAt(i + 1) - 64; // ZigZag decoding\n\n x = x >> 1 ^ -(x & 1);\n y = y >> 1 ^ -(y & 1); // Delta deocding\n\n x += prevX;\n y += prevY;\n prevX = x;\n prevY = y; // Dequantize\n\n result.push([x / encodeScale, y / encodeScale]);\n }\n\n return result;\n}\n\nexport default function parseGeoJSON(geoJson, nameProperty) {\n geoJson = decode(geoJson);\n return zrUtil.map(zrUtil.filter(geoJson.features, function (featureObj) {\n // Output of mapshaper may have geometry null\n return featureObj.geometry && featureObj.properties && featureObj.geometry.coordinates.length > 0;\n }), function (featureObj) {\n var properties = featureObj.properties;\n var geo = featureObj.geometry;\n var geometries = [];\n\n switch (geo.type) {\n case 'Polygon':\n var coordinates = geo.coordinates; // According to the GeoJSON specification.\n // First must be exterior, and the rest are all interior(holes).\n\n geometries.push(new GeoJSONPolygonGeometry(coordinates[0], coordinates.slice(1)));\n break;\n\n case 'MultiPolygon':\n zrUtil.each(geo.coordinates, function (item) {\n if (item[0]) {\n geometries.push(new GeoJSONPolygonGeometry(item[0], item.slice(1)));\n }\n });\n break;\n\n case 'LineString':\n geometries.push(new GeoJSONLineStringGeometry([geo.coordinates]));\n break;\n\n case 'MultiLineString':\n geometries.push(new GeoJSONLineStringGeometry(geo.coordinates));\n }\n\n var region = new GeoJSONRegion(properties[nameProperty || 'name'], geometries, properties.cp);\n region.properties = properties;\n return region;\n });\n}","map":{"version":3,"sources":["D:/Work/WorkSpace/GitWorkSpace/TenShop/resource/ElectronicMall/src啊/ElectronicMallVue/node_modules/echarts/lib/coord/geo/parseGeoJson.js"],"names":["zrUtil","GeoJSONLineStringGeometry","GeoJSONPolygonGeometry","GeoJSONRegion","decode","json","UTF8Encoding","jsonCompressed","encodeScale","UTF8Scale","features","each","feature","geometry","encodeOffsets","coordinates","type","decodeRing","decodeRings","rings","idx","c","length","coordinate","result","prevX","prevY","i","x","charCodeAt","y","push","parseGeoJSON","geoJson","nameProperty","map","filter","featureObj","properties","geo","geometries","slice","item","region","cp"],"mappings":";;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO,KAAKA,MAAZ,MAAwB,0BAAxB;AACA,SAASC,yBAAT,EAAoCC,sBAApC,EAA4DC,aAA5D,QAAiF,aAAjF;;AAEA,SAASC,MAAT,CAAgBC,IAAhB,EAAsB;AACpB,MAAI,CAACA,IAAI,CAACC,YAAV,EAAwB;AACtB,WAAOD,IAAP;AACD;;AAED,MAAIE,cAAc,GAAGF,IAArB;AACA,MAAIG,WAAW,GAAGD,cAAc,CAACE,SAAjC;;AAEA,MAAID,WAAW,IAAI,IAAnB,EAAyB;AACvBA,IAAAA,WAAW,GAAG,IAAd;AACD;;AA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J,YAAY,IAAI,MAAjB,CAA5B,EAAsDM,UAAtD,EAAkEF,UAAU,CAACM,EAA7E,CAAb;AACAD,IAAAA,MAAM,CAACL,UAAP,GAAoBA,UAApB;AACA,WAAOK,MAAP;AACD,GAnCM,CAAP;AAoCD","sourcesContent":["\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n/**\n * Parse and decode geo json\n */\nimport * as zrUtil from 'zrender/lib/core/util.js';\nimport { GeoJSONLineStringGeometry, GeoJSONPolygonGeometry, GeoJSONRegion } from './Region.js';\n\nfunction decode(json) {\n if (!json.UTF8Encoding) {\n return json;\n }\n\n var jsonCompressed = json;\n var encodeScale = jsonCompressed.UTF8Scale;\n\n if (encodeScale == null) {\n encodeScale = 1024;\n }\n\n var features = jsonCompressed.features;\n zrUtil.each(features, function (feature) {\n var geometry = feature.geometry;\n var encodeOffsets = geometry.encodeOffsets;\n var coordinates = geometry.coordinates; // Geometry may be appeded manually in the script after json loaded.\n // In this case this geometry is usually not encoded.\n\n if (!encodeOffsets) {\n return;\n }\n\n switch (geometry.type) {\n case 'LineString':\n geometry.coordinates = decodeRing(coordinates, encodeOffsets, encodeScale);\n break;\n\n case 'Polygon':\n decodeRings(coordinates, encodeOffsets, encodeScale);\n break;\n\n case 'MultiLineString':\n decodeRings(coordinates, encodeOffsets, encodeScale);\n break;\n\n case 'MultiPolygon':\n zrUtil.each(coordinates, function (rings, idx) {\n return decodeRings(rings, encodeOffsets[idx], encodeScale);\n });\n }\n }); // Has been decoded\n\n jsonCompressed.UTF8Encoding = false;\n return jsonCompressed;\n}\n\nfunction decodeRings(rings, encodeOffsets, encodeScale) {\n for (var c = 0; c < rings.length; c++) {\n rings[c] = decodeRing(rings[c], encodeOffsets[c], encodeScale);\n }\n}\n\nfunction decodeRing(coordinate, encodeOffsets, encodeScale) {\n var result = [];\n var prevX = encodeOffsets[0];\n var prevY = encodeOffsets[1];\n\n for (var i = 0; i < coordinate.length; i += 2) {\n var x = coordinate.charCodeAt(i) - 64;\n var y = coordinate.charCodeAt(i + 1) - 64; // ZigZag decoding\n\n x = x >> 1 ^ -(x & 1);\n y = y >> 1 ^ -(y & 1); // Delta deocding\n\n x += prevX;\n y += prevY;\n prevX = x;\n prevY = y; // Dequantize\n\n result.push([x / encodeScale, y / encodeScale]);\n }\n\n return result;\n}\n\nexport default function parseGeoJSON(geoJson, nameProperty) {\n geoJson = decode(geoJson);\n return zrUtil.map(zrUtil.filter(geoJson.features, function (featureObj) {\n // Output of mapshaper may have geometry null\n return featureObj.geometry && featureObj.properties && featureObj.geometry.coordinates.length > 0;\n }), function (featureObj) {\n var properties = featureObj.properties;\n var geo = featureObj.geometry;\n var geometries = [];\n\n switch (geo.type) {\n case 'Polygon':\n var coordinates = geo.coordinates; // According to the GeoJSON specification.\n // First must be exterior, and the rest are all interior(holes).\n\n geometries.push(new GeoJSONPolygonGeometry(coordinates[0], coordinates.slice(1)));\n break;\n\n case 'MultiPolygon':\n zrUtil.each(geo.coordinates, function (item) {\n if (item[0]) {\n geometries.push(new GeoJSONPolygonGeometry(item[0], item.slice(1)));\n }\n });\n break;\n\n case 'LineString':\n geometries.push(new GeoJSONLineStringGeometry([geo.coordinates]));\n break;\n\n case 'MultiLineString':\n geometries.push(new GeoJSONLineStringGeometry(geo.coordinates));\n }\n\n var region = new GeoJSONRegion(properties[nameProperty || 'name'], geometries, properties.cp);\n region.properties = properties;\n return region;\n });\n}"]},"metadata":{},"sourceType":"module"} |