mirror of https://gitee.com/antv-l7/antv-l7
fix: 解决冲突问题
This commit is contained in:
commit
d6b684aad2
|
@ -0,0 +1,2 @@
|
|||
### Simple Line
|
||||
<code src="./simpleline.tsx"></code>
|
|
@ -0,0 +1,209 @@
|
|||
import {
|
||||
LineLayer,
|
||||
Scene,
|
||||
// @ts-ignore
|
||||
} from '@antv/l7';
|
||||
// @ts-ignore
|
||||
import { GaodeMap } from '@antv/l7-maps';
|
||||
import React, { useEffect } from 'react';
|
||||
|
||||
function getImageData(img: HTMLImageElement) {
|
||||
const canvas: HTMLCanvasElement = document.createElement('canvas');
|
||||
const ctx = canvas.getContext('2d') as CanvasRenderingContext2D;
|
||||
const { width, height } = img;
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
|
||||
ctx.drawImage(img, 0, 0, width, height);
|
||||
const imageData = ctx.getImageData(0, 0, width, height);
|
||||
|
||||
return imageData;
|
||||
}
|
||||
|
||||
function getLatData(data: number[]) {
|
||||
const size = Math.floor(Math.sqrt(data.length));
|
||||
|
||||
const arr = [];
|
||||
const startLng = 110;
|
||||
const lngStep = 5 / (size - 1);
|
||||
const startLat = 30;
|
||||
const latStep = -5 / (size - 1);
|
||||
for (let i = 0; i < size; i++) {
|
||||
const arr2 = [];
|
||||
for (let j = 0; j < size; j++) {
|
||||
const index = i + j * size;
|
||||
const x = startLng + lngStep * i;
|
||||
const y = startLat + latStep * j;
|
||||
// @ts-ignore
|
||||
arr2.push([x, y, data[index]]);
|
||||
}
|
||||
// @ts-ignore
|
||||
arr.push(arr2);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
function getLngData(data: number[]) {
|
||||
const size = Math.floor(Math.sqrt(data.length));
|
||||
const arr = [];
|
||||
const startLng = 110;
|
||||
const lngStep = 5 / (size - 1);
|
||||
const startLat = 30;
|
||||
const latStep = -5 / (size - 1);
|
||||
|
||||
for (let i = 0; i < size; i++) {
|
||||
const arr2 = [];
|
||||
for (let j = 0; j < size; j++) {
|
||||
const index = i * size + j;
|
||||
const x = startLng + lngStep * j;
|
||||
const y = startLat + latStep * i;
|
||||
// @ts-ignore
|
||||
arr2.push([x, y, data[index]]);
|
||||
}
|
||||
// @ts-ignore
|
||||
arr.push(arr2);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
function getR(data: Uint8ClampedArray) {
|
||||
const arr = [];
|
||||
for (let i = 0; i < data.length; i += 4) {
|
||||
// @ts-ignore
|
||||
arr.push(data[i]);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
export default () => {
|
||||
useEffect(() => {
|
||||
const scene = new Scene({
|
||||
id: 'map',
|
||||
map: new GaodeMap({
|
||||
center: [121.268, 30.3628],
|
||||
pitch: 0,
|
||||
// style: 'blank',
|
||||
zoom: 3,
|
||||
}),
|
||||
});
|
||||
|
||||
const layer = new LineLayer()
|
||||
.source({
|
||||
type: 'FeatureCollection',
|
||||
features: [
|
||||
{
|
||||
type: 'Feature',
|
||||
properties: {},
|
||||
geometry: {
|
||||
type: 'MultiLineString',
|
||||
coordinates: [
|
||||
[
|
||||
[80, 30, 5000],
|
||||
[150, 30, 5000],
|
||||
[150, 10, 5000],
|
||||
],
|
||||
[
|
||||
[120, 50, 5000],
|
||||
[120, 30, 5000],
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'Feature',
|
||||
properties: {},
|
||||
geometry: {
|
||||
type: 'MultiLineString',
|
||||
coordinates: [
|
||||
[
|
||||
[100, 35, 100],
|
||||
[120, 50, 100],
|
||||
[120, 20, 100],
|
||||
[130, 20, 100],
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
// .source([
|
||||
// {
|
||||
// lng1: 120,
|
||||
// lat1: 30,
|
||||
// lng2: 130,
|
||||
// lat2: 30
|
||||
// }
|
||||
// ], {
|
||||
// parser: {
|
||||
// type: 'json',
|
||||
// x: 'lng1',
|
||||
// y: 'lat1',
|
||||
// x1: 'lng2',
|
||||
// y1: 'lat2'
|
||||
// }
|
||||
// })
|
||||
.shape('simple')
|
||||
.color('#f00')
|
||||
.style({
|
||||
vertexHeightScale: 2000,
|
||||
sourceColor: '#f00',
|
||||
targetColor: '#0f0',
|
||||
});
|
||||
|
||||
scene.on('loaded', () => {
|
||||
scene.addLayer(layer);
|
||||
});
|
||||
|
||||
const img: HTMLImageElement = new Image();
|
||||
img.crossOrigin = 'none';
|
||||
img.src =
|
||||
'https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*UkvYRYS5jTAAAAAAAAAAAAAAARQnAQ';
|
||||
img.onload = function() {
|
||||
const data = getImageData(img);
|
||||
const rData = getR(data.data);
|
||||
const d1 = getLngData(rData);
|
||||
const d2 = getLatData(rData);
|
||||
const geoData = {
|
||||
type: 'FeatureCollection',
|
||||
features: [
|
||||
{
|
||||
type: 'Feature',
|
||||
properties: {},
|
||||
geometry: {
|
||||
type: 'MultiLineString',
|
||||
coordinates: d1,
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'Feature',
|
||||
properties: {},
|
||||
geometry: {
|
||||
type: 'MultiLineString',
|
||||
coordinates: d2,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
// console.log(geoData)
|
||||
const layer = new LineLayer({})
|
||||
.source(geoData)
|
||||
.size(1)
|
||||
.shape('simple')
|
||||
.color('#f00')
|
||||
.style({
|
||||
vertexHeightScale: 2000,
|
||||
opacity: 0.4,
|
||||
});
|
||||
scene.addLayer(layer);
|
||||
};
|
||||
}, []);
|
||||
return (
|
||||
<div
|
||||
id="map"
|
||||
style={{
|
||||
height: '500px',
|
||||
position: 'relative',
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
|
@ -49,10 +49,10 @@ module.exports = {
|
|||
coverageReporters: ["html"],
|
||||
coverageThreshold: {
|
||||
global: {
|
||||
branches: 7,
|
||||
branches: 6,
|
||||
functions: 7,
|
||||
lines: 10,
|
||||
statements: 10,
|
||||
lines: 9,
|
||||
statements: 9,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
@ -167,7 +167,7 @@
|
|||
"postbuild": "yarn build:declarations",
|
||||
"build:declarations": "lerna run tsc --stream --no-bail",
|
||||
"lint:fix": "prettier --write packages/**/src/**/*.ts packages/site/docs/api/**/*.md packages/site/docs/api/*.md dev-demos/**/**/*.tsx *.md",
|
||||
"lint:src": "eslint packages/**/src/**/*.ts dev-demos/**/**/*.tsx ",
|
||||
"lint:src": "eslint packages/**/src/ dev-demos/ --ext .ts,.tsx",
|
||||
"lint:examples": "eslint packages/site/examples --fix --ext .js",
|
||||
"lint:css": "stylelint 'packages/**/src/**/*.js{,x}'",
|
||||
"lint": "run-p -c lint:*",
|
||||
|
@ -180,7 +180,7 @@
|
|||
"release-cdn": "antv-bin upload -n @antv/l7",
|
||||
"test": "umi-test",
|
||||
"test-cover": "umi-test --coverage",
|
||||
"cover-viewer": "umi-test --coverage && cd coverage && http-server -p 6001 -o",
|
||||
"test-cover-viewer": "umi-test --coverage && cd coverage && http-server -p 6001 -o",
|
||||
"test-live": "umi-test --watch",
|
||||
"tsc": "tsc",
|
||||
"watch": "yarn clean && yarn worker && lerna run watch --parallel",
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
ILngLat,
|
||||
IMapService,
|
||||
IPoint,
|
||||
IPopup,
|
||||
IPopupOption,
|
||||
ISceneService,
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import { $window, LRUCache } from '@antv/l7-utils';
|
||||
import { inject, injectable } from 'inversify';
|
||||
import { injectable } from 'inversify';
|
||||
import TinySDF from 'l7-tiny-sdf';
|
||||
import 'reflect-metadata';
|
||||
import { buildMapping } from '../../utils/font_util';
|
||||
import {
|
||||
IFontAtlas,
|
||||
IFontMapping,
|
||||
IFontMappingItem,
|
||||
IFontOptions,
|
||||
IFontService,
|
||||
IIconFontGlyph,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { $window } from '@antv/l7-utils';
|
||||
import { EventEmitter } from 'eventemitter3';
|
||||
import { inject, injectable } from 'inversify';
|
||||
import { injectable } from 'inversify';
|
||||
import 'reflect-metadata';
|
||||
import { buildIconMaping } from '../../utils/font_util';
|
||||
import { ITexture2D } from '../renderer/ITexture2D';
|
||||
|
@ -9,7 +9,6 @@ import {
|
|||
IIcon,
|
||||
IICONMap,
|
||||
IIconService,
|
||||
IIconValue,
|
||||
IImage,
|
||||
} from './IIconService';
|
||||
const BUFFER = 3;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { mat4 } from 'gl-matrix';
|
||||
import { inject, injectable } from 'inversify';
|
||||
import { injectable } from 'inversify';
|
||||
import 'reflect-metadata';
|
||||
import { ICameraService, IViewport } from './ICameraService';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { mat3, mat4, quat, vec3, vec4 } from 'gl-matrix';
|
||||
import { mat4, vec3 } from 'gl-matrix';
|
||||
import Camera from './Camera';
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { anchorType } from '@antv/l7-utils';
|
||||
import { Container, injectable } from 'inversify';
|
||||
import { Container } from 'inversify';
|
||||
import { ILngLat, IMapService, IPoint } from '../map/IMapService';
|
||||
import { IPopup } from './IPopupService';
|
||||
export interface IMarkerScene {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { anchorType } from '@antv/l7-utils';
|
||||
import { Container } from 'inversify';
|
||||
import { ILngLat, IMapService } from '../map/IMapService';
|
||||
import { ILngLat } from '../map/IMapService';
|
||||
|
||||
export interface IPopupOption {
|
||||
closeButton: boolean;
|
||||
|
|
|
@ -6,7 +6,6 @@ import {
|
|||
IMarker,
|
||||
IMarkerLayer,
|
||||
IMarkerService,
|
||||
IMarkerServiceCfg,
|
||||
} from './IMarkerService';
|
||||
|
||||
@injectable()
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// import Ajv from 'ajv';
|
||||
import { injectable, postConstruct } from 'inversify';
|
||||
import { injectable } from 'inversify';
|
||||
import { merge } from 'lodash';
|
||||
import 'reflect-metadata';
|
||||
import { ILayerConfig } from '../layer/ILayerService';
|
||||
import { IRenderConfig } from '../renderer/IRendererService';
|
||||
import { IGlobalConfigService, ISceneConfig } from './IConfigService';
|
||||
import WarnInfo, { IWarnInfo } from './warnInfo';
|
||||
import WarnInfo from './warnInfo';
|
||||
|
||||
/**
|
||||
* 场景默认配置项
|
||||
|
|
|
@ -30,7 +30,6 @@ import {
|
|||
IStyleAttribute,
|
||||
IStyleAttributeService,
|
||||
IStyleAttributeUpdateOptions,
|
||||
ScaleAttributeType,
|
||||
StyleAttrField,
|
||||
StyleAttributeField,
|
||||
StyleAttributeOption,
|
||||
|
|
|
@ -4,8 +4,6 @@ import {
|
|||
} from '../renderer/IAttribute';
|
||||
import { IBufferInitializationOptions } from '../renderer/IBuffer';
|
||||
import { IElements } from '../renderer/IElements';
|
||||
import { IParseDataItem, IParserData } from '../source/ISourceService';
|
||||
import { ILayer } from './ILayerService';
|
||||
|
||||
/**
|
||||
* 1. 提供各个 Layer 样式属性初始值的注册服务
|
||||
|
@ -178,6 +176,7 @@ export type Triangulation = (
|
|||
size: number;
|
||||
normals?: number[];
|
||||
indexes?: number[];
|
||||
count?: number;
|
||||
};
|
||||
|
||||
export interface IStyleAttributeUpdateOptions {
|
||||
|
@ -215,6 +214,7 @@ export interface IStyleAttributeService {
|
|||
[attributeName: string]: IAttribute;
|
||||
};
|
||||
elements: IElements;
|
||||
count: number | null;
|
||||
};
|
||||
createAttributesAndIndicesAscy(
|
||||
encodedFeatures: IEncodeFeature[],
|
||||
|
|
|
@ -7,7 +7,7 @@ import Clock from '../../utils/clock';
|
|||
import { IGlobalConfigService } from '../config/IConfigService';
|
||||
import { IMapService } from '../map/IMapService';
|
||||
import { IRendererService } from '../renderer/IRendererService';
|
||||
import { ILayerModel, ILayerService } from './ILayerService';
|
||||
import { ILayerService } from './ILayerService';
|
||||
|
||||
@injectable()
|
||||
export default class LayerService implements ILayerService {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { isNil } from 'lodash';
|
||||
import {
|
||||
IAttributeScale,
|
||||
IScaleOption,
|
||||
IStyleAttribute,
|
||||
StyleScaleType,
|
||||
} from '../layer/IStyleAttributeService';
|
||||
|
@ -11,7 +10,6 @@ import {
|
|||
IEncodeFeature,
|
||||
IFeatureRange,
|
||||
IStyleAttributeInitializationOptions,
|
||||
IStyleScale,
|
||||
IVertexAttributeDescriptor,
|
||||
} from './IStyleAttributeService';
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import { executeWorkerTask } from '@antv/l7-utils';
|
||||
import { inject, injectable, optional } from 'inversify';
|
||||
import { inject, injectable } from 'inversify';
|
||||
import 'reflect-metadata';
|
||||
import { TYPES } from '../../types';
|
||||
import { gl } from '../renderer/gl';
|
||||
import { IAttribute } from '../renderer/IAttribute';
|
||||
import { IElements } from '../renderer/IElements';
|
||||
import { IRendererService } from '../renderer/IRendererService';
|
||||
import { IParseDataItem } from '../source/ISourceService';
|
||||
import { ILayer, IWorkerOption } from './ILayerService';
|
||||
import { IWorkerOption } from './ILayerService';
|
||||
import {
|
||||
IAttributeScale,
|
||||
IEncodeFeature,
|
||||
|
@ -40,6 +39,7 @@ export default class StyleAttributeService implements IStyleAttributeService {
|
|||
[attributeName: string]: IAttribute;
|
||||
};
|
||||
elements: IElements;
|
||||
count: number | null;
|
||||
};
|
||||
@inject(TYPES.IRendererService)
|
||||
private readonly rendererService: IRendererService;
|
||||
|
@ -249,6 +249,7 @@ export default class StyleAttributeService implements IStyleAttributeService {
|
|||
this.attributesAndIndices = {
|
||||
attributes,
|
||||
elements,
|
||||
count: null,
|
||||
};
|
||||
|
||||
resolve(this.attributesAndIndices);
|
||||
|
@ -269,6 +270,7 @@ export default class StyleAttributeService implements IStyleAttributeService {
|
|||
[attributeName: string]: IAttribute;
|
||||
};
|
||||
elements: IElements;
|
||||
count: number | null;
|
||||
} {
|
||||
// 每次创建的初始化化 LayerOut
|
||||
this.featureLayout = {
|
||||
|
@ -283,6 +285,7 @@ export default class StyleAttributeService implements IStyleAttributeService {
|
|||
return attr.descriptor;
|
||||
});
|
||||
let verticesNum = 0;
|
||||
let vecticesCount = 0; // 在不使用 element 的时候记录顶点、图层所有顶点的总数
|
||||
const vertices: number[] = [];
|
||||
const indices: number[] = [];
|
||||
const normals: number[] = [];
|
||||
|
@ -295,7 +298,13 @@ export default class StyleAttributeService implements IStyleAttributeService {
|
|||
normals: normalsForCurrentFeature,
|
||||
size: vertexSize,
|
||||
indexes,
|
||||
count,
|
||||
} = this.triangulation(feature, segmentNumber);
|
||||
|
||||
if (typeof count === 'number') {
|
||||
vecticesCount += count;
|
||||
}
|
||||
|
||||
indicesForCurrentFeature.forEach((i) => {
|
||||
indices.push(i + verticesNum);
|
||||
});
|
||||
|
@ -383,6 +392,7 @@ export default class StyleAttributeService implements IStyleAttributeService {
|
|||
this.attributesAndIndices = {
|
||||
attributes,
|
||||
elements,
|
||||
count: vecticesCount,
|
||||
};
|
||||
return this.attributesAndIndices;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { ILayer } from '../layer/ILayerService';
|
||||
import { IAttribute, IAttributeInitializationOptions } from './IAttribute';
|
||||
import { IBuffer, IBufferInitializationOptions } from './IBuffer';
|
||||
import { IElements, IElementsInitializationOptions } from './IElements';
|
||||
|
@ -7,7 +6,7 @@ import {
|
|||
IFramebufferInitializationOptions,
|
||||
} from './IFramebuffer';
|
||||
import { IModel, IModelInitializationOptions } from './IModel';
|
||||
import { IMultiPassRenderer, IPass } from './IMultiPassRenderer';
|
||||
import { IPass } from './IMultiPassRenderer';
|
||||
import { ITexture2D, ITexture2DInitializationOptions } from './ITexture2D';
|
||||
|
||||
export interface IRenderConfig {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { inject, injectable } from 'inversify';
|
||||
import { injectable } from 'inversify';
|
||||
import 'reflect-metadata';
|
||||
import { TYPES } from '../../../types';
|
||||
import { ICameraService } from '../../camera/ICameraService';
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { decodePickingColor, DOM, encodePickingColor } from '@antv/l7-utils';
|
||||
import { inject, injectable } from 'inversify';
|
||||
import { injectable } from 'inversify';
|
||||
import 'reflect-metadata';
|
||||
import { TYPES } from '../../../types';
|
||||
import {
|
||||
IInteractionTarget,
|
||||
InteractionEvent,
|
||||
|
|
|
@ -22,7 +22,7 @@ import {
|
|||
} from '../interaction/IInteractionService';
|
||||
import { IPickingService } from '../interaction/IPickingService';
|
||||
import { ILayer, ILayerService } from '../layer/ILayerService';
|
||||
import { IMapCamera, IMapConfig, IMapService } from '../map/IMapService';
|
||||
import { IMapService } from '../map/IMapService';
|
||||
import { IRenderConfig, IRendererService } from '../renderer/IRendererService';
|
||||
import { IShaderModuleService } from '../shader/IShaderModuleService';
|
||||
import { ISceneService } from './ISceneService';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { createVec3, getAngle } from '../math';
|
||||
import { getAngle } from '../math';
|
||||
|
||||
describe('util.math', () => {
|
||||
it('should clamp angle with `getAngle()`', () => {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
AttributeType,
|
||||
gl,
|
||||
IAttrubuteAndElements,
|
||||
IEncodeFeature,
|
||||
IModel,
|
||||
IModelUniform,
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
import {
|
||||
AttributeType,
|
||||
gl,
|
||||
IAnimateOption,
|
||||
IEncodeFeature,
|
||||
ILayerConfig,
|
||||
IModel,
|
||||
IModelUniform,
|
||||
ITexture2D,
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import { ILayerConfig, IModelUniform } from '@antv/l7-core';
|
||||
import { ILayerConfig } from '@antv/l7-core';
|
||||
import BaseModel from '../../core/BaseModel';
|
||||
import {
|
||||
CanvasUpdateType,
|
||||
ICanvasLayerStyleOptions,
|
||||
IDrawingOnCanvas,
|
||||
} from '../../core/interface';
|
||||
|
||||
export default class CanvaModel extends BaseModel {
|
||||
|
|
|
@ -1186,12 +1186,13 @@ export default class BaseLayer<ChildLayerStyleOptions = {}>
|
|||
const {
|
||||
attributes,
|
||||
elements,
|
||||
count,
|
||||
} = this.styleAttributeService.createAttributesAndIndices(
|
||||
this.encodedData,
|
||||
triangulation,
|
||||
segmentNumber,
|
||||
);
|
||||
const m = createModel({
|
||||
const modeloptions = {
|
||||
attributes,
|
||||
uniforms,
|
||||
fs,
|
||||
|
@ -1199,7 +1200,11 @@ export default class BaseLayer<ChildLayerStyleOptions = {}>
|
|||
elements,
|
||||
blend: BlendTypes[BlendType.normal],
|
||||
...rest,
|
||||
});
|
||||
};
|
||||
if (count) {
|
||||
modeloptions.count = count;
|
||||
}
|
||||
const m = createModel(modeloptions);
|
||||
resolve(m);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -145,49 +145,73 @@ export function LineTriangulation(feature: IEncodeFeature) {
|
|||
}
|
||||
|
||||
export function SimpleLineTriangulation(feature: IEncodeFeature) {
|
||||
const { coordinates, originCoordinates, version } = feature;
|
||||
const { coordinates } = feature;
|
||||
const pos: any[] = [];
|
||||
|
||||
const line = new ExtrudePolyline({
|
||||
dash: true,
|
||||
join: 'bevel',
|
||||
const { results, totalDistance } = getSimpleLineVertices(
|
||||
coordinates as IPosition[],
|
||||
);
|
||||
results.map((point) => {
|
||||
pos.push(point[0], point[1], point[2], point[3], 0, totalDistance);
|
||||
});
|
||||
|
||||
if (version === 'GAODE2.x') {
|
||||
// 处理高德2.0几何体构建
|
||||
let path1 = coordinates as number[][][] | number[][]; // 计算位置
|
||||
if (!Array.isArray(path1[0][0])) {
|
||||
path1 = [coordinates] as number[][][];
|
||||
}
|
||||
let path2 = originCoordinates as number[][][] | number[][]; // 计算法线
|
||||
if (!Array.isArray(path2[0][0])) {
|
||||
path2 = [originCoordinates] as number[][][];
|
||||
}
|
||||
for (let i = 0; i < path1.length; i++) {
|
||||
// 高德2.0在计算线时,需要使用经纬度计算发现,使用 customCoords.lnglatToCoords 计算的数据来计算顶点的位置
|
||||
const item1 = path1[i];
|
||||
const item2 = path2[i];
|
||||
line.simpleExtrude_gaode2(item1 as number[][], item2 as number[][]);
|
||||
}
|
||||
} else {
|
||||
// 处理非高德2.0的几何体构建
|
||||
let path = coordinates as number[][][] | number[][];
|
||||
if (path[0] && !Array.isArray(path[0][0])) {
|
||||
path = [coordinates] as number[][][];
|
||||
}
|
||||
path.forEach((item: any) => {
|
||||
line.simpleExtrude(item as number[][]);
|
||||
});
|
||||
}
|
||||
|
||||
const linebuffer = line.complex;
|
||||
return {
|
||||
vertices: linebuffer.positions, // [ x,y,z, distance, miter, total ]
|
||||
indices: linebuffer.indices,
|
||||
normals: linebuffer.normals,
|
||||
vertices: pos,
|
||||
indices: [],
|
||||
normals: [],
|
||||
size: 6,
|
||||
count: results.length,
|
||||
};
|
||||
}
|
||||
|
||||
function lineSegmentDistance(b1: number[], a1: number[]) {
|
||||
const dx = a1[0] - b1[0];
|
||||
const dy = a1[1] - b1[1];
|
||||
return Math.sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
|
||||
function pushDis(point: number[], n: number) {
|
||||
if (point.length < 3) {
|
||||
point.push(0);
|
||||
}
|
||||
point.push(n);
|
||||
return point;
|
||||
}
|
||||
|
||||
function getSimpleLineVertices(points: number[][]) {
|
||||
let distance = 0;
|
||||
if (points.length < 2) {
|
||||
return {
|
||||
results: points,
|
||||
totalDistance: 0,
|
||||
};
|
||||
} else {
|
||||
const results: number[][] = [];
|
||||
const point = pushDis(points[0], distance);
|
||||
results.push(point);
|
||||
|
||||
for (let i = 1; i < points.length - 1; i++) {
|
||||
const subDistance = lineSegmentDistance(points[i - 1], points[i]);
|
||||
distance += subDistance;
|
||||
|
||||
const mulPoint = pushDis(points[i], distance);
|
||||
results.push(mulPoint);
|
||||
results.push(mulPoint);
|
||||
}
|
||||
const pointDistance = lineSegmentDistance(
|
||||
points[points.length - 2],
|
||||
points[points.length - 1],
|
||||
);
|
||||
distance += pointDistance;
|
||||
|
||||
results.push(pushDis(points[points.length - 1], distance));
|
||||
return {
|
||||
results,
|
||||
totalDistance: distance,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function polygonTriangulation(feature: IEncodeFeature) {
|
||||
const { coordinates } = feature;
|
||||
const flattengeo = earcut.flatten(coordinates as number[][][]);
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
import {
|
||||
AttributeType,
|
||||
BlendType,
|
||||
gl,
|
||||
IEncodeFeature,
|
||||
ILayerConfig,
|
||||
IModel,
|
||||
IModelUniform,
|
||||
ITexture2D,
|
||||
} from '@antv/l7-core';
|
||||
|
||||
import BaseModel, { styleOffset, styleSingle } from '../../core/BaseModel';
|
||||
import BaseModel from '../../core/BaseModel';
|
||||
import { earthTriangulation } from '../../core/triangulation';
|
||||
|
||||
import baseFrag from '../shaders/base_frag.glsl';
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
IColorRamp,
|
||||
} from '@antv/l7-utils';
|
||||
import { mat4 } from 'gl-matrix';
|
||||
import { inject, injectable } from 'inversify';
|
||||
import { injectable } from 'inversify';
|
||||
import 'reflect-metadata';
|
||||
import BaseModel from '../../core/BaseModel';
|
||||
import { IHeatMapLayerStyleOptions } from '../../core/interface';
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
import { getMask, rgb2arr } from '@antv/l7-utils';
|
||||
import { isNumber } from 'lodash';
|
||||
import BaseModel from '../../core/BaseModel';
|
||||
import { ILineLayerStyleOptions, lineStyleType } from '../../core/interface';
|
||||
import { ILineLayerStyleOptions } from '../../core/interface';
|
||||
import { LineArcTriangulation } from '../../core/triangulation';
|
||||
import line_arc_frag from '../shaders/line_arc_great_circle_frag.glsl';
|
||||
import line_arc2d_vert from '../shaders/line_arc_great_circle_vert.glsl';
|
||||
|
|
|
@ -3,7 +3,6 @@ import {
|
|||
gl,
|
||||
IAnimateOption,
|
||||
IEncodeFeature,
|
||||
IImage,
|
||||
ILayerConfig,
|
||||
IModel,
|
||||
IModelUniform,
|
||||
|
|
|
@ -2,7 +2,6 @@ import {
|
|||
AttributeType,
|
||||
gl,
|
||||
IEncodeFeature,
|
||||
ILayerConfig,
|
||||
IModel,
|
||||
IModelUniform,
|
||||
ITexture2D,
|
||||
|
|
|
@ -74,5 +74,6 @@ void main() {
|
|||
}
|
||||
|
||||
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, lineHeight + h, 1.0));
|
||||
gl_PointSize = 10.0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
import PointLayer from '../';
|
||||
import Map from '../../../../maps/src/map';
|
||||
import { Scene } from '../../../../scene/src';
|
||||
import extrudePolygon from '../shape/extrude';
|
||||
describe('pointLayer', () => {
|
||||
const layer = new PointLayer({
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { gl, IModel, Triangulation } from '@antv/l7-core';
|
||||
import { gl, IModel } from '@antv/l7-core';
|
||||
import { getMask } from '@antv/l7-utils';
|
||||
import BaseModel from '../../core/BaseModel';
|
||||
import { IPolygonLayerStyleOptions } from '../../core/interface';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { IEncodeFeature, IParseDataItem } from '@antv/l7-core';
|
||||
import { IParseDataItem } from '@antv/l7-core';
|
||||
// @ts-ignore
|
||||
import Martini from '@mapbox/martini';
|
||||
export function RasterTriangulation(parserData: IParseDataItem) {
|
||||
|
|
|
@ -4,8 +4,6 @@ import {
|
|||
IEncodeFeature,
|
||||
IModel,
|
||||
ITexture2D,
|
||||
lazyInject,
|
||||
TYPES,
|
||||
} from '@antv/l7-core';
|
||||
import { generateColorRamp, getMask, IColorRamp } from '@antv/l7-utils';
|
||||
import { isEqual } from 'lodash';
|
||||
|
|
|
@ -12,7 +12,6 @@ import { osmLonLat2TileXY, Tile, TilesetManager } from '@antv/l7-utils';
|
|||
import MaskLayer from '../../mask';
|
||||
import {
|
||||
getLayerShape,
|
||||
readPixel,
|
||||
readRasterValue,
|
||||
registerLayers,
|
||||
} from '../utils';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { ILayer, ISubLayerInitOptions } from '@antv/l7-core';
|
||||
import Source from '@antv/l7-source';
|
||||
import { Tile } from '@antv/l7-utils';
|
||||
import { ITileFactoryOptions, ITileStyles } from '../interface';
|
||||
import { ITileFactoryOptions } from '../interface';
|
||||
import TileFactory from './base';
|
||||
export default class VectorPolygonTile extends TileFactory {
|
||||
public parentLayer: ILayer;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { ILayer, ISubLayerInitOptions } from '@antv/l7-core';
|
||||
import Source from '@antv/l7-source';
|
||||
import { Tile } from '@antv/l7-utils';
|
||||
import { ITileFactoryOptions, ITileStyles } from '../interface';
|
||||
import { ITileFactoryOptions } from '../interface';
|
||||
import TileFactory from './base';
|
||||
|
||||
export default class VectorPolygonTile extends TileFactory {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { ILayer, ISubLayerInitOptions } from '@antv/l7-core';
|
||||
import Source from '@antv/l7-source';
|
||||
import { Tile } from '@antv/l7-utils';
|
||||
import { ITileFactoryOptions, ITileStyles } from '../interface';
|
||||
import { ITileFactoryOptions } from '../interface';
|
||||
import TileFactory from './base';
|
||||
export default class VectorPolygonTile extends TileFactory {
|
||||
public parentLayer: ILayer;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { ILayer, ISubLayerInitOptions } from '@antv/l7-core';
|
||||
import Source from '@antv/l7-source';
|
||||
import { Tile, TilesetManager } from '@antv/l7-utils';
|
||||
import { Tile } from '@antv/l7-utils';
|
||||
import ImageLayer from '../../image';
|
||||
import { ITileFactoryOptions } from '../interface';
|
||||
import TileFactory from './base';
|
||||
|
|
|
@ -3,8 +3,6 @@ import {
|
|||
ILayer,
|
||||
ILayerService,
|
||||
IMapService,
|
||||
IScale,
|
||||
IScaleOptions,
|
||||
ISource,
|
||||
ITileLayer,
|
||||
ITileLayerManager,
|
||||
|
|
|
@ -7,7 +7,7 @@ import {
|
|||
ITexture2D,
|
||||
Point,
|
||||
} from '@antv/l7-core';
|
||||
import { FrequencyController, getMask } from '@antv/l7-utils';
|
||||
import { FrequencyController } from '@antv/l7-utils';
|
||||
import BaseModel from '../../core/BaseModel';
|
||||
import { IWindLayerStyleOptions } from '../../core/interface';
|
||||
import { RasterImageTriangulation } from '../../core/triangulation';
|
||||
|
|
|
@ -10,14 +10,12 @@ import { Event } from './handler/events/event';
|
|||
import { IMapOptions } from './interface';
|
||||
type CallBack = (_: number) => void;
|
||||
import {
|
||||
cancel,
|
||||
clamp,
|
||||
ease as defaultEasing,
|
||||
interpolate,
|
||||
now,
|
||||
pick,
|
||||
prefersReducedMotion,
|
||||
raf,
|
||||
wrap,
|
||||
} from './util';
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import MapMouseEvent from './map_mouse_event';
|
||||
import MapTouchEvent from './map_touch_event';
|
||||
import MapWheelEvent, { IMapBoxZoomEvent } from './map_wheel_event';
|
||||
import MapWheelEvent from './map_wheel_event';
|
||||
|
||||
export { MapMouseEvent, MapTouchEvent, MapWheelEvent };
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
// @ts-ignore
|
||||
import Point from '../../geo/point';
|
||||
import DOM from '../../utils/dom';
|
||||
import MouseHandler from './mouse_handler';
|
||||
import { buttonStillPressed, LEFT_BUTTON } from './util';
|
||||
import { LEFT_BUTTON } from './util';
|
||||
export default class MousePanHandler extends MouseHandler {
|
||||
public mousedown(e: MouseEvent, point: Point) {
|
||||
super.mousedown(e, point);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
// @ts-ignore
|
||||
import Point from '../../geo/point';
|
||||
import DOM from '../../utils/dom';
|
||||
import TwoTouchHandler from './two_touch';
|
||||
|
||||
const ROTATION_THRESHOLD = 25; // pixels along circumference of touch circle
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
// @ts-ignore
|
||||
import Point from '../../geo/point';
|
||||
import DOM from '../../utils/dom';
|
||||
import TwoTouchHandler from './two_touch';
|
||||
|
||||
const ZOOM_THRESHOLD = 0.1;
|
||||
|
|
|
@ -81,12 +81,12 @@ export default class ReglModel implements IModel {
|
|||
drawParams.instances = instances;
|
||||
}
|
||||
|
||||
// Tip:
|
||||
// elements 中可能包含 count,此时不应传入
|
||||
// count 和 elements 相比、count 优先
|
||||
if (count) {
|
||||
drawParams.count = count;
|
||||
}
|
||||
|
||||
if (elements) {
|
||||
} else if (elements) {
|
||||
drawParams.elements = (elements as ReglElements).get();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
// @ts-ignore
|
||||
import { PolygonLayer } from '@antv/l7-layers';
|
||||
import { Map } from '@antv/l7-maps';
|
||||
import { Scene } from '../src/';
|
||||
describe('template', () => {
|
||||
it('scene l7 map method', () => {
|
||||
expect(2).toEqual(2);
|
||||
});
|
||||
});
|
|
@ -321,7 +321,7 @@ img.onload = function() {
|
|||
type: 'Feature',
|
||||
properties: {},
|
||||
geometry: {
|
||||
type: 'LineString',
|
||||
type: 'MultiLineString',
|
||||
coordinates: d1
|
||||
}
|
||||
},
|
||||
|
@ -329,7 +329,7 @@ img.onload = function() {
|
|||
type: 'Feature',
|
||||
properties: {},
|
||||
geometry: {
|
||||
type: 'LineString',
|
||||
type: 'MultiLineString',
|
||||
coordinates: d2
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { pull } from 'lodash';
|
||||
import { $window, isMini } from './mini-adapter';
|
||||
import { $window } from './mini-adapter';
|
||||
|
||||
type ELType = HTMLElement | SVGElement;
|
||||
export function getContainer(domId: string | HTMLDivElement) {
|
||||
|
@ -171,46 +170,3 @@ export function getViewPortScale() {
|
|||
}
|
||||
|
||||
export const DPR = getViewPortScale() < 1 ? 1 : $window.devicePixelRatio;
|
||||
|
||||
export function addStyle(el: ELType, style: string) {
|
||||
el.setAttribute('style', `${el.style.cssText}${style}`);
|
||||
}
|
||||
|
||||
export function getStyleList(style: string): string[] {
|
||||
return style
|
||||
.split(';')
|
||||
.map((item) => item.trim())
|
||||
.filter((item) => item);
|
||||
}
|
||||
|
||||
export function removeStyle(el: ELType, style: string) {
|
||||
const oldStyleList = getStyleList(el.getAttribute('style') ?? '');
|
||||
const targetStyleList = getStyleList(style);
|
||||
const newStyleList = pull(oldStyleList, ...targetStyleList);
|
||||
el.setAttribute('style', newStyleList.join(';'));
|
||||
}
|
||||
|
||||
export function css2Style(obj: any) {
|
||||
return Object.entries(obj)
|
||||
.map(([key, value]) => `${key}: ${value}`)
|
||||
.join(';');
|
||||
}
|
||||
|
||||
export function getDiffRect(dom1Rect: any, dom2Rect: any) {
|
||||
return {
|
||||
left: dom1Rect.left - dom2Rect.left,
|
||||
top: dom1Rect.top - dom2Rect.top,
|
||||
right: dom2Rect.left + dom2Rect.width - dom1Rect.left - dom1Rect.width,
|
||||
bottom: dom2Rect.top + dom2Rect.height - dom1Rect.top - dom1Rect.height,
|
||||
};
|
||||
}
|
||||
|
||||
export function setChecked(el: ELType, value: boolean) {
|
||||
// @ts-ignore
|
||||
el.checked = value;
|
||||
if (value) {
|
||||
el.setAttribute('checked', 'true');
|
||||
} else {
|
||||
el.removeAttribute('checked');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ export default class GridTile extends React.Component {
|
|||
type: 'Feature',
|
||||
properties: {},
|
||||
geometry: {
|
||||
type: 'LineString',
|
||||
type: 'MultiLineString',
|
||||
coordinates: d1,
|
||||
},
|
||||
},
|
||||
|
@ -114,7 +114,7 @@ export default class GridTile extends React.Component {
|
|||
type: 'Feature',
|
||||
properties: {},
|
||||
geometry: {
|
||||
type: 'LineString',
|
||||
type: 'MultiLineString',
|
||||
coordinates: d2,
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue