@geoscene/core 4.34.9 → 4.34.10

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.
Files changed (69) hide show
  1. package/analysis/ViewshedVideo.js +5 -0
  2. package/analysis/viewshedVideo/ViewshedAnalysisView3DVideo.js +5 -0
  3. package/analysis/viewshedVideo/ViewshedComputedDataVideo.js +5 -0
  4. package/analysis/viewshedVideo/ViewshedSubVisualizationVideo.js +5 -0
  5. package/analysis/viewshedVideo/ViewshedVisualizationVideo.js +5 -0
  6. package/analysis/viewshedVideo/render/ViewshedTechniqueVideo.js +5 -0
  7. package/analysis/viewshedVideo/render/ViewshedVideo.glsl.js +243 -0
  8. package/analysis/viewshedVideo/render/ViewshedVideo.js +5 -0
  9. package/bundle/lib/fflate.js +12 -0
  10. package/layers/mixins/SceneService.js +1 -1
  11. package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
  12. package/layers/support/rasterFormats/ImageCanvasDecoder.js +1 -1
  13. package/layers/support/rasterFormats/RasterCodec.js +1 -1
  14. package/layers/voxel/drill/VoxelContinuousDrill.js +5 -0
  15. package/layers/voxel/drill/VoxelDiscreteDrill.js +5 -0
  16. package/layers/voxel/drill/common.js +5 -0
  17. package/package.json +1 -1
  18. package/views/3d/analysis/analysisViewModuleImportUtils.js +1 -1
  19. package/views/3d/layers/I3SMeshView3D.js +1 -1
  20. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  21. package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
  22. package/views/3d/layers/ViewshedLayerView3D.js +1 -1
  23. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  24. package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
  25. package/views/3d/layers/support/LayerViewAnalysisViewManager.js +1 -1
  26. package/views/draw/expert/AttackArrowDrawer.js +5 -0
  27. package/views/draw/expert/AttackTailedArrowDrawer.js +5 -0
  28. package/views/draw/expert/BaseDrawer.js +5 -0
  29. package/views/draw/expert/Constant.js +5 -0
  30. package/views/draw/expert/CurveDrawer.js +5 -0
  31. package/views/draw/expert/CurveFlagDrawer.js +5 -0
  32. package/views/draw/expert/CurvedArrowDrawer.js +5 -0
  33. package/views/draw/expert/EllipseDrawer.js +5 -0
  34. package/views/draw/expert/ExpertDraw.js +5 -0
  35. package/views/draw/expert/GatheringPlaceDrawer.js +5 -0
  36. package/views/draw/expert/LuneDrawer.js +5 -0
  37. package/views/draw/expert/PincerArrowDrawer.js +5 -0
  38. package/views/draw/expert/SectorDrawer.js +5 -0
  39. package/views/draw/expert/SquadCombatDrawer.js +5 -0
  40. package/views/draw/expert/StraightArrowDrawer.js +5 -0
  41. package/views/draw/expert/TailedSquadCombatDrawer.js +5 -0
  42. package/views/draw/expert/plot/Constants.js +5 -0
  43. package/views/draw/expert/plot/PlotTypes.js +5 -0
  44. package/views/draw/expert/plot/plots/Arc.js +41 -0
  45. package/views/draw/expert/plot/plots/AssaultDirection.js +15 -0
  46. package/views/draw/expert/plot/plots/AttackArrow.js +5 -0
  47. package/views/draw/expert/plot/plots/Circle.js +5 -0
  48. package/views/draw/expert/plot/plots/ClosedCurve.js +5 -0
  49. package/views/draw/expert/plot/plots/Curve.js +5 -0
  50. package/views/draw/expert/plot/plots/CurveFlag.js +5 -0
  51. package/views/draw/expert/plot/plots/CurvedArrow.js +5 -0
  52. package/views/draw/expert/plot/plots/DoubleArrow.js +5 -0
  53. package/views/draw/expert/plot/plots/Ellipse.js +5 -0
  54. package/views/draw/expert/plot/plots/FineArrow.js +5 -0
  55. package/views/draw/expert/plot/plots/FreehandLine.js +19 -0
  56. package/views/draw/expert/plot/plots/FreehandPolygon.js +19 -0
  57. package/views/draw/expert/plot/plots/GatheringPlace.js +5 -0
  58. package/views/draw/expert/plot/plots/Lune.js +5 -0
  59. package/views/draw/expert/plot/plots/Marker.js +16 -0
  60. package/views/draw/expert/plot/plots/Plot.js +5 -0
  61. package/views/draw/expert/plot/plots/Polygon.js +18 -0
  62. package/views/draw/expert/plot/plots/Polyline.js +19 -0
  63. package/views/draw/expert/plot/plots/Rectangle.js +28 -0
  64. package/views/draw/expert/plot/plots/Sector.js +5 -0
  65. package/views/draw/expert/plot/plots/SquadCombat.js +5 -0
  66. package/views/draw/expert/plot/plots/StraightArrow.js +5 -0
  67. package/views/draw/expert/plot/plots/TailedAttackArrow.js +5 -0
  68. package/views/draw/expert/plot/plots/TailedSquadCombat.js +5 -0
  69. package/views/draw/expert/plot/utils/plot_util.js +5 -0
@@ -0,0 +1,15 @@
1
+ import PlotTypes from '../PlotTypes.js';
2
+ import FineArrow from './FineArrow.js';
3
+
4
+ export default class AssaultDirection extends FineArrow {
5
+ constructor(points) {
6
+ super(points);
7
+ this.type = PlotTypes.ASSAULT_DIRECTION;
8
+ this.tailWidthFactor = 0.2;
9
+ this.neckWidthFactor = 0.25;
10
+ this.headWidthFactor = 0.3;
11
+ this.headAngle = Math.PI / 4;
12
+ this.neckAngle = Math.PI * 0.17741;
13
+ this.setPoints(points);
14
+ }
15
+ }
@@ -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 AttackArrow extends Plot{constructor(points){super(points);this.type=PlotTypes.ATTACK_ARROW;this.headHeightFactor=0.18;this.headWidthFactor=0.3;this.neckHeightFactor=0.85;this.neckWidthFactor=0.15;this.headTailFactor=0.8;this.setPoints(points)}generate(){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 tailWidthFactor=PlotUtils.distance(tailLeft,tailRight)/PlotUtils.getBaseLength(bonePnts);const bodyPnts=this.getArrowBodyPoints(bonePnts,neckLeft,neckRight,tailWidthFactor);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())}getArrowHeadPoints(points,tailLeft,tailRight){let len=PlotUtils.getBaseLength(points);let headHeight=len*this.headHeightFactor;const headPnt=points[points.length-1];len=PlotUtils.distance(headPnt,points[points.length-2]);const tailWidth=PlotUtils.distance(tailLeft,tailRight);if(headHeight>tailWidth*this.headTailFactor){headHeight=tailWidth*this.headTailFactor}const headWidth=headHeight*this.headWidthFactor;const neckWidth=headHeight*this.neckWidthFactor;const neckHeight=headHeight*this.neckHeightFactor;const headEndPnt=PlotUtils.getThirdPoint(points[points.length-2],headPnt,0,headHeight,true);const neckEndPnt=PlotUtils.getThirdPoint(points[points.length-2],headPnt,0,neckHeight,true);const headLeft=PlotUtils.getThirdPoint(headPnt,headEndPnt,Constants.HALF_PI,headWidth,false);const headRight=PlotUtils.getThirdPoint(headPnt,headEndPnt,Constants.HALF_PI,headWidth,true);const neckLeft=PlotUtils.getThirdPoint(headPnt,neckEndPnt,Constants.HALF_PI,neckWidth,false);const neckRight=PlotUtils.getThirdPoint(headPnt,neckEndPnt,Constants.HALF_PI,neckWidth,true);return[neckLeft,headLeft,headPnt,headRight,neckRight]}getArrowBodyPoints(points,neckLeft,neckRight,tailWidthFactor){const allLen=PlotUtils.wholeDistance(points);const len=PlotUtils.getBaseLength(points);const tailWidth=len*tailWidthFactor;const neckWidth=PlotUtils.distance(neckLeft,neckRight);const widthDif=(tailWidth-neckWidth)/2;let tempLen=0;const leftBodyPnts=[];const rightBodyPnts=[];for(let i=1;i<points.length-1;i++){const angle=PlotUtils.getAngleOfThreePoints(points[i-1],points[i],points[i+1])/2;tempLen+=PlotUtils.distance(points[i-1],points[i]);const w=(tailWidth/2-tempLen/allLen*widthDif)/Math.sin(angle);const left=PlotUtils.getThirdPoint(points[i-1],points[i],Math.PI-angle,w,true);const right=PlotUtils.getThirdPoint(points[i-1],points[i],angle,w,false);leftBodyPnts.push(left);rightBodyPnts.push(right)}return leftBodyPnts.concat(rightBodyPnts)}getAttackArrowHeadPoints(t,o,e,defaultParam){this.headHeightFactor=defaultParam.headHeightFactor;this.headTailFactor=defaultParam.headTailFactor;this.headWidthFactor=defaultParam.headWidthFactor;this.neckWidthFactor=defaultParam.neckWidthFactor;this.neckHeightFactor=defaultParam.neckHeightFactor;let r=PlotUtils.getBaseLength(t);let n=r*this.headHeightFactor;const g=t[t.length-1];r=PlotUtils.distance(g,t[t.length-2]);const i=PlotUtils.distance(o,e);n>i*this.headTailFactor&&(n=i*this.headTailFactor);const s=n*this.headWidthFactor;const a=n*this.neckWidthFactor;n=n>r?r:n;const l=n*this.neckHeightFactor;const u=PlotUtils.getThirdPoint(t[t.length-2],g,0,n,!0);const c=PlotUtils.getThirdPoint(t[t.length-2],g,0,l,!0);const p=PlotUtils.getThirdPoint(g,u,Constants.HALF_PI,s,!1);const h=PlotUtils.getThirdPoint(g,u,Constants.HALF_PI,s,!0);const d=PlotUtils.getThirdPoint(g,c,Constants.HALF_PI,a,!1);const f=PlotUtils.getThirdPoint(g,c,Constants.HALF_PI,a,!0);return[d,p,g,h,f]}getAttackArrowBodyPoints(t,o,e,r){const u=[];const c=[];for(let n=PlotUtils.wholeDistance(t),g=PlotUtils.getBaseLength(t),i=g*r,s=PlotUtils.distance(o,e),a=(i-s)/2,l=0,p=1;p<t.length-1;p++){const h=PlotUtils.getAngleOfThreePoints(t[p-1],t[p],t[p+1])/2;l+=PlotUtils.distance(t[p-1],t[p]);const d=(i/2-l/n*a)/Math.sin(h);const f=PlotUtils.getThirdPoint(t[p-1],t[p],Math.PI-h,d,!0);const E=PlotUtils.getThirdPoint(t[p-1],t[p],h,d,!1);u.push(f);c.push(E)}return u.concat(c)}}
@@ -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{distance}from'../utils/plot_util.js';import Constants from'../Constants.js';export default class Circle extends Plot{constructor(points){super(points);this.type=PlotTypes.CIRCLE;this.fixPointCount=2;this.setPoints(points)}generate(){const count=this.getPointCount();if(count<2){return}const center=this.points[0];const radius=distance(center,this.points[1]);this.setCoordinates([this.generatePoints(center,radius)])}generatePoints(center,radius){let x;let y;let angle;const points=[];for(let i=0;i<=Constants.FITTING_COUNT;i++){angle=Math.PI*2*i/Constants.FITTING_COUNT;x=center[0]+radius*Math.cos(angle);y=center[1]+radius*Math.sin(angle);points.push([x,y])}return points}}
@@ -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 ClosedCurve extends Plot{constructor(points){super(points);this.type=PlotTypes.CLOSED_CURVE;this.t=0.3;this.setPoints(points)}generate(){let count=this.getPointCount();if(count<2){return}if(count===2){this.setCoordinates([this.points])}else{const pnts=this.getPoints();pnts.push(pnts[0],pnts[1]);let normals=[];for(let i=0;i<pnts.length-2;i++){const normalPoints=PlotUtils.getBisectorNormals(this.t,pnts[i],pnts[i+1],pnts[i+2]);normals=normals.concat(normalPoints)}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';export default class Curve extends Plot{constructor(points){super(points);this.type=PlotTypes.CURVE;this.t=0.3;this.setPoints(points)}generate(){const count=this.getPointCount();if(count<2){return}if(count===2){this.setCoordinates([this.points])}else{this.setCoordinates(PlotUtils.getCurvePoints(this.t,this.points))}}}
@@ -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 utils from'../utils/plot_util.js';export default class CurveFlag extends Plot{constructor(points){super(points);this.type=PlotTypes.CURVE_FLAG;this.t=0.3;this.setPoints(points)}generate(){const count=this.getPointCount();if(count<2){return}this.setCoordinates(this.calculatePoints(this.points))}calculatePoints(points){let components=[];if(points.length>1){const startPoint=points[0];const endPoint=points[points.length-1];const point1=startPoint;const point2=[(endPoint[0]-startPoint[0])/4+startPoint[0],(endPoint[1]-startPoint[1])/8+startPoint[1]];const point3=[(startPoint[0]+endPoint[0])/2,startPoint[1]];const point4=[(endPoint[0]-startPoint[0])*3/4+startPoint[0],-(endPoint[1]-startPoint[1])/8+startPoint[1]];const point5=[endPoint[0],startPoint[1]];const point6=[endPoint[0],(startPoint[1]+endPoint[1])/2];const point7=[(endPoint[0]-startPoint[0])*3/4+startPoint[0],(endPoint[1]-startPoint[1])*3/8+startPoint[1]];const point8=[(startPoint[0]+endPoint[0])/2,(startPoint[1]+endPoint[1])/2];const point9=[(endPoint[0]-startPoint[0])/4+startPoint[0],(endPoint[1]-startPoint[1])*5/8+startPoint[1]];const point10=[startPoint[0],(startPoint[1]+endPoint[1])/2];const point11=[startPoint[0],endPoint[1]];const curve1=utils.getBezierPoints([point1,point2,point3,point4,point5]);const curve2=utils.getBezierPoints([point6,point7,point8,point9,point10,point10,point10,point10,point10]);components=curve1.concat(curve2);components.push(point11);components.push(startPoint)}return components}}
@@ -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 Curve extends Plot{constructor(points){super(points);this.type=PlotTypes.CURVE;this.t=0.3;this.arrowLengthScale=5;this.maxArrowLength=3000000;this.setPoints(points)}generate(){const count=this.getPointCount();if(count<2){return}if(count===2){const[pnt1,pnt2]=this.points;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/2,false);const rightPnt=PlotUtils.getThirdPoint(pnt1,pnt2,Math.PI/6,len/2,true);this.setCoordinates([pnt1,pnt2,leftPnt,pnt2,rightPnt])}else{const curvePoints=PlotUtils.getCurvePoints(this.t,this.points);const pnt2=this.points[this.points.length-1];const distance=PlotUtils.wholeDistance(this.points);let len=distance/this.arrowLengthScale;len=len>this.maxArrowLength?this.maxArrowLength:len;const leftPnt=PlotUtils.getThirdPoint(curvePoints[curvePoints.length-2],curvePoints[curvePoints.length-1],Math.PI/6,len/2,false);const rightPnt=PlotUtils.getThirdPoint(curvePoints[curvePoints.length-2],curvePoints[curvePoints.length-1],Math.PI/6,len/2,true);this.setCoordinates([[...curvePoints],[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 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 DoubleArrow extends Plot{constructor(points){super(points);this.type=PlotTypes.DOUBLE_ARROW;this.headHeightFactor=0.25;this.headWidthFactor=0.3;this.neckHeightFactor=0.85;this.neckWidthFactor=0.15;this.connPoint=null;this.tempPoint4=null;this.fixPointCount=4;this.setPoints(points)}generate(){let count=this.getPointCount();if(count<2){return}if(count===2){this.setCoordinates([this.points]);return}const pnt1=this.points[0];const pnt2=this.points[1];const pnt3=this.points[2];count=this.getPointCount();if(count===3){this.tempPoint4=this.getTempPoint4(pnt1,pnt2,pnt3)}else{this.tempPoint4=this.points[3]}if(count===3||count===4){this.connPoint=PlotUtils.mid(pnt1,pnt2)}else{this.connPoint=this.points[4]}let leftArrowPnts,rightArrowPnts;if(PlotUtils.isClockWise(pnt1,pnt2,pnt3)){leftArrowPnts=this.getArrowPoints(pnt1,this.connPoint,this.tempPoint4,false);rightArrowPnts=this.getArrowPoints(this.connPoint,pnt2,pnt3,true)}else{leftArrowPnts=this.getArrowPoints(pnt2,this.connPoint,pnt3,false);rightArrowPnts=this.getArrowPoints(this.connPoint,pnt1,this.tempPoint4,true)}const m=leftArrowPnts.length;const t=(m-5)/2;const llBodyPnts=leftArrowPnts.slice(0,t);const lArrowPnts=leftArrowPnts.slice(t,t+5);let lrBodyPnts=leftArrowPnts.slice(t+5,m);let rlBodyPnts=rightArrowPnts.slice(0,t);const rArrowPnts=rightArrowPnts.slice(t,t+5);const rrBodyPnts=rightArrowPnts.slice(t+5,m);rlBodyPnts=PlotUtils.getBezierPoints(rlBodyPnts);const bodyPnts=PlotUtils.getBezierPoints(rrBodyPnts.concat(llBodyPnts.slice(1)));lrBodyPnts=PlotUtils.getBezierPoints(lrBodyPnts);const pnts=rlBodyPnts.concat(rArrowPnts,bodyPnts,lArrowPnts,lrBodyPnts);this.setCoordinates([pnts])}getArrowPoints(pnt1,pnt2,pnt3,clockWise){const midPnt=PlotUtils.mid(pnt1,pnt2);const len=PlotUtils.distance(midPnt,pnt3);let midPnt1=PlotUtils.getThirdPoint(pnt3,midPnt,0,len*0.3,true);let midPnt2=PlotUtils.getThirdPoint(pnt3,midPnt,0,len*0.5,true);midPnt1=PlotUtils.getThirdPoint(midPnt,midPnt1,Constants.HALF_PI,len/5,clockWise);midPnt2=PlotUtils.getThirdPoint(midPnt,midPnt2,Constants.HALF_PI,len/4,clockWise);const points=[midPnt,midPnt1,midPnt2,pnt3];const arrowPnts=this.getArrowHeadPoints(points,this.headHeightFactor,this.headWidthFactor,this.neckHeightFactor,this.neckWidthFactor);const neckLeftPoint=arrowPnts[0];const neckRightPoint=arrowPnts[4];const tailWidthFactor=PlotUtils.distance(pnt1,pnt2)/PlotUtils.getBaseLength(points)/2;const bodyPnts=this.getArrowBodyPoints(points,neckLeftPoint,neckRightPoint,tailWidthFactor);const n=bodyPnts.length;let lPoints=bodyPnts.slice(0,n/2);let rPoints=bodyPnts.slice(n/2,n);lPoints.push(neckLeftPoint);rPoints.push(neckRightPoint);lPoints=lPoints.reverse();lPoints.push(pnt2);rPoints=rPoints.reverse();rPoints.push(pnt1);return lPoints.reverse().concat(arrowPnts,rPoints)};finishDrawing(){if(this.getPointCount()===3&&this.tempPoint4!==null){this.points.push(this.tempPoint4)}if(this.connPoint!==null){this.points.push(this.connPoint)}};getArrowHeadPoints(points,tailLeft,tailRight){const len=PlotUtils.getBaseLength(points);const headHeight=len*this.headHeightFactor;const headPnt=points[points.length-1];const headWidth=headHeight*this.headWidthFactor;const neckWidth=headHeight*this.neckWidthFactor;const neckHeight=headHeight*this.neckHeightFactor;const headEndPnt=PlotUtils.getThirdPoint(points[points.length-2],headPnt,0,headHeight,true);const neckEndPnt=PlotUtils.getThirdPoint(points[points.length-2],headPnt,0,neckHeight,true);const headLeft=PlotUtils.getThirdPoint(headPnt,headEndPnt,Constants.HALF_PI,headWidth,false);const headRight=PlotUtils.getThirdPoint(headPnt,headEndPnt,Constants.HALF_PI,headWidth,true);const neckLeft=PlotUtils.getThirdPoint(headPnt,neckEndPnt,Constants.HALF_PI,neckWidth,false);const neckRight=PlotUtils.getThirdPoint(headPnt,neckEndPnt,Constants.HALF_PI,neckWidth,true);return[neckLeft,headLeft,headPnt,headRight,neckRight]};getArrowBodyPoints(points,neckLeft,neckRight,tailWidthFactor){const allLen=PlotUtils.wholeDistance(points);const len=PlotUtils.getBaseLength(points);const tailWidth=len*tailWidthFactor;const neckWidth=PlotUtils.distance(neckLeft,neckRight);const widthDif=(tailWidth-neckWidth)/2;let tempLen=0;const leftBodyPnts=[];const rightBodyPnts=[];for(let i=1;i<points.length-1;i++){const angle=PlotUtils.getAngleOfThreePoints(points[i-1],points[i],points[i+1])/2;tempLen+=PlotUtils.distance(points[i-1],points[i]);const w=(tailWidth/2-tempLen/allLen*widthDif)/Math.sin(angle);const left=PlotUtils.getThirdPoint(points[i-1],points[i],Math.PI-angle,w,true);const right=PlotUtils.getThirdPoint(points[i-1],points[i],angle,w,false);leftBodyPnts.push(left);rightBodyPnts.push(right)}return leftBodyPnts.concat(rightBodyPnts)};getTempPoint4(linePnt1,linePnt2,point){const midPnt=PlotUtils.mid(linePnt1,linePnt2);const len=PlotUtils.distance(midPnt,point);const angle=PlotUtils.getAngleOfThreePoints(linePnt1,midPnt,point);let symPnt,distance1,distance2,mid;if(angle<Constants.HALF_PI){distance1=len*Math.sin(angle);distance2=len*Math.cos(angle);mid=PlotUtils.getThirdPoint(linePnt1,midPnt,Constants.HALF_PI,distance1,false);symPnt=PlotUtils.getThirdPoint(midPnt,mid,Constants.HALF_PI,distance2,true)}else if(angle>=Constants.HALF_PI&&angle<Math.PI){distance1=len*Math.sin(Math.PI-angle);distance2=len*Math.cos(Math.PI-angle);mid=PlotUtils.getThirdPoint(linePnt1,midPnt,Constants.HALF_PI,distance1,false);symPnt=PlotUtils.getThirdPoint(midPnt,mid,Constants.HALF_PI,distance2,false)}else if(angle>=Math.PI&&angle<Math.PI*1.5){distance1=len*Math.sin(angle-Math.PI);distance2=len*Math.cos(angle-Math.PI);mid=PlotUtils.getThirdPoint(linePnt1,midPnt,Constants.HALF_PI,distance1,true);symPnt=PlotUtils.getThirdPoint(midPnt,mid,Constants.HALF_PI,distance2,true)}else{distance1=len*Math.sin(Math.PI*2-angle);distance2=len*Math.cos(Math.PI*2-angle);mid=PlotUtils.getThirdPoint(linePnt1,midPnt,Constants.HALF_PI,distance1,true);symPnt=PlotUtils.getThirdPoint(midPnt,mid,Constants.HALF_PI,distance2,false)}return symPnt}}
@@ -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 Constants from'../Constants.js';import*as PlotUtils from'../utils/plot_util.js';export default class Ellipse extends Plot{constructor(points){super(points);this.type=PlotTypes.ELLIPSE;this.fixPointCount=2;this.setPoints(points)}generate(){const count=this.getPointCount();if(count<2){return}const pnt1=this.points[0];const pnt2=this.points[1];const center=PlotUtils.mid(pnt1,pnt2);const majorRadius=Math.abs((pnt1[0]-pnt2[0])/2);const minorRadius=Math.abs((pnt1[1]-pnt2[1])/2);this.setCoordinates([this.generatePoints(center,majorRadius,majorRadius)])}generatePoints(center,majorRadius,minorRadius){let x;let y;let angle;const points=[];for(let i=0;i<=Constants.FITTING_COUNT;i++){angle=Math.PI*2*i/Constants.FITTING_COUNT;x=center[0]+majorRadius*Math.cos(angle);y=center[1]+minorRadius*Math.sin(angle);points.push([x,y])}return points}}
@@ -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 FineArrow extends Plot{constructor(points){super(points);this.type=PlotTypes.FINE_ARROW;this.tailWidthFactor=0.15;this.neckWidthFactor=0.2;this.headWidthFactor=0.25;this.headAngle=Math.PI/8.5;this.neckAngle=Math.PI/13;this.fixPointCount=2;this.setPoints(points)}generate(){const count=this.getPointCount();if(count<2){return}const pnts=this.getPoints();const pnt1=pnts[0];const pnt2=pnts[1];const len=PlotUtils.getBaseLength(pnts);const tailWidth=len*this.tailWidthFactor;const neckWidth=len*this.neckWidthFactor;const headWidth=len*this.headWidthFactor;const tailLeft=PlotUtils.getThirdPoint(pnt2,pnt1,Constants.HALF_PI,tailWidth,true);const tailRight=PlotUtils.getThirdPoint(pnt2,pnt1,Constants.HALF_PI,tailWidth,false);const headLeft=PlotUtils.getThirdPoint(pnt1,pnt2,this.headAngle,headWidth,false);const headRight=PlotUtils.getThirdPoint(pnt1,pnt2,this.headAngle,headWidth,true);const neckLeft=PlotUtils.getThirdPoint(pnt1,pnt2,this.neckAngle,neckWidth,false);const neckRight=PlotUtils.getThirdPoint(pnt1,pnt2,this.neckAngle,neckWidth,true);const pList=[tailLeft,neckLeft,headLeft,pnt2,headRight,neckRight,tailRight];this.coordinates=pList}}
@@ -0,0 +1,19 @@
1
+ import Plot from './Plot.js';
2
+ import PlotTypes from '../PlotTypes.js';
3
+
4
+ export default class FreehandLine extends Plot {
5
+ constructor(points) {
6
+ super(points);
7
+ this.type = PlotTypes.FREEHAND_LINE;
8
+ this.freehand = true;
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,19 @@
1
+ import Plot from './Plot.js';
2
+ import PlotTypes from '../PlotTypes.js';
3
+
4
+ export default class FreehandPolygon extends Plot {
5
+ constructor(points) {
6
+ super(points);
7
+ this.type = PlotTypes.FREEHAND_POLYGON;
8
+ this.freehand = true;
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,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};