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

bing-streetside

v1.0.2

Published

A library to fetch the "Street Side" image tiles from Bing Maps. This uses reverse engineered API's.

Downloads

1

Readme

Bing-Streetside

A library to fetch the "Street Side" image tiles from Bing Maps. This uses reverse engineered API's.

API:

Bing:

Constructing the bing class retrieves the settings + default options. These include the API key, "generation id" along with default settings such as the bubble count

Available methods on this are:

getBubble(id)

This returns a Bubble object

getBubbles({opts})

The available options are:

  • count
  • box
    • north (latitude)
    • south (latidude)
    • east (longitude)
    • west (longitude)
  • center
    • lat
    • lng
    • radius (in meters)

This returns a list of Bubble objects.

May also add in support for geohashes, along with other bounding box formats.

Bubble:

This object represents a "bubble" on Bing, this is 360 sphere.

The sphere consists of an image for each side (front, right, back, left, top, bottom.

Enums:

side

  • FRONT
  • RIGHT
  • BACK
  • LEFT
  • TOP
  • BOTTOM

The available methods on this are:

tileToIndex(x, y, detail)

Converts an x,y coordinate index to a quadtree hash, with the specified number of bits (detail)

fetchXY(side, detail, x, y)

Fetches the tile, returns a Buffer object containing jpeg data.

fetchSide(side, detail)

Fetches an entire side, this fetches them in parallel, although uses a request pool of 16, spread over 2 domains - this approximately matches browser behaviour. The level of detail exponentially increases the number of tiles needing to be fetched. For each value of detail, the number of tiles needed quadruples:

  • 0: 1 request (254x254px)
  • 1: 4 requests (508x508px)
  • 2: 16 requests (1016x1016px)
  • 3: 64 requests (2032x2032px)

Example:

new Bing().then(bing => {
  return bing.getBubble(146511614);
}).then(bubble => {
  return bubble.getSide(Bing.Bubble.side.FRONT, 2);
}).then(canvas => {
  let buffer = canvas.toBuffer();
  fs.writeFile(__dirname+'/result.png', buffer);
});

Future Work

Still a fair few breaking changes to be done.

Bing

  • caching for the returned info.
  • returning a promise in a constructor seems a little dodgy. May change this to lazy load, wait for the internal promise within the getBubble and getBubbles methods.

fetchSide

  • Return type needs changing to be a buffer directly, although this isn't ideal for converting it's more consistant.
  • May allow retrieving an area by percentage along with how many pixels to render into - do automatic selection of detail based on this.
  • May allow specifying an angle rather than a side. 0 degrees being front, 45 degrees being halfway between front and right, etc. Just tricky in terms of how to handle up/down.
  • May be interesting allowing returning angles relative to north.

fetchSphere

  • return a full 360 degree sphere. This however needs projecting to polar. Maybe we should return an object containing each side individually, with a toPolar() method.