From d1d916590a0e5bb6e5070fcd0a478051f50da891 Mon Sep 17 00:00:00 2001 From: gagan-bansal Date: Sun, 13 Apr 2014 16:37:37 +0000 Subject: [PATCH] created global variable for browser through browserify --- dist/geojson2svg.js | 30 +++++++++++++----------------- dist/geojson2svg.js.map | 4 ++-- examples/world.js | 9 +++------ package.json | 11 +++++++---- src/main.js | 8 +------- 5 files changed, 26 insertions(+), 36 deletions(-) diff --git a/dist/geojson2svg.js b/dist/geojson2svg.js index 8d99bab..02c70cb 100644 --- a/dist/geojson2svg.js +++ b/dist/geojson2svg.js @@ -1,4 +1,4 @@ -(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\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", "//index.js \n(function() { \n\tvar singles = ['Point', 'LineString', 'Polygon'];\n\tvar multies = ['MultiPoint', 'MultiLineString', 'MultiPolygon'];\n\tfunction explode(g) {\n\t if( multies.indexOf(g.type) > -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", "//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