Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@turf/midpoint

Package Overview
Dependencies
Maintainers
4
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/midpoint - npm Package Compare versions

Comparing version 4.5.2 to 4.6.0

5

index.d.ts
/// <reference types="geojson" />
type Point = GeoJSON.Feature<GeoJSON.Point>;
type Point = GeoJSON.Feature<GeoJSON.Point> | GeoJSON.Point | number[];
type Feature = GeoJSON.Feature<GeoJSON.Point>;

@@ -8,4 +9,4 @@ /**

*/
declare function midpoint(from: Point, to: Point): Point;
declare function midpoint(point1: Point, point2: Point): Feature;
declare namespace midpoint { }
export = midpoint;

36

index.js

@@ -10,35 +10,21 @@ var bearing = require('@turf/bearing');

* @name midpoint
* @param {Feature<Point>} from first point
* @param {Feature<Point>} to second point
* @param {Geometry|Feature<Point>|Array<number>} point1 first point
* @param {Geometry|Feature<Point>|Array<number>} point2 second point
* @returns {Feature<Point>} a point midway between `pt1` and `pt2`
* @example
* var pt1 = {
* "type": "Feature",
* "properties": {},
* "geometry": {
* "type": "Point",
* "coordinates": [144.834823, -37.771257]
* }
* };
* var pt2 = {
* "type": "Feature",
* "properties": {},
* "geometry": {
* "type": "Point",
* "coordinates": [145.14244, -37.830937]
* }
* };
* var point1 = turf.point([144.834823, -37.771257]);
* var point2 = turf.point([145.14244, -37.830937]);
*
* var midpoint = turf.midpoint(pt1, pt2);
* var midpoint = turf.midpoint(point1, point2);
*
* //addToMap
* var addToMap = [point1, point2, midpoint];
* midpoint.properties['marker-color'] = '#f00';
* var addToMap = [pt1, pt2, midpoint];
*/
module.exports = function (from, to) {
var dist = distance(from, to, 'miles');
var heading = bearing(from, to);
var midpoint = destination(from, dist / 2, heading, 'miles');
*/
module.exports = function (point1, point2) {
var dist = distance(point1, point2, 'miles');
var heading = bearing(point1, point2);
var midpoint = destination(point1, dist / 2, heading, 'miles');
return midpoint;
};
{
"name": "@turf/midpoint",
"version": "4.5.2",
"version": "4.6.0",
"description": "turf midpoint module",

@@ -33,3 +33,3 @@ "main": "index.js",

"devDependencies": {
"@turf/helpers": "^4.5.2",
"@turf/helpers": "^4.6.0",
"benchmark": "^2.1.4",

@@ -39,6 +39,6 @@ "tape": "^4.6.3"

"dependencies": {
"@turf/bearing": "^4.5.2",
"@turf/destination": "^4.5.2",
"@turf/distance": "^4.5.2"
"@turf/bearing": "^4.6.0",
"@turf/destination": "^4.6.0",
"@turf/distance": "^4.6.0"
}
}

@@ -10,4 +10,4 @@ # @turf/midpoint

- `from` **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[Point](http://geojson.org/geojson-spec.html#point)>** first point
- `to` **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[Point](http://geojson.org/geojson-spec.html#point)>** second point
- `point1` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[Point](http://geojson.org/geojson-spec.html#point)> | [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>)** first point
- `point2` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[Point](http://geojson.org/geojson-spec.html#point)> | [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>)** second point

@@ -17,24 +17,10 @@ **Examples**

```javascript
var pt1 = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [144.834823, -37.771257]
}
};
var pt2 = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [145.14244, -37.830937]
}
};
var point1 = turf.point([144.834823, -37.771257]);
var point2 = turf.point([145.14244, -37.830937]);
var midpoint = turf.midpoint(pt1, pt2);
var midpoint = turf.midpoint(point1, point2);
//addToMap
var addToMap = [point1, point2, midpoint];
midpoint.properties['marker-color'] = '#f00';
var addToMap = [pt1, pt2, midpoint];
```

@@ -41,0 +27,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc