UNPKG

thematic-earth

Version:

HTML-based, whole-Earth thematic maps using locally hosted data layers

2 lines 2.81 kB
/* Copyright (c) 2023 Read Write Tools. Legal use subject to the Thematic Earth Software License Agreement. */ import BaseSpatialFile from'../catalog/base-spatial-file.class.js';import GeneralFeature from'../features/general-feature.class.js';import*as Color from'../graphics/color.js';import FT from'../enum/feature-type.enum.js';import expect from'../dev/expect.js';export default class Sphere extends BaseSpatialFile{constructor(e){super(e);var t=new Object;this.generalFeature=new GeneralFeature(t,FT.SPHERE),this.localPointsNeedGeoCoords=!0,this.localPointsNeedProjection=!0,this.localPointsNeedTransformation=!0,this.localPointsNeedPlacement=!0,this.thematicEarthElement.signal.broadcast('catalog/spatialFileAdded',{spatialFileType:'sphere'}),Object.seal(this)}recomputeStyles(e,t,r,a){expect(e,'RenderClock'),expect(t,'Visualizer'),expect(r,'Layer'),expect(a,'Number'),super.recomputeStyles(e,t,r,(()=>{this.generalFeature.computeFeatureStyle(e,t,r.tessClassname,r.tessIdentifier,0,a)}))}runCourtesyValidator(e,t,r){expect(e,'Visualizer'),expect(t,'Layer'),expect(r,'Number'),super.runCourtesyValidator((()=>{this.generalFeature.runCourtesyValidator(e,t.tessClassname,t.tessIdentifier,0,r)}))}rotation(e,t){expect(e,'RenderClock'),expect(t,'GeocentricCoordinates'),super.rotation(e,t,(()=>{}))}projection(e,t){expect(e,'RenderClock'),expect(t,'OrthographicProjection'),super.projection(e,t,(()=>{}))}transformation(e,t){expect(e,'RenderClock'),expect(t,'CartesianTransformation'),super.transformation(e,t,(()=>{}))}placement(e,t){expect(e,'RenderClock'),expect(t,'Viewport'),super.placement(e,t,(()=>{}))}drawLayer(e,t,r){expect(e,'RenderClock'),expect(t,'Earth'),expect(r,'Layer'),super.drawLayer(e,(()=>{let e=this.generalFeature.getCanvasParamsPerLayerId(r.layerId);'hidden'!=e.safeString('visibility')&&this.drawSphere(t,e)}))}drawSphere(e,t){expect(e,'Earth'),expect(t,'CanvasParams');var r=e.canvas.getContext('2d'),a=e.carte.translate.a*e.carte.multiplier,o=e.carte.translate.b*e.carte.multiplier,s=e.viewport.centerPoint.x+a,i=e.viewport.centerPoint.y+o,l=e.getVisualizedRadius();r.beginPath(),r.arc(s,i,l,0,2*Math.PI,!1),r.closePath();var n=t.safeString('fill-color');if('none'!=n){var c=t.getTransparency();r.fillStyle=Color.computeColorPlusTransparency(n,c)}if(t.wantsStroke()){var p=t.safeString('stroke-color');c=t.getTransparency();r.strokeStyle=Color.computeColorPlusTransparency(p,c),r.lineWidth=t.safeNumber('stroke-width'),r.stroke()}t.hasFillColor()&&(r.fillStyle=t.safeString('fill-color'),r.globalCompositeOperation=t.safeString('fill-composition'),r.fill(),r.globalCompositeOperation='source-over')}discoverFeatures(e,t,r){if(this.generalFeature.featureIsVisible(r)&&1==this.thematicEarthElement.earth.getCoordinatesFromCanvasXY(e,t).isOnEarth)return this.generalFeature;return null}}