Comparing version 1.0.2 to 1.0.3
@@ -157,4 +157,4 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.hull = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ | ||
/* | ||
(c) 2014-2020, Andrii Heonia | ||
Hull.js, a JavaScript library for concave hull generation by set of points. | ||
(c) 2014-2022, Andrii Heonia | ||
Hull.js is a JavaScript library for concave hull generation by the set of points. | ||
https://github.com/AndriiHeonia/hull | ||
@@ -325,3 +325,4 @@ */ | ||
if (points.length < 4) { | ||
return points.concat([points[0]]); | ||
const concave = points.concat([points[0]]); | ||
return format ? formatUtil.fromXy(concave, format) : concave; | ||
} | ||
@@ -346,7 +347,3 @@ | ||
if (format) { | ||
return formatUtil.fromXy(concave, format); | ||
} else { | ||
return concave; | ||
} | ||
return format ? formatUtil.fromXy(concave, format) : concave; | ||
} | ||
@@ -353,0 +350,0 @@ |
{ | ||
"name": "hull.js", | ||
"version": "1.0.2", | ||
"description": "JavaScript library that builds concave hulls (shapes) by set of points", | ||
"version": "1.0.3", | ||
"description": "JavaScript library that builds concave hulls (shapes) by the set of points", | ||
"homepage": "https://github.com/AndriiHeonia/hull", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -1,5 +0,9 @@ | ||
Hull.js - JavaScript library that builds concave hull by set of points. | ||
Hull.js is a JavaScript library that builds concave hull by the set of points. | ||
[![Build Status](https://travis-ci.org/AndriiHeonia/hull.svg?branch=master)](https://travis-ci.org/AndriiHeonia/hull) | ||
## Important Information | ||
This library was born in free independent Ukraine. Today not only Ukraine, but the entire international rule-based order is under attack, and you can help to defend it by supporting the Armed Forces of Ukraine via well trusted https://savelife.in.ua/en/ foundation. For other options to help, explore https://ukraine.ua/. | ||
## Examples | ||
@@ -54,5 +58,5 @@ | ||
## Development | ||
npm install # install dependencies | ||
npm test # build dist file and run tests | ||
npm run-script watch # watch ./src dir and rebuild dist file | ||
npm install # install dependencies | ||
npm test # build dist file and run tests | ||
npm run watch # watch ./src dir and rebuild dist file | ||
@@ -80,2 +84,5 @@ ## Contribute | ||
### 1.0.3 — 05.11.2022 | ||
- Fix issue with formatting when users pass less than 4 points as an input. | ||
- Remove bower.json, as Bower itself is deprecated. | ||
### 1.0.2 — 26.09.2021 | ||
@@ -82,0 +89,0 @@ - Clean up .gitignore. |
/* | ||
(c) 2014-2021, Andrii Heonia | ||
Hull.js, a JavaScript library for concave hull generation by set of points. | ||
(c) 2014-2022, Andrii Heonia | ||
Hull.js is a JavaScript library for concave hull generation by the set of points. | ||
https://github.com/AndriiHeonia/hull | ||
@@ -169,3 +169,4 @@ */ | ||
if (points.length < 4) { | ||
return points.concat([points[0]]); | ||
const concave = points.concat([points[0]]); | ||
return format ? formatUtil.fromXy(concave, format) : concave; | ||
} | ||
@@ -190,7 +191,3 @@ | ||
if (format) { | ||
return formatUtil.fromXy(concave, format); | ||
} else { | ||
return concave; | ||
} | ||
return format ? formatUtil.fromXy(concave, format) : concave; | ||
} | ||
@@ -197,0 +194,0 @@ |
@@ -18,5 +18,12 @@ const assert = require("assert"), | ||
it('should return concave hull with lngs and lats', function() { | ||
const points = [{lng:-0.206792373176235, lat:51.4911165465815 }, {lng:-0.207062672933557, lat:51.4915703125214 }, {lng:-0.207465840096923, lat:51.4912077781219 }, {lng:-0.210193421020222, lat:51.4918159814458 }, {lng:-0.214944392455692, lat:51.4929945001276 }, {lng:-0.208133371509344, lat:51.4910830915252 }, {lng:-0.214162055384851, lat:51.4905275966855 }, {lng:-0.208161917730384, lat:51.4903551232517 }, {lng:-0.209680931181673, lat:51.4901894811742 }, {lng:-0.212571431609104, lat:51.4903145141462 }, {lng:-0.216849005460861, lat:51.4921781720221}]; | ||
const expected = [{lng: -0.206792373176235, lat: 51.4911165465815 }, {lng: -0.207062672933557, lat: 51.4915703125214 }, {lng: -0.207465840096923, lat: 51.4912077781219 }, {lng: -0.210193421020222, lat: 51.4918159814458 }, {lng: -0.214944392455692, lat: 51.4929945001276 }, {lng: -0.216849005460861, lat: 51.4921781720221 }, {lng: -0.214162055384851, lat: 51.4905275966855 }, {lng: -0.212571431609104, lat: 51.4903145141462 }, {lng: -0.209680931181673, lat: 51.4901894811742 }, {lng: -0.208161917730384, lat: 51.4903551232517 }, {lng: -0.208133371509344, lat: 51.4910830915252 }, {lng: -0.206792373176235, lat: 51.4911165465815}]; | ||
let points, | ||
expected; | ||
points = [{lng:-0.206792373176235, lat:51.4911165465815 }, {lng:-0.207062672933557, lat:51.4915703125214 }, {lng:-0.207465840096923, lat:51.4912077781219 }, {lng:-0.210193421020222, lat:51.4918159814458 }, {lng:-0.214944392455692, lat:51.4929945001276 }, {lng:-0.208133371509344, lat:51.4910830915252 }, {lng:-0.214162055384851, lat:51.4905275966855 }, {lng:-0.208161917730384, lat:51.4903551232517 }, {lng:-0.209680931181673, lat:51.4901894811742 }, {lng:-0.212571431609104, lat:51.4903145141462 }, {lng:-0.216849005460861, lat:51.4921781720221}]; | ||
expected = [{lng: -0.206792373176235, lat: 51.4911165465815 }, {lng: -0.207062672933557, lat: 51.4915703125214 }, {lng: -0.207465840096923, lat: 51.4912077781219 }, {lng: -0.210193421020222, lat: 51.4918159814458 }, {lng: -0.214944392455692, lat: 51.4929945001276 }, {lng: -0.216849005460861, lat: 51.4921781720221 }, {lng: -0.214162055384851, lat: 51.4905275966855 }, {lng: -0.212571431609104, lat: 51.4903145141462 }, {lng: -0.209680931181673, lat: 51.4901894811742 }, {lng: -0.208161917730384, lat: 51.4903551232517 }, {lng: -0.208133371509344, lat: 51.4910830915252 }, {lng: -0.206792373176235, lat: 51.4911165465815}]; | ||
assert.deepEqual(hull(points, 0.0011, ['.lng', '.lat']), expected); | ||
points = [{lat: 10, lng: 10}, {lat: 100, lng: 10}, {lat: 100, lng: 100}]; | ||
expected = [{lat: 10, lng: 10}, {lat: 100, lng: 10}, {lat: 100, lng: 100}, {lat: 10, lng: 10}]; | ||
assert.deepEqual(hull(points, 10, ['.lng', '.lat']), expected); | ||
}); | ||
@@ -23,0 +30,0 @@ |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
98978
121
2
19
751