0.2.2 • Published 7 years ago

field-of-view v0.2.2

Weekly downloads
9
License
MIT
Repository
github
Last release
7 years ago

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
          ]
        ]
      }
    ]
  }
}

npm.io

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

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago