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

geojson2svg

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geojson2svg - npm Package Compare versions

Comparing version 0.0.10 to 0.1.0

CHANGELOG.md

32

dist/geojson2svg.js

@@ -1,2 +0,2 @@

!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<r.length;o++)s(r[o]);return s})({1:[function(require,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<r.length;o++)s(r[o]);return s})({"/home/ubuntu/projects/geojson2svg/node_modules/multigeojson/index.js":[function(require,module,exports){
//index.js

@@ -52,3 +52,3 @@ (function() {

},{}],2:[function(require,module,exports){
},{}],"/home/ubuntu/projects/geojson2svg/node_modules/xtend/immutable.js":[function(require,module,exports){
module.exports = extend

@@ -72,3 +72,3 @@

},{}],3:[function(require,module,exports){
},{}],"/home/ubuntu/projects/geojson2svg/src/converter.js":[function(require,module,exports){
//converter.js

@@ -154,3 +154,3 @@ var multi = require('multigeojson');

},{"multigeojson":1}],4:[function(require,module,exports){
},{"multigeojson":"/home/ubuntu/projects/geojson2svg/node_modules/multigeojson/index.js"}],"/home/ubuntu/projects/geojson2svg/src/instance.js":[function(require,module,exports){
var extend = require('xtend'),

@@ -164,4 +164,9 @@ converter = require('./converter.js');

this.options = options || {};
this.mapExtent = this.options.mapExtent
|| {'left':-180,'bottom':-90,'right':180,'top':90};
this.mapExtent = this.options.mapExtent ||
{
left: -20037508.342789244,
right: 20037508.342789244,
bottom: -20037508.342789244,
top: 20037508.342789244
};
this.res = this.calResolution(this.mapExtent,this.viewportSize);

@@ -209,3 +214,3 @@ };

var opt = extend(extend({},this.options), options || {});
//var explode = opt.hasOwnProperty('explode') ? opt.explode : false;
var output = opt.output || 'svg';
var paths = converter[geom.type].call(this,geom,

@@ -217,3 +222,3 @@ this.res,

var svgJsons,svgEles;
if(opt.output && opt.output.toLowerCase() == 'svg') {
if (output.toLowerCase() == 'svg') {
svgJsons = paths.map(function(path) {

@@ -226,4 +231,5 @@ return pathToSvgJson(path,geom.type,opt.attributes,opt);

return svgEles;
} else {
return paths;
}
return paths;
} else {

@@ -268,3 +274,3 @@ return;

},{"./converter.js":3,"xtend":2}],5:[function(require,module,exports){
},{"./converter.js":"/home/ubuntu/projects/geojson2svg/src/converter.js","xtend":"/home/ubuntu/projects/geojson2svg/node_modules/xtend/immutable.js"}],"/home/ubuntu/projects/geojson2svg/src/main.js":[function(require,module,exports){
var g2svg = require('./instance.js');

@@ -278,6 +284,4 @@ var geojson2svg = function(viewportSize,options) {

},{"./instance.js":4}]},{},[5])(5)
},{"./instance.js":"/home/ubuntu/projects/geojson2svg/src/instance.js"}]},{},["/home/ubuntu/projects/geojson2svg/src/main.js"])("/home/ubuntu/projects/geojson2svg/src/main.js")
});
//# sourceMappingURL=geojson2svg.js.map
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi91c3IvbG9jYWwvbGliL25vZGVfbW9kdWxlcy93YXRjaGlmeS9ub2RlX21vZHVsZXMvYnJvd3NlcmlmeS9ub2RlX21vZHVsZXMvYnJvd3Nlci1wYWNrL19wcmVsdWRlLmpzIiwiL2hvbWUvdWJ1bnR1L3Byb2plY3RzL2dlb2pzb24yc3ZnL25vZGVfbW9kdWxlcy9tdWx0aWdlb2pzb24vaW5kZXguanMiLCIvaG9tZS91YnVudHUvcHJvamVjdHMvZ2VvanNvbjJzdmcvbm9kZV9tb2R1bGVzL3h0ZW5kL2ltbXV0YWJsZS5qcyIsIi9ob21lL3VidW50dS9wcm9qZWN0cy9nZW9qc29uMnN2Zy9zcmMvY29udmVydGVyLmpzIiwiL2hvbWUvdWJ1bnR1L3Byb2plY3RzL2dlb2pzb24yc3ZnL3NyYy9pbnN0YW5jZS5qcyIsIi9ob21lL3VidW50dS9wcm9qZWN0cy9nZW9qc29uMnN2Zy9zcmMvbWFpbi5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTtBQ0FBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUF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2aWV3cG9ydFNpemUpIHJldHVybjtcbiAgcmV0dXJuIG5ldyBnMnN2Zyh2aWV3cG9ydFNpemUsb3B0aW9ucyk7XG59O1xuXG5tb2R1bGUuZXhwb3J0cyA9IGdlb2pzb24yc3ZnO1xuIl19

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

!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(){return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&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}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module){!function(){function explode(g){return multies.indexOf(g.type)>-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;i<arguments.length;i++){var source=arguments[i];for(var key in source)source.hasOwnProperty(key)&&(target[key]=source[key])}return target}module.exports=extend},{}],3:[function(require,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<holes.length;i++)path+=" M"+getCoordString(holes[i],res,origin);return path+="Z",[path]}function multiPolygon(geom,res,origin,opt){var explode=opt.hasOwnProperty("explode")?opt.explode:!1,paths=multi.explode(geom).map(function(single){return polygon(single,res,origin,opt)[0]});return explode?paths:[paths.join(" ").replace(/Z/g,"")+"Z"]}var multi=require("multigeojson");module.exports={Point:point,MultiPoint:multiPoint,LineString:lineString,MultiLineString:multiLineString,Polygon:polygon,MultiPolygon:multiPolygon}},{multigeojson:1}],4:[function(require,module){var extend=require("xtend"),converter=require("./converter.js"),g2svg=function(viewportSize,options){viewportSize&&(this.viewportSize=viewportSize,this.options=options||{},this.mapExtent=this.options.mapExtent||{left:-180,bottom:-90,right:180,top:90},this.res=this.calResolution(this.mapExtent,this.viewportSize))};g2svg.prototype.calResolution=function(extent,size){var xres=(extent.right-extent.left)/size.width,yres=(extent.top-extent.bottom)/size.height;return Math.max(xres,yres)},g2svg.prototype.convert=function(geojson,options){var opt=extend(extend({},this.options),options||{}),svgElements=[];if("FeatureCollection"==geojson.type)for(var i=0;i<geojson.features.length;i++)svgElements=svgElements.concat(this.convertFeature(geojson.features[i],opt));else if("Feature"==geojson.type)svgElements=this.convertFeature(geojson,opt);else if("GeomtryCollection"==geojson.type)for(var i=0;i<geojson.geometries.length;i++)svgElements=svgElements.concat(this.convertGeometry(geojson.geometries[i],opt));else{if(!converter[geojson.type])return;svgElements=this.convertGeometry(geojson,opt)}return opt.callback&&opt.callback.call(this,svgElements),svgElements},g2svg.prototype.convertFeature=function(feature,options){if(feature||feature.geometry){var opt=extend(extend({},this.options),options||{});return opt.attributes=opt.attributes||{},opt.attributes.id=opt.attributes.id||feature.id||null,this.convertGeometry(feature.geometry,opt)}},g2svg.prototype.convertGeometry=function(geom,options){if(converter[geom.type]){var svgJsons,svgEles,opt=extend(extend({},this.options),options||{}),paths=converter[geom.type].call(this,geom,this.res,{x:this.mapExtent.left,y:this.mapExtent.top},opt);return opt.output&&"svg"==opt.output.toLowerCase()?(svgJsons=paths.map(function(path){return pathToSvgJson(path,geom.type,opt.attributes,opt)}),svgEles=svgJsons.map(function(json){return jsonToSvgElement(json,geom.type)})):paths}};var pathToSvgJson=function(path,type,attributes,opt){var svg={},forcePath=opt&&opt.hasOwnProperty("forcePath")?opt.forcePath:!0;"Point"!=type&&"MultiPoint"!=type||forcePath?(svg={d:path},("Polygon"==type||"MultiPolygon"==type)&&"evenodd"==svg["fill-rule"]):(svg.cx=path.split(",")[0],svg.cy=path.split(",")[1],svg.r=opt&&opt.r?opt.r:"1");for(var key in attributes)svg[key]=attributes[key];return svg},jsonToSvgElement=function(json,type,opt){var forcePath=opt&&opt.hasOwnProperty("forcePath")?opt.forcePath:!0,ele="<path";"Point"!=type&&"MultiPoint"!=type||forcePath||(ele="<circle");for(var key in json)ele+=" "+key+'="'+json[key]+'"';return ele+="/>"};module.exports=g2svg},{"./converter.js":3,xtend:2}],5:[function(require,module){var g2svg=require("./instance.js"),geojson2svg=function(viewportSize,options){return viewportSize?new g2svg(viewportSize,options):void 0};module.exports=geojson2svg},{"./instance.js":4}]},{},[5])(5)});
!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(){return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&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}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module){!function(){function explode(g){return multies.indexOf(g.type)>-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;i<arguments.length;i++){var source=arguments[i];for(var key in source)source.hasOwnProperty(key)&&(target[key]=source[key])}return target}module.exports=extend},{}],3:[function(require,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<holes.length;i++)path+=" M"+getCoordString(holes[i],res,origin);return path+="Z",[path]}function multiPolygon(geom,res,origin,opt){var explode=opt.hasOwnProperty("explode")?opt.explode:!1,paths=multi.explode(geom).map(function(single){return polygon(single,res,origin,opt)[0]});return explode?paths:[paths.join(" ").replace(/Z/g,"")+"Z"]}var multi=require("multigeojson");module.exports={Point:point,MultiPoint:multiPoint,LineString:lineString,MultiLineString:multiLineString,Polygon:polygon,MultiPolygon:multiPolygon}},{multigeojson:1}],4:[function(require,module){var extend=require("xtend"),converter=require("./converter.js"),g2svg=function(viewportSize,options){viewportSize&&(this.viewportSize=viewportSize,this.options=options||{},this.mapExtent=this.options.mapExtent||{left:-20037508.342789244,right:20037508.342789244,bottom:-20037508.342789244,top:20037508.342789244},this.res=this.calResolution(this.mapExtent,this.viewportSize))};g2svg.prototype.calResolution=function(extent,size){var xres=(extent.right-extent.left)/size.width,yres=(extent.top-extent.bottom)/size.height;return Math.max(xres,yres)},g2svg.prototype.convert=function(geojson,options){var opt=extend(extend({},this.options),options||{}),svgElements=[];if("FeatureCollection"==geojson.type)for(var i=0;i<geojson.features.length;i++)svgElements=svgElements.concat(this.convertFeature(geojson.features[i],opt));else if("Feature"==geojson.type)svgElements=this.convertFeature(geojson,opt);else if("GeomtryCollection"==geojson.type)for(var i=0;i<geojson.geometries.length;i++)svgElements=svgElements.concat(this.convertGeometry(geojson.geometries[i],opt));else{if(!converter[geojson.type])return;svgElements=this.convertGeometry(geojson,opt)}return opt.callback&&opt.callback.call(this,svgElements),svgElements},g2svg.prototype.convertFeature=function(feature,options){if(feature||feature.geometry){var opt=extend(extend({},this.options),options||{});return opt.attributes=opt.attributes||{},opt.attributes.id=opt.attributes.id||feature.id||null,this.convertGeometry(feature.geometry,opt)}},g2svg.prototype.convertGeometry=function(geom,options){if(converter[geom.type]){var svgJsons,svgEles,opt=extend(extend({},this.options),options||{}),output=opt.output||"svg",paths=converter[geom.type].call(this,geom,this.res,{x:this.mapExtent.left,y:this.mapExtent.top},opt);return"svg"==output.toLowerCase()?(svgJsons=paths.map(function(path){return pathToSvgJson(path,geom.type,opt.attributes,opt)}),svgEles=svgJsons.map(function(json){return jsonToSvgElement(json,geom.type)})):paths}};var pathToSvgJson=function(path,type,attributes,opt){var svg={},forcePath=opt&&opt.hasOwnProperty("forcePath")?opt.forcePath:!0;"Point"!=type&&"MultiPoint"!=type||forcePath?(svg={d:path},("Polygon"==type||"MultiPolygon"==type)&&"evenodd"==svg["fill-rule"]):(svg.cx=path.split(",")[0],svg.cy=path.split(",")[1],svg.r=opt&&opt.r?opt.r:"1");for(var key in attributes)svg[key]=attributes[key];return svg},jsonToSvgElement=function(json,type,opt){var forcePath=opt&&opt.hasOwnProperty("forcePath")?opt.forcePath:!0,ele="<path";"Point"!=type&&"MultiPoint"!=type||forcePath||(ele="<circle");for(var key in json)ele+=" "+key+'="'+json[key]+'"';return ele+="/>"};module.exports=g2svg},{"./converter.js":3,xtend:2}],5:[function(require,module){var g2svg=require("./instance.js"),geojson2svg=function(viewportSize,options){return viewportSize?new g2svg(viewportSize,options):void 0};module.exports=geojson2svg},{"./instance.js":4}]},{},[5])(5)});

