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

geo-point

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geo-point - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

package.json
{
"name": "geo-point",
"version": "1.0.1",
"version": "1.0.2",
"description": "geo point",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -10,29 +10,88 @@ # GeoPoint

###### `fromGeoJSON({type: String, coordinates: [longitude: Number, latitude: Number]}): GeoPoint`
factory function
```js
const point = GeoPoint.fromGeoJSON({
type: 'Point',
coordinates: [-0.15, 51.5]
});
```
###### `fromObject({latitude: Number, longitude: Number}): GeoPoint`
factory function
###### `calculateDistance(p1: GeoPoint, p2: GeoPoint): Number`
Returns a distance between points in meters
```js
const point = GeoPoint.fromObject({
latitude: 51.5,
longitude: -0.15
});
```
###### `fromLatLngArray([latitude: Number, longitude: Number]): GeoPoint`
factory function
```js
const point = GeoPoint.fromLatLngArray([51.5, -0.15]);
```
###### `fromLngLatArray([longitude: Number, longitude: Number]): GeoPoint`
factory function
```js
const point = GeoPoint.fromLngLatArray([-0.15, 51.5]);
```
###### `calculateDistance(p1: GeoPoint, p2: GeoPoint): Number`
Returns a distance between points in meters
```js
const point1 = new GeoPoint(51.5, -0.15);
const point2 = new GeoPoint(51.6, -0.15);
const distanceInMeters = GeoPoint.calculateDistance(point1, point2);
```
## Instance methods
###### `toString(): String`
returns `"51.5,-015"`
returns a string representation of coordinate pair
```js
const point = new GeoPoint(51.5, -0.15);
point.toString(); // String(51.5,-0.15)
```
###### `toGeoJSON(): Object`
returns a GeoJSON representation
```js
{
"type": "Point",
"coordinates": [-0.15, 51.5]
}
const point = new GeoPoint(51.5, -0.15);
const geoJson = point.toGeoJSON();
geoJson.should.have.keys(['type', 'coordinates']);
geoJson.type.should.equals('Point');
geoJson.coordinates.should.deep.equals([-0.15, 51.5]);
```
###### `toPlainObject(): Object`
returns a plain `{latitude: Number, longitude: Number}` object
```js
const point = new GeoPoint(51.5, -0.15);
point.toPlainObject().should.have.keys(['latitude', 'longitude']);
```
###### `toLatLngArray(): Array`
returns latitude, longitude pairs array
```js
const point = new GeoPoint(51.5, -0.15);
point.toLatLngArray().should.deep.equals([51.5, -0.15]);
```
###### `toLngLatArray(): Array`
returns longitude, latitude pairs array
```js
const point = new GeoPoint(51.5, -0.15);
point.toLngLatArray().should.deep.equals([-0.15, 51.5]);
```
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