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

geojson

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geojson - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

17

geojson.js

@@ -125,11 +125,14 @@ (function(GeoJSON) {

for(var gtype in params.geom) {
attr = (typeof params.geom[gtype] === 'object') ? params.geom[gtype][0] : params.geom[gtype];
if(params.geom.hasOwnProperty(gtype) && item[attr]) {
var val = params.geom[gtype];
// Geometry parameter specified as: {Point: 'coords'}
if(typeof val === 'string' && item.hasOwnProperty(val)) {
geom.type = gtype;
geom.coordinates = item[val];
}
if(typeof params.geom[gtype] === 'string') {
geom.coordinates = item[params.geom[gtype]];
} else {
geom.coordinates = [item[params.geom[gtype][1]], item[params.geom[gtype][0]]];
}
// Geometry parameter specified as: {Point: ['lat', 'lng']}
else if(Array.isArray(val) && item.hasOwnProperty(val[0]) && item.hasOwnProperty(val[1])){
geom.type = gtype;
geom.coordinates = [item[val[1]], item[val[0]]];
}

@@ -136,0 +139,0 @@ }

@@ -1,3 +0,3 @@

// geojson.js - v0.2.0
// (c) 2014 Casey Thomas, MIT License
!function(a){function b(a,b){var c=a||{};for(var d in b)b.hasOwnProperty(d)&&!c[d]&&(c[d]=b[d]);return c}function c(a,b){if(b.crs&&(a.crs={type:"name",properties:{name:b.crs}}),b.bbox&&(a.bbox=b.bbox),b.extraGlobal){a.properties={};for(var c in b.extraGlobal)a.properties[c]=b.extraGlobal[c]}}function d(a){a.geom={};for(var b in a)a.hasOwnProperty(b)&&-1!==j.indexOf(b)&&(a.geom[b]=a[b],delete a[b]);e(a.geom)}function e(a){for(var b in a)a.hasOwnProperty(b)&&("string"==typeof a[b]?k.push(a[b]):"object"==typeof a[b]&&(k.push(a[b][0]),k.push(a[b][1])));if(0===k.length)throw new Error("No geometry attributes specified")}function f(a,b,c){var d={type:"Feature"};return d.geometry=g(a,b),d.properties=c.call(a),d}function g(a,b){var c,d={};for(var e in b.geom)c="object"==typeof b.geom[e]?b.geom[e][0]:b.geom[e],b.geom.hasOwnProperty(e)&&a[c]&&(d.type=e,d.coordinates="string"==typeof b.geom[e]?a[b.geom[e]]:[a[b.geom[e][1]],a[b.geom[e][0]]]);return d}function h(a){var b;return a.exclude||a.include?a.include?b=function(b){a.include.forEach(function(a){b[a]=this[a]},this)}:a.exclude&&(b=function(b){for(var c in this)this.hasOwnProperty(c)&&-1===k.indexOf(c)&&-1===a.exclude.indexOf(c)&&(b[c]=this[c])}):b=function(a){for(var b in this)this.hasOwnProperty(b)&&-1===k.indexOf(b)&&(a[b]=this[b])},function(){var c={};return b.call(this,c),a.extra&&i(c,a.extra),c}}function i(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}a.version="0.2.0",a.defaults={},a.parse=function(a,e,g){var i,j={type:"FeatureCollection",features:[]},l=b(e,this.defaults);return k.length=0,d(l),i=h(l),a.forEach(function(a){j.features.push(f(a,l,i))}),c(j,l),g&&"function"==typeof g?void g(j):j};var j=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],k=[]}("object"==typeof module?module.exports:window.GeoJSON={});
// geojson.js - v0.2.1
// (c) 2015 Casey Thomas, MIT License
!function(a){function b(a,b){var c=a||{};for(var d in b)b.hasOwnProperty(d)&&!c[d]&&(c[d]=b[d]);return c}function c(a,b){if(b.crs&&(a.crs={type:"name",properties:{name:b.crs}}),b.bbox&&(a.bbox=b.bbox),b.extraGlobal){a.properties={};for(var c in b.extraGlobal)a.properties[c]=b.extraGlobal[c]}}function d(a){a.geom={};for(var b in a)a.hasOwnProperty(b)&&-1!==j.indexOf(b)&&(a.geom[b]=a[b],delete a[b]);e(a.geom)}function e(a){for(var b in a)a.hasOwnProperty(b)&&("string"==typeof a[b]?k.push(a[b]):"object"==typeof a[b]&&(k.push(a[b][0]),k.push(a[b][1])));if(0===k.length)throw new Error("No geometry attributes specified")}function f(a,b,c){var d={type:"Feature"};return d.geometry=g(a,b),d.properties=c.call(a),d}function g(a,b){var c={};for(var d in b.geom){var e=b.geom[d];"string"==typeof e&&a.hasOwnProperty(e)?(c.type=d,c.coordinates=a[e]):Array.isArray(e)&&a.hasOwnProperty(e[0])&&a.hasOwnProperty(e[1])&&(c.type=d,c.coordinates=[a[e[1]],a[e[0]]])}return c}function h(a){var b;return a.exclude||a.include?a.include?b=function(b){a.include.forEach(function(a){b[a]=this[a]},this)}:a.exclude&&(b=function(b){for(var c in this)this.hasOwnProperty(c)&&-1===k.indexOf(c)&&-1===a.exclude.indexOf(c)&&(b[c]=this[c])}):b=function(a){for(var b in this)this.hasOwnProperty(b)&&-1===k.indexOf(b)&&(a[b]=this[b])},function(){var c={};return b.call(this,c),a.extra&&i(c,a.extra),c}}function i(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}a.version="0.2.0",a.defaults={},a.parse=function(a,e,g){var i,j={type:"FeatureCollection",features:[]},l=b(e,this.defaults);return k.length=0,d(l),i=h(l),a.forEach(function(a){j.features.push(f(a,l,i))}),c(j,l),g&&"function"==typeof g?void g(j):j};var j=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],k=[]}("object"==typeof module?module.exports:window.GeoJSON={});

@@ -21,3 +21,3 @@ module.exports = function(grunt) {

banner: '// <%= pkg.name %>.js - v<%= pkg.version %>\n' +
'// (c) 2014 Casey Thomas, MIT License \n'
'// (c) 2015 Casey Thomas, MIT License \n'
},

@@ -39,2 +39,2 @@ dist: {

grunt.registerTask('default', ['simplemocha', 'jshint', 'uglify']);
};
};

@@ -5,3 +5,3 @@ {

"author": "Casey Thomas <caseypthomas@gmail.com>",
"version": "0.2.0",
"version": "0.2.1",
"main": "./geojson",

@@ -8,0 +8,0 @@ "repository": {

@@ -289,2 +289,13 @@ if (typeof window === 'undefined') {

it("returns valid GeoJSON output for 0,0", function(done){
GeoJSON.parse([{ lat: 0, lng: 0 }], {Point: ['lat', 'lng']}, function(geojson){
expect(geojson.type).to.be('FeatureCollection');
expect(geojson.features).to.be.an('array');
expect(geojson.features.length).to.be(1);
expect(geojson.features[0].geometry.coordinates[0]).to.equal(0);
expect(geojson.features[0].geometry.coordinates[1]).to.equal(0);
done();
});
});
it("throws an error if no geometry attributes have been specified", function() {

@@ -291,0 +302,0 @@ expect(function(){ GeoJSON.parse(data); }).to.throwException(/No geometry attributes specified/);

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