@@ -9,8 +9,17 @@ var dataURLPoly = './data/countries.geo.json';

var geojson = JSON.parse(resp);
// covert wgs84 data to Web Mercator projection
var geojson3857 = reproject.reproject(
geojson,'EPSG:4326','EPSG:3857',proj4.defs);
var svgMap = document.getElementById('map');
var convertor = geojson2svg({width:800,height:800});
var attributes = {
'style': 'stroke:#006600; fill: #F0F8FF;stroke-width:0.5px;',
'vector-effect':'non-scaling-stroke'};
var svgElements = convertor.convert(geojson,{attributes:attributes,output:'svg',explode:false});
var convertor = geojson2svg(
{width:800,height:800},
{
attributes: {
'style': 'stroke:#006600; fill: #F0F8FF;stroke-width:0.5px;',
'vector-effect':'non-scaling-stroke'
},
explode: false
}
);
var svgElements = convertor.convert(geojson3857);
var parser = new DOMParser();

@@ -17,0 +26,0 @@ svgElements.forEach(function(svgStr) {

{
"name": "geojson2svg",
"version": "0.0.10",
"version": "0.1.0",
"description": "Converts geojson to svg/path string given svg viewport size and maps extent.",

@@ -5,0 +5,0 @@ "main": "src/main.js",

# geojson2svg
Converts geojson to svg or path data string given svg viewport size and maps extent.
Converts geojson to svg string given svg viewport size and maps extent.

@@ -13,3 +13,3 @@ ## Installation

```
This create a global variable 'geojson2svg'
This creates a global variable 'geojson2svg'
## Usage

@@ -29,7 +29,57 @@ Using in node.js or with browserify

**mapExtent** is critical option default is ```{left: -180, bottom: -90, right: 180, top: 90}``` geographic extent, if set as default that means your data is in geographic coordinate system and output svg string would be without any projection used. For the projected data specify map extent(mapExtent) in the projected coordinate system e.g. for Spherical Mercator that is used by Google Maps, use extent as ```{left: -20037508.34,bottom: -20037508.34, right: 20037508.34, top: 20037508.34}```.
**convert** function returns array of svg element string
### Options
In case the geojsons are in geographic coordinates and you want to project the data, use [reproject](https://github.com/perliedman/reproject) or [proj4js](https://github.com/proj4js/proj4js).
* **mapExtent:** {"left": coordinate, "bottom": coordinate, "right": coordinate, "top": coordinate}. Coordinates should be in same projection as of geojson. Default maps extent are of Web Mercator projection (EPSG:3857). Default extent values are:
```
{
left: -20037508.342789244,
right: 20037508.342789244,
bottom: -20037508.342789244,
top: 20037508.342789244
}
```
* **output:** 'svg'|'path' default is 'svg'
**convert** function returns array of svg/path data string
'svg' - svg element string is returned like ```'<path d="M0,0 20,10 106,40"/>'```
'path' - path 'd' value is returned 'M0,0 20,10 106,40' a linestring
* **explode:** true | false, default is false. Should multigeojson be exploded to many svg elements or not.
* **attributes:** json object containing attribute(key) and values(value) for all svg elements. These attributes would be added to svg string. If option is like
``` {"attributes": {"class": "mapstyle"}}```
returned string would be
```'<path class="mapstyle" d="M0,0 20,10 106,40"/>'```
* **pointAsCircle:** true | false, default is false. For point geojson return circle element for option:
``` { "pointAsCircel": true } ```
output svg string would be:
```'<cirlce cx="30" cy="40" r="1" />'```
* **r:** radius of point svg element
* **callback:** function, accept function that will be called on every geojson conversion with output string as one input variable e.g:
```
{ "callback": function(svgString) {
// do something with svgString
}}
```
Suitable callback function could be render svgString.
The options **'attributes'**, **'r'** and **'callback'** can also be given in **convert** function
```
var svgString = convertor.convert(geojson,
{
"attributes": ...,
"r": ...,
"callback": function
}
```
**mapExtent** is critical option default are the extents of Web Mercator projection ('EPSG:3857') or also known as Spherical Mercator. This projection is used by many web mapping sites (Google / Bing / OpenStreetMap). In case your source data is in geographic coordinates, it can be converted on the fly to Web Mercator Projection using [reproject](https://github.com/perliedman/reproject) or [proj4js](https://github.com/proj4js/proj4js). Check my [world map](https://github.com/gagan-bansal/geojson2svg/blob/master/examples/world.html) example for detail.
### Examples

@@ -41,3 +91,3 @@ Converts geojson LineString to svg element string:

mapExtent: {left: -180, bottom: -90, right: 180, top: 90},
output: 'svg'
output: 'svg'
}

@@ -54,3 +104,4 @@ );

{
output: 'path' //default is path
mapExtent: {left: -180, bottom: -90, right: 180, top: 90},
output: 'path'
}

@@ -68,17 +119,2 @@ );

```
### Options
* **mapExtent:** {"left": coordinate, "bottom": coordinate, "right": coordinate, "top": coordinate}. Coordinates should be in same projection as of geojson
* **output:** 'svg'|'path' default is 'path'
path - path 'd' value is returned 'M0,0 20,10 106,40' a linestring
svg - svg element string is returned like '<path d="M0,0 20,10 106,40"/>'
* **explode:** true|false default is false. Should multigeojson be exploded to many svg elements or not.
* **attributes:** json object containing attribute(key) and values(value) for all svg elements. These attributes would be added for output:'svg' option like attributes: {"class": "mapstyle"} returned string would be '<path class="mapstyle" d="M0,0 20,10 106,40"/>'
* **pointAsCircle:** true|false default is false, for point geojson return cirlce element for output:'svg' like '<cirlce cx="30" cy="40" r="1" />'; when output:'path' out string is '30,40'
* **r:** radius of point svg element
* **callback:** function, accept function that will be called on every geojson conversion with output string as one input variable e.g ```parseSVG(svg) { //do some thing}```
**Options for each geojson:**
**output, exlpode, attributes, pointAsCircle, r** if passed in **convert** function along with each geojson overrides the main options
## Developing

@@ -85,0 +121,0 @@ Once you run

@@ -9,4 +9,9 @@ var extend = require('xtend'),

this.options = options || {};
this.mapExtent = this.options.mapExtent
|| {'left':-180,'bottom':-90,'right':180,'top':90};
this.mapExtent = this.options.mapExtent ||
{
left: -20037508.342789244,
right: 20037508.342789244,
bottom: -20037508.342789244,
top: 20037508.342789244
};
this.res = this.calResolution(this.mapExtent,this.viewportSize);

@@ -54,3 +59,3 @@ };

var opt = extend(extend({},this.options), options || {});
//var explode = opt.hasOwnProperty('explode') ? opt.explode : false;
var output = opt.output || 'svg';
var paths = converter[geom.type].call(this,geom,

@@ -62,3 +67,3 @@ this.res,

var svgJsons,svgEles;
if(opt.output && opt.output.toLowerCase() == 'svg') {
if (output.toLowerCase() == 'svg') {
svgJsons = paths.map(function(path) {

@@ -71,4 +76,5 @@ return pathToSvgJson(path,geom.type,opt.attributes,opt);

return svgEles;
} else {
return paths;
}
return paths;
} else {

@@ -75,0 +81,0 @@ return;

@@ -6,5 +6,3 @@ 'use strict';

'MultiPolygon'];
testDataSets.push(require('./testdata1.js'));
//testDataSets.push(require('./testdata2.js'));
//var expect = require('expect.js'),
var testData = require('./testdata.js');
var expect = require('chai').expect

@@ -14,11 +12,4 @@ ,parsePath = require('parse-svg-path')

/*expect.Assertion.prototype.path = function(path) {
console.log('this: '+JSON.stringify(this.obj));
console.log('path: '+ path.length);
expect(this.obj).to.eql(path);
};*/
describe('geojson2svg', function() {
testDataSets.forEach(function(testData) {
var precision = testData.precision;
var precision = testData.precision;
describe(testData.desc+ ': .convert()', function() {

@@ -29,25 +20,46 @@ var geojson2svg = require('../src/main.js');

it(data.type+ ' {output: "path",explode: false,r:2}',function() {
var actualPaths = converter.convert(data.geojson,testData.options);
testPath(actualPaths,data.path,data.geojson.type,precision);
debugger;
var options = {output:'path'};
options = extend(options,testData.options);
var actualPaths = converter.convert(data.geojson,options);
testPath(actualPaths,data.path,data.geojson.type,precision);
});
it(data.type + ' {output: "svg",explode: false,r:2}',function() {
debugger;
var options = {output:'svg'};
options = extend(options,testData.options);
var actualSVGs = converter.convert(data.geojson,options);
testSVG(actualSVGs,data.svg,data.geojson.type,precision);
it(data.type + ' {output: "svg",explode: false,r:2}',function() {
var actualSVGs = converter.convert(data.geojson,testData.options);
testSVG(actualSVGs,data.svg,data.geojson.type,precision);
});
});
it('Feature {output: "path",explode: false}', function() {
var actualPaths = converter.convert(testData.feature.geojson,
{output:'path',explode:false});
testPath(actualPaths,testData.feature.path,
testData.feature.geojson.type,
precision);
});
it('Feature {output: "svg",explode: false}', function() {
var actualSVGs = converter.convert(testData.feature.geojson,
{
output:'svg',
explode:false,
attributes: { id: 'id1',style:'stroke: #000066; fill: 3333ff;' }
});
});
it('Feature {output: "path",explode: false}', function() {
testSVG(actualSVGs,testData.feature.svg,
testData.feature.geojson.geometry.type,
precision);
});
it('Feature {output: "path",explode: true}', function() {
if(basics.indexOf(testData.feature.geojson.type) > -1) {
var actualPaths = converter.convert(testData.feature.geojson,
{output:'path',explode:false});
testPath(actualPaths,testData.feature.path,
{output:'path',explode:true});
testPath(actualPaths,testData.feature.path_explode,
testData.feature.geojson.type,
precision);
});
it('Feature {output: "svg",explode: false}', function() {
}
});
it('Feature {output: "svg",explode: true}', function() {
if(basics.indexOf(testData.feature.geojson.type) > -1) {
var actualSVGs = converter.convert(testData.feature.geojson,
{
output:'svg',
explode:false,
explode:true,
attributes: { id: 'id1',style:'stroke: #000066; fill: 3333ff;' }

@@ -58,37 +70,15 @@ });

precision);
});
it('Feature {output: "path",explode: true}', function() {
if(basics.indexOf(testData.feature.geojson.type) > -1) {
var actualPaths = converter.convert(testData.feature.geojson,
{output:'path',explode:true});
testPath(actualPaths,testData.feature.path_explode,
testData.feature.geojson.type,
precision);
}
});
it('Feature {output: "svg",explode: true}', function() {
if(basics.indexOf(testData.feature.geojson.type) > -1) {
var actualSVGs = converter.convert(testData.feature.geojson,
{
output:'svg',
explode:true,
attributes: { id: 'id1',style:'stroke: #000066; fill: 3333ff;' }
});
testSVG(actualSVGs,testData.feature.svg,
testData.feature.geojson.geometry.type,
precision);
}
});
it('FeatureCollection {output: "path",explode: false}', function() {
var actualPaths = converter.convert(testData.featureCollection.geojson,
{output: 'path', explode: false});
expect(actualPaths).to.be.an('array');
var expPaths = testData.featureCollection.path;
expect(actualPaths.length).to.be.equal(expPaths.length);
for(var i=0; i < expPaths.length; i++) {
testPath([actualPaths[i]],[expPaths[i]],
testData.featureCollection.geojson.features[i].geometry.type,precision);
}
});
});
}
});
it('FeatureCollection {output: "path",explode: false}', function() {
var actualPaths = converter.convert(testData.featureCollection.geojson,
{output: 'path', explode: false});
expect(actualPaths).to.be.an('array');
var expPaths = testData.featureCollection.path;
expect(actualPaths.length).to.be.equal(expPaths.length);
for(var i=0; i < expPaths.length; i++) {
testPath([actualPaths[i]],[expPaths[i]],
testData.featureCollection.geojson.features[i].geometry.type,precision);
}
});
});

@@ -95,0 +85,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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