mirror of https://gitee.com/antv-l7/antv-l7
fix: fix code tslint err (#1436)
Co-authored-by: shihui <yiqianyao.yqy@alibaba-inc.com>
This commit is contained in:
parent
7d09373950
commit
b3f81b04e7
|
@ -89,8 +89,8 @@ export default () => {
|
|||
.source(midPoints, {
|
||||
parser: {
|
||||
type: 'json',
|
||||
x: '_lng',
|
||||
y: '_lat',
|
||||
x: 'lng',
|
||||
y: 'lat',
|
||||
},
|
||||
})
|
||||
.shape('circle')
|
||||
|
@ -114,8 +114,8 @@ export default () => {
|
|||
.source(midPoints, {
|
||||
parser: {
|
||||
type: 'json',
|
||||
x: '_lng',
|
||||
y: '_lat',
|
||||
x: 'lng',
|
||||
y: 'lat',
|
||||
},
|
||||
})
|
||||
.shape('circle')
|
||||
|
|
|
@ -88,8 +88,8 @@ export default () => {
|
|||
.source(midPoints, {
|
||||
parser: {
|
||||
type: 'json',
|
||||
x: '_lng',
|
||||
y: '_lat',
|
||||
x: 'lng',
|
||||
y: 'lat',
|
||||
},
|
||||
})
|
||||
.shape('circle')
|
||||
|
@ -109,8 +109,8 @@ export default () => {
|
|||
.source(midPoints, {
|
||||
parser: {
|
||||
type: 'json',
|
||||
x: '_lng',
|
||||
y: '_lat',
|
||||
x: 'lng',
|
||||
y: 'lat',
|
||||
},
|
||||
})
|
||||
.shape('circle')
|
||||
|
|
|
@ -88,8 +88,8 @@ export default () => {
|
|||
.source(midPoints, {
|
||||
parser: {
|
||||
type: 'json',
|
||||
x: '_lng',
|
||||
y: '_lat',
|
||||
x: 'lng',
|
||||
y: 'lat',
|
||||
},
|
||||
})
|
||||
.shape('circle')
|
||||
|
@ -111,8 +111,8 @@ export default () => {
|
|||
.source(midPoints, {
|
||||
parser: {
|
||||
type: 'json',
|
||||
x: '_lng',
|
||||
y: '_lat',
|
||||
x: 'lng',
|
||||
y: 'lat',
|
||||
},
|
||||
})
|
||||
.shape('circle')
|
||||
|
|
|
@ -20,7 +20,9 @@ export default class CanvasLayer extends BaseLayer<ICanvasLayerStyleOptions> {
|
|||
|
||||
public hide(): ILayer {
|
||||
// 清除画布
|
||||
this.layerModel.clearCanvas && this.layerModel?.clearCanvas();
|
||||
if (this.layerModel.clearCanvas) {
|
||||
this.layerModel.clearCanvas();
|
||||
}
|
||||
|
||||
this.updateLayerConfig({
|
||||
visible: false,
|
||||
|
|
|
@ -1055,8 +1055,9 @@ export default class BaseLayer<ChildLayerStyleOptions = {}>
|
|||
if (this.coordCenter === undefined) {
|
||||
const layerCenter = this.layerSource.center;
|
||||
this.coordCenter = layerCenter;
|
||||
this.mapService?.setCoordCenter &&
|
||||
if (this.mapService.setCoordCenter) {
|
||||
this.mapService.setCoordCenter(layerCenter);
|
||||
}
|
||||
}
|
||||
this.sourceEvent();
|
||||
});
|
||||
|
@ -1407,7 +1408,9 @@ export default class BaseLayer<ChildLayerStyleOptions = {}>
|
|||
}
|
||||
|
||||
protected reRender() {
|
||||
this.inited && this.layerService.reRender();
|
||||
if (this.inited) {
|
||||
this.layerService.reRender();
|
||||
}
|
||||
}
|
||||
protected splitValuesAndCallbackInAttribute(
|
||||
valuesOrCallback?: unknown[],
|
||||
|
|
|
@ -8,12 +8,13 @@ export default class LayerAnimateStylePlugin implements ILayerPlugin {
|
|||
layer.hooks.beforeRender.tap('LayerAnimateStylePlugin', () => {
|
||||
// @ts-ignore
|
||||
const animateStatus = layer.animateStatus;
|
||||
animateStatus &&
|
||||
if (animateStatus) {
|
||||
layer.models.forEach((model: IModel) => {
|
||||
model.addUniforms({
|
||||
...layer.layerModel.getAnimateUniforms(),
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,8 @@ export default class ShaderUniformPlugin implements ILayerPlugin {
|
|||
if (layer.coordCenter === undefined) {
|
||||
layer.coordCenter = layer.getSource().center;
|
||||
}
|
||||
this.mapService.setCoordCenter &&
|
||||
if (this.mapService.setCoordCenter) {
|
||||
this.mapService.setCoordCenter(layer.coordCenter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,8 +26,9 @@ export default class UpdateStyleAttributePlugin implements ILayerPlugin {
|
|||
) {
|
||||
return;
|
||||
}
|
||||
layer.modelLoaded &&
|
||||
if (layer.modelLoaded) {
|
||||
this.updateStyleAttribute(layer, { styleAttributeService });
|
||||
}
|
||||
});
|
||||
}
|
||||
private updateStyleAttribute(
|
||||
|
|
|
@ -206,7 +206,9 @@ export default class ReglModel implements IModel {
|
|||
if (!pick) {
|
||||
this.drawCommand(reglDrawProps);
|
||||
} else {
|
||||
this.drawPickCommand && this.drawPickCommand(reglDrawProps);
|
||||
if (this.drawPickCommand) {
|
||||
this.drawPickCommand(reglDrawProps);
|
||||
}
|
||||
}
|
||||
// this.drawCommand(reglDrawProps);
|
||||
// this.drawPickCommand(reglDrawProps);
|
||||
|
|
|
@ -87,8 +87,8 @@ function GetGeoJSON(
|
|||
let j;
|
||||
|
||||
function project(line: any[]) {
|
||||
for (let j = 0; j < line.length; j++) {
|
||||
const p = line[j];
|
||||
for (let index = 0; index < line.length; index++) {
|
||||
const p = line[index];
|
||||
if (p[3]) {
|
||||
// 避免重复计算
|
||||
break;
|
||||
|
@ -97,7 +97,7 @@ function GetGeoJSON(
|
|||
const lng = ((p[0] + x0) * 360) / size - 180;
|
||||
const lat =
|
||||
(360 / Math.PI) * Math.atan(Math.exp((y2 * Math.PI) / 180)) - 90;
|
||||
line[j] = [lng, lat, 0, 1];
|
||||
line[index] = [lng, lat, 0, 1];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,23 +172,26 @@ const getVectorTile = async (
|
|||
);
|
||||
features.push(feature);
|
||||
});
|
||||
type IGeojsonVT = VectorTileLayer & {
|
||||
features: Feature[];
|
||||
};
|
||||
// @ts-ignore
|
||||
const featureCollection: IGeojsonVT = {
|
||||
features,
|
||||
};
|
||||
|
||||
const vectorTile = {
|
||||
const vectorTile: MapboxVectorTile = {
|
||||
layers: {
|
||||
// Tip: fixed SourceLayer Name
|
||||
geojsonvt: {
|
||||
features,
|
||||
} as VectorTileLayer & {
|
||||
features: Feature[];
|
||||
},
|
||||
geojsonvt: featureCollection,
|
||||
},
|
||||
} as MapboxVectorTile;
|
||||
};
|
||||
|
||||
resolve(vectorTile);
|
||||
});
|
||||
};
|
||||
|
||||
function getGeoJSONVTOptions(cfg?: ITileParserCFG) {
|
||||
function getOption(cfg?: ITileParserCFG) {
|
||||
const defaultOptions = {
|
||||
// geojson-vt default options
|
||||
maxZoom: 14, // max zoom to preserve detail on
|
||||
|
@ -206,27 +209,7 @@ function getGeoJSONVTOptions(cfg?: ITileParserCFG) {
|
|||
if (cfg === undefined || typeof cfg.geojsonvtOptions === 'undefined') {
|
||||
return defaultOptions;
|
||||
} else {
|
||||
cfg.geojsonvtOptions.maxZoom &&
|
||||
(defaultOptions.maxZoom = cfg.geojsonvtOptions.maxZoom);
|
||||
cfg.geojsonvtOptions.indexMaxZoom &&
|
||||
(defaultOptions.indexMaxZoom = cfg.geojsonvtOptions.indexMaxZoom);
|
||||
cfg.geojsonvtOptions.indexMaxPoints &&
|
||||
(defaultOptions.indexMaxPoints = cfg.geojsonvtOptions.indexMaxPoints);
|
||||
cfg.geojsonvtOptions.tolerance &&
|
||||
(defaultOptions.tolerance = cfg.geojsonvtOptions.tolerance);
|
||||
cfg.geojsonvtOptions.extent &&
|
||||
(defaultOptions.extent = cfg.geojsonvtOptions.extent);
|
||||
cfg.geojsonvtOptions.buffer &&
|
||||
(defaultOptions.buffer = cfg.geojsonvtOptions.buffer);
|
||||
cfg.geojsonvtOptions.lineMetrics &&
|
||||
(defaultOptions.lineMetrics = cfg.geojsonvtOptions.lineMetrics);
|
||||
cfg.geojsonvtOptions.promoteId &&
|
||||
(defaultOptions.promoteId = cfg.geojsonvtOptions.promoteId);
|
||||
cfg.geojsonvtOptions.generateId &&
|
||||
(defaultOptions.generateId = cfg.geojsonvtOptions.generateId);
|
||||
cfg.geojsonvtOptions.debug &&
|
||||
(defaultOptions.debug = cfg.geojsonvtOptions.debug);
|
||||
return defaultOptions;
|
||||
return { ...defaultOptions, ...cfg.geojsonvtOptions };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,7 +217,7 @@ export default function geojsonVTTile(
|
|||
data: FeatureCollection<Geometries, Properties>,
|
||||
cfg: ITileParserCFG,
|
||||
): IParserData {
|
||||
const geojsonOptions = getGeoJSONVTOptions(cfg) as geojsonvt.Options &
|
||||
const geojsonOptions = getOption(cfg) as geojsonvt.Options &
|
||||
IGeojsonvtOptions;
|
||||
|
||||
const extent = geojsonOptions.extent || 4096;
|
||||
|
|
|
@ -33,8 +33,7 @@ export default function json(data: IJsonData, cfg: IParserCfg): IParserData {
|
|||
);
|
||||
})
|
||||
.forEach((col, index) => {
|
||||
const _geometry = { ...col[geometry] };
|
||||
const rewindGeometry = rewind(_geometry, true);
|
||||
const rewindGeometry = rewind({ ...col[geometry] }, true);
|
||||
// multi feature 情况拆分
|
||||
flattenEach(
|
||||
rewindGeometry,
|
||||
|
@ -70,11 +69,13 @@ export default function json(data: IJsonData, cfg: IParserCfg): IParserData {
|
|||
if (Array.isArray(coordinates[0]) && !Array.isArray(coordinates[0][0])) {
|
||||
type = 'LineString';
|
||||
}
|
||||
const geometry = {
|
||||
type,
|
||||
coordinates: [...col[coordinates]],
|
||||
};
|
||||
const rewindGeometry = rewind(geometry, true);
|
||||
const rewindGeometry = rewind(
|
||||
{
|
||||
type,
|
||||
coordinates: [...col[coordinates]],
|
||||
},
|
||||
true,
|
||||
);
|
||||
coords = rewindGeometry.coordinates;
|
||||
} else if (x && y && x1 && y1) {
|
||||
// 起终点数据
|
||||
|
|
|
@ -8,7 +8,9 @@ export default function raster(
|
|||
cfg: IRasterCfg,
|
||||
): IParserData {
|
||||
const { extent, width, height, min, max, format, operation } = cfg;
|
||||
let bandData, rasterWidth, rasterHeight;
|
||||
let bandData;
|
||||
let rasterWidth;
|
||||
let rasterHeight;
|
||||
if (format === undefined || isNumberArray(data)) {
|
||||
// 兼容写法 - 用户直接传入解析完的波段数据
|
||||
bandData = Array.from(data as number[]);
|
||||
|
|
|
@ -8,7 +8,9 @@ export default function rasterRgb(
|
|||
cfg: IRasterCfg,
|
||||
): IParserData {
|
||||
const { extent, width, height, min, max, format, operation } = cfg;
|
||||
let bandData, rasterWidth, rasterHeight;
|
||||
let bandData;
|
||||
let rasterWidth;
|
||||
let rasterHeight;
|
||||
if (format === undefined || isNumberArray(data)) {
|
||||
// 兼容写法 - 用户直接传入解析完的波段数据
|
||||
bandData = Array.from(data as number[]);
|
||||
|
|
|
@ -23,7 +23,7 @@ const getVectorTile = async (tile: Tile): Promise<MapboxVectorTile> => {
|
|||
// | |
|
||||
// minLng/minLat --- maxLng/minLat
|
||||
|
||||
const vectorTile = {
|
||||
const vectorTile: MapboxVectorTile = {
|
||||
layers: {
|
||||
// Tip: fixed SourceLayer Name
|
||||
testTile: ({
|
||||
|
@ -50,7 +50,7 @@ const getVectorTile = async (tile: Tile): Promise<MapboxVectorTile> => {
|
|||
features: Feature[];
|
||||
},
|
||||
},
|
||||
} as MapboxVectorTile;
|
||||
};
|
||||
|
||||
resolve(vectorTile);
|
||||
});
|
||||
|
|
|
@ -10,7 +10,7 @@ const arcSource = {
|
|||
[100.72265625, 27.994401411046148],
|
||||
],
|
||||
offset: 0.3,
|
||||
_id: 0
|
||||
id: 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -31,10 +31,10 @@ describe('lineAtOffset', () => {
|
|||
[ 100.72265625, 27.994401411046148 ]
|
||||
],
|
||||
offset: 0.3,
|
||||
_id: 0,
|
||||
_lng: 99.66757224332352,
|
||||
_lat: 36.507847734146466,
|
||||
_height: 0
|
||||
id: 0,
|
||||
lng: 99.66757224332352,
|
||||
lat: 36.507847734146466,
|
||||
height: 0
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
@ -87,10 +87,10 @@ describe('lineAtOffset', () => {
|
|||
[ 100.72265625, 27.994401411046148 ]
|
||||
],
|
||||
offset: 0.3,
|
||||
_id: 0,
|
||||
_lng: 99.66757224332352,
|
||||
_lat: 36.507847734146466,
|
||||
_height: 0
|
||||
id: 0,
|
||||
lng: 99.66757224332352,
|
||||
lat: 36.507847734146466,
|
||||
height: 0
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
@ -103,10 +103,10 @@ describe('lineAtOffset', () => {
|
|||
[ 100.72265625, 27.994401411046148 ]
|
||||
],
|
||||
offset: 0.3,
|
||||
_id: 0,
|
||||
_lng: 99.72191962749187,
|
||||
_lat: 36.54640697914567,
|
||||
_height: 0
|
||||
id: 0,
|
||||
lng: 99.72191962749187,
|
||||
lat: 36.54640697914567,
|
||||
height: 0
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
@ -118,12 +118,12 @@ describe('lineAtOffset', () => {
|
|||
[ 99.228515625, 37.43997405227057 ],
|
||||
[ 100.72265625, 27.994401411046148 ]
|
||||
],
|
||||
height: 0,
|
||||
id: 0,
|
||||
lat: 36.54640697914567,
|
||||
lng: 99.72191962749187,
|
||||
offset: 0.3,
|
||||
_id: 0,
|
||||
_lng: 99.72191962749187,
|
||||
_lat: 36.54640697914567,
|
||||
_height: 0
|
||||
}
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -135,10 +135,10 @@ describe('lineAtOffset', () => {
|
|||
[ 100.72265625, 27.994401411046148 ]
|
||||
],
|
||||
offset: 0.3,
|
||||
_id: 0,
|
||||
_lng: 99.39897617955312,
|
||||
_lat: 36.46373143064039,
|
||||
_height: undefined
|
||||
id: 0,
|
||||
lng: 99.39897617955312,
|
||||
lat: 36.46373143064039,
|
||||
height: undefined
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
@ -151,10 +151,10 @@ describe('lineAtOffset', () => {
|
|||
[ 100.72265625, 27.994401411046148 ]
|
||||
],
|
||||
offset: 0.3,
|
||||
_id: 0,
|
||||
_lng: 1.7395272931153063,
|
||||
_lat: 0.6371821457776072,
|
||||
_height: 0
|
||||
id: 0,
|
||||
lng: 1.7395272931153063,
|
||||
lat: 0.6371821457776072,
|
||||
height: 0
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
@ -167,10 +167,10 @@ describe('lineAtOffset', () => {
|
|||
[ 100.72265625, 27.994401411046148 ]
|
||||
],
|
||||
offset: 0.3,
|
||||
_id: 0,
|
||||
_lng: 99.3779296875,
|
||||
_lat: 36.495416788148134,
|
||||
_height: 0
|
||||
id: 0,
|
||||
lng: 99.3779296875,
|
||||
lat: 36.495416788148134,
|
||||
height: 0
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
|
|
@ -43,13 +43,13 @@ function bezier3(arr: Point, t: number) {
|
|||
|
||||
function getAngularDist(source: Point, target: Point) {
|
||||
const delta = [source[0] - target[0], source[1] - target[1]];
|
||||
const sin_half_delta = [Math.sin(delta[0] / 2.0), Math.sin(delta[1] / 2.0)]; // Math.sin(delta / 2.0);
|
||||
const sinHalfDelta = [Math.sin(delta[0] / 2.0), Math.sin(delta[1] / 2.0)]; // Math.sin(delta / 2.0);
|
||||
const a =
|
||||
sin_half_delta[1] * sin_half_delta[1] +
|
||||
sinHalfDelta[1] * sinHalfDelta[1] +
|
||||
Math.cos(source[1]) *
|
||||
Math.cos(target[1]) *
|
||||
sin_half_delta[0] *
|
||||
sin_half_delta[0];
|
||||
sinHalfDelta[0] *
|
||||
sinHalfDelta[0];
|
||||
return 2.0 * Math.atan2(Math.sqrt(a), Math.sqrt(1.0 - a));
|
||||
}
|
||||
|
||||
|
@ -77,15 +77,13 @@ export function interpolate(
|
|||
}
|
||||
const a = Math.sin((1.0 - offset) * angularDist) / Math.sin(angularDist);
|
||||
const b = Math.sin(offset * angularDist) / Math.sin(angularDist);
|
||||
const sin_source = [Math.sin(source[0]), Math.sin(source[1])];
|
||||
const cos_source = [Math.cos(source[0]), Math.cos(source[1])];
|
||||
const sin_target = [Math.sin(target[0]), Math.sin(target[1])];
|
||||
const cos_target = [Math.cos(target[0]), Math.cos(target[1])];
|
||||
const x =
|
||||
a * cos_source[1] * cos_source[0] + b * cos_target[1] * cos_target[0];
|
||||
const y =
|
||||
a * cos_source[1] * sin_source[0] + b * cos_target[1] * sin_target[0];
|
||||
const z = a * sin_source[1] + b * sin_target[1];
|
||||
const sinSource = [Math.sin(source[0]), Math.sin(source[1])];
|
||||
const cosSource = [Math.cos(source[0]), Math.cos(source[1])];
|
||||
const sinTarget = [Math.sin(target[0]), Math.sin(target[1])];
|
||||
const cosTarget = [Math.cos(target[0]), Math.cos(target[1])];
|
||||
const x = a * cosSource[1] * cosSource[0] + b * cosTarget[1] * cosTarget[0];
|
||||
const y = a * cosSource[1] * sinSource[0] + b * cosTarget[1] * sinTarget[0];
|
||||
const z = a * sinSource[1] + b * sinTarget[1];
|
||||
return [
|
||||
radiansToDegrees(Math.atan2(y, x)),
|
||||
radiansToDegrees(Math.atan2(z, Math.sqrt(x * x + y * y))),
|
||||
|
|
|
@ -7,7 +7,7 @@ export function lineAtOffset(source: Source, option: ILineAtOffset) {
|
|||
const { featureId } = option;
|
||||
let features = source.data.dataArray;
|
||||
if (typeof featureId === 'number') {
|
||||
features = features.filter(({ _id }: { _id: number }) => _id === featureId);
|
||||
features = features.filter(({ id }: { id: number }) => id === featureId);
|
||||
}
|
||||
return features.map((feature: any) => {
|
||||
const position = getLineOffsetPosition(feature, option);
|
||||
|
@ -46,12 +46,8 @@ function getLineOffsetPosition(feature: any, option: ILineAtOffset) {
|
|||
|
||||
const source = coordinates[0];
|
||||
const target = coordinates[1];
|
||||
let linetheatOffset;
|
||||
if (typeof thetaOffset === 'string') {
|
||||
linetheatOffset = feature[thetaOffset] || 0;
|
||||
} else {
|
||||
linetheatOffset = thetaOffset;
|
||||
}
|
||||
const linetheatOffset =
|
||||
typeof thetaOffset === 'string' ? feature[thetaOffset] || 0 : thetaOffset;
|
||||
|
||||
let calFunc;
|
||||
switch (shape) {
|
||||
|
@ -75,8 +71,8 @@ function getLineOffsetPosition(feature: any, option: ILineAtOffset) {
|
|||
);
|
||||
|
||||
return {
|
||||
_lng: lng,
|
||||
_lat: lat,
|
||||
_height: height,
|
||||
lng,
|
||||
lat,
|
||||
height,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -18,25 +18,25 @@ export function pathLineAtOffset(coords: Point[], offset: number) {
|
|||
});
|
||||
}
|
||||
const offsetDistance = totalDistance * offset;
|
||||
let _lng, _lat;
|
||||
for (let i = 0; i < cachePoints.length; i++) {
|
||||
const currentDistance = cachePoints[i].totalDistance;
|
||||
let lng;
|
||||
let lat;
|
||||
for (const point of cachePoints) {
|
||||
const currentDistance = point.totalDistance;
|
||||
if (currentDistance > offsetDistance) {
|
||||
const p1 = cachePoints[i].p1;
|
||||
const p2 = cachePoints[i].p2;
|
||||
const p1 = point.p1;
|
||||
const p2 = point.p2;
|
||||
const radius =
|
||||
(offsetDistance - cachePoints[i].lastTotalDistance) /
|
||||
cachePoints[i].distance;
|
||||
(offsetDistance - point.lastTotalDistance) / point.distance;
|
||||
const offsetPoint = mixPoint(p2, p1, radius);
|
||||
_lng = offsetPoint[0];
|
||||
_lat = offsetPoint[1];
|
||||
lng = offsetPoint[0];
|
||||
lat = offsetPoint[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return {
|
||||
_lng,
|
||||
_lat,
|
||||
_height: 0,
|
||||
lng,
|
||||
lat,
|
||||
height: 0,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue