Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

satellite-view

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

satellite-view

Re-project a map to a globe with WebGL

  • 2.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

satellite-view

tests

Re-project a map to a globe with WebGL

The latitude and longitude under each pixel is computed via the inverse General Perspective Projection, following the equations in John Snyder's Map Projections, A Working Manual.

When the point of perspective is close to the surface of the sphere, Snyder's exact equations are replaced by series approximations. These approximations are numerically more robust in single-precision floating point math, as used by WebGL. See Robust Raster Reprojection for details on the approximations.

Check out the live example using tiles from Stamen Maps.

Installation

satellite-view is provided as an ESM module import.

import * as satelliteView from 'satellite-view';

Initialization

satelliteView.init takes a parameters object with the following properties:

  • context: (REQUIRED) An extended WebGL rendering context, as returned by the initContext method from yawgl
  • globeRadius: The (floating point) radius of the spherical Earth. Units must match the units of the altitude in the camPos array supplied to the draw method. Default: 6371 (km).
  • map: (REQUIRED) An object with the following properties, OR an array of objects where each element has the following properties:
    • canvas: an HTML Canvas element containing a map image
    • camPos: a 2-element array containing the map coordinates of the camera position. Map coordinates range from [0, 0] at the top left corner of the Canvas to [1, 1] at the bottom right
    • scale: a 2-element array containing the scales of the current map relative to a map covering the whole world
    • changed: a (Boolean) flag indicating whether the map image has changed since the last draw call
  • pixelRatio: Ratio of the pixel size of the rendered image (drawingbuffer size) to the CSS display size of the container. Default: window.devicePixelRatio. Note: if a value is supplied, the pixel ratio will remain constant across draw calls. The default behavior will update the pixel ratio when window.devicePixelRatio changes
  • units: Specify "degrees" or "radians" as the units of the longitude and latitude in the camPos argument of any future draw calls. Default: "radians"

API

Initialization returns an object with the following properties and methods:

  • canvas: Link to the Canvas element on which the view is rendered
  • draw(camPos, maxRayTan, camMoving): Renders the globe on the Canvas. Arguments:
    • camPos: a 3-element array containing the longitude, latitude, altitude of the camera. Longitude and latitude are in the units specified on initialization. Altitude is in the same units as the supplied globe radius.
    • maxRayTan: a 2-element array containing the maximum ray tangents at the corners of the camera sensor. The values are the tangents of half the field of view angles:
      • maxRayTan[0] = tan(FOV_x / 2)
      • maxRayTan[1] = tan(FOV_y / 2)
    • camMoving: a (Boolean) flag indicating whether the camera position has changed since the last draw call
  • setPixelRatio(ratio): sets device pixelRatio to the supplied constant value

Keywords

FAQs

Package last updated on 15 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc