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

leaflet-geometryutil

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

leaflet-geometryutil - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

.gitmodules

63

dist/leaflet.geometryutil.js

@@ -1,4 +0,18 @@

var L = L || exports;
(function () {
// Packaging/modules magic dance.
(function (factory) {
var L;
if (typeof define === 'function' && define.amd) {
// AMD
define(['leaflet'], factory);
} else if (typeof module !== 'undefined') {
// Node/CommonJS
L = require('leaflet');
module.exports = factory(L);
} else {
// Browser globals
if (typeof window.L === 'undefined')
throw 'Leaflet must be loaded first';
factory(window.L);
}
}(function (L) {
"use strict";

@@ -11,3 +25,3 @@

L.GeometryUtil = {
L.GeometryUtil = L.extend(L.GeometryUtil || {}, {

@@ -41,2 +55,32 @@ /**

/**
Shortcut function for converting distance to readable distance.
@param {Number} distance
@param {String} unit ('metric' or 'imperial')
@returns {Number} in yard or miles
*/
readableDistance: function (distance, unit) {
var isMetric = (unit !== 'imperial'),
distanceStr;
if (isMetric) {
// show metres when distance is < 1km, then show km
if (distance > 1000) {
distanceStr = (distance / 1000).toFixed(2) + ' km';
}
else {
distanceStr = Math.ceil(distance) + ' m';
}
}
else {
distance *= 1.09361;
if (distance > 1760) {
distanceStr = (distance / 1760).toFixed(2) + ' miles';
}
else {
distanceStr = Math.ceil(distance) + ' yd';
}
}
return distanceStr;
},
/**
Returns true if the latlng belongs to segment.

@@ -117,3 +161,3 @@ param {L.LatLng} latlng

var latlngs = layer.getLatLngs(),
var latlngs = layer.getLatLngs().slice(0),
mindist = Infinity,

@@ -437,3 +481,3 @@ result = null,

},
/**

@@ -457,5 +501,6 @@ Returns LatLng of rotated point around specified LatLng center.

}
};
});
}());
return L.GeometryUtil;
}));

4

package.json
{
"name": "leaflet-geometryutil"
, "version": "0.2.0"
, "version": "0.3.0"
, "description": "Leaflet utility functions on geometries"

@@ -11,3 +11,3 @@ , "keywords": ["Leaflet", "GIS"]

, "dependencies": {
"leaflet": "0.6.4"
"leaflet": "0.7.0"
}

@@ -14,0 +14,0 @@ , "devDependencies": {

@@ -6,3 +6,3 @@ Leaflet.GeometryUtil

* Tested with stable Leaflet 0.5.1
* Tested with stable Leaflet 0.7.0

@@ -34,3 +34,12 @@ Usage

---------
### master ###
* Nothing changed yet.
### 0.3.0 ###
* Added UMD style initialization (thanks @PerLiedman)
* Added readable distance (thanks @Mylen)
* Fix side effects on latlngs with `closest()` (thanks @AndrewIngram)
### 0.2.0 ###

@@ -55,2 +64,8 @@

License
-------
* BSD New
Authors

@@ -64,3 +79,4 @@ -------

* [Frédéric Bonifas](https://github.com/fredericbonifas)
* [Alexander Melard](https://github.com/mylen)
[![Makina Corpus](http://depot.makina-corpus.org/public/logo.gif)](http://makinacorpus.com)

@@ -18,11 +18,2 @@ var assert = chai.assert;

describe('Distance between LatLng', function() {
it('It should be 0 if same point', function(done) {
assert.equal(0, L.GeometryUtil.distance(map, L.latLng([10, 10]), L.latLng([10, 10])));
done();
});
});
describe('Distance to segment', function() {

@@ -59,2 +50,25 @@ it('It should be 0 if point on segment', function(done) {

describe('Readable distances', function() {
it('It should be meters by default', function(done) {
assert.equal("0 m", L.GeometryUtil.readableDistance(0));
done();
});
it('It should be 0 yd if imperial', function(done) {
assert.equal("0 yd", L.GeometryUtil.readableDistance(0, 'imperial'));
done();
});
it('It should be kilometers if superior to 1000', function(done) {
assert.equal("1.01 km", L.GeometryUtil.readableDistance(1010));
done();
});
it('It should be miles if superior to 1760', function(done) {
assert.equal("1.24 miles", L.GeometryUtil.readableDistance(2000, 'imperial'));
done();
});
});
describe('Accumulated length of line', function() {

@@ -61,0 +75,0 @@ it('It should be empty for empty line', function(done) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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