From 607ff999549f8c846714c32c067e06c3e06b4833 Mon Sep 17 00:00:00 2001 From: gagan-bansal Date: Wed, 27 Aug 2014 02:18:41 +0000 Subject: [PATCH] switch dependant from deep-extend to xtend, all dependants version upgraded --- dist/geojson2svg.js | 125 ++++++++++------------------------------ dist/geojson2svg.js.map | 16 ++--- dist/geojson2svg.min.js | 2 +- package.json | 18 +++--- src/instance.js | 2 +- test/test.js | 9 +-- 6 files changed, 53 insertions(+), 119 deletions(-) diff --git a/dist/geojson2svg.js b/dist/geojson2svg.js index 6d43397..3a36218 100644 --- a/dist/geojson2svg.js +++ b/dist/geojson2svg.js @@ -1,88 +1,4 @@ -!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var o;"undefined"!=typeof window?o=window:"undefined"!=typeof global?o=global:"undefined"!=typeof self&&(o=self),o.geojson2svg=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);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o - * @license MIT - * - * The MIT License (MIT) - * - * Copyright (c) 2013 Viacheslav Lotsmanov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * Extening object that entered in first argument. - * Returns extended object or false if have no target object or incorrect type. - * If you wish to clone object, simply use that: - * deepExtend({}, yourObj_1, [yourObj_N]) - first arg is new empty object - */ -var deepExtend = module.exports = function (/*obj_1, [obj_2], [obj_N]*/) { - if (arguments.length < 1 || typeof arguments[0] !== 'object') { - return false; - } - - if (arguments.length < 2) return arguments[0]; - - var target = arguments[0]; - - // convert arguments to array and cut off target object - var args = Array.prototype.slice.call(arguments, 1); - - var key, val, src, clone; - - args.forEach(function (obj) { - if (typeof obj !== 'object') return; - - for (key in obj) { - if ( ! (key in obj)) continue; - - src = target[key]; - val = obj[key]; - - if (val === target) continue; - - if (typeof val !== 'object' || val === null) { - target[key] = val; - continue; - } - - if (typeof src !== 'object' || src === null) { - clone = (Array.isArray(val)) ? [] : {}; - target[key] = deepExtend(clone, val); - continue; - } - - if (Array.isArray(val)) { - clone = (Array.isArray(src)) ? src : []; - } else { - clone = (!Array.isArray(src)) ? src : {}; - } - - target[key] = deepExtend(clone, val); - } - }); - - return target; -} - -},{}],2:[function(_dereq_,module,exports){ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var o;"undefined"!=typeof window?o=window:"undefined"!=typeof global?o=global:"undefined"!=typeof self&&(o=self),o.geojson2svg=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\n * @license MIT\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2013 Viacheslav Lotsmanov\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of\n * this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to\n * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n * the Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\n * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\n * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * Extening object that entered in first argument.\n * Returns extended object or false if have no target object or incorrect type.\n * If you wish to clone object, simply use that:\n * deepExtend({}, yourObj_1, [yourObj_N]) - first arg is new empty object\n */\nvar deepExtend = module.exports = function (/*obj_1, [obj_2], [obj_N]*/) {\n if (arguments.length < 1 || typeof arguments[0] !== 'object') {\n return false;\n }\n\n if (arguments.length < 2) return arguments[0];\n\n var target = arguments[0];\n\n // convert arguments to array and cut off target object\n var args = Array.prototype.slice.call(arguments, 1);\n\n var key, val, src, clone;\n\n args.forEach(function (obj) {\n if (typeof obj !== 'object') return;\n\n for (key in obj) {\n if ( ! (key in obj)) continue;\n\n src = target[key];\n val = obj[key];\n\n if (val === target) continue;\n\n if (typeof val !== 'object' || val === null) {\n target[key] = val;\n continue;\n }\n\n if (typeof src !== 'object' || src === null) {\n clone = (Array.isArray(val)) ? [] : {};\n target[key] = deepExtend(clone, val);\n continue;\n }\n\n if (Array.isArray(val)) {\n clone = (Array.isArray(src)) ? src : [];\n } else {\n clone = (!Array.isArray(src)) ? src : {};\n }\n\n target[key] = deepExtend(clone, val);\n }\n });\n\n return target;\n}\n", + "(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 -1) {\n\t return g.coordinates.map(function(part) {\n\t var single = {};\n\t single.type = g.type.replace('Multi','');\n\t single.coordinates = part;\n if(g.crs) single.crs = g.crs;\n\t return single;\n\t }); \n\t } else {\n\t return false;\n\t }\n\t}\n\tfunction implode(gs) {\n\t var sameType = gs.every(function(g) { \n\t return singles.indexOf(g.type) > -1;\n\t })\n var crs = gs[0].crs || 0;\n var sameCrs = gs.every(function(g) {\n var gcrs = g.crs || 0;\n return gcrs == crs;\n });\n\t if(sameType && sameCrs) {\n\t var multi = {};\n\t multi.type = 'Multi' + gs[0].type;\n\t multi.coordinates = [];\n if(crs != 0) multi.crs = crs;\n\t gs.forEach(function(g) {\n\t multi.coordinates.push(g.coordinates);\n\t });\n\t return multi;\n\t } else {\n\t return false;\n\t }\n\t};\n\tvar multigeojson = {\n\t explode: explode,\n\t implode: implode\n\t};\n\tif(typeof module !== 'undefined' && module.exports) {\n\t module.exports = multigeojson;\n\t} else if(window) {\n\t window.multigeojson = multigeojson;\n\t}\n})();\n", + "module.exports = extend\n\nfunction extend() {\n var target = {}\n\n for (var i = 0; i < arguments.length; i++) {\n var source = arguments[i]\n\n for (var key in source) {\n if (source.hasOwnProperty(key)) {\n target[key] = source[key]\n }\n }\n }\n\n return target\n}\n", "//converter.js\nvar multi = require('multigeojson');\nfunction getCoordString(coords,res,origin) {\n //origin - svg image origin \n var coordStr = coords.map(function(coord) {\n return (coord[0] - origin.x)/res + ',' + (origin.y - coord[1])/res;\n });\n return coordStr.join(' ');\n}\nfunction addAttributes(ele,attributes) {\n var part = ele.split('/>')[0];\n for(var key in attributes) {\n if(attributes[key]) {\n part += ' ' + key + '=\"' + attributes[key] + '\"';\n }\n }\n return part + ' />';\n}\n\nfunction point(geom,res,origin,opt) {\n var r = opt && opt.r ? opt.r : 1;\n var path = 'M' + getCoordString([geom.coordinates],res,origin)\n +' m'+ -r+ ',0'+ ' a'+r+','+ r + ' 0 1,1 '+ 2*r + ','+0\n +' a'+r+','+ r + ' 0 1,1 '+ -2*r + ','+0;\n return [path];\n}\nfunction multiPoint(geom,res,origin,opt) {\n var explode = opt && opt.hasOwnProperty('explode') ? opt.explode : false;\n var paths = multi.explode(geom).map(function(single) {\n return point(single,res,origin,opt)[0];\n });\n if(!explode) return [paths.join(' ')];\n return paths;\n\n}\nfunction lineString(geom,res,origin,otp) {\n var coords = getCoordString(geom.coordinates,res,origin);\n var path = 'M'+ coords; \n return [path];\n}\nfunction multiLineString(geom,res,origin,opt) {\n var explode = opt && opt.hasOwnProperty('explode') ? opt.explode : false;\n var paths = multi.explode(geom).map(function(single) {\n return lineString(single,res,origin,opt)[0];\n });\n if(!explode) return [paths.join(' ')];\n return paths;\n}\nfunction polygon(geom,res,origin,opt) {\n var mainStr,holes,holeStr;\n mainStr = getCoordString(geom.coordinates[0],res,origin);\n if (geom.coordinates.length > 1) {\n holes = geom.coordinates.slice(1,geom.coordinates.length);\n }\n var path = 'M'+ mainStr;\n if(holes) {\n for(var i=0;i-1?g.coordinates.map(function(part){var single={};return single.type=g.type.replace("Multi",""),single.coordinates=part,g.crs&&(single.crs=g.crs),single}):!1}function implode(gs){var sameType=gs.every(function(g){return singles.indexOf(g.type)>-1}),crs=gs[0].crs||0,sameCrs=gs.every(function(g){var gcrs=g.crs||0;return gcrs==crs});if(sameType&&sameCrs){var multi={};return multi.type="Multi"+gs[0].type,multi.coordinates=[],0!=crs&&(multi.crs=crs),gs.forEach(function(g){multi.coordinates.push(g.coordinates)}),multi}return!1}var singles=["Point","LineString","Polygon"],multies=["MultiPoint","MultiLineString","MultiPolygon"],multigeojson={explode:explode,implode:implode};"undefined"!=typeof module&&module.exports?module.exports=multigeojson:window&&(window.multigeojson=multigeojson)}()},{}],3:[function(_dereq_,module){function getCoordString(coords,res,origin){var coordStr=coords.map(function(coord){return(coord[0]-origin.x)/res+","+(origin.y-coord[1])/res});return coordStr.join(" ")}function point(geom,res,origin,opt){var r=opt&&opt.r?opt.r:1,path="M"+getCoordString([geom.coordinates],res,origin)+" m"+-r+",0 a"+r+","+r+" 0 1,1 "+2*r+",0 a"+r+","+r+" 0 1,1 "+-2*r+",0";return[path]}function multiPoint(geom,res,origin,opt){var explode=opt&&opt.hasOwnProperty("explode")?opt.explode:!1,paths=multi.explode(geom).map(function(single){return point(single,res,origin,opt)[0]});return explode?paths:[paths.join(" ")]}function lineString(geom,res,origin){var coords=getCoordString(geom.coordinates,res,origin),path="M"+coords;return[path]}function multiLineString(geom,res,origin,opt){var explode=opt&&opt.hasOwnProperty("explode")?opt.explode:!1,paths=multi.explode(geom).map(function(single){return lineString(single,res,origin,opt)[0]});return explode?paths:[paths.join(" ")]}function polygon(geom,res,origin){var mainStr,holes;mainStr=getCoordString(geom.coordinates[0],res,origin),geom.coordinates.length>1&&(holes=geom.coordinates.slice(1,geom.coordinates.length));var path="M"+mainStr;if(holes)for(var i=0;i-1?g.coordinates.map(function(part){var single={};return single.type=g.type.replace("Multi",""),single.coordinates=part,g.crs&&(single.crs=g.crs),single}):!1}function implode(gs){var sameType=gs.every(function(g){return singles.indexOf(g.type)>-1}),crs=gs[0].crs||0,sameCrs=gs.every(function(g){var gcrs=g.crs||0;return gcrs==crs});if(sameType&&sameCrs){var multi={};return multi.type="Multi"+gs[0].type,multi.coordinates=[],0!=crs&&(multi.crs=crs),gs.forEach(function(g){multi.coordinates.push(g.coordinates)}),multi}return!1}var singles=["Point","LineString","Polygon"],multies=["MultiPoint","MultiLineString","MultiPolygon"],multigeojson={explode:explode,implode:implode};"undefined"!=typeof module&&module.exports?module.exports=multigeojson:window&&(window.multigeojson=multigeojson)}()},{}],2:[function(require,module){function extend(){for(var target={},i=0;i1&&(holes=geom.coordinates.slice(1,geom.coordinates.length));var path="M"+mainStr;if(holes)for(var i=0;i dist/geojson2svg.js", "build-min": "browserify src/main.js --standalone geojson2svg | uglifyjs -c > dist/geojson2svg.min.js", "build": "npm run build-debug && npm run build-min", - "watch": "watchify src/main.js --debug --standalone geojson2svg -o dist/geojson2svg.js -v" + "watch": "watchify src/main.js --debug --standalone geojson2svg -o dist/geojson2svg.js -v" }, "keywords": [ "maps", @@ -22,16 +22,16 @@ "auther": "Gagan Bansal", "license": "MIT", "dependencies": { - "deep-extend": "~0.2.8", - "multigeojson": "0.0.0" + "multigeojson": "~0.0.1", + "xtend": "~4.0.0" }, "devDependencies": { - "browserify": "^3.46.0", - "chai": "~1.9.0", - "jsdom": "~0.10.5", - "mocha": "~1.17.1", + "browserify": "~5.10.1", + "chai": "~1.9.1", + "jsdom": "~1.0.0-pre", + "mocha": "~1.21.4", "parse-svg-path": "~0.1.1", - "uglify-js": "^2.4.13", - "watchify": "^0.8.3" + "uglify-js": "~2.4.15", + "watchify": "~1.0.2" } } diff --git a/src/instance.js b/src/instance.js index fadcf02..831f94f 100644 --- a/src/instance.js +++ b/src/instance.js @@ -1,4 +1,4 @@ -var extend = require('deep-extend'), +var extend = require('xtend'), converter = require('./converter.js'); //g2svg as geojson2svg (shorthand) diff --git a/test/test.js b/test/test.js index 0c1ac33..6ebbf14 100644 --- a/test/test.js +++ b/test/test.js @@ -1,6 +1,6 @@ 'use strict'; var testDataSets = []; -var extend = require('deep-extend'); +var extend = require('xtend'); var basics = ['Point', 'LineString', 'Polygon', 'MultiPoint', 'MultiLineString', 'MultiPolygon']; testDataSets.push(require('./testdata1.js')); @@ -28,8 +28,9 @@ describe('geojson2svg', function() { testPath(actualPaths,data.path,data.geojson.type,precision); }); it(data.type + ' {output: "svg",explode: false,r:2}',function() { + debugger; var options = {output:'svg'}; - extend(options,testData.options); + options = extend(options,testData.options); var actualSVGs = converter.convert(data.geojson,options); testSVG(actualSVGs,data.svg,data.geojson.type,precision); }); @@ -94,8 +95,8 @@ function testSVG(actualSVGs,expSVGs,type,precision) { expect(actualSVGs.length).to.be.equal(expSVGs.length); var expSVGEle,actSVGEle,expPaths,actPaths; for(var i=0;i