npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

satellite-view

v2.1.2

Published

Re-project a map to a globe with WebGL

Downloads

7

Readme

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