UNPKG

thematic-earth

Version:

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

2 lines 2.54 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 LineFeature from'../features/line-feature.class.js';import ProjectedPoint from'../projection/projected-point.class.js';import expect from'../dev/expect.js';export default class NamedParallels extends BaseSpatialFile{constructor(e,t){for(var a in super(e),this.parallels=[],t)if(t.hasOwnProperty(a)){var r=new LineFeature;r.featureName=a,r.kvPairs.name=r.featureName;var l=t[a];if(l<-90||l>90)continue;for(var s=-180;s<=180;s++)r.addPoint(new ProjectedPoint(l,s));this.parallels.push(r),this.addFeatureToLookupMap(r)}this.localPointsNeedGeoCoords=!0,this.localPointsNeedProjection=!0,this.localPointsNeedTransformation=!0,this.localPointsNeedPlacement=!0,this.thematicEarthElement.signal.broadcast('catalog/spatialFileAdded',{spatialFileType:'named-parallels',namedCircles:t}),Object.seal(this)}recomputeStyles(e,t,a,r){expect(e,'RenderClock'),expect(t,'Visualizer'),expect(a,'Layer'),expect(r,'Number'),super.recomputeStyles(e,t,a,(()=>{for(var l=0;l<this.parallels.length;l++)this.parallels[l].computeFeatureStyle(e,t,a.tessClassname,a.tessIdentifier,l,r)}))}runCourtesyValidator(e,t,a){expect(e,'Visualizer'),expect(t,'Layer'),expect(a,'Number'),super.runCourtesyValidator((()=>{for(var r=0;r<this.parallels.length;r++)this.parallels[r].runCourtesyValidator(e,t.tessClassname,t.tessIdentifier,r,a)}))}rotation(e,t){expect(e,'RenderClock'),expect(t,'GeocentricCoordinates'),super.rotation(e,t,(()=>{for(var a=0;a<this.parallels.length;a++)this.parallels[a].toGeoCoords(e,t)}))}projection(e,t){expect(e,'RenderClock'),expect(t,'OrthographicProjection'),super.projection(e,t,(()=>{for(var a=0;a<this.parallels.length;a++)this.parallels[a].toPlane(e,t)}))}transformation(e,t){expect(e,'RenderClock'),expect(t,'CartesianTransformation'),super.transformation(e,t,(()=>{for(var a=0;a<this.parallels.length;a++)this.parallels[a].toPixels(e,t)}))}placement(e,t){expect(e,'RenderClock'),expect(t,'Viewport'),super.placement(e,t,(()=>{for(var a=0;a<this.parallels.length;a++)this.parallels[a].toViewportCanvas(e,t)}))}drawLayer(e,t,a){expect(e,'RenderClock'),expect(t,'Earth'),expect(a,'Layer'),super.drawLayer(e,(()=>{for(var r=0;r<this.parallels.length;r++)this.parallels[r].drawFeature(e,t,a)}))}discoverFeatures(e,t,a){for(var r=0;r<this.parallels.length;r++){var l=this.parallels[r];if(l.featureIsVisible(a)&&l.isPointerOnLine(e,t))return l}return null}}