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

@antv/l7-utils

Package Overview
Dependencies
Maintainers
64
Versions
533
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/l7-utils - npm Package Compare versions

Comparing version 2.17.12 to 2.18.0

es/lodash-adapter.d.ts

2

es/ajax.d.ts

@@ -49,5 +49,5 @@ export declare const getProtocolAction: (url: string) => import("./config").IProtocolHandler;

export declare const getArrayBuffer: (requestParameters: RequestParameters, callback: ResponseCallback<ArrayBuffer>) => Cancelable;
export declare const postData: (requestParameters: RequestParameters, callback: ResponseCallback<string>) => any;
export declare const postData: (requestParameters: RequestParameters, callback: ResponseCallback<string>) => XMLHttpRequest;
export declare function sameOrigin(url: string): boolean;
export declare const getImage: (requestParameters: RequestParameters, callback: ResponseCallback<HTMLImageElement | ImageBitmap | null>, transformResponse?: ((response: object) => any) | undefined) => Cancelable;
export declare const formatImage: (imgData: ArrayBuffer, callback: ResponseCallback<HTMLImageElement | ImageBitmap | null>) => void;

@@ -8,9 +8,5 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";

import _wrapNativeSuper from "@babel/runtime/helpers/esm/wrapNativeSuper";
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 { SceneConifg } from "./config";
import { $window, $XMLHttpRequest } from "./mini-adapter";
export var getProtocolAction = function getProtocolAction(url) {

@@ -21,5 +17,3 @@ return SceneConifg.REGISTERED_PROTOCOLS[url.substring(0, url.indexOf('://'))];

_inherits(AJAXError, _Error);
var _super = _createSuper(AJAXError);
/**

@@ -40,7 +34,6 @@ * The response's HTTP status code.

*/
function AJAXError(status, statusText, url, body) {
var _this;
_classCallCheck(this, AJAXError);
_this = _super.call(this, "AJAXError: ".concat(statusText, " (").concat(status, "): ").concat(url));

@@ -53,15 +46,11 @@ _this.status = status;

}
return _createClass(AJAXError);
}( /*#__PURE__*/_wrapNativeSuper(Error));
function makeXMLHttpRequest(requestParameters, callback) {
var xhr = new $XMLHttpRequest();
var xhr = new XMLHttpRequest();
var url = Array.isArray(requestParameters.url) ? requestParameters.url[0] : requestParameters.url;
xhr.open(requestParameters.method || 'GET', url, true);
if (requestParameters.type === 'arrayBuffer') {
xhr.responseType = 'arraybuffer';
}
for (var k in requestParameters.headers) {

@@ -72,3 +61,2 @@ if (requestParameters.headers.hasOwnProperty(k)) {

}
if (requestParameters.type === 'json') {

@@ -78,13 +66,9 @@ xhr.responseType = 'text';

}
xhr.withCredentials = requestParameters.credentials === 'include';
xhr.onerror = function () {
callback(new Error(xhr.statusText));
};
xhr.onload = function () {
if ((xhr.status >= 200 && xhr.status < 300 || xhr.status === 0) && xhr.response !== null) {
var _data = xhr.response;
if (requestParameters.type === 'json') {

@@ -98,3 +82,2 @@ // We're manually parsing JSON here to get better error messages.

}
callback(null, _data, xhr.getResponseHeader('Cache-Control'), xhr.getResponseHeader('Expires'), xhr);

@@ -108,3 +91,3 @@ } else {

};
// @ts-ignore
xhr.cancel = xhr.abort;

@@ -114,3 +97,2 @@ xhr.send(requestParameters.body);

}
export function makeXMLHttpRequestPromise(requestParameters) {

@@ -137,9 +119,8 @@ return new Promise(function (resolve, reject) {

}
function makeRequest(requestParameters, callback) {
// TODO: isWorker
// makeFetchRequest
return makeXMLHttpRequest(requestParameters, callback);
}
export var getJSON = function getJSON(requestParameters, callback) {

@@ -163,19 +144,17 @@ var action = getProtocolAction(requestParameters.url) || makeRequest;

export function sameOrigin(url) {
var a = $window.document.createElement('a');
var a = window.document.createElement('a');
a.href = url;
return a.protocol === $window.document.location.protocol && a.host === $window.document.location.host;
return a.protocol === window.document.location.protocol && a.host === window.document.location.host;
}
var transparentPngUrl = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=';
function arrayBufferToImage(data, callback) {
var img = new $window.Image();
var URL = $window.URL || $window.webkitURL;
var img = new window.Image();
var URL = window.URL || window.webkitURL;
img.crossOrigin = 'anonymous';
img.onload = function () {
callback(null, img);
URL.revokeObjectURL(img.src); // prevent image dataURI memory leak in Safari;
URL.revokeObjectURL(img.src);
// prevent image dataURI memory leak in Safari;
// but don't free the image immediately because it might be uploaded in the next frame
// https://github.com/mapbox/mapbox-gl-js/issues/10226
img.onload = null;

@@ -186,7 +165,5 @@ window.requestAnimationFrame(function () {

};
img.onerror = function () {
return callback(new Error('Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.'));
};
var blob = new Blob([new Uint8Array(data)], {

@@ -197,3 +174,2 @@ type: 'image/png'

}
function arrayBufferToImageBitmap(data, callback) {

@@ -209,3 +185,2 @@ var blob = new Blob([new Uint8Array(data)], {

}
export var getImage = function getImage(requestParameters, callback, transformResponse) {

@@ -220,3 +195,2 @@ // request the image with XHR to work around caching issues

var transformImgData = transformResponse ? transformResponse(imgData) : imgData;
if (imageBitmapSupported) {

@@ -229,3 +203,2 @@ arrayBufferToImageBitmap(transformImgData, callback);

};
if (requestParameters.type === 'json') {

@@ -239,3 +212,2 @@ return getJSON(requestParameters, optionFunc);

var imageBitmapSupported = typeof createImageBitmap === 'function';
if (imageBitmapSupported) {

@@ -242,0 +214,0 @@ arrayBufferToImageBitmap(imgData, callback);

@@ -26,3 +26,2 @@ export var anchorType = /*#__PURE__*/function (anchorType) {

var classList = element.classList;
for (var _key in anchorTranslate) {

@@ -33,4 +32,3 @@ if (anchorTranslate.hasOwnProperty(_key)) {

}
classList.add("l7-".concat(prefix, "-anchor-").concat(anchor));
}
import * as d3 from 'd3-color';
import { $window, isMini } from "./mini-adapter";
export function isColor(str) {

@@ -13,3 +12,2 @@ if (typeof str === 'string') {

var arr = [0, 0, 0, 0];
if (color != null) {

@@ -21,3 +19,2 @@ arr[0] = color.r / 255;

}
return arr;

@@ -28,4 +25,4 @@ }

var i2 = color && color[1];
var i3 = color && color[2]; // 1 was added to seperate from no selection
var i3 = color && color[2];
// 1 was added to seperate from no selection
var index = i1 + i2 * 256 + i3 * 65536 - 1;

@@ -39,12 +36,12 @@ return index;

export function generateColorRamp(colorRamp) {
var canvas = $window.document.createElement('canvas');
var canvas = window.document.createElement('canvas');
var ctx = canvas.getContext('2d');
canvas.width = 256;
canvas.height = 1;
var data = null; // draw linear color
var data = null;
// draw linear color
var gradient = ctx.createLinearGradient(0, 0, 256, 1);
var min = colorRamp.positions[0];
var max = colorRamp.positions[colorRamp.positions.length - 1];
for (var i = 0; i < colorRamp.colors.length; ++i) {

@@ -54,46 +51,25 @@ var value = (colorRamp.positions[i] - min) / (max - min);

}
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, 256, 1);
data = new Uint8ClampedArray(ctx.getImageData(0, 0, 256, 1).data);
// @ts-ignore
canvas = null;
// @ts-ignore
ctx = null;
return {
data: data,
width: 256,
height: 1
};
}
if (!isMini) {
data = ctx.getImageData(0, 0, 256, 1).data; // 使用 createImageData 替代 new ImageData、兼容 IE11
var imageData = ctx.createImageData(256, 1);
for (var _i = 0; _i < imageData.data.length; _i += 4) {
imageData.data[_i + 0] = data[_i + 0];
imageData.data[_i + 1] = data[_i + 1];
imageData.data[_i + 2] = data[_i + 2];
imageData.data[_i + 3] = data[_i + 3];
} // @ts-ignore
canvas = null; // @ts-ignore
ctx = null;
return imageData;
} else {
data = new Uint8ClampedArray(ctx.getImageData(0, 0, 256, 1).data); // @ts-ignore
canvas = null; // @ts-ignore
ctx = null;
return {
data: data,
width: 256,
height: 1
};
}
} // 连续型 Position 支持设置原始数据
// 连续型 Position 支持设置原始数据
export function generateLinearRamp(colorRamp, domain) {
var canvas = $window.document.createElement('canvas');
var canvas = window.document.createElement('canvas');
var ctx = canvas.getContext('2d');
canvas.width = 256;
canvas.height = 1; // draw linear color
canvas.height = 1;
// draw linear color
var gradient = ctx.createLinearGradient(0, 0, 256, 1);
var step = domain[1] - domain[0];
for (var i = 0; i < colorRamp.colors.length; ++i) {

@@ -103,16 +79,17 @@ var value = Math.max((colorRamp.positions[i] - domain[0]) / step, 0);

}
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, 256, 1);
var data = ctx.getImageData(0, 0, 256, 1).data;
var imageData = toIEIMageData(ctx, data); // @ts-ignore
var imageData = toIEIMageData(ctx, data);
canvas = null; // @ts-ignore
// @ts-ignore
canvas = null;
// @ts-ignore
ctx = null;
return imageData;
} // 枚举类型
}
// 枚举类型
export function generateCatRamp(colorRamp) {
var canvas = $window.document.createElement('canvas');
var canvas = window.document.createElement('canvas');
var ctx = canvas.getContext('2d');

@@ -129,12 +106,13 @@ canvas.width = 256;

imageData.data[p * 4 + 3] = colorArray[3] * 255;
}); // @ts-ignore
canvas = null; // @ts-ignore
});
// @ts-ignore
canvas = null;
// @ts-ignore
ctx = null;
return imageData;
} // 等间距
}
// 等间距
export function generateQuantizeRamp(colorRamp) {
var canvas = $window.document.createElement('canvas');
var canvas = window.document.createElement('canvas');
var ctx = canvas.getContext('2d');

@@ -146,3 +124,2 @@ ctx.globalAlpha = 1.0;

// draw linear color
for (var i = 0; i < colorRamp.colors.length; i++) {

@@ -153,19 +130,20 @@ ctx.beginPath();

ctx.moveTo(i * step, 0); // positioned at 50,25
ctx.lineTo((i + 1) * step, 0);
ctx.stroke();
}
var data = ctx.getImageData(0, 0, 256, 1).data;
// 使用 createImageData 替代 new ImageData、兼容 IE11
var imageData = toIEIMageData(ctx, data);
var data = ctx.getImageData(0, 0, 256, 1).data; // 使用 createImageData 替代 new ImageData、兼容 IE11
var imageData = toIEIMageData(ctx, data); // @ts-ignore
canvas = null; // @ts-ignore
// @ts-ignore
canvas = null;
// @ts-ignore
ctx = null;
return imageData;
} // 自定义间距
}
// 自定义间距
export function generateCustomRamp(colorRamp, domain) {
var canvas = $window.document.createElement('canvas');
var canvas = window.document.createElement('canvas');
var ctx = canvas.getContext('2d');

@@ -176,7 +154,5 @@ ctx.globalAlpha = 1.0;

var step = domain[1] - domain[0];
if (colorRamp.positions.length - colorRamp.colors.length !== 1) {
console.warn('positions 的数字个数应当比 colors 的样式多一个,poisitions 的首尾值一般为数据的最大最新值');
}
for (var i = 0; i < colorRamp.colors.length; i++) {

@@ -187,19 +163,15 @@ ctx.beginPath();

ctx.moveTo((colorRamp.positions[i] - domain[0]) / step * 255, 0); // positioned at 50,25
ctx.lineTo((colorRamp.positions[i + 1] - domain[0]) / step * 255, 0);
ctx.stroke();
}
var data = ctx.getImageData(0, 0, 256, 1).data;
var imageData = toIEIMageData(ctx, data); // @ts-ignore
canvas = null; // @ts-ignore
var imageData = toIEIMageData(ctx, data);
// @ts-ignore
canvas = null;
// @ts-ignore
ctx = null;
return imageData;
}
function toIEIMageData(ctx, data) {
var imageData = ctx.createImageData(256, 1);
for (var i = 0; i < imageData.data.length; i += 4) {

@@ -211,6 +183,4 @@ imageData.data[i + 0] = data[i + 0];

}
return imageData;
}
export function getDefaultDomain(rampColors) {

@@ -220,3 +190,2 @@ switch (rampColors.type) {

return [0, 255];
default:

@@ -223,0 +192,0 @@ return [0, 1];

@@ -16,23 +16,17 @@ var gl = {

break;
case 'GAODE2.x':
return gl.BACK;
break;
case 'MAPBOX':
return gl.FRONT;
break;
case 'SIMPLE':
return gl.FRONT;
break;
case 'GLOBEL':
return gl.BACK;
break;
case 'DEBAULT':
return gl.FRONT;
break;
default:

@@ -39,0 +33,0 @@ return gl.FRONT;

@@ -6,3 +6,3 @@ export type ELType = HTMLElement | SVGElement;

export declare function splitWords(str: string): string[];
export declare function create(tagName: string, className?: string, container?: HTMLElement): any;
export declare function create(tagName: string, className?: string, container?: HTMLElement): HTMLElement;
export declare function remove(el: ELType | DocumentFragment): void;

@@ -19,3 +19,3 @@ export declare function addClass(el: ELType, name: string): void;

export declare function getViewPortScale(): number;
export declare const DPR: any;
export declare const DPR: number;
export declare function addStyle(el: ELType, style: string): void;

@@ -22,0 +22,0 @@ export declare function getStyleList(style: string): string[];

import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import { pull } from 'lodash';
import { $window } from "./mini-adapter";
import { lodashUtil } from "./lodash-adapter";
var pull = lodashUtil.pull;
export function getContainer(domId) {
var $dom = domId;
if (typeof domId === 'string') {
$dom = $window.document.getElementById(domId);
$dom = window.document.getElementById(domId);
}
return $dom;

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

return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
} // @function splitWords(str: String): String[]
}
// @function splitWords(str: String): String[]
// Trims and splits the string on whitespace and returns the array of parts.
export function splitWords(str) {
return trim(str).split(/\s+/);
}
function testProp(props) {
var _$window$document, _$window$document$doc;
var docStyle = $window === null || $window === void 0 ? void 0 : (_$window$document = $window.document) === null || _$window$document === void 0 ? void 0 : (_$window$document$doc = _$window$document.documentElement) === null || _$window$document$doc === void 0 ? void 0 : _$window$document$doc.style;
var _window, _window$document, _window$document$docu;
var docStyle = (_window = window) === null || _window === void 0 ? void 0 : (_window$document = _window.document) === null || _window$document === void 0 ? void 0 : (_window$document$docu = _window$document.documentElement) === null || _window$document$docu === void 0 ? void 0 : _window$document$docu.style;
if (!docStyle) {
return props[0];
}
for (var i in props) {

@@ -38,34 +33,28 @@ if (props[i] && props[i] in docStyle) {

}
return props[0];
}
export function create(tagName, className, container) {
var el = $window.document.createElement(tagName);
var el = window.document.createElement(tagName);
if (className) {
el.className = className || '';
}
if (container) {
container.appendChild(el);
}
return el;
} // @function remove(el: HTMLElement)
}
// @function remove(el: HTMLElement)
// Removes `el` from its parent element
export function remove(el) {
var parent = el.parentNode;
if (parent) {
parent.removeChild(el);
}
} // @function addClass(el: HTMLElement, name: String)
}
// @function addClass(el: HTMLElement, name: String)
// Adds `name` to the element's class attribute.
export function addClass(el, name) {
if (el.classList !== undefined) {
var classes = splitWords(name);
for (var i = 0, len = classes.length; i < len; i++) {

@@ -78,5 +67,6 @@ el.classList.add(classes[i]);

}
} // @function removeClass(el: HTMLElement, name: String)
}
// @function removeClass(el: HTMLElement, name: String)
// Removes `name` from the element's class attribute.
export function removeClass(el, name) {

@@ -91,5 +81,6 @@ if (el.classList !== undefined) {

}
} // @function hasClass(el: HTMLElement, name: String): Boolean
}
// @function hasClass(el: HTMLElement, name: String): Boolean
// Returns `true` if the element's class attribute contains `name`.
export function hasClass(el, name) {

@@ -99,8 +90,8 @@ if (el.classList !== undefined) {

}
var className = getClass(el);
return className.length > 0 && new RegExp('(^|\\s)' + name + '(\\s|$)').test(className);
} // @function setClass(el: HTMLElement, name: String)
}
// @function setClass(el: HTMLElement, name: String)
// Sets the element's class.
export function setClass(el, name) {

@@ -113,5 +104,6 @@ if (el instanceof HTMLElement) {

}
} // @function getClass(el: HTMLElement): String
}
// @function getClass(el: HTMLElement): String
// Returns the element's class.
export function getClass(el) {

@@ -124,3 +116,2 @@ // Check if the element is an SVGElementInstance and use the correspondingElement instead

}
return el.className.baseVal === undefined ? el.className : el.className.baseVal;

@@ -141,15 +132,15 @@ }

// modern browsers
$window.dispatchEvent(new Event('resize'));
window.dispatchEvent(new Event('resize'));
} else {
// for IE and other old browsers
// causes deprecation warning on modern browsers
var evt = $window.document.createEvent('UIEvents'); // @ts-ignore
evt.initUIEvent('resize', true, false, $window, 0);
$window.dispatchEvent(evt);
var evt = window.document.createEvent('UIEvents');
// @ts-ignore
evt.initUIEvent('resize', true, false, window, 0);
window.dispatchEvent(evt);
}
}
export function printCanvas(canvas) {
var css = ['padding: ' + (canvas.height / 2 - 8) + 'px ' + canvas.width / 2 + 'px;', 'line-height: ' + canvas.height + 'px;', 'background-image: url(' + canvas.toDataURL() + ');']; // tslint:disable-next-line:no-console
var css = ['padding: ' + (canvas.height / 2 - 8) + 'px ' + canvas.width / 2 + 'px;', 'line-height: ' + canvas.height + 'px;', 'background-image: url(' + canvas.toDataURL() + ');'];
// tslint:disable-next-line:no-console
console.log('%c\n', css.join(''));

@@ -159,15 +150,11 @@ }

var _content;
var meta = $window.document.querySelector('meta[name="viewport"]');
var meta = window.document.querySelector('meta[name="viewport"]');
if (!meta) {
return 1;
}
var contentItems = (_content = meta.content) === null || _content === void 0 ? void 0 : _content.split(',');
var scale = contentItems.find(function (item) {
var _item$split = item.split('='),
_item$split2 = _slicedToArray(_item$split, 1),
key = _item$split2[0];
_item$split2 = _slicedToArray(_item$split, 1),
key = _item$split2[0];
return key === 'initial-scale';

@@ -177,3 +164,3 @@ });

}
export var DPR = getViewPortScale() < 1 ? 1 : $window.devicePixelRatio;
export var DPR = getViewPortScale() < 1 ? 1 : window.devicePixelRatio;
export function addStyle(el, style) {

@@ -191,3 +178,2 @@ el.setAttribute('style', "".concat(el.style.cssText).concat(style));

var _el$getAttribute;
var oldStyleList = getStyleList((_el$getAttribute = el.getAttribute('style')) !== null && _el$getAttribute !== void 0 ? _el$getAttribute : '');

@@ -201,5 +187,4 @@ var targetStyleList = getStyleList(style);

var _ref2 = _slicedToArray(_ref, 2),
key = _ref2[0],
value = _ref2[1];
key = _ref2[0],
value = _ref2[1];
return "".concat(key, ": ").concat(value);

@@ -219,3 +204,2 @@ }).join(';');

