New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

geo-util

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geo-util - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

test/test-index.js

29

dist/index.js

@@ -7,8 +7,31 @@ 'use strict';

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _lodash = require('lodash');
var _lodash2 = _interopRequireDefault(_lodash);
var _point = require('./point');
var point = _interopRequireWildcard(_point);
var _point2 = _interopRequireDefault(_point);
exports.point = point;
function isLegal(collection) {
return collection && collection.type && _lodash2['default'].isArray(collection.geometries);
}
exports['default'] = {
point: _point2['default'],
isPoints: function isPoints(collection) {
return isLegal(collection) && collection.type === 'point';
},
isLines: function isLines(collection) {
return isLegal(collection) && collection.type === 'line';
},
isPolygons: function isPolygons(collection) {
return isLegal(collection) && collection.type === 'polygon';
},
toGeoJSON: function toGeoJSON(collection) {
if (isPoint(collection)) return _point2['default'].toGeoJSON(collection);
}
};
module.exports = exports['default'];

30

dist/point.js

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

'use strict';
"use strict";
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true

@@ -9,3 +9,3 @@ });

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -16,3 +16,3 @@ var _ngeohash = require('ngeohash');

exports['default'] = {
exports["default"] = {
clusterByGeohash: function clusterByGeohash(points, geohashLevel, reducer) {

@@ -23,3 +23,3 @@ var result = [];

var point = points.geometries[i];
var geohash = _ngeohash2['default'].encode(point.lat, point.lng, geohashLevel);
var geohash = _ngeohash2["default"].encode(point.lat, point.lng, geohashLevel);
if (geohashes[geohash]) {

@@ -32,3 +32,3 @@ geohashes[geohash] = reducer(geohashes[geohash], point);

for (var geohash in geohashes) {
var _ngeohash$decode = _ngeohash2['default'].decode(geohash);
var _ngeohash$decode = _ngeohash2["default"].decode(geohash);

@@ -44,4 +44,20 @@ var latitude = _ngeohash$decode.latitude;

return result;
},
toGeoJson: function toGeoJson(points) {
var features = points.geometries.map(function (point) {
return {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [point.lng, point.lat, point.alt || 0]
},
"properties": _extends({}, point.properties, {
id: point.id,
time: point.time
})
};
});
return { type: "FeatureCollection", features: features };
}
};
module.exports = exports['default'];
module.exports = exports["default"];

@@ -1,5 +0,22 @@

import * as point from './point'
import _ from 'lodash'
import point from './point'
export {
point
function isLegal(collection) {
return collection && collection.type && _.isArray(collection.geometries)
}
export default {
point,
isPoints(collection) {
return isLegal(collection) && collection.type === 'point'
},
isLines(collection) {
return isLegal(collection) && collection.type === 'line'
},
isPolygons(collection) {
return isLegal(collection) && collection.type === 'polygon'
},
toGeoJSON(collection) {
if (isPoint(collection)) return point.toGeoJSON(collection)
},
}

@@ -26,3 +26,20 @@ import ngeohash from 'ngeohash'

},
toGeoJson(points) {
const features = points.geometries.map((point) => {
return {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [point.lng, point.lat, point.alt || 0]
},
"properties": {
...point.properties,
id: point.id,
time: point.time
}
}
})
return {type: "FeatureCollection", features}
}
}
{
"name": "geo-util",
"version": "0.0.4",
"version": "0.0.5",
"description": "geo-util for eye",

@@ -5,0 +5,0 @@ "author": "xiagan <huikang.whk@alibaba-inc.com>",

@@ -54,2 +54,30 @@ import e from 'expect.js'

})
describe('toGeoJson()', () => {
const points = {
type: 'point',
geometries: [
{
id: '1',
lat: 10.1111111,
lng: 110.1111111,
properties: {
value: 1
}
},
]
}
it('should return cluster points', () => {
const geometries = points.geometries
const result = point.toGeoJson(points)
e(result).to.have.property('type', 'FeatureCollection')
e(result.features).to.be.an(Array)
e(result.features[0]).to.have.property('type', 'Feature')
e(result.features[0].geometry).to.have.property('type', 'Point')
e(result.features[0].geometry.coordinates[0]).to.be.equal(110.1111111)
e(result.features[0].geometry.coordinates[1]).to.be.equal(10.1111111)
e(result.features[0].geometry.coordinates[2]).to.be.equal(0)
e(result.features[0].properties).to.have.property('value', 1)
e(result.features[0].properties).to.have.property('id', '1')
})
})
})

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