Comparing version 0.2.1 to 0.2.2
@@ -90,2 +90,24 @@ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.hull=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
function _formatToXy(pointset, format) { | ||
if (format === undefined) { | ||
return pointset; | ||
} | ||
return pointset.map(function(pt) { | ||
/*jslint evil: true */ | ||
var _getXY = new Function('pt', 'return [pt' + format[0] + ',' + 'pt' + format[1] + '];'); | ||
return _getXY(pt); | ||
}); | ||
} | ||
function _xyToFormat(pointset, format) { | ||
if (format === undefined) { | ||
return pointset; | ||
} | ||
return pointset.map(function(pt) { | ||
/*jslint evil: true */ | ||
var _getObj = new Function('pt', 'var o = {}; o' + format[0] + '= pt[0]; o' + format[1] + '= pt[1]; return o;'); | ||
return _getObj(pt); | ||
}); | ||
} | ||
function _sortByX(pointset) { | ||
@@ -253,3 +275,3 @@ return pointset.sort(function(a, b) { | ||
function hull(pointset, concavity) { | ||
function hull(pointset, concavity, format) { | ||
var lower, upper, convex, | ||
@@ -263,3 +285,4 @@ innerPoints, | ||
} | ||
pointset = _sortByX(pointset); | ||
pointset = _sortByX(_formatToXy(pointset, format)); | ||
upper = _upperTangent(pointset); | ||
@@ -275,3 +298,3 @@ lower = _lowerTangent(pointset); | ||
return _concave(convex, Math.pow(maxEdgeLen, 2), maxSearchBBoxSize, grid(innerPoints)); | ||
return _xyToFormat(_concave(convex, Math.pow(maxEdgeLen, 2), maxSearchBBoxSize, grid(innerPoints)), format); | ||
} | ||
@@ -278,0 +301,0 @@ |
{ | ||
"name": "hull.js", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "JavaScript library that builds concave hulls (shapes) by set of points", | ||
"homepage": "https://github.com/AndreyGeonya/hull", | ||
"homepage": "https://github.com/AndriiHeonia/hull", | ||
"keywords": [ | ||
@@ -13,6 +13,6 @@ "geometry", | ||
], | ||
"author": "Andrey Geonya <a.geonya@gmail.com>", | ||
"author": "Andrey Geonya <a.heonia@gmail.com>", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/AndreyGeonya/hull.git" | ||
"url": "git://github.com/AndriiHeonia/hull.git" | ||
}, | ||
@@ -19,0 +19,0 @@ "main": "./src/hull.js", |
Hull.js - JavaScript library that builds concave hull by set of points. | ||
[![Build Status](https://travis-ci.org/AndreyGeonya/hull.svg?branch=master)](https://travis-ci.org/AndreyGeonya/hull) | ||
## Examples | ||
@@ -13,4 +15,5 @@ | ||
## Params | ||
* 1st param - array of coordinates in format: [[x1, y1], [x2, y2], ..., [xn, yn]]; | ||
* 2nd param - concavity. 1 - thin shape. Infinity - convex hull. By default 20. | ||
* 1st param - array of coordinates in format: `[[x1, y1], [x2, y2], ..., [xn, yn]]`; | ||
* 2nd param - concavity. `1` - thin shape. `Infinity` - convex hull. By default `20`; | ||
* 3rd param - points format. For example: `['.lng', '.lat']` if you have `{lng: x, lat: y}` points. By default you can use `[x, y]` points. | ||
@@ -53,5 +56,4 @@ ## How it works | ||
* make point formats configurable to support formats like `{x: 10, y: 10}` and `{lat: 52, lng: 82}`; | ||
* add new map based example that demonstrates usage with other point formats; | ||
* think about parallelisation of the calculations (on GPU or CPU); | ||
* think about holes; | ||
* think about automatic `concavity` adjustment based on density. | ||
@@ -70,2 +72,4 @@ | ||
### 0.2.2 — 04.02.2015 | ||
Configurable point formats, now you can use points like `{x: 10, y: 10}` and `{lat: 52, lng: 82}`; | ||
### 0.2.1 — 21.10.2014 | ||
@@ -72,0 +76,0 @@ Some minor updates (doc, package.json, etc.). |
@@ -12,2 +12,24 @@ /* | ||
function _formatToXy(pointset, format) { | ||
if (format === undefined) { | ||
return pointset; | ||
} | ||
return pointset.map(function(pt) { | ||
/*jslint evil: true */ | ||
var _getXY = new Function('pt', 'return [pt' + format[0] + ',' + 'pt' + format[1] + '];'); | ||
return _getXY(pt); | ||
}); | ||
} | ||
function _xyToFormat(pointset, format) { | ||
if (format === undefined) { | ||
return pointset; | ||
} | ||
return pointset.map(function(pt) { | ||
/*jslint evil: true */ | ||
var _getObj = new Function('pt', 'var o = {}; o' + format[0] + '= pt[0]; o' + format[1] + '= pt[1]; return o;'); | ||
return _getObj(pt); | ||
}); | ||
} | ||
function _sortByX(pointset) { | ||
@@ -175,3 +197,3 @@ return pointset.sort(function(a, b) { | ||
function hull(pointset, concavity) { | ||
function hull(pointset, concavity, format) { | ||
var lower, upper, convex, | ||
@@ -185,3 +207,4 @@ innerPoints, | ||
} | ||
pointset = _sortByX(pointset); | ||
pointset = _sortByX(_formatToXy(pointset, format)); | ||
upper = _upperTangent(pointset); | ||
@@ -197,3 +220,3 @@ lower = _lowerTangent(pointset); | ||
return _concave(convex, Math.pow(maxEdgeLen, 2), maxSearchBBoxSize, grid(innerPoints)); | ||
return _xyToFormat(_concave(convex, Math.pow(maxEdgeLen, 2), maxSearchBBoxSize, grid(innerPoints)), format); | ||
} | ||
@@ -200,0 +223,0 @@ |
@@ -16,2 +16,8 @@ var assert = require("assert"), | ||
}); | ||
it('should return concave hull with lngs and lats', function() { | ||
var vertices = [{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 } ]; | ||
var 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(vertices, 0.0011, ['.lng', '.lat']), expected); | ||
}); | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4845024
31
432605
77
5