el.checked = value;
if (value) {

@@ -237,3 +221,2 @@ el.setAttribute('checked', 'true');

div.innerHTML = children;
while (div.firstChild) {

@@ -240,0 +223,0 @@ container.append(div.firstChild);

var _navigator;
export function isImageBitmap(image) {

@@ -9,9 +8,9 @@ return typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap;

return typeof importScripts === 'function';
} // Ensure that we're sending the correct referrer from blob URL worker bundles.
}
// Ensure that we're sending the correct referrer from blob URL worker bundles.
// For files loaded from the local file system, `location.origin` will be set
// to the string(!) "null" (Firefox), or "file://" (Chrome, Safari, Edge, IE),
// and we will set an empty referrer. Otherwise, we're using the document's URL.
/* global self */
export var getReferrer = isWorker() ? function () {

@@ -29,6 +28,4 @@ return self.worker && self.worker.referrer;

var flag = true;
for (var _i = 0, _Agents = Agents; _i < _Agents.length; _i++) {
var v = _Agents[_i];
if (userAgentInfo.indexOf(v) > 0) {

@@ -39,4 +36,3 @@ flag = false;

}
return flag;
}

@@ -9,20 +9,15 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";

}
context[fn] = context[fn].bind(context);
});
} // 频率控制器
}
// 频率控制器
export var FrequencyController = /*#__PURE__*/function () {
function FrequencyController() {
var duration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 16;
_classCallCheck(this, FrequencyController);
_defineProperty(this, "duration", 16);
_defineProperty(this, "timestamp", new Date().getTime());
this.duration = duration;
}
_createClass(FrequencyController, [{

@@ -34,3 +29,2 @@ key: "run",

this.timestamp = currentTime;
if (timeCut >= this.duration) {

@@ -41,4 +35,3 @@ callback();

}]);
return FrequencyController;
}();

@@ -8,7 +8,6 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";

var _bounds = _slicedToArray(bounds, 4),
minLng = _bounds[0],
minLat = _bounds[1],
maxLng = _bounds[2],
maxLat = _bounds[3];
minLng = _bounds[0],
minLat = _bounds[1],
maxLng = _bounds[2],
maxLat = _bounds[3];
return lngLat.lng > minLng && lngLat.lng <= maxLng && lngLat.lat > minLat && lngLat.lat <= maxLat;

@@ -21,3 +20,2 @@ }

*/
export function extent(data) {

@@ -31,3 +29,2 @@ var dataExtent = [Infinity, Infinity, -Infinity, -Infinity];

}
function caculExtent(dataExtent, coords) {

@@ -42,11 +39,8 @@ if (Array.isArray(coords[0])) {

}
if (dataExtent[1] > coords[1]) {
dataExtent[1] = coords[1];
}
if (dataExtent[2] < coords[0]) {
dataExtent[2] = coords[0];
}
if (dataExtent[3] < coords[1]) {

@@ -56,10 +50,7 @@ dataExtent[3] = coords[1];

}
return dataExtent;
}
export function tranfrormCoord(data, cb) {
return transform(data, cb);
}
function transform(item, cb) {

@@ -71,6 +62,4 @@ if (Array.isArray(item[0])) {

}
return cb(item);
}
export function lngLatToMeters(lnglat) {

@@ -88,3 +77,2 @@ var validate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;

y = y * originShift / 180.0;
if (accuracy.enable) {

@@ -94,3 +82,2 @@ x = Number(x.toFixed(accuracy.decimal));

}
return lnglat.length === 3 ? [x, y, lnglat[2]] : [x, y];

@@ -105,3 +92,2 @@ }

lat = 180 / Math.PI * (2 * Math.atan(Math.exp(lat * Math.PI / 180.0)) - Math.PI / 2.0);
if (decimal !== undefined && decimal !== null) {

@@ -111,3 +97,2 @@ lng = Number(lng.toFixed(decimal));

}
return meters.length === 3 ? [lng, lat, meters[2]] : [lng, lat];

@@ -118,16 +103,13 @@ }

throw new Error('lng is required');
} // lngitudes cannot extends beyond +/-90 degrees
}
// lngitudes cannot extends beyond +/-90 degrees
if (lng > 180 || lng < -180) {
lng = lng % 360;
if (lng > 180) {
lng = -360 + lng;
}
if (lng < -180) {
lng = 360 + lng;
}
if (lng === 0) {

@@ -137,3 +119,2 @@ lng = 0;

}
return lng;

@@ -145,14 +126,10 @@ }

}
if (lat > 90 || lat < -90) {
lat = lat % 180;
if (lat > 90) {
lat = -180 + lat;
}
if (lat < -90) {
lat = 180 + lat;
}
if (lat === 0) {

@@ -162,3 +139,2 @@ lat = 0;

}
return lat;

@@ -170,14 +146,12 @@ }

}
var lng = longitude(lnglat[0]);
var lat = latitude(lnglat[1]); // Global Mercator does not support latitudes within 85 to 90 degrees
var lat = latitude(lnglat[1]);
// Global Mercator does not support latitudes within 85 to 90 degrees
if (lat > 85) {
lat = 85;
}
if (lat < -85) {
lat = -85;
}
return lnglat.length === 3 ? [lng, lat, lnglat[2]] : [lng, lat];

@@ -207,7 +181,5 @@ }

var scale = 256 << 20;
var _px = _slicedToArray(px, 2),
x = _px[0],
y = _px[1];
x = _px[0],
y = _px[1];
x = (x / scale - b) / a;

@@ -244,3 +216,4 @@ y = (y / scale - d) / c;

var a = Math.pow(Math.sin(dLat / 2), 2) + Math.pow(Math.sin(dLon / 2), 2) * Math.cos(lat1) * Math.cos(lat2);
return radiansToLength(2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)), // eslint-disable-next-line @typescript-eslint/no-unused-vars
return radiansToLength(2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
units = 'meters');

@@ -268,3 +241,2 @@ }

