New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@antv/l7-source

Package Overview
Dependencies
Maintainers
64
Versions
540
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/l7-source - npm Package Compare versions

Comparing version 2.21.1 to 2.21.2

lib/factory.d.ts

21

es/factory.js

@@ -0,14 +1,17 @@

// src/factory.ts
var TRANSFORMS = {};
var PARSERS = {};
export var getParser = function getParser(type) {
return PARSERS[type];
};
export var registerParser = function registerParser(type, parserFunction) {
var getParser = (type) => PARSERS[type];
var registerParser = (type, parserFunction) => {
PARSERS[type] = parserFunction;
};
export var getTransform = function getTransform(type) {
return TRANSFORMS[type];
var getTransform = (type) => TRANSFORMS[type];
var registerTransform = (type, transFunction) => {
TRANSFORMS[type] = transFunction;
};
export var registerTransform = function registerTransform(type, transFunction) {
TRANSFORMS[type] = transFunction;
};
export {
getParser,
getTransform,
registerParser,
registerTransform
};

@@ -0,1 +1,2 @@

// src/index.ts
import { registerParser, registerTransform } from "./factory";

@@ -22,25 +23,37 @@ import csv from "./parser/csv";

import { map } from "./transform/map";
export { getParser, getTransform, registerParser, registerTransform } from "./factory";
import {
getParser,
getTransform,
registerParser as registerParser2,
registerTransform as registerTransform2
} from "./factory";
export * from "./interface";
export * from "./source/index";
export { rasterDataTypes };
registerParser('rasterTile', rasterTile);
registerParser('mvt', mapboxVectorTile);
registerParser('geojsonvt', geojsonVTTile);
registerParser('testTile', testTile);
registerParser('geojson', geojson);
registerParser('jsonTile', jsonTile);
registerParser('image', image);
registerParser('csv', csv);
registerParser('json', json);
registerParser('raster', raster);
registerParser('rasterRgb', rasterRgb);
registerParser('rgb', rgb);
registerParser('ndi', ndi);
registerTransform('cluster', cluster);
registerTransform('filter', filter);
registerTransform('join', join);
registerTransform('map', map);
registerTransform('grid', aggregatorToGrid);
registerTransform('hexagon', pointToHexbin);
export default Source;
registerParser("rasterTile", rasterTile);
registerParser("mvt", mapboxVectorTile);
registerParser("geojsonvt", geojsonVTTile);
registerParser("testTile", testTile);
registerParser("geojson", geojson);
registerParser("jsonTile", jsonTile);
registerParser("image", image);
registerParser("csv", csv);
registerParser("json", json);
registerParser("raster", raster);
registerParser("rasterRgb", rasterRgb);
registerParser("rgb", rgb);
registerParser("ndi", ndi);
registerTransform("cluster", cluster);
registerTransform("filter", filter);
registerTransform("join", join);
registerTransform("map", map);
registerTransform("grid", aggregatorToGrid);
registerTransform("hexagon", pointToHexbin);
var src_default = Source;
export {
src_default as default,
getParser,
getTransform,
rasterDataTypes,
registerParser2 as registerParser,
registerTransform2 as registerTransform
};

@@ -1,6 +0,10 @@

import { csvParse } from 'd3-dsv';
// src/parser/csv.ts
import { csvParse } from "d3-dsv";
import json from "./json";
export default function csv(data, cfg) {
var csvData = csvParse(data);
function csv(data, cfg) {
const csvData = csvParse(data);
return json(csvData, cfg);
}
}
export {
csv as default
};

@@ -1,37 +0,49 @@

import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import { getCoords } from '@turf/invariant';
import { flattenEach } from '@turf/meta';
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
// src/parser/geojson.ts
import { getCoords } from "@turf/invariant";
import { flattenEach } from "@turf/meta";
import { geojsonRewind } from "../utils/util";
function djb2hash(field) {
var str = field.toString();
var hash = 5381;
var i = str.length;
const str = field.toString();
let hash = 5381;
let i = str.length;
while (i) {
hash = hash * 33 ^ str.charCodeAt(--i);
}
/* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
* integers. Since we want the results to be always positive, convert the
* signed int to an unsigned by doing an unsigned bitshift. */
return hash >>> 0;
}
function getFeatureID(feature, key) {
if (key === undefined) {
if (key === void 0) {
return null;
}
// @ts-ignore
if (typeof (feature.properties[key] * 1) === 'number') {
// @ts-ignore
if (typeof (feature.properties[key] * 1) === "number") {
return feature.properties[key] * 1;
}
if (feature.properties && feature.properties[key]) {
// 根据 properties 要素的属性进行编码
return djb2hash(feature.properties[key] + '') % 1000019;
return djb2hash(feature.properties[key] + "") % 1000019;
}
return null;
}
export default function geoJSON(data, cfg) {
var resultData = [];
var featureKeys = {};
function geoJSON(data, cfg) {
const resultData = [];
const featureKeys = {};
if (!data.features) {

@@ -43,4 +55,4 @@ data.features = [];

}
data.features = data.features.filter(function (item) {
var geometry = item.geometry;
data.features = data.features.filter((item) => {
const geometry = item.geometry;
return item != null && geometry && geometry.type && geometry.coordinates && geometry.coordinates.length > 0;

@@ -52,24 +64,28 @@ });

dataArray: [],
featureKeys: featureKeys
featureKeys
};
}
// multi feature 情况拆分
flattenEach(data, function (currentFeature, featureIndex) {
var featureId = getFeatureID(currentFeature, cfg === null || cfg === void 0 ? void 0 : cfg.featureId);
if (featureId === null) {
featureId = featureIndex;
flattenEach(
data,
(currentFeature, featureIndex) => {
let featureId = getFeatureID(currentFeature, cfg == null ? void 0 : cfg.featureId);
if (featureId === null) {
featureId = featureIndex;
}
const sortedID = featureId;
const coord = getCoords(currentFeature);
const dataItem = __spreadProps(__spreadValues({}, currentFeature.properties), {
coordinates: coord,
_id: sortedID
});
resultData.push(dataItem);
}
var sortedID = featureId;
var coord = getCoords(currentFeature);
var dataItem = _objectSpread(_objectSpread({}, currentFeature.properties), {}, {
coordinates: coord,
_id: sortedID
});
resultData.push(dataItem);
});
);
return {
dataArray: resultData,
featureKeys: featureKeys
featureKeys
};
}
}
export {
geoJSON as default
};

@@ -1,5 +0,43 @@

import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import _regeneratorRuntime from "@babel/runtime/regenerator";
import geojsonvt from 'geojson-vt';
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/parser/geojsonvt.ts
import geojsonvt from "geojson-vt";
import VtSource from "../source/geojsonvt";

@@ -13,4 +51,4 @@ var DEFAULT_CONFIG = {

function signedArea(ring) {
var sum = 0;
for (var i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) {
let sum = 0;
for (let i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) {
p1 = ring[i];

@@ -23,15 +61,15 @@ p2 = ring[j];

function classifyRings(rings) {
var len = rings.length;
const len = rings.length;
if (len <= 1) {
return [rings];
}
var polygons = [];
var polygon;
var ccw;
for (var i = 0; i < len; i++) {
var area = signedArea(rings[i]);
const polygons = [];
let polygon;
let ccw;
for (let i = 0; i < len; i++) {
const area = signedArea(rings[i]);
if (area === 0) {
continue;
}
if (ccw === undefined) {
if (ccw === void 0) {
ccw = area < 0;

@@ -53,24 +91,23 @@ }

}
var VectorTileFeatureTypes = ['Unknown', 'Point', 'LineString', 'Polygon'];
var VectorTileFeatureTypes = ["Unknown", "Point", "LineString", "Polygon"];
function GetGeoJSON(extent, x, y, z, vectorTileFeature) {
var coords = vectorTileFeature.geometry;
var currenType = vectorTileFeature.type;
var currentProperties = vectorTileFeature.tags;
var currentId = vectorTileFeature.id;
var size = extent * Math.pow(2, z);
var x0 = extent * x;
var y0 = extent * y;
var type = VectorTileFeatureTypes[currenType];
var i;
var j;
let coords = vectorTileFeature.geometry;
const currenType = vectorTileFeature.type;
const currentProperties = vectorTileFeature.tags;
const currentId = vectorTileFeature.id;
const size = extent * Math.pow(2, z);
const x0 = extent * x;
const y0 = extent * y;
let type = VectorTileFeatureTypes[currenType];
let i;
let j;
function project(line) {
for (var index = 0; index < line.length; index++) {
var p = line[index];
for (let index = 0; index < line.length; index++) {
const p = line[index];
if (p[3]) {
// 避免重复计算
break;
}
var y2 = 180 - (p[1] + y0) * 360 / size;
var lng = (p[0] + x0) * 360 / size - 180;
var lat = 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
const y2 = 180 - (p[1] + y0) * 360 / size;
const lng = (p[0] + x0) * 360 / size - 180;
const lat = 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
line[index] = [lng, lat, 0, 1];

@@ -81,3 +118,3 @@ }

case 1:
var points = [];
const points = [];
for (i = 0; i < coords.length; i++) {

@@ -106,8 +143,8 @@ points[i] = coords[i][0];

} else {
type = 'Multi' + type;
type = "Multi" + type;
}
var result = {
type: 'Feature',
const result = {
type: "Feature",
geometry: {
type: type,
type,
coordinates: coords

@@ -118,40 +155,32 @@ },

tileOrigin: [0, 0],
coord: ''
coord: ""
};
return result;
}
var getVectorTile = /*#__PURE__*/function () {
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(tile, tileIndex, tileParams, extent) {
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
return _context.abrupt("return", new Promise(function (resolve) {
var tileData = tileIndex.getTile(tile.z, tile.x, tile.y);
// tileData
var features = tileData ? tileData.features.map(function (vectorTileFeature) {
return GetGeoJSON(extent, tileParams.x, tileParams.y, tileParams.z, vectorTileFeature);
}) : [];
var vectorTile = {
layers: {
defaultLayer: {
// @ts-ignore
features: features
}
}
};
var vectorSource = new VtSource(vectorTile, tile.x, tile.y, tile.z);
resolve(vectorSource);
}));
case 1:
case "end":
return _context.stop();
var getVectorTile = (tile, tileIndex, tileParams, extent) => __async(void 0, null, function* () {
return new Promise((resolve) => {
const tileData = tileIndex.getTile(tile.z, tile.x, tile.y);
const features = tileData ? tileData.features.map((vectorTileFeature) => {
return GetGeoJSON(
extent,
tileParams.x,
tileParams.y,
tileParams.z,
vectorTileFeature
);
}) : [];
const vectorTile = {
layers: {
defaultLayer: {
// @ts-ignore
features
}
}
}, _callee);
}));
return function getVectorTile(_x, _x2, _x3, _x4) {
return _ref.apply(this, arguments);
};
}();
};
const vectorSource = new VtSource(vectorTile, tile.x, tile.y, tile.z);
resolve(vectorSource);
});
});
function getOption(cfg) {
var defaultOptions = {
const defaultOptions = {
// geojson-vt default options

@@ -162,3 +191,3 @@ maxZoom: 14,

// max zoom in the tile index
indexMaxPoints: 100000,
indexMaxPoints: 1e5,
// max number of points per tile in the tile index

@@ -177,26 +206,30 @@ tolerance: 3,

// whether to generate feature ids. Cannot be used with promoteId
debug: 0 // logging level (0, 1 or 2)
debug: 0
// logging level (0, 1 or 2)
};
if (cfg === undefined || typeof cfg.geojsonvtOptions === 'undefined') {
if (cfg === void 0 || typeof cfg.geojsonvtOptions === "undefined") {
return defaultOptions;
} else {
return _objectSpread(_objectSpread({}, defaultOptions), cfg.geojsonvtOptions);
return __spreadValues(__spreadValues({}, defaultOptions), cfg.geojsonvtOptions);
}
}
export default function geojsonVTTile(data, cfg) {
var geojsonOptions = getOption(cfg);
var extent = geojsonOptions.extent || 4096;
var tileIndex = geojsonvt(data, geojsonOptions);
var getTileData = function getTileData(tileParams, tile) {
function geojsonVTTile(data, cfg) {
const geojsonOptions = getOption(cfg);
const extent = geojsonOptions.extent || 4096;
const tileIndex = geojsonvt(data, geojsonOptions);
const getTileData = (tileParams, tile) => {
return getVectorTile(tile, tileIndex, tileParams, extent);
};
var tilesetOptions = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_CONFIG), cfg), {}, {
getTileData: getTileData
const tilesetOptions = __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_CONFIG), cfg), {
getTileData
});
return {
data: data,
data,
dataArray: [],
tilesetOptions: tilesetOptions,
tilesetOptions,
isTile: true
};
}
}
export {
geojsonVTTile as default
};

@@ -1,16 +0,35 @@

import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import { getImage, isImageBitmap } from '@antv/l7-utils';
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
// src/parser/image.ts
import { getImage, isImageBitmap } from "@antv/l7-utils";
import { extentToCoord } from "../utils/util";
export default function image(data, cfg) {
// 为 extent 赋默认值
var _cfg$extent = cfg.extent,
extent = _cfg$extent === void 0 ? [121.168, 30.2828, 121.384, 30.4219] : _cfg$extent,
coordinates = cfg.coordinates,
_cfg$requestParameter = cfg.requestParameters,
requestParameters = _cfg$requestParameter === void 0 ? {} : _cfg$requestParameter;
var images = new Promise(function (resolve) {
function image(data, cfg) {
const {
extent = [121.168, 30.2828, 121.384, 30.4219],
coordinates,
requestParameters = {}
} = cfg;
const images = new Promise((resolve) => {
if (data instanceof HTMLImageElement || isImageBitmap(data)) {
resolve([data]);
} else {
loadData(data, requestParameters, function (res) {
loadData(data, requestParameters, (res) => {
resolve(res);

@@ -20,11 +39,13 @@ });

});
var imageCoord = extentToCoord(coordinates, extent);
var resultData = {
const imageCoord = extentToCoord(coordinates, extent);
const resultData = {
originData: data,
images: images,
images,
_id: 1,
dataArray: [{
_id: 0,
coordinates: imageCoord
}]
dataArray: [
{
_id: 0,
coordinates: imageCoord
}
]
};

@@ -34,7 +55,5 @@ return resultData;

function loadData(url, requestParameters, done) {
var imageDatas = [];
if (typeof url === 'string') {
getImage(_objectSpread(_objectSpread({}, requestParameters), {}, {
url: url
}), function (err, img) {
const imageDatas = [];
if (typeof url === "string") {
getImage(__spreadProps(__spreadValues({}, requestParameters), { url }), (err, img) => {
if (img) {

@@ -46,8 +65,6 @@ imageDatas.push(img);

} else {
var imageCount = url.length;
var imageindex = 0;
url.forEach(function (item) {
getImage(_objectSpread(_objectSpread({}, requestParameters), {}, {
url: item
}), function (err, img) {
const imageCount = url.length;
let imageindex = 0;
url.forEach((item) => {
getImage(__spreadProps(__spreadValues({}, requestParameters), { url: item }), (err, img) => {
imageindex++;

@@ -64,2 +81,5 @@ if (img) {

return image;
}
}
export {
image as default
};

@@ -1,1 +0,5 @@

export { default as geojson } from "./geojson";
// src/parser/index.ts
import { default as default2 } from "./geojson";
export {
default2 as geojson
};

@@ -1,17 +0,28 @@

import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
// @ts-ignore
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
// @ts-ignore
import { getCoords } from '@turf/invariant';
import { flattenEach } from '@turf/meta';
// src/parser/json.ts
import { getCoords } from "@turf/invariant";
import { flattenEach } from "@turf/meta";
import { geojsonRewind } from "../utils/util";
export default function json(data, cfg) {
var x = cfg.x,
y = cfg.y,
x1 = cfg.x1,
y1 = cfg.y1,
coordinates = cfg.coordinates,
geometry = cfg.geometry;
var resultData = [];
function json(data, cfg) {
const { x, y, x1, y1, coordinates, geometry } = cfg;
const resultData = [];
if (!Array.isArray(data)) {

@@ -22,18 +33,18 @@ return {

}
// GeoJson geometry 数据
if (geometry) {
data.filter(function (item) {
data.filter((item) => {
return item[geometry] && item[geometry].type && item[geometry].coordinates && item[geometry].coordinates.length > 0;
}).forEach(function (col, index) {
var rewindGeometry = geojsonRewind(col[geometry]);
// multi feature 情况拆分
flattenEach(rewindGeometry, function (currentFeature) {
var coord = getCoords(currentFeature);
var dataItem = _objectSpread(_objectSpread({}, col), {}, {
_id: index,
coordinates: coord
});
resultData.push(dataItem);
});
}).forEach((col, index) => {
const rewindGeometry = geojsonRewind(col[geometry]);
flattenEach(
rewindGeometry,
(currentFeature) => {
const coord = getCoords(currentFeature);
const dataItem = __spreadProps(__spreadValues({}, col), {
_id: index,
coordinates: coord
});
resultData.push(dataItem);
}
);
});

@@ -44,18 +55,15 @@ return {

}
for (var featureIndex = 0; featureIndex < data.length; featureIndex++) {
var col = data[featureIndex];
var coords = [];
// GeoJson coordinates 数据
// 仅支持 Point LineString Polygon 三种 coordinates
for (let featureIndex = 0; featureIndex < data.length; featureIndex++) {
const col = data[featureIndex];
let coords = [];
if (coordinates) {
var type = 'Polygon';
let type = "Polygon";
if (!Array.isArray(coordinates[0])) {
type = 'Point';
type = "Point";
}
if (Array.isArray(coordinates[0]) && !Array.isArray(coordinates[0][0])) {
type = 'LineString';
type = "LineString";
}
var rewindGeometry = geojsonRewind({
type: type,
const rewindGeometry = geojsonRewind({
type,
coordinates: col[coordinates]

@@ -65,11 +73,9 @@ });

} else if (x && y && x1 && y1) {
// 起终点数据
var from = [parseFloat(col[x]), parseFloat(col[y])];
var to = [parseFloat(col[x1]), parseFloat(col[y1])];
const from = [parseFloat(col[x]), parseFloat(col[y])];
const to = [parseFloat(col[x1]), parseFloat(col[y1])];
coords = [from, to];
} else if (x && y) {
// 点数据
coords = [parseFloat(col[x]), parseFloat(col[y])];
}
var dataItem = _objectSpread(_objectSpread({}, col), {}, {
const dataItem = __spreadProps(__spreadValues({}, col), {
_id: featureIndex,

@@ -83,2 +89,5 @@ coordinates: coords

};
}
}
export {
json as default
};

@@ -1,94 +0,125 @@

import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import _regeneratorRuntime from "@babel/runtime/regenerator";
import { getData, getURLFromTemplate } from '@antv/l7-utils';
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/parser/jsonTile.ts
import {
getData,
getURLFromTemplate
} from "@antv/l7-utils";
import VtSource from "../source/geojsonvt";
var getVectorTile = /*#__PURE__*/function () {
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(url, tile, requestParameters, getCustomData) {
var params, tileUrl;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
params = {
x: tile.x,
y: tile.y,
z: tile.z
var getVectorTile = (url, tile, requestParameters, getCustomData) => __async(void 0, null, function* () {
const params = { x: tile.x, y: tile.y, z: tile.z };
const tileUrl = getURLFromTemplate(url, params);
return new Promise((resolve) => {
if (getCustomData) {
getCustomData(params, (err, data) => {
if (err || !data) {
const vectorTile = {
layers: { defaultLayer: { features: [] } }
};
tileUrl = getURLFromTemplate(url, params);
return _context.abrupt("return", new Promise(function (resolve) {
if (getCustomData) {
getCustomData(params, function (err, data) {
if (err || !data) {
var vectorTile = {
layers: {
defaultLayer: {
features: []
}
}
};
var vectorSource = new VtSource(vectorTile, tile.x, tile.y, tile.z);
resolve(vectorSource);
} else {
var _vectorTile = {
layers: {
defaultLayer: {
features: data.features
}
}
};
var _vectorSource = new VtSource(_vectorTile, tile.x, tile.y, tile.z);
resolve(_vectorSource);
const vectorSource = new VtSource(vectorTile, tile.x, tile.y, tile.z);
resolve(vectorSource);
} else {
const vectorTile = {
layers: { defaultLayer: { features: data.features } }
};
const vectorSource = new VtSource(vectorTile, tile.x, tile.y, tile.z);
resolve(vectorSource);
}
});
} else {
getData(
__spreadProps(__spreadValues({}, requestParameters), {
url: tileUrl
}),
(err, data) => {
if (err || !data) {
const vectorTile = {
layers: {
defaultLayer: {
features: []
}
});
} else {
getData(_objectSpread(_objectSpread({}, requestParameters), {}, {
url: tileUrl
}), function (err, data) {
if (err || !data) {
var vectorTile = {
layers: {
defaultLayer: {
features: []
}
}
};
var vectorSource = new VtSource(vectorTile, tile.x, tile.y, tile.z);
resolve(vectorSource);
} else {
var json = JSON.parse(data);
var _vectorTile2 = {
layers: {
defaultLayer: {
features: json
}
}
};
var _vectorSource2 = new VtSource(_vectorTile2, tile.x, tile.y, tile.z);
resolve(_vectorSource2);
}
};
const vectorSource = new VtSource(
vectorTile,
tile.x,
tile.y,
tile.z
);
resolve(vectorSource);
} else {
const json = JSON.parse(data);
const vectorTile = {
layers: {
defaultLayer: {
features: json
}
});
}
}));
case 3:
case "end":
return _context.stop();
}
}, _callee);
}));
return function getVectorTile(_x, _x2, _x3, _x4) {
return _ref.apply(this, arguments);
}
};
const vectorSource = new VtSource(
vectorTile,
tile.x,
tile.y,
tile.z
);
resolve(vectorSource);
}
}
);
}
});
});
function jsonTile(url, cfg) {
const getTileData = (_, tile) => {
return getVectorTile(url, tile, cfg == null ? void 0 : cfg.requestParameters, cfg.getCustomData);
};
}();
export default function jsonTile(url, cfg) {
var getTileData = function getTileData(_, tile) {
return getVectorTile(url, tile, cfg === null || cfg === void 0 ? void 0 : cfg.requestParameters, cfg.getCustomData);
};
var tilesetOptions = _objectSpread(_objectSpread({}, cfg), {}, {
getTileData: getTileData
const tilesetOptions = __spreadProps(__spreadValues({}, cfg), {
getTileData
});
return {
dataArray: [],
tilesetOptions: tilesetOptions,
tilesetOptions,
isTile: true
};
}
}
export {
jsonTile as default
};

@@ -1,5 +0,46 @@

import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import _regeneratorRuntime from "@babel/runtime/regenerator";
import { getArrayBuffer, getURLFromTemplate } from '@antv/l7-utils';
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/parser/mvt.ts
import {
getArrayBuffer,
getURLFromTemplate
} from "@antv/l7-utils";
import VectorSource from "../source/vector";

@@ -13,64 +54,60 @@ var DEFAULT_CONFIG = {

};
var getVectorTile = /*#__PURE__*/function () {
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(url, tileParams, tile, requestParameters, getCustomData) {
var tileUrl;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
tileUrl = getURLFromTemplate(url, tileParams);
return _context.abrupt("return", new Promise(function (resolve) {
if (getCustomData) {
getCustomData({
x: tile.x,
y: tile.y,
z: tile.z
}, function (err, data) {
if (err || !data) {
resolve(undefined);
} else {
var vectorSource = new VectorSource(data, tile.x, tile.y, tile.z);
resolve(vectorSource);
}
});
} else {
var xhr = getArrayBuffer(_objectSpread(_objectSpread({}, requestParameters), {}, {
url: tileUrl
}), function (err, data) {
if (err || !data) {
resolve(undefined);
} else {
var vectorSource = new VectorSource(data, tile.x, tile.y, tile.z);
resolve(vectorSource);
}
});
tile.xhrCancel = function () {
return xhr.cancel();
};
}
}));
case 2:
case "end":
return _context.stop();
}
}, _callee);
}));
return function getVectorTile(_x, _x2, _x3, _x4, _x5) {
return _ref.apply(this, arguments);
};
}();
export default function mapboxVectorTile(data, cfg) {
// TODO: 后续考虑支持多服务
var url = Array.isArray(data) ? data[0] : data;
var getTileData = function getTileData(tileParams, tile) {
return getVectorTile(url, tileParams, tile, cfg === null || cfg === void 0 ? void 0 : cfg.requestParameters, cfg === null || cfg === void 0 ? void 0 : cfg.getCustomData);
};
var tilesetOptions = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_CONFIG), cfg), {}, {
getTileData: getTileData
var getVectorTile = (url, tileParams, tile, requestParameters, getCustomData) => __async(void 0, null, function* () {
const tileUrl = getURLFromTemplate(url, tileParams);
return new Promise((resolve) => {
if (getCustomData) {
getCustomData(
{
x: tile.x,
y: tile.y,
z: tile.z
},
(err, data) => {
if (err || !data) {
resolve(void 0);
} else {
const vectorSource = new VectorSource(data, tile.x, tile.y, tile.z);
resolve(vectorSource);
}
}
);
} else {
const xhr = getArrayBuffer(
__spreadProps(__spreadValues({}, requestParameters), {
url: tileUrl
}),
(err, data) => {
if (err || !data) {
resolve(void 0);
} else {
const vectorSource = new VectorSource(data, tile.x, tile.y, tile.z);
resolve(vectorSource);
}
}
);
tile.xhrCancel = () => xhr.cancel();
}
});
});
function mapboxVectorTile(data, cfg) {
const url = Array.isArray(data) ? data[0] : data;
const getTileData = (tileParams, tile) => getVectorTile(
url,
tileParams,
tile,
cfg == null ? void 0 : cfg.requestParameters,
cfg == null ? void 0 : cfg.getCustomData
);
const tilesetOptions = __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_CONFIG), cfg), {
getTileData
});
return {
data: url,
dataArray: [],
tilesetOptions: tilesetOptions,
tilesetOptions,
isTile: true
};
}
}
export {
mapboxVectorTile as default
};

@@ -1,5 +0,29 @@

import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import { RasterTileType } from '@antv/l7-core';
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
// src/parser/raster-tile.ts
import { RasterTileType } from "@antv/l7-core";
import { getCustomData, getCustomImageData } from "../utils/tile/getCustomData";
import { defaultFormat, getTileBuffer, getTileImage } from "../utils/tile/getRasterTile";
import {
defaultFormat,
getTileBuffer,
getTileImage
} from "../utils/tile/getRasterTile";
var DEFAULT_CONFIG = {

@@ -12,3 +36,3 @@ tileSize: 256,

};
export var rasterDataTypes = [RasterTileType.ARRAYBUFFER, RasterTileType.RGB];
var rasterDataTypes = [RasterTileType.ARRAYBUFFER, RasterTileType.RGB];
function isUrlError(url) {

@@ -18,3 +42,3 @@ if (Array.isArray(url) && url.length === 0) {

}
if (!Array.isArray(url) && typeof url !== 'string') {
if (!Array.isArray(url) && typeof url !== "string") {
return true;

@@ -24,19 +48,11 @@ }

}
/**
*
* @param data
* @param cfg
* @returns
*/
export default function rasterTile(data) {
var cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
function rasterTile(data, cfg = {}) {
if (isUrlError(data)) {
throw new Error('tile server url is error');
throw new Error("tile server url is error");
}
var tileDataType = (cfg === null || cfg === void 0 ? void 0 : cfg.dataType) || RasterTileType.IMAGE;
// Tip: RasterTileType.RGB 是彩色多通道的数据纹理,同样走数据纹理的请求
let tileDataType = (cfg == null ? void 0 : cfg.dataType) || RasterTileType.IMAGE;
if (tileDataType === RasterTileType.RGB) {
tileDataType = RasterTileType.ARRAYBUFFER;
}
var getTileData = function getTileData(tileParams, tile) {
const getTileData = (tileParams, tile) => {
switch (tileDataType) {

@@ -48,11 +64,24 @@ case RasterTileType.IMAGE:

return getCustomImageData(
// 自定义地形请求方式数据
tile, // @ts-ignore
cfg === null || cfg === void 0 ? void 0 : cfg.getCustomData);
// 自定义地形请求方式数据
tile,
// @ts-ignore
cfg == null ? void 0 : cfg.getCustomData
);
case RasterTileType.ARRAYBUFFER:
return getTileBuffer(data, tileParams, tile, (cfg === null || cfg === void 0 ? void 0 : cfg.format) || defaultFormat, cfg === null || cfg === void 0 ? void 0 : cfg.operation);
return getTileBuffer(
data,
tileParams,
tile,
(cfg == null ? void 0 : cfg.format) || defaultFormat,
cfg == null ? void 0 : cfg.operation
);
case RasterTileType.CUSTOMARRAYBUFFER:
case RasterTileType.CUSTOMRGB:
return getCustomData(tile, // @ts-ignore
cfg === null || cfg === void 0 ? void 0 : cfg.getCustomData, (cfg === null || cfg === void 0 ? void 0 : cfg.format) || defaultFormat, cfg === null || cfg === void 0 ? void 0 : cfg.operation);
return getCustomData(
tile,
// @ts-ignore
cfg == null ? void 0 : cfg.getCustomData,
(cfg == null ? void 0 : cfg.format) || defaultFormat,
cfg == null ? void 0 : cfg.operation
);
default:

@@ -62,11 +91,13 @@ return getTileImage(data, tileParams, tile, cfg);

};
var tilesetOptions = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_CONFIG), cfg), {}, {
getTileData: getTileData
});
const tilesetOptions = __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_CONFIG), cfg), { getTileData });
return {
data: data,
data,
dataArray: [],
tilesetOptions: tilesetOptions,
tilesetOptions,
isTile: true
};
}
}
export {
rasterTile as default,
rasterDataTypes
};

@@ -0,18 +1,19 @@

// src/parser/raster.ts
import { bandsOperation } from "../utils/bandOperation/bands";
import { isNumberArray, extentToCoord } from "../utils/util";
export default function raster(data, cfg) {
var _cfg$extent = cfg.extent,
extent = _cfg$extent === void 0 ? [121.168, 30.2828, 121.384, 30.4219] : _cfg$extent,
coordinates = cfg.coordinates,
width = cfg.width,
height = cfg.height,
min = cfg.min,
max = cfg.max,
format = cfg.format,
operation = cfg.operation;
var bandData;
var rasterWidth;
var rasterHeight;
if (format === undefined || isNumberArray(data)) {
// 兼容写法 - 用户直接传入解析完的波段数据
function raster(data, cfg) {
const {
extent = [121.168, 30.2828, 121.384, 30.4219],
coordinates,
width,
height,
min,
max,
format,
operation
} = cfg;
let bandData;
let rasterWidth;
let rasterHeight;
if (format === void 0 || isNumberArray(data)) {
bandData = Array.from(data);

@@ -22,21 +23,24 @@ rasterWidth = width;

} else {
// 用户传入为解析的栅格数据 - arraybuffer
// 将数据统一为 IRasterFileData[]
var imageDataList = Array.isArray(data) ? data : [data];
const imageDataList = Array.isArray(data) ? data : [data];
bandData = bandsOperation(imageDataList, format, operation);
}
var imageCoord = extentToCoord(coordinates, extent);
var resultData = {
const imageCoord = extentToCoord(coordinates, extent);
const resultData = {
_id: 1,
dataArray: [{
_id: 1,
data: bandData,
width: rasterWidth,
height: rasterHeight,
min: min,
max: max,
coordinates: imageCoord
}]
dataArray: [
{
_id: 1,
data: bandData,
width: rasterWidth,
height: rasterHeight,
min,
max,
coordinates: imageCoord
}
]
};
return resultData;
}
}
export {
raster as default
};

@@ -1,43 +0,64 @@

import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["extent", "coordinates", "width", "height"];
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
target[prop] = source[prop];
}
return target;
};
// src/parser/raster/ndi.ts
import { extentToCoord } from "../../utils/util";
/**
* @description: 栅格数据解析
*/
export default function rasterRgb(data, cfg) {
var _cfg$extent = cfg.extent,
extent = _cfg$extent === void 0 ? [121.168, 30.2828, 121.384, 30.4219] : _cfg$extent,
coordinates = cfg.coordinates,
width = cfg.width,
height = cfg.height,
options = _objectWithoutProperties(cfg, _excluded);
function rasterRgb(data, cfg) {
const _a = cfg, { extent = [121.168, 30.2828, 121.384, 30.4219], coordinates, width, height } = _a, options = __objRest(_a, ["extent", "coordinates", "width", "height"]);
if (data.length < 2) {
console.warn('RGB解析需要2个波段的数据');
console.warn("RGB解析需要2个波段的数据");
}
var _ref = options.bands || [0, 1],
_ref2 = _slicedToArray(_ref, 2),
n = _ref2[0],
d = _ref2[1];
var bandsData = [data[n], data[d]];
var ndidata = [];
for (var i = 0; i < bandsData[0].length; i++) {
const [n, d] = options.bands || [0, 1];
const bandsData = [data[n], data[d]];
const ndidata = [];
for (let i = 0; i < bandsData[0].length; i++) {
ndidata.push((bandsData[1][i] - bandsData[0][i]) / (bandsData[1][i] + bandsData[0][i]));
}
var imageCoord = extentToCoord(coordinates, extent);
var resultData = {
const imageCoord = extentToCoord(coordinates, extent);
const resultData = {
_id: 1,
dataArray: [_objectSpread(_objectSpread({
_id: 1,
data: ndidata,
width: width,
height: height
}, options), {}, {
coordinates: imageCoord
})]
dataArray: [
__spreadProps(__spreadValues({
_id: 1,
data: ndidata,
width,
height
}, options), {
coordinates: imageCoord
})
]
};
return resultData;
}
}
export {
rasterRgb as default
};

@@ -1,36 +0,49 @@

import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["extent", "coordinates", "width", "height"];
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
target[prop] = source[prop];
}
return target;
};
// src/parser/raster/rgb.ts
import { percentile } from "../../utils/bandOperation/operationSchema";
import { extentToCoord } from "../../utils/util";
/**
* @description: 栅格数据解析
*/
export default function rasterRgb(data, cfg) {
var extent = cfg.extent,
coordinates = cfg.coordinates,
width = cfg.width,
height = cfg.height,
options = _objectWithoutProperties(cfg, _excluded);
function rasterRgb(data, cfg) {
const _a = cfg, { extent, coordinates, width, height } = _a, options = __objRest(_a, ["extent", "coordinates", "width", "height"]);
if (data.length < 3) {
console.warn('RGB解析需要三个波段的数据');
console.warn("RGB解析需要三个波段的数据");
}
var _ref = options.bands || [0, 1, 2],
_ref2 = _slicedToArray(_ref, 3),
r = _ref2[0],
g = _ref2[1],
b = _ref2[2];
var bandsData = [data[r], data[g], data[b]];
var rgbdata = [];
var _ref3 = (options === null || options === void 0 ? void 0 : options.countCut) || [2, 98],
_ref4 = _slicedToArray(_ref3, 2),
low = _ref4[0],
high = _ref4[1];
var minMaxR = (options === null || options === void 0 ? void 0 : options.RMinMax) || percentile(bandsData[0], low, high);
var minMaxG = (options === null || options === void 0 ? void 0 : options.GMinMax) || percentile(bandsData[1], low, high);
var minMaxB = (options === null || options === void 0 ? void 0 : options.BMinMax) || percentile(bandsData[2], low, high);
for (var i = 0; i < bandsData[0].length; i++) {
const [r, g, b] = options.bands || [0, 1, 2];
const bandsData = [data[r], data[g], data[b]];
const rgbdata = [];
const [low, high] = (options == null ? void 0 : options.countCut) || [2, 98];
const minMaxR = (options == null ? void 0 : options.RMinMax) || percentile(bandsData[0], low, high);
const minMaxG = (options == null ? void 0 : options.GMinMax) || percentile(bandsData[1], low, high);
const minMaxB = (options == null ? void 0 : options.BMinMax) || percentile(bandsData[2], low, high);
for (let i = 0; i < bandsData[0].length; i++) {
rgbdata.push(Math.max(0, bandsData[0][i] - minMaxR[0]));

@@ -40,18 +53,23 @@ rgbdata.push(Math.max(0, bandsData[1][i] - minMaxG[0]));

}
var imageCoord = extentToCoord(coordinates, extent);
var resultData = {
const imageCoord = extentToCoord(coordinates, extent);
const resultData = {
_id: 1,
dataArray: [_objectSpread(_objectSpread({
_id: 1,
data: rgbdata,
width: width,
height: height,
rMinMax: minMaxR,
gMinMax: minMaxG,
bMinMax: minMaxB
}, options), {}, {
coordinates: imageCoord
})]
dataArray: [
__spreadProps(__spreadValues({
_id: 1,
data: rgbdata,
width,
height,
rMinMax: minMaxR,
gMinMax: minMaxG,
bMinMax: minMaxB
}, options), {
coordinates: imageCoord
})
]
};
return resultData;
}
}
export {
rasterRgb as default
};

@@ -1,41 +0,65 @@

import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["extent", "coordinates", "min", "max", "width", "height", "format", "operation"];
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
target[prop] = source[prop];
}
return target;
};
// src/parser/rasterRgb.ts
import { bandsOperation } from "../utils/bandOperation/bands";
import { isNumberArray, extentToCoord } from "../utils/util";
export default function rasterRgb(data, cfg) {
var extent = cfg.extent,
coordinates = cfg.coordinates,
min = cfg.min,
max = cfg.max,
width = cfg.width,
height = cfg.height,
format = cfg.format,
operation = cfg.operation,
rest = _objectWithoutProperties(cfg, _excluded);
var bandData;
if (format === undefined || isNumberArray(data)) {
// 兼容写法 - 用户直接传入解析完的波段数据
function rasterRgb(data, cfg) {
const _a = cfg, { extent, coordinates, min, max, width, height, format, operation } = _a, rest = __objRest(_a, ["extent", "coordinates", "min", "max", "width", "height", "format", "operation"]);
let bandData;
if (format === void 0 || isNumberArray(data)) {
bandData = Array.from(data);
} else {
// 用户传入为解析的栅格数据 - arraybuffer
// 将数据统一为 IRasterFileData[]
var imageDataList = Array.isArray(data) ? data : [data];
const imageDataList = Array.isArray(data) ? data : [data];
bandData = bandsOperation(imageDataList, format, operation);
}
var imageCoord = extentToCoord(coordinates, extent);
var resultData = {
const imageCoord = extentToCoord(coordinates, extent);
const resultData = {
_id: 1,
dataArray: [_objectSpread(_objectSpread({
_id: 1,
data: bandData,
width: width,
height: height
}, rest), {}, {
min: min,
max: max,
coordinates: imageCoord
})]
dataArray: [
__spreadProps(__spreadValues({
_id: 1,
data: bandData,
width,
height
}, rest), {
min,
max,
coordinates: imageCoord
})
]
};
return resultData;
}
}
export {
rasterRgb as default
};

@@ -1,5 +0,42 @@

import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import _regeneratorRuntime from "@babel/runtime/regenerator";
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/parser/testTile.ts
var DEFAULT_CONFIG = {

@@ -11,63 +48,48 @@ tileSize: 256,

};
var getVectorTile = /*#__PURE__*/function () {
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(tile) {
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
return _context.abrupt("return", new Promise(function (resolve) {
var _tile$bounds = _slicedToArray(tile.bounds, 4),
minLng = _tile$bounds[0],
minLat = _tile$bounds[1],
maxLng = _tile$bounds[2],
maxLat = _tile$bounds[3];
// minLng/maxLat ---- maxLng/maxLat
// | |
// | |
// | |
// minLng/minLat --- maxLng/minLat
var vectorTile = {
layers: {
// Tip: fixed SourceLayer Name
testTile: {
features: [{
type: 'Feature',
properties: {
key: tile.x + '/' + tile.y + '/' + tile.z,
x: (minLng + maxLng) / 2,
y: (minLat + maxLat) / 2
},
geometry: {
type: 'LineString',
coordinates: [[maxLng, maxLat], [maxLng, minLat], [minLng, minLat], [minLng, minLat]]
}
}]
}
var getVectorTile = (tile) => __async(void 0, null, function* () {
return new Promise((resolve) => {
const [minLng, minLat, maxLng, maxLat] = tile.bounds;
const vectorTile = {
layers: {
// Tip: fixed SourceLayer Name
testTile: {
features: [
{
type: "Feature",
properties: {
key: tile.x + "/" + tile.y + "/" + tile.z,
x: (minLng + maxLng) / 2,
y: (minLat + maxLat) / 2
},
geometry: {
type: "LineString",
coordinates: [
[maxLng, maxLat],
[maxLng, minLat],
[minLng, minLat],
[minLng, minLat]
]
}
};
resolve(vectorTile);
}));
case 1:
case "end":
return _context.stop();
}
]
}
}
}, _callee);
}));
return function getVectorTile(_x) {
return _ref.apply(this, arguments);
};
}();
export default function mapboxVectorTile(data, cfg) {
var getTileData = function getTileData(tile) {
return getVectorTile(tile);
};
var tilesetOptions = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_CONFIG), cfg), {}, {
getTileData: getTileData
};
resolve(vectorTile);
});
});
function mapboxVectorTile(data, cfg) {
const getTileData = (tile) => getVectorTile(tile);
const tilesetOptions = __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_CONFIG), cfg), {
getTileData
});
return {
data: data,
data,
dataArray: [],
tilesetOptions: tilesetOptions,
tilesetOptions,
isTile: true
};
}
}
export {
mapboxVectorTile as default
};

@@ -1,23 +0,48 @@

import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _regeneratorRuntime from "@babel/runtime/regenerator";
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
import { SyncHook } from '@antv/async-hook';
import { bBoxToBounds, extent, lodashUtil, padBounds, TilesetManager } from '@antv/l7-utils';
import { EventEmitter } from 'eventemitter3';
var cloneDeep = lodashUtil.cloneDeep,
isFunction = lodashUtil.isFunction,
isString = lodashUtil.isString,
mergeWith = lodashUtil.mergeWith;
// @ts-ignore
// tslint:disable-next-line:no-submodule-imports
var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/source.ts
import { SyncHook } from "@antv/async-hook";
import {
bBoxToBounds,
extent,
lodashUtil,
padBounds,
TilesetManager
} from "@antv/l7-utils";
import { EventEmitter } from "eventemitter3";
import { getParser, getTransform } from "./factory";

@@ -27,2 +52,3 @@ import { cluster } from "./transform/cluster";

import { getColumn } from "./utils/util";
var { cloneDeep, isFunction, isString, mergeWith } = lodashUtil;
function mergeCustomizer(objValue, srcValue) {

@@ -33,24 +59,16 @@ if (Array.isArray(srcValue)) {

}
//
var Source = /*#__PURE__*/function (_EventEmitter) {
_inherits(Source, _EventEmitter);
var _super = _createSuper(Source);
function Source(data, cfg) {
var _this;
_classCallCheck(this, Source);
_this = _super.call(this);
// this.rawData = cloneDeep(data);
_defineProperty(_assertThisInitialized(_this), "type", 'source');
_defineProperty(_assertThisInitialized(_this), "isTile", false);
_defineProperty(_assertThisInitialized(_this), "inited", false);
var Source = class extends EventEmitter {
constructor(data, cfg) {
super();
this.type = "source";
this.isTile = false;
this.inited = false;
// 生命周期钩子
_defineProperty(_assertThisInitialized(_this), "hooks", {
this.hooks = {
init: new SyncHook()
});
_defineProperty(_assertThisInitialized(_this), "parser", {
type: 'geojson'
});
_defineProperty(_assertThisInitialized(_this), "transforms", []);
_defineProperty(_assertThisInitialized(_this), "cluster", false);
_defineProperty(_assertThisInitialized(_this), "clusterOptions", {
};
this.parser = { type: "geojson" };
this.transforms = [];
this.cluster = false;
this.clusterOptions = {
enable: false,

@@ -60,356 +78,260 @@ radius: 40,

zoom: -99,
method: 'count'
});
method: "count"
};
// 是否有效范围
_defineProperty(_assertThisInitialized(_this), "invalidExtent", false);
_defineProperty(_assertThisInitialized(_this), "dataArrayChanged", false);
_defineProperty(_assertThisInitialized(_this), "cfg", {
this.invalidExtent = false;
this.dataArrayChanged = false;
this.cfg = {
autoRender: true
});
_this.originData = data;
_this.initCfg(cfg);
_this.init().then(function () {
_this.inited = true;
_this.emit('update', {
type: 'inited'
};
this.originData = data;
this.initCfg(cfg);
this.init().then(() => {
this.inited = true;
this.emit("update", {
type: "inited"
});
});
return _this;
}
_createClass(Source, [{
key: "getSourceCfg",
value: function getSourceCfg() {
return this.cfg;
}
}, {
key: "getClusters",
value: function getClusters(zoom) {
return this.clusterIndex.getClusters(this.caculClusterExtent(2), zoom);
}
}, {
key: "getClustersLeaves",
value: function getClustersLeaves(id) {
return this.clusterIndex.getLeaves(id, Infinity);
}
}, {
key: "getParserType",
value: function getParserType() {
return this.parser.type;
}
}, {
key: "updateClusterData",
value: function updateClusterData(zoom) {
var _this2 = this;
var _this$clusterOptions = this.clusterOptions,
_this$clusterOptions$ = _this$clusterOptions.method,
method = _this$clusterOptions$ === void 0 ? 'sum' : _this$clusterOptions$,
field = _this$clusterOptions.field;
var data = this.clusterIndex.getClusters(this.caculClusterExtent(2), Math.floor(zoom));
this.clusterOptions.zoom = zoom;
data.forEach(function (p) {
if (!p.id) {
p.properties.point_count = 1;
getSourceCfg() {
return this.cfg;
}
getClusters(zoom) {
return this.clusterIndex.getClusters(this.caculClusterExtent(2), zoom);
}
getClustersLeaves(id) {
return this.clusterIndex.getLeaves(id, Infinity);
}
getParserType() {
return this.parser.type;
}
updateClusterData(zoom) {
const { method = "sum", field } = this.clusterOptions;
let data = this.clusterIndex.getClusters(
this.caculClusterExtent(2),
Math.floor(zoom)
);
this.clusterOptions.zoom = zoom;
data.forEach((p) => {
if (!p.id) {
p.properties.point_count = 1;
}
});
if (field || isFunction(method)) {
data = data.map((item) => {
const id = item.id;
if (id) {
const points = this.clusterIndex.getLeaves(id, Infinity);
const properties = points.map((d) => d.properties);
let statNum;
if (isString(method) && field) {
const column = getColumn(properties, field);
statNum = statMap[method](column);
}
if (isFunction(method)) {
statNum = method(properties);
}
item.properties.stat = statNum;
} else {
item.properties.point_count = 1;
}
return item;
});
if (field || isFunction(method)) {
data = data.map(function (item) {
var id = item.id;
if (id) {
var points = _this2.clusterIndex.getLeaves(id, Infinity);
var properties = points.map(function (d) {
return d.properties;
});
var statNum;
if (isString(method) && field) {
var column = getColumn(properties, field);
statNum = statMap[method](column);
}
if (isFunction(method)) {
statNum = method(properties);
}
item.properties.stat = statNum;
} else {
item.properties.point_count = 1;
}
return item;
});
}
this.data = getParser('geojson')({
type: 'FeatureCollection',
features: data
});
this.executeTrans();
}
}, {
key: "getFeatureById",
value: function getFeatureById(id) {
var _ref = this.parser,
_ref$type = _ref.type,
type = _ref$type === void 0 ? 'geojson' : _ref$type,
geometry = _ref.geometry;
if (type === 'geojson' && !this.cluster) {
var feature = id < this.originData.features.length ? this.originData.features[id] : 'null';
var newFeature = cloneDeep(feature);
if (newFeature !== null && newFeature !== void 0 && newFeature.properties && (this.transforms.length !== 0 || this.dataArrayChanged)) {
// 如果数据进行了transforms 属性会发生改变 或者数据dataArray发生更新
var item = this.data.dataArray.find(function (dataItem) {
return dataItem._id === id;
});
newFeature.properties = item;
}
return newFeature;
} else if (type === 'json' && geometry) {
return this.data.dataArray.find(function (dataItem) {
this.data = getParser("geojson")({
type: "FeatureCollection",
features: data
});
this.executeTrans();
}
getFeatureById(id) {
const { type = "geojson", geometry } = this.parser;
if (type === "geojson" && !this.cluster) {
const feature = id < this.originData.features.length ? this.originData.features[id] : "null";
const newFeature = cloneDeep(feature);
if ((newFeature == null ? void 0 : newFeature.properties) && (this.transforms.length !== 0 || this.dataArrayChanged)) {
const item = this.data.dataArray.find((dataItem) => {
return dataItem._id === id;
});
} else {
return id < this.data.dataArray.length ? this.data.dataArray[id] : 'null';
newFeature.properties = item;
}
return newFeature;
} else if (type === "json" && geometry) {
return this.data.dataArray.find((dataItem) => dataItem._id === id);
} else {
return id < this.data.dataArray.length ? this.data.dataArray[id] : "null";
}
}, {
key: "updateFeaturePropertiesById",
value: function updateFeaturePropertiesById(id, properties) {
this.data.dataArray = this.data.dataArray.map(function (dataItem) {
}
updateFeaturePropertiesById(id, properties) {
this.data.dataArray = this.data.dataArray.map(
(dataItem) => {
if (dataItem._id === id) {
return _objectSpread(_objectSpread({}, dataItem), properties);
return __spreadValues(__spreadValues({}, dataItem), properties);
}
return dataItem;
}
);
this.dataArrayChanged = true;
this.emit("update", {
type: "update"
});
}
getFeatureId(field, value) {
const feature = this.data.dataArray.find((dataItem) => {
return dataItem[field] === value;
});
return feature == null ? void 0 : feature._id;
}
setData(data, options) {
this.originData = data;
this.dataArrayChanged = false;
this.initCfg(options);
this.init().then(() => {
this.emit("update", {
type: "update"
});
this.dataArrayChanged = true;
this.emit('update', {
type: 'update'
});
}
reloadAllTile() {
var _a;
(_a = this.tileset) == null ? void 0 : _a.reloadAll();
}
reloadTilebyId(z, x, y) {
var _a;
(_a = this.tileset) == null ? void 0 : _a.reloadTileById(z, x, y);
}
reloadTileByLnglat(lng, lat, z) {
var _a;
(_a = this.tileset) == null ? void 0 : _a.reloadTileByLnglat(lng, lat, z);
}
getTileExtent(e, zoom) {
var _a;
return (_a = this.tileset) == null ? void 0 : _a.getTileExtent(e, zoom);
}
getTileByZXY(z, x, y) {
var _a;
return (_a = this.tileset) == null ? void 0 : _a.getTileByZXY(z, x, y);
}
reloadTileByExtent(bounds, z) {
var _a;
(_a = this.tileset) == null ? void 0 : _a.reloadTileByExtent(bounds, z);
}
destroy() {
var _a;
this.removeAllListeners();
this.originData = null;
this.clusterIndex = null;
this.data = null;
(_a = this.tileset) == null ? void 0 : _a.destroy();
}
processData() {
return __async(this, null, function* () {
return new Promise((resolve, reject) => {
try {
this.excuteParser();
this.initCluster();
this.executeTrans();
resolve({});
} catch (err) {
reject(err);
}
});
}
}, {
key: "getFeatureId",
value: function getFeatureId(field, value) {
var feature = this.data.dataArray.find(function (dataItem) {
return dataItem[field] === value;
});
return feature === null || feature === void 0 ? void 0 : feature._id;
}
}, {
key: "setData",
value: function setData(data, options) {
var _this3 = this;
this.originData = data;
this.dataArrayChanged = false;
this.initCfg(options);
this.init().then(function () {
_this3.emit('update', {
type: 'update'
});
});
}
}, {
key: "reloadAllTile",
value: function reloadAllTile() {
var _this$tileset;
(_this$tileset = this.tileset) === null || _this$tileset === void 0 || _this$tileset.reloadAll();
}
}, {
key: "reloadTilebyId",
value: function reloadTilebyId(z, x, y) {
var _this$tileset2;
(_this$tileset2 = this.tileset) === null || _this$tileset2 === void 0 || _this$tileset2.reloadTileById(z, x, y);
}
}, {
key: "reloadTileByLnglat",
value: function reloadTileByLnglat(lng, lat, z) {
var _this$tileset3;
(_this$tileset3 = this.tileset) === null || _this$tileset3 === void 0 || _this$tileset3.reloadTileByLnglat(lng, lat, z);
}
}, {
key: "getTileExtent",
value: function getTileExtent(e, zoom) {
var _this$tileset4;
return (_this$tileset4 = this.tileset) === null || _this$tileset4 === void 0 ? void 0 : _this$tileset4.getTileExtent(e, zoom);
}
}, {
key: "getTileByZXY",
value: function getTileByZXY(z, x, y) {
var _this$tileset5;
return (_this$tileset5 = this.tileset) === null || _this$tileset5 === void 0 ? void 0 : _this$tileset5.getTileByZXY(z, x, y);
}
}, {
key: "reloadTileByExtent",
value: function reloadTileByExtent(bounds, z) {
var _this$tileset6;
(_this$tileset6 = this.tileset) === null || _this$tileset6 === void 0 || _this$tileset6.reloadTileByExtent(bounds, z);
}
}, {
key: "destroy",
value: function destroy() {
var _this$tileset7;
this.removeAllListeners();
this.originData = null;
this.clusterIndex = null;
// @ts-ignore
this.data = null;
(_this$tileset7 = this.tileset) === null || _this$tileset7 === void 0 || _this$tileset7.destroy();
}
}, {
key: "processData",
value: function () {
var _processData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
var _this4 = this;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
return _context.abrupt("return", new Promise(function (resolve, reject) {
try {
_this4.excuteParser();
_this4.initCluster();
_this4.executeTrans();
resolve({});
} catch (err) {
reject(err);
}
}));
case 1:
case "end":
return _context.stop();
}
}, _callee);
}));
function processData() {
return _processData.apply(this, arguments);
});
}
initCfg(option) {
this.cfg = mergeWith(this.cfg, option, mergeCustomizer);
const cfg = this.cfg;
if (cfg) {
if (cfg.parser) {
this.parser = cfg.parser;
}
return processData;
}()
}, {
key: "initCfg",
value: function initCfg(option) {
this.cfg = mergeWith(this.cfg, option, mergeCustomizer);
var cfg = this.cfg;
if (cfg) {
if (cfg.parser) {
this.parser = cfg.parser;
}
if (cfg.transforms) {
this.transforms = cfg.transforms;
}
this.cluster = cfg.cluster || false;
if (cfg.clusterOptions) {
this.cluster = true;
this.clusterOptions = _objectSpread(_objectSpread({}, this.clusterOptions), cfg.clusterOptions);
}
if (cfg.transforms) {
this.transforms = cfg.transforms;
}
}
}, {
key: "init",
value: function () {
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
this.inited = false;
_context2.next = 3;
return this.processData();
case 3:
this.inited = true;
case 4:
case "end":
return _context2.stop();
}
}, _callee2, this);
}));
function init() {
return _init.apply(this, arguments);
this.cluster = cfg.cluster || false;
if (cfg.clusterOptions) {
this.cluster = true;
this.clusterOptions = __spreadValues(__spreadValues({}, this.clusterOptions), cfg.clusterOptions);
}
return init;
}()
/**
* 数据解析
*/
}, {
key: "excuteParser",
value: function excuteParser() {
// 耗时计算测试
var parser = this.parser;
var type = parser.type || 'geojson';
var sourceParser = getParser(type);
this.data = sourceParser(this.originData, parser);
// 为瓦片图层的父图层创建数据瓦片金字塔管理器
this.tileset = this.initTileset();
// 判断当前 source 是否需要计算范围
if (parser.cancelExtent) {
return;
}
// 计算范围
this.extent = extent(this.data.dataArray);
this.setCenter(this.extent);
this.invalidExtent = this.extent[0] === this.extent[2] || this.extent[1] === this.extent[3];
}
}, {
key: "setCenter",
value: function setCenter(bbox) {
this.center = [(bbox[0] + bbox[2]) / 2, (bbox[1] + bbox[3]) / 2];
if (isNaN(this.center[0]) || isNaN(this.center[1])) {
// this.center = [NaN, NaN] // Infinity - Infinity = NaN
// 默认设置为大地原点
this.center = [108.92361111111111, 34.54083333333333];
}
}
init() {
return __async(this, null, function* () {
this.inited = false;
yield this.processData();
this.inited = true;
});
}
/**
* 数据解析
*/
excuteParser() {
const parser = this.parser;
const type = parser.type || "geojson";
const sourceParser = getParser(type);
this.data = sourceParser(this.originData, parser);
this.tileset = this.initTileset();
if (parser.cancelExtent) {
return;
}
/**
* 瓦片数据管理器
*/
}, {
key: "initTileset",
value: function initTileset() {
var tilesetOptions = this.data.tilesetOptions;
if (!tilesetOptions) {
return;
}
this.isTile = true;
if (this.tileset) {
this.tileset.updateOptions(tilesetOptions);
return this.tileset;
}
var tileset = new TilesetManager(_objectSpread({}, tilesetOptions));
return tileset;
this.extent = extent(this.data.dataArray);
this.setCenter(this.extent);
this.invalidExtent = this.extent[0] === this.extent[2] || this.extent[1] === this.extent[3];
}
setCenter(bbox) {
this.center = [(bbox[0] + bbox[2]) / 2, (bbox[1] + bbox[3]) / 2];
if (isNaN(this.center[0]) || isNaN(this.center[1])) {
this.center = [108.92361111111111, 34.54083333333333];
}
/**
* 数据统计
*/
}, {
key: "executeTrans",
value: function executeTrans() {
var _this5 = this;
var trans = this.transforms;
trans.forEach(function (tran) {
var type = tran.type;
var data = getTransform(type)(_this5.data, tran);
Object.assign(_this5.data, data);
});
}
/**
* 瓦片数据管理器
*/
initTileset() {
const { tilesetOptions } = this.data;
if (!tilesetOptions) {
return;
}
/**
* 数据聚合
*/
}, {
key: "initCluster",
value: function initCluster() {
if (!this.cluster) {
return;
}
var clusterOptions = this.clusterOptions || {};
this.clusterIndex = cluster(this.data, clusterOptions);
this.isTile = true;
if (this.tileset) {
this.tileset.updateOptions(tilesetOptions);
return this.tileset;
}
}, {
key: "caculClusterExtent",
value: function caculClusterExtent(bufferRatio) {
var newBounds = [[-Infinity, -Infinity], [Infinity, Infinity]];
if (!this.invalidExtent) {
newBounds = padBounds(bBoxToBounds(this.extent), bufferRatio);
}
return newBounds[0].concat(newBounds[1]);
const tileset = new TilesetManager(__spreadValues({}, tilesetOptions));
return tileset;
}
/**
* 数据统计
*/
executeTrans() {
const trans = this.transforms;
trans.forEach((tran) => {
const { type } = tran;
const data = getTransform(type)(this.data, tran);
Object.assign(this.data, data);
});
}
/**
* 数据聚合
*/
initCluster() {
if (!this.cluster) {
return;
}
}]);
return Source;
}(EventEmitter);
export { Source as default };
const clusterOptions = this.clusterOptions || {};
this.clusterIndex = cluster(this.data, clusterOptions);
}
caculClusterExtent(bufferRatio) {
let newBounds = [
[-Infinity, -Infinity],
[Infinity, Infinity]
];
if (!this.invalidExtent) {
newBounds = padBounds(bBoxToBounds(this.extent), bufferRatio);
}
return newBounds[0].concat(newBounds[1]);
}
};
export {
Source as default
};

@@ -1,9 +0,11 @@

import _createClass from "@babel/runtime/helpers/esm/createClass";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
var BaseSource = /*#__PURE__*/_createClass(function BaseSource(data, x, y, z) {
_classCallCheck(this, BaseSource);
this.x = x;
this.y = y;
this.z = z;
});
export { BaseSource as default };
// src/source/baseSource.ts
var BaseSource = class {
constructor(data, x, y, z) {
this.x = x;
this.y = y;
this.z = z;
}
};
export {
BaseSource as default
};

@@ -1,8 +0,5 @@

import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
var VectorSource = /*#__PURE__*/function () {
function VectorSource(vector, x, y, z) {
_classCallCheck(this, VectorSource);
_defineProperty(this, "vectorLayerCache", {});
// src/source/geojsonvt.ts
var VectorSource = class {
constructor(vector, x, y, z) {
this.vectorLayerCache = {};
this.x = x;

@@ -13,23 +10,18 @@ this.y = y;

}
_createClass(VectorSource, [{
key: "getTileData",
value: function getTileData(sourceLayer) {
if (!sourceLayer || !this.vectorTile.layers[sourceLayer]) {
return [];
}
// 优先走缓存
if (this.vectorLayerCache[sourceLayer]) {
return this.vectorLayerCache[sourceLayer];
}
var vectorTile = this.vectorTile.layers[sourceLayer];
return vectorTile.features;
getTileData(sourceLayer) {
if (!sourceLayer || !this.vectorTile.layers[sourceLayer]) {
return [];
}
}, {
key: "getFeatureById",
value: function getFeatureById() {
throw new Error('Method not implemented.');
if (this.vectorLayerCache[sourceLayer]) {
return this.vectorLayerCache[sourceLayer];
}
}]);
return VectorSource;
}();
export { VectorSource as default };
const vectorTile = this.vectorTile.layers[sourceLayer];
return vectorTile.features;
}
getFeatureById() {
throw new Error("Method not implemented.");
}
};
export {
VectorSource as default
};

@@ -0,2 +1,6 @@

// src/source/index.ts
export * from "../interface";
export { default as VectorSource } from "./vector";
import { default as default2 } from "./vector";
export {
default2 as VectorSource
};

@@ -1,11 +0,27 @@

import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { VectorTile } from '@mapbox/vector-tile';
import Protobuf from 'pbf';
var VectorSource = /*#__PURE__*/function () {
function VectorSource(data, x, y, z) {
_classCallCheck(this, VectorSource);
_defineProperty(this, "vectorLayerCache", {});
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
// src/source/vector.ts
import { VectorTile } from "@mapbox/vector-tile";
import Protobuf from "pbf";
var VectorSource = class {
constructor(data, x, y, z) {
this.vectorLayerCache = {};
this.x = x;

@@ -16,43 +32,33 @@ this.y = y;

}
_createClass(VectorSource, [{
key: "getTileData",
value: function getTileData(sourceLayer) {
if (!sourceLayer || !this.vectorTile.layers[sourceLayer]) {
return [];
}
// 优先走缓存
if (this.vectorLayerCache[sourceLayer]) {
return this.vectorLayerCache[sourceLayer];
}
var vectorTile = this.vectorTile.layers[sourceLayer];
// @ts-ignore
if (Array.isArray(vectorTile.features)) {
// 数据不需要被解析 geojson-vt 类型
// @ts-ignore
this.vectorLayerCache[sourceLayer] = vectorTile.features;
// @ts-ignore
return vectorTile.features;
}
var features = [];
for (var i = 0; i < vectorTile.length; i++) {
var vectorTileFeature = vectorTile.feature(i);
var feature = vectorTileFeature.toGeoJSON(this.x, this.y, this.z);
features.push(_objectSpread(_objectSpread({}, feature), {}, {
properties: _objectSpread({
id: feature.id
}, feature.properties)
}));
}
this.vectorLayerCache[sourceLayer] = features;
return features;
getTileData(sourceLayer) {
if (!sourceLayer || !this.vectorTile.layers[sourceLayer]) {
return [];
}
}, {
key: "getFeatureById",
value: function getFeatureById() {
throw new Error('Method not implemented.');
if (this.vectorLayerCache[sourceLayer]) {
return this.vectorLayerCache[sourceLayer];
}
}]);
return VectorSource;
}();
export { VectorSource as default };
const vectorTile = this.vectorTile.layers[sourceLayer];
if (Array.isArray(vectorTile.features)) {
this.vectorLayerCache[sourceLayer] = vectorTile.features;
return vectorTile.features;
}
const features = [];
for (let i = 0; i < vectorTile.length; i++) {
const vectorTileFeature = vectorTile.feature(i);
const feature = vectorTileFeature.toGeoJSON(this.x, this.y, this.z);
features.push(__spreadProps(__spreadValues({}, feature), {
properties: __spreadValues({
id: feature.id
}, feature.properties)
}));
}
this.vectorLayerCache[sourceLayer] = features;
return features;
}
getFeatureById() {
throw new Error("Method not implemented.");
}
};
export {
VectorSource as default
};

@@ -1,36 +0,47 @@

import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
// @ts-ignore
// tslint:disable-next-line:no-submodule-imports
import Supercluster from 'supercluster/dist/supercluster';
export function cluster(data, option) {
var _option$radius = option.radius,
radius = _option$radius === void 0 ? 40 : _option$radius,
_option$maxZoom = option.maxZoom,
maxZoom = _option$maxZoom === void 0 ? 18 : _option$maxZoom,
_option$minZoom = option.minZoom,
minZoom = _option$minZoom === void 0 ? 0 : _option$minZoom,
_option$zoom = option.zoom,
zoom = _option$zoom === void 0 ? 2 : _option$zoom;
var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
// src/transform/cluster.ts
import Supercluster from "supercluster/dist/supercluster";
function cluster(data, option) {
const { radius = 40, maxZoom = 18, minZoom = 0, zoom = 2 } = option;
if (data.pointIndex) {
var clusterData = data.pointIndex.getClusters(data.extent, Math.floor(zoom));
const clusterData = data.pointIndex.getClusters(
data.extent,
Math.floor(zoom)
);
data.dataArray = formatData(clusterData);
return data;
}
var pointIndex = new Supercluster({
radius: radius,
minZoom: minZoom,
maxZoom: maxZoom
const pointIndex = new Supercluster({
radius,
minZoom,
maxZoom
});
var geojson = {
type: 'FeatureCollection',
const geojson = {
type: "FeatureCollection",
features: []
};
geojson.features = data.dataArray.map(function (item) {
geojson.features = data.dataArray.map((item) => {
return {
type: 'Feature',
type: "Feature",
geometry: {
type: 'Point',
type: "Point",
coordinates: item.coordinates
},
properties: _objectSpread({}, item)
properties: __spreadValues({}, item)
};

@@ -41,5 +52,5 @@ });

}
export function formatData(clusterPoint) {
return clusterPoint.map(function (point, index) {
return _objectSpread({
function formatData(clusterPoint) {
return clusterPoint.map((point, index) => {
return __spreadValues({
coordinates: point.geometry.coordinates,

@@ -49,2 +60,6 @@ _id: index + 1

});
}
}
export {
cluster,
formatData
};

@@ -1,3 +0,4 @@

export function filter(data, options) {
var callback = options.callback;
// src/transform/filter.ts
function filter(data, options) {
const { callback } = options;
if (callback) {

@@ -7,2 +8,5 @@ data.dataArray = data.dataArray.filter(callback);

return data;
}
}
export {
filter
};

@@ -1,19 +0,10 @@

function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
/**
* 生成四边形热力图
*/
import { aProjectFlat, Satistics } from '@antv/l7-utils';
var R_EARTH = 6378000;
export function aggregatorToGrid(data, option) {
var dataArray = data.dataArray;
var _option$size = option.size,
size = _option$size === void 0 ? 10 : _option$size;
var pixlSize = size / (2 * Math.PI * R_EARTH) * (256 << 20) / 2;
var _pointsGridHash2 = _pointsGridHash(dataArray, size),
gridHash = _pointsGridHash2.gridHash,
gridOffset = _pointsGridHash2.gridOffset;
var layerData = _getGridLayerDataFromGridHash(gridHash, gridOffset, option);
// src/transform/grid.ts
import { aProjectFlat, Satistics } from "@antv/l7-utils";
var R_EARTH = 6378e3;
function aggregatorToGrid(data, option) {
const dataArray = data.dataArray;
const { size = 10 } = option;
const pixlSize = size / (2 * Math.PI * R_EARTH) * (256 << 20) / 2;
const { gridHash, gridOffset } = _pointsGridHash(dataArray, size);
const layerData = _getGridLayerDataFromGridHash(gridHash, gridOffset, option);
return {

@@ -23,3 +14,3 @@ yOffset: pixlSize,

radius: pixlSize,
type: 'grid',
type: "grid",
dataArray: layerData

@@ -29,67 +20,36 @@ };

function _pointsGridHash(dataArray, size) {
var latMin = Infinity;
var latMax = -Infinity;
var pLat;
var _iterator = _createForOfIteratorHelper(dataArray),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var point = _step.value;
pLat = point.coordinates[1];
if (Number.isFinite(pLat)) {
latMin = pLat < latMin ? pLat : latMin;
latMax = pLat > latMax ? pLat : latMax;
}
let latMin = Infinity;
let latMax = -Infinity;
let pLat;
for (const point of dataArray) {
pLat = point.coordinates[1];
if (Number.isFinite(pLat)) {
latMin = pLat < latMin ? pLat : latMin;
latMax = pLat > latMax ? pLat : latMax;
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
var centerLat = (latMin + latMax) / 2;
var gridOffset = _calculateGridLatLonOffset(size, centerLat);
const centerLat = (latMin + latMax) / 2;
const gridOffset = _calculateGridLatLonOffset(size, centerLat);
if (gridOffset.xOffset <= 0 || gridOffset.yOffset <= 0) {
return {
gridHash: {},
gridOffset: gridOffset
};
return { gridHash: {}, gridOffset };
}
var gridHash = {};
var _iterator2 = _createForOfIteratorHelper(dataArray),
_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var _point = _step2.value;
var lat = _point.coordinates[1];
var lng = _point.coordinates[0];
if (Number.isFinite(lat) && Number.isFinite(lng)) {
var latIdx = Math.floor((lat + 90) / gridOffset.yOffset);
var lonIdx = Math.floor((lng + 180) / gridOffset.xOffset);
var _key = "".concat(latIdx, "-").concat(lonIdx);
gridHash[_key] = gridHash[_key] || {
count: 0,
points: []
};
gridHash[_key].count += 1;
gridHash[_key].points.push(_point);
}
const gridHash = {};
for (const point of dataArray) {
const lat = point.coordinates[1];
const lng = point.coordinates[0];
if (Number.isFinite(lat) && Number.isFinite(lng)) {
const latIdx = Math.floor((lat + 90) / gridOffset.yOffset);
const lonIdx = Math.floor((lng + 180) / gridOffset.xOffset);
const key = `${latIdx}-${lonIdx}`;
gridHash[key] = gridHash[key] || { count: 0, points: [] };
gridHash[key].count += 1;
gridHash[key].points.push(point);
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
return {
gridHash: gridHash,
gridOffset: gridOffset
};
return { gridHash, gridOffset };
}
// 计算网格偏移量
function _calculateGridLatLonOffset(cellSize, latitude) {
var yOffset = _calculateLatOffset(cellSize);
var xOffset = _calculateLonOffset(latitude, cellSize);
return {
yOffset: yOffset,
xOffset: xOffset
};
const yOffset = _calculateLatOffset(cellSize);
const xOffset = _calculateLonOffset(latitude, cellSize);
return { yOffset, xOffset };
}

@@ -103,9 +63,9 @@ function _calculateLatOffset(dy) {

function _getGridLayerDataFromGridHash(gridHash, gridOffset, option) {
return Object.keys(gridHash).reduce(function (accu, key, i) {
var idxs = key.split('-');
var latIdx = parseInt(idxs[0], 10);
var lonIdx = parseInt(idxs[1], 10);
var item = {};
return Object.keys(gridHash).reduce((accu, key, i) => {
const idxs = key.split("-");
const latIdx = parseInt(idxs[0], 10);
const lonIdx = parseInt(idxs[1], 10);
const item = {};
if (option.field && option.method) {
var columns = Satistics.getColumn(gridHash[key].points, option.field);
const columns = Satistics.getColumn(gridHash[key].points, option.field);
item[option.method] = Satistics.statMap[option.method](columns);

@@ -115,10 +75,15 @@ }

_id: i,
coordinates: aProjectFlat([-180 + gridOffset.xOffset * (lonIdx + 0.5), -90 + gridOffset.yOffset * (latIdx + 0.5)]),
coordinates: aProjectFlat([
-180 + gridOffset.xOffset * (lonIdx + 0.5),
-90 + gridOffset.yOffset * (latIdx + 0.5)
]),
rawData: gridHash[key].points,
count: gridHash[key].count
});
// @ts-ignore
accu.push(item);
return accu;
}, []);
}
}
export {
aggregatorToGrid
};

@@ -1,36 +0,50 @@

import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import { aProjectFlat, Satistics } from '@antv/l7-utils';
import { hexbin } from 'd3-hexbin';
var R_EARTH = 6378000;
export function pointToHexbin(data, option) {
var dataArray = data.dataArray;
var _option$size = option.size,
size = _option$size === void 0 ? 10 : _option$size,
_option$method = option.method,
method = _option$method === void 0 ? 'sum' : _option$method;
var pixlSize = size / (2 * Math.PI * R_EARTH) * (256 << 20) / 2;
var screenPoints = dataArray.map(function (point) {
var _aProjectFlat = aProjectFlat(point.coordinates),
_aProjectFlat2 = _slicedToArray(_aProjectFlat, 2),
x = _aProjectFlat2[0],
y = _aProjectFlat2[1];
return _objectSpread(_objectSpread({}, point), {}, {
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
// src/transform/hexagon.ts
import { aProjectFlat, Satistics } from "@antv/l7-utils";
import { hexbin } from "d3-hexbin";
var R_EARTH = 6378e3;
function pointToHexbin(data, option) {
const dataArray = data.dataArray;
const { size = 10, method = "sum" } = option;
const pixlSize = size / (2 * Math.PI * R_EARTH) * (256 << 20) / 2;
const screenPoints = dataArray.map((point) => {
const [x, y] = aProjectFlat(point.coordinates);
return __spreadProps(__spreadValues({}, point), {
coordinates: [x, y]
});
});
var newHexbin = hexbin().radius(pixlSize).x(function (d) {
return d.coordinates[0];
}).y(function (d) {
return d.coordinates[1];
});
var hexbinBins = newHexbin(screenPoints);
var result = {
dataArray: hexbinBins.map(function (hex, index) {
const newHexbin = hexbin().radius(pixlSize).x((d) => d.coordinates[0]).y((d) => d.coordinates[1]);
const hexbinBins = newHexbin(screenPoints);
const result = {
dataArray: hexbinBins.map((hex, index) => {
if (option.field && method) {
var columns = Satistics.getColumn(hex, option.field);
const columns = Satistics.getColumn(hex, option.field);
hex[method] = Satistics.statMap[method](columns);
}
return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, option.method, hex[method]), "count", hex.length), "rawData", hex), "coordinates", [hex.x, hex.y]), "_id", index);
return {
[option.method]: hex[method],
count: hex.length,
rawData: hex,
coordinates: [hex.x, hex.y],
_id: index
};
}),

@@ -40,5 +54,8 @@ radius: pixlSize,

yOffset: pixlSize,
type: 'hexagon'
type: "hexagon"
};
return result;
}
}
export {
pointToHexbin
};

@@ -1,21 +0,33 @@

import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
/**
*
* @param data
* @param options
*/
export function join(geoData, options) {
var sourceField = options.sourceField,
targetField = options.targetField,
data = options.data;
var dataObj = {};
data.forEach(function (element) {
// 属性数据
var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
// src/transform/join.ts
function join(geoData, options) {
const { sourceField, targetField, data } = options;
const dataObj = {};
data.forEach((element) => {
dataObj[element[sourceField]] = element;
});
geoData.dataArray = geoData.dataArray.map(function (item) {
var joinName = item[targetField];
return _objectSpread(_objectSpread({}, item), dataObj[joinName]);
geoData.dataArray = geoData.dataArray.map((item) => {
const joinName = item[targetField];
return __spreadValues(__spreadValues({}, item), dataObj[joinName]);
});
return geoData;
}
}
export {
join
};

@@ -1,3 +0,4 @@

export function map(data, options) {
var callback = options.callback;
// src/transform/map.ts
function map(data, options) {
const { callback } = options;
if (callback) {

@@ -7,2 +8,5 @@ data.dataArray = data.dataArray.map(callback);

return data;
}
}
export {
map
};

@@ -1,107 +0,94 @@

import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _typeof from "@babel/runtime/helpers/esm/typeof";
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import _regeneratorRuntime from "@babel/runtime/regenerator";
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/utils/bandOperation/bands.ts
import { calculate } from "./math";
import { operationsSchema } from "./operationSchema";
/**
* 执行波段计算 format + operation
* @param imageDataList
* @param rasterFormat
* @param operation
* @returns
*/
export function bandsOperation(_x, _x2, _x3) {
return _bandsOperation.apply(this, arguments);
function bandsOperation(imageDataList, rasterFormat, operation) {
return __async(this, null, function* () {
if (imageDataList.length === 0) {
return {
rasterData: [0],
width: 1,
heigh: 1
};
}
const formatData = yield Promise.all(
imageDataList.map(({ data, bands = [0] }) => rasterFormat(data, bands))
);
const bandsData = [];
formatData.forEach((d) => {
Array.isArray(d) ? bandsData.push(...d) : bandsData.push(d);
});
const { width, height } = bandsData[0];
let rasterData;
switch (typeof operation) {
case "function":
rasterData = operation(bandsData);
break;
case "object":
if (!Array.isArray(operation)) {
rasterData = processSchemaOperation(
operation,
bandsData
);
} else {
rasterData = { rasterData: calculate(operation, bandsData) };
}
break;
default:
rasterData = { rasterData: bandsData[0].rasterData };
}
return __spreadProps(__spreadValues({}, rasterData), {
width,
height
});
});
}
function _bandsOperation() {
_bandsOperation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(imageDataList, rasterFormat, operation) {
var formatData, bandsData, _bandsData$, width, height, rasterData;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
if (!(imageDataList.length === 0)) {
_context.next = 2;
break;
}
return _context.abrupt("return", {
rasterData: [0],
width: 1,
heigh: 1
});
case 2:
_context.next = 4;
return Promise.all(imageDataList.map(function (_ref) {
var data = _ref.data,
_ref$bands = _ref.bands,
bands = _ref$bands === void 0 ? [0] : _ref$bands;
return rasterFormat(data, bands);
}));
case 4:
formatData = _context.sent;
bandsData = []; // Tip: rasterFormat 返回值 rasterData|rasterData[]
formatData.forEach(function (d) {
Array.isArray(d) ? bandsData.push.apply(bandsData, _toConsumableArray(d)) : bandsData.push(d);
});
// 多个栅格数据必须是相同大小才能进行相互之间的运算
_bandsData$ = bandsData[0], width = _bandsData$.width, height = _bandsData$.height;
_context.t0 = _typeof(operation);
_context.next = _context.t0 === 'function' ? 11 : _context.t0 === 'object' ? 13 : 15;
break;
case 11:
rasterData = operation(bandsData);
return _context.abrupt("break", 16);
case 13:
// 波段计算表达式 - operation
// operation: ['+', ['band', 0], 1]
/**
* operation: {
* r: ['+', ['band', 0], 1],
* g: ['+', ['band', 0], 1],
* b: ['+', ['band', 0], 1],
* }
*/
if (!Array.isArray(operation)) {
// RGB 三通道
rasterData = processSchemaOperation(operation, bandsData);
} else {
// 数值计算
rasterData = {
rasterData: calculate(operation, bandsData)
};
}
return _context.abrupt("break", 16);
case 15:
rasterData = {
rasterData: bandsData[0].rasterData
};
case 16:
return _context.abrupt("return", _objectSpread(_objectSpread({}, rasterData), {}, {
width: width,
height: height
}));
case 17:
case "end":
return _context.stop();
}
}, _callee);
}));
return _bandsOperation.apply(this, arguments);
}
function processSchemaOperation(operation, bandsData) {
var schema = operationsSchema[operation.type];
if (schema.type === 'function') {
// @ts-ignore
return schema.method(bandsData, operation === null || operation === void 0 ? void 0 : operation.options);
} else if (schema.type === 'operation') {
if (operation.type === 'rgb') {
// TODO 临时处理
// @ts-ignore
const schema = operationsSchema[operation.type];
if (schema.type === "function") {
return schema.method(bandsData, operation == null ? void 0 : operation.options);
} else if (schema.type === "operation") {
if (operation.type === "rgb") {
return getRgbBands(schema.expression, bandsData);
} else {
// @ts-ignore
return {
rasterData: calculate(schema.expression, bandsData)
};
return { rasterData: calculate(schema.expression, bandsData) };
}

@@ -111,45 +98,25 @@ }

function getRgbBands(operation, bandsData) {
if (operation.r === undefined) {
console.warn('Channel R lost in Operation! Use band[0] to fill!');
if (operation.r === void 0) {
console.warn("Channel R lost in Operation! Use band[0] to fill!");
}
if (operation.g === undefined) {
console.warn('Channel G lost in Operation! Use band[0] to fill!');
if (operation.g === void 0) {
console.warn("Channel G lost in Operation! Use band[0] to fill!");
}
if (operation.b === undefined) {
console.warn('Channel B lost in Operation! Use band[0] to fill!');
if (operation.b === void 0) {
console.warn("Channel B lost in Operation! Use band[0] to fill!");
}
var r = calculate(operation.r || ['band', 0], bandsData);
var g = calculate(operation.g || ['band', 0], bandsData);
var b = calculate(operation.b || ['band', 0], bandsData);
const r = calculate(operation.r || ["band", 0], bandsData);
const g = calculate(operation.g || ["band", 0], bandsData);
const b = calculate(operation.b || ["band", 0], bandsData);
return [r, g, b];
}
/**
* 处理每个请求得到的栅格文件数据
*/
export function processRasterData(_x4, _x5, _x6, _x7) {
return _processRasterData.apply(this, arguments);
function processRasterData(rasterFiles, rasterFormat, operation, callback) {
return __async(this, null, function* () {
const rasterData = yield bandsOperation(rasterFiles, rasterFormat, operation);
callback(null, { data: rasterData });
});
}
function _processRasterData() {
_processRasterData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(rasterFiles, rasterFormat, operation, callback) {
var rasterData;
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return bandsOperation(rasterFiles, rasterFormat, operation);
case 2:
rasterData = _context2.sent;
// 目前 max|min 没有生效
callback(null, {
data: rasterData
});
case 4:
case "end":
return _context2.stop();
}
}, _callee2);
}));
return _processRasterData.apply(this, arguments);
}
export {
bandsOperation,
processRasterData
};

@@ -1,86 +0,56 @@

import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
// tslint:disable-next-line: jsdoc-format
/** 数学运算 根据计算表达式进行数学运算
* * * Math operators:
* `['*', value1, value2]`
* `['/', value1, value2]`
* `['+', value1, value2]`
* `['-', value1, value2]`
* `['%', value1, value2]`
* `['^', value1, value2]`
* `['abs', value1]`
* `['floor', value1]`
* `['round', value1]`
* `['ceil', value1]`
* `['sin', value1]`
* `['cos', value1]`
* `['atan', value1, value2]`
*/
export function mathematical(symbol, n1, n2) {
// src/utils/bandOperation/math.ts
function mathematical(symbol, n1, n2) {
switch (symbol) {
case '+':
case "+":
return n1 + n2;
case '-':
case "-":
return n1 - n2;
case '*':
case "*":
return n1 * n2;
case '/':
case "/":
return n1 / n2;
case '%':
case "%":
return n1 % n2;
case '^':
case "^":
return Math.pow(n1, n2);
case 'abs':
case "abs":
return Math.abs(n1);
case 'floor':
case "floor":
return Math.floor(n1);
case 'round':
case "round":
return Math.round(n1);
case 'ceil':
case "ceil":
return Math.ceil(n1);
case 'sin':
case "sin":
return Math.sin(n1);
case 'cos':
case "cos":
return Math.cos(n1);
case 'atan':
case "atan":
return n2 === -1 ? Math.atan(n1) : Math.atan2(n1, n2);
case 'min':
case "min":
return Math.min(n1, n2);
case 'max':
case "max":
return Math.max(n1, n2);
case 'log10':
case "log10":
return Math.log(n1);
case 'log2':
case "log2":
return Math.log2(n1);
default:
console.warn('Calculate symbol err! Return default 0');
console.warn("Calculate symbol err! Return default 0");
return 0;
}
}
/**
* 根据表达式计算
* @param express
* @param bandsData
*/
export function calculate(express, bandsData) {
var _bandsData$ = bandsData[0],
width = _bandsData$.width,
height = _bandsData$.height;
var dataArray = bandsData.map(function (band) {
return band.rasterData;
});
var length = width * height;
var rasterData = [];
var originExp = JSON.stringify(express);
for (var i = 0; i < length; i++) {
var exp = JSON.parse(originExp);
// 将表达式中的 ['band', 0]、['band', 1] 等替换为实际的栅格数据
var expResult = spellExpress(exp, dataArray, i);
if (typeof expResult === 'number') {
// exp: ['band', 0] => exp: 2 ...
// exp 直接指定了波段值,替换完后直接就是数值了,无需计算
function calculate(express, bandsData) {
const { width, height } = bandsData[0];
const dataArray = bandsData.map((band) => band.rasterData);
const length = width * height;
const rasterData = [];
const originExp = JSON.stringify(express);
for (let i = 0; i < length; i++) {
const exp = JSON.parse(originExp);
const expResult = spellExpress(exp, dataArray, i);
if (typeof expResult === "number") {
rasterData.push(expResult);
} else {
var result = calculateExpress(exp);
const result = calculateExpress(exp);
rasterData.push(result);

@@ -91,28 +61,19 @@ }

}
/**
* 将表达式中的指定波段替换为对应波段的栅格数据
* @param express
* @param dataArray
* @param index
*/
export function spellExpress(express, dataArray, index) {
/**
* 用户直接指定波段数值,无需计算
*/
if (express.length === 2 && express[0] === 'band' && typeof express[1] === 'number') {
function spellExpress(express, dataArray, index) {
if (express.length === 2 && express[0] === "band" && typeof express[1] === "number") {
try {
return dataArray[express[1]][index];
} catch (err) {
console.warn('Raster Data err!');
console.warn("Raster Data err!");
return 0;
}
}
express.map(function (e, i) {
express.map((e, i) => {
if (Array.isArray(e) && e.length > 0) {
switch (e[0]) {
case 'band':
case "band":
try {
express[i] = dataArray[e[1]][index];
} catch (err) {
console.warn('Raster Data err!');
console.warn("Raster Data err!");
express[i] = 0;

@@ -127,21 +88,16 @@ }

}
export function formatExpress(express) {
var _express = _slicedToArray(express, 3),
symbol1 = _express[0],
_express$ = _express[1],
symbol2 = _express$ === void 0 ? -1 : _express$,
_express$2 = _express[2],
symbol3 = _express$2 === void 0 ? -1 : _express$2;
if (symbol1 === undefined) {
console.warn('Express err!');
return ['+', 0, 0];
function formatExpress(express) {
const [symbol1, symbol2 = -1, symbol3 = -1] = express;
if (symbol1 === void 0) {
console.warn("Express err!");
return ["+", 0, 0];
}
var symbol = symbol1.replace(/\s+/g, '');
const symbol = symbol1.replace(/\s+/g, "");
return [symbol, symbol2, symbol3];
}
export function calculateExpress(express) {
var formatExp = formatExpress(express);
var str = formatExp[0];
var left = formatExp[1];
var right = formatExp[2];
function calculateExpress(express) {
const formatExp = formatExpress(express);
const str = formatExp[0];
let left = formatExp[1];
let right = formatExp[2];
if (Array.isArray(left)) {

@@ -154,2 +110,9 @@ left = calculateExpress(express[1]);

return mathematical(str, left, right);
}
}
export {
calculate,
calculateExpress,
formatExpress,
mathematical,
spellExpress
};

@@ -1,11 +0,14 @@

import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
export var operationsSchema = {
// src/utils/bandOperation/operationSchema.ts
var operationsSchema = {
nd: {
type: 'operation',
expression: ['/', ['-', ['band', 1], ['band', 0]],
// R > NIR
['+', ['band', 1], ['band', 0]]]
type: "operation",
expression: [
"/",
["-", ["band", 1], ["band", 0]],
// R > NIR
["+", ["band", 1], ["band", 0]]
]
},
rgb: {
type: 'function',
type: "function",
method: strethRgb2minMax

@@ -15,14 +18,11 @@ }

function strethRgb2minMax(bandsData, options) {
var channelR = bandsData[0].rasterData;
var channelG = bandsData[1].rasterData;
var channelB = bandsData[2].rasterData;
var data = [];
var _ref = (options === null || options === void 0 ? void 0 : options.countCut) || [2, 98],
_ref2 = _slicedToArray(_ref, 2),
low = _ref2[0],
high = _ref2[1];
var minMaxR = (options === null || options === void 0 ? void 0 : options.RMinMax) || percentile(channelR, low, high);
var minMaxG = (options === null || options === void 0 ? void 0 : options.GMinMax) || percentile(channelG, low, high);
var minMaxB = (options === null || options === void 0 ? void 0 : options.BMinMax) || percentile(channelB, low, high);
for (var i = 0; i < channelR.length; i++) {
const channelR = bandsData[0].rasterData;
const channelG = bandsData[1].rasterData;
const channelB = bandsData[2].rasterData;
const data = [];
const [low, high] = (options == null ? void 0 : options.countCut) || [2, 98];
const minMaxR = (options == null ? void 0 : options.RMinMax) || percentile(channelR, low, high);
const minMaxG = (options == null ? void 0 : options.GMinMax) || percentile(channelG, low, high);
const minMaxB = (options == null ? void 0 : options.BMinMax) || percentile(channelB, low, high);
for (let i = 0; i < channelR.length; i++) {
data.push(Math.max(0, channelR[i] - minMaxR[0]));

@@ -39,14 +39,12 @@ data.push(Math.max(0, channelG[i] - minMaxG[0]));

}
// https://gis.stackexchange.com/questions/324888/what-does-cumulative-count-cut-actually-do
export function percentile(data, minPercent, maxPercent) {
// 计算效率问题
var sortData = data.slice().sort(function (a, b) {
return a - b;
});
var dataLength = sortData.length;
var min = sortData[Math.ceil(dataLength * minPercent / 100)];
var max = sortData[Math.ceil(dataLength * maxPercent / 100)];
function percentile(data, minPercent, maxPercent) {
const sortData = data.slice().sort((a, b) => a - b);
const dataLength = sortData.length;
const min = sortData[Math.ceil(dataLength * minPercent / 100)];
const max = sortData[Math.ceil(dataLength * maxPercent / 100)];
return [min, max];
}
}
export {
operationsSchema,
percentile
};

@@ -0,9 +1,8 @@

// src/utils/statistics.ts
function max(x) {
if (x.length === 0) {
throw new Error('max requires at least one data point');
throw new Error("max requires at least one data point");
}
var value = x[0];
for (var i = 1; i < x.length; i++) {
// On the first iteration of this loop, max is
// undefined and is thus made the maximum element in the array
let value = x[0];
for (let i = 1; i < x.length; i++) {
if (x[i] > value) {

@@ -17,8 +16,6 @@ value = x[i];

if (x.length === 0) {
throw new Error('min requires at least one data point');
throw new Error("min requires at least one data point");
}
var value = x[0];
for (var i = 1; i < x.length; i++) {
// On the first iteration of this loop, min is
// undefined and is thus made the minimum element in the array
let value = x[0];
for (let i = 1; i < x.length; i++) {
if (x[i] < value) {

@@ -31,18 +28,10 @@ value = x[i];

function sum(x) {
// If the array is empty, we needn't bother computing its sum
if (x.length === 0) {
return 0;
}
// Initializing the sum as the first number in the array
var sumNum = x[0];
// Keeping track of the floating-point error correction
var correction = 0;
var transition;
for (var i = 1; i < x.length; i++) {
let sumNum = x[0];
let correction = 0;
let transition;
for (let i = 1; i < x.length; i++) {
transition = sumNum + x[i] * 1;
// Here we need to update the correction in a different fashion
// if the new absolute value is greater than the absolute sum
if (Math.abs(sumNum) >= Math.abs(x[i])) {

@@ -55,4 +44,2 @@ correction += sumNum - transition + x[i];

}
// Returning the corrected sum
return sumNum + correction * 1;

@@ -62,12 +49,18 @@ }

if (x.length === 0) {
throw new Error('mean requires at least one data point');
throw new Error("mean requires at least one data point");
}
return sum(x) / x.length;
}
export { sum, max, min, mean };
export var statMap = {
min: min,
max: max,
mean: mean,
sum: sum
};
var statMap = {
min,
max,
mean,
sum
};
export {
max,
mean,
min,
statMap,
sum
};

@@ -1,84 +0,88 @@

import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import _regeneratorRuntime from "@babel/runtime/regenerator";
// import { bindCancel } from './request';
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
import { formatImage } from '@antv/l7-utils';
// src/utils/tile/getCustomData.ts
import { formatImage } from "@antv/l7-utils";
import { processRasterData } from "../bandOperation/bands";
export var getCustomData = /*#__PURE__*/function () {
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(tile, getCustomDataFunc, rasterFormat, operation) {
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
return _context.abrupt("return", new Promise(function (resolve, reject) {
getCustomDataFunc({
x: tile.x,
y: tile.y,
z: tile.z
}, function (err, data) {
if (err || data.length === 0) {
reject(err);
return;
var getCustomData = (tile, getCustomDataFunc, rasterFormat, operation) => __async(void 0, null, function* () {
return new Promise((resolve, reject) => {
getCustomDataFunc(
{
x: tile.x,
y: tile.y,
z: tile.z
},
(err, data) => {
if (err || data.length === 0) {
reject(err);
return;
}
if (data) {
processRasterData(
[{ data, bands: [0] }],
rasterFormat,
operation,
(error, img) => {
if (error) {
reject(error);
} else if (img) {
resolve(img);
}
if (data) {
processRasterData([{
data: data,
bands: [0]
}], rasterFormat, operation, function (error, img) {
if (error) {
reject(error);
} else if (img) {
resolve(img);
}
});
}
});
}));
case 1:
case "end":
return _context.stop();
}
);
}
}
}, _callee);
}));
return function getCustomData(_x, _x2, _x3, _x4) {
return _ref.apply(this, arguments);
};
}();
export var getCustomImageData = /*#__PURE__*/function () {
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(tile, getCustomDataFunc) {
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
return _context2.abrupt("return", new Promise(function (resolve, reject) {
getCustomDataFunc({
x: tile.x,
y: tile.y,
z: tile.z
}, function (err, data) {
if (err || !data) {
reject(err);
return;
}
if (data instanceof ArrayBuffer) {
formatImage(data, function (error, image) {
if (error) {
reject(error);
}
resolve(image);
});
} else if (data instanceof HTMLImageElement) {
resolve(data);
} else {
reject(err);
}
});
}));
case 1:
case "end":
return _context2.stop();
);
});
});
var getCustomImageData = (tile, getCustomDataFunc) => __async(void 0, null, function* () {
return new Promise((resolve, reject) => {
getCustomDataFunc(
{
x: tile.x,
y: tile.y,
z: tile.z
},
(err, data) => {
if (err || !data) {
reject(err);
return;
}
if (data instanceof ArrayBuffer) {
formatImage(data, (error, image) => {
if (error) {
reject(error);
}
resolve(image);
});
} else if (data instanceof HTMLImageElement) {
resolve(data);
} else {
reject(err);
}
}
}, _callee2);
}));
return function getCustomImageData(_x5, _x6) {
return _ref2.apply(this, arguments);
};
}();
);
});
});
export {
getCustomData,
getCustomImageData
};

@@ -1,125 +0,106 @@

import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import _regeneratorRuntime from "@babel/runtime/regenerator";
import { getArrayBuffer, makeXMLHttpRequestPromise } from '@antv/l7-utils';
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/utils/tile/getRasterData.ts
import {
getArrayBuffer,
makeXMLHttpRequestPromise
} from "@antv/l7-utils";
import { processRasterData } from "../bandOperation/bands";
import { bindCancel, getTileBandParams } from "./request";
export var getRasterFile = /*#__PURE__*/function () {
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(tile, requestParameters, callback, rasterFormat, operation) {
var tileBandParams, _yield$getMultiArrayB, rasterFiles, xhrList, errList, xhr;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
// Tip: 至少存在一个请求文件的 url,处理得到标准的 ITileBand[] url 路径和 bands 参数
tileBandParams = getTileBandParams(requestParameters.url);
if (!(tileBandParams.length > 1)) {
_context.next = 15;
break;
var getRasterFile = (tile, requestParameters, callback, rasterFormat, operation) => __async(void 0, null, function* () {
const tileBandParams = getTileBandParams(requestParameters.url);
if (tileBandParams.length > 1) {
const { rasterFiles, xhrList, errList } = yield getMultiArrayBuffer(
tileBandParams,
requestParameters
);
bindCancel(tile, xhrList);
if (errList.length > 0) {
callback(errList, null);
return;
}
processRasterData(rasterFiles, rasterFormat, operation, callback);
} else {
const xhr = getArrayBuffer(requestParameters, (err, imgData) => {
if (err) {
callback(err);
} else if (imgData) {
const rasterFiles = [
{
data: imgData,
bands: tileBandParams[0].bands
}
_context.next = 4;
return getMultiArrayBuffer(tileBandParams, requestParameters);
case 4:
_yield$getMultiArrayB = _context.sent;
rasterFiles = _yield$getMultiArrayB.rasterFiles;
xhrList = _yield$getMultiArrayB.xhrList;
errList = _yield$getMultiArrayB.errList;
// 多波段计算
bindCancel(tile, xhrList);
if (!(errList.length > 0)) {
_context.next = 12;
break;
}
callback(errList, null);
return _context.abrupt("return");
case 12:
processRasterData(rasterFiles, rasterFormat, operation, callback);
_context.next = 17;
break;
case 15:
xhr = getArrayBuffer(requestParameters, function (err, imgData) {
if (err) {
callback(err);
} else if (imgData) {
var _rasterFiles = [{
data: imgData,
bands: tileBandParams[0].bands
}];
processRasterData(_rasterFiles, rasterFormat, operation, callback);
}
});
bindCancel(tile, [xhr]);
case 17:
case "end":
return _context.stop();
];
processRasterData(rasterFiles, rasterFormat, operation, callback);
}
}, _callee);
}));
return function getRasterFile(_x, _x2, _x3, _x4, _x5) {
return _ref.apply(this, arguments);
};
}();
/**
* get multi raster files async
* @param tileBandParams
* @param requestParameters
* @returns
*/
function getMultiArrayBuffer(_x6, _x7) {
return _getMultiArrayBuffer.apply(this, arguments);
});
bindCancel(tile, [xhr]);
}
});
function getMultiArrayBuffer(tileBandParams, requestParameters) {
return __async(this, null, function* () {
const rasterFiles = [];
const xhrList = [];
const errList = [];
for (let i = 0; i < tileBandParams.length; i++) {
const tileBandParam = tileBandParams[i];
const params = __spreadProps(__spreadValues({}, requestParameters), {
url: tileBandParam.url
});
const bands = tileBandParam.bands;
const { err, data, xhr } = yield makeXMLHttpRequestPromise(__spreadProps(__spreadValues({}, params), {
type: "arrayBuffer"
}));
if (err) {
errList.push(err);
}
xhrList.push(xhr);
rasterFiles.push({
data,
bands
});
}
return { rasterFiles, xhrList, errList };
});
}
function _getMultiArrayBuffer() {
_getMultiArrayBuffer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(tileBandParams, requestParameters) {
var rasterFiles, xhrList, errList, i, tileBandParam, params, bands, _yield$makeXMLHttpReq, err, data, xhr;
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
rasterFiles = [];
xhrList = [];
errList = []; // tslint:disable-next-line: prefer-for-of
i = 0;
case 4:
if (!(i < tileBandParams.length)) {
_context2.next = 20;
break;
}
tileBandParam = tileBandParams[i];
params = _objectSpread(_objectSpread({}, requestParameters), {}, {
url: tileBandParam.url
});
bands = tileBandParam.bands;
_context2.next = 10;
return makeXMLHttpRequestPromise(_objectSpread(_objectSpread({}, params), {}, {
type: 'arrayBuffer'
}));
case 10:
_yield$makeXMLHttpReq = _context2.sent;
err = _yield$makeXMLHttpReq.err;
data = _yield$makeXMLHttpReq.data;
xhr = _yield$makeXMLHttpReq.xhr;
if (err) {
errList.push(err);
}
xhrList.push(xhr);
rasterFiles.push({
data: data,
bands: bands
});
case 17:
i++;
_context2.next = 4;
break;
case 20:
return _context2.abrupt("return", {
rasterFiles: rasterFiles,
xhrList: xhrList,
errList: errList
});
case 21:
case "end":
return _context2.stop();
}
}, _callee2);
}));
return _getMultiArrayBuffer.apply(this, arguments);
}
export {
getRasterFile
};

@@ -1,95 +0,97 @@

import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import _regeneratorRuntime from "@babel/runtime/regenerator";
import { getImage, getURLFromTemplate, getWMTSURLFromTemplate } from '@antv/l7-utils';
var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/utils/tile/getRasterTile.ts
import {
getImage,
getURLFromTemplate,
getWMTSURLFromTemplate
} from "@antv/l7-utils";
import { getRasterFile } from "./getRasterData";
import { getTileUrl } from "./request";
/**
* 用于获取 raster data 的瓦片,如 tiff、lerc、dem 等
* 支持多文件模式
* @param url
* @param tileParams
* @param tile
* @param rasterFormat
* @returns
*/
export var getTileBuffer = /*#__PURE__*/function () {
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(url, tileParams, tile, rasterFormat, operation) {
var requestParameters;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
requestParameters = {
// getTileUrl 将原始的 url 路径进行转化(多服务器)
url: getTileUrl(url, tileParams)
};
return _context.abrupt("return", new Promise(function (resolve, reject) {
getRasterFile(tile, requestParameters, function (err, img) {
if (err) {
reject(err);
} else if (img) {
resolve(img);
}
}, rasterFormat, operation);
}));
case 2:
case "end":
return _context.stop();
}
}, _callee);
}));
return function getTileBuffer(_x, _x2, _x3, _x4, _x5) {
return _ref.apply(this, arguments);
var getTileBuffer = (url, tileParams, tile, rasterFormat, operation) => __async(void 0, null, function* () {
const requestParameters = {
// getTileUrl 将原始的 url 路径进行转化(多服务器)
url: getTileUrl(url, tileParams)
};
}();
/**
* 获取图片格式的文件 jpg、png 等
* @param url
* @param tileParams
* @param tile
* @returns
*/
export var getTileImage = /*#__PURE__*/function () {
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(url, tileParams, tile, cfg) {
var imageUrl, templateUrl, getWMTSURLFromTemplateNew, getURLFromTemplateNew;
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
// TODO: 后续考虑支持加载多服务
templateUrl = Array.isArray(url) ? url[0] : url;
if (cfg.wmtsOptions) {
getWMTSURLFromTemplateNew = (cfg === null || cfg === void 0 ? void 0 : cfg.getURLFromTemplate) || getWMTSURLFromTemplate;
imageUrl = getWMTSURLFromTemplateNew(templateUrl, _objectSpread(_objectSpread({}, tileParams), cfg.wmtsOptions));
} else {
getURLFromTemplateNew = (cfg === null || cfg === void 0 ? void 0 : cfg.getURLFromTemplate) || getURLFromTemplate;
imageUrl = getURLFromTemplateNew(templateUrl, tileParams);
}
return _context2.abrupt("return", new Promise(function (resolve, reject) {
var _cfg$requestParameter;
var xhr = getImage({
url: imageUrl,
type: (cfg === null || cfg === void 0 || (_cfg$requestParameter = cfg.requestParameters) === null || _cfg$requestParameter === void 0 ? void 0 : _cfg$requestParameter.type) || 'arrayBuffer'
}, function (err, img) {
if (err) {
reject(err);
} else if (img) {
resolve(img);
}
}, cfg.transformResponse);
tile.xhrCancel = function () {
return xhr.cancel();
};
}));
case 3:
case "end":
return _context2.stop();
}
}, _callee2);
}));
return function getTileImage(_x6, _x7, _x8, _x9) {
return _ref2.apply(this, arguments);
};
}();
export var defaultFormat = function defaultFormat() {
return new Promise((resolve, reject) => {
getRasterFile(
tile,
requestParameters,
(err, img) => {
if (err) {
reject(err);
} else if (img) {
resolve(img);
}
},
rasterFormat,
operation
);
});
});
var getTileImage = (url, tileParams, tile, cfg) => __async(void 0, null, function* () {
let imageUrl;
const templateUrl = Array.isArray(url) ? url[0] : url;
if (cfg.wmtsOptions) {
const getWMTSURLFromTemplateNew = (cfg == null ? void 0 : cfg.getURLFromTemplate) || getWMTSURLFromTemplate;
imageUrl = getWMTSURLFromTemplateNew(templateUrl, __spreadValues(__spreadValues({}, tileParams), cfg.wmtsOptions));
} else {
const getURLFromTemplateNew = (cfg == null ? void 0 : cfg.getURLFromTemplate) || getURLFromTemplate;
imageUrl = getURLFromTemplateNew(templateUrl, tileParams);
}
return new Promise((resolve, reject) => {
var _a;
const xhr = getImage(
{
url: imageUrl,
type: ((_a = cfg == null ? void 0 : cfg.requestParameters) == null ? void 0 : _a.type) || "arrayBuffer"
},
(err, img) => {
if (err) {
reject(err);
} else if (img) {
resolve(img);
}
},
cfg.transformResponse
);
tile.xhrCancel = () => xhr.cancel();
});
});
var defaultFormat = () => {
return {

@@ -100,2 +102,7 @@ rasterData: new Uint8Array([0]),

};
};
};
export {
defaultFormat,
getTileBuffer,
getTileImage
};

@@ -1,31 +0,13 @@

import { getURLFromTemplate } from '@antv/l7-utils';
/**
* 根据不同的输入,将对应的 url 路径进行转化
* https://{a-c}.xxx.ccc => https://a.xxx.ccc
* https://{a-c}.xxx.ccc => https://b.xxx.ccc
* https://{a-c}.xxx.ccc => https://c.xxx.ccc
* @param url
* 'https://a.xxx.ccc '
* or
* ['https://a.xxx.ccc', 'https://c.ddd.ccc']
* or
* [
* {
* url: 'https://a.xxx.ccc',
* bands: [0]
* },
* ...
* ]
* @param tileParams
* @returns
*/
export function getTileUrl(url, tileParams) {
// src/utils/tile/request.ts
import {
getURLFromTemplate
} from "@antv/l7-utils";
function getTileUrl(url, tileParams) {
if (Array.isArray(url)) {
if (typeof url[0] === 'string') {
return url.map(function (src) {
return getURLFromTemplate(src, tileParams);
});
if (typeof url[0] === "string") {
return url.map(
(src) => getURLFromTemplate(src, tileParams)
);
} else {
return url.map(function (o) {
return url.map((o) => {
return {

@@ -41,30 +23,12 @@ url: getURLFromTemplate(o.url, tileParams),

}
/**
* 处理 url 中的波段参数,将不同的 url 格式处理成统一格式
* @param urlBandParam
* 'https://a.bb.xxx'
* or
* [
* 'https://a.bb.xxx',
* 'https://a.bb.xxx'
* ]
* or
* [
* {
* url: 'https://a.bb.xxx',
* bands: [0, 1]
* },
* ...
* ]
* @returns
*/
export function getTileBandParams(urlBandParam) {
if (typeof urlBandParam === 'string') {
return [{
url: urlBandParam,
bands: [0]
}];
} else if (typeof urlBandParam[0] === 'string') {
return urlBandParam.map(function (param) {
function getTileBandParams(urlBandParam) {
if (typeof urlBandParam === "string") {
return [
{
url: urlBandParam,
bands: [0]
}
];
} else if (typeof urlBandParam[0] === "string") {
return urlBandParam.map((param) => {
return {

@@ -79,14 +43,13 @@ url: param,

}
/**
* 设置 tile 文件请求的取消函数
* @param tile
* @param xhrList
*/
export function bindCancel(tile, xhrList) {
tile.xhrCancel = function () {
xhrList.map(function (xhr) {
function bindCancel(tile, xhrList) {
tile.xhrCancel = () => {
xhrList.map((xhr) => {
xhr.abort();
});
};
}
}
export {
bindCancel,
getTileBandParams,
getTileUrl
};

@@ -1,14 +0,14 @@

import { lodashUtil } from '@antv/l7-utils';
// @ts-ignore
import rewind from '@mapbox/geojson-rewind';
export function getColumn(data, columnName) {
return data.map(function (item) {
// src/utils/util.ts
import { lodashUtil } from "@antv/l7-utils";
import rewind from "@mapbox/geojson-rewind";
function getColumn(data, columnName) {
return data.map((item) => {
return item[columnName] * 1;
});
}
export function isRasterFileData(data) {
if (data === undefined) {
function isRasterFileData(data) {
if (data === void 0) {
return false;
}
if (!Array.isArray(data) && data.data !== undefined) {
if (!Array.isArray(data) && data.data !== void 0) {
return true;

@@ -19,3 +19,3 @@ } else {

}
export function isRasterFileDataArray(data) {
function isRasterFileDataArray(data) {
if (Array.isArray(data)) {

@@ -34,3 +34,3 @@ if (data.length === 0) {

}
export function isNumberArray(data) {
function isNumberArray(data) {
if (Array.isArray(data)) {

@@ -40,3 +40,3 @@ if (data.length === 0) {

}
if (typeof data[0] === 'number') {
if (typeof data[0] === "number") {
return true;

@@ -49,21 +49,22 @@ } else {

}
/**
* enforce polygon ring winding order for geojson
* https://github.com/mapbox/geojson-rewind
* @param geojson
* @returns geojson
*/
export function geojsonRewind(geojson) {
// rewind 方法会修改原始数据,frozen 的数据,需要深度克隆后才能修改
var data = Object.isFrozen(geojson) ? lodashUtil.cloneDeep(geojson) : geojson;
// 设置地理多边形方向 If clockwise is true, the outer ring is clockwise, otherwise it is counterclockwise.
function geojsonRewind(geojson) {
const data = Object.isFrozen(geojson) ? lodashUtil.cloneDeep(geojson) : geojson;
rewind(data, true);
return data;
}
// raster and image layer extentToCoord
export function extentToCoord(coord, extent) {
return coord ? coord : [[extent[0], extent[3]], [extent[2], extent[3]], [extent[2], extent[1]], [extent[0], extent[1]]];
}
function extentToCoord(coord, extent) {
return coord ? coord : [
[extent[0], extent[3]],
[extent[2], extent[3]],
[extent[2], extent[1]],
[extent[0], extent[1]]
];
}
export {
extentToCoord,
geojsonRewind,
getColumn,
isNumberArray,
isRasterFileData,
isRasterFileDataArray
};
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {

@@ -78,7 +95,6 @@ for (var name in all)

const coord = (0, import_invariant.getCoords)(currentFeature);
const dataItem = {
...currentFeature.properties,
const dataItem = __spreadProps(__spreadValues({}, currentFeature.properties), {
coordinates: coord,
_id: sortedID
};
});
resultData.push(dataItem);

@@ -85,0 +101,0 @@ }

var __create = Object.create;
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {

@@ -28,2 +45,22 @@ for (var name in all)

var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};

@@ -148,3 +185,3 @@ // src/parser/geojsonvt.ts

}
var getVectorTile = async (tile, tileIndex, tileParams, extent) => {
var getVectorTile = (tile, tileIndex, tileParams, extent) => __async(void 0, null, function* () {
return new Promise((resolve) => {

@@ -172,3 +209,3 @@ const tileData = tileIndex.getTile(tile.z, tile.x, tile.y);

});
};
});
function getOption(cfg) {

@@ -201,3 +238,3 @@ const defaultOptions = {

} else {
return { ...defaultOptions, ...cfg.geojsonvtOptions };
return __spreadValues(__spreadValues({}, defaultOptions), cfg.geojsonvtOptions);
}

@@ -212,7 +249,5 @@ }

};
const tilesetOptions = {
...DEFAULT_CONFIG,
...cfg,
const tilesetOptions = __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_CONFIG), cfg), {
getTileData
};
});
return {

@@ -219,0 +254,0 @@ data,

var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {

@@ -59,3 +76,3 @@ for (var name in all)

if (typeof url === "string") {
(0, import_l7_utils.getImage)({ ...requestParameters, url }, (err, img) => {
(0, import_l7_utils.getImage)(__spreadProps(__spreadValues({}, requestParameters), { url }), (err, img) => {
if (img) {

@@ -70,3 +87,3 @@ imageDatas.push(img);

url.forEach((item) => {
(0, import_l7_utils.getImage)({ ...requestParameters, url: item }, (err, img) => {
(0, import_l7_utils.getImage)(__spreadProps(__spreadValues({}, requestParameters), { url: item }), (err, img) => {
imageindex++;

@@ -73,0 +90,0 @@ if (img) {

var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {

@@ -45,7 +62,6 @@ for (var name in all)

const coord = (0, import_invariant.getCoords)(currentFeature);
const dataItem = {
...col,
const dataItem = __spreadProps(__spreadValues({}, col), {
_id: index,
coordinates: coord
};
});
resultData.push(dataItem);

@@ -82,7 +98,6 @@ }

}
const dataItem = {
...col,
const dataItem = __spreadProps(__spreadValues({}, col), {
_id: featureIndex,
coordinates: coords
};
});
resultData.push(dataItem);

@@ -89,0 +104,0 @@ }

var __create = Object.create;
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {

@@ -28,2 +45,22 @@ for (var name in all)

var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};

@@ -38,3 +75,3 @@ // src/parser/jsonTile.ts

var import_geojsonvt = __toESM(require("../source/geojsonvt"));
var getVectorTile = async (url, tile, requestParameters, getCustomData) => {
var getVectorTile = (url, tile, requestParameters, getCustomData) => __async(void 0, null, function* () {
const params = { x: tile.x, y: tile.y, z: tile.z };

@@ -61,6 +98,5 @@ const tileUrl = (0, import_l7_utils.getURLFromTemplate)(url, params);

(0, import_l7_utils.getData)(
{
...requestParameters,
__spreadProps(__spreadValues({}, requestParameters), {
url: tileUrl
},
}),
(err, data) => {

@@ -103,3 +139,3 @@ if (err || !data) {

});
};
});
function jsonTile(url, cfg) {

@@ -109,6 +145,5 @@ const getTileData = (_, tile) => {

};
const tilesetOptions = {
...cfg,
const tilesetOptions = __spreadProps(__spreadValues({}, cfg), {
getTileData
};
});
return {

@@ -115,0 +150,0 @@ dataArray: [],

var __create = Object.create;
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {

@@ -28,2 +45,22 @@ for (var name in all)

var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};

@@ -45,3 +82,3 @@ // src/parser/mvt.ts

};
var getVectorTile = async (url, tileParams, tile, requestParameters, getCustomData) => {
var getVectorTile = (url, tileParams, tile, requestParameters, getCustomData) => __async(void 0, null, function* () {
const tileUrl = (0, import_l7_utils.getURLFromTemplate)(url, tileParams);

@@ -67,6 +104,5 @@ return new Promise((resolve) => {

const xhr = (0, import_l7_utils.getArrayBuffer)(
{
...requestParameters,
__spreadProps(__spreadValues({}, requestParameters), {
url: tileUrl
},
}),
(err, data) => {

@@ -84,3 +120,3 @@ if (err || !data) {

});
};
});
function mapboxVectorTile(data, cfg) {

@@ -95,7 +131,5 @@ const url = Array.isArray(data) ? data[0] : data;

);
const tilesetOptions = {
...DEFAULT_CONFIG,
...cfg,
const tilesetOptions = __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_CONFIG), cfg), {
getTileData
};
});
return {

@@ -102,0 +136,0 @@ data: url,

var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {

@@ -87,3 +104,3 @@ for (var name in all)

};
const tilesetOptions = { ...DEFAULT_CONFIG, ...cfg, getTileData };
const tilesetOptions = __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_CONFIG), cfg), { getTileData });
return {

@@ -90,0 +107,0 @@ data,

var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
target[prop] = source[prop];
}
return target;
};
var __export = (target, all) => {

@@ -27,3 +56,3 @@ for (var name in all)

function rasterRgb(data, cfg) {
const { extent = [121.168, 30.2828, 121.384, 30.4219], coordinates, width, height, ...options } = cfg;
const _a = cfg, { extent = [121.168, 30.2828, 121.384, 30.4219], coordinates, width, height } = _a, options = __objRest(_a, ["extent", "coordinates", "width", "height"]);
if (data.length < 2) {

@@ -42,10 +71,10 @@ console.warn("RGB解析需要2个波段的数据");

dataArray: [
{
__spreadProps(__spreadValues({
_id: 1,
data: ndidata,
width,
height,
...options,
height
}, options), {
coordinates: imageCoord
}
})
]

@@ -52,0 +81,0 @@ };

var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
target[prop] = source[prop];
}
return target;
};
var __export = (target, all) => {

@@ -28,3 +57,3 @@ for (var name in all)

function rasterRgb(data, cfg) {
const { extent, coordinates, width, height, ...options } = cfg;
const _a = cfg, { extent, coordinates, width, height } = _a, options = __objRest(_a, ["extent", "coordinates", "width", "height"]);
if (data.length < 3) {

@@ -49,3 +78,3 @@ console.warn("RGB解析需要三个波段的数据");

dataArray: [
{
__spreadProps(__spreadValues({
_id: 1,

@@ -57,6 +86,6 @@ data: rgbdata,

gMinMax: minMaxG,
bMinMax: minMaxB,
...options,
bMinMax: minMaxB
}, options), {
coordinates: imageCoord
}
})
]

@@ -63,0 +92,0 @@ };

var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
target[prop] = source[prop];
}
return target;
};
var __export = (target, all) => {

@@ -28,3 +57,3 @@ for (var name in all)

function rasterRgb(data, cfg) {
const { extent, coordinates, min, max, width, height, format, operation, ...rest } = cfg;
const _a = cfg, { extent, coordinates, min, max, width, height, format, operation } = _a, rest = __objRest(_a, ["extent", "coordinates", "min", "max", "width", "height", "format", "operation"]);
let bandData;

@@ -41,12 +70,12 @@ if (format === void 0 || (0, import_util.isNumberArray)(data)) {

dataArray: [
{
__spreadProps(__spreadValues({
_id: 1,
data: bandData,
width,
height,
...rest,
height
}, rest), {
min,
max,
coordinates: imageCoord
}
})
]

@@ -53,0 +82,0 @@ };

var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {

@@ -18,2 +35,22 @@ for (var name in all)

var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};

@@ -32,3 +69,3 @@ // src/parser/testTile.ts

};
var getVectorTile = async (tile) => {
var getVectorTile = (tile) => __async(void 0, null, function* () {
return new Promise((resolve) => {

@@ -64,10 +101,8 @@ const [minLng, minLat, maxLng, maxLat] = tile.bounds;

});
};
});
function mapboxVectorTile(data, cfg) {
const getTileData = (tile) => getVectorTile(tile);
const tilesetOptions = {
...DEFAULT_CONFIG,
...cfg,
const tilesetOptions = __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_CONFIG), cfg), {
getTileData
};
});
return {

@@ -74,0 +109,0 @@ data,

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __export = (target, all) => {

@@ -18,2 +32,22 @@ for (var name in all)

var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};

@@ -147,6 +181,3 @@ // src/source.ts

if (dataItem._id === id) {
return {
...dataItem,
...properties
};
return __spreadValues(__spreadValues({}, dataItem), properties);
}

@@ -209,12 +240,14 @@ return dataItem;

}
async processData() {
return new Promise((resolve, reject) => {
try {
this.excuteParser();
this.initCluster();
this.executeTrans();
resolve({});
} catch (err) {
reject(err);
}
processData() {
return __async(this, null, function* () {
return new Promise((resolve, reject) => {
try {
this.excuteParser();
this.initCluster();
this.executeTrans();
resolve({});
} catch (err) {
reject(err);
}
});
});

@@ -235,13 +268,12 @@ }

this.cluster = true;
this.clusterOptions = {
...this.clusterOptions,
...cfg.clusterOptions
};
this.clusterOptions = __spreadValues(__spreadValues({}, this.clusterOptions), cfg.clusterOptions);
}
}
}
async init() {
this.inited = false;
await this.processData();
this.inited = true;
init() {
return __async(this, null, function* () {
this.inited = false;
yield this.processData();
this.inited = true;
});
}

@@ -283,5 +315,3 @@ /**

}
const tileset = new import_l7_utils.TilesetManager({
...tilesetOptions
});
const tileset = new import_l7_utils.TilesetManager(__spreadValues({}, tilesetOptions));
return tileset;

@@ -288,0 +318,0 @@ }

var __create = Object.create;
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {

@@ -61,9 +78,7 @@ for (var name in all)

const feature = vectorTileFeature.toGeoJSON(this.x, this.y, this.z);
features.push({
...feature,
properties: {
id: feature.id,
...feature.properties
}
});
features.push(__spreadProps(__spreadValues({}, feature), {
properties: __spreadValues({
id: feature.id
}, feature.properties)
}));
}

@@ -70,0 +85,0 @@ this.vectorLayerCache[sourceLayer] = features;

@@ -5,4 +5,18 @@ var __create = Object.create;

var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __export = (target, all) => {

@@ -64,5 +78,3 @@ for (var name in all)

},
properties: {
...item
}
properties: __spreadValues({}, item)
};

@@ -75,7 +87,6 @@ });

return clusterPoint.map((point, index) => {
return {
return __spreadValues({
coordinates: point.geometry.coordinates,
_id: index + 1,
...point.properties
};
_id: index + 1
}, point.properties);
});

@@ -82,0 +93,0 @@ }

var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {

@@ -34,6 +51,5 @@ for (var name in all)

const [x, y] = (0, import_l7_utils.aProjectFlat)(point.coordinates);
return {
...point,
return __spreadProps(__spreadValues({}, point), {
coordinates: [x, y]
};
});
});

@@ -40,0 +56,0 @@ const newHexbin = (0, import_d3_hexbin.hexbin)().radius(pixlSize).x((d) => d.coordinates[0]).y((d) => d.coordinates[1]);

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __export = (target, all) => {

@@ -33,6 +47,3 @@ for (var name in all)

const joinName = item[targetField];
return {
...item,
...dataObj[joinName]
};
return __spreadValues(__spreadValues({}, item), dataObj[joinName]);
});

@@ -39,0 +50,0 @@ return geoData;

var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {

@@ -18,2 +35,22 @@ for (var name in all)

var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};

@@ -29,41 +66,42 @@ // src/utils/bandOperation/bands.ts

var import_operationSchema = require("./operationSchema");
async function bandsOperation(imageDataList, rasterFormat, operation) {
if (imageDataList.length === 0) {
return {
rasterData: [0],
width: 1,
heigh: 1
};
}
const formatData = await Promise.all(
imageDataList.map(({ data, bands = [0] }) => rasterFormat(data, bands))
);
const bandsData = [];
formatData.forEach((d) => {
Array.isArray(d) ? bandsData.push(...d) : bandsData.push(d);
function bandsOperation(imageDataList, rasterFormat, operation) {
return __async(this, null, function* () {
if (imageDataList.length === 0) {
return {
rasterData: [0],
width: 1,
heigh: 1
};
}
const formatData = yield Promise.all(
imageDataList.map(({ data, bands = [0] }) => rasterFormat(data, bands))
);
const bandsData = [];
formatData.forEach((d) => {
Array.isArray(d) ? bandsData.push(...d) : bandsData.push(d);
});
const { width, height } = bandsData[0];
let rasterData;
switch (typeof operation) {
case "function":
rasterData = operation(bandsData);
break;
case "object":
if (!Array.isArray(operation)) {
rasterData = processSchemaOperation(
operation,
bandsData
);
} else {
rasterData = { rasterData: (0, import_math.calculate)(operation, bandsData) };
}
break;
default:
rasterData = { rasterData: bandsData[0].rasterData };
}
return __spreadProps(__spreadValues({}, rasterData), {
width,
height
});
});
const { width, height } = bandsData[0];
let rasterData;
switch (typeof operation) {
case "function":
rasterData = operation(bandsData);
break;
case "object":
if (!Array.isArray(operation)) {
rasterData = processSchemaOperation(
operation,
bandsData
);
} else {
rasterData = { rasterData: (0, import_math.calculate)(operation, bandsData) };
}
break;
default:
rasterData = { rasterData: bandsData[0].rasterData };
}
return {
...rasterData,
width,
height
};
}

@@ -97,5 +135,7 @@ function processSchemaOperation(operation, bandsData) {

}
async function processRasterData(rasterFiles, rasterFormat, operation, callback) {
const rasterData = await bandsOperation(rasterFiles, rasterFormat, operation);
callback(null, { data: rasterData });
function processRasterData(rasterFiles, rasterFormat, operation, callback) {
return __async(this, null, function* () {
const rasterData = yield bandsOperation(rasterFiles, rasterFormat, operation);
callback(null, { data: rasterData });
});
}

@@ -102,0 +142,0 @@ // Annotate the CommonJS export names for ESM import in node:

@@ -18,2 +18,22 @@ var __defProp = Object.defineProperty;

var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};

@@ -29,3 +49,3 @@ // src/utils/tile/getCustomData.ts

var import_bands = require("../bandOperation/bands");
var getCustomData = async (tile, getCustomDataFunc, rasterFormat, operation) => {
var getCustomData = (tile, getCustomDataFunc, rasterFormat, operation) => __async(void 0, null, function* () {
return new Promise((resolve, reject) => {

@@ -60,4 +80,4 @@ getCustomDataFunc(

});
};
var getCustomImageData = async (tile, getCustomDataFunc) => {
});
var getCustomImageData = (tile, getCustomDataFunc) => __async(void 0, null, function* () {
return new Promise((resolve, reject) => {

@@ -90,3 +110,3 @@ getCustomDataFunc(

});
};
});
// Annotate the CommonJS export names for ESM import in node:

@@ -93,0 +113,0 @@ 0 && (module.exports = {

var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {

@@ -18,2 +35,22 @@ for (var name in all)

var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};

@@ -29,6 +66,6 @@ // src/utils/tile/getRasterData.ts

var import_request = require("./request");
var getRasterFile = async (tile, requestParameters, callback, rasterFormat, operation) => {
var getRasterFile = (tile, requestParameters, callback, rasterFormat, operation) => __async(void 0, null, function* () {
const tileBandParams = (0, import_request.getTileBandParams)(requestParameters.url);
if (tileBandParams.length > 1) {
const { rasterFiles, xhrList, errList } = await getMultiArrayBuffer(
const { rasterFiles, xhrList, errList } = yield getMultiArrayBuffer(
tileBandParams,

@@ -59,28 +96,28 @@ requestParameters

}
};
async function getMultiArrayBuffer(tileBandParams, requestParameters) {
const rasterFiles = [];
const xhrList = [];
const errList = [];
for (let i = 0; i < tileBandParams.length; i++) {
const tileBandParam = tileBandParams[i];
const params = {
...requestParameters,
url: tileBandParam.url
};
const bands = tileBandParam.bands;
const { err, data, xhr } = await (0, import_l7_utils.makeXMLHttpRequestPromise)({
...params,
type: "arrayBuffer"
});
if (err) {
errList.push(err);
});
function getMultiArrayBuffer(tileBandParams, requestParameters) {
return __async(this, null, function* () {
const rasterFiles = [];
const xhrList = [];
const errList = [];
for (let i = 0; i < tileBandParams.length; i++) {
const tileBandParam = tileBandParams[i];
const params = __spreadProps(__spreadValues({}, requestParameters), {
url: tileBandParam.url
});
const bands = tileBandParam.bands;
const { err, data, xhr } = yield (0, import_l7_utils.makeXMLHttpRequestPromise)(__spreadProps(__spreadValues({}, params), {
type: "arrayBuffer"
}));
if (err) {
errList.push(err);
}
xhrList.push(xhr);
rasterFiles.push({
data,
bands
});
}
xhrList.push(xhr);
rasterFiles.push({
data,
bands
});
}
return { rasterFiles, xhrList, errList };
return { rasterFiles, xhrList, errList };
});
}

@@ -87,0 +124,0 @@ // Annotate the CommonJS export names for ESM import in node:

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __export = (target, all) => {

@@ -18,2 +32,22 @@ for (var name in all)

var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};

@@ -31,3 +65,3 @@ // src/utils/tile/getRasterTile.ts

var import_request = require("./request");
var getTileBuffer = async (url, tileParams, tile, rasterFormat, operation) => {
var getTileBuffer = (url, tileParams, tile, rasterFormat, operation) => __async(void 0, null, function* () {
const requestParameters = {

@@ -52,4 +86,4 @@ // getTileUrl 将原始的 url 路径进行转化(多服务器)

});
};
var getTileImage = async (url, tileParams, tile, cfg) => {
});
var getTileImage = (url, tileParams, tile, cfg) => __async(void 0, null, function* () {
let imageUrl;

@@ -59,6 +93,3 @@ const templateUrl = Array.isArray(url) ? url[0] : url;

const getWMTSURLFromTemplateNew = (cfg == null ? void 0 : cfg.getURLFromTemplate) || import_l7_utils.getWMTSURLFromTemplate;
imageUrl = getWMTSURLFromTemplateNew(templateUrl, {
...tileParams,
...cfg.wmtsOptions
});
imageUrl = getWMTSURLFromTemplateNew(templateUrl, __spreadValues(__spreadValues({}, tileParams), cfg.wmtsOptions));
} else {

@@ -86,3 +117,3 @@ const getURLFromTemplateNew = (cfg == null ? void 0 : cfg.getURLFromTemplate) || import_l7_utils.getURLFromTemplate;

});
};
});
var defaultFormat = () => {

@@ -89,0 +120,0 @@ return {

{
"name": "@antv/l7-source",
"version": "2.21.1",
"version": "2.21.2",
"description": "",
"license": "ISC",
"author": "lzxue",
"license": "MIT",
"author": "https://github.com/orgs/antvis/people",
"sideEffects": true,

@@ -13,19 +13,16 @@ "main": "lib/index.js",

"lib",
"es",
"README.md"
"es"
],
"scripts": {
"build": "father build",
"build:cjs": "BABEL_ENV=cjs babel src --root-mode upward --out-dir lib --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments",
"build:esm": "BABEL_ENV=esm babel src --root-mode upward --out-dir es --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments",
"clean": "rimraf dist; rimraf es; rimraf lib;",
"sync": "tnpm sync",
"test": "umi-test --passWithNoTests",
"tsc": "tsc --project tsconfig.build.json",
"watch": "BABEL_ENV=cjs babel src --watch --root-mode upward --out-dir lib --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments"
"dev": "father dev",
"build": "npm run clean && father build",
"check-deps": "father doctor",
"lint": "eslint src __tests__",
"clean": "rimraf dist es lib",
"sync": "tnpm sync"
},
"dependencies": {
"@antv/async-hook": "^2.2.9",
"@antv/l7-core": "2.21.1",
"@antv/l7-utils": "2.21.1",
"@antv/l7-core": "^2.21.2",
"@antv/l7-utils": "^2.21.2",
"@babel/runtime": "^7.7.7",

@@ -55,3 +52,3 @@ "@mapbox/geojson-rewind": "^0.5.2",

},
"gitHead": "1e0d2e5920f479f77095a2c5eddda8a8d7ac9e0f"
"gitHead": "5c2d29d2ac1d631bdecf741cb1725316c0d6f9b9"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc