@geoscene/core 4.34.9 → 4.34.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +18 -18
- package/analysis/ViewshedVideo.js +5 -0
- package/analysis/viewshedVideo/ViewshedAnalysisView3DVideo.js +5 -0
- package/analysis/viewshedVideo/ViewshedComputedDataVideo.js +5 -0
- package/analysis/viewshedVideo/ViewshedSubVisualizationVideo.js +5 -0
- package/analysis/viewshedVideo/ViewshedVisualizationVideo.js +5 -0
- package/analysis/viewshedVideo/render/ViewshedTechniqueVideo.js +5 -0
- package/analysis/viewshedVideo/render/ViewshedVideo.glsl.js +243 -0
- package/analysis/viewshedVideo/render/ViewshedVideo.js +5 -0
- package/assets/geoscene/core/workers/chunks/0f735b0dec173142f3b6.js +1 -1
- package/assets/geoscene/core/workers/chunks/3a457e718a901a45902e.js +1 -1
- package/assets/geoscene/core/workers/chunks/49571d6875de1f2e7e25.js +32 -32
- package/assets/geoscene/core/workers/chunks/7565b382f6b3d2cb46a3.js +1 -1
- package/assets/geoscene/core/workers/chunks/9ff8ee6ed6b98c03ae7e.js +1 -1
- package/assets/geoscene/core/workers/chunks/aa78b69219d9a0ef1c54.js +1 -1
- package/assets/geoscene/core/workers/chunks/ce16489cf7eb0d78c741.js +1 -1
- package/assets/geoscene/core/workers/chunks/d6e0528eacee7ea4c1ce.js +1 -1
- package/assets/geoscene/core/workers/chunks/f651c05604eab83aef5f.js +1 -1
- package/bundle/lib/fflate.js +12 -0
- package/copyright.txt +1654 -1654
- package/layers/mixins/SceneService.js +1 -1
- package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
- package/layers/support/rasterFormats/ImageCanvasDecoder.js +1 -1
- package/layers/support/rasterFormats/RasterCodec.js +1 -1
- package/layers/voxel/drill/VoxelContinuousDrill.js +5 -0
- package/layers/voxel/drill/VoxelDiscreteDrill.js +5 -0
- package/layers/voxel/drill/common.js +5 -0
- package/package.json +30 -30
- package/views/3d/analysis/analysisViewModuleImportUtils.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
- package/views/3d/layers/ViewshedLayerView3D.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
- package/views/3d/layers/support/LayerViewAnalysisViewManager.js +1 -1
- package/views/draw/expert/AttackArrowDrawer.js +5 -0
- package/views/draw/expert/AttackTailedArrowDrawer.js +5 -0
- package/views/draw/expert/BaseDrawer.js +5 -0
- package/views/draw/expert/Constant.js +5 -0
- package/views/draw/expert/CurveDrawer.js +5 -0
- package/views/draw/expert/CurveFlagDrawer.js +5 -0
- package/views/draw/expert/CurvedArrowDrawer.js +5 -0
- package/views/draw/expert/EllipseDrawer.js +5 -0
- package/views/draw/expert/ExpertDraw.js +5 -0
- package/views/draw/expert/GatheringPlaceDrawer.js +5 -0
- package/views/draw/expert/LuneDrawer.js +5 -0
- package/views/draw/expert/PincerArrowDrawer.js +5 -0
- package/views/draw/expert/SectorDrawer.js +5 -0
- package/views/draw/expert/SquadCombatDrawer.js +5 -0
- package/views/draw/expert/StraightArrowDrawer.js +5 -0
- package/views/draw/expert/TailedSquadCombatDrawer.js +5 -0
- package/views/draw/expert/plot/Constants.js +5 -0
- package/views/draw/expert/plot/PlotTypes.js +5 -0
- package/views/draw/expert/plot/plots/Arc.js +41 -0
- package/views/draw/expert/plot/plots/AssaultDirection.js +15 -0
- package/views/draw/expert/plot/plots/AttackArrow.js +5 -0
- package/views/draw/expert/plot/plots/Circle.js +5 -0
- package/views/draw/expert/plot/plots/ClosedCurve.js +5 -0
- package/views/draw/expert/plot/plots/Curve.js +5 -0
- package/views/draw/expert/plot/plots/CurveFlag.js +5 -0
- package/views/draw/expert/plot/plots/CurvedArrow.js +5 -0
- package/views/draw/expert/plot/plots/DoubleArrow.js +5 -0
- package/views/draw/expert/plot/plots/Ellipse.js +5 -0
- package/views/draw/expert/plot/plots/FineArrow.js +5 -0
- package/views/draw/expert/plot/plots/FreehandLine.js +19 -0
- package/views/draw/expert/plot/plots/FreehandPolygon.js +19 -0
- package/views/draw/expert/plot/plots/GatheringPlace.js +5 -0
- package/views/draw/expert/plot/plots/Lune.js +5 -0
- package/views/draw/expert/plot/plots/Marker.js +16 -0
- package/views/draw/expert/plot/plots/Plot.js +5 -0
- package/views/draw/expert/plot/plots/Polygon.js +18 -0
- package/views/draw/expert/plot/plots/Polyline.js +19 -0
- package/views/draw/expert/plot/plots/Rectangle.js +28 -0
- package/views/draw/expert/plot/plots/Sector.js +5 -0
- package/views/draw/expert/plot/plots/SquadCombat.js +5 -0
- package/views/draw/expert/plot/plots/StraightArrow.js +5 -0
- package/views/draw/expert/plot/plots/TailedAttackArrow.js +5 -0
- package/views/draw/expert/plot/plots/TailedSquadCombat.js +5 -0
- package/views/draw/expert/plot/utils/plot_util.js +5 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.geoscene.cn/4.33/geoscene/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import Plot from'./Plot.js';import PlotTypes from'../PlotTypes.js';import*as PlotUtils from'../utils/plot_util.js';import Constants from'../Constants.js';export default class GatheringPlace extends Plot{constructor(points){super(points);this.type=PlotTypes.GATHERING_PLACE;this.t=0.4;this.fixPointCount=3;this.setPoints(points)}generate(){let pnts=this.getPoints();if(pnts.length<2){return}if(this.getPointCount()===2){const mid=PlotUtils.mid(pnts[0],pnts[1]);const d=PlotUtils.distance(pnts[0],mid)/0.9;const pnt=PlotUtils.getThirdPoint(pnts[0],mid,Constants.HALF_PI,d,true);pnts=[pnts[0],pnt,pnts[1]]}const mid=PlotUtils.mid(pnts[0],pnts[2]);pnts.push(mid,pnts[0],pnts[1]);let normals=[];for(let i=0;i<pnts.length-2;i++){const pnt1=pnts[i];const pnt2=pnts[i+1];const pnt3=pnts[i+2];const normalPoints=PlotUtils.getBisectorNormals(this.t,pnt1,pnt2,pnt3);normals=normals.concat(normalPoints)}const count=normals.length;normals=[normals[count-1]].concat(normals.slice(0,count-1));const pList=[];for(let i=0;i<pnts.length-2;i++){const pnt1=pnts[i];const pnt2=pnts[i+1];pList.push(pnt1);for(let t=0;t<=Constants.FITTING_COUNT;t++){const pnt=PlotUtils.getCubicValue(t/Constants.FITTING_COUNT,pnt1,normals[i*2],normals[i*2+1],pnt2);pList.push(pnt)}pList.push(pnt2)}this.setCoordinates([pList])}}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.geoscene.cn/4.33/geoscene/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import Plot from'./Plot.js';import PlotTypes from'../PlotTypes.js';import*as PlotUtils from'../utils/plot_util.js';import Constants from'../Constants.js';export default class Lune extends Plot{constructor(points){super(points);this.type=PlotTypes.LUNE;this.fixPointCount=3;this.setPoints(points)}generate(){if(this.getPointCount()<2){return}let pnts=this.getPoints();if(this.getPointCount()===2){const mid=PlotUtils.mid(pnts[0],pnts[1]);const d=PlotUtils.distance(pnts[0],mid);const pnt=PlotUtils.getThirdPoint(pnts[0],mid,Constants.HALF_PI,d);pnts.push(pnt)}const pnt1=pnts[0];const pnt2=pnts[1];const pnt3=pnts[2];const center=PlotUtils.getCircleCenterOfThreePoints(pnt1,pnt2,pnt3);const radius=PlotUtils.distance(pnt1,center);const angle1=PlotUtils.getAzimuth(pnt1,center);const angle2=PlotUtils.getAzimuth(pnt2,center);let startAngle,endAngle;if(PlotUtils.isClockWise(pnt1,pnt2,pnt3)){startAngle=angle2;endAngle=angle1}else{startAngle=angle1;endAngle=angle2}pnts=PlotUtils.getArcPoints(center,radius,startAngle,endAngle);pnts.push(pnts[0]);this.setCoordinates([pnts])}}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Plot from './Plot.js';
|
|
2
|
+
import PlotTypes from '../PlotTypes.js';
|
|
3
|
+
|
|
4
|
+
export default class Marker extends Plot {
|
|
5
|
+
constructor(points) {
|
|
6
|
+
super(points);
|
|
7
|
+
this.type = PlotTypes.MARKER;
|
|
8
|
+
this.fixPointCount = 1;
|
|
9
|
+
this.setPoints(points);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
generate() {
|
|
13
|
+
const pnt = this.points[0];
|
|
14
|
+
this.setCoordinates(pnt);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.geoscene.cn/4.33/geoscene/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
class Plot{constructor(points){this.setPoints(points);this.geo_type='RootTest'}isPlot(){return true}setPoints(value){this.points=value||[];if(this.points.length>=1){this.generate()}}getPoints(){return this.points.slice(0)}getPointCount(){return this.points.length}updatePoint(point,index){if(index>=0&&index<this.points.length){this.points[index]=point;this.generate()}}updateLastPoint(point){this.updatePoint(point,this.points.length-1)}generate(){}finishDrawing(){}setCoordinates(coordinates){if(coordinates instanceof Array&&coordinates.length===1){this.coordinates=coordinates[0]}else{this.coordinates=coordinates}}getCoordinates(){return this.coordinates}}export default Plot;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Plot from './Plot.js';
|
|
2
|
+
import PlotTypes from '../PlotTypes.js';
|
|
3
|
+
|
|
4
|
+
export default class Polygon extends Plot {
|
|
5
|
+
constructor(points) {
|
|
6
|
+
super(points);
|
|
7
|
+
this.type = PlotTypes.POLYGON;
|
|
8
|
+
this.setPoints(points);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
generate() {
|
|
12
|
+
const count = this.getPointCount();
|
|
13
|
+
if (count < 2) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
this.setCoordinates([this.points]);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Plot from './Plot.js';
|
|
2
|
+
import PlotTypes from '../PlotTypes.js';
|
|
3
|
+
// --fix dyj 目前mix函数只支持简单对象的拷贝,Plot必须放在复杂对象前面
|
|
4
|
+
export default class Polyline extends Plot {
|
|
5
|
+
constructor(points) {
|
|
6
|
+
super(points);
|
|
7
|
+
this.type = PlotTypes.POLYLINE;
|
|
8
|
+
this.geo_type = 'LineString';
|
|
9
|
+
this.setPoints(points);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
generate() {
|
|
13
|
+
const count = this.getPointCount();
|
|
14
|
+
if (count < 2) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
this.setCoordinates(this.points);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Plot from './Plot.js';
|
|
2
|
+
import PlotTypes from '../PlotTypes.js';
|
|
3
|
+
|
|
4
|
+
export default class Rectangle extends Plot {
|
|
5
|
+
constructor(points) {
|
|
6
|
+
super(points);
|
|
7
|
+
this.type = PlotTypes.RECTANGLE;
|
|
8
|
+
this.fixPointCount = 2;
|
|
9
|
+
this.setPoints(points);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
generate() {
|
|
13
|
+
const count = this.getPointCount();
|
|
14
|
+
if (!(count < 2)) {
|
|
15
|
+
const pnt1 = this.points[0];
|
|
16
|
+
const pnt2 = this.points[1];
|
|
17
|
+
const xmin = Math.min(pnt1[0], pnt2[0]);
|
|
18
|
+
const xmax = Math.max(pnt1[0], pnt2[0]);
|
|
19
|
+
const ymin = Math.min(pnt1[1], pnt2[1]);
|
|
20
|
+
const ymax = Math.max(pnt1[1], pnt2[1]);
|
|
21
|
+
const tl = [xmin, ymax];
|
|
22
|
+
const tr = [xmax, ymax];
|
|
23
|
+
const br = [xmax, ymin];
|
|
24
|
+
const bl = [xmin, ymin];
|
|
25
|
+
this.setCoordinates([[tl, tr, br, bl]]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.geoscene.cn/4.33/geoscene/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import Plot from'./Plot.js';import PlotTypes from'../PlotTypes.js';import*as PlotUtils from'../utils/plot_util.js';export default class Sector extends Plot{constructor(points){super(points);this.type=PlotTypes.SECTOR;this.fixPointCount=3;this.setPoints(points)}generate(){if(this.getPointCount()<2){return}if(this.getPointCount()===2){this.setCoordinates([this.points])}else{const pnts=this.getPoints();const center=pnts[0];const pnt2=pnts[1];const pnt3=pnts[2];const radius=PlotUtils.distance(pnt2,center);const startAngle=PlotUtils.getAzimuth(pnt2,center);const endAngle=PlotUtils.getAzimuth(pnt3,center);const pList=PlotUtils.getArcPoints(center,radius,startAngle,endAngle);pList.push(center,pList[0]);this.setCoordinates([pList])}}}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.geoscene.cn/4.33/geoscene/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import PlotTypes from'../PlotTypes.js';import AttackArrow from'./AttackArrow.js';import*as PlotUtils from'../utils/plot_util.js';import Constants from'../Constants.js';export default class SquadCombat extends AttackArrow{constructor(points){super(points);this.type=PlotTypes.SQUAD_COMBAT;this.headHeightFactor=0.18;this.headWidthFactor=0.3;this.neckHeightFactor=0.85;this.neckWidthFactor=0.15;this.tailWidthFactor=0.1;this.setPoints(points)}generate(){let count=this.getPointCount();if(count<2){return}const pnts=this.getPoints();const tailPnts=this.getTailPoints(pnts);const headPnts=this.getArrowHeadPoints(pnts,tailPnts[0],tailPnts[1]);const neckLeft=headPnts[0];const neckRight=headPnts[4];const bodyPnts=this.getArrowBodyPoints(pnts,neckLeft,neckRight,this.tailWidthFactor);count=bodyPnts.length;let leftPnts=[tailPnts[0]].concat(bodyPnts.slice(0,count/2));leftPnts.push(neckLeft);let rightPnts=[tailPnts[1]].concat(bodyPnts.slice(count/2,count));rightPnts.push(neckRight);leftPnts=PlotUtils.getQBSplinePoints(leftPnts);rightPnts=PlotUtils.getQBSplinePoints(rightPnts);this.setCoordinates([leftPnts.concat(headPnts,rightPnts.reverse())])}getTailPoints(points){const allLen=PlotUtils.getBaseLength(points);const tailWidth=allLen*this.tailWidthFactor;const tailLeft=PlotUtils.getThirdPoint(points[1],points[0],Constants.HALF_PI,tailWidth,false);const tailRight=PlotUtils.getThirdPoint(points[1],points[0],Constants.HALF_PI,tailWidth,true);return[tailLeft,tailRight]}}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.geoscene.cn/4.33/geoscene/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import Plot from'./Plot.js';import PlotTypes from'../PlotTypes.js';import*as PlotUtils from'../utils/plot_util.js';export default class StraightArrow extends Plot{constructor(points){super(points);this.type=PlotTypes.STRAIGHT_ARROW;this.fixPointCount=2;this.maxArrowLength=3000000;this.arrowLengthScale=5;this.setPoints(points)}generate(){if(this.getPointCount()<2){return}const pnts=this.getPoints();const pnt1=pnts[0];const pnt2=pnts[1];const distance=PlotUtils.distance(pnt1,pnt2);let len=distance/this.arrowLengthScale;len=len>this.maxArrowLength?this.maxArrowLength:len;const leftPnt=PlotUtils.getThirdPoint(pnt1,pnt2,Math.PI/6,len,false);const rightPnt=PlotUtils.getThirdPoint(pnt1,pnt2,Math.PI/6,len,true);this.setCoordinates([pnt1,pnt2,leftPnt,pnt2,rightPnt])}}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.geoscene.cn/4.33/geoscene/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import PlotTypes from'../PlotTypes.js';import AttackArrow from'./AttackArrow.js';import*as PlotUtils from'../utils/plot_util.js';export default class TailedAttackArrow extends AttackArrow{constructor(points){super(points);this.type=PlotTypes.TAILED_ATTACK_ARROW;this.headHeightFactor=0.18;this.headWidthFactor=0.3;this.neckHeightFactor=0.85;this.neckWidthFactor=0.15;this.tailWidthFactor=0.1;this.headTailFactor=0.8;this.swallowTailFactor=1;this.swallowTailPnt=null;this.setPoints(points)}generate(point){if(this.getPointCount()<2){return}if(this.getPointCount()===2){this.coordinates=this.points;return}const pnts=this.getPoints();let tailLeft=pnts[0];let tailRight=pnts[1];if(PlotUtils.isClockWise(pnts[0],pnts[1],pnts[2])){tailLeft=pnts[1];tailRight=pnts[0]}const midTail=PlotUtils.mid(tailLeft,tailRight);const bonePnts=[midTail].concat(pnts.slice(2));const headPnts=this.getArrowHeadPoints(bonePnts,tailLeft,tailRight);const neckLeft=headPnts[0];const neckRight=headPnts[4];const tailWidth=PlotUtils.distance(tailLeft,tailRight);const allLen=PlotUtils.getBaseLength(bonePnts);const len=allLen*this.tailWidthFactor*this.swallowTailFactor;this.swallowTailPnt=PlotUtils.getThirdPoint(bonePnts[1],bonePnts[0],0,len,true);const factor=tailWidth/allLen;const bodyPnts=this.getArrowBodyPoints(bonePnts,neckLeft,neckRight,factor);const count=bodyPnts.length;let leftPnts=[tailLeft].concat(bodyPnts.slice(0,count/2));leftPnts.push(neckLeft);let rightPnts=[tailRight].concat(bodyPnts.slice(count/2,count));rightPnts.push(neckRight);leftPnts=PlotUtils.getQBSplinePoints(leftPnts);rightPnts=PlotUtils.getQBSplinePoints(rightPnts);this.coordinates=leftPnts.concat(headPnts,rightPnts.reverse(),[this.swallowTailPnt,leftPnts[0]])}generateNew(inputPoint){inputPoint=this.getPoints();const array2Dto1D=function(j){const newArray=[];j.forEach(function(b){newArray.push(b[0]);newArray.push(b[1])});return newArray};const tailedAttackArrowDefualParam={headHeightFactor:0.18,headWidthFactor:0.3,neckHeightFactor:0.85,neckWidthFactor:0.15,tailWidthFactor:0.1,headTailFactor:0.8,swallowTailFactor:1};const result={controlPoint:null,polygonalPoint:null};result.controlPoint=inputPoint;const t=inputPoint.length;if(!(t<2)){if(inputPoint.length===2){result.polygonalPoint=inputPoint;return result}const o=inputPoint;let e=o[0];let r=o[1];if(PlotUtils.isClockWise(o[0],o[1],o[2])){e=o[1];r=o[0]}const n=PlotUtils.mid(e,r);const g=[n].concat(o.slice(2));const i=this.getAttackArrowHeadPoints(g,e,r,tailedAttackArrowDefualParam);const s=i[0];const a=i[4];const l=PlotUtils.distance(e,r);const u=PlotUtils.getBaseLength(g);const c=u*this.tailWidthFactor*this.swallowTailFactor;this.swallowTailPnt=PlotUtils.getThirdPoint(g[1],g[0],0,c,!0);const p=l/u;const h=this.getAttackArrowBodyPoints(g,s,a,p);const t=h.length;let d=[e].concat(h.slice(0,t/2));d.push(s);let f=[r].concat(h.slice(t/2,t));let newArray=[];f.push(a);d=PlotUtils.getQBSplinePoints(d);f=PlotUtils.getQBSplinePoints(f);newArray=array2Dto1D(d.concat(i,f.reverse(),[this.swallowTailPnt,d[0]]));result.polygonalPoint=newArray}return result}}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.geoscene.cn/4.33/geoscene/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import PlotTypes from'../PlotTypes.js';import AttackArrow from'./AttackArrow.js';import*as PlotUtils from'../utils/plot_util.js';import Constants from'../Constants.js';export default class TailedSquadCombat extends AttackArrow{constructor(points){super(points);this.type=PlotTypes.TAILED_SQUAD_COMBAT;this.headHeightFactor=0.18;this.headWidthFactor=0.3;this.neckHeightFactor=0.85;this.neckWidthFactor=0.15;this.tailWidthFactor=0.1;this.swallowTailFactor=1;this.swallowTailPnt=null;this.setPoints(points)}generate(){let count=this.getPointCount();if(count<2){return}const pnts=this.getPoints();const tailPnts=this.getTailPoints(pnts);const headPnts=this.getArrowHeadPoints(pnts,tailPnts[0],tailPnts[2]);const neckLeft=headPnts[0];const neckRight=headPnts[4];const bodyPnts=this.getArrowBodyPoints(pnts,neckLeft,neckRight,this.tailWidthFactor);count=bodyPnts.length;let leftPnts=[tailPnts[0]].concat(bodyPnts.slice(0,count/2));leftPnts.push(neckLeft);let rightPnts=[tailPnts[2]].concat(bodyPnts.slice(count/2,count));rightPnts.push(neckRight);leftPnts=PlotUtils.getQBSplinePoints(leftPnts);rightPnts=PlotUtils.getQBSplinePoints(rightPnts);this.setCoordinates([leftPnts.concat(headPnts,rightPnts.reverse(),[tailPnts[1],leftPnts[0]])])}getTailPoints(points){const allLen=PlotUtils.getBaseLength(points);const tailWidth=allLen*this.tailWidthFactor;const tailLeft=PlotUtils.getThirdPoint(points[1],points[0],Constants.HALF_PI,tailWidth,false);const tailRight=PlotUtils.getThirdPoint(points[1],points[0],Constants.HALF_PI,tailWidth,true);const len=tailWidth*this.swallowTailFactor;const swallowTailPnt=PlotUtils.getThirdPoint(points[1],points[0],0,len,true);return[tailLeft,swallowTailPnt,tailRight]}}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.geoscene.cn/4.33/geoscene/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import Constants from'../Constants.js';export function distance(c,d){return Math.sqrt(Math.pow((c[0]-d[0]),2)+Math.pow((c[1]-d[1]),2))};export function wholeDistance(c){let distanceLen=0;for(let i=0;i<c.length-1;i++){distanceLen+=distance(c[i],c[i+1])}return distanceLen};export function getBaseLength(c){return Math.pow(wholeDistance(c),0.99)};export function mid(c,d){return[(c[0]+d[0])/2,(c[1]+d[1])/2]};export function getCircleCenterOfThreePoints(c,d,g){const pntA=[(c[0]+d[0])/2,(c[1]+d[1])/2];const pntB=[pntA[0]-c[1]+d[1],pntA[1]+c[0]-d[0]];const pntC=[(c[0]+g[0])/2,(c[1]+g[1])/2];const pntD=[pntC[0]-c[1]+g[1],pntC[1]+c[0]-g[0]];return getIntersectPoint(pntA,pntB,pntC,pntD)};export function getIntersectPoint(c,d,g,h){let f,x,y;if(c[1]===d[1]){f=(h[0]-g[0])/(h[1]-g[1]);x=f*(c[1]-g[1])+g[0];y=c[1];return[x,y]}let e;if(g[1]===h[1]){e=(d[0]-c[0])/(d[1]-c[1]);x=e*(g[1]-c[1])+c[0];y=g[1];return[x,y]}e=(d[0]-c[0])/(d[1]-c[1]);f=(h[0]-g[0])/(h[1]-g[1]);y=(e*c[1]-c[0]-f*g[1]+g[0])/(e-f);x=e*y-e*c[1]+c[0];return[x,y]};export function getAzimuth(c,d){let azimuth;const angle=Math.asin(Math.abs(d[1]-c[1])/distance(c,d));if(d[1]>=c[1]&&d[0]>=c[0]){azimuth=angle+Math.PI}else if(d[1]>=c[1]&&d[0]<c[0]){azimuth=Constants.TWO_PI-angle}else if(d[1]<c[1]&&d[0]<c[0]){azimuth=angle}else if(d[1]<c[1]&&d[0]>=c[0]){azimuth=Math.PI-angle}return azimuth};export function getAngleOfThreePoints(c,d,g){const angle=getAzimuth(d,c)-getAzimuth(d,g);return(angle<0?angle+Constants.TWO_PI:angle)};export function isClockWise(c,d,g){return((g[1]-c[1])*(d[0]-c[0])>(d[1]-c[1])*(g[0]-c[0]))};export function getPointOnLine(c,d,g){const x=d[0]+(c*(g[0]-d[0]));const y=d[1]+(c*(g[1]-d[1]));return[x,y]};export function getCubicValue(c,d,g,h,l){c=Math.max(Math.min(c,1),0);const tp=1-c;const t2=c*c;const t3=t2*c;const tp2=tp*tp;const tp3=tp2*tp;const x=(tp3*d[0])+(3*tp2*c*g[0])+(3*tp*t2*h[0])+(t3*l[0]);const y=(tp3*d[1])+(3*tp2*c*g[1])+(3*tp*t2*h[1])+(t3*l[1]);return[x,y]};export function getThirdPoint(c,d,g,h,l){const azimuth=getAzimuth(c,d);const alpha=l?azimuth+g:azimuth-g;const dx=h*Math.cos(alpha);const dy=h*Math.sin(alpha);return[d[0]+dx,d[1]+dy]};export function getArcPoints(c,d,g,h){let x;let y;const pnts=[];let angleDiff=h-g;angleDiff=angleDiff<0?angleDiff+Constants.TWO_PI:angleDiff;for(let i=0;i<=Constants.FITTING_COUNT;i++){const angle=g+angleDiff*i/Constants.FITTING_COUNT;x=c[0]+d*Math.cos(angle);y=c[1]+d*Math.sin(angle);pnts.push([x,y])}return pnts};export function getBisectorNormals(c,d,g,h){const normal=getNormal(d,g,h);const dist=Math.sqrt(normal[0]*normal[0]+normal[1]*normal[1]);const uX=normal[0]/dist;const uY=normal[1]/dist;const d1=distance(d,g);const d2=distance(g,h);let dt,x,y,bisectorNormalRight,bisectorNormalLeft;if(dist>Constants.ZERO_TOLERANCE){if(isClockWise(d,g,h)){dt=c*d1;x=g[0]-dt*uY;y=g[1]+dt*uX;bisectorNormalRight=[x,y];dt=c*d2;x=g[0]+dt*uY;y=g[1]-dt*uX;bisectorNormalLeft=[x,y]}else{dt=c*d1;x=g[0]+dt*uY;y=g[1]-dt*uX;bisectorNormalRight=[x,y];dt=c*d2;x=g[0]-dt*uY;y=g[1]+dt*uX;bisectorNormalLeft=[x,y]}}else{x=g[0]+c*(d[0]-g[0]);y=g[1]+c*(d[1]-g[1]);bisectorNormalRight=[x,y];x=g[0]+c*(h[0]-g[0]);y=g[1]+c*(h[1]-g[1]);bisectorNormalLeft=[x,y]}return[bisectorNormalRight,bisectorNormalLeft]};export function getNormal(c,d,g){let dX1=c[0]-d[0];let dY1=c[1]-d[1];const d1=Math.sqrt(dX1*dX1+dY1*dY1);dX1/=d1;dY1/=d1;let dX2=g[0]-d[0];let dY2=g[1]-d[1];const d2=Math.sqrt(dX2*dX2+dY2*dY2);dX2/=d2;dY2/=d2;const uX=dX1+dX2;const uY=dY1+dY2;return[uX,uY]};export function getCurvePoints(c,d){const leftControl=getLeftMostControlPoint(d);let normals=[leftControl];for(let i=0;i<d.length-2;i++){const pnt1=d[i];const pnt2=d[i+1];const pnt3=d[i+2];const normalPoints=getBisectorNormals(c,pnt1,pnt2,pnt3);normals=normals.concat(normalPoints)}const rightControl=getRightMostControlPoint(d);normals.push(rightControl);const points=[];for(let i=0;i<d.length-1;i++){const pnt1=d[i];const pnt2=d[i+1];points.push(pnt1);for(let j=0;j<Constants.FITTING_COUNT;j++){const pnt=getCubicValue(j/Constants.FITTING_COUNT,pnt1,normals[i*2],normals[i*2+1],pnt2);points.push(pnt)}points.push(pnt2)}return points};export function getLeftMostControlPoint(c){const pnt1=c[0];const pnt2=c[1];const pnt3=c[2];const pnts=getBisectorNormals(0,pnt1,pnt2,pnt3);const normalRight=pnts[0];const normal=getNormal(pnt1,pnt2,pnt3);const dist=Math.sqrt(normal[0]*normal[0]+normal[1]*normal[1]);let controlX,controlY;if(dist>Constants.ZERO_TOLERANCE){const arrMid=mid(pnt1,pnt2);const pX=pnt1[0]-arrMid[0];const pY=pnt1[1]-arrMid[1];const d1=distance(pnt1,pnt2);const n=2.0/d1;const nX=-n*pY;const nY=n*pX;const a11=nX*nX-nY*nY;const a12=2*nX*nY;const a22=nY*nY-nX*nX;const dX=normalRight[0]-arrMid[0];const dY=normalRight[1]-arrMid[1];controlX=arrMid[0]+a11*dX+a12*dY;controlY=arrMid[1]+a12*dX+a22*dY}else{}return[controlX,controlY]};export function getRightMostControlPoint(c){const count=c.length;const pnt1=c[count-3];const pnt2=c[count-2];const pnt3=c[count-1];const pnts=getBisectorNormals(0,pnt1,pnt2,pnt3);const normalLeft=pnts[1];const normal=getNormal(pnt1,pnt2,pnt3);const dist=Math.sqrt(normal[0]*normal[0]+normal[1]*normal[1]);let controlX,controlY;if(dist>Constants.ZERO_TOLERANCE){const arrMid=mid(pnt2,pnt3);const pX=pnt3[0]-arrMid[0];const pY=pnt3[1]-arrMid[1];const d1=distance(pnt2,pnt3);const n=2.0/d1;const nX=-n*pY;const nY=n*pX;const a11=nX*nX-nY*nY;const a12=2*nX*nY;const a22=nY*nY-nX*nX;const dX=normalLeft[0]-arrMid[0];const dY=normalLeft[1]-arrMid[1];controlX=arrMid[0]+a11*dX+a12*dY;controlY=arrMid[1]+a12*dX+a22*dY}else{}return[controlX,controlY]};export function getBezierPoints(c){if(c.length<=2){return c}const bezierPoints=[];const n=c.length-1;for(let t=0;t<=1;t+=0.01){let x=0;let y=0;for(let index=0;index<=n;index++){const factor=getBinomialFactor(n,index);const a=Math.pow(t,index);const b=Math.pow((1-t),(n-index));x+=factor*a*b*c[index][0];y+=factor*a*b*c[index][1]}bezierPoints.push([x,y])}bezierPoints.push(c[n]);return bezierPoints};export function getBinomialFactor(c,d){return getFactorial(c)/(getFactorial(d)*getFactorial(c-d))};export function getFactorial(c){if(c<=1){return 1}if(c===2){return 2}if(c===3){return 6}if(c===4){return 24}if(c===5){return 120}let result=1;for(let i=1;i<=c;i++){result*=i}return result};export function getQBSplinePoints(c){if(c.length<=2){return c}const n=2;const bSplinePoints=[];const m=c.length-n-1;bSplinePoints.push(c[0]);for(let i=0;i<=m;i++){for(let t=0;t<=1;t+=0.05){let x=0;let y=0;for(let k=0;k<=n;k++){const factor=getQuadricBSplineFactor(k,t);x+=factor*c[i+k][0];y+=factor*c[i+k][1]}bSplinePoints.push([x,y])}}bSplinePoints.push(c[c.length-1]);return bSplinePoints};export function getQuadricBSplineFactor(c,d){if(c===0){return Math.pow(d-1,2)/2}if(c===1){return(-2*Math.pow(d,2)+2*d+1)/2}if(c===2){return Math.pow(d,2)/2}return 0};
|