*/
export function boundsContains(b1, b2) {

@@ -278,3 +250,2 @@ return b1[0][0] <= b2[0][0] && b1[0][1] <= b2[0][1] && b1[1][0] >= b2[1][0] && b1[1][1] >= b2[1][1];

*/
export function bBoxToBounds(b1) {

@@ -290,11 +261,8 @@ return [[b1[0], b1[1]], [b1[2], b1[3]]];

}
function dotMul(v1, v2) {
return v1[0] * v2[0] + v1[1] * v2[1];
}
function getMod(v) {
return Math.sqrt(v[0] * v[0] + v[1] * v[1]);
}
export function calAngle(v1, v2) {

@@ -309,2 +277,3 @@ return Math.acos(dotMul(v1, v2) / (getMod(v1) * getMod(v2))) * 180 / Math.PI;

// }
if (v2[0] > 0) {

@@ -330,11 +299,8 @@ if (v2[1] > 0) {

var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;
if (!coords || coords.length < 2) {
return;
}
var originVec2 = [0, 1];
var totalDis = 0;
var path = [];
for (var i = 0; i < coords.length - 1; i++) {

@@ -345,9 +311,8 @@ var p1 = coords[i];

totalDis += dis;
var direct = [p1[0] - p2[0], p1[1] - p2[1]]; // const direct: Point = [p2[0] - p1[0], p2[1] - p1[1]];
var direct = [p1[0] - p2[0], p1[1] - p2[1]];
// const direct: Point = [p2[0] - p1[0], p2[1] - p1[1]];
var rotation = getAngle(originVec2, direct);
if (i > 0) {
var lastRotation = path[i - 1].rotation;
if (lastRotation - rotation > 360 - lastRotation + rotation) {

@@ -357,3 +322,2 @@ rotation = rotation + 360;

}
path.push({

@@ -367,3 +331,2 @@ start: p1,

}
path.map(function (point) {

@@ -377,5 +340,7 @@ point.duration = time * (point.dis / totalDis);

if (isNumber(coord[0])) {
return coord; // @ts-ignore
return coord;
// @ts-ignore
} else if (isNumber(coord[0][0])) {
throw new Error('当前数据不支持标注'); // @ts-ignore
throw new Error('当前数据不支持标注');
// @ts-ignore
} else if (isNumber(coord[0][0][0])) {

@@ -398,2 +363,3 @@ var coords = coord;

}
/**

@@ -404,3 +370,2 @@ * 计算

*/
export function calculatePointsCenterAndRadius(points) {

@@ -414,7 +379,5 @@ var maxX = points[0];

var pCount = 0;
for (var i = 0; i < points.length; i += 2) {
var x = points[i];
var y = points[i + 1];
if (x && y) {

@@ -430,3 +393,2 @@ maxX = Math.max(x, maxX);

}
return {

@@ -437,2 +399,3 @@ center: [xCount / pCount, yCount / pCount],

}
/**

@@ -442,5 +405,4 @@ * 获取经纬度点集对应的 bbox

*/
export function getBBoxFromPoints(pointList) {
return bbox(featureCollection([lineString(pointList)]));
}

@@ -7,3 +7,2 @@ export function BKDRHash(str) {

var MAX_SAFE_INTEGER = Math.floor(9007199254740991 / seed2);
for (var i = 0; i < str.length; i++) {

@@ -13,6 +12,4 @@ if (hash > MAX_SAFE_INTEGER) {

}
hash = hash * seed + str.charCodeAt(i);
}
return hash;

@@ -24,7 +21,5 @@ }

var i = str.length;
while (i) {
hash = hash * 33 ^ str.charCodeAt(--i);
}
return hash >>> 0;

@@ -31,0 +26,0 @@ }

@@ -12,4 +12,4 @@ export * from './ajax';

export * from './lineAtOffset';
export * from './lodash-adapter';
export * from './lru_cache';
export * from './mini-adapter/index';
export * as Satistics from './statistics';

@@ -16,0 +16,0 @@ export * from './tileset-manager';

@@ -14,4 +14,5 @@ // @ts-ignore

export * from "./lineAtOffset";
export * from "./lodash-adapter";
export * from "./lru_cache";
export * from "./mini-adapter/index";
// export * from './mini-adapter/index';
import * as _Satistics from "./statistics";

@@ -18,0 +19,0 @@ export { _Satistics as Satistics };

@@ -9,3 +9,2 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";

var pointOffset = offset;
if (autoFit) {

@@ -15,3 +14,2 @@ // Tip: 自动偏移到线的节点位置

}
if (!thetaOffset) {

@@ -23,3 +21,2 @@ return interpolate(source, target, pointOffset, 0.314, mapVersion);

}
function bezier3(arr, t) {

@@ -29,10 +26,7 @@ var ut = 1 - t;

}
function calDistance(p1, p2) {
return Math.sqrt(Math.pow(p1[0] - p2[0], 2) + Math.pow(p1[1] - p2[1], 2));
}
function midPoint(source, target, thetaOffset) {
var center = [target[0] - source[0], target[1] - source[1]]; // target - source;
var r = calDistance(center, [0, 0]);

@@ -45,3 +39,2 @@ var theta = Math.atan2(center[1], center[0]);

}
function interpolate(source, target, offset, thetaOffset, mapVersion) {

@@ -59,3 +52,2 @@ if (mapVersion === Version['GAODE2.x']) {

var _mid = midPoint(source, target, thetaOffset);
var _x = [source[0], _mid[0], target[0]];

@@ -62,0 +54,0 @@ var _y = [source[1], _mid[1], target[1]];

@@ -8,3 +8,2 @@ import { degreesToRadians, radiansToDegrees } from '@turf/helpers';

var pointOffset = offset;
if (autoFit) {

@@ -15,9 +14,6 @@ // Tip: 自动偏移到线的节点位置

}
return interpolate(source, target, pointOffset, mapVersion);
}
function midPoint(source, target) {
var center = [target[0] - source[0], target[1] - source[1]]; // target - source;
var r = calDistance(center, [0, 0]);

@@ -31,3 +27,2 @@ var theta = Math.atan2(center[1], center[0]);

}
function bezier3(arr, t) {

@@ -37,15 +32,11 @@ var ut = 1 - t;

}
function getAngularDist(source, target) {
var delta = [source[0] - target[0], source[1] - target[1]];
var sinHalfDelta = [Math.sin(delta[0] / 2.0), Math.sin(delta[1] / 2.0)]; // Math.sin(delta / 2.0);
var a = sinHalfDelta[1] * sinHalfDelta[1] + Math.cos(source[1]) * Math.cos(target[1]) * sinHalfDelta[0] * sinHalfDelta[0];
return 2.0 * Math.atan2(Math.sqrt(a), Math.sqrt(1.0 - a));
}
export function interpolate(s, t, offset, mapVersion) {
var source = [degreesToRadians(s[0]), degreesToRadians(s[1])];
var target = [degreesToRadians(t[0]), degreesToRadians(t[1])];
if (mapVersion === 'GAODE2.x') {

@@ -59,7 +50,5 @@ // gaode2.x

var angularDist = getAngularDist(source, target);
if (Math.abs(angularDist - Math.PI) < 0.001) {
return [(1.0 - offset) * source[0] + offset * target[0], (1.0 - offset) * source[1] + offset * target[1]];
}
var a = Math.sin((1.0 - offset) * angularDist) / Math.sin(angularDist);

@@ -71,7 +60,4 @@ var b = Math.sin(offset * angularDist) / Math.sin(angularDist);

var cosTarget = [Math.cos(target[0]), Math.cos(target[1])];
var _x = a * cosSource[1] * cosSource[0] + b * cosTarget[1] * cosTarget[0];
var _y = a * cosSource[1] * sinSource[0] + b * cosTarget[1] * sinTarget[0];
var z = a * sinSource[1] + b * sinTarget[1];

@@ -78,0 +64,0 @@ return [radiansToDegrees(Math.atan2(_y, _x)), radiansToDegrees(Math.atan2(z, Math.sqrt(_x * _x + _y * _y)))];

@@ -9,3 +9,2 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";

var features = source.data.dataArray;
if (typeof featureId === 'number') {

@@ -17,3 +16,2 @@ features = features.filter(function (_ref) {

}
return features.map(function (feature) {

@@ -35,18 +33,15 @@ var position = getLineOffsetPosition(feature, option);

}
function getLineOffsetPosition(feature, option) {
var offset = option.offset,
shape = option.shape,
thetaOffset = option.thetaOffset,
mapVersion = option.mapVersion,
_option$segmentNumber = option.segmentNumber,
segmentNumber = _option$segmentNumber === void 0 ? 30 : _option$segmentNumber,
_option$autoFit = option.autoFit,
autoFit = _option$autoFit === void 0 ? true : _option$autoFit;
shape = option.shape,
thetaOffset = option.thetaOffset,
mapVersion = option.mapVersion,
_option$segmentNumber = option.segmentNumber,
segmentNumber = _option$segmentNumber === void 0 ? 30 : _option$segmentNumber,
_option$autoFit = option.autoFit,
autoFit = _option$autoFit === void 0 ? true : _option$autoFit;
var coordinates = feature.coordinates;
if (shape === 'line') {
return pathLineAtOffset(coordinates, offset);
}
var source = coordinates[0];

@@ -56,3 +51,2 @@ var target = coordinates[1];

var calFunc;
switch (shape) {

@@ -62,17 +56,13 @@ case 'arc':

break;
case 'greatcircle':
calFunc = greatCircleLineAtOffset;
break;
default:
calFunc = arcLineAtOffset;
}
var _calFunc = calFunc(source, target, offset, linetheatOffset, mapVersion, segmentNumber, autoFit),
_calFunc2 = _slicedToArray(_calFunc, 3),
lng = _calFunc2[0],
lat = _calFunc2[1],
height = _calFunc2[2];
_calFunc2 = _slicedToArray(_calFunc, 3),
lng = _calFunc2[0],
lat = _calFunc2[1],
height = _calFunc2[2];
return {

@@ -79,0 +69,0 @@ lng: lng,

export function pathLineAtOffset(coords, offset) {
var totalDistance = 0;
var cachePoints = [];
for (var i = 0; i < coords.length - 1; i++) {

@@ -19,11 +18,8 @@ var p1 = coords[i];

}
var offsetDistance = totalDistance * offset;
var lng;
var lat;
for (var _i = 0, _cachePoints = cachePoints; _i < _cachePoints.length; _i++) {
var point = _cachePoints[_i];
var currentDistance = point.totalDistance;
if (currentDistance > offsetDistance) {

@@ -39,3 +35,2 @@ var _p = point.p1;

}
return {

@@ -47,9 +42,7 @@ lng: lng,

}
function mixPoint(p1, p2, r) {
return [p1[0] * r + p2[0] * (1 - r), p1[1] * r + p2[1] * (1 - r)];
}
function calDistance(p1, p2) {
return Math.sqrt(Math.pow(p1[0] - p2[0], 2) + Math.pow(p1[1] - p2[1], 2));
}
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
/**

@@ -10,2 +9,3 @@ * LRU Cache class with limit

*/
export var LRUCache = /*#__PURE__*/function () {

@@ -15,5 +15,3 @@ function LRUCache() {

var destroy = arguments.length > 1 ? arguments[1] : undefined;
_classCallCheck(this, LRUCache);
this.limit = limit;

@@ -24,3 +22,2 @@ this.destroy = destroy || this.defaultDestroy;

}
_createClass(LRUCache, [{

@@ -30,8 +27,7 @@ key: "clear",

var _this = this;
this.order.forEach(function (key) {
_this.delete(key);
});
this.cache = {}; // access/update order, first item is oldest, last item is newest
this.cache = {};
// access/update order, first item is oldest, last item is newest
this.order = [];

@@ -43,3 +39,2 @@ }

var value = this.cache[key];
if (value) {

@@ -50,3 +45,2 @@ // update order

}
return value;

@@ -62,3 +56,2 @@ }

}
this.cache[key] = value;

@@ -77,3 +70,2 @@ this.appendOrder(key);

var value = this.cache[key];
if (value) {

@@ -96,3 +88,2 @@ this.deleteCache(key);

});
if (index >= 0) {

@@ -106,4 +97,4 @@ this.order.splice(index, 1);

this.order.push(key);
} // eslint-disable-next-line @typescript-eslint/no-unused-vars
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
}, {

@@ -115,4 +106,3 @@ key: "defaultDestroy",

}]);
return LRUCache;
}();

@@ -5,5 +5,3 @@ function max(x) {

}
var value = x[0];
for (var i = 1; i < x.length; i++) {

@@ -16,6 +14,4 @@ // On the first iteration of this loop, max is

}
return value * 1;
}
function min(x) {

@@ -25,5 +21,3 @@ if (x.length === 0) {

}
var value = x[0];
for (var i = 1; i < x.length; i++) {

@@ -36,6 +30,4 @@ // On the first iteration of this loop, min is

}
return value * 1;
}
function sum(x) {

@@ -45,15 +37,13 @@ // If the array is empty, we needn't bother computing its sum

return 0;
} // Initializing the sum as the first number in the array
}
// Initializing the sum as the first number in the array
var sumNum = x[0] * 1;
for (var i = 1; i < x.length; i++) {
sumNum += x[i] * 1;
} // Returning the corrected sum
}
// Returning the corrected sum
return sumNum;
}
function mean(x) {

@@ -63,6 +53,4 @@ if (x.length === 0) {

}
return sum(x) / x.length;
}
function mode(x) {

@@ -72,7 +60,5 @@ if (x.length === 0) {

}
if (x.length < 3) {
return x[0];
}
x.sort();

@@ -83,3 +69,2 @@ var last = x[0];

var seenThis = 1;
for (var i = 1; i < x.length + 1; i++) {

@@ -91,3 +76,2 @@ if (x[i] !== last) {

}
seenThis = 1;

@@ -99,6 +83,4 @@ last = x[i];

}
return value * 1;
}
export { sum, max, min, mean, mode };

@@ -105,0 +87,0 @@ export var statMap = {

import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
var _UPDATE_TILE_STRATEGI;
import { UpdateTileStrategy } from "./types";

@@ -10,6 +8,8 @@ import { updateTileStateOverlap, updateTileStateRealtime, updateTileStateReplace } from "./utils/strategies";

export var BOUNDS_BUFFER_SCALE = 0.2;
export var DEFAULT_CACHE_SCALE = 5; // 瓦片更新显示策略
export var DEFAULT_CACHE_SCALE = 5;
// 瓦片更新显示策略
export var UPDATE_TILE_STRATEGIES = (_UPDATE_TILE_STRATEGI = {}, _defineProperty(_UPDATE_TILE_STRATEGI, UpdateTileStrategy.Realtime, updateTileStateRealtime), _defineProperty(_UPDATE_TILE_STRATEGI, UpdateTileStrategy.Overlap, updateTileStateOverlap), _defineProperty(_UPDATE_TILE_STRATEGI, UpdateTileStrategy.Replace, updateTileStateReplace), _UPDATE_TILE_STRATEGI);
export var NOOP = function NOOP() {//
export var NOOP = function NOOP() {
//
};

@@ -11,7 +11,4 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

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 bboxPolygon from '@turf/bbox-polygon';

@@ -25,58 +22,39 @@ import { EventEmitter } from 'eventemitter3';

*/
export var SourceTile = /*#__PURE__*/function (_EventEmitter) {
_inherits(SourceTile, _EventEmitter);
var _super = _createSuper(SourceTile);
// 瓦片索引
// 循环加载瓦片
// 瓦片大小
// 是否可以见
// 是否是当前层级的瓦片
// 是否可以见发生变化
// 瓦片的父级瓦片
// 瓦片的子级瓦片
// 瓦片数据
// 瓦片属性
// 瓦片序号
function SourceTile(options) {
var _this;
_classCallCheck(this, SourceTile);
_this = _super.call(this);
// 瓦片索引
// 循环加载瓦片
// 瓦片大小
_defineProperty(_assertThisInitialized(_this), "tileSize", 256);
// 是否可以见
_defineProperty(_assertThisInitialized(_this), "isVisible", false);
// 是否是当前层级的瓦片
_defineProperty(_assertThisInitialized(_this), "isCurrent", false);
// 是否可以见发生变化
_defineProperty(_assertThisInitialized(_this), "isVisibleChange", false);
_defineProperty(_assertThisInitialized(_this), "loadedLayers", 0);
_defineProperty(_assertThisInitialized(_this), "isLayerLoaded", false);
_defineProperty(_assertThisInitialized(_this), "isLoad", false);
_defineProperty(_assertThisInitialized(_this), "isChildLoad", false);
// 瓦片的父级瓦片
_defineProperty(_assertThisInitialized(_this), "parent", null);
// 瓦片的子级瓦片
_defineProperty(_assertThisInitialized(_this), "children", []);
// 瓦片数据
_defineProperty(_assertThisInitialized(_this), "data", null);
// 瓦片属性
_defineProperty(_assertThisInitialized(_this), "properties", {});
// 瓦片序号
_defineProperty(_assertThisInitialized(_this), "loadDataId", 0);
var x = options.x,
y = options.y,
z = options.z,
tileSize = options.tileSize,
_options$warp = options.warp,
warp = _options$warp === void 0 ? true : _options$warp;
y = options.y,
z = options.z,
tileSize = options.tileSize,
_options$warp = options.warp,
warp = _options$warp === void 0 ? true : _options$warp;
_this.x = x;

@@ -88,5 +66,5 @@ _this.y = y;

return _this;
} // 是否正在请求瓦片
}
// 是否正在请求瓦片
_createClass(SourceTile, [{

@@ -96,4 +74,5 @@ key: "isLoading",

return this.loadStatus === LoadTileDataStatus.Loading;
} // 是否瓦片请求成功
}
// 是否瓦片请求成功
}, {

@@ -103,4 +82,5 @@ key: "isLoaded",

return this.loadStatus === LoadTileDataStatus.Loaded;
} // 是否瓦片请求失败
}
// 是否瓦片请求失败
}, {

@@ -115,4 +95,5 @@ key: "isFailure",

this.isLayerLoaded = true;
} // 是否瓦片请求被取消
}
// 是否瓦片请求被取消
}, {

@@ -122,4 +103,5 @@ key: "isCancelled",

return this.loadStatus === LoadTileDataStatus.Cancelled;
} // 是否数据请求结束
}
// 是否数据请求结束
}, {

@@ -129,4 +111,5 @@ key: "isDone",

return [LoadTileDataStatus.Loaded, LoadTileDataStatus.Cancelled, LoadTileDataStatus.Failure].includes(this.loadStatus);
} // 瓦片的经纬度边界
}
// 瓦片的经纬度边界
}, {

@@ -136,4 +119,5 @@ key: "bounds",

return tileToBounds(this.x, this.y, this.z);
} // 瓦片边界面
}
// 瓦片边界面
}, {

@@ -143,7 +127,6 @@ key: "bboxPolygon",

var _this$bounds = _slicedToArray(this.bounds, 4),
minLng = _this$bounds[0],
minLat = _this$bounds[1],
maxLng = _this$bounds[2],
maxLat = _this$bounds[3];
minLng = _this$bounds[0],
minLat = _this$bounds[1],
maxLng = _this$bounds[2],
maxLat = _this$bounds[3];
var center = [(maxLng - minLng) / 2, (maxLat - minLat) / 2];

@@ -156,10 +139,12 @@ var polygon = bboxPolygon(this.bounds, {

center: center,
meta: "\n ".concat(this.key, "\n ") // ${this.bbox.slice(0, 2)}
meta: "\n ".concat(this.key, "\n ")
// ${this.bbox.slice(0, 2)}
// ${this.bbox.slice(2)}
}
});
return polygon;
} // 瓦片的 key
}
// 瓦片的 key
}, {

@@ -176,4 +161,4 @@ key: "key",

this.emit('layerLoaded');
} // 请求瓦片数据
}
// 请求瓦片数据
}, {

@@ -184,91 +169,72 @@ key: "loadData",

var getData, onLoad, onError, loadDataId, tileData, error, x, y, z, bounds, tileSize, warp, _getTileWarpXY, warpX, warpY, signal, params;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
getData = _ref.getData, onLoad = _ref.onLoad, onError = _ref.onError;
this.loadDataId++;
loadDataId = this.loadDataId; // 如果重复请求,执行最新请求
if (this.isLoading) {
this.abortLoad();
}
this.abortController = new AbortController();
this.loadStatus = LoadTileDataStatus.Loading;
tileData = null;
_context.prev = 7;
x = this.x, y = this.y, z = this.z, bounds = this.bounds, tileSize = this.tileSize, warp = this.warp; // wrap
_getTileWarpXY = getTileWarpXY(x, y, z, warp), warpX = _getTileWarpXY.warpX, warpY = _getTileWarpXY.warpY;
signal = this.abortController.signal;
params = {
x: warpX,
y: warpY,
z: z,
bounds: bounds,
tileSize: tileSize,
signal: signal,
warp: warp
};
_context.next = 14;
return getData(params, this);
case 14:
tileData = _context.sent;
_context.next = 20;
while (1) switch (_context.prev = _context.next) {
case 0:
getData = _ref.getData, onLoad = _ref.onLoad, onError = _ref.onError;
this.loadDataId++;
loadDataId = this.loadDataId; // 如果重复请求,执行最新请求
if (this.isLoading) {
this.abortLoad();
}
this.abortController = new AbortController();
this.loadStatus = LoadTileDataStatus.Loading;
tileData = null;
_context.prev = 7;
x = this.x, y = this.y, z = this.z, bounds = this.bounds, tileSize = this.tileSize, warp = this.warp; // wrap
_getTileWarpXY = getTileWarpXY(x, y, z, warp), warpX = _getTileWarpXY.warpX, warpY = _getTileWarpXY.warpY;
signal = this.abortController.signal;
params = {
x: warpX,
y: warpY,
z: z,
bounds: bounds,
tileSize: tileSize,
signal: signal,
warp: warp
};
_context.next = 14;
return getData(params, this);
case 14:
tileData = _context.sent;
_context.next = 20;
break;
case 17:
_context.prev = 17;
_context.t0 = _context["catch"](7);
error = _context.t0;
case 20:
if (!(loadDataId !== this.loadDataId)) {
_context.next = 22;
break;
case 17:
_context.prev = 17;
_context.t0 = _context["catch"](7);
error = _context.t0;
case 20:
if (!(loadDataId !== this.loadDataId)) {
_context.next = 22;
break;
}
return _context.abrupt("return");
case 22:
if (!(this.isCancelled && !tileData)) {
_context.next = 24;
break;
}
return _context.abrupt("return");
case 24:
if (!(error || !tileData)) {
_context.next = 28;
break;
}
this.loadStatus = LoadTileDataStatus.Failure;
onError(error, this);
return _context.abrupt("return");
case 28:
this.loadStatus = LoadTileDataStatus.Loaded;
this.data = tileData;
onLoad(this);
case 31:
case "end":
return _context.stop();
}
}
return _context.abrupt("return");
case 22:
if (!(this.isCancelled && !tileData)) {
_context.next = 24;
break;
}
return _context.abrupt("return");
case 24:
if (!(error || !tileData)) {
_context.next = 28;
break;
}
this.loadStatus = LoadTileDataStatus.Failure;
onError(error, this);
return _context.abrupt("return");
case 28:
this.loadStatus = LoadTileDataStatus.Loaded;
this.data = tileData;
onLoad(this);
case 31:
case "end":
return _context.stop();
}
}, _callee, this, [[7, 17]]);
}));
function loadData(_x) {
return _loadData.apply(this, arguments);
}
return loadData;
}() // 重新请求瓦片数据
}, {

@@ -280,6 +246,6 @@ key: "reloadData",

}
this.loadData(params);
} // 取消请求瓦片数据
}
// 取消请求瓦片数据
}, {

@@ -291,6 +257,4 @@ key: "abortLoad",

}
this.loadStatus = LoadTileDataStatus.Cancelled;
this.abortController.abort();
if (this.xhrCancel) {

@@ -301,4 +265,3 @@ this.xhrCancel();

}]);
return SourceTile;
}(EventEmitter);

@@ -10,15 +10,9 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";

import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
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; }
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; }
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 EventEmitter from 'eventemitter3';
import { throttle } from 'lodash';
import { lodashUtil } from "../lodash-adapter";
import { BOUNDS_BUFFER_SCALE, DEFAULT_CACHE_SCALE, DEFAULT_EXTENT, NOOP, UPDATE_TILE_STRATEGIES } from "./const";

@@ -29,2 +23,3 @@ import { SourceTile } from "./tile";

import { getTileIndices as _getTileIndices, osmLonLat2TileXY } from "./utils/lonlat-tile";
var throttle = lodashUtil.throttle;
export var TileEventType = /*#__PURE__*/function (TileEventType) {

@@ -39,34 +34,29 @@ TileEventType["TilesLoadStart"] = "tiles-load-start";

}({});
/**
* 管理瓦片数据
*/
export var TilesetManager = /*#__PURE__*/function (_EventEmitter) {
_inherits(TilesetManager, _EventEmitter);
var _super = _createSuper(TilesetManager);
// 上一次视野状态
function TilesetManager(options) {
var _this;
_classCallCheck(this, TilesetManager);
_this = _super.call(this);
// 当前层级的瓦片
_defineProperty(_assertThisInitialized(_this), "currentTiles", []);
// 缓存的瓦片,key 为 {z}-{x}-{y}
_defineProperty(_assertThisInitialized(_this), "cacheTiles", new Map());
_defineProperty(_assertThisInitialized(_this), "throttleUpdate", throttle(function (zoom, latLonBounds) {
_this.update(zoom, latLonBounds);
}, 16));
// 瓦片加载成功回调
_defineProperty(_assertThisInitialized(_this), "onTileLoad", function (tile) {
_this.emit(TileEventType.TileLoaded, tile);
_this.updateTileVisible();
_this.loadFinished();
});
// 瓦片加载失败回调
_defineProperty(_assertThisInitialized(_this), "onTileError", function (error, tile) {

@@ -77,14 +67,10 @@ _this.emit(TileEventType.TileError, {

});
_this.updateTileVisible();
_this.loadFinished();
});
// 瓦片被删除回调
_defineProperty(_assertThisInitialized(_this), "onTileUnload", function (tile) {
_this.emit(TileEventType.TileUnload, tile);
_this.loadFinished();
});
_this.options = {

@@ -101,9 +87,7 @@ tileSize: 256,

};
_this.updateOptions(options);
return _this;
} // 更新配置项
}
// 更新配置项
_createClass(TilesetManager, [{

@@ -115,4 +99,4 @@ key: "isLoaded",

});
} // 缓存的瓦片数组
}
// 缓存的瓦片数组
}, {

@@ -126,4 +110,3 @@ key: "tiles",

return tiles;
} // 当前层级的瓦片
}
}, {

@@ -141,15 +124,14 @@ key: "updateOptions",

key: "update",
value: // 更新
value:
// 更新
// 1.瓦片序号发生改变 2.瓦片新增 3.瓦片显隐控制
function update(zoom, latLonBounds) {
var _this2 = this;
// 校验层级,向上取整
var verifyZoom = Math.max(0, Math.ceil(zoom));
if (this.lastViewStates && this.lastViewStates.zoom === verifyZoom && isLatLonBoundsContains(this.lastViewStates.latLonBoundsBuffer, latLonBounds)) {
return;
} // 扩大缓存区的边界
}
// 扩大缓存区的边界
var latLonBoundsBuffer = getLatLonBoundsBuffer(latLonBounds, BOUNDS_BUFFER_SCALE);

@@ -170,12 +152,8 @@ this.lastViewStates = {

var x = _ref.x,
y = _ref.y,
z = _ref.z;
y = _ref.y,
z = _ref.z;
var tile = _this2.getTile(x, y, z);
if (tile) {
var _tile, _tile2;
var needsReload = ((_tile = tile) === null || _tile === void 0 ? void 0 : _tile.isFailure) || ((_tile2 = tile) === null || _tile2 === void 0 ? void 0 : _tile2.isCancelled);
if (needsReload) {

@@ -188,6 +166,4 @@ tile.loadData({

}
return tile;
}
tile = _this2.createTile(x, y, z);

@@ -197,14 +173,13 @@ isAddTile = true;

});
if (isAddTile) {
// 更新缓存
this.resizeCacheTiles();
} // 更新瓦片显示状态
this.updateTileVisible(); // 取消滞留请求中的瓦片
}
// 更新瓦片显示状态
this.updateTileVisible();
// 取消滞留请求中的瓦片
this.pruneRequests();
} // 重新加载瓦片
}
// 重新加载瓦片
}, {

@@ -214,10 +189,8 @@ key: "reloadAll",

var _iterator = _createForOfIteratorHelper(this.cacheTiles),
_step;
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var _step$value = _slicedToArray(_step.value, 2),
tileId = _step$value[0],
tile = _step$value[1];
tileId = _step$value[0],
tile = _step$value[1];
if (!this.currentTiles.includes(tile)) {

@@ -228,3 +201,2 @@ this.cacheTiles.delete(tileId);

}
this.onTileUnload(tile);

@@ -247,3 +219,2 @@ tile.loadData({

var tile = this.cacheTiles.get("".concat(x, ",").concat(y, ",").concat(z));
if (tile) {

@@ -262,3 +233,2 @@ this.onTileUnload(tile);

var tile = this.getTileByLngLat(lng, lat, z);
if (tile) {

@@ -272,3 +242,2 @@ this.reloadTileById(tile.z, tile.x, tile.y);

var _this3 = this;
var tiles = this.getTileIndices(z, extent);

@@ -278,4 +247,5 @@ tiles.forEach(function (tile) {

});
} // 取消滞留请求中的瓦片
}
// 取消滞留请求中的瓦片
}, {

@@ -285,10 +255,7 @@ key: "pruneRequests",

var abortCandidates = [];
var _iterator2 = _createForOfIteratorHelper(this.cacheTiles.values()),
_step2;
_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var _tile3 = _step2.value;
if (_tile3.isLoading) {

@@ -305,3 +272,2 @@ if (!_tile3.isCurrent && !_tile3.isVisible) {

}
while (abortCandidates.length > 0) {

@@ -336,4 +302,5 @@ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion

return tile[0];
} // 摧毁
}
// 摧毁
}, {

@@ -343,8 +310,6 @@ key: "clear",

var _iterator3 = _createForOfIteratorHelper(this.cacheTiles.values()),
_step3;
_step3;
try {
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
var tile = _step3.value;
if (tile.isLoading) {

@@ -361,8 +326,8 @@ tile.abortLoad();

}
this.lastViewStates = undefined;
this.cacheTiles.clear();
this.currentTiles = [];
} // 摧毁
}
// 摧毁
}, {

@@ -373,4 +338,5 @@ key: "destroy",

this.removeAllListeners();
} // 更新瓦片显隐状态
}
// 更新瓦片显隐状态
}, {

@@ -380,7 +346,6 @@ key: "updateTileVisible",

var updateStrategy = this.options.updateStrategy;
var beforeVisible = new Map(); // 重置显示状态
var beforeVisible = new Map();
// 重置显示状态
var _iterator4 = _createForOfIteratorHelper(this.cacheTiles.values()),
_step4;
_step4;
try {

@@ -393,4 +358,4 @@ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {

tile.isVisible = false;
} // 设置当前视野的瓦片为可见
}
// 设置当前视野的瓦片为可见
} catch (err) {

@@ -401,6 +366,4 @@ _iterator4.e(err);

}
var _iterator5 = _createForOfIteratorHelper(this.currentTiles),
_step5;
_step5;
try {

@@ -417,5 +380,3 @@ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {

}
var tiles = Array.from(this.cacheTiles.values());
if (typeof updateStrategy === 'function') {

@@ -425,5 +386,5 @@ updateStrategy(tiles);

UPDATE_TILE_STRATEGIES[updateStrategy](tiles);
} // 检查瓦片显示状态是否发生改变
}
// 检查瓦片显示状态是否发生改变
var isVisibleChange = false;

@@ -438,8 +399,8 @@ Array.from(this.cacheTiles.values()).forEach(function (tile) {

});
if (isVisibleChange) {
this.emit(TileEventType.TileUpdate);
}
} // 获取当前视野层级瓦片的所有索引
}
// 获取当前视野层级瓦片的所有索引
}, {

@@ -449,8 +410,7 @@ key: "getTileIndices",

var _this$options = this.options,
tileSize = _this$options.tileSize,
extent = _this$options.extent,
zoomOffset = _this$options.zoomOffset;
tileSize = _this$options.tileSize,
extent = _this$options.extent,
zoomOffset = _this$options.zoomOffset;
var maxZoom = Math.floor(this.options.maxZoom);
var minZoom = Math.ceil(this.options.minZoom);
var indices = _getTileIndices({

@@ -465,9 +425,8 @@ maxZoom: maxZoom,

});
return indices;
} // 瓦片加载成功回调
}
}, {
key: "getTileId",
value: // 获取瓦片 ID
value:
// 获取瓦片 ID
function getTileId(x, y, z) {

@@ -483,10 +442,9 @@ var tileId = "".concat(x, ",").concat(y, ",").concat(z);

});
if (finish) {
this.emit(TileEventType.TilesLoadFinished);
}
return finish;
} // 获取瓦片
}
// 获取瓦片
}, {

@@ -498,4 +456,5 @@ key: "getTile",

return tile;
} // 创建瓦片
}
// 创建瓦片
}, {

@@ -519,4 +478,5 @@ key: "createTile",

return tile;
} // 当缓存超过最大值时,清除不可见的瓦片
}
// 当缓存超过最大值时,清除不可见的瓦片
}, {

@@ -527,13 +487,10 @@ key: "resizeCacheTiles",

var overflown = this.cacheTiles.size > maxCacheSize;
if (overflown) {
var _iterator6 = _createForOfIteratorHelper(this.cacheTiles),
_step6;
_step6;
try {
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
var _step6$value = _slicedToArray(_step6.value, 2),
tileId = _step6$value[0],
tile = _step6$value[1];
tileId = _step6$value[0],
tile = _step6$value[1];
if (!tile.isVisible && !this.currentTiles.includes(tile)) {

@@ -543,3 +500,2 @@ this.cacheTiles.delete(tileId);

}
if (this.cacheTiles.size <= maxCacheSize) {

@@ -554,8 +510,8 @@ break;

}
} // 缓存更新重新计算瓦片树
}
// 缓存更新重新计算瓦片树
this.rebuildTileTree();
} // 重新计算瓦片树
}
// 重新计算瓦片树
}, {

@@ -566,4 +522,3 @@ key: "rebuildTileTree",

var _iterator7 = _createForOfIteratorHelper(this.cacheTiles.values()),
_step7;
_step7;
try {

@@ -574,4 +529,5 @@ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {

tile.children.length = 0;
} // 重新计算瓦片上的关系树
}
// 重新计算瓦片上的关系树
} catch (err) {

@@ -582,6 +538,4 @@ _iterator7.e(err);

}
var _iterator8 = _createForOfIteratorHelper(this.cacheTiles.values()),
_step8;
_step8;
try {

@@ -592,3 +546,2 @@ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {

_tile5.parent = parent;
if (parent !== null && parent !== void 0 && parent.children) {

@@ -603,4 +556,5 @@ parent.children.push(_tile5);

}
} // 获取瓦片的最近上级的瓦片
}
// 获取瓦片的最近上级的瓦片
}, {

@@ -614,3 +568,2 @@ key: "getNearestAncestor",

var parent = this.getTile(x, y, z);
if (parent) {

@@ -620,8 +573,6 @@ return parent;

}
return null;
}
}]);
return TilesetManager;
}(EventEmitter);
// Bounds [minLng, minLat, maxLng, maxLat]
// 瓦片更新显示策略

@@ -3,0 +4,0 @@ export var UpdateTileStrategy = /*#__PURE__*/function (UpdateTileStrategy) {

import { bBoxToBounds, boundsContains, padBounds } from "../../geo";
/**
* 获取经纬度边界的缓存后的边界
*/
export var getLatLonBoundsBuffer = function getLatLonBoundsBuffer(latLonBounds, bufferRatio) {
var bounds = bBoxToBounds(latLonBounds);
var newBounds = padBounds(bounds, bufferRatio); // 地图对称子午线最多重复三次
var newBounds = padBounds(bounds, bufferRatio);
// 地图对称子午线最多重复三次
var maxLngExtent = 360 * 3 - 180;

@@ -15,6 +15,6 @@ var maxLatExtent = 85.0511287798065;

};
/**
* 边界是否包含在内
*/
export var isLatLonBoundsContains = function isLatLonBoundsContains(latLonBoundsBuffer, latLonBounds) {

@@ -21,0 +21,0 @@ var boundsBuffer = bBoxToBounds(latLonBoundsBuffer);

@@ -8,4 +8,5 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";

return [x, y];
} // https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#ECMAScript_.28JavaScript.2FActionScript.2C_etc..29
}
// https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#ECMAScript_.28JavaScript.2FActionScript.2C_etc..29
export function osmTileXY2LonLat(x, y, zoom) {

@@ -17,19 +18,18 @@ var lon = x / Math.pow(2, zoom) * 360 - 180;

}
/**
* 获取当前瓦片的经纬度边界
*/
export var tileToBounds = function tileToBounds(x, y, z) {
var _osmTileXY2LonLat = osmTileXY2LonLat(x, y, z),
_osmTileXY2LonLat2 = _slicedToArray(_osmTileXY2LonLat, 2),
minLng = _osmTileXY2LonLat2[0],
maxLat = _osmTileXY2LonLat2[1];
_osmTileXY2LonLat2 = _slicedToArray(_osmTileXY2LonLat, 2),
minLng = _osmTileXY2LonLat2[0],
maxLat = _osmTileXY2LonLat2[1];
var _osmTileXY2LonLat3 = osmTileXY2LonLat(x + 1, y + 1, z),
_osmTileXY2LonLat4 = _slicedToArray(_osmTileXY2LonLat3, 2),
maxLng = _osmTileXY2LonLat4[0],
minLat = _osmTileXY2LonLat4[1];
_osmTileXY2LonLat4 = _slicedToArray(_osmTileXY2LonLat3, 2),
maxLng = _osmTileXY2LonLat4[0],
minLat = _osmTileXY2LonLat4[1];
return [minLng, minLat, maxLng, maxLat];
};
/**

@@ -42,44 +42,38 @@ * 获取当前视野层级瓦片的所有索引

*/
export function getTileIndices(_ref) {
var zoom = _ref.zoom,
latLonBounds = _ref.latLonBounds,
_ref$maxZoom = _ref.maxZoom,
maxZoom = _ref$maxZoom === void 0 ? Infinity : _ref$maxZoom,
_ref$minZoom = _ref.minZoom,
minZoom = _ref$minZoom === void 0 ? 0 : _ref$minZoom,
_ref$zoomOffset = _ref.zoomOffset,
zoomOffset = _ref$zoomOffset === void 0 ? 0 : _ref$zoomOffset,
_ref$extent = _ref.extent,
extent = _ref$extent === void 0 ? DEFAULT_EXTENT : _ref$extent;
var z = Math.ceil(zoom) + zoomOffset; // 如果当前 zoom 层级小于 minZoom
latLonBounds = _ref.latLonBounds,
_ref$maxZoom = _ref.maxZoom,
maxZoom = _ref$maxZoom === void 0 ? Infinity : _ref$maxZoom,
_ref$minZoom = _ref.minZoom,
minZoom = _ref$minZoom === void 0 ? 0 : _ref$minZoom,
_ref$zoomOffset = _ref.zoomOffset,
zoomOffset = _ref$zoomOffset === void 0 ? 0 : _ref$zoomOffset,
_ref$extent = _ref.extent,
extent = _ref$extent === void 0 ? DEFAULT_EXTENT : _ref$extent;
var z = Math.ceil(zoom) + zoomOffset;
// 如果当前 zoom 层级小于 minZoom
if (Number.isFinite(minZoom) && z < minZoom) {
return [];
} // 如果当前 zoom 层级大于 maxZoom
}
// 如果当前 zoom 层级大于 maxZoom
if (Number.isFinite(maxZoom) && z > maxZoom) {
z = maxZoom;
}
var _latLonBounds = _slicedToArray(latLonBounds, 4),
minLng = _latLonBounds[0],
minLat = _latLonBounds[1],
maxLng = _latLonBounds[2],
maxLat = _latLonBounds[3];
minLng = _latLonBounds[0],
minLat = _latLonBounds[1],
maxLng = _latLonBounds[2],
maxLat = _latLonBounds[3];
var bounds = [Math.max(minLng, extent[0]), Math.max(minLat, extent[1]), Math.min(maxLng, extent[2]), Math.min(maxLat, extent[3])];
var indices = [];
var _osmLonLat2TileXY = osmLonLat2TileXY(bounds[0], bounds[1], z),
_osmLonLat2TileXY2 = _slicedToArray(_osmLonLat2TileXY, 2),
minX = _osmLonLat2TileXY2[0],
maxY = _osmLonLat2TileXY2[1];
_osmLonLat2TileXY2 = _slicedToArray(_osmLonLat2TileXY, 2),
minX = _osmLonLat2TileXY2[0],
maxY = _osmLonLat2TileXY2[1];
var _osmLonLat2TileXY3 = osmLonLat2TileXY(bounds[2], bounds[3], z),
_osmLonLat2TileXY4 = _slicedToArray(_osmLonLat2TileXY3, 2),
maxX = _osmLonLat2TileXY4[0],
minY = _osmLonLat2TileXY4[1];
_osmLonLat2TileXY4 = _slicedToArray(_osmLonLat2TileXY3, 2),
maxX = _osmLonLat2TileXY4[0],
minY = _osmLonLat2TileXY4[1];
for (var x = minX; x <= maxX; x++) {

@@ -93,13 +87,11 @@ for (var y = minY; y <= maxY; y++) {

}
} // 计算中心瓦片索引
}
// 计算中心瓦片索引
var centerX = (maxX + minX) / 2;
var centerY = (maxY + minY) / 2;
var distance = function distance(x, y) {
return Math.abs(x - centerX) + Math.abs(y - centerY);
}; // 通过离中心瓦片距离排序,越近的排在前面
};
// 通过离中心瓦片距离排序,越近的排在前面
indices.sort(function (a, b) {

@@ -110,6 +102,6 @@ return distance(a.x, a.y) - distance(b.x, b.y);

}
/**
* Warp 瓦片索引,支持对称子午线瓦片连续
*/
export var getTileWarpXY = function getTileWarpXY(x, y, z) {

@@ -122,3 +114,2 @@ var wrap = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;

var warpY = y;
if (wrap) {

@@ -131,3 +122,2 @@ if (warpX < 0) {

}
return {

@@ -134,0 +124,0 @@ warpX: warpX,

// 访问状态
var TILE_STATE_DEFAULT = 0; // 访问状态
var TILE_STATE_DEFAULT = 0;
// 访问状态
var TILE_STATE_VISITED = 1;
// 可见状态
var TILE_STATE_VISIBLE = 2;
var TILE_STATE_VISITED = 1; // 可见状态
var TILE_STATE_VISIBLE = 2;
/*

@@ -12,3 +13,2 @@ * 瓦片更新状态策略 - 实时更新策略

*/
export function updateTileStateRealtime(tiles) {

@@ -21,2 +21,3 @@ tiles.forEach(function (tile) {

}
/*

@@ -28,3 +29,2 @@ * 瓦片更新状态策略 - 渐近更新策略

*/
export function updateTileStateOverlap(tiles) {

@@ -43,2 +43,3 @@ tiles.forEach(function (tile) {

}
/*

@@ -48,8 +49,7 @@ * 瓦片更新状态策略 - 全部替换策略

*/
export function updateTileStateReplace(tiles) {
tiles.forEach(function (tile) {
tile.properties.state = TILE_STATE_DEFAULT;
}); // 更新当前视野瓦片的上级瓦片可见状态
});
// 更新当前视野瓦片的上级瓦片可见状态
tiles.forEach(function (tile) {

@@ -59,4 +59,5 @@ if (tile.isCurrent) {

}
}); // 通过 zoom 层级排序,最小的层级在上面
});
// 通过 zoom 层级排序,最小的层级在上面
var sortedTiles = tiles.slice().sort(function (t1, t2) {

@@ -67,3 +68,2 @@ return t1.z - t2.z;

tile.isVisible = Boolean(tile.properties.state & TILE_STATE_VISIBLE);
if (tile.children.length && (tile.isVisible || tile.properties.state & TILE_STATE_VISITED)) {

@@ -79,2 +79,3 @@ // 如果瓦片可见,隐藏所有的子级瓦片

}
/*

@@ -84,3 +85,2 @@ * 查找上级已加载的瓦片作为占位符

*/
function getPlaceholderInAncestors(tile) {

@@ -93,13 +93,10 @@ while (tile) {

}
tile = tile.parent;
}
return false;
}
/*
* 递归查找将子级已加载瓦片作为占位符
*/
function getPlaceholderInChildren(tile) {

@@ -106,0 +103,0 @@ tile.children.forEach(function (child) {

@@ -6,6 +6,6 @@ import { getProtocolAction } from "../../ajax";

*/
export function isURLTemplate(s) {
return /(?=.*{box})(?=.*{z})(?=.*{x})(?=.*({y}|{-y}))/.test(s);
}
/**

@@ -16,7 +16,5 @@ * https://github.com/openlayers/openlayers/blob/main/src/ol/tileurlfunction.js

*/
export function expandUrl(url) {
var urls = [];
var match = /\{([a-z])-([a-z])\}/.exec(url);
if (match) {

@@ -27,30 +25,23 @@ // char range

var charCode;
for (charCode = startCharCode; charCode <= stopCharCode; ++charCode) {
urls.push(url.replace(match[0], String.fromCharCode(charCode)));
}
return urls;
}
match = /\{(\d+)-(\d+)\}/.exec(url);
if (match) {
// number range
var stop = parseInt(match[2], 10);
for (var i = parseInt(match[1], 10); i <= stop; i++) {
urls.push(url.replace(match[0], i.toString()));
}
return urls;
}
urls.push(url);
return urls;
}
/*
* 获取瓦片请求地址
*/
export function getURLFromTemplate(template, properties) {

@@ -60,12 +51,12 @@ if (!template || !template.length) {

}
var x = properties.x,
y = properties.y,
z = properties.z;
y = properties.y,
z = properties.z;
var urls = expandUrl(template);
var index = Math.abs(x + y) % urls.length; // 兼容其他协议的 URL 模版
var index = Math.abs(x + y) % urls.length;
// 兼容其他协议的 URL 模版
var url = getProtocolAction(urls[index]) ? "".concat(urls[index], "/{z}/{x}/{y}") : urls[index];
return url.replace(/\{x\}/g, x.toString()).replace(/\{y\}/g, y.toString()).replace(/\{z\}/g, z.toString()).replace(/\{bbox\}/g, tileToBounds(x, y, z).join(',')).replace(/\{-y\}/g, (Math.pow(2, z) - y - 1).toString());
}
/**

@@ -77,15 +68,15 @@ * wmts url

var x = properties.x,
y = properties.y,
z = properties.z,
layer = properties.layer,
_properties$version = properties.version,
version = _properties$version === void 0 ? '1.0.0' : _properties$version,
_properties$style = properties.style,
style = _properties$style === void 0 ? 'default' : _properties$style,
format = properties.format,
_properties$service = properties.service,
service = _properties$service === void 0 ? 'WMTS' : _properties$service,
tileMatrixset = properties.tileMatrixset;
y = properties.y,
z = properties.z,
layer = properties.layer,
_properties$version = properties.version,
version = _properties$version === void 0 ? '1.0.0' : _properties$version,
_properties$style = properties.style,
style = _properties$style === void 0 ? 'default' : _properties$style,
format = properties.format,
_properties$service = properties.service,
service = _properties$service === void 0 ? 'WMTS' : _properties$service,
tileMatrixset = properties.tileMatrixset;
var url = "".concat(template, "&SERVICE=").concat(service, "&REQUEST=GetTile&VERSION=").concat(version, "&LAYER=").concat(layer, "&STYLE=").concat(style, "&TILEMATRIXSET=").concat(tileMatrixset, "&FORMAT=").concat(format, "&TILECOL=").concat(x, "&TILEROW=").concat(y, "&TILEMATRIX=").concat(z);
return url;
}

@@ -8,4 +8,4 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";

import { aProjectFlat } from "../geo";
var tmp = vec2.create(); // eslint-disable-next-line @typescript-eslint/no-unused-vars
var tmp = vec2.create();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
var capEnd = vec2.create();

@@ -30,13 +30,9 @@ var lineA = vec2.create();

}
function isPointEqual(a, b) {
return a[0] === b[0] && a[1] === b[1];
}
export function getArrayUnique(matrix) {
var map = new Map();
for (var i = 0; i < matrix.length; i++) {
var key = matrix[0].toString() + '-' + matrix[1].toString();
if (map.get(key)) {

@@ -49,24 +45,14 @@ matrix.splice(i, 1);

}
return matrix;
}
var ExtrudePolyline = /*#__PURE__*/function () {
function ExtrudePolyline() {
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
_classCallCheck(this, ExtrudePolyline);
_defineProperty(this, "lastFlip", -1);
_defineProperty(this, "miter", vec2.fromValues(0, 0));
_defineProperty(this, "started", false);
_defineProperty(this, "dash", false);
_defineProperty(this, "totalDistance", 0);
_defineProperty(this, "currentIndex", 0);
this.join = opts.join || 'miter';

@@ -85,3 +71,2 @@ this.cap = opts.cap || 'butt';

}
_createClass(ExtrudePolyline, [{

@@ -91,38 +76,38 @@ key: "extrude_gaode2",

var complex = this.complex;
if (points.length <= 1) {
return complex;
}
this.lastFlip = -1;
this.started = false;
this.normal = null;
this.totalDistance = 0; // 去除数组里重复的点
this.totalDistance = 0;
// 去除数组里重复的点
// points = getArrayUnique(points);
var total = points.length;
var count = complex.startIndex;
for (var i = 1; i < total; i++) {
var _originPoints$, _originPoints$i$, _originPoints$2;
var last = points[i - 1];
last.push((_originPoints$ = originPoints[i - 1][2]) !== null && _originPoints$ !== void 0 ? _originPoints$ : 0); // @ts-ignore
last.push((_originPoints$ = originPoints[i - 1][2]) !== null && _originPoints$ !== void 0 ? _originPoints$ : 0);
// @ts-ignore
var originLast = originPoints[i - 1];
var cur = points[i];
cur.push((_originPoints$i$ = originPoints[i][2]) !== null && _originPoints$i$ !== void 0 ? _originPoints$i$ : 0); // @ts-ignore
cur.push((_originPoints$i$ = originPoints[i][2]) !== null && _originPoints$i$ !== void 0 ? _originPoints$i$ : 0);
// @ts-ignore
var originCur = originPoints[i];
var next = i < points.length - 1 ? [].concat(_toConsumableArray(points[i + 1]), [(_originPoints$2 = originPoints[i + 1][2]) !== null && _originPoints$2 !== void 0 ? _originPoints$2 : 0]) : null;
var originNext = i < originPoints.length - 1 ? originPoints[i + 1] : null;
var amt = this.segment_gaode2(complex, count, // @ts-ignore
last, // @ts-ignore
cur, // @ts-ignore
next, // @ts-ignore
originLast, originCur, // @ts-ignore
var amt = this.segment_gaode2(complex, count,
// @ts-ignore
last,
// @ts-ignore
cur,
// @ts-ignore
next,
// @ts-ignore
originLast, originCur,
// @ts-ignore
originNext);
count += amt;
}
if (this.dash) {

@@ -133,3 +118,2 @@ for (var _i = 0; _i < complex.positions.length / 6; _i++) {

}
complex.startIndex = complex.positions.length / 6;

@@ -142,38 +126,38 @@ return complex;

var complex = this.complex;
if (points.length <= 1) {
return complex;
}
this.lastFlip = -1;
this.started = false;
this.normal = null;
this.totalDistance = 0; // 去除数组里重复的点
this.totalDistance = 0;
// 去除数组里重复的点
// points = getArrayUnique(points);
var total = points.length;
var count = complex.startIndex;
for (var i = 1; i < total; i++) {
var _originPoints$3, _originPoints$i$2, _originPoints$4;
var last = points[i - 1];
last.push((_originPoints$3 = originPoints[i - 1][2]) !== null && _originPoints$3 !== void 0 ? _originPoints$3 : 0); // @ts-ignore
last.push((_originPoints$3 = originPoints[i - 1][2]) !== null && _originPoints$3 !== void 0 ? _originPoints$3 : 0);
// @ts-ignore
var originLast = originPoints[i - 1];
var cur = points[i];
cur.push((_originPoints$i$2 = originPoints[i][2]) !== null && _originPoints$i$2 !== void 0 ? _originPoints$i$2 : 0); // @ts-ignore
cur.push((_originPoints$i$2 = originPoints[i][2]) !== null && _originPoints$i$2 !== void 0 ? _originPoints$i$2 : 0);
// @ts-ignore
var originCur = originPoints[i];
var next = i < points.length - 1 ? [].concat(_toConsumableArray(points[i + 1]), [(_originPoints$4 = originPoints[i + 1][2]) !== null && _originPoints$4 !== void 0 ? _originPoints$4 : 0]) : null;
var originNext = i < originPoints.length - 1 ? originPoints[i + 1] : null;
var amt = this.simpleSegment(complex, count, // @ts-ignore
last, // @ts-ignore
cur, // @ts-ignore
next, // @ts-ignore
originLast, originCur, // @ts-ignore
var amt = this.simpleSegment(complex, count,
// @ts-ignore
last,
// @ts-ignore
cur,
// @ts-ignore
next,
// @ts-ignore
originLast, originCur,
// @ts-ignore
originNext);
count += amt;
}
if (this.dash) {

@@ -184,3 +168,2 @@ for (var _i2 = 0; _i2 < complex.positions.length / 6; _i2++) {

}
complex.startIndex = complex.positions.length / 6;

@@ -193,16 +176,13 @@ return complex;

var complex = this.complex;
if (points.length <= 1) {
return complex;
}
this.lastFlip = -1;
this.started = false;
this.normal = null;
this.totalDistance = 0; // 去除数组里重复的点
this.totalDistance = 0;
// 去除数组里重复的点
// points = getArrayUnique(points);
var total = points.length;
var count = complex.startIndex;
for (var i = 1; i < total; i++) {

@@ -215,3 +195,2 @@ var last = points[i - 1];

}
if (this.dash) {

@@ -222,3 +201,2 @@ for (var _i3 = 0; _i3 < complex.positions.length / 6; _i3++) {

}
complex.startIndex = complex.positions.length / 6;

@@ -231,7 +209,5 @@ return complex;

var complex = this.complex;
if (points.length <= 1) {
return complex;
}
this.lastFlip = -1;

@@ -243,3 +219,2 @@ this.started = false;

var count = complex.startIndex;
for (var i = 1; i < total; i++) {

@@ -252,3 +227,2 @@ var last = points[i - 1];

}
if (this.dash) {

@@ -259,3 +233,2 @@ for (var _i4 = 0; _i4 < complex.positions.length / 6; _i4++) {

}
complex.startIndex = complex.positions.length / 6;

@@ -266,3 +239,4 @@ return complex;

key: "segment_gaode2",
value: function segment_gaode2(complex, index, last, cur, next, originLast, originCur, // eslint-disable-next-line @typescript-eslint/no-unused-vars
value: function segment_gaode2(complex, index, last, cur, next, originLast, originCur,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
originNext) {

@@ -276,7 +250,6 @@ var count = 0;

var flatCur = aProjectFlat([originCur[0], originCur[1]]);
var flatLast = aProjectFlat([originLast[0], originLast[1]]); // @ts-ignore
var flatLast = aProjectFlat([originLast[0], originLast[1]]);
// @ts-ignore
direction(lineA, cur, last);
var segmentDistance = 0;
if (this.dash) {

@@ -287,3 +260,2 @@ // @ts-ignore

}
if (!this.normal) {

@@ -293,6 +265,6 @@ this.normal = vec2.create();

}
if (!this.started) {
this.started = true; // if the end cap is type square, we can just push the verts out a bit
this.started = true;
// if the end cap is type square, we can just push the verts out a bit
if (capSquare) {

@@ -315,13 +287,8 @@ // vec2.scaleAndAdd(capEnd, last, lineA, -this.thickness);

}
indices.push(index + 0, index + 1, index + 2);
if (!next) {
computeNormal(this.normal, lineA);
if (capSquare) {
var _out = vec2.create();
var _out2 = vec2.create();
vec2.sub(_out2, lineA, this.normal);

@@ -339,3 +306,2 @@ vec2.add(_out, lineA, this.normal);

}
indices.push.apply(indices, _toConsumableArray(this.lastFlip === 1 ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]));

@@ -346,25 +312,27 @@ count += 2;

if (isPointEqual(cur, next)) {
vec2.add( // @ts-ignore
next, // @ts-ignore
cur, vec2.normalize( // @ts-ignore
next, // @ts-ignore
vec2.add(
// @ts-ignore
next,
// @ts-ignore
cur, vec2.normalize(
// @ts-ignore
next,
// @ts-ignore
vec2.subtract(next, cur, last)));
} // @ts-ignore
}
// @ts-ignore
direction(lineB, next, cur);
// stores tangent & miter
var _computeMiter = computeMiter(tangent, vec2.create(), lineA, lineB, this.thickness),
_computeMiter2 = _slicedToArray(_computeMiter, 2),
miterLen = _computeMiter2[0],
miter = _computeMiter2[1];
// normal(tmp, lineA)
direction(lineB, next, cur); // stores tangent & miter
var _computeMiter = computeMiter(tangent, vec2.create(), lineA, lineB, this.thickness),
_computeMiter2 = _slicedToArray(_computeMiter, 2),
miterLen = _computeMiter2[0],
miter = _computeMiter2[1]; // normal(tmp, lineA)
// get orientation
var flip = vec2.dot(tangent, this.normal) < 0 ? -1 : 1;
var bevel = joinBevel;
if (!bevel && this.join === 'miter') {
var limit = miterLen;
if (limit > this.miterLimit) {

@@ -374,3 +342,2 @@ bevel = true;

}
if (bevel) {

@@ -384,8 +351,8 @@ normals.push(this.normal[0], this.normal[1], 0);

this.currentIndex++;
indices.push.apply(indices, _toConsumableArray(this.lastFlip !== -flip ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3])); // now add the bevel triangle
indices.push.apply(indices, _toConsumableArray(this.lastFlip !== -flip ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]));
// now add the bevel triangle
indices.push(index + 2, index + 3, index + 4);
computeNormal(tmp, lineB);
vec2.copy(this.normal, tmp); // store normal for next round
normals.push(this.normal[0], this.normal[1], 0);

@@ -399,11 +366,10 @@ positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, -this.thickness * flip, cur[2] | 0);

indices.push.apply(indices, _toConsumableArray(this.lastFlip === 1 ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]));
flip = -1; // the miter is now the normal for our next join
flip = -1;
// the miter is now the normal for our next join
vec2.copy(this.normal, miter);
count += 2;
}
this.lastFlip = flip;
}
return count;

@@ -419,7 +385,6 @@ }

var flatCur = aProjectFlat([cur[0], cur[1]]);
var flatLast = aProjectFlat([last[0], last[1]]); // @ts-ignore
var flatLast = aProjectFlat([last[0], last[1]]);
// @ts-ignore
direction(lineA, flatCur, flatLast);
var segmentDistance = 0;
if (this.dash) {

@@ -430,3 +395,2 @@ // @ts-ignore

}
if (!this.normal) {

@@ -436,3 +400,2 @@ this.normal = vec2.create();

}
if (!this.started) {

@@ -442,5 +405,3 @@ this.started = true;

}
indices.push(index + 0, index + 1, index + 2);
if (!next) {

@@ -453,21 +414,22 @@ computeNormal(this.normal, lineA);

var flatNext = aProjectFlat([next[0], next[1]]);
if (isPointEqual(flatCur, flatNext)) {
vec2.add(flatNext, flatCur, vec2.normalize(flatNext, vec2.subtract(flatNext, flatCur, flatLast)));
}
direction(lineB, flatNext, flatCur);
direction(lineB, flatNext, flatCur); // stores tangent & miter
// stores tangent & miter
var _computeMiter3 = computeMiter(tangent, vec2.create(), lineA, lineB, this.thickness),
_computeMiter4 = _slicedToArray(_computeMiter3, 2),
miterLen = _computeMiter4[0],
miter = _computeMiter4[1]; // normal(tmp, lineA)
_computeMiter4 = _slicedToArray(_computeMiter3, 2),
miterLen = _computeMiter4[0],
miter = _computeMiter4[1];
// normal(tmp, lineA)
// get orientation
var flip = vec2.dot(tangent, this.normal) < 0 ? -1 : 1;
this.extrusions(positions, normals, cur, miter, miterLen, this.totalDistance);
indices.push.apply(indices, _toConsumableArray(this.lastFlip === 1 ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]));
flip = -1; // the miter is now the normal for our next join
flip = -1;
// the miter is now the normal for our next join
vec2.copy(this.normal, miter);

@@ -477,3 +439,2 @@ count += 2;

}
return count;

@@ -491,7 +452,6 @@ }

var flatCur = aProjectFlat([cur[0], cur[1]]);
var flatLast = aProjectFlat([last[0], last[1]]); // @ts-ignore
var flatLast = aProjectFlat([last[0], last[1]]);
// @ts-ignore
direction(lineA, flatCur, flatLast);
var segmentDistance = 0;
if (this.dash) {

@@ -502,3 +462,2 @@ // @ts-ignore

}
if (!this.normal) {

@@ -508,6 +467,6 @@ this.normal = vec2.create();

}
if (!this.started) {
this.started = true; // if the end cap is type square, we can just push the verts out a bit
this.started = true;
// if the end cap is type square, we can just push the verts out a bit
if (capSquare) {

@@ -525,3 +484,4 @@ // vec2.scaleAndAdd(capEnd, last, lineA, -this.thickness);

this.complex.indexes.push(this.currentIndex);
this.currentIndex++; // this.extrusions(positions, normals, last, out, this.thickness);
this.currentIndex++;
// this.extrusions(positions, normals, last, out, this.thickness);
// last = capEnd;

@@ -532,8 +492,5 @@ } else {

}
indices.push(index + 0, index + 1, index + 2);
if (!next) {
computeNormal(this.normal, lineA);
if (capSquare) {

@@ -543,8 +500,6 @@ // vec2.scaleAndAdd(capEnd, cur, lineA, this.thickness);

var _out3 = vec2.create();
var _out4 = vec2.create();
vec2.sub(_out4, lineA, this.normal);
vec2.add(_out3, lineA, this.normal); // this.extrusions(positions, normals, cur, out, this.thickness);
vec2.add(_out3, lineA, this.normal);
// this.extrusions(positions, normals, cur, out, this.thickness);
normals.push(_out4[0], _out4[1], 0);

@@ -559,5 +514,5 @@ normals.push(_out3[0], _out3[1], 0);

this.extrusions(positions, normals, cur, this.normal, this.thickness, this.totalDistance);
} // this.extrusions(positions, normals, cur, this.normal, this.thickness);
}
// this.extrusions(positions, normals, cur, this.normal, this.thickness);
indices.push.apply(indices, _toConsumableArray(this.lastFlip === 1 ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]));

@@ -567,22 +522,20 @@ count += 2;

var flatNext = aProjectFlat([next[0], next[1]]);
if (isPointEqual(flatCur, flatNext)) {
vec2.add(flatNext, flatCur, vec2.normalize(flatNext, vec2.subtract(flatNext, flatCur, flatLast)));
}
direction(lineB, flatNext, flatCur);
direction(lineB, flatNext, flatCur); // stores tangent & miter
// stores tangent & miter
var _computeMiter5 = computeMiter(tangent, vec2.create(), lineA, lineB, this.thickness),
_computeMiter6 = _slicedToArray(_computeMiter5, 2),
miterLen = _computeMiter6[0],
miter = _computeMiter6[1]; // normal(tmp, lineA)
_computeMiter6 = _slicedToArray(_computeMiter5, 2),
miterLen = _computeMiter6[0],
miter = _computeMiter6[1];
// normal(tmp, lineA)
// get orientation
var flip = vec2.dot(tangent, this.normal) < 0 ? -1 : 1;
var bevel = joinBevel;
if (!bevel && this.join === 'miter') {
var limit = miterLen;
if (limit > this.miterLimit) {

@@ -592,3 +545,2 @@ bevel = true;

}
if (bevel) {

@@ -602,8 +554,8 @@ normals.push(this.normal[0], this.normal[1], 0);

this.currentIndex++;
indices.push.apply(indices, _toConsumableArray(this.lastFlip !== -flip ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3])); // now add the bevel triangle
indices.push.apply(indices, _toConsumableArray(this.lastFlip !== -flip ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]));
// now add the bevel triangle
indices.push(index + 2, index + 3, index + 4);
computeNormal(tmp, lineB);
vec2.copy(this.normal, tmp); // store normal for next round
normals.push(this.normal[0], this.normal[1], 0);

@@ -617,11 +569,10 @@ positions.push(cur[0], cur[1], cur[2] | 0, this.totalDistance, -this.thickness * flip, cur[2] | 0);

indices.push.apply(indices, _toConsumableArray(this.lastFlip === 1 ? [index, index + 2, index + 3] : [index + 2, index + 1, index + 3]));
flip = -1; // the miter is now the normal for our next join
flip = -1;
// the miter is now the normal for our next join
vec2.copy(this.normal, miter);
count += 2;
}
this.lastFlip = flip;
}
return count;

@@ -631,5 +582,8 @@ }

key: "extrusions",
value: function extrusions(positions, normals, point, // 顶点
normal, // 法向量
thickness, // 高度
value: function extrusions(positions, normals, point,
// 顶点
normal,
// 法向量
thickness,
// 高度
distanceRadio) {

@@ -652,6 +606,4 @@ normals.push(normal[0], normal[1], 0);

}]);
return ExtrudePolyline;
}();
export { ExtrudePolyline as default };

@@ -7,4 +7,5 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

import { pointFillModel } from "./pointFillModel";
import { polygonFillModel } from "./polygonFillModel"; // current support worker
import { polygonFillModel } from "./polygonFillModel";
// current support worker
export var WorkerSourceMap = {

@@ -15,5 +16,3 @@ pointFill: pointFillModel,

};
var workerTypes = _objectSpread({}, WorkerSourceMap);
function worker(_x) {

@@ -23,4 +22,2 @@ return _worker.apply(this, arguments);

// export default createWorker(worker);
function _worker() {

@@ -30,21 +27,15 @@ _worker = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {

return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
workerType = _ref.workerType, data = _ref.data;
if (!workerTypes[workerType]) {
_context.next = 3;
break;
}
return _context.abrupt("return", workerTypes[workerType](data));
case 3:
return _context.abrupt("return", Promise.reject(new Error("Worker with type \"".concat(workerType, "\" non-existent."))));
case 4:
case "end":
return _context.stop();
}
while (1) switch (_context.prev = _context.next) {
case 0:
workerType = _ref.workerType, data = _ref.data;
if (!workerTypes[workerType]) {
_context.next = 3;
break;
}
return _context.abrupt("return", workerTypes[workerType](data));
case 3:
return _context.abrupt("return", Promise.reject(new Error("Worker with type \"".concat(workerType, "\" non-existent."))));
case 4:
case "end":
return _context.stop();
}

@@ -55,3 +46,2 @@ }, _callee);

}
export { createWorker, worker };

@@ -11,114 +11,102 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";

return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
descriptors = _ref.descriptors, features = _ref.features, enablePicking = _ref.enablePicking, iconMap = _ref.iconMap;
updateFuncs = {
// fixed feature func
a_Color: a_Color,
a_Position: a_Position,
filter: a_filter,
a_vertexId: a_vertexId,
a_PickingColor: function a_PickingColor(feature) {
var id = feature.id;
return enablePicking ? encodePickingColor(id) : [0, 0, 0];
},
// pointFill feature func
a_DistanceAndIndex: function a_DistanceAndIndex(feature, featureIdx, vertex, attributeIdx, normal, vertexIndex) {
return vertexIndex === undefined ? [vertex[3], 10] : [vertex[3], vertexIndex];
},
a_Total_Distance: function a_Total_Distance(feature, featureIdx, vertex) {
return [vertex[5]];
},
a_Size: function a_Size(feature) {
var _feature$size = feature.size,
pointSize = _feature$size === void 0 ? 1 : _feature$size;
return Array.isArray(pointSize) ? [pointSize[0], pointSize[1]] : [pointSize, 0];
},
a_Normal: function a_Normal(feature, featureIdx, vertex, attributeIdx, normal) {
return normal;
},
a_Miter: function a_Miter(feature, featureIdx, vertex) {
return [vertex[4]];
},
a_iconMapUV: function a_iconMapUV(feature) {
var texture = feature.texture;
var _ref3 = iconMap[texture] || {
while (1) switch (_context.prev = _context.next) {
case 0:
descriptors = _ref.descriptors, features = _ref.features, enablePicking = _ref.enablePicking, iconMap = _ref.iconMap;
updateFuncs = {
// fixed feature func
a_Color: a_Color,
a_Position: a_Position,
filter: a_filter,
a_vertexId: a_vertexId,
a_PickingColor: function a_PickingColor(feature) {
var id = feature.id;
return enablePicking ? encodePickingColor(id) : [0, 0, 0];
},
// pointFill feature func
a_DistanceAndIndex: function a_DistanceAndIndex(feature, featureIdx, vertex, attributeIdx, normal, vertexIndex) {
return vertexIndex === undefined ? [vertex[3], 10] : [vertex[3], vertexIndex];
},
a_Total_Distance: function a_Total_Distance(feature, featureIdx, vertex) {
return [vertex[5]];
},
a_Size: function a_Size(feature) {
var _feature$size = feature.size,
pointSize = _feature$size === void 0 ? 1 : _feature$size;
return Array.isArray(pointSize) ? [pointSize[0], pointSize[1]] : [pointSize, 0];
},
a_Normal: function a_Normal(feature, featureIdx, vertex, attributeIdx, normal) {
return normal;
},
a_Miter: function a_Miter(feature, featureIdx, vertex) {
return [vertex[4]];
},
a_iconMapUV: function a_iconMapUV(feature) {
var texture = feature.texture;
var _ref3 = iconMap[texture] || {
x: 0,
y: 0
},
x = _ref3.x,
y = _ref3.y;
return [x, y];
x = _ref3.x,
y = _ref3.y;
return [x, y];
}
};
featureLayout = {
sizePerElement: 0,
elements: []
};
verticesNum = 0;
indices = [];
size = 3;
features.forEach(function (feature, featureIdx) {
var _triangulation = triangulation(feature),
indicesForCurrentFeature = _triangulation.indices,
verticesForCurrentFeature = _triangulation.vertices,
normalsForCurrentFeature = _triangulation.normals,
vertexSize = _triangulation.size,
indexes = _triangulation.indexes;
indicesForCurrentFeature.forEach(function (i) {
indices.push(i + verticesNum);
});
size = vertexSize;
var verticesNumForCurrentFeature = verticesForCurrentFeature.length / vertexSize;
featureLayout.sizePerElement = size;
featureLayout.elements.push({
featureIdx: featureIdx,
vertices: verticesForCurrentFeature,
normals: normalsForCurrentFeature,
offset: verticesNum
});
verticesNum += verticesNumForCurrentFeature;
var _loop = function _loop(vertexIdx) {
var normal = (normalsForCurrentFeature === null || normalsForCurrentFeature === void 0 ? void 0 : normalsForCurrentFeature.slice(vertexIdx * 3, vertexIdx * 3 + 3)) || [];
var vertice = verticesForCurrentFeature.slice(vertexIdx * vertexSize, vertexIdx * vertexSize + vertexSize);
var vertexIndex = 0;
if (indexes && indexes[vertexIdx] !== undefined) {
vertexIndex = indexes[vertexIdx];
}
descriptors.forEach(function (descriptor) {
// @ts-ignore
if (descriptor && updateFuncs[descriptor.name]) {
var _descriptor$buffer$da;
// @ts-ignore
(_descriptor$buffer$da = descriptor.buffer.data).push.apply(_descriptor$buffer$da, _toConsumableArray(updateFuncs[descriptor.name](feature, featureIdx, vertice, vertexIdx, normal, vertexIndex)));
}
});
};
featureLayout = {
sizePerElement: 0,
elements: []
};
verticesNum = 0;
indices = [];
size = 3;
features.forEach(function (feature, featureIdx) {
var _triangulation = triangulation(feature),
indicesForCurrentFeature = _triangulation.indices,
verticesForCurrentFeature = _triangulation.vertices,
normalsForCurrentFeature = _triangulation.normals,
vertexSize = _triangulation.size,
indexes = _triangulation.indexes;
indicesForCurrentFeature.forEach(function (i) {
indices.push(i + verticesNum);
});
size = vertexSize;
var verticesNumForCurrentFeature = verticesForCurrentFeature.length / vertexSize;
featureLayout.sizePerElement = size;
featureLayout.elements.push({
featureIdx: featureIdx,
vertices: verticesForCurrentFeature,
normals: normalsForCurrentFeature,
offset: verticesNum
});
verticesNum += verticesNumForCurrentFeature;
var _loop = function _loop(vertexIdx) {
var normal = (normalsForCurrentFeature === null || normalsForCurrentFeature === void 0 ? void 0 : normalsForCurrentFeature.slice(vertexIdx * 3, vertexIdx * 3 + 3)) || [];
var vertice = verticesForCurrentFeature.slice(vertexIdx * vertexSize, vertexIdx * vertexSize + vertexSize);
var vertexIndex = 0;
if (indexes && indexes[vertexIdx] !== undefined) {
vertexIndex = indexes[vertexIdx];
}
descriptors.forEach(function (descriptor) {
// @ts-ignore
if (descriptor && updateFuncs[descriptor.name]) {
var _descriptor$buffer$da;
// @ts-ignore
(_descriptor$buffer$da = descriptor.buffer.data).push.apply(_descriptor$buffer$da, _toConsumableArray(updateFuncs[descriptor.name](feature, featureIdx, vertice, vertexIdx, normal, vertexIndex)));
}
});
};
for (var vertexIdx = 0; vertexIdx < verticesNumForCurrentFeature; vertexIdx++) {
_loop(vertexIdx);
}
});
return _context.abrupt("return", {
descriptors: descriptors,
featureLayout: featureLayout,
indices: indices
});
case 8:
case "end":
return _context.stop();
}
for (var vertexIdx = 0; vertexIdx < verticesNumForCurrentFeature; vertexIdx++) {
_loop(vertexIdx);
}
});
return _context.abrupt("return", {
descriptors: descriptors,
featureLayout: featureLayout,
indices: indices
});
case 8:
case "end":
return _context.stop();
}
}, _callee);
}));
return function lineModel(_x) {

@@ -125,0 +113,0 @@ return _ref2.apply(this, arguments);

@@ -11,101 +11,91 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";

return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
descriptors = _ref.descriptors, features = _ref.features, enablePicking = _ref.enablePicking, shape2d = _ref.shape2d;
updateFuncs = {
// fixed feature func
a_Color: a_Color,
a_Position: a_Position,
filter: a_filter,
a_vertexId: a_vertexId,
a_PickingColor: function a_PickingColor(feature) {
var id = feature.id;
return enablePicking ? encodePickingColor(id) : [0, 0, 0];
},
// pointFill feature func
a_Shape: function a_Shape(feature) {
var _feature$shape = feature.shape,
shape = _feature$shape === void 0 ? 2 : _feature$shape;
var shapeIndex = shape2d.indexOf(shape);
return [shapeIndex];
},
a_Extrude: function a_Extrude(feature, featureIdx, vertex, attributeIdx) {
var extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];
var extrudeIndex = attributeIdx % 4 * 3;
return [extrude[extrudeIndex], extrude[extrudeIndex + 1], extrude[extrudeIndex + 2]];
},
a_Size: function a_Size(feature) {
var _feature$size = feature.size,
pointSize = _feature$size === void 0 ? 5 : _feature$size;
return Array.isArray(pointSize) ? [pointSize[0]] : [pointSize];
while (1) switch (_context.prev = _context.next) {
case 0:
descriptors = _ref.descriptors, features = _ref.features, enablePicking = _ref.enablePicking, shape2d = _ref.shape2d;
updateFuncs = {
// fixed feature func
a_Color: a_Color,
a_Position: a_Position,
filter: a_filter,
a_vertexId: a_vertexId,
a_PickingColor: function a_PickingColor(feature) {
var id = feature.id;
return enablePicking ? encodePickingColor(id) : [0, 0, 0];
},
// pointFill feature func
a_Shape: function a_Shape(feature) {
var _feature$shape = feature.shape,
shape = _feature$shape === void 0 ? 2 : _feature$shape;
var shapeIndex = shape2d.indexOf(shape);
return [shapeIndex];
},
a_Extrude: function a_Extrude(feature, featureIdx, vertex, attributeIdx) {
var extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];
var extrudeIndex = attributeIdx % 4 * 3;
return [extrude[extrudeIndex], extrude[extrudeIndex + 1], extrude[extrudeIndex + 2]];
},
a_Size: function a_Size(feature) {
var _feature$size = feature.size,
pointSize = _feature$size === void 0 ? 5 : _feature$size;
return Array.isArray(pointSize) ? [pointSize[0]] : [pointSize];
}
};
featureLayout = {
sizePerElement: 0,
elements: []
};
verticesNum = 0;
indices = [];
size = 3;
features.forEach(function (feature, featureIdx) {
var _triangulation = triangulation(feature),
indicesForCurrentFeature = _triangulation.indices,
verticesForCurrentFeature = _triangulation.vertices,
normalsForCurrentFeature = _triangulation.normals,
vertexSize = _triangulation.size,
indexes = _triangulation.indexes;
indicesForCurrentFeature.forEach(function (i) {
indices.push(i + verticesNum);
});
size = vertexSize;
var verticesNumForCurrentFeature = verticesForCurrentFeature.length / vertexSize;
featureLayout.sizePerElement = size;
featureLayout.elements.push({
featureIdx: featureIdx,
vertices: verticesForCurrentFeature,
normals: normalsForCurrentFeature,
offset: verticesNum
});
verticesNum += verticesNumForCurrentFeature;
var _loop = function _loop(vertexIdx) {
var normal = (normalsForCurrentFeature === null || normalsForCurrentFeature === void 0 ? void 0 : normalsForCurrentFeature.slice(vertexIdx * 3, vertexIdx * 3 + 3)) || [];
var vertice = verticesForCurrentFeature.slice(vertexIdx * vertexSize, vertexIdx * vertexSize + vertexSize);
var vertexIndex = 0;
if (indexes && indexes[vertexIdx] !== undefined) {
vertexIndex = indexes[vertexIdx];
}
descriptors.forEach(function (descriptor) {
// @ts-ignore
if (descriptor && updateFuncs[descriptor.name]) {
var _descriptor$buffer$da;
// @ts-ignore
(_descriptor$buffer$da = descriptor.buffer.data).push.apply(_descriptor$buffer$da, _toConsumableArray(updateFuncs[descriptor.name](feature, featureIdx, vertice, vertexIdx, normal, vertexIndex)));
}
});
};
featureLayout = {
sizePerElement: 0,
elements: []
};
verticesNum = 0;
indices = [];
size = 3;
features.forEach(function (feature, featureIdx) {
var _triangulation = triangulation(feature),
indicesForCurrentFeature = _triangulation.indices,
verticesForCurrentFeature = _triangulation.vertices,
normalsForCurrentFeature = _triangulation.normals,
vertexSize = _triangulation.size,
indexes = _triangulation.indexes;
indicesForCurrentFeature.forEach(function (i) {
indices.push(i + verticesNum);
});
size = vertexSize;
var verticesNumForCurrentFeature = verticesForCurrentFeature.length / vertexSize;
featureLayout.sizePerElement = size;
featureLayout.elements.push({
featureIdx: featureIdx,
vertices: verticesForCurrentFeature,
normals: normalsForCurrentFeature,
offset: verticesNum
});
verticesNum += verticesNumForCurrentFeature;
var _loop = function _loop(vertexIdx) {
var normal = (normalsForCurrentFeature === null || normalsForCurrentFeature === void 0 ? void 0 : normalsForCurrentFeature.slice(vertexIdx * 3, vertexIdx * 3 + 3)) || [];
var vertice = verticesForCurrentFeature.slice(vertexIdx * vertexSize, vertexIdx * vertexSize + vertexSize);
var vertexIndex = 0;
if (indexes && indexes[vertexIdx] !== undefined) {
vertexIndex = indexes[vertexIdx];
}
descriptors.forEach(function (descriptor) {
// @ts-ignore
if (descriptor && updateFuncs[descriptor.name]) {
var _descriptor$buffer$da;
// @ts-ignore
(_descriptor$buffer$da = descriptor.buffer.data).push.apply(_descriptor$buffer$da, _toConsumableArray(updateFuncs[descriptor.name](feature, featureIdx, vertice, vertexIdx, normal, vertexIndex)));
}
});
};
for (var vertexIdx = 0; vertexIdx < verticesNumForCurrentFeature; vertexIdx++) {
_loop(vertexIdx);
}
});
return _context.abrupt("return", {
descriptors: descriptors,
featureLayout: featureLayout,
indices: indices
});
case 8:
case "end":
return _context.stop();
}
for (var vertexIdx = 0; vertexIdx < verticesNumForCurrentFeature; vertexIdx++) {
_loop(vertexIdx);
}
});
return _context.abrupt("return", {
descriptors: descriptors,
featureLayout: featureLayout,
indices: indices
});
case 8:
case "end":
return _context.stop();
}
}, _callee);
}));
return function pointFillModel(_x) {

@@ -112,0 +102,0 @@ return _ref2.apply(this, arguments);

@@ -11,86 +11,77 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";

return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
descriptors = _ref.descriptors, features = _ref.features, enablePicking = _ref.enablePicking;
updateFuncs = {
// fixed feature func
a_Color: a_Color,
a_Position: a_Position,
filter: a_filter,
a_vertexId: a_vertexId,
a_PickingColor: function a_PickingColor(feature) {
var id = feature.id;
return enablePicking ? encodePickingColor(id) : [0, 0, 0];
} // polygonFill feature func
// empty
while (1) switch (_context.prev = _context.next) {
case 0:
descriptors = _ref.descriptors, features = _ref.features, enablePicking = _ref.enablePicking;
updateFuncs = {
// fixed feature func
a_Color: a_Color,
a_Position: a_Position,
filter: a_filter,
a_vertexId: a_vertexId,
a_PickingColor: function a_PickingColor(feature) {
var id = feature.id;
return enablePicking ? encodePickingColor(id) : [0, 0, 0];
}
};
featureLayout = {
sizePerElement: 0,
elements: []
};
verticesNum = 0;
indices = [];
size = 3;
features.forEach(function (feature, featureIdx) {
var _triangulation = triangulation(feature),
indicesForCurrentFeature = _triangulation.indices,
verticesForCurrentFeature = _triangulation.vertices,
normalsForCurrentFeature = _triangulation.normals,
vertexSize = _triangulation.size,
indexes = _triangulation.indexes;
indicesForCurrentFeature.forEach(function (i) {
indices.push(i + verticesNum);
});
size = vertexSize;
var verticesNumForCurrentFeature = verticesForCurrentFeature.length / vertexSize;
featureLayout.sizePerElement = size;
featureLayout.elements.push({
featureIdx: featureIdx,
vertices: verticesForCurrentFeature,
normals: normalsForCurrentFeature,
offset: verticesNum
});
verticesNum += verticesNumForCurrentFeature;
var _loop = function _loop(vertexIdx) {
var normal = (normalsForCurrentFeature === null || normalsForCurrentFeature === void 0 ? void 0 : normalsForCurrentFeature.slice(vertexIdx * 3, vertexIdx * 3 + 3)) || [];
var vertice = verticesForCurrentFeature.slice(vertexIdx * vertexSize, vertexIdx * vertexSize + vertexSize);
var vertexIndex = 0;
if (indexes && indexes[vertexIdx] !== undefined) {
vertexIndex = indexes[vertexIdx];
}
descriptors.forEach(function (descriptor) {
// @ts-ignore
if (descriptor && updateFuncs[descriptor.name]) {
var _descriptor$buffer$da;
// @ts-ignore
(_descriptor$buffer$da = descriptor.buffer.data).push.apply(_descriptor$buffer$da, _toConsumableArray(updateFuncs[descriptor.name](feature, featureIdx, vertice, vertexIdx, normal, vertexIndex)));
}
});
};
for (var vertexIdx = 0; vertexIdx < verticesNumForCurrentFeature; vertexIdx++) {
_loop(vertexIdx);
}
// polygonFill feature func
// empty
};
featureLayout = {
sizePerElement: 0,
elements: []
};
verticesNum = 0;
indices = [];
size = 3;
features.forEach(function (feature, featureIdx) {
var _triangulation = triangulation(feature),
indicesForCurrentFeature = _triangulation.indices,
verticesForCurrentFeature = _triangulation.vertices,
normalsForCurrentFeature = _triangulation.normals,
vertexSize = _triangulation.size,
indexes = _triangulation.indexes;
indicesForCurrentFeature.forEach(function (i) {
indices.push(i + verticesNum);
});
return _context.abrupt("return", {
descriptors: descriptors,
featureLayout: featureLayout,
indices: indices
size = vertexSize;
var verticesNumForCurrentFeature = verticesForCurrentFeature.length / vertexSize;
featureLayout.sizePerElement = size;
featureLayout.elements.push({
featureIdx: featureIdx,
vertices: verticesForCurrentFeature,
normals: normalsForCurrentFeature,
offset: verticesNum
});
case 8:
case "end":
return _context.stop();
}
verticesNum += verticesNumForCurrentFeature;
var _loop = function _loop(vertexIdx) {
var normal = (normalsForCurrentFeature === null || normalsForCurrentFeature === void 0 ? void 0 : normalsForCurrentFeature.slice(vertexIdx * 3, vertexIdx * 3 + 3)) || [];
var vertice = verticesForCurrentFeature.slice(vertexIdx * vertexSize, vertexIdx * vertexSize + vertexSize);
var vertexIndex = 0;
if (indexes && indexes[vertexIdx] !== undefined) {
vertexIndex = indexes[vertexIdx];
}
descriptors.forEach(function (descriptor) {
// @ts-ignore
if (descriptor && updateFuncs[descriptor.name]) {
var _descriptor$buffer$da;
// @ts-ignore
(_descriptor$buffer$da = descriptor.buffer.data).push.apply(_descriptor$buffer$da, _toConsumableArray(updateFuncs[descriptor.name](feature, featureIdx, vertice, vertexIdx, normal, vertexIndex)));
}
});
};
for (var vertexIdx = 0; vertexIdx < verticesNumForCurrentFeature; vertexIdx++) {
_loop(vertexIdx);
}
});
return _context.abrupt("return", {
descriptors: descriptors,
featureLayout: featureLayout,
indices: indices
});
case 8:
case "end":
return _context.stop();
}
}, _callee);
}));
return function polygonFillModel(_x) {

@@ -97,0 +88,0 @@ return _ref2.apply(this, arguments);

@@ -8,4 +8,5 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";

var coordinates = feature.coordinates,
originCoordinates = feature.originCoordinates,
version = feature.version; // let path = coordinates as number[][][] | number[][];
originCoordinates = feature.originCoordinates,
version = feature.version;
// let path = coordinates as number[][][] | number[][];
// if (!Array.isArray(path[0][0])) {

@@ -19,17 +20,12 @@ // path = [coordinates] as number[][][];

});
if (version === 'GAODE2.x') {
// 处理高德2.0几何体构建
var path1 = coordinates; // 计算位置
if (!Array.isArray(path1[0][0])) {
path1 = [coordinates];
}
var path2 = originCoordinates; // 计算法线
if (!Array.isArray(path2[0][0])) {
path2 = [originCoordinates];
}
for (var i = 0; i < path1.length; i++) {

@@ -44,7 +40,5 @@ // 高德2.0在计算线时,需要使用经纬度计算发现,使用 customCoords.lnglatToCoords 计算的数据来计算顶点的位置

var path = coordinates;
if (path[0] && !Array.isArray(path[0][0])) {
path = [coordinates];
}
path.forEach(function (item) {

@@ -54,3 +48,2 @@ line.extrude(item);

}
var linebuffer = line.complex;

@@ -78,4 +71,5 @@ return {

var vertices = flattengeo.vertices,
dimensions = flattengeo.dimensions,
holes = flattengeo.holes; // if (version !== 'GAODE2.x') {
dimensions = flattengeo.dimensions,
holes = flattengeo.holes;
// if (version !== 'GAODE2.x') {
// for (let i = 0; i < vertices.length; i += dimensions) {

@@ -88,4 +82,4 @@ // const mer = project_mercator(vertices[i + 0], vertices[i + 1]);

// https://github.com/mapbox/earcut/issues/159
var triangles = earcut(vertices, holes, dimensions); // if (version !== 'GAODE2.x') {
var triangles = earcut(vertices, holes, dimensions);
// if (version !== 'GAODE2.x') {
// for (let i = 0; i < vertices.length; i += dimensions) {

@@ -104,19 +98,14 @@ // const ll = mercator_lnglat(vertices[i + 0], vertices[i + 1]);

}
function project_mercator(x, y) {
var y1 = y;
if (y > LATMAX) {
y1 = LATMAX;
}
if (y < -LATMAX) {
y1 = -LATMAX;
}
return [Math.PI * x / 180 + Math.PI, Math.PI - Math.log(Math.tan(Math.PI * 0.25 + Math.PI * y1 / 180 * 0.5))];
}
function mercator_lnglat(x, y) {
return [(x - Math.PI) * 180 / Math.PI, (Math.atan(Math.exp(Math.PI - y)) - Math.PI * 0.25) * 2 * 180 / Math.PI];
}

@@ -34,3 +34,2 @@ var __defProp = Object.defineProperty;

var import_config = require("./config");
var import_mini_adapter = require("./mini-adapter");
var getProtocolAction = (url) => import_config.SceneConifg.REGISTERED_PROTOCOLS[url.substring(0, url.indexOf("://"))];

@@ -47,3 +46,3 @@ var AJAXError = class extends Error {

function makeXMLHttpRequest(requestParameters, callback) {
const xhr = new import_mini_adapter.$XMLHttpRequest();
const xhr = new XMLHttpRequest();
const url = Array.isArray(requestParameters.url) ? requestParameters.url[0] : requestParameters.url;

@@ -134,10 +133,10 @@ xhr.open(requestParameters.method || "GET", url, true);

function sameOrigin(url) {
const a = import_mini_adapter.$window.document.createElement("a");
const a = window.document.createElement("a");
a.href = url;
return a.protocol === import_mini_adapter.$window.document.location.protocol && a.host === import_mini_adapter.$window.document.location.host;
return a.protocol === window.document.location.protocol && a.host === window.document.location.host;
}
var transparentPngUrl = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";
function arrayBufferToImage(data, callback) {
const img = new import_mini_adapter.$window.Image();
const URL = import_mini_adapter.$window.URL || import_mini_adapter.$window.webkitURL;
const img = new window.Image();
const URL = window.URL || window.webkitURL;
img.crossOrigin = "anonymous";

@@ -144,0 +143,0 @@ img.onload = () => {

@@ -45,3 +45,2 @@ var __create = Object.create;

var d3 = __toESM(require("d3-color"));
var import_mini_adapter = require("./mini-adapter");
function isColor(str) {

@@ -80,3 +79,3 @@ if (typeof str === "string") {

function generateColorRamp(colorRamp) {
let canvas = import_mini_adapter.$window.document.createElement("canvas");
let canvas = window.document.createElement("canvas");
let ctx = canvas.getContext("2d");

@@ -95,23 +94,9 @@ canvas.width = 256;

ctx.fillRect(0, 0, 256, 1);
if (!import_mini_adapter.isMini) {
data = ctx.getImageData(0, 0, 256, 1).data;
const imageData = ctx.createImageData(256, 1);
for (let i = 0; i < imageData.data.length; i += 4) {
imageData.data[i + 0] = data[i + 0];
imageData.data[i + 1] = data[i + 1];
imageData.data[i + 2] = data[i + 2];
imageData.data[i + 3] = data[i + 3];
}
canvas = null;
ctx = null;
return imageData;
} else {
data = new Uint8ClampedArray(ctx.getImageData(0, 0, 256, 1).data);
canvas = null;
ctx = null;
return { data, width: 256, height: 1 };
}
data = new Uint8ClampedArray(ctx.getImageData(0, 0, 256, 1).data);
canvas = null;
ctx = null;
return { data, width: 256, height: 1 };
}
function generateLinearRamp(colorRamp, domain) {
let canvas = import_mini_adapter.$window.document.createElement("canvas");
let canvas = window.document.createElement("canvas");
let ctx = canvas.getContext("2d");

@@ -135,3 +120,3 @@ canvas.width = 256;

function generateCatRamp(colorRamp) {
let canvas = import_mini_adapter.$window.document.createElement("canvas");
let canvas = window.document.createElement("canvas");
let ctx = canvas.getContext("2d");

@@ -154,3 +139,3 @@ canvas.width = 256;

function generateQuantizeRamp(colorRamp) {
let canvas = import_mini_adapter.$window.document.createElement("canvas");
let canvas = window.document.createElement("canvas");
let ctx = canvas.getContext("2d");

@@ -176,3 +161,3 @@ ctx.globalAlpha = 1;

function generateCustomRamp(colorRamp, domain) {
let canvas = import_mini_adapter.$window.document.createElement("canvas");
let canvas = window.document.createElement("canvas");
let ctx = canvas.getContext("2d");

@@ -179,0 +164,0 @@ ctx.globalAlpha = 1;

@@ -49,8 +49,8 @@ var __defProp = Object.defineProperty;

module.exports = __toCommonJS(dom_exports);
var import_lodash = require("lodash");
var import_mini_adapter = require("./mini-adapter");
var import_lodash_adapter = require("./lodash-adapter");
var { pull } = import_lodash_adapter.lodashUtil;
function getContainer(domId) {
let $dom = domId;
if (typeof domId === "string") {
$dom = import_mini_adapter.$window.document.getElementById(domId);
$dom = window.document.getElementById(domId);
}

@@ -66,4 +66,4 @@ return $dom;

function testProp(props) {
var _a, _b, _c;
const docStyle = (_c = (_b = (_a = import_mini_adapter.$window) == null ? void 0 : _a.document) == null ? void 0 : _b.documentElement) == null ? void 0 : _c.style;
var _a, _b;
const docStyle = (_b = (_a = window == null ? void 0 : window.document) == null ? void 0 : _a.documentElement) == null ? void 0 : _b.style;
if (!docStyle) {

@@ -80,3 +80,3 @@ return props[0];

function create(tagName, className, container) {
const el = import_mini_adapter.$window.document.createElement(tagName);
const el = window.document.createElement(tagName);
if (className) {

@@ -151,7 +151,7 @@ el.className = className || "";

if (typeof Event === "function") {
import_mini_adapter.$window.dispatchEvent(new Event("resize"));
window.dispatchEvent(new Event("resize"));
} else {
const evt = import_mini_adapter.$window.document.createEvent("UIEvents");
evt.initUIEvent("resize", true, false, import_mini_adapter.$window, 0);
import_mini_adapter.$window.dispatchEvent(evt);
const evt = window.document.createEvent("UIEvents");
evt.initUIEvent("resize", true, false, window, 0);
window.dispatchEvent(evt);
}

@@ -169,3 +169,3 @@ }

var _a;
const meta = import_mini_adapter.$window.document.querySelector('meta[name="viewport"]');
const meta = window.document.querySelector('meta[name="viewport"]');
if (!meta) {

@@ -181,3 +181,3 @@ return 1;

}
var DPR = getViewPortScale() < 1 ? 1 : import_mini_adapter.$window.devicePixelRatio;
var DPR = getViewPortScale() < 1 ? 1 : window.devicePixelRatio;
function addStyle(el, style) {

@@ -192,3 +192,3 @@ el.setAttribute("style", `${el.style.cssText}${style}`);

const targetStyleList = getStyleList(style);
const newStyleList = (0, import_lodash.pull)(oldStyleList, ...targetStyleList);
const newStyleList = pull(oldStyleList, ...targetStyleList);
el.setAttribute("style", newStyleList.join(";"));

@@ -195,0 +195,0 @@ }

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

__reExport(src_exports, require("./lineAtOffset"), module.exports);
__reExport(src_exports, require("./lodash-adapter"), module.exports);
__reExport(src_exports, require("./lru_cache"), module.exports);
__reExport(src_exports, require("./mini-adapter/index"), module.exports);
var Satistics = __toESM(require("./statistics"));

@@ -74,4 +74,4 @@ __reExport(src_exports, require("./tileset-manager"), module.exports);

...require("./lineAtOffset"),
...require("./lodash-adapter"),
...require("./lru_cache"),
...require("./mini-adapter/index"),
...require("./tileset-manager"),

@@ -78,0 +78,0 @@ ...require("./worker-helper"),

@@ -37,3 +37,3 @@ var __create = Object.create;

var import_eventemitter3 = __toESM(require("eventemitter3"));
var import_lodash = require("lodash");
var import_lodash_adapter = require("../lodash-adapter");
var import_const = require("./const");

@@ -44,2 +44,3 @@ var import_tile = require("./tile");

var import_lonlat_tile = require("./utils/lonlat-tile");
var { throttle } = import_lodash_adapter.lodashUtil;
var TileEventType = /* @__PURE__ */ ((TileEventType2) => {

@@ -61,3 +62,3 @@ TileEventType2["TilesLoadStart"] = "tiles-load-start";

this.cacheTiles = /* @__PURE__ */ new Map();
this.throttleUpdate = (0, import_lodash.throttle)((zoom, latLonBounds) => {
this.throttleUpdate = throttle((zoom, latLonBounds) => {
this.update(zoom, latLonBounds);

@@ -64,0 +65,0 @@ }, 16);

@@ -1,6 +0,4 @@

var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;

@@ -19,10 +17,2 @@ var __export = (target, all) => {

};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

@@ -39,3 +29,2 @@

var import_web_worker_helper = require("web-worker-helper");
var import_l7_utils_worker = __toESM(require("../../dist/l7-utils.worker.js"));
var import_workers = require("../workers");

@@ -71,3 +60,2 @@ var import_worker_map = require("./worker-map");

}
setL7WorkerSource(import_l7_utils_worker.default);
// Annotate the CommonJS export names for ESM import in node:

@@ -74,0 +62,0 @@ 0 && (module.exports = {

{
"name": "@antv/l7-utils",
"version": "2.17.12",
"version": "2.18.0",
"description": "",

@@ -42,3 +42,3 @@ "main": "lib/index.js",

},
"gitHead": "e1d345d25c580a3a44b79a112654d12953293fe6",
"gitHead": "1188476199fa8c47f21ef8e6cba36a82ca715006",
"publishConfig": {

@@ -45,0 +45,0 @@ "access": "public"

Sorry, the diff of this file is too big to display

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