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

leaflet-geometryutil

Package Overview
Dependencies
Maintainers
5
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.6.0 to 0.7.0

6

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

@@ -16,3 +16,5 @@ "keywords": [

"scripts": {
"test": "node_modules/.bin/mocha-phantomjs spec/index.html",
"test-leaflet-0.7.7": "npm install leaflet@0.7.7 && node_modules/.bin/mocha-phantomjs spec/index.html",
"test-leaflet-1.0.0": "npm install leaflet@1.0.0-rc.3 && node_modules/.bin/mocha-phantomjs spec/index.html",
"test": "npm run test-leaflet-0.7.7 && npm run test-leaflet-1.0.0",
"generate-docs": "rm -rf docs; node_modules/.bin/jsdoc -c jsdoc.config -d ./docs/"

@@ -19,0 +21,0 @@ },

@@ -7,9 +7,4 @@ Leaflet.GeometryUtil

* Tested with stable Leaflet 0.7.0
* Tested with Leaflet 1.0.0-rc.3
For Leaflet 1.0, some users encounter problems with closest method.
We plan to open a new branch for testing purpose soon !
Don't hesitate to submit issues or Pull Request if you detect something wrong.
Usage

@@ -43,2 +38,4 @@ -----

sudo apt-get install nodejs phantomjs
npm install
```

@@ -59,2 +56,6 @@

### 0.7.0 ###
* Tested for Leaflet 1.0.0-rc.3
### 0.6.0 ###

@@ -61,0 +62,0 @@

@@ -8,3 +8,5 @@ describe('Accumulated length of line', function() {

it('It should return 0 and length in meters for a segment', function(done) {
assert.deepEqual([0, 111319.49079327357], L.GeometryUtil.accumulatedLengths(L.polyline([[0, 0], [1, 0]])));
var accumulatedLengths = L.GeometryUtil.accumulatedLengths(L.polyline([[0, 0], [1, 0]]));
assert.equal(accumulatedLengths[0], 0);
assert.closeTo(accumulatedLengths[1], 111319.49079327357, 500); // compatibility of Leaflet 1.0, due to earth R changed
done();

@@ -14,5 +16,8 @@ });

it('It should return accumulated lengths', function(done) {
assert.deepEqual([0, 55659.74539663678, 111319.49079327357], L.GeometryUtil.accumulatedLengths(L.polyline([[0, 0], [0.5, 0], [1, 0]])));
var accumulatedLengths = L.GeometryUtil.accumulatedLengths(L.polyline([[0, 0], [0.5, 0], [1, 0]]));
assert.equal(accumulatedLengths[0], 0);
assert.closeTo(accumulatedLengths[1], 55659.74539663678, 500); // compatibility of Leaflet 1.0, due to earth R changed
assert.closeTo(accumulatedLengths[2], 111319.49079327357, 500); // compatibility of Leaflet 1.0, due to earth R changed
done();
});
});

@@ -72,3 +72,3 @@ describe('Closest on path with precision', function() {

it('It should return null if layer param is not instance of Array|L.Polygon|L.Polyline', function(done) {
it('It should return null if layer param is not instance of Array|L.Polygon|L.Polyline (Leaflet 0.7.7 only)', function(done) {
var campus = {

@@ -145,3 +145,11 @@ "type": "Feature",

closest = L.GeometryUtil.closest(map, layers.getLayers()[0], ll);
assert.isNull(closest);
// if layers.getLayers()[0] is a LayerGroup, we are in Leaflet 0.7.7
// so there is no result
// if not, we are in Leaflet 1.0, and we don't need to test it, because
// layers.getLayers()[0] will contain a multipolygon, and so there is a result
if (layers.getLayers()[0] instanceof L.LayerGroup) {
assert.isNull(closest);
} else {
assert.isOk(true);
}
done();

@@ -148,0 +156,0 @@ });

@@ -91,3 +91,5 @@ describe('Closest among layers', function() {

closest = L.GeometryUtil.closestLayer(map, layers.getLayers(), ll);
assert.deepEqual(closest.layer, layers.getLayers()[0].getLayers()[0])
// we test instanceof because of differences between Leaflet 0.7.7 & 1.0.0
// in 0.7.7 geojson are LayerGroup, in 1.0, we have directly instances of L.Polyline & co
assert.deepEqual(closest.layer, layers.getLayers()[0] instanceof L.LayerGroup ? layers.getLayers()[0].getLayers()[0] : layers.getLayers()[0])
assert.deepEqual(closest.distance, 4)

@@ -94,0 +96,0 @@ done();

@@ -21,16 +21,38 @@ describe('Extract line', function() {

it('It should return extra coordinate if middle of segment', function(done) {
assert.deepEqual(L.GeometryUtil.extract(map, line, 0, 0.2),
[L.latLng([0, 0]), L.latLng([0.600141459027052, 0.6001219630588661])]);
assert.deepEqual(L.GeometryUtil.extract(map, line, 0, 0.6),
[L.latLng([0, 0]), L.latLng([1, 1]), L.latLng([1.800282914111311, 1.8002439493392906])]);
assert.deepEqual(L.GeometryUtil.extract(map, line, 0.6, 1.0),
[L.latLng([1.800282914111311, 1.8002439493392906]), L.latLng([2, 2]), L.latLng([3, 3])]);
assert.deepEqual(L.GeometryUtil.extract(map, line, 0.2, 0.8),
[L.latLng([0.600141459027052, 0.6001219630588661]), L.latLng([1, 1]), L.latLng([2, 2]), L.latLng([2.40024267258436, 2.4001524293923637])]);
var extract1 = L.GeometryUtil.extract(map, line, 0, 0.2),
extract2 = L.GeometryUtil.extract(map, line, 0, 0.6),
extract3 = L.GeometryUtil.extract(map, line, 0.6, 1.0),
extract4 = L.GeometryUtil.extract(map, line, 0.2, 0.8),
extract5 = L.GeometryUtil.extract(map, line, 1.0, 0.6);
assert.deepEqual(extract1[0], L.latLng([0, 0]));
assert.closeTo(extract1[1].lat, 0.600141459027052, 0.0000001); // compatibility of Leaflet 1.0, due to earth R changed
assert.closeTo(extract1[1].lng, 0.6001219630588661, 0.0000001); // compatibility of Leaflet 1.0, due to earth R changed
assert.deepEqual(extract2[0], L.latLng([0, 0]));
assert.deepEqual(extract2[1], L.latLng([1, 1]));
assert.closeTo(extract2[2].lat, 1.800282914111311, 0.0000001); // compatibility of Leaflet 1.0, due to earth R changed
assert.closeTo(extract2[2].lng, 1.8002439493392906, 0.0000001); // compatibility of Leaflet 1.0, due to earth R changed
assert.closeTo(extract3[0].lat, 1.800282914111311, 0.0000001); // compatibility of Leaflet 1.0, due to earth R changed
assert.closeTo(extract3[0].lng, 1.8002439493392906, 0.0000001); // compatibility of Leaflet 1.0, due to earth R changed
assert.deepEqual(extract3[1], L.latLng([2, 2]));
assert.deepEqual(extract3[2], L.latLng([3, 3]));
assert.closeTo(extract4[0].lat, 0.600141459027052, 0.0000001); // compatibility of Leaflet 1.0, due to earth R changed
assert.closeTo(extract4[0].lng, 0.6001219630588661, 0.0000001); // compatibility of Leaflet 1.0, due to earth R changed
assert.deepEqual(extract4[1], L.latLng([1, 1]));
assert.deepEqual(extract4[2], L.latLng([2, 2]));
assert.closeTo(extract4[3].lat, 2.40024267258436, 0.0000001); // compatibility of Leaflet 1.0, due to earth R changed
assert.closeTo(extract4[3].lng, 2.4001524293923637, 0.0000001); // compatibility of Leaflet 1.0, due to earth R changed
// Should work symetrically
assert.deepEqual(L.GeometryUtil.extract(map, line, 1.0, 0.6),
[L.latLng([3, 3]), L.latLng([2, 2]), L.latLng([1.800282914111311, 1.8002439493392906])]);
assert.deepEqual(extract5[0], L.latLng([3, 3]));
assert.deepEqual(extract5[1], L.latLng([2, 2]));
assert.closeTo(extract5[2].lat, 1.800282914111311, 0.0000001); // compatibility of Leaflet 1.0, due to earth R changed
assert.closeTo(extract5[2].lng, 1.8002439493392906, 0.0000001); // compatibility of Leaflet 1.0, due to earth R changed
done();
});
});

@@ -8,5 +8,5 @@ describe('Length of line', function() {

it('It should return length in meters', function(done) {
assert.equal(111319.49079327357, L.GeometryUtil.length(L.polyline([[0, 0], [1, 0]])));
assert.closeTo(111319.49079327357, L.GeometryUtil.length(L.polyline([[0, 0], [1, 0]])), 500); // compatibility of Leaflet 1.0, due to earth R changed
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

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