Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@turf/bearing
Advanced tools
@turf/bearing is a module within the Turf.js library that provides geospatial analysis tools. Specifically, it calculates the bearing between two geographical points. This is useful in various applications such as navigation, mapping, and geographic information systems (GIS).
Calculate Bearing
This feature calculates the bearing between two geographical points. The bearing is the angle between the north direction and the line connecting the two points, measured in degrees.
const turf = require('@turf/turf');
const point1 = turf.point([0, 0]);
const point2 = turf.point([10, 10]);
const bearing = turf.bearing(point1, point2);
console.log(bearing);
Calculate Bearing with Initial and Final Bearings
This feature allows you to calculate both the initial and final bearings between two points. The initial bearing is the angle at the starting point, while the final bearing is the angle at the destination point.
const turf = require('@turf/turf');
const point1 = turf.point([0, 0]);
const point2 = turf.point([10, 10]);
const initialBearing = turf.bearing(point1, point2, {final: false});
const finalBearing = turf.bearing(point1, point2, {final: true});
console.log(`Initial Bearing: ${initialBearing}, Final Bearing: ${finalBearing}`);
Geolib is a library for geospatial calculations. It provides functions to calculate distances, bearings, and other geographic information. Compared to @turf/bearing, Geolib offers a broader range of geospatial functionalities but may not be as specialized in GIS analysis.
Geodesy is a library for geodesic calculations. It includes methods for calculating distances, bearings, and other geospatial metrics. It is similar to @turf/bearing in terms of bearing calculation but also includes more advanced geodesic functions.
Takes two points and finds the geographic bearing between them, i.e. the angle measured in degrees from the north line (0 degrees)
Parameters
start
(Geometry | Feature<Point> | Array<number>) starting Pointend
(Geometry | Feature<Point> | Array<number>) ending Pointfinal
[boolean] calculates the final bearing if true (optional, default false
)Examples
var point1 = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [-75.343, 39.984]
}
};
var point2 = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [-75.534, 39.123]
}
};
var bearing = turf.bearing(point1, point2);
//addToMap
var addToMap = [point1, point2]
point1.properties['marker-color'] = '#f00'
point2.properties['marker-color'] = '#0f0'
point1.properties.bearing = bearing
Returns number bearing in decimal degrees, between -180 and 180 degrees (positive clockwise)
This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.
Install this module individually:
$ npm install @turf/bearing
Or install the Turf module that includes it as a function:
$ npm install @turf/turf
4.3.0
@turf/polygon-tangents
Finds the tangents of a (Multi)Polygon from a Point. (https://github.com/Turfjs/turf/pull/708)@turf/rewind
Rewind LineString or Polygon outer ring ~clockwise~ counter-clockwise and inner rings ~counterclockwise~ clockwise (https://github.com/Turfjs/turf/pull/700 & https://github.com/Turfjs/turf/issues/66)@turf/isobands
- Takes a grid FeatureCollection of Point features with z-values and an array of value breaks and generates filled contour isobands. (https://github.com/Turfjs/turf/pull/619)@turf/helpers
(https://github.com/Turfjs/turf/pull/732)@turf/inside
(https://github.com/Turfjs/turf/pull/706)@turf/meta
. (https://github.com/Turfjs/turf/pull/712 & https://github.com/Turfjs/turf/issues/692)getGeom
& getGeomType
in @turf/invariant
(https://github.com/Turfjs/turf/pull/720)round()
, radians2degrees()
and degrees2radians()
to turf-helpers
(https://github.com/Turfjs/turf/pull/715)@turf/rewind
(https://github.com/Turfjs/turf/pull/741)@turf/circle
translate properties (https://github.com/Turfjs/turf/pull/717)@turf/buffer
to polygons (https://github.com/Turfjs/turf/issues/660 & https://github.com/Turfjs/turf/pull/718)@turf/difference
(https://github.com/Turfjs/turf/pull/725)@turf/line-intersect
(https://github.com/Turfjs/turf/pull/731)@turf/line-chunk
(https://github.com/Turfjs/turf/pull/726)@turf/line-segment
(https://github.com/Turfjs/turf/pull/727 & https://github.com/Turfjs/turf/pull/711)@turf/line-overlap
(https://github.com/Turfjs/turf/pull/711)@turf/rewind
(https://github.com/Turfjs/turf/pull/741)@turf/buffer
(https://github.com/Turfjs/turf/pull/739)radius
to @turf/buffer
(https://github.com/Turfjs/turf/pull/736)FAQs
turf bearing module
The npm package @turf/bearing receives a total of 0 weekly downloads. As such, @turf/bearing popularity was classified as not popular.
We found that @turf/bearing demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.