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

field-of-view

v0.2.2

Published

Creates photo fields of view from GeoJSON files

Downloads

87

Readme

field-of-view

field-of-view is a JavaScript library to create photo fields of view GeoJSON geometries. field-of-view can be used in tools for photo geotagging, for example:

field-of-view is developed for The New York Public Library's NYC Space/Time Directory.

Input

  • Point: camera location
  • LineString with two points: field of view
  • GeometryCollection with two Point geometries: camera and target locations
  • GeometryCollection with three Point geometries: camera and target locations, and a point to determine the angle of the field-of-view

See the API section for more details.

Output

Example:

{
  "type": "Feature",
  "properties": {
    "angle": 45,
    "bearing": -87.81893783,
    "distance": 690.3534921
  },
  "geometry": {
    "type": "GeometryCollection",
    "geometries": [
      {
        "type": "Point",
        "coordinates": [
          4.918044805,
          52.379463370
        ]
      },
      {
        "type": "LineString",
        "coordinates": [
          [
            4.908044296,
            52.38226812
          ],
          [
            4.90772491,
            52.37713015
          ]
        ]
      }
    ]
  }
}

Installation

Using Node.js:

npm install field-of-view

Browser:

<script src="https://unpkg.com/field-of-view"></script>

Usage

Node.js example:

const fieldOfView = require('field-of-view')

const feature = {
  type: 'Feature',
  properties: {
    angle: 50
  },
  geometry: {
    type: 'LineString',
    coordinates: [
      [
        4.90028,
        52.37249
      ],
      [
        4.90065,
        52.37262
      ]
    ]
  }
}

const fov = fieldOfView.fromFeature(feature)

console.log(fov, null, 2)

API

fieldOfView.fromFeature (feature, options)

Converts feature to Field of View geometry; feature must be one of the following GeoJSON objects:

  • Point
    • Point is camera location
    • properties.bearing should be specified
    • properties.distance should be specified
  • LineString with two points; this is the field of view of the photo
  • GeometryCollection with two Point geometries
    1. Point location of the camera
    2. Point location of the camera's target
  • GeometryCollection with three Point geometries
    1. Point location of the camera
    2. Point location of the camera's target
    3. Point determining the angle of the field-of-view

In all cases except the last, features must specify the camera's angle of view by setting properties.angle, or by passing the angle as an option to the field-of-view module:

const options = {
  angle: 45
}

fieldOfView.fromFeature returns a single feature with a GeometryCollection containing two geometries, the location of the camera and the field of view. The feature's properties contains three values:

  • angle: angle of view of camera (0 - 180)
  • bearing: bearing of camera (0 - 360)
  • distance: distance between camera and target, in meters

See the Output section for an example.

See also

  • http://spacetime.nypl.org/
  • https://github.com/nypl-spacetime/Leaflet.GeotagPhoto
  • https://github.com/nypl-spacetime/surveyor
  • http://turfjs.org/
  • http://publicdomain.nypl.org/fifth-avenue/