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

openpanos-client

v0.2.6

Published

OpenPanos is a platform for creating linked, navigable networks of 360 panoramas. This is the Pannellum-based client component. You can use it either with openpanos-server or your own server.

Downloads

3

Readme

openpanos

A platform for creating linked, navigable networks of 360 panoramas.

Introduction

OpenPanos is a platform for creating linked networks of 360 panoramas. It is based on the core engine of OpenTrailView, a project to create 360 tours of paths and trails. It uses various other libraries:

  • Photo Sphere Viewer - NEW for version 0.2.0, a flexible and powerful panorama viewing library, originally developed by Jéremy Heleine and enhanced by Damien Sorel.
  • GeoJSON Path Finder - a library to create a routing graph from GeoJSON and route between two points. Developed by Per Liedman; note that you have to currently use my own fork with OpenPanos (included in this package), as it relies on a bugfix which has not been merged into master on the original project yet. This is likely to change.

OpenPanos consists of two parts, a client and a server. It is possible to use the client without the server if you provide your own server.

The client

The client (openpanos-client; this package) is Photo Sphere Viewer and GeoJSON Path Finder-based, and handles displaying and linking the panoramas. By default, the client will work with a given set of API endpoints. However this is configurable and you can connect it to your own PostGIS-based API.

Basic usage of the client

You use the Client object, which is exported from the openpanos-client module, e.g.:

// Import the module
const openpanos = require('openpanos-client');
const client = new openpanos.Client();

The Client object has various methods. Note that many of these rely on a server-side API being available, see below for details. In particular, to load the panoramas, you must provide a panoImg API endpoint which serves a given panorama by ID.

Note all methods are asynchronous and thus return a promise, except for the on event-handling method.

  • findPanoramaByLonLat(lon, lat) : finds and loads the nearest panorama to a given latitude and longitude.

      • You must have a nearest API endpoint setup, to find the nearest panorama server-side.
  • loadPanorama(id) - will load a given panorama by ID.

      • You must have a byID API endpoint setup, to find the panorama with that ID.
  • moveTo(id) - moves to an already-loaded panorama with a given ID. DEPRECATED - as of 0.2.2, just use loadPanorama()

  • update(id, properties) - updates selected metadata of a given panorama referenced by ID. The properties parameter is an object containing this metadata and can contain one or both of the following properties:

    • position (a two-member array of longitude and latitude);
    • poseheadingdegrees (a float, the bearing of the centre point of the panorama).
  • on(eventname, eventhandler)- handle events with an event handler function. The events that are currently handled are:

    • panoChanged: when the current panorama changes. The ID of the new panorama is passed as an argument to the event handler.
    • locationChanged: when the current location changes. The new longitude and latitude, respectively, are passed as arguments to the event handler.

Setting up API endpoints

For OpenPanos to work, you need a server set up which will provide your panorama images, find panorama metadata by ID, find the nearest panorama to a given latitude and longitude, and find panoramas near to the current one.

These endpoints can be specified as options when you create your Client object:

const Client = new openpanos.Client({
	api: {
		byId: , // ... returns metadata of a panorama with a given ID
		nearest: , // ... finds the nearest panorama to a given lat/lon
		panoImg: , // ... returns the actual image of a panorama with a given ID
		panoImgResized: , // ... returns the panorama image resized to a given pixel width (optional)
		geojson: , // returns GeoJSON of all routes (such as OSM ways) within a given bounding box
		nearby: , // returns panoramas near to a given panorama
	}
});

Each endpoint is described in detail below, along with its default value. Note that values in braces will be replaced by the code with whatever the current value is.

byId endpoint (default op/panorama/{id}) : returns a JSON object with these properties:

  • id: the pano ID
  • userid: the ID of the user the pano belongs to (optional)
  • authorised: is the panorama authorised yet? (optional)
  • lon: the longitude
  • lat: the latitude
  • poseheadingdegrees: the bearing of the centre of the panorama.

nearest endpoint (default op/panorama/nearest/{lon}/{lat]) : returns a JSON object containing the panorama nearest to the given lon and lat. Returns the same JSON as byID.

panoImg endpoint (default op/panorama/{id}.jpg) : returns the JPEG image of the panorama itself. May contain checks, e.g. has the panorama been authorised yet.

panoImgResized endpoint (default op/panorama/{id}w{width}.jpg) : returns the JPEG image of the panorama itself, resized to a given width. Useful for thumbnails and previews. Optional.

geojson endpoint (default op/map/highways) : expects one query string parameter bbox containing w,s,e,n in WGS84 lat/lon. Returns GeoJSON data of all highways (routes, including paths) in the given bounding box, for example OpenStreetMap highways.

nearby endpoint (default op/panorama/{id}/nearby} : returns all panoramas nearby to a given source panorama. It's up to you how you define "nearby", but this call is necessary to link panoramas to adjacent ones, so don't set the value too small. It should return a JSON object containing:

  • panos : an array of individual panorama objects (see byId and nearest above);
  • bbox : the bounding box of all panoramas returned.