UNPKG

thematic-earth

Version:

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

2 lines 3.23 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 HemisphereFeature from'../features/hemisphere-feature.class.js';import RS from'../enum/rendering-state.enum.js';import*as CB from'../menu/menu-callbacks.js';import expect from'../dev/expect.js';const degreesToRadians=Math.PI/180;export default class Night extends BaseSpatialFile{constructor(t){super(t);this.identityPoints=new HemisphereFeature(90),this.identityPoints.featureName='night',this.registerEventListeners(),this.localPointsNeedGeoCoords=!0,this.localPointsNeedProjection=!0,this.localPointsNeedTransformation=!0,this.localPointsNeedPlacement=!0,this.thematicEarthElement.signal.broadcast('catalog/spatialFileAdded',{spatialFileType:'night'}),Object.seal(this)}registerEventListeners(){this.thematicEarthElement.signal.listen('carte/solarDeclination',(t=>{this.localPointsNeedProjection=!0,this.localPointsNeedTransformation=!0})),this.thematicEarthElement.signal.listen('earthPosition/timeOfDayHMS',(t=>{this.localPointsNeedProjection=!0,this.localPointsNeedTransformation=!0}))}recomputeStyles(t,e,i,s){expect(t,'RenderClock'),expect(e,'Visualizer'),expect(i,'Layer'),expect(s,'Number'),super.recomputeStyles(t,e,i,(()=>{this.identityPoints.computeFeatureStyle(t,e,i.tessClassname,i.tessIdentifier,0,s)}))}runCourtesyValidator(t,e,i){expect(t,'Visualizer'),expect(e,'Layer'),expect(i,'Number'),super.runCourtesyValidator((()=>{this.identityPoints.runCourtesyValidator(t,e.tessClassname,e.tessIdentifier,0,i)}))}rotation(t,e){expect(t,'RenderClock'),expect(e,'GeocentricCoordinates'),super.rotation(t,e,(()=>{for(var t=0;t<this.identityPoints.outerRing.length;t++)e.toNightPhiLambda(this.identityPoints.outerRing[t])}))}projection(t,e){expect(t,'RenderClock'),expect(e,'OrthographicProjection'),super.projection(t,e,(()=>{var t=CB.numSecondsSinceMidnightUTC(this.thematicEarthElement.earth.earthPosition.UTC)+64800;t>=86400&&(t-=86400);var i=2*(t/86400)*Math.PI;this.identityPoints.pointsOnNearSide=0,this.identityPoints.pointsOnFarSide=0;for(var s=0;s<this.identityPoints.outerRing.length;s++){let t=this.identityPoints.outerRing[s];e.toNightEastingNorthing(t,i),t.isOnNearSide?this.identityPoints.pointsOnNearSide++:this.identityPoints.pointsOnFarSide++}}))}transformation(t,e){expect(t,'RenderClock'),expect(e,'CartesianTransformation'),super.transformation(t,e,(()=>{for(var t=0;t<this.identityPoints.outerRing.length;t++)e.toEarthXY(this.identityPoints.outerRing[t],!0,!0,!0)}))}placement(t,e){expect(t,'RenderClock'),expect(e,'Viewport'),super.placement(t,e,(()=>{for(var i=0;i<this.identityPoints.outerRing.length;i++){let s=this.identityPoints.outerRing[i];if(e.toCanvasXY(s),s.isOnNearSide)if(s.isOnCanvas)this.identityPoints.pointsOnCanvas++;else if(this.identityPoints.pointsOffCanvas++,t.renderingState==RS.SKETCHING)return}}))}drawLayer(t,e,i){expect(t,'RenderClock'),expect(e,'Earth'),expect(i,'Layer'),super.drawLayer(t,(()=>{this.identityPoints.drawFeature(t,e,i)}))}discoverFeatures(t,e,i){return this.identityPoints.featureIsVisible(i)&&this.identityPoints.isPointerInsidePolygon(t,e)?this.identityPoints:null}}