field-of-view v0.2.2
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:
- Leaflet.GeotagPhoto - Leaflet plugin for photo geotagging
- Surveyor - web application for crowdsourced image geotagging
- Street View, Then & Now: New York City's Fifth Avenue
field-of-view is developed for The New York Public Library's NYC Space/Time Directory.
Input
Point: camera locationLineStringwith two points: field of viewGeometryCollectionwith twoPointgeometries: camera and target locationsGeometryCollectionwith threePointgeometries: camera and target locations, and a point to determine the angle of the field-of-view
See the API section for more details.
Output
GeometryCollectionwith two geometries:Point: location of cameraLineString: field of view
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-viewBrowser:
<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.bearingshould be specifiedproperties.distanceshould be specified
LineStringwith two points; this is the field of view of the photoGeometryCollectionwith twoPointgeometries- Point location of the camera
- Point location of the camera's target
GeometryCollectionwith threePointgeometries- Point location of the camera
- Point location of the camera's target
- 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.