From 2e8d9d458045cd7fc80c0bcf65136c120928f33c Mon Sep 17 00:00:00 2001 From: morganherlocker Date: Fri, 5 Dec 2014 14:20:52 -0500 Subject: [PATCH 01/42] point buffer implemented --- geojson/FeatureCollection.geojson | 141 ------------------------------ geojson/LineString.geojson | 1 - geojson/Point.geojson | 8 -- geojson/Polygon.geojson | 43 --------- index.js | 74 +++++----------- package.json | 3 +- test.js | 35 ++++---- 7 files changed, 42 insertions(+), 263 deletions(-) delete mode 100644 geojson/FeatureCollection.geojson delete mode 100644 geojson/LineString.geojson delete mode 100644 geojson/Point.geojson delete mode 100644 geojson/Polygon.geojson diff --git a/geojson/FeatureCollection.geojson b/geojson/FeatureCollection.geojson deleted file mode 100644 index 966478d..0000000 --- a/geojson/FeatureCollection.geojson +++ /dev/null @@ -1,141 +0,0 @@ - { - "type": "FeatureCollection", - "features": [ - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [-75.833, 39.284]}, - "properties": { - "name": "Location B", - "category": "House", - "elevation": 25 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [-75.6, 39.984]}, - "properties": { - "name": "Location A", - "category": "Store", - "elevation": 23 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [ -75.221, 39.125]}, - "properties": { - "name": "Location C", - "category": "Office", - "elevation": 29 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [-75.358, 39.987]}, - "properties": { - "name": "Location A", - "category": "Store", - "elevation": 12 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [-75.9221, 39.27]}, - "properties": { - "name": "Location B", - "category": "House", - "elevation": 11 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [ -75.534, 39.123]}, - "properties": { - "name": "Location C", - "category": "Office", - "elevation": 49 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [-75.21, 39.12]}, - "properties": { - "name": "Location A", - "category": "Store", - "elevation": 50 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [-75.22, 39.33]}, - "properties": { - "name": "Location B", - "category": "House", - "elevation": 90 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [ -75.44, 39.55]}, - "properties": { - "name": "Location C", - "category": "Office", - "elevation": 22 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [-75.77, 39.66]}, - "properties": { - "name": "Location A", - "category": "Store", - "elevation": 99 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [-75.44, 39.11]}, - "properties": { - "name": "Location B", - "category": "House", - "elevation": 55 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [ -75.05, 39.92]}, - "properties": { - "name": "Location C", - "category": "Office", - "elevation": 41 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [-75.88, 39.98]}, - "properties": { - "name": "Location A", - "category": "Store", - "elevation": 52 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [-75.55, 39.55]}, - "properties": { - "name": "Location B", - "category": "House", - "elevation": 143 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [ -75.33, 39.44]}, - "properties": { - "name": "Location C", - "category": "Office", - "elevation": 76 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [ -75.56, 39.24]}, - "properties": { - "name": "Location C", - "category": "Office", - "elevation": 18 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [ -75.56, 39.36]}, - "properties": { - "name": "Location C", - "category": "Office", - "elevation": 52 - } - } - ] - } \ No newline at end of file diff --git a/geojson/LineString.geojson b/geojson/LineString.geojson deleted file mode 100644 index 152c448..0000000 --- a/geojson/LineString.geojson +++ /dev/null @@ -1 +0,0 @@ -{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-80.08724212646484,32.77428536643231],[-80.08718319576123,32.774407687035286],[-80.08700937968847,32.774766344815355],[-80.08672514230369,32.77534888372924],[-80.08633494766407,32.77614284773365],[-80.08584325982665,32.7771357807853],[-80.08525454284863,32.77831522684092],[-80.0845732607871,32.77966872985719],[-80.08380387769924,32.78118383379086],[-80.08295085764209,32.782848082598626],[-80.06932431738281,32.80743595279523],[-80.06781585015088,32.809918368715984],[-80.06628177869239,32.81238800094813],[-80.06472656706445,32.81483239344839],[-80.06315467932423,32.81723909017347],[-80.06157057952882,32.81959563508009],[-80.05997873173536,32.82188957212499],[-80.05838360000097,32.82410844526483],[-80.05678964838282,32.82623979845637],[-80.05520134093798,32.82827117565631],[-80.03937919482422,32.840455481030595],[-80.03820681391552,32.84031557495512],[-80.03709940542186,32.839912668840455],[-80.03607559555957,32.839228128951426],[-80.03513665748144,32.83827031609085],[-80.0342780125122,32.83705398890388],[-80.03349508197655,32.83559390603568],[-80.03278328719922,32.833904826131416],[-80.03213804950488,32.83200150783622],[-80.03155479021825,32.829898709795266],[-80.02792001184082,32.797823240639616],[-80.02772335677393,32.794477859971806],[-80.02752915733595,32.79112486194529],[-80.02733283485155,32.7877790052052],[-80.02712981064552,32.78445504839672],[-80.02691550604247,32.781167750165],[-80.02668534236719,32.77793186915518],[-80.02643474094434,32.77476216401244],[-80.02615912309864,32.771673393381924],[-80.02585391015478,32.768680315908796],[-80.01923379016112,32.74629318460675],[-80.0182162993667,32.7455995993445],[-80.01710969069532,32.745193569626686],[-80.01590938547167,32.74508985409846],[-80.01462611447754,32.74530625723315],[-80.0133079284668,32.7458529732646],[-80.01196016835938,32.7467148599869],[-80.0105844626587,32.747875435203014],[-80.00918243986817,32.74931821671588],[-80.00775572849122,32.75102672232845],[-79.99089820861818,32.78264416628983],[-79.9893022574707,32.786255749728674],[-79.98770278828124,32.789918788705535],[-79.98610142955323,32.793616801023354],[-79.98449980979004,32.79733330448507],[-79.98289955749513,32.801051816893654],[-79.98130230117187,32.804755856052026],[-79.97970966932374,32.808428939763154],[-79.9781232904541,32.81205458582997],[-79.97654479306641,32.81561631205542],[-79.96016725158691,32.84586268264848],[-79.95881035524904,32.84737175940747],[-79.95748251093748,32.84860264776342],[-79.95618534715575,32.849538865519264],[-79.95492049240723,32.850163930477954],[-79.95368957519531,32.850461360442424],[-79.95251206269141,32.85043662672373],[-79.95140467835009,32.850115427468296],[-79.9503649350996,32.84951162073215],[-79.94939034586817,32.84863906457134],[-79.94225872705078,32.8252668887998],[-79.94187199444922,32.822250267913596],[-79.94151808393359,32.81914505233115],[-79.94119450843213,32.815965100108514],[-79.94089878087306,32.812724269301725],[-79.94062841418457,32.8094364179668],[-79.94038092129493,32.8061154041598],[-79.94015381513232,32.80277508593673],[-79.93994460862501,32.79942932135364],[-79.93975081470117,32.79609196846656],[-79.93792500952149,32.76389966267125],[-79.93772217500099,32.76174417850698],[-79.93750242113087,32.75977726076716],[-79.93726326083936,32.75801276750783],[-79.93700220705468,32.75646455678503],[-79.9367167727051,32.755146486654795],[-79.93640447071876,32.754072415173134],[-79.93606645257714,32.7532530165506],[-79.93574776400976,32.75265405687018],[-79.93546119593701,32.752255715114025],[-79.93394115820313,32.758609055294215],[-79.93390701563526,32.75993476040094],[-79.93388282349024,32.76134718872719],[-79.93386687637793,32.76283757914186],[-79.9338574689082,32.76439717051379],[-79.93385289569092,32.766017201711854],[-79.93385145133594,32.767688911604935],[-79.93385143045312,32.769403539061884],[-79.93385112765235,32.771152322951565],[-79.93384883754345,32.77292650214285],[-79.93320474243163,32.791612879648774],[-79.93304558419482,32.79300843423089],[-79.93286226857812,32.79431548940991],[-79.9326530901914,32.79552528405464],[-79.93241634364453,32.79662905703398],[-79.93215032354738,32.797618047216794],[-79.93185332450977,32.79848349347194],[-79.93152364114161,32.79921663466829],[-79.93115956805272,32.7998087096747],[-79.93076445230713,32.80025548858628],[-79.92563361053467,32.79800331988575],[-79.92511511165772,32.79732586216012],[-79.92459094416503,32.79659927901422],[-79.92406180217284,32.79583041516321],[-79.92352837979736,32.7950261153223],[-79.9229913711548,32.794193224206666],[-79.92245147036132,32.79333858653149],[-79.9219093715332,32.79246904701197],[-79.92136576878663,32.791591450363285],[-79.9208213562378,32.79071264130061],[-79.91497788848876,32.782923310831485],[-79.91447789937743,32.78256384058549],[-79.91398612397462,32.78229213922294],[-79.91350325639647,32.78211505145899],[-79.91302999075928,32.78203942200884],[-79.9125670211792,32.78207209558768],[-79.91211504177247,32.78221991691069],[-79.91167474665528,32.782489730693044],[-79.91124682994385,32.78288838164996],[-79.9108319857544,32.78342271449659],[-79.91051217022705,32.79825185788735],[-79.91083374809764,32.80021842735615],[-79.91118676088965,32.80224954504018],[-79.91156481953027,32.804336287035326],[-79.91196153494678,32.80646972943742],[-79.9123705180664,32.80864094834233],[-79.9127853798164,32.81084101984593],[-79.91319973112402,32.813061020044074],[-79.91360718291651,32.81529202503262],[-79.9140013461211,32.81752511090743],[-79.91563281976319,32.83967415743999],[-79.91536917223829,32.84123614942711],[-79.91500917817969,32.842684211546704],[-79.91454644851464,32.8440094198946],[-79.91397459417041,32.84520285056667],[-79.91328722607422,32.84625557965878],[-79.9124779551533,32.84715868326679],[-79.91154039233496,32.84790323748656],[-79.91046814854639,32.84848031841395],[-79.90925483471483,32.84888100214482],[-79.88681002807616,32.84043101772218],[-79.88412558002344,32.83863843745276],[-79.88136658816114,32.836718132514406],[-79.87854052117969,32.83468042668278],[-79.87565484776954,32.832535643733465],[-79.8727170366211,32.830294107442114],[-79.8697345564248,32.82796614158433],[-79.8667148758711,32.82556206993572],[-79.86366546365039,32.823092216271924],[-79.86059378845312,32.820566904368555],[-79.82747205029295,32.79208082944673],[-79.82471577723045,32.789695273166785],[-79.82203433416699,32.78738846773032],[-79.81943518979296,32.785170736912946],[-79.81692581279883,32.78305240449029],[-79.81451367187499,32.78104379423797],[-79.8122062357119,32.77915522993161],[-79.81001097299999,32.77739703534683],[-79.80793535242968,32.775779534259236],[-79.80598684269138,32.774313050444455],[-79.79534838500975,32.769070906870525],[-79.79543174302734,32.76941324126892],[-79.79566084053221,32.76986395696048],[-79.7960265045117,32.77041767918655],[-79.79651956195312,32.7710690331885],[-79.79713083984373,32.771812644207664],[-79.7978511651709,32.77264313748538],[-79.79867136492186,32.773555138263006],[-79.79958226608397,32.774543271781894],[-79.80057469564451,32.77560216328338],[-79.81424881347655,32.79038281567679],[-79.81550408882812,32.791871571794594],[-79.81672164341308,32.79336121403251],[-79.81789230421874,32.794846367631884],[-79.81900689823242,32.79632165783408],[-79.8200562524414,32.797781709880425],[-79.82103119383301,32.79922114901228],[-79.82192254939454,32.800634600470985],[-79.82272114611327,32.8020166894979],[-79.82341781097657,32.803362041334346],[-79.82317655694578,32.81511763936037],[-79.82264117182325,32.81603438083504],[-79.82205102188087,32.81693771442673],[-79.82140863476954,32.81782681524612],[-79.82071653814013,32.81870085840387],[-79.81997725964357,32.81955901901067],[-79.81919332693067,32.82040047217716],[-79.81836726765233,32.821224393014035],[-79.81750160945947,32.82202995663195],[-79.81659888000293,32.82281633814159],[-79.80494506072998,32.82996459725244],[-79.80379463287794,32.83045645209492],[-79.80263999322362,32.83091840126783],[-79.80148366941798,32.831349619881834],[-79.80032818911182,32.8317492830476],[-79.79917607995607,32.83211656587579],[-79.79802986960156,32.8324506434771],[-79.79689208569923,32.83275069096218],[-79.7957652558999,32.833015883441696],[-79.7946519078545,32.833245396026335],[-79.78379761834717,32.83333571959247],[-79.7828884123711,32.833179884680774],[-79.78198295070703,32.83300497173636],[-79.78108284014503,32.832809895070106],[-79.78018968747509,32.83259356899291],[-79.77930509948729,32.832354907815684],[-79.77843068297167,32.832092825849315],[-79.77756804471827,32.83180623740469],[-79.77671879151708,32.83149405679271],[-79.77588453015821,32.831155198324254],[-79.76815665875245,32.82535650956062],[-79.76762762912402,32.8246128330644],[-79.7671344796084,32.82382836475334],[-79.7666788169956,32.82300201893834],[-79.76626224807569,32.822132709930294],[-79.76588637963867,32.821219352040096],[-79.76555281847462,32.82026085957865],[-79.76526317137353,32.819256146856844],[-79.7650190451255,32.81820412818556],[-79.76482204652052,32.817103717875725],[-79.76629620263671,32.8014305177732],[-79.76689192710352,32.7995741723892],[-79.76759057844433,32.79762646866419],[-79.76838602601123,32.795594594234984],[-79.76927213915624,32.79348573673839],[-79.77024278723144,32.79130708381121],[-79.77129183958887,32.78906582309027],[-79.77241316558056,32.786769142212364],[-79.77360063455859,32.7844242288143],[-79.77484811587502,32.7820382705329],[-79.790777859375,32.75513943126411],[-79.7922672982119,32.752821570053676],[-79.79373705096387,32.750556103238424],[-79.79518098698291,32.748350218455144],[-79.79659297562108,32.746211103340656],[-79.79796688623048,32.74414594553178],[-79.79929658816309,32.742161932665304],[-79.80057595077098,32.740266252378035],[-79.80179884340623,32.73846609230681],[-79.80295913542089,32.736768640088414]]},"properties":{}} \ No newline at end of file diff --git a/geojson/Point.geojson b/geojson/Point.geojson deleted file mode 100644 index 8c290bf..0000000 --- a/geojson/Point.geojson +++ /dev/null @@ -1,8 +0,0 @@ -{ - "type": "Feature", - "geometry": {"type": "Point", "coordinates": [-75.4, 39.4]}, - "properties": { - "name": "Location A", - "category": "Store" - } -} \ No newline at end of file diff --git a/geojson/Polygon.geojson b/geojson/Polygon.geojson deleted file mode 100644 index b187016..0000000 --- a/geojson/Polygon.geojson +++ /dev/null @@ -1,43 +0,0 @@ -{ - "type": "Feature", - "properties": {}, - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [ - -79.92141723632812, - 32.953944317478246 - ], - [ - -79.97428894042969, - 32.83690450361482 - ], - [ - -79.97360229492188, - 32.76071688548088 - ], - [ - -79.93034362792969, - 32.76475877693074 - ], - [ - -79.93789672851562, - 32.74108223150125 - ], - [ - -79.80537414550781, - 32.7231762754146 - ], - [ - -79.81773376464844, - 32.923402043498875 - ], - [ - -79.92141723632812, - 32.953944317478246 - ] - ] - ] - } -} diff --git a/index.js b/index.js index 2529176..980030e 100644 --- a/index.js +++ b/index.js @@ -1,63 +1,35 @@ -// http://stackoverflow.com/questions/839899/how-do-i-calculate-a-point-on-a-circles-circumference -// radians = degrees * (pi/180) -// https://github.com/bjornharrtell/jsts/blob/master/examples/buffer.html +var featurecollection = require('turf-featurecollection'); +var destination = require('turf-destination'); +var polygon = require('turf-polygon'); -var featurecollection = require('turf-featurecollection') -var polygon = require('turf-polygon') -var combine = require('turf-combine') -var jsts = require('jsts') +module.exports = function(feature, radius, units, resolution){ + if(!resolution) resolution = 36; + var geom = feature.geometry + if(geom.type === 'Point') { + return pointBuffer(feature, radius, units, resolution); + } else if(geom.type === 'MultiPoint') { -module.exports = function(feature, radius, units, done){ - var buffered; + } else if(geom.type === 'LineString') { - done = done || function () {}; + } else if(geom.type === 'MultiLineString') { - switch(units){ - case 'miles': - radius = radius / 69.047 - break - case 'kilometers': - radius = radius / 111.12 - break - case 'degrees': - break - } - - if(feature.type === 'FeatureCollection'){ - var multi = combine(feature); - multi.properties = {} + } else if(geom.type === 'Polygon') { - buffered = bufferOp(multi, radius); + } else if(geom.type === 'MultiPolygon') { - done(null, buffered); - return buffered; - } - else{ - buffered = bufferOp(feature, radius); - - done(null, buffered); - return buffered; } } -var bufferOp = function(feature, radius){ - var reader = new jsts.io.GeoJSONReader() - var geom = reader.read(JSON.stringify(feature.geometry)) - var buffered = geom.buffer(radius); - var parser = new jsts.io.GeoJSONParser() - buffered = parser.write(buffered) - - if(buffered.type === 'MultiPolygon'){ - buffered = { - type: 'Feature', - geometry: buffered, - properties: {} - } - buffered = featurecollection([buffered]) +function pointBuffer (pt, radius, units, resolution) { + var ring = [] + var resMultiple = 360/resolution; + for(var i = 0; i < resolution; i++) { + var spoke = destination(pt, radius, i*resMultiple, units) + ring.push(spoke.geometry.coordinates) } - else{ - buffered = featurecollection([polygon(buffered.coordinates)]) + if((ring[0][0] !== ring[ring.length-1][0]) && (ring[0][1] != ring[ring.length-1][1])) { + ring.push([ring[0][0], ring[0][1]]); } - - return buffered; + + return polygon([ring]) } \ No newline at end of file diff --git a/package.json b/package.json index 914cc21..5562b32 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,7 @@ "tape": "^2.13.3" }, "dependencies": { - "jsts": "^0.13.4", - "turf-combine": "0.1.0", + "turf-destination": "0.0.5", "turf-featurecollection": "^0.1.0", "turf-polygon": "^0.1.1" } diff --git a/test.js b/test.js index 852b42b..e0db808 100644 --- a/test.js +++ b/test.js @@ -1,22 +1,23 @@ -var test = require('tape') -var buffer = require('./') -var fs = require('fs') +var test = require('tape'); +var buffer = require('./'); +var fs = require('fs'); +var fc = require('turf-featurecollection') test('buffer', function(t){ - var pt = JSON.parse(fs.readFileSync(__dirname+'/geojson/Point.geojson')) - var line = JSON.parse(fs.readFileSync(__dirname+'/geojson/LineString.geojson')) - var polygon = JSON.parse(fs.readFileSync(__dirname+'/geojson/Polygon.geojson')) - var fc = JSON.parse(fs.readFileSync(__dirname+'/geojson/FeatureCollection.geojson')) + var pt = JSON.parse(fs.readFileSync(__dirname+'/fixtures/Point.geojson')); + var line = JSON.parse(fs.readFileSync(__dirname+'/fixtures/LineString.geojson')); + var polygon = JSON.parse(fs.readFileSync(__dirname+'/fixtures/Polygon.geojson')); - var buffPt = buffer(pt, 10, 'miles') - var buffLine = buffer(pt, 10, 'miles') - var buffPoly = buffer(pt, 10, 'miles') - var buffFC = buffer(fc, 10, 'miles') + var buffPt = buffer(pt, 10, 'miles', 1000); + console.log(JSON.stringify(buffPt)) + //var buffLine = buffer(pt, 10, 'miles'); + //var buffPoly = buffer(pt, 10, 'miles'); + //var buffFC = buffer(fc, 10, 'miles'); - t.ok(buffPt, 'should buffer a point') - t.ok(buffLine, 'should buffer a line') - t.ok(buffPoly, 'should buffer a polygon') - t.ok(buffFC, 'should buffer featurecollection') + t.ok(buffPt, 'should buffer a point'); + //t.ok(buffLine, 'should buffer a line'); + //t.ok(buffPoly, 'should buffer a polygon'); + //t.ok(buffFC, 'should buffer featurecollection'); - t.end() -}) \ No newline at end of file + t.end(); +}); \ No newline at end of file From 33b4c02c8d81de60fca50ef0cc2fb4e47c802b1e Mon Sep 17 00:00:00 2001 From: morganherlocker Date: Fri, 5 Dec 2014 14:21:09 -0500 Subject: [PATCH 02/42] add fixtures --- fixtures/FeatureCollection.geojson | 141 +++++++++++++++++++++++++++++ fixtures/LineString.geojson | 1 + fixtures/Point.geojson | 8 ++ fixtures/Polygon.geojson | 43 +++++++++ 4 files changed, 193 insertions(+) create mode 100644 fixtures/FeatureCollection.geojson create mode 100644 fixtures/LineString.geojson create mode 100644 fixtures/Point.geojson create mode 100644 fixtures/Polygon.geojson diff --git a/fixtures/FeatureCollection.geojson b/fixtures/FeatureCollection.geojson new file mode 100644 index 0000000..966478d --- /dev/null +++ b/fixtures/FeatureCollection.geojson @@ -0,0 +1,141 @@ + { + "type": "FeatureCollection", + "features": [ + { "type": "Feature", + "geometry": {"type": "Point", "coordinates": [-75.833, 39.284]}, + "properties": { + "name": "Location B", + "category": "House", + "elevation": 25 + } + }, + { "type": "Feature", + "geometry": {"type": "Point", "coordinates": [-75.6, 39.984]}, + "properties": { + "name": "Location A", + "category": "Store", + "elevation": 23 + } + }, + { "type": "Feature", + "geometry": {"type": "Point", "coordinates": [ -75.221, 39.125]}, + "properties": { + "name": "Location C", + "category": "Office", + "elevation": 29 + } + }, + { "type": "Feature", + "geometry": {"type": "Point", "coordinates": [-75.358, 39.987]}, + "properties": { + "name": "Location A", + "category": "Store", + "elevation": 12 + } + }, + { "type": "Feature", + "geometry": {"type": "Point", "coordinates": [-75.9221, 39.27]}, + "properties": { + "name": "Location B", + "category": "House", + "elevation": 11 + } + }, + { "type": "Feature", + "geometry": {"type": "Point", "coordinates": [ -75.534, 39.123]}, + "properties": { + "name": "Location C", + "category": "Office", + "elevation": 49 + } + }, + { "type": "Feature", + "geometry": {"type": "Point", "coordinates": [-75.21, 39.12]}, + "properties": { + "name": "Location A", + "category": "Store", + "elevation": 50 + } + }, + { "type": "Feature", + "geometry": {"type": "Point", "coordinates": [-75.22, 39.33]}, + "properties": { + "name": "Location B", + "category": "House", + "elevation": 90 + } + }, + { "type": "Feature", + "geometry": {"type": "Point", "coordinates": [ -75.44, 39.55]}, + "properties": { + "name": "Location C", + "category": "Office", + "elevation": 22 + } + }, + { "type": "Feature", + "geometry": {"type": "Point", "coordinates": [-75.77, 39.66]}, + "properties": { + "name": "Location A", + "category": "Store", + "elevation": 99 + } + }, + { "type": "Feature", + "geometry": {"type": "Point", "coordinates": [-75.44, 39.11]}, + "properties": { + "name": "Location B", + "category": "House", + "elevation": 55 + } + }, + { "type": "Feature", + "geometry": {"type": "Point", "coordinates": [ -75.05, 39.92]}, + "properties": { + "name": "Location C", + "category": "Office", + "elevation": 41 + } + }, + { "type": "Feature", + "geometry": {"type": "Point", "coordinates": [-75.88, 39.98]}, + "properties": { + "name": "Location A", + "category": "Store", + "elevation": 52 + } + }, + { "type": "Feature", + "geometry": {"type": "Point", "coordinates": [-75.55, 39.55]}, + "properties": { + "name": "Location B", + "category": "House", + "elevation": 143 + } + }, + { "type": "Feature", + "geometry": {"type": "Point", "coordinates": [ -75.33, 39.44]}, + "properties": { + "name": "Location C", + "category": "Office", + "elevation": 76 + } + }, + { "type": "Feature", + "geometry": {"type": "Point", "coordinates": [ -75.56, 39.24]}, + "properties": { + "name": "Location C", + "category": "Office", + "elevation": 18 + } + }, + { "type": "Feature", + "geometry": {"type": "Point", "coordinates": [ -75.56, 39.36]}, + "properties": { + "name": "Location C", + "category": "Office", + "elevation": 52 + } + } + ] + } \ No newline at end of file diff --git a/fixtures/LineString.geojson b/fixtures/LineString.geojson new file mode 100644 index 0000000..152c448 --- /dev/null +++ b/fixtures/LineString.geojson @@ -0,0 +1 @@ +{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-80.08724212646484,32.77428536643231],[-80.08718319576123,32.774407687035286],[-80.08700937968847,32.774766344815355],[-80.08672514230369,32.77534888372924],[-80.08633494766407,32.77614284773365],[-80.08584325982665,32.7771357807853],[-80.08525454284863,32.77831522684092],[-80.0845732607871,32.77966872985719],[-80.08380387769924,32.78118383379086],[-80.08295085764209,32.782848082598626],[-80.06932431738281,32.80743595279523],[-80.06781585015088,32.809918368715984],[-80.06628177869239,32.81238800094813],[-80.06472656706445,32.81483239344839],[-80.06315467932423,32.81723909017347],[-80.06157057952882,32.81959563508009],[-80.05997873173536,32.82188957212499],[-80.05838360000097,32.82410844526483],[-80.05678964838282,32.82623979845637],[-80.05520134093798,32.82827117565631],[-80.03937919482422,32.840455481030595],[-80.03820681391552,32.84031557495512],[-80.03709940542186,32.839912668840455],[-80.03607559555957,32.839228128951426],[-80.03513665748144,32.83827031609085],[-80.0342780125122,32.83705398890388],[-80.03349508197655,32.83559390603568],[-80.03278328719922,32.833904826131416],[-80.03213804950488,32.83200150783622],[-80.03155479021825,32.829898709795266],[-80.02792001184082,32.797823240639616],[-80.02772335677393,32.794477859971806],[-80.02752915733595,32.79112486194529],[-80.02733283485155,32.7877790052052],[-80.02712981064552,32.78445504839672],[-80.02691550604247,32.781167750165],[-80.02668534236719,32.77793186915518],[-80.02643474094434,32.77476216401244],[-80.02615912309864,32.771673393381924],[-80.02585391015478,32.768680315908796],[-80.01923379016112,32.74629318460675],[-80.0182162993667,32.7455995993445],[-80.01710969069532,32.745193569626686],[-80.01590938547167,32.74508985409846],[-80.01462611447754,32.74530625723315],[-80.0133079284668,32.7458529732646],[-80.01196016835938,32.7467148599869],[-80.0105844626587,32.747875435203014],[-80.00918243986817,32.74931821671588],[-80.00775572849122,32.75102672232845],[-79.99089820861818,32.78264416628983],[-79.9893022574707,32.786255749728674],[-79.98770278828124,32.789918788705535],[-79.98610142955323,32.793616801023354],[-79.98449980979004,32.79733330448507],[-79.98289955749513,32.801051816893654],[-79.98130230117187,32.804755856052026],[-79.97970966932374,32.808428939763154],[-79.9781232904541,32.81205458582997],[-79.97654479306641,32.81561631205542],[-79.96016725158691,32.84586268264848],[-79.95881035524904,32.84737175940747],[-79.95748251093748,32.84860264776342],[-79.95618534715575,32.849538865519264],[-79.95492049240723,32.850163930477954],[-79.95368957519531,32.850461360442424],[-79.95251206269141,32.85043662672373],[-79.95140467835009,32.850115427468296],[-79.9503649350996,32.84951162073215],[-79.94939034586817,32.84863906457134],[-79.94225872705078,32.8252668887998],[-79.94187199444922,32.822250267913596],[-79.94151808393359,32.81914505233115],[-79.94119450843213,32.815965100108514],[-79.94089878087306,32.812724269301725],[-79.94062841418457,32.8094364179668],[-79.94038092129493,32.8061154041598],[-79.94015381513232,32.80277508593673],[-79.93994460862501,32.79942932135364],[-79.93975081470117,32.79609196846656],[-79.93792500952149,32.76389966267125],[-79.93772217500099,32.76174417850698],[-79.93750242113087,32.75977726076716],[-79.93726326083936,32.75801276750783],[-79.93700220705468,32.75646455678503],[-79.9367167727051,32.755146486654795],[-79.93640447071876,32.754072415173134],[-79.93606645257714,32.7532530165506],[-79.93574776400976,32.75265405687018],[-79.93546119593701,32.752255715114025],[-79.93394115820313,32.758609055294215],[-79.93390701563526,32.75993476040094],[-79.93388282349024,32.76134718872719],[-79.93386687637793,32.76283757914186],[-79.9338574689082,32.76439717051379],[-79.93385289569092,32.766017201711854],[-79.93385145133594,32.767688911604935],[-79.93385143045312,32.769403539061884],[-79.93385112765235,32.771152322951565],[-79.93384883754345,32.77292650214285],[-79.93320474243163,32.791612879648774],[-79.93304558419482,32.79300843423089],[-79.93286226857812,32.79431548940991],[-79.9326530901914,32.79552528405464],[-79.93241634364453,32.79662905703398],[-79.93215032354738,32.797618047216794],[-79.93185332450977,32.79848349347194],[-79.93152364114161,32.79921663466829],[-79.93115956805272,32.7998087096747],[-79.93076445230713,32.80025548858628],[-79.92563361053467,32.79800331988575],[-79.92511511165772,32.79732586216012],[-79.92459094416503,32.79659927901422],[-79.92406180217284,32.79583041516321],[-79.92352837979736,32.7950261153223],[-79.9229913711548,32.794193224206666],[-79.92245147036132,32.79333858653149],[-79.9219093715332,32.79246904701197],[-79.92136576878663,32.791591450363285],[-79.9208213562378,32.79071264130061],[-79.91497788848876,32.782923310831485],[-79.91447789937743,32.78256384058549],[-79.91398612397462,32.78229213922294],[-79.91350325639647,32.78211505145899],[-79.91302999075928,32.78203942200884],[-79.9125670211792,32.78207209558768],[-79.91211504177247,32.78221991691069],[-79.91167474665528,32.782489730693044],[-79.91124682994385,32.78288838164996],[-79.9108319857544,32.78342271449659],[-79.91051217022705,32.79825185788735],[-79.91083374809764,32.80021842735615],[-79.91118676088965,32.80224954504018],[-79.91156481953027,32.804336287035326],[-79.91196153494678,32.80646972943742],[-79.9123705180664,32.80864094834233],[-79.9127853798164,32.81084101984593],[-79.91319973112402,32.813061020044074],[-79.91360718291651,32.81529202503262],[-79.9140013461211,32.81752511090743],[-79.91563281976319,32.83967415743999],[-79.91536917223829,32.84123614942711],[-79.91500917817969,32.842684211546704],[-79.91454644851464,32.8440094198946],[-79.91397459417041,32.84520285056667],[-79.91328722607422,32.84625557965878],[-79.9124779551533,32.84715868326679],[-79.91154039233496,32.84790323748656],[-79.91046814854639,32.84848031841395],[-79.90925483471483,32.84888100214482],[-79.88681002807616,32.84043101772218],[-79.88412558002344,32.83863843745276],[-79.88136658816114,32.836718132514406],[-79.87854052117969,32.83468042668278],[-79.87565484776954,32.832535643733465],[-79.8727170366211,32.830294107442114],[-79.8697345564248,32.82796614158433],[-79.8667148758711,32.82556206993572],[-79.86366546365039,32.823092216271924],[-79.86059378845312,32.820566904368555],[-79.82747205029295,32.79208082944673],[-79.82471577723045,32.789695273166785],[-79.82203433416699,32.78738846773032],[-79.81943518979296,32.785170736912946],[-79.81692581279883,32.78305240449029],[-79.81451367187499,32.78104379423797],[-79.8122062357119,32.77915522993161],[-79.81001097299999,32.77739703534683],[-79.80793535242968,32.775779534259236],[-79.80598684269138,32.774313050444455],[-79.79534838500975,32.769070906870525],[-79.79543174302734,32.76941324126892],[-79.79566084053221,32.76986395696048],[-79.7960265045117,32.77041767918655],[-79.79651956195312,32.7710690331885],[-79.79713083984373,32.771812644207664],[-79.7978511651709,32.77264313748538],[-79.79867136492186,32.773555138263006],[-79.79958226608397,32.774543271781894],[-79.80057469564451,32.77560216328338],[-79.81424881347655,32.79038281567679],[-79.81550408882812,32.791871571794594],[-79.81672164341308,32.79336121403251],[-79.81789230421874,32.794846367631884],[-79.81900689823242,32.79632165783408],[-79.8200562524414,32.797781709880425],[-79.82103119383301,32.79922114901228],[-79.82192254939454,32.800634600470985],[-79.82272114611327,32.8020166894979],[-79.82341781097657,32.803362041334346],[-79.82317655694578,32.81511763936037],[-79.82264117182325,32.81603438083504],[-79.82205102188087,32.81693771442673],[-79.82140863476954,32.81782681524612],[-79.82071653814013,32.81870085840387],[-79.81997725964357,32.81955901901067],[-79.81919332693067,32.82040047217716],[-79.81836726765233,32.821224393014035],[-79.81750160945947,32.82202995663195],[-79.81659888000293,32.82281633814159],[-79.80494506072998,32.82996459725244],[-79.80379463287794,32.83045645209492],[-79.80263999322362,32.83091840126783],[-79.80148366941798,32.831349619881834],[-79.80032818911182,32.8317492830476],[-79.79917607995607,32.83211656587579],[-79.79802986960156,32.8324506434771],[-79.79689208569923,32.83275069096218],[-79.7957652558999,32.833015883441696],[-79.7946519078545,32.833245396026335],[-79.78379761834717,32.83333571959247],[-79.7828884123711,32.833179884680774],[-79.78198295070703,32.83300497173636],[-79.78108284014503,32.832809895070106],[-79.78018968747509,32.83259356899291],[-79.77930509948729,32.832354907815684],[-79.77843068297167,32.832092825849315],[-79.77756804471827,32.83180623740469],[-79.77671879151708,32.83149405679271],[-79.77588453015821,32.831155198324254],[-79.76815665875245,32.82535650956062],[-79.76762762912402,32.8246128330644],[-79.7671344796084,32.82382836475334],[-79.7666788169956,32.82300201893834],[-79.76626224807569,32.822132709930294],[-79.76588637963867,32.821219352040096],[-79.76555281847462,32.82026085957865],[-79.76526317137353,32.819256146856844],[-79.7650190451255,32.81820412818556],[-79.76482204652052,32.817103717875725],[-79.76629620263671,32.8014305177732],[-79.76689192710352,32.7995741723892],[-79.76759057844433,32.79762646866419],[-79.76838602601123,32.795594594234984],[-79.76927213915624,32.79348573673839],[-79.77024278723144,32.79130708381121],[-79.77129183958887,32.78906582309027],[-79.77241316558056,32.786769142212364],[-79.77360063455859,32.7844242288143],[-79.77484811587502,32.7820382705329],[-79.790777859375,32.75513943126411],[-79.7922672982119,32.752821570053676],[-79.79373705096387,32.750556103238424],[-79.79518098698291,32.748350218455144],[-79.79659297562108,32.746211103340656],[-79.79796688623048,32.74414594553178],[-79.79929658816309,32.742161932665304],[-79.80057595077098,32.740266252378035],[-79.80179884340623,32.73846609230681],[-79.80295913542089,32.736768640088414]]},"properties":{}} \ No newline at end of file diff --git a/fixtures/Point.geojson b/fixtures/Point.geojson new file mode 100644 index 0000000..8c290bf --- /dev/null +++ b/fixtures/Point.geojson @@ -0,0 +1,8 @@ +{ + "type": "Feature", + "geometry": {"type": "Point", "coordinates": [-75.4, 39.4]}, + "properties": { + "name": "Location A", + "category": "Store" + } +} \ No newline at end of file diff --git a/fixtures/Polygon.geojson b/fixtures/Polygon.geojson new file mode 100644 index 0000000..b187016 --- /dev/null +++ b/fixtures/Polygon.geojson @@ -0,0 +1,43 @@ +{ + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -79.92141723632812, + 32.953944317478246 + ], + [ + -79.97428894042969, + 32.83690450361482 + ], + [ + -79.97360229492188, + 32.76071688548088 + ], + [ + -79.93034362792969, + 32.76475877693074 + ], + [ + -79.93789672851562, + 32.74108223150125 + ], + [ + -79.80537414550781, + 32.7231762754146 + ], + [ + -79.81773376464844, + 32.923402043498875 + ], + [ + -79.92141723632812, + 32.953944317478246 + ] + ] + ] + } +} From dff0c3d38825871db5ba03c757a52a9c97ae1dc0 Mon Sep 17 00:00:00 2001 From: morganherlocker Date: Fri, 5 Dec 2014 15:36:14 -0500 Subject: [PATCH 03/42] multipoint buffers --- fixtures/MultiPoint.geojson | 21 +++++++++++++++++++++ fixtures/out/multipoint.geojson | 1 + fixtures/out/point.geojson | 1 + index.js | 7 ++++++- package.json | 1 + test.js | 7 ++++++- 6 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 fixtures/MultiPoint.geojson create mode 100644 fixtures/out/multipoint.geojson create mode 100644 fixtures/out/point.geojson diff --git a/fixtures/MultiPoint.geojson b/fixtures/MultiPoint.geojson new file mode 100644 index 0000000..f0b69d0 --- /dev/null +++ b/fixtures/MultiPoint.geojson @@ -0,0 +1,21 @@ +{ + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + -89.43283081054688, + 43.07089421067248 + ], + [ + -89.37103271484375, + 43.08456131144392 + ], + [ + -89.329833984375, + 43.107249487936684 + ] + ] + } +} \ No newline at end of file diff --git a/fixtures/out/multipoint.geojson b/fixtures/out/multipoint.geojson new file mode 100644 index 0000000..363754e --- /dev/null +++ b/fixtures/out/multipoint.geojson @@ -0,0 +1 @@ +{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-89.43283081054688,43.2155805225742],[-89.4203649828276,43.21529434166688],[-89.40794870129314,43.21443693640974],[-89.39563131102858,43.21301171457976],[-89.38346175580287,43.21102434043423],[-89.37148837961438,43.20848271172525],[-89.35975873086646,43.2053969276614],[-89.34831937002741,43.201779247957155],[-89.3372156816084,43.197644043149516],[-89.32649169127056,43.193007736398606],[-89.31618988884263,43.18788873702618],[-89.30635105799922,43.18230736608081],[-89.29701411331347,43.17628577425214],[-89.28821594535763,43.16984785248842],[-89.2799912744836,43.16301913570187],[-89.27237251386867,43.1558266999738],[-89.26538964236474,43.14829905369746],[-89.25907008763885,43.14046602312012],[-89.25343862004183,43.13235863276716],[-89.248517257588,43.12400898124947],[-89.24432518237657,43.11545011297191],[-89.24087866872948,43.106715886274706],[-89.23819102326787,43.0978408385505],[-89.2362725370932,43.08886004888918],[-89.23513045018676,43.07980899880858],[-89.23476892808769,43.070723431633446],[-89.23518905085801,43.06163921108629],[-89.2363888142921,43.052592179653224],[-89.23836314327995,43.0436180172847],[-89.24110391718533,43.03475210098568],[-89.24460000705486,43.026029365842554],[-89.24883732443108,43.01748416802467],[-89.25379888150057,43.00915015028674],[-89.25946486226952,43.00106011048549],[-89.26581270442281,42.99324587360888],[-89.27281719148706,42.98573816779936],[-89.28045055488727,42.97856650483523],[-89.28868258545575,42.97175906551366],[-89.297480753925,42.96534259035911],[-89.30681033991088,42.959342276057946],[-89.31663456886884,42.95378167799767],[-89.32691475648501,42.94868261926423],[-89.33761045994565,42.94406510642636],[-89.34867963551004,42.93994725240959],[-89.3600788017979,42.936345206736085],[-89.37176320818861,42.93327309337893],[-89.38368700771747,42.930742956451574],[-89.39580343384489,42.928764713924984],[-89.40806498046554,42.927346119535606],[-89.42042358451761,42.92649273301858],[-89.43283081054688,42.92620789877076],[-89.44523803657613,42.92649273301858],[-89.45759664062821,42.927346119535606],[-89.46985818724886,42.928764713924984],[-89.48197461337628,42.930742956451574],[-89.49389841290514,42.93327309337893],[-89.50558281929585,42.936345206736085],[-89.51698198558371,42.93994725240959],[-89.5280511611481,42.94406510642636],[-89.53874686460874,42.94868261926423],[-89.5490270522249,42.95378167799767],[-89.55885128118287,42.959342276057946],[-89.56818086716875,42.96534259035911],[-89.576979035638,42.97175906551366],[-89.58521106620648,42.97856650483523],[-89.59284442960667,42.98573816779936],[-89.59984891667094,42.99324587360888],[-89.60619675882421,43.00106011048549],[-89.61186273959318,43.00915015028674],[-89.61682429666267,43.01748416802467],[-89.62106161403888,43.026029365842554],[-89.62455770390841,43.03475210098568],[-89.62729847781378,43.0436180172847],[-89.62927280680165,43.052592179653224],[-89.63047257023574,43.06163921108629],[-89.63089269300605,43.070723431633446],[-89.63053117090699,43.07980899880858],[-89.62938908400055,43.08886004888918],[-89.62747059782588,43.0978408385505],[-89.62478295236427,43.106715886274706],[-89.62133643871718,43.11545011297191],[-89.61714436350573,43.12400898124947],[-89.61222300105192,43.13235863276716],[-89.60659153345489,43.14046602312012],[-89.60027197872901,43.14829905369746],[-89.59328910722506,43.1558266999738],[-89.58567034661013,43.16301913570187],[-89.57744567573612,43.16984785248842],[-89.56864750778028,43.17628577425214],[-89.55931056309453,43.18230736608081],[-89.54947173225112,43.18788873702618],[-89.53916992982317,43.193007736398606],[-89.52844593948535,43.197644043149516],[-89.51734225106634,43.201779247957155],[-89.50590289022729,43.2053969276614],[-89.49417324147937,43.20848271172525],[-89.48219986529087,43.21102434043423],[-89.47003031006516,43.21301171457976],[-89.4577129198006,43.21443693640974],[-89.44529663826613,43.21529434166688],[-89.43283081054688,43.2155805225742]]]},"properties":{}},{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-89.37103271484375,43.22924762334563],[-89.35856409230236,43.22896144211477],[-89.3461450272214,43.22810403589212],[-89.33382487591311,43.226678812469984],[-89.3216525932771,43.224691436130996],[-89.30967653429799,43.222149804662024],[-89.2979442581744,43.219064017315475],[-89.2865023359325,43.21544633385796],[-89.27539616235985,43.211311124886],[-89.2646697730689,43.2066748136258],[-89.25436566747311,43.201555809470634],[-89.24452463842573,43.19597443354489],[-89.23518560923462,43.189952836617095],[-89.22638547872764,43.18351490971629],[-89.21815897500002,43.176686187836005],[-89.2105385184297,43.16949374713814],[-89.20355409449866,43.16196609609449],[-89.19723313690842,43.154133061027665],[-89.19160042142623,43.146025666533944],[-89.18667797084545,43.137676011289486],[-89.1824849713903,43.12911713975788],[-89.17903770084044,43.12038291033055],[-89.17634946859654,43.11150786044303],[-89.17443056785383,43.102527069219086],[-89.1732882399969,43.09347601820099],[-89.1729266512759,43.08439045072796],[-89.17334688177257,43.07530623052693],[-89.17454692661335,43.0662592000783],[-89.17652170933926,43.0572850393167],[-89.17926310729301,43.0484191252215],[-89.18275998883982,43.03969639284415],[-89.18699826219424,43.03115119831019],[-89.19196093558475,43.02281718432244],[-89.19762818844784,43.014727148678446],[-89.2039774533075,43.006912916300585],[-89.21098350796103,42.99940521526047],[-89.21861857755987,42.992233557261294],[-89.22685244614459,42.98542612302216],[-89.23565257716567,42.97900965298758],[-89.24498424249556,42.97300934376353],[-89.25481065941544,42.96744875065776],[-89.26509313503823,42.96234969667845],[-89.2757912176107,42.957732188319746],[-89.28686285412017,42.95361433843693],[-89.2982645536169,42.950012296487365],[-89.30995155564861,42.94694018638575],[-89.32187800319296,42.94441005219454],[-89.3339971194637,42.94243181184184],[-89.34626138795697,42.941013219030005],[-89.35862273509811,42.94015983346949],[-89.37103271484375,42.93987499954219],[-89.38344269458939,42.94015983346949],[-89.39580404173051,42.941013219030005],[-89.40806831022377,42.94243181184184],[-89.42018742649454,42.94441005219454],[-89.43211387403889,42.94694018638575],[-89.44380087607058,42.950012296487365],[-89.45520257556731,42.95361433843693],[-89.4662742120768,42.957732188319746],[-89.47697229464924,42.96234969667845],[-89.48725477027206,42.96744875065776],[-89.49708118719194,42.97300934376353],[-89.50641285252182,42.97900965298758],[-89.5152129835429,42.98542612302216],[-89.52344685212763,42.992233557261294],[-89.53108192172645,42.99940521526047],[-89.53808797637998,43.006912916300585],[-89.54443724123966,43.014727148678446],[-89.55010449410275,43.02281718432244],[-89.55506716749325,43.03115119831019],[-89.55930544084768,43.03969639284415],[-89.56280232239446,43.0484191252215],[-89.56554372034824,43.0572850393167],[-89.56751850307415,43.0662592000783],[-89.56871854791493,43.07530623052693],[-89.56913877841157,43.08439045072796],[-89.5687771896906,43.09347601820099],[-89.56763486183367,43.102527069219086],[-89.56571596109096,43.11150786044303],[-89.56302772884703,43.12038291033055],[-89.5595804582972,43.12911713975788],[-89.55538745884205,43.137676011289486],[-89.55046500826126,43.146025666533944],[-89.54483229277908,43.154133061027665],[-89.53851133518883,43.16196609609449],[-89.53152691125779,43.16949374713814],[-89.52390645468748,43.176686187836005],[-89.51567995095985,43.18351490971629],[-89.50687982045288,43.189952836617095],[-89.49754079126177,43.19597443354489],[-89.48769976221439,43.201555809470634],[-89.4773956566186,43.2066748136258],[-89.46666926732763,43.211311124886],[-89.455563093755,43.21544633385796],[-89.4441211715131,43.219064017315475],[-89.43238889538948,43.222149804662024],[-89.42041283641039,43.224691436130996],[-89.40824055377439,43.226678812469984],[-89.3959204024661,43.22810403589212],[-89.38350133738514,43.22896144211477],[-89.37103271484375,43.22924762334563]]]},"properties":{}},{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-89.329833984375,43.251935799838414],[-89.31736071793199,43.25164961807011],[-89.30493702768513,43.2507922102437],[-89.29261228860199,43.24936698417697],[-89.28043547407688,43.247379604194485],[-89.26845495734949,43.24483796814104],[-89.25671831555572,43.24175217534179],[-89.24527213726526,43.2381344856499],[-89.23416183434082,43.23399926976083],[-89.22343145893005,43.2293629510105],[-89.21312352637264,43.224243938910966],[-89.20327884477304,43.21866255471258],[-89.19393635195287,43.21264094931491],[-89.1851329604575,43.20620301388116],[-89.17690341124862,43.19937428353995],[-89.16928013666875,43.19218183458703],[-89.16229313321652,43.18465417562469],[-89.15596984462024,43.17682113310068],[-89.15033505564705,43.168713731728964],[-89.14541079703115,43.16036407029419],[-89.14121626185104,43.151805193357475],[-89.13776773363148,43.14307095939531],[-89.13507852639151,43.13419590591443],[-89.13315893680534,43.125215112094956],[-89.1320162085893,43.11616405951963],[-89.13165450917484,43.107078491551825],[-89.13207491867621,43.09799427192578],[-89.13327543111006,43.088947243112344],[-89.13525096777586,43.07997308501994],[-89.13799340265803,43.07110717458541],[-89.14149159966614,43.06238444680214],[-89.14573146148494,43.053839257722935],[-89.15069598976609,43.045505249964414],[-89.15636535635286,43.0374152212258],[-89.162716985194,43.029600996320575],[-89.1697256445667,43.02209330320264],[-89.17736354919822,43.014921653450486],[-89.18560047184404,43.00811422765345],[-89.19440386385462,43.00169776612339],[-89.20373898423591,42.99569746533263],[-89.21356903668682,42.99013688045649],[-89.22385531407492,42.98503783437398],[-89.23455734979298,42.98042033345535],[-89.24563307542222,42.97630249043921],[-89.25703898411216,42.972700454675255],[-89.26873029907415,42.96962834998123],[-89.28066114657427,42.96709822033485],[-89.29278473280034,42.965119983593034],[-89.30505352397022,42.96370139340158],[-89.31741942904118,42.96284800942988],[-89.329833984375,42.962563176034955],[-89.34224853970882,42.96284800942988],[-89.35461444477978,42.96370139340158],[-89.36688323594966,42.965119983593034],[-89.37900682217574,42.96709822033485],[-89.39093766967585,42.96962834998123],[-89.40262898463786,42.972700454675255],[-89.41403489332777,42.97630249043921],[-89.42511061895702,42.98042033345535],[-89.43581265467509,42.98503783437398],[-89.44609893206318,42.99013688045649],[-89.4559289845141,42.99569746533263],[-89.46526410489538,43.00169776612339],[-89.47406749690595,43.00811422765345],[-89.4823044195518,43.014921653450486],[-89.4899423241833,43.02209330320264],[-89.496950983556,43.029600996320575],[-89.50330261239714,43.0374152212258],[-89.50897197898392,43.045505249964414],[-89.51393650726507,43.053839257722935],[-89.51817636908386,43.06238444680214],[-89.52167456609197,43.07110717458541],[-89.52441700097414,43.07997308501994],[-89.52639253763994,43.088947243112344],[-89.52759305007379,43.09799427192578],[-89.52801345957516,43.107078491551825],[-89.5276517601607,43.11616405951963],[-89.52650903194464,43.125215112094956],[-89.52458944235849,43.13419590591443],[-89.52190023511852,43.14307095939531],[-89.51845170689896,43.151805193357475],[-89.51425717171884,43.16036407029419],[-89.50933291310295,43.168713731728964],[-89.50369812412977,43.17682113310068],[-89.49737483553348,43.18465417562469],[-89.49038783208124,43.19218183458703],[-89.48276455750138,43.19937428353995],[-89.4745350082925,43.20620301388116],[-89.46573161679713,43.21264094931491],[-89.45638912397696,43.21866255471258],[-89.44654444237736,43.224243938910966],[-89.43623650981993,43.2293629510105],[-89.42550613440918,43.23399926976083],[-89.41439583148474,43.2381344856499],[-89.40294965319427,43.24175217534179],[-89.39121301140051,43.24483796814104],[-89.3792324946731,43.247379604194485],[-89.36705568014801,43.24936698417697],[-89.35473094106487,43.2507922102437],[-89.34230725081801,43.25164961807011],[-89.329833984375,43.251935799838414]]]},"properties":{}},{"type":"Feature","properties":{},"geometry":{"type":"MultiPoint","coordinates":[[-89.43283081054688,43.07089421067248],[-89.37103271484375,43.08456131144392],[-89.329833984375,43.107249487936684]]}}]} \ No newline at end of file diff --git a/fixtures/out/point.geojson b/fixtures/out/point.geojson new file mode 100644 index 0000000..3b7b4b2 --- /dev/null +++ b/fixtures/out/point.geojson @@ -0,0 +1 @@ +{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-75.4,39.54468631190172],[-75.3988210989337,39.54468344997537],[-75.39764224469958,39.544674864310025],[-75.39646348412799,39.54466055524676],[-75.39528486404541,39.54464052335399],[-75.39410643127269,39.54461476942751],[-75.39292823262308,39.54458329449042],[-75.39175031490035,39.54454609979307],[-75.3905727248969,39.54450318681303],[-75.38939550939187,39.54445455725506],[-75.38821871514929,39.54440021305096],[-75.38704238891606,39.54434015635958],[-75.38586657742019,39.5442743895667],[-75.38469132736886,39.5442029152849],[-75.38351668544652,39.54412573635347],[-75.38234269831302,39.544042855838356],[-75.3811694126017,39.54395427703197],[-75.37999687491752,39.543860003453034],[-75.37882513183517,39.54376003884652],[-75.37765422989723,39.54365438718346],[-75.37648421561217,39.543543052660745],[-75.3753151354526,39.54342603970101],[-75.37414703585328,39.54330335295245],[-75.37297996320939,39.5431749972886],[-75.37181396387447,39.543040977808154],[-75.37064908415864,39.54290129983478],[-75.3694853703268,39.54275596891687],[-75.36832286859658,39.54260499082733],[-75.36716162513666,39.54244837156335],[-75.36600168606476,39.542286117346165],[-75.36484309744587,39.54211823462079],[-75.3636859052903,39.54194473005577],[-75.36253015555192,39.541765610542896],[-75.36137589412625,39.54158088319695],[-75.36022316684858,39.54139055535539],[-75.35907201949216,39.541194634578105],[-75.35792249776634,39.540993128647],[-75.35677464731474,39.54078604556583],[-75.35562851371333,39.54057339355974],[-75.3544841424687,39.540355181075014],[-75.3533415790162,39.54013141677872],[-75.35220086871796,39.53990210955833],[-75.35106205686128,39.5396672685214],[-75.34992518865663,39.53942690299515],[-75.34879030923592,39.53918102252617],[-75.34765746365068,39.53892963687993],[-75.3465266968701,39.53867275604047],[-75.34539805377945,39.538410390209954],[-75.34427157917806,39.53814254980828],[-75.34314731777765,39.53786924547261],[-75.34202531420044,39.53759048805702],[-75.34090561297738,39.537306288632],[-75.3397882585464,39.53701665848402],[-75.33867329525056,39.536721609115084],[-75.33756076733623,39.536421152242255],[-75.33645071895141,39.53611529979719],[-75.3353431941439,39.53580406392563],[-75.3342382368595,39.535487456986985],[-75.33313589094027,39.53516549155372],[-75.33203620012274,39.534838180410965],[-75.3309392080362,39.5345055365559],[-75.32984495820088,39.53416757319728],[-75.32875349402624,39.53382430375491],[-75.32766485880923,39.53347574185907],[-75.32657909573246,39.53312190135001],[-75.32549624786259,39.532762796277304],[-75.32441635814853,39.53239844089941],[-75.32333946941971,39.53202884968296],[-75.32226562438436,39.53165403730228],[-75.32119486562783,39.53127401863874],[-75.32012723561084,39.53088880878018],[-75.31906277666775,39.5304984230203],[-75.31800153100491,39.530102876857995],[-75.31694354069899,39.52970218599681],[-75.31588884769519,39.529296366344234],[-75.31483749380564,39.52888543401111],[-75.3137895207077,39.52846940531095],[-75.31274496994229,39.52804829675929],[-75.31170388291216,39.527622125073016],[-75.31066630088037,39.52719090716971],[-75.3096322649685,39.526754660166944],[-75.30860181615502,39.52631340138159],[-75.30757499527378,39.52586714832914],[-75.30655184301217,39.52541591872299],[-75.30553239990967,39.524959730473725],[-75.30451670635608,39.52449860168839],[-75.30350480259003,39.524032550669766],[-75.3024967286973,39.523561595915616],[-75.3014925246092,39.523085756117986],[-75.30049223010101,39.5226050501624],[-75.29949588479043,39.52211949712709],[-75.29850352813584,39.521629116282334],[-75.29751519943495,39.521133927089515],[-75.296530937823,39.520633949200466],[-75.29555078227135,39.520129202456616],[-75.2945747715859,39.51961970688822],[-75.29360294440549,39.51910548271352],[-75.29263533920036,39.51858655033797],[-75.29167199427071,39.51806293035339],[-75.29071294774505,39.51753464353711],[-75.28975823757871,39.5170017108512],[-75.28880790155242,39.516464153441575],[-75.28786197727065,39.51592199263713],[-75.28692050216029,39.51537524994896],[-75.28598351346898,39.51482394706938],[-75.28505104826375,39.51426810587116],[-75.28412314342951,39.513707748406574],[-75.28319983566756,39.51314289690653],[-75.28228116149417,39.51257357377968],[-75.28136715723906,39.511999801611545],[-75.28045785904409,39.51142160316354],[-75.27955330286164,39.51083900137211],[-75.27865352445338,39.51025201934781],[-75.27775855938863,39.50966068037434],[-75.27686844304318,39.509065007907616],[-75.27598321059772,39.50846502557488],[-75.27510289703649,39.507860757173646],[-75.27422753714595,39.50725222667084],[-75.27335716551332,39.5066394582018],[-75.27249181652525,39.50602247606931],[-75.27163152436647,39.50540130474259],[-75.2707763230184,39.50477596885635],[-75.26992624625782,39.50414649320981],[-75.26908132765557,39.50351290276566],[-75.2682416005752,39.50287522264908],[-75.26740709817162,39.50223347814675],[-75.26657785338979,39.50158769470579],[-75.26575389896354,39.50093789793278],[-75.2649352674141,39.50028411359268],[-75.26412199104894,39.49962636760788],[-75.26331410196045,39.498964686057064],[-75.26251163202467,39.49829909517421],[-75.2617146129001,39.49762962134755],[-75.26092307602636,39.49695629111849],[-75.26013705262298,39.49627913118049],[-75.25935657368827,39.49559816837816],[-75.25858166999792,39.494913429705974],[-75.257812372104,39.49422494230733],[-75.25704871033355,39.49353273347339],[-75.25629071478757,39.49283683064203],[-75.2555384153397,39.492137261396714],[-75.25479184163517,39.49143405346539],[-75.25405102308954,39.49072723471939],[-75.2533159888876,39.490016833172284],[-75.25258676798224,39.489302876978776],[-75.25186338909326,39.48858539443361],[-75.25114588070629,39.487864413970364],[-75.25043427107168,39.487139964160356],[-75.24972858820337,39.486412073711485],[-75.24902885987782,39.485680771467116],[-75.24833511363293,39.484946086404854],[-75.24764737676695,39.48420804763544],[-75.24696567633742,39.48346668440157],[-75.24629003916012,39.482722026076715],[-75.24562049180801,39.48197410216396],[-75.24495706061025,39.48122294229479],[-75.24429977165113,39.48046857622797],[-75.24364865076906,39.47971103384826],[-75.24300372355556,39.47895034516531],[-75.24236501535434,39.47818654031241],[-75.24173255126021,39.477419649545254],[-75.24110635611821,39.47664970324083],[-75.24048645452253,39.47587673189611],[-75.2398728708157,39.47510076612687],[-75.23926562908755,39.47432183666644],[-75.23866475317433,39.47353997436451],[-75.23807026665773,39.472755210185895],[-75.23748219286408,39.47196757520924],[-75.23690055486334,39.47117710062587],[-75.23632537546823,39.470383817738465],[-75.23575667723345,39.46958775795983],[-75.23519448245474,39.46878895281165],[-75.23463881316798,39.46798743392325],[-75.23408969114844,39.4671832330303],[-75.23354713790987,39.466376381973525],[-75.23301117470372,39.46556691269752],[-75.23248182251835,39.46475485724937],[-75.23195910207816,39.46394024777745],[-75.23144303384285,39.463123116530085],[-75.23093363800663,39.462303495854336],[-75.23043093449745,39.46148141819461],[-75.22993494297621,39.46065691609143],[-75.2294456828361,39.45983002218017],[-75.22896317320176,39.45900076918964],[-75.22848743292865,39.45816918994091],[-75.2280184806022,39.457335317345894],[-75.22755633453734,39.456499184406105],[-75.22710101277754,39.455660824211314],[-75.22665253309431,39.45482026993823],[-75.22621091298649,39.453977554849196],[-75.22577616967955,39.45313271229084],[-75.22534832012502,39.45228577569275],[-75.22492738099974,39.45143677856616],[-75.22451336870537,39.4505857545026],[-75.22410629936766,39.44973273717255],[-75.22370618883592,39.44887776032414],[-75.22331305268243,39.448020857781735],[-75.22292690620179,39.44716206344469],[-75.22254776441046,39.446301411285866],[-75.22217564204611,39.44543893535042],[-75.22181055356711,39.44457466975435],[-75.22145251315203,39.44370864868317],[-75.22110153469902,39.44284090639058],[-75.2207576318254,39.441971477197036],[-75.2204208178672,39.44110039548845],[-75.22009110587842,39.44022769571478],[-75.21976850863089,39.43935341238869],[-75.2194530386136,39.43847758008419],[-75.2191447080322,39.43760023343517],[-75.2188435288088,39.43672140713415],[-75.21854951258128,39.43584113593082],[-75.218262670703,39.4349594546307],[-75.21798301424238,39.4340763980937],[-75.21771055398249,39.43319200123281],[-75.21744530042066,39.43230629901269],[-75.21718726376812,39.431419326448214],[-75.21693645394967,39.430531118603206],[-75.21669288060323,39.42964171058892],[-75.21645655307961,39.42875113756275],[-75.2162274804421,39.42785943472676],[-75.21600567146625,39.42696663732634],[-75.21579113463945,39.426072780648774],[-75.21558387816071,39.42517790002186],[-75.21538390994041,39.424282030812506],[-75.21519123759992,39.423385208425294],[-75.21500586847148,39.42248746830115],[-75.21482780959778,39.421588845915856],[-75.21465706773193,39.42068937677871],[-75.21449364933711,39.419789096431096],[-75.21433756058636,39.41888804044504],[-75.21418880736239,39.41798624442187],[-75.21404739525747,39.41708374399075],[-75.21391332957313,39.4161805748073],[-75.21378661532009,39.41527677255216],[-75.21366725721806,39.414372372929606],[-75.2135552596956,39.413467411666105],[-75.21345062689002,39.41256192450893],[-75.21335336264727,39.41165594722473],[-75.21326347052172,39.41074951559813],[-75.21318095377623,39.40984266543027],[-75.21310581538198,39.408935432537454],[-75.21303805801834,39.408027852749704],[-75.21297768407297,39.40711996190933],[-75.2129246956416,39.40621179586954],[-75.2128790945281,39.40530339049297],[-75.21284088224444,39.404394781650346],[-75.2128100600106,39.40348600521901],[-75.2127866287547,39.40257709708153],[-75.21277058911288,39.40166809312425],[-75.2127619414294,39.40075902923592],[-75.21276068575668,39.39984994130622],[-75.21276682185523,39.3989408652244],[-75.21278034919385,39.398031836877834],[-75.21280126694963,39.39712289215063],[-75.21282957400801,39.39621406692214],[-75.2128652689629,39.39530539706564],[-75.21290835011676,39.39439691844686],[-75.21295881548077,39.39348866692257],[-75.21301666277485,39.39258067833922],[-75.21308188942788,39.39167298853142],[-75.21315449257784,39.39076563332062],[-75.2132344690719,39.3898586485137],[-75.2133218154667,39.38895206990147],[-75.21341652802839,39.38804593325735],[-75.213518602733,39.387140274335955],[-75.21362803526648,39.38623512887158],[-75.21374482102499,39.38533053257695],[-75.21386895511512,39.38442652114169],[-75.21400043235414,39.383523130230984],[-75.21413924727021,39.382620395484146],[-75.21428539410269,39.38171835251322],[-75.21443886680238,39.38081703690158],[-75.21459965903178,39.379916484202546],[-75.21476776416546,39.37901672993796],[-75.21494317529026,39.378117809596766],[-75.21512588520574,39.37721975863372],[-75.21531588642435,39.37632261246786],[-75.2155131711719,39.3754264064812],[-75.21571773138788,39.374531176017314],[-75.21592955872573,39.37363695637993],[-75.21614864455336,39.372743782831584],[-75.21637497995341,39.371851690592194],[-75.2166085557237,39.37096071483771],[-75.21684936237764,39.370070890698685],[-75.2170973901446,39.36918225325895],[-75.21735262897043,39.36829483755421],[-75.21761506851776,39.367408678570634],[-75.21788469816659,39.366523811243574],[-75.21816150701464,39.36564027045609],[-75.2184454838779,39.364758091037636],[-75.2187366172911,39.3638773077627],[-75.21903489550812,39.36299795534941],[-75.21934030650256,39.362120068458175],[-75.21965283796833,39.36124368169036],[-75.21997247732,39.3603688295869],[-75.22029921169347,39.35949554662693],[-75.2206330279465,39.35862386722648],[-75.2209739126592,39.35775382573708],[-75.22132185213464,39.35688545644443],[-75.22167683239944,39.356018793567074],[-75.2220388392044,39.355153871255055],[-75.22240785802494,39.35429072358853],[-75.22278387406192,39.3534293845765],[-75.22316687224209,39.352569888155436],[-75.22355683721881,39.351712268187974],[-75.22395375337265,39.35085655846157],[-75.22435760481213,39.35000279268719],[-75.2247683753742,39.34915100449799],[-75.22518604862509,39.348301227447976],[-75.22561060786097,39.34745349501073],[-75.22604203610854,39.34660784057809],[-75.22648031612577,39.34576429745881],[-75.22692543040272,39.34492289887729],[-75.2273773611621,39.34408367797228],[-75.22783609036014,39.34324666779556],[-75.22830159968726,39.34241190131066],[-75.22877387056882,39.34157941139158],[-75.22925288416596,39.3407492308215],[-75.22973862137626,39.33992139229148],[-75.23023106283463,39.33909592839921],[-75.23073018891405,39.33827287164772],[-75.23123597972635,39.33745225444411],[-75.23174841512309,39.33663410909831],[-75.23226747469634,39.335818467821774],[-75.23279313777955,39.33500536272625],[-75.23332538344829,39.33419482582254],[-75.23386419052126,39.3333868890192],[-75.23440953756104,39.33258158412135],[-75.23496140287497,39.33177894282941],[-75.23551976451611,39.33097899673784],[-75.23608460028402,39.33018177733396],[-75.23665588772575,39.32938731599668],[-75.23723360413669,39.32859564399527],[-75.23781772656159,39.327806792488175],[-75.2384082317953,39.32702079252178],[-75.23900509638393,39.32623767502921],[-75.23960829662566,39.32545747082911],[-75.24021780857169,39.32468021062443],[-75.24083360802729,39.32390592500129],[-75.24145567055274,39.32313464442771],[-75.24208397146427,39.32236639925247],[-75.24271848583511,39.321601219703936],[-75.24335918849648,39.32083913588884],[-75.24400605403858,39.32008017779115],[-75.24465905681167,39.319324375270845],[-75.24531817092698,39.318571758062845],[-75.24598337025789,39.317822355775775],[-75.24665462844091,39.31707619789081],[-75.2473319188767,39.316333313760616],[-75.2480152147312,39.31559373260807],[-75.24870448893668,39.314857483525266],[-75.24939971419285,39.31412459547227],[-75.25010086296784,39.31339509727607],[-75.25080790749949,39.31266901762939],[-75.2515208197963,39.31194638508965],[-75.25223957163857,39.31122722807777],[-75.25296413457959,39.31051157487714],[-75.25369447994676,39.30979945363247],[-75.25443057884267,39.30909089234874],[-75.2551724021463,39.30838591889005],[-75.2559199205142,39.3076845609786],[-75.25667310438159,39.30698684619356],[-75.2574319239636,39.306292801970066],[-75.25819634925641,39.305602455598056],[-75.25896635003846,39.30491583422132],[-75.25974189587167,39.304232964836345],[-75.26052295610259,39.30355387429137],[-75.26130949986369,39.30287858928522],[-75.2621014960745,39.30220713636638],[-75.26289891344291,39.30153954193192],[-75.2637017204664,39.30087583222645],[-75.26450988543324,39.30021603334114],[-75.26532337642382,39.299560171212676],[-75.26614216131179,39.29890827162227],[-75.26696620776549,39.298260360194654],[-75.26779548324913,39.2976164623971],[-75.26862995502401,39.29697660353842],[-75.26946959015001,39.29634080876797],[-75.27031435548669,39.29570910307471],[-75.27116421769469,39.29508151128618],[-75.27201914323707,39.29445805806761],[-75.27287909838056,39.29383876792091],[-75.27374404919694,39.29322366518373],[-75.27461396156433,39.29261277402853],[-75.27548880116859,39.29200611846162],[-75.27636853350465,39.29140372232227],[-75.27725312387784,39.29080560928173],[-75.27814253740526,39.290211802842386],[-75.27903673901716,39.289622326336776],[-75.27993569345838,39.28903720292671],[-75.28083936528962,39.288456455602386],[-75.28174771888887,39.28788010718152],[-75.28266071845287,39.28730818030842],[-75.28357832799846,39.28674069745311],[-75.28450051136396,39.2861776809105],[-75.28542723221068,39.28561915279947],[-75.28635845402422,39.285065135062055],[-75.28729414011605,39.2845156494626],[-75.28823425362482,39.283970717586875],[-75.28917875751783,39.28343036084127],[-75.29012761459256,39.28289460045198],[-75.291080787478,39.28236345746413],[-75.2920382386362,39.28183695274103],[-75.29299993036372,39.2813151069633],[-75.29396582479309,39.28079794062814],[-75.29493588389425,39.28028547404847],[-75.2959100694762,39.27977772735219],[-75.2968883431882,39.27927472048139],[-75.29787066652158,39.27877647319155],[-75.29885700081104,39.27828300505084],[-75.2998473072362,39.27779433543929],[-75.3008415468232,39.2773104835481],[-75.30183968044605,39.27683146837886],[-75.30284166882835,39.276357308742824],[-75.30384747254467,39.275888023260215],[-75.30485705202219,39.275423630359455],[-75.30587036754211,39.274964148276474],[-75.3068873792414,39.27450959505401],[-75.30790804711408,39.27405998854094],[-75.30893233101308,39.27361534639151],[-75.30996019065154,39.27317568606475],[-75.31099158560453,39.2727410248237],[-75.31202647531057,39.272311379734866],[-75.31306481907322,39.27188676766742],[-75.31410657606264,39.27146720529265],[-75.31515170531722,39.271052709083314],[-75.31620016574512,39.270643295312915],[-75.31725191612585,39.270238980055176],[-75.31830691511202,39.26983977918337],[-75.31936512123072,39.2694457083697],[-75.32042649288529,39.269056783084714],[-75.32149098835691,39.268673018596694],[-75.32255856580618,39.26829442997109],[-75.3236291832747,39.26792103206992],[-75.32470279868686,39.26755283955119],[-75.32577936985129,39.26718986686834],[-75.3268588544626,39.26683212826966],[-75.32794121010296,39.26647963779782],[-75.32902639424383,39.26613240928921],[-75.3301143642475,39.265790456373516],[-75.33120507736885,39.26545379247311],[-75.33229849075686,39.2651224308026],[-75.33339456145644,39.264796384368246],[-75.33449324640998,39.26447566596755],[-75.33559450245903,39.26416028818868],[-75.33669828634604,39.26385026341002],[-75.33780455471587,39.26354560379973],[-75.33891326411772,39.263246321315165],[-75.34002437100655,39.262952427702544],[-75.34113783174494,39.26266393449641],[-75.34225360260471,39.26238085301922],[-75.34337163976862,39.26210319438094],[-75.34449189933201,39.2618309694785],[-75.34561433730464,39.261564188995536],[-75.34673890961223,39.26130286340184],[-75.34786557209823,39.261047002953035],[-75.34899428052559,39.26079661769013],[-75.35012499057831,39.26055171743922],[-75.35125765786336,39.26031231181097],[-75.35239223791216,39.26007841020038],[-75.35352868618251,39.25985002178632],[-75.35466695806018,39.25962715553127],[-75.35580700886067,39.25940982018086],[-75.35694879383092,39.259198024263675],[-75.35809226815108,39.25899177609078],[-75.3592373869362,39.258791083755504],[-75.36038410523794,39.25859595513308],[-75.36153237804638,39.25840639788038],[-75.36268216029171,39.25822241943554],[-75.36383340684591,39.2580440270178],[-75.36498607252462,39.257871227627106],[-75.36614011208877,39.25770402804388],[-75.36729548024638,39.25754243482881],[-75.3684521316543,39.25738645432251],[-75.36961002091994,39.25723609264536],[-75.37076910260302,39.25709135569719],[-75.37192933121736,39.25695224915712],[-75.37309066123258,39.25681877848331],[-75.3742530470759,39.25669094891275],[-75.37541644313386,39.25656876546106],[-75.37658080375407,39.2564522329223],[-75.37774608324708,39.25634135586879],[-75.37891223588792,39.256236138650934],[-75.38007921591814,39.25613658539701],[-75.38124697754729,39.2560427000131],[-75.38241547495494,39.25595448618285],[-75.38358466229221,39.255871947367375],[-75.38475449368376,39.25579508680513],[-75.38592492322937,39.25572390751174],[-75.38709590500585,39.25565841227994],[-75.3882673930687,39.255598603679445],[-75.38943934145392,39.255544484056834],[-75.39061170417982,39.255496055535495],[-75.39178443524872,39.25545332001549],[-75.3929574886488,39.255416279173545],[-75.39413081835582,39.25538493446293],[-75.39530437833483,39.25535928711344],[-75.39647812254209,39.25533933813136],[-75.39765200492675,39.25532508829935],[-75.39882597943263,39.2553165381765],[-75.4,39.255313688098276],[-75.40117402056738,39.2553165381765],[-75.40234799507326,39.25532508829935],[-75.40352187745792,39.25533933813136],[-75.40469562166518,39.25535928711344],[-75.40586918164419,39.25538493446293],[-75.4070425113512,39.255416279173545],[-75.40821556475129,39.25545332001549],[-75.40938829582018,39.255496055535495],[-75.41056065854609,39.255544484056834],[-75.41173260693131,39.255598603679445],[-75.41290409499416,39.25565841227994],[-75.41407507677063,39.25572390751174],[-75.41524550631625,39.25579508680513],[-75.4164153377078,39.255871947367375],[-75.41758452504507,39.25595448618285],[-75.41875302245272,39.2560427000131],[-75.41992078408187,39.25613658539701],[-75.42108776411207,39.256236138650934],[-75.42225391675294,39.25634135586879],[-75.42341919624593,39.2564522329223],[-75.42458355686615,39.25656876546106],[-75.42574695292411,39.25669094891275],[-75.42690933876743,39.25681877848331],[-75.42807066878265,39.25695224915712],[-75.42923089739699,39.25709135569719],[-75.43038997908008,39.25723609264536],[-75.43154786834572,39.25738645432251],[-75.43270451975363,39.25754243482881],[-75.43385988791124,39.25770402804388],[-75.4350139274754,39.257871227627106],[-75.4361665931541,39.2580440270178],[-75.4373178397083,39.25822241943554],[-75.43846762195362,39.25840639788038],[-75.43961589476207,39.25859595513308],[-75.44076261306381,39.258791083755504],[-75.44190773184893,39.25899177609078],[-75.44305120616909,39.259198024263675],[-75.44419299113935,39.25940982018086],[-75.44533304193983,39.25962715553127],[-75.4464713138175,39.25985002178632],[-75.44760776208786,39.26007841020038],[-75.44874234213665,39.26031231181097],[-75.4498750094217,39.26055171743922],[-75.45100571947442,39.26079661769013],[-75.45213442790178,39.261047002953035],[-75.45326109038778,39.26130286340184],[-75.45438566269537,39.261564188995536],[-75.455508100668,39.2618309694785],[-75.45662836023139,39.26210319438094],[-75.4577463973953,39.26238085301922],[-75.45886216825507,39.26266393449641],[-75.45997562899345,39.262952427702544],[-75.46108673588229,39.263246321315165],[-75.46219544528414,39.26354560379973],[-75.46330171365398,39.26385026341002],[-75.46440549754098,39.26416028818868],[-75.46550675359003,39.26447566596755],[-75.46660543854357,39.264796384368246],[-75.46770150924316,39.2651224308026],[-75.46879492263116,39.26545379247311],[-75.4698856357525,39.265790456373516],[-75.47097360575619,39.26613240928921],[-75.47205878989705,39.26647963779782],[-75.47314114553741,39.26683212826966],[-75.47422063014871,39.26718986686834],[-75.47529720131315,39.26755283955119],[-75.4763708167253,39.26792103206992],[-75.47744143419384,39.26829442997109],[-75.4785090116431,39.268673018596694],[-75.47957350711472,39.269056783084714],[-75.4806348787693,39.2694457083697],[-75.48169308488798,39.26983977918337],[-75.48274808387416,39.270238980055176],[-75.4837998342549,39.270643295312915],[-75.48484829468279,39.271052709083314],[-75.48589342393737,39.27146720529265],[-75.48693518092679,39.27188676766742],[-75.48797352468944,39.272311379734866],[-75.48900841439549,39.2727410248237],[-75.49003980934847,39.27317568606475],[-75.49106766898693,39.27361534639151],[-75.49209195288591,39.27405998854094],[-75.49311262075861,39.27450959505401],[-75.4941296324579,39.274964148276474],[-75.49514294797783,39.275423630359455],[-75.49615252745532,39.275888023260215],[-75.49715833117166,39.276357308742824],[-75.49816031955396,39.27683146837886],[-75.49915845317682,39.2773104835481],[-75.5001526927638,39.27779433543929],[-75.50114299918897,39.27828300505084],[-75.50212933347844,39.27877647319155],[-75.50311165681181,39.27927472048139],[-75.50408993052382,39.27977772735219],[-75.50506411610576,39.28028547404847],[-75.50603417520692,39.28079794062814],[-75.50700006963629,39.2813151069633],[-75.50796176136382,39.28183695274103],[-75.50891921252202,39.28236345746413],[-75.50987238540745,39.28289460045198],[-75.51082124248217,39.28343036084127],[-75.51176574637519,39.283970717586875],[-75.51270585988397,39.2845156494626],[-75.51364154597579,39.285065135062055],[-75.51457276778933,39.28561915279947],[-75.51549948863605,39.2861776809105],[-75.51642167200156,39.28674069745311],[-75.51733928154714,39.28730818030842],[-75.51825228111115,39.28788010718152],[-75.51916063471039,39.288456455602386],[-75.52006430654163,39.28903720292671],[-75.52096326098285,39.289622326336776],[-75.52185746259475,39.290211802842386],[-75.52274687612217,39.29080560928173],[-75.52363146649536,39.29140372232227],[-75.52451119883142,39.29200611846162],[-75.52538603843568,39.29261277402853],[-75.52625595080308,39.29322366518373],[-75.52712090161945,39.29383876792091],[-75.52798085676294,39.29445805806761],[-75.52883578230532,39.29508151128618],[-75.52968564451332,39.29570910307471],[-75.53053040985,39.29634080876797],[-75.53137004497599,39.29697660353842],[-75.53220451675088,39.2976164623971],[-75.53303379223452,39.298260360194654],[-75.53385783868822,39.29890827162227],[-75.53467662357619,39.299560171212676],[-75.53549011456677,39.30021603334114],[-75.53629827953361,39.30087583222645],[-75.5371010865571,39.30153954193192],[-75.53789850392552,39.30220713636638],[-75.53869050013633,39.30287858928522],[-75.53947704389742,39.30355387429137],[-75.54025810412834,39.304232964836345],[-75.54103364996155,39.30491583422132],[-75.5418036507436,39.305602455598056],[-75.5425680760364,39.306292801970066],[-75.54332689561842,39.30698684619356],[-75.54408007948581,39.3076845609786],[-75.54482759785371,39.30838591889005],[-75.54556942115734,39.30909089234874],[-75.54630552005325,39.30979945363247],[-75.54703586542041,39.31051157487714],[-75.54776042836144,39.31122722807777],[-75.54847918020371,39.31194638508965],[-75.54919209250052,39.31266901762939],[-75.54989913703217,39.31339509727607],[-75.55060028580716,39.31412459547227],[-75.55129551106332,39.314857483525266],[-75.55198478526881,39.31559373260807],[-75.55266808112331,39.316333313760616],[-75.5533453715591,39.31707619789081],[-75.55401662974212,39.317822355775775],[-75.55468182907303,39.318571758062845],[-75.55534094318834,39.319324375270845],[-75.55599394596142,39.32008017779115],[-75.55664081150353,39.32083913588884],[-75.5572815141649,39.321601219703936],[-75.55791602853574,39.32236639925247],[-75.55854432944727,39.32313464442771],[-75.55916639197272,39.32390592500129],[-75.55978219142833,39.32468021062443],[-75.56039170337435,39.32545747082911],[-75.56099490361608,39.32623767502921],[-75.5615917682047,39.32702079252178],[-75.56218227343842,39.327806792488175],[-75.56276639586332,39.32859564399527],[-75.56334411227427,39.32938731599668],[-75.563915399716,39.33018177733396],[-75.5644802354839,39.33097899673784],[-75.56503859712504,39.33177894282941],[-75.56559046243898,39.33258158412135],[-75.56613580947875,39.3333868890192],[-75.56667461655172,39.33419482582254],[-75.56720686222046,39.33500536272625],[-75.56773252530367,39.335818467821774],[-75.56825158487692,39.33663410909831],[-75.56876402027366,39.33745225444411],[-75.56926981108596,39.33827287164772],[-75.56976893716538,39.33909592839921],[-75.57026137862374,39.33992139229148],[-75.57074711583405,39.3407492308215],[-75.5712261294312,39.34157941139158],[-75.57169840031275,39.34241190131066],[-75.57216390963987,39.34324666779556],[-75.57262263883791,39.34408367797228],[-75.5730745695973,39.34492289887729],[-75.57351968387422,39.34576429745881],[-75.57395796389147,39.34660784057809],[-75.57438939213904,39.34745349501073],[-75.57481395137492,39.348301227447976],[-75.57523162462581,39.34915100449799],[-75.57564239518788,39.35000279268719],[-75.57604624662736,39.35085655846157],[-75.5764431627812,39.351712268187974],[-75.57683312775792,39.352569888155436],[-75.5772161259381,39.3534293845765],[-75.57759214197507,39.35429072358853],[-75.57796116079561,39.355153871255055],[-75.57832316760056,39.356018793567074],[-75.57867814786538,39.35688545644443],[-75.57902608734081,39.35775382573708],[-75.5793669720535,39.35862386722648],[-75.57970078830654,39.35949554662693],[-75.58002752268001,39.3603688295869],[-75.58034716203169,39.36124368169036],[-75.58065969349745,39.362120068458175],[-75.5809651044919,39.36299795534941],[-75.58126338270891,39.3638773077627],[-75.5815545161221,39.364758091037636],[-75.58183849298537,39.36564027045609],[-75.58211530183343,39.366523811243574],[-75.58238493148225,39.367408678570634],[-75.58264737102958,39.36829483755421],[-75.58290260985541,39.36918225325895],[-75.58315063762237,39.370070890698685],[-75.58339144427632,39.37096071483771],[-75.5836250200466,39.371851690592194],[-75.58385135544665,39.372743782831584],[-75.58407044127428,39.37363695637993],[-75.58428226861213,39.374531176017314],[-75.58448682882809,39.3754264064812],[-75.58468411357566,39.37632261246786],[-75.58487411479427,39.37721975863372],[-75.58505682470975,39.378117809596766],[-75.58523223583455,39.37901672993796],[-75.58540034096823,39.379916484202546],[-75.58556113319763,39.38081703690158],[-75.58571460589731,39.38171835251322],[-75.5858607527298,39.382620395484146],[-75.58599956764587,39.383523130230984],[-75.5861310448849,39.38442652114169],[-75.58625517897502,39.38533053257695],[-75.58637196473353,39.38623512887158],[-75.58648139726701,39.387140274335955],[-75.58658347197161,39.38804593325735],[-75.58667818453331,39.38895206990147],[-75.5867655309281,39.3898586485137],[-75.58684550742217,39.39076563332062],[-75.58691811057211,39.39167298853142],[-75.58698333722515,39.39258067833922],[-75.58704118451922,39.39348866692257],[-75.58709164988325,39.39439691844686],[-75.58713473103711,39.39530539706564],[-75.587170425992,39.39621406692214],[-75.58719873305039,39.39712289215063],[-75.58721965080615,39.398031836877834],[-75.58723317814479,39.3989408652244],[-75.58723931424333,39.39984994130622],[-75.5872380585706,39.40075902923592],[-75.58722941088713,39.40166809312425],[-75.58721337124531,39.40257709708153],[-75.58718993998941,39.40348600521901],[-75.58715911775558,39.404394781650346],[-75.5871209054719,39.40530339049297],[-75.58707530435841,39.40621179586954],[-75.58702231592703,39.40711996190933],[-75.58696194198167,39.408027852749704],[-75.58689418461803,39.408935432537454],[-75.58681904622378,39.40984266543027],[-75.58673652947829,39.41074951559813],[-75.58664663735274,39.41165594722473],[-75.58654937310997,39.41256192450893],[-75.58644474030442,39.413467411666105],[-75.58633274278195,39.414372372929606],[-75.58621338467992,39.41527677255216],[-75.58608667042688,39.4161805748073],[-75.58595260474254,39.41708374399075],[-75.58581119263762,39.41798624442187],[-75.58566243941365,39.41888804044504],[-75.5855063506629,39.419789096431096],[-75.58534293226806,39.42068937677871],[-75.58517219040223,39.421588845915856],[-75.58499413152853,39.42248746830115],[-75.58480876240009,39.423385208425294],[-75.5846160900596,39.424282030812506],[-75.58441612183928,39.42517790002186],[-75.58420886536057,39.426072780648774],[-75.58399432853376,39.42696663732634],[-75.58377251955791,39.42785943472676],[-75.5835434469204,39.42875113756275],[-75.58330711939678,39.42964171058892],[-75.58306354605034,39.430531118603206],[-75.58281273623189,39.431419326448214],[-75.58255469957935,39.43230629901269],[-75.58228944601753,39.43319200123281],[-75.58201698575763,39.4340763980937],[-75.58173732929701,39.4349594546307],[-75.58145048741873,39.43584113593082],[-75.5811564711912,39.43672140713415],[-75.58085529196781,39.43760023343517],[-75.58054696138642,39.43847758008419],[-75.58023149136912,39.43935341238869],[-75.57990889412159,39.44022769571478],[-75.57957918213282,39.44110039548845],[-75.57924236817459,39.441971477197036],[-75.578898465301,39.44284090639058],[-75.57854748684798,39.44370864868317],[-75.57818944643289,39.44457466975435],[-75.5778243579539,39.44543893535042],[-75.57745223558955,39.446301411285866],[-75.57707309379822,39.44716206344469],[-75.57668694731758,39.448020857781735],[-75.57629381116409,39.44887776032414],[-75.57589370063235,39.44973273717255],[-75.57548663129464,39.4505857545026],[-75.57507261900027,39.45143677856616],[-75.57465167987499,39.45228577569275],[-75.57422383032045,39.45313271229084],[-75.57378908701351,39.453977554849196],[-75.5733474669057,39.45482026993823],[-75.57289898722247,39.455660824211314],[-75.57244366546267,39.456499184406105],[-75.5719815193978,39.457335317345894],[-75.57151256707137,39.45816918994091],[-75.57103682679823,39.45900076918964],[-75.5705543171639,39.45983002218017],[-75.5700650570238,39.46065691609143],[-75.56956906550255,39.46148141819461],[-75.56906636199336,39.462303495854336],[-75.56855696615716,39.463123116530085],[-75.56804089792185,39.46394024777745],[-75.56751817748166,39.46475485724937],[-75.56698882529629,39.46556691269752],[-75.56645286209015,39.466376381973525],[-75.56591030885157,39.4671832330303],[-75.56536118683204,39.46798743392325],[-75.56480551754527,39.46878895281165],[-75.56424332276654,39.46958775795983],[-75.56367462453177,39.470383817738465],[-75.56309944513667,39.47117710062587],[-75.56251780713593,39.47196757520924],[-75.56192973334227,39.472755210185895],[-75.56133524682568,39.47353997436451],[-75.56073437091246,39.47432183666644],[-75.56012712918431,39.47510076612687],[-75.55951354547749,39.47587673189611],[-75.5588936438818,39.47664970324083],[-75.5582674487398,39.477419649545254],[-75.55763498464566,39.47818654031241],[-75.55699627644445,39.47895034516531],[-75.55635134923095,39.47971103384826],[-75.55570022834888,39.48046857622797],[-75.55504293938976,39.48122294229479],[-75.554379508192,39.48197410216396],[-75.5537099608399,39.482722026076715],[-75.55303432366259,39.48346668440157],[-75.55235262323306,39.48420804763544],[-75.55166488636708,39.484946086404854],[-75.55097114012219,39.485680771467116],[-75.55027141179664,39.486412073711485],[-75.54956572892833,39.487139964160356],[-75.54885411929372,39.487864413970364],[-75.54813661090675,39.48858539443361],[-75.54741323201777,39.489302876978776],[-75.5466840111124,39.490016833172284],[-75.54594897691047,39.49072723471939],[-75.54520815836484,39.49143405346539],[-75.54446158466031,39.492137261396714],[-75.54370928521244,39.49283683064203],[-75.54295128966646,39.49353273347339],[-75.54218762789601,39.49422494230733],[-75.54141833000209,39.494913429705974],[-75.54064342631175,39.49559816837816],[-75.53986294737702,39.49627913118049],[-75.53907692397365,39.49695629111849],[-75.53828538709992,39.49762962134755],[-75.53748836797534,39.49829909517421],[-75.53668589803956,39.498964686057064],[-75.53587800895107,39.49962636760788],[-75.53506473258591,39.50028411359268],[-75.53424610103647,39.50093789793278],[-75.5334221466102,39.50158769470579],[-75.5325929018284,39.50223347814675],[-75.53175839942482,39.50287522264908],[-75.53091867234444,39.50351290276566],[-75.53007375374219,39.50414649320981],[-75.52922367698162,39.50477596885635],[-75.52836847563354,39.50540130474259],[-75.52750818347475,39.50602247606931],[-75.5266428344867,39.5066394582018],[-75.52577246285405,39.50725222667084],[-75.52489710296352,39.507860757173646],[-75.5240167894023,39.50846502557488],[-75.52313155695683,39.509065007907616],[-75.52224144061138,39.50966068037434],[-75.52134647554664,39.51025201934781],[-75.52044669713835,39.51083900137211],[-75.51954214095592,39.51142160316354],[-75.51863284276095,39.511999801611545],[-75.51771883850584,39.51257357377968],[-75.51680016433245,39.51314289690653],[-75.5158768565705,39.513707748406574],[-75.51494895173626,39.51426810587116],[-75.51401648653103,39.51482394706938],[-75.51307949783973,39.51537524994896],[-75.51213802272936,39.51592199263713],[-75.5111920984476,39.516464153441575],[-75.5102417624213,39.5170017108512],[-75.50928705225496,39.51753464353711],[-75.5083280057293,39.51806293035339],[-75.50736466079964,39.51858655033797],[-75.50639705559452,39.51910548271352],[-75.50542522841411,39.51961970688822],[-75.50444921772866,39.520129202456616],[-75.50346906217702,39.520633949200466],[-75.50248480056506,39.521133927089515],[-75.50149647186417,39.521629116282334],[-75.50050411520958,39.52211949712709],[-75.499507769899,39.5226050501624],[-75.49850747539081,39.523085756117986],[-75.4975032713027,39.523561595915616],[-75.49649519740998,39.524032550669766],[-75.49548329364393,39.52449860168839],[-75.49446760009035,39.524959730473725],[-75.49344815698784,39.52541591872299],[-75.49242500472623,39.52586714832914],[-75.49139818384499,39.52631340138159],[-75.49036773503151,39.526754660166944],[-75.48933369911964,39.52719090716971],[-75.48829611708786,39.527622125073016],[-75.48725503005772,39.52804829675929],[-75.48621047929231,39.52846940531095],[-75.48516250619437,39.52888543401111],[-75.48411115230482,39.529296366344234],[-75.48305645930103,39.52970218599681],[-75.4819984689951,39.530102876857995],[-75.48093722333226,39.5304984230203],[-75.47987276438917,39.53088880878018],[-75.47880513437217,39.53127401863874],[-75.47773437561564,39.53165403730228],[-75.4766605305803,39.53202884968296],[-75.47558364185149,39.53239844089941],[-75.47450375213742,39.532762796277304],[-75.47342090426756,39.53312190135001],[-75.47233514119078,39.53347574185907],[-75.47124650597377,39.53382430375491],[-75.47015504179913,39.53416757319728],[-75.46906079196381,39.5345055365559],[-75.46796379987727,39.534838180410965],[-75.46686410905974,39.53516549155372],[-75.4657617631405,39.535487456986985],[-75.46465680585611,39.53580406392563],[-75.4635492810486,39.53611529979719],[-75.46243923266378,39.536421152242255],[-75.46132670474945,39.536721609115084],[-75.4602117414536,39.53701665848402],[-75.45909438702262,39.537306288632],[-75.45797468579957,39.53759048805702],[-75.45685268222236,39.53786924547261],[-75.45572842082196,39.53814254980828],[-75.45460194622056,39.538410390209954],[-75.45347330312991,39.53867275604047],[-75.45234253634933,39.53892963687993],[-75.45120969076409,39.53918102252617],[-75.45007481134338,39.53942690299515],[-75.44893794313873,39.5396672685214],[-75.44779913128205,39.53990210955833],[-75.44665842098381,39.54013141677872],[-75.44551585753129,39.540355181075014],[-75.44437148628668,39.54057339355974],[-75.44322535268527,39.54078604556583],[-75.44207750223366,39.540993128647],[-75.44092798050785,39.541194634578105],[-75.43977683315143,39.54139055535539],[-75.43862410587374,39.54158088319695],[-75.43746984444807,39.541765610542896],[-75.43631409470972,39.54194473005577],[-75.43515690255414,39.54211823462079],[-75.43399831393525,39.542286117346165],[-75.43283837486334,39.54244837156335],[-75.43167713140342,39.54260499082733],[-75.43051462967321,39.54275596891687],[-75.42935091584137,39.54290129983478],[-75.42818603612554,39.543040977808154],[-75.42702003679062,39.5431749972886],[-75.42585296414673,39.54330335295245],[-75.42468486454742,39.54342603970101],[-75.42351578438785,39.543543052660745],[-75.42234577010278,39.54365438718346],[-75.42117486816484,39.54376003884652],[-75.42000312508249,39.543860003453034],[-75.41883058739832,39.54395427703197],[-75.41765730168699,39.544042855838356],[-75.41648331455349,39.54412573635347],[-75.41530867263114,39.5442029152849],[-75.41413342257982,39.5442743895667],[-75.41295761108395,39.54434015635958],[-75.41178128485072,39.54440021305096],[-75.41060449060814,39.54445455725506],[-75.40942727510311,39.54450318681303],[-75.40824968509966,39.54454609979307],[-75.40707176737693,39.54458329449042],[-75.40589356872732,39.54461476942751],[-75.4047151359546,39.54464052335399],[-75.40353651587202,39.54466055524676],[-75.40235775530043,39.544674864310025],[-75.4011789010663,39.54468344997537],[-75.4,39.54468631190172]]]},"properties":{}},{"type":"Feature","geometry":{"type":"Point","coordinates":[-75.4,39.4]},"properties":{"name":"Location A","category":"Store"}}]} \ No newline at end of file diff --git a/index.js b/index.js index 980030e..7cc80ee 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ var featurecollection = require('turf-featurecollection'); var destination = require('turf-destination'); +var point = require('turf-point'); var polygon = require('turf-polygon'); module.exports = function(feature, radius, units, resolution){ @@ -8,7 +9,11 @@ module.exports = function(feature, radius, units, resolution){ if(geom.type === 'Point') { return pointBuffer(feature, radius, units, resolution); } else if(geom.type === 'MultiPoint') { - + var buffers = [] + geom.coordinates.forEach(function(coords) { + buffers.push(pointBuffer(point(coords[0], coords[1]), radius, units, resolution)); + }); + return featurecollection(buffers) } else if(geom.type === 'LineString') { } else if(geom.type === 'MultiLineString') { diff --git a/package.json b/package.json index 5562b32..5b9d1f9 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "dependencies": { "turf-destination": "0.0.5", "turf-featurecollection": "^0.1.0", + "turf-point": "^0.1.6", "turf-polygon": "^0.1.1" } } diff --git a/test.js b/test.js index e0db808..50d40a8 100644 --- a/test.js +++ b/test.js @@ -5,16 +5,21 @@ var fc = require('turf-featurecollection') test('buffer', function(t){ var pt = JSON.parse(fs.readFileSync(__dirname+'/fixtures/Point.geojson')); + var multipt = JSON.parse(fs.readFileSync(__dirname+'/fixtures/MultiPoint.geojson')); var line = JSON.parse(fs.readFileSync(__dirname+'/fixtures/LineString.geojson')); var polygon = JSON.parse(fs.readFileSync(__dirname+'/fixtures/Polygon.geojson')); var buffPt = buffer(pt, 10, 'miles', 1000); - console.log(JSON.stringify(buffPt)) + fs.writeFileSync(__dirname+'/fixtures/out/point.geojson', JSON.stringify(fc([buffPt, pt]))); + var buffMultiPt = buffer(multipt, 10, 'miles', 100); + buffMultiPt.features.push(multipt) + fs.writeFileSync(__dirname+'/fixtures/out/multipoint.geojson', JSON.stringify(buffMultiPt)); //var buffLine = buffer(pt, 10, 'miles'); //var buffPoly = buffer(pt, 10, 'miles'); //var buffFC = buffer(fc, 10, 'miles'); t.ok(buffPt, 'should buffer a point'); + t.ok(buffMultiPt, 'should buffer a multipoint'); //t.ok(buffLine, 'should buffer a line'); //t.ok(buffPoly, 'should buffer a polygon'); //t.ok(buffFC, 'should buffer featurecollection'); From 08b50237ebb731f46a1f9589ef35c08ab863f493 Mon Sep 17 00:00:00 2001 From: morganherlocker Date: Fri, 5 Dec 2014 15:48:47 -0500 Subject: [PATCH 04/42] line buffer test --- fixtures/LineString.geojson | 42 ++++++++++++++++++++++++++++++++++++- index.js | 6 +++++- test.js | 6 ++++-- 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/fixtures/LineString.geojson b/fixtures/LineString.geojson index 152c448..991f184 100644 --- a/fixtures/LineString.geojson +++ b/fixtures/LineString.geojson @@ -1 +1,41 @@ -{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-80.08724212646484,32.77428536643231],[-80.08718319576123,32.774407687035286],[-80.08700937968847,32.774766344815355],[-80.08672514230369,32.77534888372924],[-80.08633494766407,32.77614284773365],[-80.08584325982665,32.7771357807853],[-80.08525454284863,32.77831522684092],[-80.0845732607871,32.77966872985719],[-80.08380387769924,32.78118383379086],[-80.08295085764209,32.782848082598626],[-80.06932431738281,32.80743595279523],[-80.06781585015088,32.809918368715984],[-80.06628177869239,32.81238800094813],[-80.06472656706445,32.81483239344839],[-80.06315467932423,32.81723909017347],[-80.06157057952882,32.81959563508009],[-80.05997873173536,32.82188957212499],[-80.05838360000097,32.82410844526483],[-80.05678964838282,32.82623979845637],[-80.05520134093798,32.82827117565631],[-80.03937919482422,32.840455481030595],[-80.03820681391552,32.84031557495512],[-80.03709940542186,32.839912668840455],[-80.03607559555957,32.839228128951426],[-80.03513665748144,32.83827031609085],[-80.0342780125122,32.83705398890388],[-80.03349508197655,32.83559390603568],[-80.03278328719922,32.833904826131416],[-80.03213804950488,32.83200150783622],[-80.03155479021825,32.829898709795266],[-80.02792001184082,32.797823240639616],[-80.02772335677393,32.794477859971806],[-80.02752915733595,32.79112486194529],[-80.02733283485155,32.7877790052052],[-80.02712981064552,32.78445504839672],[-80.02691550604247,32.781167750165],[-80.02668534236719,32.77793186915518],[-80.02643474094434,32.77476216401244],[-80.02615912309864,32.771673393381924],[-80.02585391015478,32.768680315908796],[-80.01923379016112,32.74629318460675],[-80.0182162993667,32.7455995993445],[-80.01710969069532,32.745193569626686],[-80.01590938547167,32.74508985409846],[-80.01462611447754,32.74530625723315],[-80.0133079284668,32.7458529732646],[-80.01196016835938,32.7467148599869],[-80.0105844626587,32.747875435203014],[-80.00918243986817,32.74931821671588],[-80.00775572849122,32.75102672232845],[-79.99089820861818,32.78264416628983],[-79.9893022574707,32.786255749728674],[-79.98770278828124,32.789918788705535],[-79.98610142955323,32.793616801023354],[-79.98449980979004,32.79733330448507],[-79.98289955749513,32.801051816893654],[-79.98130230117187,32.804755856052026],[-79.97970966932374,32.808428939763154],[-79.9781232904541,32.81205458582997],[-79.97654479306641,32.81561631205542],[-79.96016725158691,32.84586268264848],[-79.95881035524904,32.84737175940747],[-79.95748251093748,32.84860264776342],[-79.95618534715575,32.849538865519264],[-79.95492049240723,32.850163930477954],[-79.95368957519531,32.850461360442424],[-79.95251206269141,32.85043662672373],[-79.95140467835009,32.850115427468296],[-79.9503649350996,32.84951162073215],[-79.94939034586817,32.84863906457134],[-79.94225872705078,32.8252668887998],[-79.94187199444922,32.822250267913596],[-79.94151808393359,32.81914505233115],[-79.94119450843213,32.815965100108514],[-79.94089878087306,32.812724269301725],[-79.94062841418457,32.8094364179668],[-79.94038092129493,32.8061154041598],[-79.94015381513232,32.80277508593673],[-79.93994460862501,32.79942932135364],[-79.93975081470117,32.79609196846656],[-79.93792500952149,32.76389966267125],[-79.93772217500099,32.76174417850698],[-79.93750242113087,32.75977726076716],[-79.93726326083936,32.75801276750783],[-79.93700220705468,32.75646455678503],[-79.9367167727051,32.755146486654795],[-79.93640447071876,32.754072415173134],[-79.93606645257714,32.7532530165506],[-79.93574776400976,32.75265405687018],[-79.93546119593701,32.752255715114025],[-79.93394115820313,32.758609055294215],[-79.93390701563526,32.75993476040094],[-79.93388282349024,32.76134718872719],[-79.93386687637793,32.76283757914186],[-79.9338574689082,32.76439717051379],[-79.93385289569092,32.766017201711854],[-79.93385145133594,32.767688911604935],[-79.93385143045312,32.769403539061884],[-79.93385112765235,32.771152322951565],[-79.93384883754345,32.77292650214285],[-79.93320474243163,32.791612879648774],[-79.93304558419482,32.79300843423089],[-79.93286226857812,32.79431548940991],[-79.9326530901914,32.79552528405464],[-79.93241634364453,32.79662905703398],[-79.93215032354738,32.797618047216794],[-79.93185332450977,32.79848349347194],[-79.93152364114161,32.79921663466829],[-79.93115956805272,32.7998087096747],[-79.93076445230713,32.80025548858628],[-79.92563361053467,32.79800331988575],[-79.92511511165772,32.79732586216012],[-79.92459094416503,32.79659927901422],[-79.92406180217284,32.79583041516321],[-79.92352837979736,32.7950261153223],[-79.9229913711548,32.794193224206666],[-79.92245147036132,32.79333858653149],[-79.9219093715332,32.79246904701197],[-79.92136576878663,32.791591450363285],[-79.9208213562378,32.79071264130061],[-79.91497788848876,32.782923310831485],[-79.91447789937743,32.78256384058549],[-79.91398612397462,32.78229213922294],[-79.91350325639647,32.78211505145899],[-79.91302999075928,32.78203942200884],[-79.9125670211792,32.78207209558768],[-79.91211504177247,32.78221991691069],[-79.91167474665528,32.782489730693044],[-79.91124682994385,32.78288838164996],[-79.9108319857544,32.78342271449659],[-79.91051217022705,32.79825185788735],[-79.91083374809764,32.80021842735615],[-79.91118676088965,32.80224954504018],[-79.91156481953027,32.804336287035326],[-79.91196153494678,32.80646972943742],[-79.9123705180664,32.80864094834233],[-79.9127853798164,32.81084101984593],[-79.91319973112402,32.813061020044074],[-79.91360718291651,32.81529202503262],[-79.9140013461211,32.81752511090743],[-79.91563281976319,32.83967415743999],[-79.91536917223829,32.84123614942711],[-79.91500917817969,32.842684211546704],[-79.91454644851464,32.8440094198946],[-79.91397459417041,32.84520285056667],[-79.91328722607422,32.84625557965878],[-79.9124779551533,32.84715868326679],[-79.91154039233496,32.84790323748656],[-79.91046814854639,32.84848031841395],[-79.90925483471483,32.84888100214482],[-79.88681002807616,32.84043101772218],[-79.88412558002344,32.83863843745276],[-79.88136658816114,32.836718132514406],[-79.87854052117969,32.83468042668278],[-79.87565484776954,32.832535643733465],[-79.8727170366211,32.830294107442114],[-79.8697345564248,32.82796614158433],[-79.8667148758711,32.82556206993572],[-79.86366546365039,32.823092216271924],[-79.86059378845312,32.820566904368555],[-79.82747205029295,32.79208082944673],[-79.82471577723045,32.789695273166785],[-79.82203433416699,32.78738846773032],[-79.81943518979296,32.785170736912946],[-79.81692581279883,32.78305240449029],[-79.81451367187499,32.78104379423797],[-79.8122062357119,32.77915522993161],[-79.81001097299999,32.77739703534683],[-79.80793535242968,32.775779534259236],[-79.80598684269138,32.774313050444455],[-79.79534838500975,32.769070906870525],[-79.79543174302734,32.76941324126892],[-79.79566084053221,32.76986395696048],[-79.7960265045117,32.77041767918655],[-79.79651956195312,32.7710690331885],[-79.79713083984373,32.771812644207664],[-79.7978511651709,32.77264313748538],[-79.79867136492186,32.773555138263006],[-79.79958226608397,32.774543271781894],[-79.80057469564451,32.77560216328338],[-79.81424881347655,32.79038281567679],[-79.81550408882812,32.791871571794594],[-79.81672164341308,32.79336121403251],[-79.81789230421874,32.794846367631884],[-79.81900689823242,32.79632165783408],[-79.8200562524414,32.797781709880425],[-79.82103119383301,32.79922114901228],[-79.82192254939454,32.800634600470985],[-79.82272114611327,32.8020166894979],[-79.82341781097657,32.803362041334346],[-79.82317655694578,32.81511763936037],[-79.82264117182325,32.81603438083504],[-79.82205102188087,32.81693771442673],[-79.82140863476954,32.81782681524612],[-79.82071653814013,32.81870085840387],[-79.81997725964357,32.81955901901067],[-79.81919332693067,32.82040047217716],[-79.81836726765233,32.821224393014035],[-79.81750160945947,32.82202995663195],[-79.81659888000293,32.82281633814159],[-79.80494506072998,32.82996459725244],[-79.80379463287794,32.83045645209492],[-79.80263999322362,32.83091840126783],[-79.80148366941798,32.831349619881834],[-79.80032818911182,32.8317492830476],[-79.79917607995607,32.83211656587579],[-79.79802986960156,32.8324506434771],[-79.79689208569923,32.83275069096218],[-79.7957652558999,32.833015883441696],[-79.7946519078545,32.833245396026335],[-79.78379761834717,32.83333571959247],[-79.7828884123711,32.833179884680774],[-79.78198295070703,32.83300497173636],[-79.78108284014503,32.832809895070106],[-79.78018968747509,32.83259356899291],[-79.77930509948729,32.832354907815684],[-79.77843068297167,32.832092825849315],[-79.77756804471827,32.83180623740469],[-79.77671879151708,32.83149405679271],[-79.77588453015821,32.831155198324254],[-79.76815665875245,32.82535650956062],[-79.76762762912402,32.8246128330644],[-79.7671344796084,32.82382836475334],[-79.7666788169956,32.82300201893834],[-79.76626224807569,32.822132709930294],[-79.76588637963867,32.821219352040096],[-79.76555281847462,32.82026085957865],[-79.76526317137353,32.819256146856844],[-79.7650190451255,32.81820412818556],[-79.76482204652052,32.817103717875725],[-79.76629620263671,32.8014305177732],[-79.76689192710352,32.7995741723892],[-79.76759057844433,32.79762646866419],[-79.76838602601123,32.795594594234984],[-79.76927213915624,32.79348573673839],[-79.77024278723144,32.79130708381121],[-79.77129183958887,32.78906582309027],[-79.77241316558056,32.786769142212364],[-79.77360063455859,32.7844242288143],[-79.77484811587502,32.7820382705329],[-79.790777859375,32.75513943126411],[-79.7922672982119,32.752821570053676],[-79.79373705096387,32.750556103238424],[-79.79518098698291,32.748350218455144],[-79.79659297562108,32.746211103340656],[-79.79796688623048,32.74414594553178],[-79.79929658816309,32.742161932665304],[-79.80057595077098,32.740266252378035],[-79.80179884340623,32.73846609230681],[-79.80295913542089,32.736768640088414]]},"properties":{}} \ No newline at end of file +{ + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + -58.45962524414062, + -34.5286213832762 + ], + [ + -58.50151062011719, + -34.54841811625336 + ], + [ + -58.531723022460945, + -34.61625687562895 + ], + [ + -58.530349731445305, + -34.65523908026755 + ], + [ + -58.45550537109375, + -34.70831578223845 + ], + [ + -58.41636657714844, + -34.65806316573297 + ], + [ + -58.363494873046875, + -34.651285198954135 + ], + [ + -58.34564208984375, + -34.62925297943919 + ] + ] + } +} \ No newline at end of file diff --git a/index.js b/index.js index 7cc80ee..c988b88 100644 --- a/index.js +++ b/index.js @@ -15,7 +15,7 @@ module.exports = function(feature, radius, units, resolution){ }); return featurecollection(buffers) } else if(geom.type === 'LineString') { - + return lineBuffer(); } else if(geom.type === 'MultiLineString') { } else if(geom.type === 'Polygon') { @@ -37,4 +37,8 @@ function pointBuffer (pt, radius, units, resolution) { } return polygon([ring]) +} + +function lineBuffer () { + } \ No newline at end of file diff --git a/test.js b/test.js index 50d40a8..c6258d0 100644 --- a/test.js +++ b/test.js @@ -14,13 +14,15 @@ test('buffer', function(t){ var buffMultiPt = buffer(multipt, 10, 'miles', 100); buffMultiPt.features.push(multipt) fs.writeFileSync(__dirname+'/fixtures/out/multipoint.geojson', JSON.stringify(buffMultiPt)); - //var buffLine = buffer(pt, 10, 'miles'); + var buffLine = buffer(line, 10, 'miles'); + buffLine.features.push(line) + fs.writeFileSync(__dirname+'/fixtures/out/linestring.geojson', JSON.stringify(buffLine)); //var buffPoly = buffer(pt, 10, 'miles'); //var buffFC = buffer(fc, 10, 'miles'); t.ok(buffPt, 'should buffer a point'); t.ok(buffMultiPt, 'should buffer a multipoint'); - //t.ok(buffLine, 'should buffer a line'); + t.ok(buffLine, 'should buffer a line'); //t.ok(buffPoly, 'should buffer a polygon'); //t.ok(buffFC, 'should buffer featurecollection'); From 685a2e95c21f27eae9a142a8d021ada4194f2835 Mon Sep 17 00:00:00 2001 From: morganherlocker Date: Fri, 5 Dec 2014 19:04:11 -0500 Subject: [PATCH 05/42] segment offset and caps implemented --- index.js | 58 +++++++++++++++++++++++++++++++++++++++++++++++----- package.json | 1 + test.js | 2 +- 3 files changed, 55 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index c988b88..994e900 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ var featurecollection = require('turf-featurecollection'); var destination = require('turf-destination'); +var bearing = require('turf-bearing'); var point = require('turf-point'); var polygon = require('turf-polygon'); @@ -15,7 +16,7 @@ module.exports = function(feature, radius, units, resolution){ }); return featurecollection(buffers) } else if(geom.type === 'LineString') { - return lineBuffer(); + return lineBuffer(feature, radius, units, resolution); } else if(geom.type === 'MultiLineString') { } else if(geom.type === 'Polygon') { @@ -29,16 +30,63 @@ function pointBuffer (pt, radius, units, resolution) { var ring = [] var resMultiple = 360/resolution; for(var i = 0; i < resolution; i++) { - var spoke = destination(pt, radius, i*resMultiple, units) - ring.push(spoke.geometry.coordinates) + var spoke = destination(pt, radius, i*resMultiple, units); + ring.push(spoke.geometry.coordinates); } if((ring[0][0] !== ring[ring.length-1][0]) && (ring[0][1] != ring[ring.length-1][1])) { ring.push([ring[0][0], ring[0][1]]); } - return polygon([ring]) } -function lineBuffer () { +function lineBuffer (line, radius, units, resolution) { + //break line into segments + var segments = []; + for(var i = 0; i < line.geometry.coordinates.length-1; i++) { + segments.push([line.geometry.coordinates[i], line.geometry.coordinates[i+1]]); + } + /*create a set of boxes parallel to the segments + + --------- + + ((|¯¯¯¯¯¯¯¯¯|)) +(((|---------|))) + ((|_________|)) + + */ + for(var i = 0; i < segments.length; i++) { + var bottom = point(segments[i][0][0], segments[i][0][1]) + var top = point(segments[i][1][0], segments[i][1][1]) + var direction = bearing(bottom, top); + + var bottomLeft = destination(bottom, radius, direction - 90, units); + var bottomRight = destination(bottom, radius, direction + 90, units); + var topLeft = destination(top, radius, direction - 90, units); + var topRight = destination(top, radius, direction + 90, units); + + var poly = polygon([[bottomLeft.geometry.coordinates, topLeft.geometry.coordinates]]); + + // add top curve + var spokeNum = Math.floor(resolution/2); + var topStart = bearing(top, topLeft); + for(var k = 1; k < spokeNum; k++) { + var spokeDirection = topStart + (180 * (k/spokeNum)) + var spoke = destination(top, radius, spokeDirection, units); + poly.geometry.coordinates[0].push(spoke.geometry.coordinates); + } + // add right edge + poly.geometry.coordinates[0].push(topRight.geometry.coordinates) + poly.geometry.coordinates[0].push(bottomRight.geometry.coordinates) + //add bottom curve + var bottomStart = bearing(bottom, bottomRight); + for(var k = 1; k < spokeNum; k++) { + var spokeDirection = (bottomStart + (180 * (k/spokeNum))) + var spoke = destination(bottom, radius, spokeDirection, units); + poly.geometry.coordinates[0].push(spoke.geometry.coordinates); + } + + poly.geometry.coordinates[0].push(bottomLeft.geometry.coordinates) + console.log(JSON.stringify(poly)) + } } \ No newline at end of file diff --git a/package.json b/package.json index 5b9d1f9..f6bbdf3 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "tape": "^2.13.3" }, "dependencies": { + "turf-bearing": "0.0.2", "turf-destination": "0.0.5", "turf-featurecollection": "^0.1.0", "turf-point": "^0.1.6", diff --git a/test.js b/test.js index c6258d0..18da7f9 100644 --- a/test.js +++ b/test.js @@ -14,7 +14,7 @@ test('buffer', function(t){ var buffMultiPt = buffer(multipt, 10, 'miles', 100); buffMultiPt.features.push(multipt) fs.writeFileSync(__dirname+'/fixtures/out/multipoint.geojson', JSON.stringify(buffMultiPt)); - var buffLine = buffer(line, 10, 'miles'); + var buffLine = buffer(line, 0.4, 'miles'); buffLine.features.push(line) fs.writeFileSync(__dirname+'/fixtures/out/linestring.geojson', JSON.stringify(buffLine)); //var buffPoly = buffer(pt, 10, 'miles'); From 4ddb2d5846a30e17a82b508b5ea804e089c434c5 Mon Sep 17 00:00:00 2001 From: morganherlocker Date: Sat, 6 Dec 2014 02:58:15 -0500 Subject: [PATCH 06/42] geodesic linestring buffer FC --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 994e900..dbad33f 100644 --- a/index.js +++ b/index.js @@ -40,6 +40,7 @@ function pointBuffer (pt, radius, units, resolution) { } function lineBuffer (line, radius, units, resolution) { + var lineBuffers = featurecollection([]) //break line into segments var segments = []; for(var i = 0; i < line.geometry.coordinates.length-1; i++) { @@ -87,6 +88,8 @@ function lineBuffer (line, radius, units, resolution) { } poly.geometry.coordinates[0].push(bottomLeft.geometry.coordinates) - console.log(JSON.stringify(poly)) + lineBuffers.features.push(poly); } + console.log(JSON.stringify(lineBuffers)) + return lineBuffers; } \ No newline at end of file From 0f72899fc3f290e706161a1fcfd652b9f09fe8b4 Mon Sep 17 00:00:00 2001 From: morganherlocker Date: Sat, 6 Dec 2014 03:47:15 -0500 Subject: [PATCH 07/42] multiline string support --- index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index dbad33f..9d2e124 100644 --- a/index.js +++ b/index.js @@ -10,7 +10,7 @@ module.exports = function(feature, radius, units, resolution){ if(geom.type === 'Point') { return pointBuffer(feature, radius, units, resolution); } else if(geom.type === 'MultiPoint') { - var buffers = [] + var buffers = []; geom.coordinates.forEach(function(coords) { buffers.push(pointBuffer(point(coords[0], coords[1]), radius, units, resolution)); }); @@ -18,7 +18,10 @@ module.exports = function(feature, radius, units, resolution){ } else if(geom.type === 'LineString') { return lineBuffer(feature, radius, units, resolution); } else if(geom.type === 'MultiLineString') { - + var buffers = []; + geom.coordinates.forEach(function(line){ + buffers.push(lineBuffer(feature, radius, units, resolution)); + }); } else if(geom.type === 'Polygon') { } else if(geom.type === 'MultiPolygon') { From 41833ff137c48baabb943b4ad4f57b1d1f81b469 Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Wed, 1 Jun 2016 18:30:25 +0200 Subject: [PATCH 08/42] linestring buffer line made --- index.js | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 100 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 9d2e124..73fa325 100644 --- a/index.js +++ b/index.js @@ -1,18 +1,17 @@ var featurecollection = require('turf-featurecollection'); var destination = require('turf-destination'); var bearing = require('turf-bearing'); -var point = require('turf-point'); -var polygon = require('turf-polygon'); +var helpers = require('turf-helpers'); module.exports = function(feature, radius, units, resolution){ - if(!resolution) resolution = 36; + if(!resolution) resolution = 32; var geom = feature.geometry if(geom.type === 'Point') { return pointBuffer(feature, radius, units, resolution); } else if(geom.type === 'MultiPoint') { var buffers = []; geom.coordinates.forEach(function(coords) { - buffers.push(pointBuffer(point(coords[0], coords[1]), radius, units, resolution)); + buffers.push(pointBuffer(helpers.point(coords[0], coords[1]), radius, units, resolution)); }); return featurecollection(buffers) } else if(geom.type === 'LineString') { @@ -22,7 +21,7 @@ module.exports = function(feature, radius, units, resolution){ geom.coordinates.forEach(function(line){ buffers.push(lineBuffer(feature, radius, units, resolution)); }); - } else if(geom.type === 'Polygon') { + } else if(geom.type === 'Polygon') { } else if(geom.type === 'MultiPolygon') { @@ -39,18 +38,34 @@ function pointBuffer (pt, radius, units, resolution) { if((ring[0][0] !== ring[ring.length-1][0]) && (ring[0][1] != ring[ring.length-1][1])) { ring.push([ring[0][0], ring[0][1]]); } - return polygon([ring]) + return helpers.polygon([ring]) } function lineBuffer (line, radius, units, resolution) { + + var lineBuffer = []; + var firstLinePoint = helpers.point(line.geometry.coordinates[0]); + var firstLineBearing = bearing(helpers.point(line.geometry.coordinates[0]), helpers.point(line.geometry.coordinates[1])); + var firstBufferPoint = destination(firstLinePoint, radius, firstLineBearing + 90, units); + var lastLinePoint = helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-1]); + var lastLineBearing = bearing(helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-2]), helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-1])); + lineBuffer.push.apply(lineBuffer,[firstBufferPoint.geometry.coordinates]); + lineBuffer.push.apply(lineBuffer,lineBufferOneSide(line, radius, units, resolution, true, false).geometry.coordinates); + lineBuffer.push.apply(lineBuffer,arc(lastLinePoint, radius, lastLineBearing + 90, lastLineBearing - 90, units, resolution, true).geometry.coordinates); + lineBuffer.push.apply(lineBuffer,lineBufferOneSide(line, radius, units, resolution, true, true).geometry.coordinates); + lineBuffer.push.apply(lineBuffer,arc(firstLinePoint, radius, firstLineBearing - 90, firstLineBearing + 90, units, resolution, true).geometry.coordinates); + + return helpers.polygon([lineBuffer]); + /* var lineBuffers = featurecollection([]) //break line into segments var segments = []; for(var i = 0; i < line.geometry.coordinates.length-1; i++) { segments.push([line.geometry.coordinates[i], line.geometry.coordinates[i+1]]); } + */ /*create a set of boxes parallel to the segments - + --------- ((|¯¯¯¯¯¯¯¯¯|)) @@ -58,6 +73,7 @@ function lineBuffer (line, radius, units, resolution) { ((|_________|)) */ + /* for(var i = 0; i < segments.length; i++) { var bottom = point(segments[i][0][0], segments[i][0][1]) var top = point(segments[i][1][0], segments[i][1][1]) @@ -95,4 +111,80 @@ function lineBuffer (line, radius, units, resolution) { } console.log(JSON.stringify(lineBuffers)) return lineBuffers; -} \ No newline at end of file + */ +} + +function lineBufferOneSide (line, radius, units, resolution, right, reverse) { + if(right === undefined) var right = true; + if(reverse === undefined) var reverse = false; + var coords = line.geometry.coordinates; + if(reverse) coords = coords.reverse(); + var lineBuffer = []; + if (coords.length == 2) return lineBuffer; + var currentLinePoint = helpers.point(coords[1]); + var currentLineBearing = bearing(helpers.point(coords[0]), helpers.point(coords[1])); + for (var i = 1; i < coords.length-1; i++) { + var nextLinePoint = helpers.point(coords[i+1]); + var nextLineBearing = bearing(currentLinePoint, nextLinePoint); + lineBuffer.push.apply(lineBuffer,arc(currentLinePoint, radius, currentLineBearing + Math.pow(-1, right + 1) * 90, nextLineBearing + Math.pow(-1, right + 1) * 90, units, resolution, right).geometry.coordinates); + var currentLinePoint = nextLinePoint; + var currentLineBearing = nextLineBearing; + } + return helpers.lineString(lineBuffer) +} + +function arc (pt, radius, bearing1, bearing2, units, resolution, right) { + if(right === undefined) var right = true; + var arc = []; + var resMultiple = 360/resolution; + var steps = Math.floor((Math.pow(-1, right + 1) * (bearing1 - bearing2)).mod(360)/resMultiple); + for(var i = 0; i < steps; i++) { + var spoke = destination(pt, radius, bearing1 + Math.pow(-1, !right + 1) * i * resMultiple, units); + arc.push(spoke.geometry.coordinates); + + } + if(bearing1 - i * resMultiple != bearing2) { + var spoke = destination(pt, radius, bearing2, units); + arc.push(spoke.geometry.coordinates); + } + return helpers.lineString(arc) +} + + + + +// Function to compare Arrays of numbers. From http://stackoverflow.com/questions/7837456/how-to-compare-arrays-in-javascript +// Warn if overriding existing method +if(Array.prototype.equals) + console.warn("Overriding existing Array.prototype.equals. Possible causes: New API defines the method, there's a framework conflict or you've got double inclusions in your code."); +// attach the .equals method to Array's prototype to call it on any array +Array.prototype.equals = function (array) { + // if the other array is a falsy value, return + if (!array) + return false; + + // compare lengths - can save a lot of time + if (this.length != array.length) + return false; + + for (var i = 0, l=this.length; i < l; i++) { + // Check if we have nested arrays + if (this[i] instanceof Array && array[i] instanceof Array) { + // recurse into the nested arrays + if (!this[i].equals(array[i])) + return false; + } + else if (this[i] != array[i]) { + // Warning - two different object instances will never be equal: {x:20} != {x:20} + return false; + } + } + return true; +} +// Hide method from for-in loops +Object.defineProperty(Array.prototype, "equals", {enumerable: false}); + +// Fix Javascript modulo for negative number. From http://stackoverflow.com/questions/4467539/javascript-modulo-not-behaving +Number.prototype.mod = function(n) { + return ((this%n)+n)%n; +} From 2b8d30c8fac42457fd540a66dfd084f24d2c48fd Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Fri, 3 Jun 2016 13:28:27 +0200 Subject: [PATCH 09/42] cleanup --- index.js | 67 +++++--------------------------------------------------- 1 file changed, 6 insertions(+), 61 deletions(-) diff --git a/index.js b/index.js index 73fa325..f8246a8 100644 --- a/index.js +++ b/index.js @@ -42,85 +42,30 @@ function pointBuffer (pt, radius, units, resolution) { } function lineBuffer (line, radius, units, resolution) { - var lineBuffer = []; + var firstLinePoint = helpers.point(line.geometry.coordinates[0]); var firstLineBearing = bearing(helpers.point(line.geometry.coordinates[0]), helpers.point(line.geometry.coordinates[1])); var firstBufferPoint = destination(firstLinePoint, radius, firstLineBearing + 90, units); var lastLinePoint = helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-1]); var lastLineBearing = bearing(helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-2]), helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-1])); + lineBuffer.push.apply(lineBuffer,[firstBufferPoint.geometry.coordinates]); - lineBuffer.push.apply(lineBuffer,lineBufferOneSide(line, radius, units, resolution, true, false).geometry.coordinates); + lineBuffer.push.apply(lineBuffer,lineBufferOneSide(line, radius, units, resolution, false, true).geometry.coordinates); lineBuffer.push.apply(lineBuffer,arc(lastLinePoint, radius, lastLineBearing + 90, lastLineBearing - 90, units, resolution, true).geometry.coordinates); lineBuffer.push.apply(lineBuffer,lineBufferOneSide(line, radius, units, resolution, true, true).geometry.coordinates); lineBuffer.push.apply(lineBuffer,arc(firstLinePoint, radius, firstLineBearing - 90, firstLineBearing + 90, units, resolution, true).geometry.coordinates); return helpers.polygon([lineBuffer]); - /* - var lineBuffers = featurecollection([]) - //break line into segments - var segments = []; - for(var i = 0; i < line.geometry.coordinates.length-1; i++) { - segments.push([line.geometry.coordinates[i], line.geometry.coordinates[i+1]]); - } - */ - /*create a set of boxes parallel to the segments - - --------- - - ((|¯¯¯¯¯¯¯¯¯|)) -(((|---------|))) - ((|_________|)) - - */ - /* - for(var i = 0; i < segments.length; i++) { - var bottom = point(segments[i][0][0], segments[i][0][1]) - var top = point(segments[i][1][0], segments[i][1][1]) - - var direction = bearing(bottom, top); - - var bottomLeft = destination(bottom, radius, direction - 90, units); - var bottomRight = destination(bottom, radius, direction + 90, units); - var topLeft = destination(top, radius, direction - 90, units); - var topRight = destination(top, radius, direction + 90, units); - - var poly = polygon([[bottomLeft.geometry.coordinates, topLeft.geometry.coordinates]]); - - // add top curve - var spokeNum = Math.floor(resolution/2); - var topStart = bearing(top, topLeft); - for(var k = 1; k < spokeNum; k++) { - var spokeDirection = topStart + (180 * (k/spokeNum)) - var spoke = destination(top, radius, spokeDirection, units); - poly.geometry.coordinates[0].push(spoke.geometry.coordinates); - } - // add right edge - poly.geometry.coordinates[0].push(topRight.geometry.coordinates) - poly.geometry.coordinates[0].push(bottomRight.geometry.coordinates) - //add bottom curve - var bottomStart = bearing(bottom, bottomRight); - for(var k = 1; k < spokeNum; k++) { - var spokeDirection = (bottomStart + (180 * (k/spokeNum))) - var spoke = destination(bottom, radius, spokeDirection, units); - poly.geometry.coordinates[0].push(spoke.geometry.coordinates); - } - - poly.geometry.coordinates[0].push(bottomLeft.geometry.coordinates) - lineBuffers.features.push(poly); - } - console.log(JSON.stringify(lineBuffers)) - return lineBuffers; - */ } -function lineBufferOneSide (line, radius, units, resolution, right, reverse) { - if(right === undefined) var right = true; +function lineBufferOneSide (line, radius, units, resolution, reverse, right) { if(reverse === undefined) var reverse = false; + if(right === undefined) var right = true; var coords = line.geometry.coordinates; if(reverse) coords = coords.reverse(); var lineBuffer = []; - if (coords.length == 2) return lineBuffer; + if (coords.length == 2) return helpers.lineString(lineBuffer) var currentLinePoint = helpers.point(coords[1]); var currentLineBearing = bearing(helpers.point(coords[0]), helpers.point(coords[1])); for (var i = 1; i < coords.length-1; i++) { From 076506a12ba4b285fe0e75efd53ae10afac92596 Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Fri, 3 Jun 2016 15:33:11 +0200 Subject: [PATCH 10/42] arc at fixed bearings --- index.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index f8246a8..0d512c1 100644 --- a/index.js +++ b/index.js @@ -82,13 +82,24 @@ function arc (pt, radius, bearing1, bearing2, units, resolution, right) { if(right === undefined) var right = true; var arc = []; var resMultiple = 360/resolution; - var steps = Math.floor((Math.pow(-1, right + 1) * (bearing1 - bearing2)).mod(360)/resMultiple); - for(var i = 0; i < steps; i++) { - var spoke = destination(pt, radius, bearing1 + Math.pow(-1, !right + 1) * i * resMultiple, units); + if (right) { + var bearing = Math.floor(bearing1/resMultiple)*resMultiple; + } else { + var bearing = Math.ceil(bearing1/resMultiple)*resMultiple; + } + if (bearing != bearing1) { + var spoke = destination(pt, radius, bearing1, units); arc.push(spoke.geometry.coordinates); - } - if(bearing1 - i * resMultiple != bearing2) { + var numSteps = Math.ceil((Math.pow(-1, right + 1) * (bearing - bearing2)).mod(360)/resMultiple); + var step = numSteps; + while (step) { + var spoke = destination(pt, radius, bearing, units); + arc.push(spoke.geometry.coordinates); + bearing = bearing + Math.pow(-1, !right + 1) * resMultiple; + step--; + } + if(bearing != bearing2) { var spoke = destination(pt, radius, bearing2, units); arc.push(spoke.geometry.coordinates); } From bd4d459e04b610c1aac0e42b42f2809b2d4c7718 Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Thu, 9 Jun 2016 18:01:18 +0200 Subject: [PATCH 11/42] polygon offset implemented --- index.js | 60 ++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/index.js b/index.js index 0d512c1..3a36bb8 100644 --- a/index.js +++ b/index.js @@ -22,7 +22,7 @@ module.exports = function(feature, radius, units, resolution){ buffers.push(lineBuffer(feature, radius, units, resolution)); }); } else if(geom.type === 'Polygon') { - + return polygonBuffer(feature, radius, units, resolution); } else if(geom.type === 'MultiPolygon') { } @@ -44,21 +44,32 @@ function pointBuffer (pt, radius, units, resolution) { function lineBuffer (line, radius, units, resolution) { var lineBuffer = []; - var firstLinePoint = helpers.point(line.geometry.coordinates[0]); - var firstLineBearing = bearing(helpers.point(line.geometry.coordinates[0]), helpers.point(line.geometry.coordinates[1])); - var firstBufferPoint = destination(firstLinePoint, radius, firstLineBearing + 90, units); - var lastLinePoint = helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-1]); - var lastLineBearing = bearing(helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-2]), helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-1])); + // situation at current point = point 0 + var currentLinePoint = helpers.point(line.geometry.coordinates[0]); + var nextLineBearing = bearing(helpers.point(line.geometry.coordinates[0]), helpers.point(line.geometry.coordinates[1])); + var currentBufferPoint = destination(currentLinePoint, radius, nextLineBearing + 90, units); + var previousLinePoint = helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-1]); + var previousLineBearing = bearing(helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-2]), helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-1])); - lineBuffer.push.apply(lineBuffer,[firstBufferPoint.geometry.coordinates]); + lineBuffer.push.apply(lineBuffer,[currentBufferPoint.geometry.coordinates]); // Add first buffer point in order to close ring lineBuffer.push.apply(lineBuffer,lineBufferOneSide(line, radius, units, resolution, false, true).geometry.coordinates); - lineBuffer.push.apply(lineBuffer,arc(lastLinePoint, radius, lastLineBearing + 90, lastLineBearing - 90, units, resolution, true).geometry.coordinates); + lineBuffer.push.apply(lineBuffer,arc(previousLinePoint, radius, previousLineBearing + 90, previousLineBearing - 90, units, resolution, true).geometry.coordinates); lineBuffer.push.apply(lineBuffer,lineBufferOneSide(line, radius, units, resolution, true, true).geometry.coordinates); - lineBuffer.push.apply(lineBuffer,arc(firstLinePoint, radius, firstLineBearing - 90, firstLineBearing + 90, units, resolution, true).geometry.coordinates); + lineBuffer.push.apply(lineBuffer,arc(currentLinePoint, radius, nextLineBearing - 90, nextLineBearing + 90, units, resolution, true).geometry.coordinates); return helpers.polygon([lineBuffer]); } +function polygonBuffer (poly, radius, units, resolution) { + var offsetPolygon = []; + offsetPolygon.push(ringBufferOneSide(helpers.lineString(poly.geometry.coordinates[0]), radius, units, resolution, false, true).geometry.coordinates); + for (var i = i; i < poly.geometry.coordinates.length; i++) { + offsetPolygon.push(ringBufferOneSide(helpers.lineString(poly.geometry.coordinates[i]), radius, units, resolution, true, true).geometry.coordinates); + } + + return helpers.polygon(offsetPolygon); +} + function lineBufferOneSide (line, radius, units, resolution, reverse, right) { if(reverse === undefined) var reverse = false; if(right === undefined) var right = true; @@ -66,19 +77,43 @@ function lineBufferOneSide (line, radius, units, resolution, reverse, right) { if(reverse) coords = coords.reverse(); var lineBuffer = []; if (coords.length == 2) return helpers.lineString(lineBuffer) + var currentLinePoint = helpers.point(coords[1]); - var currentLineBearing = bearing(helpers.point(coords[0]), helpers.point(coords[1])); + var previousLineBearing = bearing(helpers.point(coords[0]), helpers.point(coords[1])); for (var i = 1; i < coords.length-1; i++) { var nextLinePoint = helpers.point(coords[i+1]); var nextLineBearing = bearing(currentLinePoint, nextLinePoint); - lineBuffer.push.apply(lineBuffer,arc(currentLinePoint, radius, currentLineBearing + Math.pow(-1, right + 1) * 90, nextLineBearing + Math.pow(-1, right + 1) * 90, units, resolution, right).geometry.coordinates); + lineBuffer.push.apply(lineBuffer, arc(currentLinePoint, radius, previousLineBearing + Math.pow(-1, right + 1) * 90, nextLineBearing + Math.pow(-1, right + 1) * 90, units, resolution, right).geometry.coordinates); var currentLinePoint = nextLinePoint; - var currentLineBearing = nextLineBearing; + var previousLineBearing = nextLineBearing; } + return helpers.lineString(lineBuffer) } +function ringBufferOneSide (ring, radius, units, resolution, reverse, right) { + if(reverse === undefined) var reverse = false; + if(right === undefined) var right = true; + var coords = ring.geometry.coordinates; + if(reverse) coords = coords.reverse(); + var ringBuffer = []; + + // situation at current point = point 0 + var currentRingPoint = helpers.point(ring.geometry.coordinates[0]); + var nextRingBearing = bearing(helpers.point(ring.geometry.coordinates[0]), helpers.point(ring.geometry.coordinates[1])); + var currentBufferPoint = destination(currentRingPoint, radius, nextRingBearing + 90, units); + var previousRingPoint = helpers.point(ring.geometry.coordinates[ring.geometry.coordinates.length-1]); + var previousRingBearing = bearing(helpers.point(ring.geometry.coordinates[ring.geometry.coordinates.length-2]), helpers.point(ring.geometry.coordinates[ring.geometry.coordinates.length-1])); + + ringBuffer.push.apply(ringBuffer, [currentBufferPoint.geometry.coordinates]); // Add first buffer point in order to close ring + ringBuffer.push.apply(ringBuffer, lineBufferOneSide(ring, radius, units, resolution, reverse, right).geometry.coordinates); + ringBuffer.push.apply(ringBuffer, arc(currentRingPoint, radius, previousRingBearing + Math.pow(-1, right + 1) * 90, nextRingBearing + Math.pow(-1, right + 1) * 90, units, resolution, right).geometry.coordinates); + + return helpers.lineString(ringBuffer) +} + function arc (pt, radius, bearing1, bearing2, units, resolution, right) { + // An arc includes the first and last point if(right === undefined) var right = true; var arc = []; var resMultiple = 360/resolution; @@ -96,6 +131,7 @@ function arc (pt, radius, bearing1, bearing2, units, resolution, right) { while (step) { var spoke = destination(pt, radius, bearing, units); arc.push(spoke.geometry.coordinates); + // the value of bearing is independent of bearing1 and bearing2, such that multiple arcs with the same centerpoint coincide, instead of zigzag overlapping bearing = bearing + Math.pow(-1, !right + 1) * resMultiple; step--; } From d258dfe17c9fa07de55e4273d6c31b689f8b6e27 Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Fri, 10 Jun 2016 00:14:05 +0200 Subject: [PATCH 12/42] line buffer return polygon, polygon buffer with or without rings returns polygon, multifeatures implemented. All seems to work as intended --- index.js | 105 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 76 insertions(+), 29 deletions(-) diff --git a/index.js b/index.js index 3a36bb8..77a780f 100644 --- a/index.js +++ b/index.js @@ -1,34 +1,44 @@ +var simplepolygon = require('../simplepolygon'); var featurecollection = require('turf-featurecollection'); var destination = require('turf-destination'); var bearing = require('turf-bearing'); var helpers = require('turf-helpers'); +var union = require('turf-union'); +var difference = require('turf-difference'); module.exports = function(feature, radius, units, resolution){ - if(!resolution) resolution = 32; - var geom = feature.geometry + if (!resolution) resolution = 32; + if (radius <= 0) throw new Error("The buffer radius must be positive"); + var geom = feature.geometry; + if (geom === null) return feature; if(geom.type === 'Point') { return pointBuffer(feature, radius, units, resolution); } else if(geom.type === 'MultiPoint') { var buffers = []; geom.coordinates.forEach(function(coords) { - buffers.push(pointBuffer(helpers.point(coords[0], coords[1]), radius, units, resolution)); + buffers.push(pointBuffer(helpers.point(coords), radius, units, resolution)); }); return featurecollection(buffers) } else if(geom.type === 'LineString') { return lineBuffer(feature, radius, units, resolution); } else if(geom.type === 'MultiLineString') { var buffers = []; - geom.coordinates.forEach(function(line){ - buffers.push(lineBuffer(feature, radius, units, resolution)); + geom.coordinates.forEach(function(coords) { + buffers.push(lineBuffer(helpers.lineString(coords), radius, units, resolution)); }); + return featurecollection(buffers) } else if(geom.type === 'Polygon') { return polygonBuffer(feature, radius, units, resolution); } else if(geom.type === 'MultiPolygon') { - + var buffers = []; + geom.coordinates.forEach(function(coords) { + buffers.push(polygonBuffer(helpers.polygon(coords), radius, units, resolution)); + }); + return featurecollection(buffers) } } -function pointBuffer (pt, radius, units, resolution) { +function pointBuffer(pt, radius, units, resolution) { var ring = [] var resMultiple = 360/resolution; for(var i = 0; i < resolution; i++) { @@ -41,7 +51,7 @@ function pointBuffer (pt, radius, units, resolution) { return helpers.polygon([ring]) } -function lineBuffer (line, radius, units, resolution) { +function lineBuffer(line, radius, units, resolution) { var lineBuffer = []; // situation at current point = point 0 @@ -57,20 +67,29 @@ function lineBuffer (line, radius, units, resolution) { lineBuffer.push.apply(lineBuffer,lineBufferOneSide(line, radius, units, resolution, true, true).geometry.coordinates); lineBuffer.push.apply(lineBuffer,arc(currentLinePoint, radius, nextLineBearing - 90, nextLineBearing + 90, units, resolution, true).geometry.coordinates); - return helpers.polygon([lineBuffer]); + return filterNetWinding(simplepolygon(helpers.polygon([lineBuffer])), function (netWinding){return netWinding == 1}).features[0]; } -function polygonBuffer (poly, radius, units, resolution) { +function polygonBuffer(poly, radius, units, resolution) { + var offsetPolygon = []; offsetPolygon.push(ringBufferOneSide(helpers.lineString(poly.geometry.coordinates[0]), radius, units, resolution, false, true).geometry.coordinates); - for (var i = i; i < poly.geometry.coordinates.length; i++) { - offsetPolygon.push(ringBufferOneSide(helpers.lineString(poly.geometry.coordinates[i]), radius, units, resolution, true, true).geometry.coordinates); + for (var i = 1; i < poly.geometry.coordinates.length; i++) { + offsetPolygon.push(ringBufferOneSide(helpers.lineString(poly.geometry.coordinates[i]), radius, units, resolution, false, true).geometry.coordinates); } - return helpers.polygon(offsetPolygon); + offsetPolygon = helpers.polygon(offsetPolygon); + + var unionWithWindingOne = unionFeatureCollection(filterNetWinding(simplepolygon(offsetPolygon), function (netWinding){return netWinding == 1})); + var unionWithWindingZero = unionFeatureCollection(filterNetWinding(simplepolygon(offsetPolygon), function (netWinding){return netWinding == 0})); + // This last one might have winding -1, so we might have to rewind it if the difference algorithm requires so + + if (unionWithWindingOne.geometry == null) return {type: "Feature", geometry: null}; + if (unionWithWindingZero.geometry == null) return unionWithWindingOne; + return difference(unionWithWindingOne, unionWithWindingZero); } -function lineBufferOneSide (line, radius, units, resolution, reverse, right) { +function lineBufferOneSide(line, radius, units, resolution, reverse, right) { if(reverse === undefined) var reverse = false; if(right === undefined) var right = true; var coords = line.geometry.coordinates; @@ -83,7 +102,7 @@ function lineBufferOneSide (line, radius, units, resolution, reverse, right) { for (var i = 1; i < coords.length-1; i++) { var nextLinePoint = helpers.point(coords[i+1]); var nextLineBearing = bearing(currentLinePoint, nextLinePoint); - lineBuffer.push.apply(lineBuffer, arc(currentLinePoint, radius, previousLineBearing + Math.pow(-1, right + 1) * 90, nextLineBearing + Math.pow(-1, right + 1) * 90, units, resolution, right).geometry.coordinates); + lineBuffer.push.apply(lineBuffer, arc(currentLinePoint, radius, previousLineBearing + Math.pow(-1, right + 1) * 90, nextLineBearing + Math.pow(-1, right + 1) * 90, units, resolution, right, true).geometry.coordinates); var currentLinePoint = nextLinePoint; var previousLineBearing = nextLineBearing; } @@ -91,7 +110,7 @@ function lineBufferOneSide (line, radius, units, resolution, reverse, right) { return helpers.lineString(lineBuffer) } -function ringBufferOneSide (ring, radius, units, resolution, reverse, right) { +function ringBufferOneSide(ring, radius, units, resolution, reverse, right) { if(reverse === undefined) var reverse = false; if(right === undefined) var right = true; var coords = ring.geometry.coordinates; @@ -112,9 +131,9 @@ function ringBufferOneSide (ring, radius, units, resolution, reverse, right) { return helpers.lineString(ringBuffer) } -function arc (pt, radius, bearing1, bearing2, units, resolution, right) { - // An arc includes the first and last point - if(right === undefined) var right = true; +function arc(pt, radius, bearing1, bearing2, units, resolution, right, shortcut) { + if (right === undefined) var right = true; + if (shortcut === undefined) var shortcut = false; var arc = []; var resMultiple = 360/resolution; if (right) { @@ -122,18 +141,21 @@ function arc (pt, radius, bearing1, bearing2, units, resolution, right) { } else { var bearing = Math.ceil(bearing1/resMultiple)*resMultiple; } + var angle = (Math.pow(-1, right + 1) * (bearing1 - bearing2)).mod(360); + var numSteps = Math.ceil((Math.pow(-1, right + 1) * (bearing - bearing2)).mod(360)/resMultiple); + var step = numSteps; if (bearing != bearing1) { var spoke = destination(pt, radius, bearing1, units); arc.push(spoke.geometry.coordinates); } - var numSteps = Math.ceil((Math.pow(-1, right + 1) * (bearing - bearing2)).mod(360)/resMultiple); - var step = numSteps; - while (step) { - var spoke = destination(pt, radius, bearing, units); - arc.push(spoke.geometry.coordinates); - // the value of bearing is independent of bearing1 and bearing2, such that multiple arcs with the same centerpoint coincide, instead of zigzag overlapping - bearing = bearing + Math.pow(-1, !right + 1) * resMultiple; - step--; + if (!(angle > 180 && shortcut)) { + while (step) { + var spoke = destination(pt, radius, bearing, units); + arc.push(spoke.geometry.coordinates); + // the value of bearing is independent of bearing1 and bearing2, such that multiple arcs with the same centerpoint coincide, instead of zigzag overlapping + bearing = bearing + Math.pow(-1, !right + 1) * resMultiple; + step--; + } } if(bearing != bearing2) { var spoke = destination(pt, radius, bearing2, units); @@ -142,13 +164,38 @@ function arc (pt, radius, bearing1, bearing2, units, resolution, right) { return helpers.lineString(arc) } +function filterNetWinding(fc, filterFn) { + var i = fc.features.length; + while (i--) { + if (!filterFn(fc.features[i].properties.netWinding)) { + fc.features.splice(i, 1); + } + } + return fc; +} + +function unionFeatureCollection(fc) { + if (fc.features.length == 0) return {type: "Feature", geometry: null}; + var incrementalUnion = fc.features[0]; + if (fc.features.length == 1) return incrementalUnion; + for (var i = 1; i < fc.features.length; i++) { + incrementalUnion = union(incrementalUnion, fc.features[i]); + } + return incrementalUnion +} +function winding(poly){ + // compute winding of first ring + var coords = poly.geometry.coordinates[0]; + var leftVtx = 0; + for (var i = 0; i < coords.length-1; i++) { if (coords[i][0] < coords[leftVtx][0]) leftVtx = i; } + return (coords[(leftVtx-1).mod(coords.length-1)][1] > coords[(leftVtx+1).mod(coords.length-1)][1]) ? 1 : -1; +} // Function to compare Arrays of numbers. From http://stackoverflow.com/questions/7837456/how-to-compare-arrays-in-javascript // Warn if overriding existing method -if(Array.prototype.equals) - console.warn("Overriding existing Array.prototype.equals. Possible causes: New API defines the method, there's a framework conflict or you've got double inclusions in your code."); +// if(Array.prototype.equals) console.warn("Overriding existing Array.prototype.equals. Possible causes: New API defines the method, there's a framework conflict or you've got double inclusions in your code."); // attach the .equals method to Array's prototype to call it on any array Array.prototype.equals = function (array) { // if the other array is a falsy value, return From e45a8aad8da83804d7b100689f643d4259491a88 Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Fri, 10 Jun 2016 00:20:53 +0200 Subject: [PATCH 13/42] removed old turf featurecollection --- index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 77a780f..f1f96b3 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,4 @@ var simplepolygon = require('../simplepolygon'); -var featurecollection = require('turf-featurecollection'); var destination = require('turf-destination'); var bearing = require('turf-bearing'); var helpers = require('turf-helpers'); @@ -18,7 +17,7 @@ module.exports = function(feature, radius, units, resolution){ geom.coordinates.forEach(function(coords) { buffers.push(pointBuffer(helpers.point(coords), radius, units, resolution)); }); - return featurecollection(buffers) + return helpers.featureCollection(buffers) } else if(geom.type === 'LineString') { return lineBuffer(feature, radius, units, resolution); } else if(geom.type === 'MultiLineString') { @@ -26,7 +25,7 @@ module.exports = function(feature, radius, units, resolution){ geom.coordinates.forEach(function(coords) { buffers.push(lineBuffer(helpers.lineString(coords), radius, units, resolution)); }); - return featurecollection(buffers) + return helpers.featureCollection(buffers) } else if(geom.type === 'Polygon') { return polygonBuffer(feature, radius, units, resolution); } else if(geom.type === 'MultiPolygon') { @@ -34,7 +33,7 @@ module.exports = function(feature, radius, units, resolution){ geom.coordinates.forEach(function(coords) { buffers.push(polygonBuffer(helpers.polygon(coords), radius, units, resolution)); }); - return featurecollection(buffers) + return helpers.featureCollection(buffers) } } From b13b9c830678189ace06478e372ea6a39809b547 Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Fri, 10 Jun 2016 18:02:09 +0200 Subject: [PATCH 14/42] lineBuffer for closed line fix --- index.js | 131 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 73 insertions(+), 58 deletions(-) diff --git a/index.js b/index.js index f1f96b3..a1a567b 100644 --- a/index.js +++ b/index.js @@ -51,83 +51,85 @@ function pointBuffer(pt, radius, units, resolution) { } function lineBuffer(line, radius, units, resolution) { - var lineBuffer = []; + var lineOffset = []; - // situation at current point = point 0 - var currentLinePoint = helpers.point(line.geometry.coordinates[0]); - var nextLineBearing = bearing(helpers.point(line.geometry.coordinates[0]), helpers.point(line.geometry.coordinates[1])); - var currentBufferPoint = destination(currentLinePoint, radius, nextLineBearing + 90, units); - var previousLinePoint = helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-1]); - var previousLineBearing = bearing(helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-2]), helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-1])); - - lineBuffer.push.apply(lineBuffer,[currentBufferPoint.geometry.coordinates]); // Add first buffer point in order to close ring - lineBuffer.push.apply(lineBuffer,lineBufferOneSide(line, radius, units, resolution, false, true).geometry.coordinates); - lineBuffer.push.apply(lineBuffer,arc(previousLinePoint, radius, previousLineBearing + 90, previousLineBearing - 90, units, resolution, true).geometry.coordinates); - lineBuffer.push.apply(lineBuffer,lineBufferOneSide(line, radius, units, resolution, true, true).geometry.coordinates); - lineBuffer.push.apply(lineBuffer,arc(currentLinePoint, radius, nextLineBearing - 90, nextLineBearing + 90, units, resolution, true).geometry.coordinates); - - return filterNetWinding(simplepolygon(helpers.polygon([lineBuffer])), function (netWinding){return netWinding == 1}).features[0]; + if (!(line.geometry.coordinates[0].equals(line.geometry.coordinates[line.geometry.coordinates.length-1]))) { + + // situation at current point = point 0 + var currentLinePoint = helpers.point(line.geometry.coordinates[0]); + var nextLineBearing = bearing(helpers.point(line.geometry.coordinates[0]), helpers.point(line.geometry.coordinates[1])); + var currentBufferPoint = destination(currentLinePoint, radius, nextLineBearing + 90, units); + var previousLinePoint = helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-1]); + var previousLineBearing = bearing(helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-2]), helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-1])); + + lineOffset.push.apply(lineOffset,[currentBufferPoint.geometry.coordinates]); // Add first buffer point in order to close ring + lineOffset.push.apply(lineOffset,lineOffsetOneSide(line, radius, units, resolution, false, true).geometry.coordinates); + lineOffset.push.apply(lineOffset,arc(previousLinePoint, radius, previousLineBearing + 90, previousLineBearing - 90, units, resolution, true).geometry.coordinates); + lineOffset.push.apply(lineOffset,lineOffsetOneSide(line, radius, units, resolution, true, true).geometry.coordinates); + lineOffset.push.apply(lineOffset,arc(currentLinePoint, radius, nextLineBearing - 90, nextLineBearing + 90, units, resolution, true).geometry.coordinates); + + return offsetToBuffer(helpers.polygon([lineOffset])); + + } else { + + lineOffset.push(ringOffsetOneSide(line, radius, units, resolution, false, true).geometry.coordinates); + lineOffset.push(ringOffsetOneSide(line, radius, units, resolution, true, true).geometry.coordinates); + + return offsetToBuffer(helpers.polygon(lineOffset)); + } } function polygonBuffer(poly, radius, units, resolution) { + var polygonOffset = []; - var offsetPolygon = []; - offsetPolygon.push(ringBufferOneSide(helpers.lineString(poly.geometry.coordinates[0]), radius, units, resolution, false, true).geometry.coordinates); + polygonOffset.push(ringOffsetOneSide(helpers.lineString(poly.geometry.coordinates[0]), radius, units, resolution, false, true).geometry.coordinates); for (var i = 1; i < poly.geometry.coordinates.length; i++) { - offsetPolygon.push(ringBufferOneSide(helpers.lineString(poly.geometry.coordinates[i]), radius, units, resolution, false, true).geometry.coordinates); + polygonOffset.push(ringOffsetOneSide(helpers.lineString(poly.geometry.coordinates[i]), radius, units, resolution, false, true).geometry.coordinates); } - offsetPolygon = helpers.polygon(offsetPolygon); - - var unionWithWindingOne = unionFeatureCollection(filterNetWinding(simplepolygon(offsetPolygon), function (netWinding){return netWinding == 1})); - var unionWithWindingZero = unionFeatureCollection(filterNetWinding(simplepolygon(offsetPolygon), function (netWinding){return netWinding == 0})); - // This last one might have winding -1, so we might have to rewind it if the difference algorithm requires so - - if (unionWithWindingOne.geometry == null) return {type: "Feature", geometry: null}; - if (unionWithWindingZero.geometry == null) return unionWithWindingOne; - return difference(unionWithWindingOne, unionWithWindingZero); + return offsetToBuffer(helpers.polygon(polygonOffset)); } -function lineBufferOneSide(line, radius, units, resolution, reverse, right) { - if(reverse === undefined) var reverse = false; - if(right === undefined) var right = true; +function lineOffsetOneSide(line, radius, units, resolution, reverse, right) { + if (reverse === undefined) var reverse = false; + if (right === undefined) var right = true; + if (reverse) line.geometry.coordinates = line.geometry.coordinates.reverse(); var coords = line.geometry.coordinates; - if(reverse) coords = coords.reverse(); - var lineBuffer = []; - if (coords.length == 2) return helpers.lineString(lineBuffer) + var lineOffset = []; + if (coords.length == 2) return helpers.lineString(lineOffset) var currentLinePoint = helpers.point(coords[1]); var previousLineBearing = bearing(helpers.point(coords[0]), helpers.point(coords[1])); for (var i = 1; i < coords.length-1; i++) { var nextLinePoint = helpers.point(coords[i+1]); var nextLineBearing = bearing(currentLinePoint, nextLinePoint); - lineBuffer.push.apply(lineBuffer, arc(currentLinePoint, radius, previousLineBearing + Math.pow(-1, right + 1) * 90, nextLineBearing + Math.pow(-1, right + 1) * 90, units, resolution, right, true).geometry.coordinates); + lineOffset.push.apply(lineOffset, arc(currentLinePoint, radius, previousLineBearing + Math.pow(-1, right + 1) * 90, nextLineBearing + Math.pow(-1, right + 1) * 90, units, resolution, right, true).geometry.coordinates); var currentLinePoint = nextLinePoint; var previousLineBearing = nextLineBearing; } - return helpers.lineString(lineBuffer) + return helpers.lineString(lineOffset) } -function ringBufferOneSide(ring, radius, units, resolution, reverse, right) { - if(reverse === undefined) var reverse = false; - if(right === undefined) var right = true; - var coords = ring.geometry.coordinates; - if(reverse) coords = coords.reverse(); - var ringBuffer = []; +function ringOffsetOneSide(ring, radius, units, resolution, reverse, right) { + if (reverse === undefined) var reverse = false; + if (right === undefined) var right = true; + if (reverse) ring.geometry.coordinates = ring.geometry.coordinates.reverse(); + var coords = ring.geometry.coordinates; // ring is a linestring + var ringOffset = []; // situation at current point = point 0 - var currentRingPoint = helpers.point(ring.geometry.coordinates[0]); - var nextRingBearing = bearing(helpers.point(ring.geometry.coordinates[0]), helpers.point(ring.geometry.coordinates[1])); + var currentRingPoint = helpers.point(coords[0]); + var nextRingBearing = bearing(helpers.point(coords[0]), helpers.point(coords[1])); var currentBufferPoint = destination(currentRingPoint, radius, nextRingBearing + 90, units); - var previousRingPoint = helpers.point(ring.geometry.coordinates[ring.geometry.coordinates.length-1]); - var previousRingBearing = bearing(helpers.point(ring.geometry.coordinates[ring.geometry.coordinates.length-2]), helpers.point(ring.geometry.coordinates[ring.geometry.coordinates.length-1])); + var previousRingPoint = helpers.point(coords[coords.length-1]); + var previousRingBearing = bearing(helpers.point(coords[coords.length-2]), helpers.point(coords[coords.length-1])); - ringBuffer.push.apply(ringBuffer, [currentBufferPoint.geometry.coordinates]); // Add first buffer point in order to close ring - ringBuffer.push.apply(ringBuffer, lineBufferOneSide(ring, radius, units, resolution, reverse, right).geometry.coordinates); - ringBuffer.push.apply(ringBuffer, arc(currentRingPoint, radius, previousRingBearing + Math.pow(-1, right + 1) * 90, nextRingBearing + Math.pow(-1, right + 1) * 90, units, resolution, right).geometry.coordinates); + ringOffset.push.apply(ringOffset, [currentBufferPoint.geometry.coordinates]); // Add first buffer point in order to close ring + ringOffset.push.apply(ringOffset, lineOffsetOneSide(ring, radius, units, resolution, false, right).geometry.coordinates); + ringOffset.push.apply(ringOffset, arc(currentRingPoint, radius, previousRingBearing + Math.pow(-1, right + 1) * 90, nextRingBearing + Math.pow(-1, right + 1) * 90, units, resolution, right, true).geometry.coordinates); - return helpers.lineString(ringBuffer) + return helpers.lineString(ringOffset) } function arc(pt, radius, bearing1, bearing2, units, resolution, right, shortcut) { @@ -143,21 +145,24 @@ function arc(pt, radius, bearing1, bearing2, units, resolution, right, shortcut) var angle = (Math.pow(-1, right + 1) * (bearing1 - bearing2)).mod(360); var numSteps = Math.ceil((Math.pow(-1, right + 1) * (bearing - bearing2)).mod(360)/resMultiple); var step = numSteps; - if (bearing != bearing1) { - var spoke = destination(pt, radius, bearing1, units); - arc.push(spoke.geometry.coordinates); - } + // Add spoke for bearing1 + var spoke = destination(pt, radius, bearing1, units); + arc.push(spoke.geometry.coordinates); if (!(angle > 180 && shortcut)) { while (step) { - var spoke = destination(pt, radius, bearing, units); - arc.push(spoke.geometry.coordinates); - // the value of bearing is independent of bearing1 and bearing2, such that multiple arcs with the same centerpoint coincide, instead of zigzag overlapping + // Only add spokes for bearings different than the first and last + if (!(bearing == bearing1) || (bearing == bearing2)) { + spoke = destination(pt, radius, bearing, units); + arc.push(spoke.geometry.coordinates); + } + // The value of bearing is independent of bearing1 and bearing2, such that multiple arcs with the same centerpoint coincide, instead of zigzag overlapping bearing = bearing + Math.pow(-1, !right + 1) * resMultiple; step--; } } - if(bearing != bearing2) { - var spoke = destination(pt, radius, bearing2, units); + // Only add spoke for bearing2 if it's not a straight line (equivalently: angle == 0) + if (!((bearing == bearing1) && (bearing1 == bearing2))) { + spoke = destination(pt, radius, bearing2, units); arc.push(spoke.geometry.coordinates); } return helpers.lineString(arc) @@ -183,6 +188,16 @@ function unionFeatureCollection(fc) { return incrementalUnion } +function offsetToBuffer(polygonOffset) { + var unionWithWindingOne = unionFeatureCollection(filterNetWinding(simplepolygon(polygonOffset), function (netWinding){return netWinding == 1})); + var unionWithWindingZero = unionFeatureCollection(filterNetWinding(simplepolygon(polygonOffset), function (netWinding){return netWinding == 0})); + // This last one might have winding -1, so we might have to rewind it if the difference algorithm requires so + + if (unionWithWindingOne.geometry == null) return {type: "Feature", geometry: null}; + if (unionWithWindingZero.geometry == null) return unionWithWindingOne; + return difference(unionWithWindingOne, unionWithWindingZero); +} + function winding(poly){ // compute winding of first ring var coords = poly.geometry.coordinates[0]; From 6cf94279f97f065b9e57c52a6409a379130312a0 Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Fri, 10 Jun 2016 18:10:21 +0200 Subject: [PATCH 15/42] all offsets are now polygon coordinates --- index.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/index.js b/index.js index a1a567b..6f97e77 100644 --- a/index.js +++ b/index.js @@ -38,16 +38,16 @@ module.exports = function(feature, radius, units, resolution){ } function pointBuffer(pt, radius, units, resolution) { - var ring = [] + var pointOffset = [[]]; var resMultiple = 360/resolution; for(var i = 0; i < resolution; i++) { var spoke = destination(pt, radius, i*resMultiple, units); - ring.push(spoke.geometry.coordinates); + pointOffset[0].push(spoke.geometry.coordinates); } - if((ring[0][0] !== ring[ring.length-1][0]) && (ring[0][1] != ring[ring.length-1][1])) { - ring.push([ring[0][0], ring[0][1]]); + if(!(pointOffset[0][0].equals(pointOffset[0][pointOffset[0].length-1])) { + pointOffset[0].push(pointOffset[0][0]); } - return helpers.polygon([ring]) + return helpers.polygon(pointOffset) } function lineBuffer(line, radius, units, resolution) { @@ -62,13 +62,14 @@ function lineBuffer(line, radius, units, resolution) { var previousLinePoint = helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-1]); var previousLineBearing = bearing(helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-2]), helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-1])); - lineOffset.push.apply(lineOffset,[currentBufferPoint.geometry.coordinates]); // Add first buffer point in order to close ring - lineOffset.push.apply(lineOffset,lineOffsetOneSide(line, radius, units, resolution, false, true).geometry.coordinates); - lineOffset.push.apply(lineOffset,arc(previousLinePoint, radius, previousLineBearing + 90, previousLineBearing - 90, units, resolution, true).geometry.coordinates); - lineOffset.push.apply(lineOffset,lineOffsetOneSide(line, radius, units, resolution, true, true).geometry.coordinates); - lineOffset.push.apply(lineOffset,arc(currentLinePoint, radius, nextLineBearing - 90, nextLineBearing + 90, units, resolution, true).geometry.coordinates); + lineOffset.push([]); + lineOffset[0].push.apply(lineOffset,[currentBufferPoint.geometry.coordinates]); // Add first buffer point in order to close ring + lineOffset[0].push.apply(lineOffset,lineOffsetOneSide(line, radius, units, resolution, false, true).geometry.coordinates); + lineOffset[0].push.apply(lineOffset,arc(previousLinePoint, radius, previousLineBearing + 90, previousLineBearing - 90, units, resolution, true).geometry.coordinates); + lineOffset[0].push.apply(lineOffset,lineOffsetOneSide(line, radius, units, resolution, true, true).geometry.coordinates); + lineOffset[0].push.apply(lineOffset,arc(currentLinePoint, radius, nextLineBearing - 90, nextLineBearing + 90, units, resolution, true).geometry.coordinates); - return offsetToBuffer(helpers.polygon([lineOffset])); + return offsetToBuffer(helpers.polygon(lineOffset)); } else { @@ -115,7 +116,7 @@ function ringOffsetOneSide(ring, radius, units, resolution, reverse, right) { if (reverse === undefined) var reverse = false; if (right === undefined) var right = true; if (reverse) ring.geometry.coordinates = ring.geometry.coordinates.reverse(); - var coords = ring.geometry.coordinates; // ring is a linestring + var coords = ring.geometry.coordinates; // ring is a lineString var ringOffset = []; // situation at current point = point 0 From b0dc332d89ce218a161f5f11621bf38ff3e55b1e Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Fri, 10 Jun 2016 18:15:25 +0200 Subject: [PATCH 16/42] brackets fix and lineOffset fix fix --- index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 6f97e77..61855c5 100644 --- a/index.js +++ b/index.js @@ -44,7 +44,7 @@ function pointBuffer(pt, radius, units, resolution) { var spoke = destination(pt, radius, i*resMultiple, units); pointOffset[0].push(spoke.geometry.coordinates); } - if(!(pointOffset[0][0].equals(pointOffset[0][pointOffset[0].length-1])) { + if(!(pointOffset[0][0].equals(pointOffset[0][pointOffset[0].length-1]))) { pointOffset[0].push(pointOffset[0][0]); } return helpers.polygon(pointOffset) @@ -63,11 +63,11 @@ function lineBuffer(line, radius, units, resolution) { var previousLineBearing = bearing(helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-2]), helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-1])); lineOffset.push([]); - lineOffset[0].push.apply(lineOffset,[currentBufferPoint.geometry.coordinates]); // Add first buffer point in order to close ring - lineOffset[0].push.apply(lineOffset,lineOffsetOneSide(line, radius, units, resolution, false, true).geometry.coordinates); - lineOffset[0].push.apply(lineOffset,arc(previousLinePoint, radius, previousLineBearing + 90, previousLineBearing - 90, units, resolution, true).geometry.coordinates); - lineOffset[0].push.apply(lineOffset,lineOffsetOneSide(line, radius, units, resolution, true, true).geometry.coordinates); - lineOffset[0].push.apply(lineOffset,arc(currentLinePoint, radius, nextLineBearing - 90, nextLineBearing + 90, units, resolution, true).geometry.coordinates); + lineOffset[0].push.apply(lineOffset[0],[currentBufferPoint.geometry.coordinates]); // Add first buffer point in order to close ring + lineOffset[0].push.apply(lineOffset[0],lineOffsetOneSide(line, radius, units, resolution, false, true).geometry.coordinates); + lineOffset[0].push.apply(lineOffset[0],arc(previousLinePoint, radius, previousLineBearing + 90, previousLineBearing - 90, units, resolution, true).geometry.coordinates); + lineOffset[0].push.apply(lineOffset[0],lineOffsetOneSide(line, radius, units, resolution, true, true).geometry.coordinates); + lineOffset[0].push.apply(lineOffset[0],arc(currentLinePoint, radius, nextLineBearing - 90, nextLineBearing + 90, units, resolution, true).geometry.coordinates); return offsetToBuffer(helpers.polygon(lineOffset)); From 78432fec7c9c0839e676edd76564bffb99837d8c Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Fri, 10 Jun 2016 18:19:13 +0200 Subject: [PATCH 17/42] commented winding function --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 61855c5..00bc729 100644 --- a/index.js +++ b/index.js @@ -199,6 +199,7 @@ function offsetToBuffer(polygonOffset) { return difference(unionWithWindingOne, unionWithWindingZero); } +// This function awaits possible future use function winding(poly){ // compute winding of first ring var coords = poly.geometry.coordinates[0]; From a5bacabcbbbe551a7b05e6a120184598b9013bf5 Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Fri, 10 Jun 2016 18:24:25 +0200 Subject: [PATCH 18/42] added rewind function --- index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/index.js b/index.js index 00bc729..bbd3acc 100644 --- a/index.js +++ b/index.js @@ -208,6 +208,17 @@ function winding(poly){ return (coords[(leftVtx-1).mod(coords.length-1)][1] > coords[(leftVtx+1).mod(coords.length-1)][1]) ? 1 : -1; } +// This function awaits possible future use +function rewind(poly){ + // outer ring to winding +1, inner rings to winding -1 + if (winding(poly.geometry.coordinates[0]) == -1) poly.geometry.coordinates[0] = poly.geometry.coordinates[0].reverse(); + for (var i = 1; i < poly.geometry.coordinates.length; i++) { + if (winding(poly.geometry.coordinates[i]) == 1) poly.geometry.coordinates[i] = poly.geometry.coordinates[i].reverse(); + } + + return poly +} + // Function to compare Arrays of numbers. From http://stackoverflow.com/questions/7837456/how-to-compare-arrays-in-javascript // Warn if overriding existing method From 3a0199fac5bc94e8e0eb91ee81a3787b223d1c9c Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Fri, 10 Jun 2016 18:51:23 +0200 Subject: [PATCH 19/42] automatically rewind polygons --- index.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index bbd3acc..f0c9a69 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ var union = require('turf-union'); var difference = require('turf-difference'); module.exports = function(feature, radius, units, resolution){ - if (!resolution) resolution = 32; + if (!resolution) resolution = 32; // Same value as JSTS if (radius <= 0) throw new Error("The buffer radius must be positive"); var geom = feature.geometry; if (geom === null) return feature; @@ -81,6 +81,7 @@ function lineBuffer(line, radius, units, resolution) { } function polygonBuffer(poly, radius, units, resolution) { + poly = rewind(poly); var polygonOffset = []; polygonOffset.push(ringOffsetOneSide(helpers.lineString(poly.geometry.coordinates[0]), radius, units, resolution, false, true).geometry.coordinates); @@ -156,7 +157,7 @@ function arc(pt, radius, bearing1, bearing2, units, resolution, right, shortcut) spoke = destination(pt, radius, bearing, units); arc.push(spoke.geometry.coordinates); } - // The value of bearing is independent of bearing1 and bearing2, such that multiple arcs with the same centerpoint coincide, instead of zigzag overlapping + // The value of bearing is independent of bearing1 and bearing2, such that multiple arcs with the same centerpoint coincide, instead of zigzag overlapping. This made sense at one point, but doesn't anymore and more over increases the chance of duplicate vertices if no shortcut is used. It could thus be simplified to equal bearing steps starting from bearing 1. bearing = bearing + Math.pow(-1, !right + 1) * resMultiple; step--; } @@ -180,6 +181,7 @@ function filterNetWinding(fc, filterFn) { } function unionFeatureCollection(fc) { + // Note: union takes a polygon, but return a polygon or multipolygon (which it can not take in). In case of buffes, however, it will always return a polygon if (fc.features.length == 0) return {type: "Feature", geometry: null}; var incrementalUnion = fc.features[0]; if (fc.features.length == 1) return incrementalUnion; @@ -211,11 +213,10 @@ function winding(poly){ // This function awaits possible future use function rewind(poly){ // outer ring to winding +1, inner rings to winding -1 - if (winding(poly.geometry.coordinates[0]) == -1) poly.geometry.coordinates[0] = poly.geometry.coordinates[0].reverse(); + if (winding(helpers.polygon([poly.geometry.coordinates[0]])) == -1) poly.geometry.coordinates[0] = poly.geometry.coordinates[0].reverse(); for (var i = 1; i < poly.geometry.coordinates.length; i++) { - if (winding(poly.geometry.coordinates[i]) == 1) poly.geometry.coordinates[i] = poly.geometry.coordinates[i].reverse(); + if (winding(helpers.polygon([poly.geometry.coordinates[i]])) == 1) poly.geometry.coordinates[i] = poly.geometry.coordinates[i].reverse(); } - return poly } From 8a506c9e928185ca804772126d03298df5e9c631 Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Sun, 12 Jun 2016 15:36:49 +0200 Subject: [PATCH 20/42] re-randomize arc points, remove duplicate vertices first --- index.js | 49 +++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/index.js b/index.js index f0c9a69..0d7ac77 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,6 @@ var simplepolygon = require('../simplepolygon'); +var plot = require('../node-tests/plot.js'); + var destination = require('turf-destination'); var bearing = require('turf-bearing'); var helpers = require('turf-helpers'); @@ -53,6 +55,8 @@ function pointBuffer(pt, radius, units, resolution) { function lineBuffer(line, radius, units, resolution) { var lineOffset = []; + line.geometry.coordinates = removeDuplicates(line.geometry.coordinates); + if (!(line.geometry.coordinates[0].equals(line.geometry.coordinates[line.geometry.coordinates.length-1]))) { // situation at current point = point 0 @@ -81,9 +85,15 @@ function lineBuffer(line, radius, units, resolution) { } function polygonBuffer(poly, radius, units, resolution) { - poly = rewind(poly); var polygonOffset = []; + poly = rewind(poly); + + poly.geometry.coordinates[0] = removeDuplicates(poly.geometry.coordinates[0]); + for (var i = 1; i < poly.geometry.coordinates.length; i++) { + poly.geometry.coordinates[i] = removeDuplicates(poly.geometry.coordinates[i]); + } + polygonOffset.push(ringOffsetOneSide(helpers.lineString(poly.geometry.coordinates[0]), radius, units, resolution, false, true).geometry.coordinates); for (var i = 1; i < poly.geometry.coordinates.length; i++) { polygonOffset.push(ringOffsetOneSide(helpers.lineString(poly.geometry.coordinates[i]), radius, units, resolution, false, true).geometry.coordinates); @@ -139,33 +149,27 @@ function arc(pt, radius, bearing1, bearing2, units, resolution, right, shortcut) if (shortcut === undefined) var shortcut = false; var arc = []; var resMultiple = 360/resolution; - if (right) { - var bearing = Math.floor(bearing1/resMultiple)*resMultiple; - } else { - var bearing = Math.ceil(bearing1/resMultiple)*resMultiple; - } var angle = (Math.pow(-1, right + 1) * (bearing1 - bearing2)).mod(360); - var numSteps = Math.ceil((Math.pow(-1, right + 1) * (bearing - bearing2)).mod(360)/resMultiple); - var step = numSteps; + var numSteps = Math.floor(angle/resMultiple); + var step = numSteps; // Counting steps first is easier than checking angle (angle involves checking 'right', 'mod(360)', lefthandedness of bearings + var bearing = bearing1; // Add spoke for bearing1 var spoke = destination(pt, radius, bearing1, units); arc.push(spoke.geometry.coordinates); + // Add spokes for all bearings between bearing1 to bearing2 + // But don't add spokes if the angle is reflex and the shortcut preference is set. In that case, just add bearing1 and bearing2. This prevents double, zigzag-overlapping arcs, and potentially non-unique vertices, when a lineOffsetOneSide is run on both sides. if (!(angle > 180 && shortcut)) { while (step) { - // Only add spokes for bearings different than the first and last - if (!(bearing == bearing1) || (bearing == bearing2)) { - spoke = destination(pt, radius, bearing, units); - arc.push(spoke.geometry.coordinates); - } - // The value of bearing is independent of bearing1 and bearing2, such that multiple arcs with the same centerpoint coincide, instead of zigzag overlapping. This made sense at one point, but doesn't anymore and more over increases the chance of duplicate vertices if no shortcut is used. It could thus be simplified to equal bearing steps starting from bearing 1. bearing = bearing + Math.pow(-1, !right + 1) * resMultiple; + spoke = destination(pt, radius, bearing, units); + arc.push(spoke.geometry.coordinates); step--; } } - // Only add spoke for bearing2 if it's not a straight line (equivalently: angle == 0) - if (!((bearing == bearing1) && (bearing1 == bearing2))) { - spoke = destination(pt, radius, bearing2, units); - arc.push(spoke.geometry.coordinates); + // Add spoke for bearing 2, but only if this spoke has not been added yet. Do this by checking the destination point, since slightly different bearings can create equal destination points. + var spokeBearing2 = destination(pt, radius, bearing2, units); + if (!spokeBearing2.geometry.coordinates.equals(spoke.geometry.coordinates)) { + arc.push(spokeBearing2.geometry.coordinates); } return helpers.lineString(arc) } @@ -220,6 +224,15 @@ function rewind(poly){ return poly } +function removeDuplicates(arr) { + for (var i = arr.length-1; i > 0; i--) { + if (arr[i].equals(arr[i-1])) { + arr.splice(i,1); + } + } + return arr; +} + // Function to compare Arrays of numbers. From http://stackoverflow.com/questions/7837456/how-to-compare-arrays-in-javascript // Warn if overriding existing method From 99a1f3563f4af244388d504487815c820132202e Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Sun, 12 Jun 2016 17:26:04 +0200 Subject: [PATCH 21/42] added test --- fixtures/multiLineString.geojson | 37 ++++++++++ fixtures/multiPolygon.geojson | 113 ++++++++++++++++++++++++++++++ fixtures/out/line.geojson | 1 + fixtures/out/multiline.geojson | 1 + fixtures/out/multipoint.geojson | 2 +- fixtures/out/multipolygon.geojson | 1 + fixtures/out/point.geojson | 2 +- fixtures/out/polygon.geojson | 1 + test.js | 48 ++++++++----- 9 files changed, 187 insertions(+), 19 deletions(-) create mode 100644 fixtures/multiLineString.geojson create mode 100644 fixtures/multiPolygon.geojson create mode 100644 fixtures/out/line.geojson create mode 100644 fixtures/out/multiline.geojson create mode 100644 fixtures/out/multipolygon.geojson create mode 100644 fixtures/out/polygon.geojson diff --git a/fixtures/multiLineString.geojson b/fixtures/multiLineString.geojson new file mode 100644 index 0000000..60d5690 --- /dev/null +++ b/fixtures/multiLineString.geojson @@ -0,0 +1,37 @@ +{ + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiLineString", + "coordinates": [ + [ + [ + 3.70513916015625, + 51.03945105265764 + ], + [ + 3.71063232421875, + 51.06545683812254 + ], + [ + 3.7278421020507812, + 51.04279701362964 + ], + [ + 3.746038208007812, + 51.0584442677861 + ] + ], + [ + [ + 3.7441062927246094, + 51.04387630433032 + ], + [ + 3.6912345886230464, + 51.059631085129986 + ] + ] + ] + } + } \ No newline at end of file diff --git a/fixtures/multiPolygon.geojson b/fixtures/multiPolygon.geojson new file mode 100644 index 0000000..09eaab2 --- /dev/null +++ b/fixtures/multiPolygon.geojson @@ -0,0 +1,113 @@ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ + 3.7075424194335938, + 51.03966692839972 + ], + [ + 3.733978271484375, + 51.02995152419996 + ], + [ + 3.7751770019531254, + 51.045279344649146 + ], + [ + 3.76556396484375, + 51.08907598780727 + ], + [ + 3.7140655517578125, + 51.09144802136697 + ], + [ + 3.742904663085937, + 51.06168097070514 + ], + [ + 3.68316650390625, + 51.061465197550305 + ], + [ + 3.7075424194335938, + 51.03966692839972 + ] + ], + [ + [ + 3.7199020385742188, + 51.04938029577453 + ], + [ + 3.730201721191406, + 51.05585474252802 + ], + [ + 3.7408447265625, + 51.04333666212316 + ], + [ + 3.720245361328125, + 51.04204149517769 + ], + [ + 3.7199020385742188, + 51.04938029577453 + ] + ] + ], + [ + [ + [ + 3.8119125366210938, + 51.03966692839972 + ], + [ + 3.8376617431640625, + 51.05089108097961 + ], + [ + 3.7902832031250004, + 51.10201287469917 + ], + [ + 3.773117065429687, + 51.0662119746483 + ], + [ + 3.8119125366210938, + 51.03966692839972 + ] + ], + [ + [ + 3.8002395629882812, + 51.06427017012091 + ], + [ + 3.8005828857421875, + 51.068585180672635 + ], + [ + 3.8174057006835933, + 51.06405440903407 + ], + [ + 3.8129425048828125, + 51.05002778118271 + ], + [ + 3.8002395629882812, + 51.06427017012091 + ] + ] + ] + ] + } + } diff --git a/fixtures/out/line.geojson b/fixtures/out/line.geojson new file mode 100644 index 0000000..d45fe57 --- /dev/null +++ b/fixtures/out/line.geojson @@ -0,0 +1 @@ +{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.6586143206309583,51.016573022446345],[3.659092126750731,51.018309626832234],[3.6600993676097535,51.01995421620466],[3.661597381140627,51.021443576931546],[3.6635286258876567,51.022720456224995],[3.6658188882723826,51.02373576499673],[3.6826783020922234,51.029758410321854],[3.675050482833044,51.03030075900952],[3.673461589505872,51.03047025970008],[3.6708037456286027,51.03102895648357],[3.6683701976277754,51.031902963851174],[3.666254434096599,51.03305871086328],[3.664537754016948,51.03445180198013],[3.663286143801658,51.036028720240566],[3.662547739141385,51.03772888103503],[3.6623509695488514,51.03948695798198],[3.662703457759199,51.04123539188418],[3.663591717508776,51.042906986576064],[3.664981662719432,51.04443749196857],[3.6779154455560366,51.05590380317674],[3.6655945601914683,51.07121148484877],[3.6646501010667047,51.07269899749903],[3.6641141592902695,51.074428953171484],[3.6641256470277743,51.076191363760806],[3.664684184538928,51.077918500659045],[3.665768364386251,51.079543983396746],[3.6673365654528287,51.08100533175784],[3.6693285458192277,51.082246368963524],[3.6716677542929714,51.0832193832522],[3.6742642722999914,51.083886964369974],[3.6770182730734353,51.084223443946506],[3.712228816705203,51.08632396695713],[3.7243632262946176,51.09708160209229],[3.725273049559862,51.09780530912813],[3.727320785049455,51.09901049987022],[3.7297036792483076,51.09994161246693],[3.7323301315650204,51.10056284736865],[3.7350991624536887,51.100850318059486],[3.7379043010769353,51.100792970953854],[3.740637685837568,51.100393011131516],[3.7431942188381635,51.099665817405366],[3.7454756131818954,51.098639350014636],[3.7473941762912695,51.097353073905595],[3.748876182908117,51.095856439315966],[3.7498647076927347,51.09420697848032],[3.7503218086632746,51.09246809204847],[3.7507233048147324,51.08862039722229],[3.792717840902223,51.091125626629726],[3.793642970164616,51.09116141593518],[3.7964423149137536,51.09103978749103],[3.799150047178124,51.09057742012819],[3.8016620570439357,51.089792092190784],[3.803881772135169,51.0887139988731],[3.805723874507378,51.087384589476585],[3.8071175817313714,51.085854971675886],[3.808009365717739,51.084183944553],[3.8111252919617007,51.075643200345425],[3.8144444540888722,51.07682889615187],[3.8170063369502487,51.07754684811742],[3.819741986377078,51.07793693315809],[3.8225462172044824,51.077984152151004],[3.825311202760056,51.077686689457686],[3.8279306279754177,51.07705598285647],[3.830303783884625,51.07611628301165],[3.83233944480781,51.07490371955904],[3.8339593781561634,51.07346490999887],[3.8351013513616232,51.07185516526167],[3.8357215203027217,51.07013636135589],[3.8357961079204634,51.0683745593127],[3.8353223094755826,51.06663746522596],[3.8343183909513177,51.064991828189974],[3.832822978248621,51.06350087615373],[3.8308935658363508,51.06222188808001],[3.828604303228536,51.06120399540906],[3.817800975960516,51.057345171128894],[3.827219585120492,51.03152879251914],[3.82752980176853,51.030279298008864],[3.8274914724539033,51.02851703750731],[3.826907263180253,51.026793339667435],[3.8257996809856882,51.02517443733476],[3.824211331943632,51.023722529960885],[3.8222032774001464,51.02249339545404],[3.8198526840804075,51.0215342494172],[3.8172498588757513,51.02088193362307],[3.8144947822215127,51.020561502894175],[3.8116932727039083,51.02058526428451],[3.7574199132482016,51.02444417654771],[3.758879605459214,51.01045537454812],[3.758881426459545,51.01043762312298],[3.7587842210317888,51.008676259292656],[3.7581427829982146,51.00696066942304],[3.7569818174977034,51.00535677404485],[3.7553459801312385,51.00392619536408],[3.753298154735996,51.00272389137752],[3.7509170338286832,51.00179604665926],[3.7482940951497277,51.00117830044946],[3.7455300903971365,51.00089437969232],[3.742731180450636,51.00095518915433],[3.6709764784540857,51.00700318847275],[3.669059151051055,51.00724922976753],[3.666445557879873,51.00788302756216],[3.6640786037239828,51.00882542658476],[3.6620492229714716,51.01004022844987],[3.660435400516278,51.011480768323615],[3.659299175314227,51.01309170528695],[3.6586842531212866,51.01481114628271],[3.6586143206309583,51.016573022446345]],[[3.7525963294499016,51.07067046876077],[3.754199390603992,51.05530770604264],[3.78515381236269,51.06636547504246],[3.782919572755461,51.0724794282812],[3.7525963294499016,51.07067046876077]],[[3.7918389150641683,51.048071821496634],[3.773207730324847,51.041416976534954],[3.794832694022288,51.03987940359399],[3.7918389150641683,51.048071821496634]],[[3.724406715063373,51.06602525278393],[3.7112257837492377,51.0543450560593],[3.7184952733827568,51.04530712842166],[3.7249247041392595,51.044849984590336],[3.726567737676786,51.045436921263196],[3.724406715063373,51.06602525278393]]]}},{"type":"Feature","properties":{},"geometry":{"type":"LineString","coordinates":[[3.8215255737304688,51.069016659603896],[3.6728668212890625,51.01591456640252],[3.7446212768554688,51.0098665670808],[3.736038208007812,51.09187928712511],[3.676643371582031,51.03923517590972],[3.8132858276367188,51.029519681180965],[3.7940597534179683,51.082174834773625],[3.6783599853515625,51.07527265208853],[3.7229919433593746,51.01980214947295]]}}]} \ No newline at end of file diff --git a/fixtures/out/multiline.geojson b/fixtures/out/multiline.geojson new file mode 100644 index 0000000..9efeb6d --- /dev/null +++ b/fixtures/out/multiline.geojson @@ -0,0 +1 @@ +{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.6908709203873524,51.038871791996094],[3.6913250519741525,51.037132654681805],[3.6923099732994733,51.03548263837015],[3.6937877880190757,51.03398513951991],[3.6957016772138216,51.032697688821315],[3.697978087062685,51.031669742965285],[3.700529556098821,51.03094078699036],[3.7032580733055553,51.030538819685994],[3.7060588384598123,51.03047927983281],[3.708824281153005,51.030764454206846],[3.7114481853166645,51.03138338989874],[3.7138297621700467,51.03231231428764],[3.7158775164179634,51.03351554667293],[3.7175127581965555,51.034946866824974],[3.718336724659222,51.036086642373725],[3.7205380002362536,51.035068254536824],[3.723076093092268,51.03432080866716],[3.7257972417896177,51.03389904323796],[3.7285969286370704,51.03381915746115],[3.7313676245640996,51.034084219549094],[3.7340029120732185,51.0346840490715],[3.736401565860018,51.035595607308025],[3.738471435644681,51.036783880728095],[3.739385305991402,51.037491604950134],[3.757585311803368,51.05313885878894],[3.75901025785188,51.05465670425302],[3.7599368160758155,51.05632011891863],[3.7603293311783292,51.05806519078144],[3.7601726597800265,51.05982486308197],[3.75947276138718,51.06153151043965],[3.7582564787028594,51.063119537985614],[3.7565705143024637,51.06452790356173],[3.754479641745628,51.065702465842634],[3.75206421897527,51.06659806779266],[3.7494170991628986,51.06718027495988],[3.7466400578722934,51.06742670135814],[3.743839874534929,51.06732787159009],[3.741124219943501,51.0668875857995],[3.738597509182114,51.06612277330307],[3.736356880787111,51.06506284057693],[3.734488457911094,51.06374853887263],[3.73043054785144,51.060258299402456],[3.72354443620072,51.06932845597228],[3.7220944817489365,51.07083710681721],[3.7202038913635147,51.07213899428092],[3.7179453137269123,51.073184068248075],[3.7154055630211555,51.073932148593066],[3.7126822799221655,51.074354472100595],[3.709880173311074,51.074434800090984],[3.7071069880473577,51.074170043838464],[3.7044693550288237,51.07357038353831],[3.702068684446381,51.07265887620985],[3.699997261422613,51.07147056773736],[3.6983346951776,51.070051143460915],[3.6971448588435143,51.06845516957308],[3.696473437656884,51.066743993351565],[3.696450431114133,51.06663967164072],[3.6909650889196204,51.040633222435375],[3.6908709203873524,51.038871791996094]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.750236989394816,51.05199864633811],[3.6973673718607785,51.067753427047556],[3.694727904342417,51.06834931204938],[3.6919541157655464,51.06861009994649],[3.689152660276175,51.06852576313085],[3.6864312576647733,51.068099544472695],[3.683894544396781,51.067347832416324],[3.6816400441914365,51.06629952979493],[3.6797544142626886,51.06499494083164],[3.678310112387574,51.063484219446536],[3.6773626133016775,51.06182543893083],[3.676948281254109,51.060082357616906],[3.6770829798036613,51.05832196680558],[3.6777614711746285,51.056611915467236],[3.67895762688609,51.055017910814826],[3.680625440137984,51.053601194599274],[3.682700799789037,51.05241619190037],[3.6851039568480197,51.051508422421925],[3.7379777455759893,51.03575364171242],[3.740615479755015,51.03515797335935],[3.7433872891760087,51.03489728509951],[3.7461867136453204,51.034981589372066],[3.7489062341505015,51.035407648261184],[3.7514413954299113,51.03615909764593],[3.7536948118549995,51.037207074682534],[3.755579903939555,51.03851132471521],[3.7570242227916606,51.04002174542293],[3.7579722351707914,51.04168030928996],[3.7583874619886966,51.043423290966665],[3.758253887406625,51.0451837143211],[3.75757658327989,51.04689392542848],[3.7563815235888725,51.04848819275247],[3.7547145945655904,51.04990523455278],[3.7526398372922185,51.0510905761823],[3.750236989394816,51.05199864633811]]]}},{"type":"Feature","properties":{},"geometry":{"type":"MultiLineString","coordinates":[[[3.746038208007812,51.0584442677861],[3.727842102050781,51.04279701362964],[3.71063232421875,51.06545683812254],[3.70513916015625,51.03945105265764]],[[3.6912345886230464,51.059631085129986],[3.7441062927246094,51.04387630433032]]]}}]} \ No newline at end of file diff --git a/fixtures/out/multipoint.geojson b/fixtures/out/multipoint.geojson index 363754e..480a62d 100644 --- a/fixtures/out/multipoint.geojson +++ b/fixtures/out/multipoint.geojson @@ -1 +1 @@ -{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-89.43283081054688,43.2155805225742],[-89.4203649828276,43.21529434166688],[-89.40794870129314,43.21443693640974],[-89.39563131102858,43.21301171457976],[-89.38346175580287,43.21102434043423],[-89.37148837961438,43.20848271172525],[-89.35975873086646,43.2053969276614],[-89.34831937002741,43.201779247957155],[-89.3372156816084,43.197644043149516],[-89.32649169127056,43.193007736398606],[-89.31618988884263,43.18788873702618],[-89.30635105799922,43.18230736608081],[-89.29701411331347,43.17628577425214],[-89.28821594535763,43.16984785248842],[-89.2799912744836,43.16301913570187],[-89.27237251386867,43.1558266999738],[-89.26538964236474,43.14829905369746],[-89.25907008763885,43.14046602312012],[-89.25343862004183,43.13235863276716],[-89.248517257588,43.12400898124947],[-89.24432518237657,43.11545011297191],[-89.24087866872948,43.106715886274706],[-89.23819102326787,43.0978408385505],[-89.2362725370932,43.08886004888918],[-89.23513045018676,43.07980899880858],[-89.23476892808769,43.070723431633446],[-89.23518905085801,43.06163921108629],[-89.2363888142921,43.052592179653224],[-89.23836314327995,43.0436180172847],[-89.24110391718533,43.03475210098568],[-89.24460000705486,43.026029365842554],[-89.24883732443108,43.01748416802467],[-89.25379888150057,43.00915015028674],[-89.25946486226952,43.00106011048549],[-89.26581270442281,42.99324587360888],[-89.27281719148706,42.98573816779936],[-89.28045055488727,42.97856650483523],[-89.28868258545575,42.97175906551366],[-89.297480753925,42.96534259035911],[-89.30681033991088,42.959342276057946],[-89.31663456886884,42.95378167799767],[-89.32691475648501,42.94868261926423],[-89.33761045994565,42.94406510642636],[-89.34867963551004,42.93994725240959],[-89.3600788017979,42.936345206736085],[-89.37176320818861,42.93327309337893],[-89.38368700771747,42.930742956451574],[-89.39580343384489,42.928764713924984],[-89.40806498046554,42.927346119535606],[-89.42042358451761,42.92649273301858],[-89.43283081054688,42.92620789877076],[-89.44523803657613,42.92649273301858],[-89.45759664062821,42.927346119535606],[-89.46985818724886,42.928764713924984],[-89.48197461337628,42.930742956451574],[-89.49389841290514,42.93327309337893],[-89.50558281929585,42.936345206736085],[-89.51698198558371,42.93994725240959],[-89.5280511611481,42.94406510642636],[-89.53874686460874,42.94868261926423],[-89.5490270522249,42.95378167799767],[-89.55885128118287,42.959342276057946],[-89.56818086716875,42.96534259035911],[-89.576979035638,42.97175906551366],[-89.58521106620648,42.97856650483523],[-89.59284442960667,42.98573816779936],[-89.59984891667094,42.99324587360888],[-89.60619675882421,43.00106011048549],[-89.61186273959318,43.00915015028674],[-89.61682429666267,43.01748416802467],[-89.62106161403888,43.026029365842554],[-89.62455770390841,43.03475210098568],[-89.62729847781378,43.0436180172847],[-89.62927280680165,43.052592179653224],[-89.63047257023574,43.06163921108629],[-89.63089269300605,43.070723431633446],[-89.63053117090699,43.07980899880858],[-89.62938908400055,43.08886004888918],[-89.62747059782588,43.0978408385505],[-89.62478295236427,43.106715886274706],[-89.62133643871718,43.11545011297191],[-89.61714436350573,43.12400898124947],[-89.61222300105192,43.13235863276716],[-89.60659153345489,43.14046602312012],[-89.60027197872901,43.14829905369746],[-89.59328910722506,43.1558266999738],[-89.58567034661013,43.16301913570187],[-89.57744567573612,43.16984785248842],[-89.56864750778028,43.17628577425214],[-89.55931056309453,43.18230736608081],[-89.54947173225112,43.18788873702618],[-89.53916992982317,43.193007736398606],[-89.52844593948535,43.197644043149516],[-89.51734225106634,43.201779247957155],[-89.50590289022729,43.2053969276614],[-89.49417324147937,43.20848271172525],[-89.48219986529087,43.21102434043423],[-89.47003031006516,43.21301171457976],[-89.4577129198006,43.21443693640974],[-89.44529663826613,43.21529434166688],[-89.43283081054688,43.2155805225742]]]},"properties":{}},{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-89.37103271484375,43.22924762334563],[-89.35856409230236,43.22896144211477],[-89.3461450272214,43.22810403589212],[-89.33382487591311,43.226678812469984],[-89.3216525932771,43.224691436130996],[-89.30967653429799,43.222149804662024],[-89.2979442581744,43.219064017315475],[-89.2865023359325,43.21544633385796],[-89.27539616235985,43.211311124886],[-89.2646697730689,43.2066748136258],[-89.25436566747311,43.201555809470634],[-89.24452463842573,43.19597443354489],[-89.23518560923462,43.189952836617095],[-89.22638547872764,43.18351490971629],[-89.21815897500002,43.176686187836005],[-89.2105385184297,43.16949374713814],[-89.20355409449866,43.16196609609449],[-89.19723313690842,43.154133061027665],[-89.19160042142623,43.146025666533944],[-89.18667797084545,43.137676011289486],[-89.1824849713903,43.12911713975788],[-89.17903770084044,43.12038291033055],[-89.17634946859654,43.11150786044303],[-89.17443056785383,43.102527069219086],[-89.1732882399969,43.09347601820099],[-89.1729266512759,43.08439045072796],[-89.17334688177257,43.07530623052693],[-89.17454692661335,43.0662592000783],[-89.17652170933926,43.0572850393167],[-89.17926310729301,43.0484191252215],[-89.18275998883982,43.03969639284415],[-89.18699826219424,43.03115119831019],[-89.19196093558475,43.02281718432244],[-89.19762818844784,43.014727148678446],[-89.2039774533075,43.006912916300585],[-89.21098350796103,42.99940521526047],[-89.21861857755987,42.992233557261294],[-89.22685244614459,42.98542612302216],[-89.23565257716567,42.97900965298758],[-89.24498424249556,42.97300934376353],[-89.25481065941544,42.96744875065776],[-89.26509313503823,42.96234969667845],[-89.2757912176107,42.957732188319746],[-89.28686285412017,42.95361433843693],[-89.2982645536169,42.950012296487365],[-89.30995155564861,42.94694018638575],[-89.32187800319296,42.94441005219454],[-89.3339971194637,42.94243181184184],[-89.34626138795697,42.941013219030005],[-89.35862273509811,42.94015983346949],[-89.37103271484375,42.93987499954219],[-89.38344269458939,42.94015983346949],[-89.39580404173051,42.941013219030005],[-89.40806831022377,42.94243181184184],[-89.42018742649454,42.94441005219454],[-89.43211387403889,42.94694018638575],[-89.44380087607058,42.950012296487365],[-89.45520257556731,42.95361433843693],[-89.4662742120768,42.957732188319746],[-89.47697229464924,42.96234969667845],[-89.48725477027206,42.96744875065776],[-89.49708118719194,42.97300934376353],[-89.50641285252182,42.97900965298758],[-89.5152129835429,42.98542612302216],[-89.52344685212763,42.992233557261294],[-89.53108192172645,42.99940521526047],[-89.53808797637998,43.006912916300585],[-89.54443724123966,43.014727148678446],[-89.55010449410275,43.02281718432244],[-89.55506716749325,43.03115119831019],[-89.55930544084768,43.03969639284415],[-89.56280232239446,43.0484191252215],[-89.56554372034824,43.0572850393167],[-89.56751850307415,43.0662592000783],[-89.56871854791493,43.07530623052693],[-89.56913877841157,43.08439045072796],[-89.5687771896906,43.09347601820099],[-89.56763486183367,43.102527069219086],[-89.56571596109096,43.11150786044303],[-89.56302772884703,43.12038291033055],[-89.5595804582972,43.12911713975788],[-89.55538745884205,43.137676011289486],[-89.55046500826126,43.146025666533944],[-89.54483229277908,43.154133061027665],[-89.53851133518883,43.16196609609449],[-89.53152691125779,43.16949374713814],[-89.52390645468748,43.176686187836005],[-89.51567995095985,43.18351490971629],[-89.50687982045288,43.189952836617095],[-89.49754079126177,43.19597443354489],[-89.48769976221439,43.201555809470634],[-89.4773956566186,43.2066748136258],[-89.46666926732763,43.211311124886],[-89.455563093755,43.21544633385796],[-89.4441211715131,43.219064017315475],[-89.43238889538948,43.222149804662024],[-89.42041283641039,43.224691436130996],[-89.40824055377439,43.226678812469984],[-89.3959204024661,43.22810403589212],[-89.38350133738514,43.22896144211477],[-89.37103271484375,43.22924762334563]]]},"properties":{}},{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-89.329833984375,43.251935799838414],[-89.31736071793199,43.25164961807011],[-89.30493702768513,43.2507922102437],[-89.29261228860199,43.24936698417697],[-89.28043547407688,43.247379604194485],[-89.26845495734949,43.24483796814104],[-89.25671831555572,43.24175217534179],[-89.24527213726526,43.2381344856499],[-89.23416183434082,43.23399926976083],[-89.22343145893005,43.2293629510105],[-89.21312352637264,43.224243938910966],[-89.20327884477304,43.21866255471258],[-89.19393635195287,43.21264094931491],[-89.1851329604575,43.20620301388116],[-89.17690341124862,43.19937428353995],[-89.16928013666875,43.19218183458703],[-89.16229313321652,43.18465417562469],[-89.15596984462024,43.17682113310068],[-89.15033505564705,43.168713731728964],[-89.14541079703115,43.16036407029419],[-89.14121626185104,43.151805193357475],[-89.13776773363148,43.14307095939531],[-89.13507852639151,43.13419590591443],[-89.13315893680534,43.125215112094956],[-89.1320162085893,43.11616405951963],[-89.13165450917484,43.107078491551825],[-89.13207491867621,43.09799427192578],[-89.13327543111006,43.088947243112344],[-89.13525096777586,43.07997308501994],[-89.13799340265803,43.07110717458541],[-89.14149159966614,43.06238444680214],[-89.14573146148494,43.053839257722935],[-89.15069598976609,43.045505249964414],[-89.15636535635286,43.0374152212258],[-89.162716985194,43.029600996320575],[-89.1697256445667,43.02209330320264],[-89.17736354919822,43.014921653450486],[-89.18560047184404,43.00811422765345],[-89.19440386385462,43.00169776612339],[-89.20373898423591,42.99569746533263],[-89.21356903668682,42.99013688045649],[-89.22385531407492,42.98503783437398],[-89.23455734979298,42.98042033345535],[-89.24563307542222,42.97630249043921],[-89.25703898411216,42.972700454675255],[-89.26873029907415,42.96962834998123],[-89.28066114657427,42.96709822033485],[-89.29278473280034,42.965119983593034],[-89.30505352397022,42.96370139340158],[-89.31741942904118,42.96284800942988],[-89.329833984375,42.962563176034955],[-89.34224853970882,42.96284800942988],[-89.35461444477978,42.96370139340158],[-89.36688323594966,42.965119983593034],[-89.37900682217574,42.96709822033485],[-89.39093766967585,42.96962834998123],[-89.40262898463786,42.972700454675255],[-89.41403489332777,42.97630249043921],[-89.42511061895702,42.98042033345535],[-89.43581265467509,42.98503783437398],[-89.44609893206318,42.99013688045649],[-89.4559289845141,42.99569746533263],[-89.46526410489538,43.00169776612339],[-89.47406749690595,43.00811422765345],[-89.4823044195518,43.014921653450486],[-89.4899423241833,43.02209330320264],[-89.496950983556,43.029600996320575],[-89.50330261239714,43.0374152212258],[-89.50897197898392,43.045505249964414],[-89.51393650726507,43.053839257722935],[-89.51817636908386,43.06238444680214],[-89.52167456609197,43.07110717458541],[-89.52441700097414,43.07997308501994],[-89.52639253763994,43.088947243112344],[-89.52759305007379,43.09799427192578],[-89.52801345957516,43.107078491551825],[-89.5276517601607,43.11616405951963],[-89.52650903194464,43.125215112094956],[-89.52458944235849,43.13419590591443],[-89.52190023511852,43.14307095939531],[-89.51845170689896,43.151805193357475],[-89.51425717171884,43.16036407029419],[-89.50933291310295,43.168713731728964],[-89.50369812412977,43.17682113310068],[-89.49737483553348,43.18465417562469],[-89.49038783208124,43.19218183458703],[-89.48276455750138,43.19937428353995],[-89.4745350082925,43.20620301388116],[-89.46573161679713,43.21264094931491],[-89.45638912397696,43.21866255471258],[-89.44654444237736,43.224243938910966],[-89.43623650981993,43.2293629510105],[-89.42550613440918,43.23399926976083],[-89.41439583148474,43.2381344856499],[-89.40294965319427,43.24175217534179],[-89.39121301140051,43.24483796814104],[-89.3792324946731,43.247379604194485],[-89.36705568014801,43.24936698417697],[-89.35473094106487,43.2507922102437],[-89.34230725081801,43.25164961807011],[-89.329833984375,43.251935799838414]]]},"properties":{}},{"type":"Feature","properties":{},"geometry":{"type":"MultiPoint","coordinates":[[-89.43283081054688,43.07089421067248],[-89.37103271484375,43.08456131144392],[-89.329833984375,43.107249487936684]]}}]} \ No newline at end of file +{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.7276268005371094,51.06560042946088],[3.7304177744418525,51.06542764833891],[3.7331014322719107,51.06491594863794],[3.7355745912680947,51.064085005463895],[3.7377421750555526,51.06296676761904],[3.739520872592203,51.06160422737134],[3.740842341591027,51.060049765389394],[3.741655833033616,51.05836313488773],[3.741930136198847,51.05660916289145],[3.7416547702584415,51.054855257332854],[3.7408403778385426,51.053168816029746],[3.739518306825894,51.051614637203436],[3.7377393978900586,51.050252430960604],[3.7355720255016878,51.04913452712063],[3.7330994685192875,51.04830386710224],[3.73041671166658,51.047792356599835],[3.7276268005371094,51.047619641915574],[3.724836889407639,51.047792356599835],[3.722154132554931,51.04830386710224],[3.719681575572531,51.04913452712063],[3.71751420318416,51.050252430960604],[3.715735294248325,51.051614637203436],[3.7144132232356757,51.053168816029746],[3.7135988308157772,51.054855257332854],[3.7133234648753715,51.05660916289145],[3.7135977680406027,51.05836313488773],[3.7144112594831915,51.060049765389394],[3.7157327284820156,51.06160422737134],[3.717511426018666,51.06296676761904],[3.7196790098061236,51.064085005463895],[3.722152168802308,51.06491594863794],[3.7248358266323662,51.06542764833891],[3.7276268005371094,51.06560042946088]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.716640472412109,51.059557739214206],[3.719431082038513,51.059384958099415],[3.722114389610197,51.058873258418856],[3.724587225845964,51.05804231527536],[3.726754526786323,51.05692407746653],[3.728532992263004,51.05556153725485],[3.7298542889027426,51.054007075303446],[3.730667674298917,51.05232044482217],[3.730941941787947,51.05056647283305],[3.7306666118916287,51.04881256726728],[3.7298523258300236,51.04712612594375],[3.72853042738485,51.045571947086906],[3.7267517505821606,51.04420974080804],[3.7245846609677113,51.04309183693204],[3.7221124265373384,51.04226117688314],[3.7194300196311265,51.04174966636033],[3.716640472412109,51.041576951668915],[3.7138509251930913,51.04174966636033],[3.7111685182868794,51.04226117688314],[3.7086962838565065,51.04309183693204],[3.7065291942420573,51.04420974080804],[3.704750517439368,51.045571947086906],[3.7034286189941943,51.04712612594375],[3.702614332932589,51.04881256726728],[3.702339003036271,51.05056647283305],[3.7026132705253008,51.05232044482217],[3.7034266559214752,51.054007075303446],[3.7047479525612137,51.05556153725485],[3.7065264180378947,51.05692407746653],[3.708693718978254,51.05804231527536],[3.711166555214021,51.058873258418856],[3.713849862785705,51.059384958099415],[3.716640472412109,51.059557739214206]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.7492561340332027,51.04293627515394],[3.7520457422994267,51.04276349405885],[3.754728087050223,51.04225179443442],[3.757200036053871,51.04142085137491],[3.7593665594793086,51.04030261366514],[3.7611443870491494,51.03894007355252],[3.7624652098930422,51.03738561168505],[3.763278303779432,51.03569898125985],[3.7635524731984824,51.03394500929039],[3.763277242383212,51.03219110370489],[3.762463248688535,51.030504662325214],[3.761141824611932,51.028950483384406],[3.7593637859171976,51.02758827700651],[3.7571974736165554,51.02647037303149],[3.754726125845577,51.02563971289865],[3.752044680903109,51.02512820231977],[3.7492561340332027,51.02495548760865],[3.746467587163296,51.02512820231977],[3.7437861422208285,51.02563971289865],[3.74131479444985,51.02647037303149],[3.739148482149208,51.02758827700651],[3.7373704434544734,51.028950483384406],[3.736049019377871,51.030504662325214],[3.735235025683193,51.03219110370489],[3.7349597948679234,51.03394500929039],[3.7352339642869734,51.03569898125985],[3.736047058173363,51.03738561168505],[3.737367881017256,51.03894007355252],[3.7391457085870967,51.04030261366514],[3.7413122320125343,51.04142085137491],[3.7437841810161827,51.04225179443442],[3.7464665257669787,51.04276349405885],[3.7492561340332027,51.04293627515394]]]}},{"type":"Feature","properties":{},"geometry":{"type":"MultiPoint","coordinates":[[3.7276268005371094,51.05661003568822],[3.716640472412109,51.05056734544155],[3.7492561340332027,51.0339458813813]]}}]} \ No newline at end of file diff --git a/fixtures/out/multipolygon.geojson b/fixtures/out/multipolygon.geojson new file mode 100644 index 0000000..b6e379a --- /dev/null +++ b/fixtures/out/multipolygon.geojson @@ -0,0 +1 @@ +{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.6803055781507905,51.06145555810943],[3.6803575473737347,51.06180652667371],[3.6805174655777697,51.06214437932413],[3.680779189262147,51.06245613214903],[3.68113266192528,51.06272980402216],[3.6815643003183642,51.06295487712816],[3.6820575163647087,51.06312270127176],[3.6825933546995184,51.06322682641593],[3.6831512213192656,51.06326325065214],[3.7378306382680155,51.06346075172122],[3.711620474640772,51.09051278954986],[3.7115748072360093,51.09056160141862],[3.7113473261266856,51.090883830362095],[3.7112243011296537,51.09122774177523],[3.71121046226037,51.09158011966733],[3.7113063438072467,51.09192742239185],[3.711508263423456,51.092256303038596],[3.711808463283128,51.092554122387654],[3.7121954079313277,51.092809434706886],[3.712654227424106,51.0930124277118],[3.7131672887535063,51.09315529976419],[3.7137148736008445,51.09323255979597],[3.7142759363533058,51.09324123841548],[3.7657743386483107,51.09086920485579],[3.766288022418104,51.09081560331141],[3.7668144491360485,51.09069345104794],[3.7672928154663508,51.090509138677604],[3.767704736939327,51.09026974991328],[3.7680343834522643,51.08998448510474],[3.7682690876405154,51.089664307556475],[3.768399831560551,51.08932152210176],[3.7780101865721063,51.045524878997234],[3.778032716998368,51.04518136382425],[3.777947431367265,51.04483298094024],[3.7777556827259318,51.04450175263377],[3.777464841755237,51.04420040732483],[3.7770860864486435,51.0439405248574],[3.776633972374982,51.043732091597086],[3.735434760039935,51.028404271152844],[3.735229638266801,51.02833483213991],[3.734704110332295,51.028212358871336],[3.734150691917528,51.028156718351994],[3.7335906482420627,51.02817004857442],[3.733045499014854,51.02825183732417],[3.73253619181766,51.02839894185503],[3.706100037410384,51.038114346051714],[3.7060108638382894,51.0381484887072],[3.705569179936619,51.038365539348604],[3.7052033202144283,51.03863260087632],[3.6808263035311213,51.06043087000873],[3.6807962723567442,51.06045824293228],[3.6805292404765897,51.06076820932305],[3.6803635526321528,51.061104961299414],[3.6803055781507905,51.06145555810943]],[[3.7230138062675704,51.044022605650525],[3.736307962136751,51.04485846431389],[3.729497002181375,51.05286885990815],[3.722797264389476,51.04865747725591],[3.7230138062675704,51.044022605650525]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.7702690591424006,51.06638487908231],[3.7703774505440566,51.06673072019063],[3.7875414670873657,51.10253162020055],[3.787710736431538,51.10280268256536],[3.788005545439315,51.103102644726036],[3.7883878896656116,51.103360727491896],[3.7888430760148086,51.10356701211253],[3.78935361115175,51.1037135704487],[3.7898998738793854,51.10379476975848],[3.7904608694167163,51.10380748924982],[3.791015036553063,51.10375124006379],[3.7915410766088944,51.1036281840697],[3.7920187722895395,51.10344305074846],[3.792429764909248,51.10320295536389],[3.7927582600739647,51.10291712542141],[3.8401340669920425,51.0517953317495],[3.840284965542477,51.05160788622985],[3.8404570082217457,51.0512724025035],[3.840521627813269,51.05092226594181],[3.8404763434226505,51.05057093227391],[3.8403228977371286,51.05023190293085],[3.8400671896846164,51.04991820621216],[3.8397190474221126,51.04964189667777],[3.8392918504259734,51.04941359199372],[3.8135422489674324,51.038189439418375],[3.813399767346485,51.038131166858825],[3.812894710094598,51.037978237592355],[3.812351912540888,51.037890201579216],[3.8117922319344695,51.037870441619354],[3.81123717403883,51.037919716990224],[3.810708067050077,51.03803613428141],[3.8102252423267178,51.03821522012466],[3.809807253360191,51.038450093029454],[3.771010575109932,51.06499513926009],[3.7709086901554696,51.06506870093599],[3.7705961993451154,51.06536141326605],[3.7703805787326887,51.06568681261988],[3.7702701162357304,51.066032394633126],[3.7702690591424006,51.06638487908231]],[[3.8032352203277706,51.06591459171116],[3.803138312755336,51.06469756494578],[3.811654679869943,51.05514853734741],[3.8141449764644895,51.062976362300255],[3.8032352203277706,51.06591459171116]]]}},{"type":"Feature","properties":{},"geometry":{"type":"MultiPolygon","coordinates":[[[[3.7075424194335938,51.03966692839972],[3.733978271484375,51.02995152419996],[3.7751770019531254,51.045279344649146],[3.76556396484375,51.08907598780727],[3.7140655517578125,51.09144802136697],[3.742904663085937,51.06168097070514],[3.68316650390625,51.061465197550305],[3.7075424194335938,51.03966692839972]],[[3.7199020385742188,51.04938029577453],[3.730201721191406,51.05585474252802],[3.7408447265625,51.04333666212316],[3.720245361328125,51.04204149517769],[3.7199020385742188,51.04938029577453]]],[[[3.8119125366210938,51.03966692839972],[3.8376617431640625,51.05089108097961],[3.7902832031250004,51.10201287469917],[3.773117065429687,51.0662119746483],[3.8119125366210938,51.03966692839972]],[[3.8002395629882812,51.06427017012091],[3.8005828857421875,51.068585180672635],[3.8174057006835933,51.06405440903407],[3.8129425048828125,51.05002778118271],[3.8002395629882812,51.06427017012091]]]]}}]} \ No newline at end of file diff --git a/fixtures/out/point.geojson b/fixtures/out/point.geojson index 3b7b4b2..e7c0629 100644 --- a/fixtures/out/point.geojson +++ b/fixtures/out/point.geojson @@ -1 +1 @@ -{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-75.4,39.54468631190172],[-75.3988210989337,39.54468344997537],[-75.39764224469958,39.544674864310025],[-75.39646348412799,39.54466055524676],[-75.39528486404541,39.54464052335399],[-75.39410643127269,39.54461476942751],[-75.39292823262308,39.54458329449042],[-75.39175031490035,39.54454609979307],[-75.3905727248969,39.54450318681303],[-75.38939550939187,39.54445455725506],[-75.38821871514929,39.54440021305096],[-75.38704238891606,39.54434015635958],[-75.38586657742019,39.5442743895667],[-75.38469132736886,39.5442029152849],[-75.38351668544652,39.54412573635347],[-75.38234269831302,39.544042855838356],[-75.3811694126017,39.54395427703197],[-75.37999687491752,39.543860003453034],[-75.37882513183517,39.54376003884652],[-75.37765422989723,39.54365438718346],[-75.37648421561217,39.543543052660745],[-75.3753151354526,39.54342603970101],[-75.37414703585328,39.54330335295245],[-75.37297996320939,39.5431749972886],[-75.37181396387447,39.543040977808154],[-75.37064908415864,39.54290129983478],[-75.3694853703268,39.54275596891687],[-75.36832286859658,39.54260499082733],[-75.36716162513666,39.54244837156335],[-75.36600168606476,39.542286117346165],[-75.36484309744587,39.54211823462079],[-75.3636859052903,39.54194473005577],[-75.36253015555192,39.541765610542896],[-75.36137589412625,39.54158088319695],[-75.36022316684858,39.54139055535539],[-75.35907201949216,39.541194634578105],[-75.35792249776634,39.540993128647],[-75.35677464731474,39.54078604556583],[-75.35562851371333,39.54057339355974],[-75.3544841424687,39.540355181075014],[-75.3533415790162,39.54013141677872],[-75.35220086871796,39.53990210955833],[-75.35106205686128,39.5396672685214],[-75.34992518865663,39.53942690299515],[-75.34879030923592,39.53918102252617],[-75.34765746365068,39.53892963687993],[-75.3465266968701,39.53867275604047],[-75.34539805377945,39.538410390209954],[-75.34427157917806,39.53814254980828],[-75.34314731777765,39.53786924547261],[-75.34202531420044,39.53759048805702],[-75.34090561297738,39.537306288632],[-75.3397882585464,39.53701665848402],[-75.33867329525056,39.536721609115084],[-75.33756076733623,39.536421152242255],[-75.33645071895141,39.53611529979719],[-75.3353431941439,39.53580406392563],[-75.3342382368595,39.535487456986985],[-75.33313589094027,39.53516549155372],[-75.33203620012274,39.534838180410965],[-75.3309392080362,39.5345055365559],[-75.32984495820088,39.53416757319728],[-75.32875349402624,39.53382430375491],[-75.32766485880923,39.53347574185907],[-75.32657909573246,39.53312190135001],[-75.32549624786259,39.532762796277304],[-75.32441635814853,39.53239844089941],[-75.32333946941971,39.53202884968296],[-75.32226562438436,39.53165403730228],[-75.32119486562783,39.53127401863874],[-75.32012723561084,39.53088880878018],[-75.31906277666775,39.5304984230203],[-75.31800153100491,39.530102876857995],[-75.31694354069899,39.52970218599681],[-75.31588884769519,39.529296366344234],[-75.31483749380564,39.52888543401111],[-75.3137895207077,39.52846940531095],[-75.31274496994229,39.52804829675929],[-75.31170388291216,39.527622125073016],[-75.31066630088037,39.52719090716971],[-75.3096322649685,39.526754660166944],[-75.30860181615502,39.52631340138159],[-75.30757499527378,39.52586714832914],[-75.30655184301217,39.52541591872299],[-75.30553239990967,39.524959730473725],[-75.30451670635608,39.52449860168839],[-75.30350480259003,39.524032550669766],[-75.3024967286973,39.523561595915616],[-75.3014925246092,39.523085756117986],[-75.30049223010101,39.5226050501624],[-75.29949588479043,39.52211949712709],[-75.29850352813584,39.521629116282334],[-75.29751519943495,39.521133927089515],[-75.296530937823,39.520633949200466],[-75.29555078227135,39.520129202456616],[-75.2945747715859,39.51961970688822],[-75.29360294440549,39.51910548271352],[-75.29263533920036,39.51858655033797],[-75.29167199427071,39.51806293035339],[-75.29071294774505,39.51753464353711],[-75.28975823757871,39.5170017108512],[-75.28880790155242,39.516464153441575],[-75.28786197727065,39.51592199263713],[-75.28692050216029,39.51537524994896],[-75.28598351346898,39.51482394706938],[-75.28505104826375,39.51426810587116],[-75.28412314342951,39.513707748406574],[-75.28319983566756,39.51314289690653],[-75.28228116149417,39.51257357377968],[-75.28136715723906,39.511999801611545],[-75.28045785904409,39.51142160316354],[-75.27955330286164,39.51083900137211],[-75.27865352445338,39.51025201934781],[-75.27775855938863,39.50966068037434],[-75.27686844304318,39.509065007907616],[-75.27598321059772,39.50846502557488],[-75.27510289703649,39.507860757173646],[-75.27422753714595,39.50725222667084],[-75.27335716551332,39.5066394582018],[-75.27249181652525,39.50602247606931],[-75.27163152436647,39.50540130474259],[-75.2707763230184,39.50477596885635],[-75.26992624625782,39.50414649320981],[-75.26908132765557,39.50351290276566],[-75.2682416005752,39.50287522264908],[-75.26740709817162,39.50223347814675],[-75.26657785338979,39.50158769470579],[-75.26575389896354,39.50093789793278],[-75.2649352674141,39.50028411359268],[-75.26412199104894,39.49962636760788],[-75.26331410196045,39.498964686057064],[-75.26251163202467,39.49829909517421],[-75.2617146129001,39.49762962134755],[-75.26092307602636,39.49695629111849],[-75.26013705262298,39.49627913118049],[-75.25935657368827,39.49559816837816],[-75.25858166999792,39.494913429705974],[-75.257812372104,39.49422494230733],[-75.25704871033355,39.49353273347339],[-75.25629071478757,39.49283683064203],[-75.2555384153397,39.492137261396714],[-75.25479184163517,39.49143405346539],[-75.25405102308954,39.49072723471939],[-75.2533159888876,39.490016833172284],[-75.25258676798224,39.489302876978776],[-75.25186338909326,39.48858539443361],[-75.25114588070629,39.487864413970364],[-75.25043427107168,39.487139964160356],[-75.24972858820337,39.486412073711485],[-75.24902885987782,39.485680771467116],[-75.24833511363293,39.484946086404854],[-75.24764737676695,39.48420804763544],[-75.24696567633742,39.48346668440157],[-75.24629003916012,39.482722026076715],[-75.24562049180801,39.48197410216396],[-75.24495706061025,39.48122294229479],[-75.24429977165113,39.48046857622797],[-75.24364865076906,39.47971103384826],[-75.24300372355556,39.47895034516531],[-75.24236501535434,39.47818654031241],[-75.24173255126021,39.477419649545254],[-75.24110635611821,39.47664970324083],[-75.24048645452253,39.47587673189611],[-75.2398728708157,39.47510076612687],[-75.23926562908755,39.47432183666644],[-75.23866475317433,39.47353997436451],[-75.23807026665773,39.472755210185895],[-75.23748219286408,39.47196757520924],[-75.23690055486334,39.47117710062587],[-75.23632537546823,39.470383817738465],[-75.23575667723345,39.46958775795983],[-75.23519448245474,39.46878895281165],[-75.23463881316798,39.46798743392325],[-75.23408969114844,39.4671832330303],[-75.23354713790987,39.466376381973525],[-75.23301117470372,39.46556691269752],[-75.23248182251835,39.46475485724937],[-75.23195910207816,39.46394024777745],[-75.23144303384285,39.463123116530085],[-75.23093363800663,39.462303495854336],[-75.23043093449745,39.46148141819461],[-75.22993494297621,39.46065691609143],[-75.2294456828361,39.45983002218017],[-75.22896317320176,39.45900076918964],[-75.22848743292865,39.45816918994091],[-75.2280184806022,39.457335317345894],[-75.22755633453734,39.456499184406105],[-75.22710101277754,39.455660824211314],[-75.22665253309431,39.45482026993823],[-75.22621091298649,39.453977554849196],[-75.22577616967955,39.45313271229084],[-75.22534832012502,39.45228577569275],[-75.22492738099974,39.45143677856616],[-75.22451336870537,39.4505857545026],[-75.22410629936766,39.44973273717255],[-75.22370618883592,39.44887776032414],[-75.22331305268243,39.448020857781735],[-75.22292690620179,39.44716206344469],[-75.22254776441046,39.446301411285866],[-75.22217564204611,39.44543893535042],[-75.22181055356711,39.44457466975435],[-75.22145251315203,39.44370864868317],[-75.22110153469902,39.44284090639058],[-75.2207576318254,39.441971477197036],[-75.2204208178672,39.44110039548845],[-75.22009110587842,39.44022769571478],[-75.21976850863089,39.43935341238869],[-75.2194530386136,39.43847758008419],[-75.2191447080322,39.43760023343517],[-75.2188435288088,39.43672140713415],[-75.21854951258128,39.43584113593082],[-75.218262670703,39.4349594546307],[-75.21798301424238,39.4340763980937],[-75.21771055398249,39.43319200123281],[-75.21744530042066,39.43230629901269],[-75.21718726376812,39.431419326448214],[-75.21693645394967,39.430531118603206],[-75.21669288060323,39.42964171058892],[-75.21645655307961,39.42875113756275],[-75.2162274804421,39.42785943472676],[-75.21600567146625,39.42696663732634],[-75.21579113463945,39.426072780648774],[-75.21558387816071,39.42517790002186],[-75.21538390994041,39.424282030812506],[-75.21519123759992,39.423385208425294],[-75.21500586847148,39.42248746830115],[-75.21482780959778,39.421588845915856],[-75.21465706773193,39.42068937677871],[-75.21449364933711,39.419789096431096],[-75.21433756058636,39.41888804044504],[-75.21418880736239,39.41798624442187],[-75.21404739525747,39.41708374399075],[-75.21391332957313,39.4161805748073],[-75.21378661532009,39.41527677255216],[-75.21366725721806,39.414372372929606],[-75.2135552596956,39.413467411666105],[-75.21345062689002,39.41256192450893],[-75.21335336264727,39.41165594722473],[-75.21326347052172,39.41074951559813],[-75.21318095377623,39.40984266543027],[-75.21310581538198,39.408935432537454],[-75.21303805801834,39.408027852749704],[-75.21297768407297,39.40711996190933],[-75.2129246956416,39.40621179586954],[-75.2128790945281,39.40530339049297],[-75.21284088224444,39.404394781650346],[-75.2128100600106,39.40348600521901],[-75.2127866287547,39.40257709708153],[-75.21277058911288,39.40166809312425],[-75.2127619414294,39.40075902923592],[-75.21276068575668,39.39984994130622],[-75.21276682185523,39.3989408652244],[-75.21278034919385,39.398031836877834],[-75.21280126694963,39.39712289215063],[-75.21282957400801,39.39621406692214],[-75.2128652689629,39.39530539706564],[-75.21290835011676,39.39439691844686],[-75.21295881548077,39.39348866692257],[-75.21301666277485,39.39258067833922],[-75.21308188942788,39.39167298853142],[-75.21315449257784,39.39076563332062],[-75.2132344690719,39.3898586485137],[-75.2133218154667,39.38895206990147],[-75.21341652802839,39.38804593325735],[-75.213518602733,39.387140274335955],[-75.21362803526648,39.38623512887158],[-75.21374482102499,39.38533053257695],[-75.21386895511512,39.38442652114169],[-75.21400043235414,39.383523130230984],[-75.21413924727021,39.382620395484146],[-75.21428539410269,39.38171835251322],[-75.21443886680238,39.38081703690158],[-75.21459965903178,39.379916484202546],[-75.21476776416546,39.37901672993796],[-75.21494317529026,39.378117809596766],[-75.21512588520574,39.37721975863372],[-75.21531588642435,39.37632261246786],[-75.2155131711719,39.3754264064812],[-75.21571773138788,39.374531176017314],[-75.21592955872573,39.37363695637993],[-75.21614864455336,39.372743782831584],[-75.21637497995341,39.371851690592194],[-75.2166085557237,39.37096071483771],[-75.21684936237764,39.370070890698685],[-75.2170973901446,39.36918225325895],[-75.21735262897043,39.36829483755421],[-75.21761506851776,39.367408678570634],[-75.21788469816659,39.366523811243574],[-75.21816150701464,39.36564027045609],[-75.2184454838779,39.364758091037636],[-75.2187366172911,39.3638773077627],[-75.21903489550812,39.36299795534941],[-75.21934030650256,39.362120068458175],[-75.21965283796833,39.36124368169036],[-75.21997247732,39.3603688295869],[-75.22029921169347,39.35949554662693],[-75.2206330279465,39.35862386722648],[-75.2209739126592,39.35775382573708],[-75.22132185213464,39.35688545644443],[-75.22167683239944,39.356018793567074],[-75.2220388392044,39.355153871255055],[-75.22240785802494,39.35429072358853],[-75.22278387406192,39.3534293845765],[-75.22316687224209,39.352569888155436],[-75.22355683721881,39.351712268187974],[-75.22395375337265,39.35085655846157],[-75.22435760481213,39.35000279268719],[-75.2247683753742,39.34915100449799],[-75.22518604862509,39.348301227447976],[-75.22561060786097,39.34745349501073],[-75.22604203610854,39.34660784057809],[-75.22648031612577,39.34576429745881],[-75.22692543040272,39.34492289887729],[-75.2273773611621,39.34408367797228],[-75.22783609036014,39.34324666779556],[-75.22830159968726,39.34241190131066],[-75.22877387056882,39.34157941139158],[-75.22925288416596,39.3407492308215],[-75.22973862137626,39.33992139229148],[-75.23023106283463,39.33909592839921],[-75.23073018891405,39.33827287164772],[-75.23123597972635,39.33745225444411],[-75.23174841512309,39.33663410909831],[-75.23226747469634,39.335818467821774],[-75.23279313777955,39.33500536272625],[-75.23332538344829,39.33419482582254],[-75.23386419052126,39.3333868890192],[-75.23440953756104,39.33258158412135],[-75.23496140287497,39.33177894282941],[-75.23551976451611,39.33097899673784],[-75.23608460028402,39.33018177733396],[-75.23665588772575,39.32938731599668],[-75.23723360413669,39.32859564399527],[-75.23781772656159,39.327806792488175],[-75.2384082317953,39.32702079252178],[-75.23900509638393,39.32623767502921],[-75.23960829662566,39.32545747082911],[-75.24021780857169,39.32468021062443],[-75.24083360802729,39.32390592500129],[-75.24145567055274,39.32313464442771],[-75.24208397146427,39.32236639925247],[-75.24271848583511,39.321601219703936],[-75.24335918849648,39.32083913588884],[-75.24400605403858,39.32008017779115],[-75.24465905681167,39.319324375270845],[-75.24531817092698,39.318571758062845],[-75.24598337025789,39.317822355775775],[-75.24665462844091,39.31707619789081],[-75.2473319188767,39.316333313760616],[-75.2480152147312,39.31559373260807],[-75.24870448893668,39.314857483525266],[-75.24939971419285,39.31412459547227],[-75.25010086296784,39.31339509727607],[-75.25080790749949,39.31266901762939],[-75.2515208197963,39.31194638508965],[-75.25223957163857,39.31122722807777],[-75.25296413457959,39.31051157487714],[-75.25369447994676,39.30979945363247],[-75.25443057884267,39.30909089234874],[-75.2551724021463,39.30838591889005],[-75.2559199205142,39.3076845609786],[-75.25667310438159,39.30698684619356],[-75.2574319239636,39.306292801970066],[-75.25819634925641,39.305602455598056],[-75.25896635003846,39.30491583422132],[-75.25974189587167,39.304232964836345],[-75.26052295610259,39.30355387429137],[-75.26130949986369,39.30287858928522],[-75.2621014960745,39.30220713636638],[-75.26289891344291,39.30153954193192],[-75.2637017204664,39.30087583222645],[-75.26450988543324,39.30021603334114],[-75.26532337642382,39.299560171212676],[-75.26614216131179,39.29890827162227],[-75.26696620776549,39.298260360194654],[-75.26779548324913,39.2976164623971],[-75.26862995502401,39.29697660353842],[-75.26946959015001,39.29634080876797],[-75.27031435548669,39.29570910307471],[-75.27116421769469,39.29508151128618],[-75.27201914323707,39.29445805806761],[-75.27287909838056,39.29383876792091],[-75.27374404919694,39.29322366518373],[-75.27461396156433,39.29261277402853],[-75.27548880116859,39.29200611846162],[-75.27636853350465,39.29140372232227],[-75.27725312387784,39.29080560928173],[-75.27814253740526,39.290211802842386],[-75.27903673901716,39.289622326336776],[-75.27993569345838,39.28903720292671],[-75.28083936528962,39.288456455602386],[-75.28174771888887,39.28788010718152],[-75.28266071845287,39.28730818030842],[-75.28357832799846,39.28674069745311],[-75.28450051136396,39.2861776809105],[-75.28542723221068,39.28561915279947],[-75.28635845402422,39.285065135062055],[-75.28729414011605,39.2845156494626],[-75.28823425362482,39.283970717586875],[-75.28917875751783,39.28343036084127],[-75.29012761459256,39.28289460045198],[-75.291080787478,39.28236345746413],[-75.2920382386362,39.28183695274103],[-75.29299993036372,39.2813151069633],[-75.29396582479309,39.28079794062814],[-75.29493588389425,39.28028547404847],[-75.2959100694762,39.27977772735219],[-75.2968883431882,39.27927472048139],[-75.29787066652158,39.27877647319155],[-75.29885700081104,39.27828300505084],[-75.2998473072362,39.27779433543929],[-75.3008415468232,39.2773104835481],[-75.30183968044605,39.27683146837886],[-75.30284166882835,39.276357308742824],[-75.30384747254467,39.275888023260215],[-75.30485705202219,39.275423630359455],[-75.30587036754211,39.274964148276474],[-75.3068873792414,39.27450959505401],[-75.30790804711408,39.27405998854094],[-75.30893233101308,39.27361534639151],[-75.30996019065154,39.27317568606475],[-75.31099158560453,39.2727410248237],[-75.31202647531057,39.272311379734866],[-75.31306481907322,39.27188676766742],[-75.31410657606264,39.27146720529265],[-75.31515170531722,39.271052709083314],[-75.31620016574512,39.270643295312915],[-75.31725191612585,39.270238980055176],[-75.31830691511202,39.26983977918337],[-75.31936512123072,39.2694457083697],[-75.32042649288529,39.269056783084714],[-75.32149098835691,39.268673018596694],[-75.32255856580618,39.26829442997109],[-75.3236291832747,39.26792103206992],[-75.32470279868686,39.26755283955119],[-75.32577936985129,39.26718986686834],[-75.3268588544626,39.26683212826966],[-75.32794121010296,39.26647963779782],[-75.32902639424383,39.26613240928921],[-75.3301143642475,39.265790456373516],[-75.33120507736885,39.26545379247311],[-75.33229849075686,39.2651224308026],[-75.33339456145644,39.264796384368246],[-75.33449324640998,39.26447566596755],[-75.33559450245903,39.26416028818868],[-75.33669828634604,39.26385026341002],[-75.33780455471587,39.26354560379973],[-75.33891326411772,39.263246321315165],[-75.34002437100655,39.262952427702544],[-75.34113783174494,39.26266393449641],[-75.34225360260471,39.26238085301922],[-75.34337163976862,39.26210319438094],[-75.34449189933201,39.2618309694785],[-75.34561433730464,39.261564188995536],[-75.34673890961223,39.26130286340184],[-75.34786557209823,39.261047002953035],[-75.34899428052559,39.26079661769013],[-75.35012499057831,39.26055171743922],[-75.35125765786336,39.26031231181097],[-75.35239223791216,39.26007841020038],[-75.35352868618251,39.25985002178632],[-75.35466695806018,39.25962715553127],[-75.35580700886067,39.25940982018086],[-75.35694879383092,39.259198024263675],[-75.35809226815108,39.25899177609078],[-75.3592373869362,39.258791083755504],[-75.36038410523794,39.25859595513308],[-75.36153237804638,39.25840639788038],[-75.36268216029171,39.25822241943554],[-75.36383340684591,39.2580440270178],[-75.36498607252462,39.257871227627106],[-75.36614011208877,39.25770402804388],[-75.36729548024638,39.25754243482881],[-75.3684521316543,39.25738645432251],[-75.36961002091994,39.25723609264536],[-75.37076910260302,39.25709135569719],[-75.37192933121736,39.25695224915712],[-75.37309066123258,39.25681877848331],[-75.3742530470759,39.25669094891275],[-75.37541644313386,39.25656876546106],[-75.37658080375407,39.2564522329223],[-75.37774608324708,39.25634135586879],[-75.37891223588792,39.256236138650934],[-75.38007921591814,39.25613658539701],[-75.38124697754729,39.2560427000131],[-75.38241547495494,39.25595448618285],[-75.38358466229221,39.255871947367375],[-75.38475449368376,39.25579508680513],[-75.38592492322937,39.25572390751174],[-75.38709590500585,39.25565841227994],[-75.3882673930687,39.255598603679445],[-75.38943934145392,39.255544484056834],[-75.39061170417982,39.255496055535495],[-75.39178443524872,39.25545332001549],[-75.3929574886488,39.255416279173545],[-75.39413081835582,39.25538493446293],[-75.39530437833483,39.25535928711344],[-75.39647812254209,39.25533933813136],[-75.39765200492675,39.25532508829935],[-75.39882597943263,39.2553165381765],[-75.4,39.255313688098276],[-75.40117402056738,39.2553165381765],[-75.40234799507326,39.25532508829935],[-75.40352187745792,39.25533933813136],[-75.40469562166518,39.25535928711344],[-75.40586918164419,39.25538493446293],[-75.4070425113512,39.255416279173545],[-75.40821556475129,39.25545332001549],[-75.40938829582018,39.255496055535495],[-75.41056065854609,39.255544484056834],[-75.41173260693131,39.255598603679445],[-75.41290409499416,39.25565841227994],[-75.41407507677063,39.25572390751174],[-75.41524550631625,39.25579508680513],[-75.4164153377078,39.255871947367375],[-75.41758452504507,39.25595448618285],[-75.41875302245272,39.2560427000131],[-75.41992078408187,39.25613658539701],[-75.42108776411207,39.256236138650934],[-75.42225391675294,39.25634135586879],[-75.42341919624593,39.2564522329223],[-75.42458355686615,39.25656876546106],[-75.42574695292411,39.25669094891275],[-75.42690933876743,39.25681877848331],[-75.42807066878265,39.25695224915712],[-75.42923089739699,39.25709135569719],[-75.43038997908008,39.25723609264536],[-75.43154786834572,39.25738645432251],[-75.43270451975363,39.25754243482881],[-75.43385988791124,39.25770402804388],[-75.4350139274754,39.257871227627106],[-75.4361665931541,39.2580440270178],[-75.4373178397083,39.25822241943554],[-75.43846762195362,39.25840639788038],[-75.43961589476207,39.25859595513308],[-75.44076261306381,39.258791083755504],[-75.44190773184893,39.25899177609078],[-75.44305120616909,39.259198024263675],[-75.44419299113935,39.25940982018086],[-75.44533304193983,39.25962715553127],[-75.4464713138175,39.25985002178632],[-75.44760776208786,39.26007841020038],[-75.44874234213665,39.26031231181097],[-75.4498750094217,39.26055171743922],[-75.45100571947442,39.26079661769013],[-75.45213442790178,39.261047002953035],[-75.45326109038778,39.26130286340184],[-75.45438566269537,39.261564188995536],[-75.455508100668,39.2618309694785],[-75.45662836023139,39.26210319438094],[-75.4577463973953,39.26238085301922],[-75.45886216825507,39.26266393449641],[-75.45997562899345,39.262952427702544],[-75.46108673588229,39.263246321315165],[-75.46219544528414,39.26354560379973],[-75.46330171365398,39.26385026341002],[-75.46440549754098,39.26416028818868],[-75.46550675359003,39.26447566596755],[-75.46660543854357,39.264796384368246],[-75.46770150924316,39.2651224308026],[-75.46879492263116,39.26545379247311],[-75.4698856357525,39.265790456373516],[-75.47097360575619,39.26613240928921],[-75.47205878989705,39.26647963779782],[-75.47314114553741,39.26683212826966],[-75.47422063014871,39.26718986686834],[-75.47529720131315,39.26755283955119],[-75.4763708167253,39.26792103206992],[-75.47744143419384,39.26829442997109],[-75.4785090116431,39.268673018596694],[-75.47957350711472,39.269056783084714],[-75.4806348787693,39.2694457083697],[-75.48169308488798,39.26983977918337],[-75.48274808387416,39.270238980055176],[-75.4837998342549,39.270643295312915],[-75.48484829468279,39.271052709083314],[-75.48589342393737,39.27146720529265],[-75.48693518092679,39.27188676766742],[-75.48797352468944,39.272311379734866],[-75.48900841439549,39.2727410248237],[-75.49003980934847,39.27317568606475],[-75.49106766898693,39.27361534639151],[-75.49209195288591,39.27405998854094],[-75.49311262075861,39.27450959505401],[-75.4941296324579,39.274964148276474],[-75.49514294797783,39.275423630359455],[-75.49615252745532,39.275888023260215],[-75.49715833117166,39.276357308742824],[-75.49816031955396,39.27683146837886],[-75.49915845317682,39.2773104835481],[-75.5001526927638,39.27779433543929],[-75.50114299918897,39.27828300505084],[-75.50212933347844,39.27877647319155],[-75.50311165681181,39.27927472048139],[-75.50408993052382,39.27977772735219],[-75.50506411610576,39.28028547404847],[-75.50603417520692,39.28079794062814],[-75.50700006963629,39.2813151069633],[-75.50796176136382,39.28183695274103],[-75.50891921252202,39.28236345746413],[-75.50987238540745,39.28289460045198],[-75.51082124248217,39.28343036084127],[-75.51176574637519,39.283970717586875],[-75.51270585988397,39.2845156494626],[-75.51364154597579,39.285065135062055],[-75.51457276778933,39.28561915279947],[-75.51549948863605,39.2861776809105],[-75.51642167200156,39.28674069745311],[-75.51733928154714,39.28730818030842],[-75.51825228111115,39.28788010718152],[-75.51916063471039,39.288456455602386],[-75.52006430654163,39.28903720292671],[-75.52096326098285,39.289622326336776],[-75.52185746259475,39.290211802842386],[-75.52274687612217,39.29080560928173],[-75.52363146649536,39.29140372232227],[-75.52451119883142,39.29200611846162],[-75.52538603843568,39.29261277402853],[-75.52625595080308,39.29322366518373],[-75.52712090161945,39.29383876792091],[-75.52798085676294,39.29445805806761],[-75.52883578230532,39.29508151128618],[-75.52968564451332,39.29570910307471],[-75.53053040985,39.29634080876797],[-75.53137004497599,39.29697660353842],[-75.53220451675088,39.2976164623971],[-75.53303379223452,39.298260360194654],[-75.53385783868822,39.29890827162227],[-75.53467662357619,39.299560171212676],[-75.53549011456677,39.30021603334114],[-75.53629827953361,39.30087583222645],[-75.5371010865571,39.30153954193192],[-75.53789850392552,39.30220713636638],[-75.53869050013633,39.30287858928522],[-75.53947704389742,39.30355387429137],[-75.54025810412834,39.304232964836345],[-75.54103364996155,39.30491583422132],[-75.5418036507436,39.305602455598056],[-75.5425680760364,39.306292801970066],[-75.54332689561842,39.30698684619356],[-75.54408007948581,39.3076845609786],[-75.54482759785371,39.30838591889005],[-75.54556942115734,39.30909089234874],[-75.54630552005325,39.30979945363247],[-75.54703586542041,39.31051157487714],[-75.54776042836144,39.31122722807777],[-75.54847918020371,39.31194638508965],[-75.54919209250052,39.31266901762939],[-75.54989913703217,39.31339509727607],[-75.55060028580716,39.31412459547227],[-75.55129551106332,39.314857483525266],[-75.55198478526881,39.31559373260807],[-75.55266808112331,39.316333313760616],[-75.5533453715591,39.31707619789081],[-75.55401662974212,39.317822355775775],[-75.55468182907303,39.318571758062845],[-75.55534094318834,39.319324375270845],[-75.55599394596142,39.32008017779115],[-75.55664081150353,39.32083913588884],[-75.5572815141649,39.321601219703936],[-75.55791602853574,39.32236639925247],[-75.55854432944727,39.32313464442771],[-75.55916639197272,39.32390592500129],[-75.55978219142833,39.32468021062443],[-75.56039170337435,39.32545747082911],[-75.56099490361608,39.32623767502921],[-75.5615917682047,39.32702079252178],[-75.56218227343842,39.327806792488175],[-75.56276639586332,39.32859564399527],[-75.56334411227427,39.32938731599668],[-75.563915399716,39.33018177733396],[-75.5644802354839,39.33097899673784],[-75.56503859712504,39.33177894282941],[-75.56559046243898,39.33258158412135],[-75.56613580947875,39.3333868890192],[-75.56667461655172,39.33419482582254],[-75.56720686222046,39.33500536272625],[-75.56773252530367,39.335818467821774],[-75.56825158487692,39.33663410909831],[-75.56876402027366,39.33745225444411],[-75.56926981108596,39.33827287164772],[-75.56976893716538,39.33909592839921],[-75.57026137862374,39.33992139229148],[-75.57074711583405,39.3407492308215],[-75.5712261294312,39.34157941139158],[-75.57169840031275,39.34241190131066],[-75.57216390963987,39.34324666779556],[-75.57262263883791,39.34408367797228],[-75.5730745695973,39.34492289887729],[-75.57351968387422,39.34576429745881],[-75.57395796389147,39.34660784057809],[-75.57438939213904,39.34745349501073],[-75.57481395137492,39.348301227447976],[-75.57523162462581,39.34915100449799],[-75.57564239518788,39.35000279268719],[-75.57604624662736,39.35085655846157],[-75.5764431627812,39.351712268187974],[-75.57683312775792,39.352569888155436],[-75.5772161259381,39.3534293845765],[-75.57759214197507,39.35429072358853],[-75.57796116079561,39.355153871255055],[-75.57832316760056,39.356018793567074],[-75.57867814786538,39.35688545644443],[-75.57902608734081,39.35775382573708],[-75.5793669720535,39.35862386722648],[-75.57970078830654,39.35949554662693],[-75.58002752268001,39.3603688295869],[-75.58034716203169,39.36124368169036],[-75.58065969349745,39.362120068458175],[-75.5809651044919,39.36299795534941],[-75.58126338270891,39.3638773077627],[-75.5815545161221,39.364758091037636],[-75.58183849298537,39.36564027045609],[-75.58211530183343,39.366523811243574],[-75.58238493148225,39.367408678570634],[-75.58264737102958,39.36829483755421],[-75.58290260985541,39.36918225325895],[-75.58315063762237,39.370070890698685],[-75.58339144427632,39.37096071483771],[-75.5836250200466,39.371851690592194],[-75.58385135544665,39.372743782831584],[-75.58407044127428,39.37363695637993],[-75.58428226861213,39.374531176017314],[-75.58448682882809,39.3754264064812],[-75.58468411357566,39.37632261246786],[-75.58487411479427,39.37721975863372],[-75.58505682470975,39.378117809596766],[-75.58523223583455,39.37901672993796],[-75.58540034096823,39.379916484202546],[-75.58556113319763,39.38081703690158],[-75.58571460589731,39.38171835251322],[-75.5858607527298,39.382620395484146],[-75.58599956764587,39.383523130230984],[-75.5861310448849,39.38442652114169],[-75.58625517897502,39.38533053257695],[-75.58637196473353,39.38623512887158],[-75.58648139726701,39.387140274335955],[-75.58658347197161,39.38804593325735],[-75.58667818453331,39.38895206990147],[-75.5867655309281,39.3898586485137],[-75.58684550742217,39.39076563332062],[-75.58691811057211,39.39167298853142],[-75.58698333722515,39.39258067833922],[-75.58704118451922,39.39348866692257],[-75.58709164988325,39.39439691844686],[-75.58713473103711,39.39530539706564],[-75.587170425992,39.39621406692214],[-75.58719873305039,39.39712289215063],[-75.58721965080615,39.398031836877834],[-75.58723317814479,39.3989408652244],[-75.58723931424333,39.39984994130622],[-75.5872380585706,39.40075902923592],[-75.58722941088713,39.40166809312425],[-75.58721337124531,39.40257709708153],[-75.58718993998941,39.40348600521901],[-75.58715911775558,39.404394781650346],[-75.5871209054719,39.40530339049297],[-75.58707530435841,39.40621179586954],[-75.58702231592703,39.40711996190933],[-75.58696194198167,39.408027852749704],[-75.58689418461803,39.408935432537454],[-75.58681904622378,39.40984266543027],[-75.58673652947829,39.41074951559813],[-75.58664663735274,39.41165594722473],[-75.58654937310997,39.41256192450893],[-75.58644474030442,39.413467411666105],[-75.58633274278195,39.414372372929606],[-75.58621338467992,39.41527677255216],[-75.58608667042688,39.4161805748073],[-75.58595260474254,39.41708374399075],[-75.58581119263762,39.41798624442187],[-75.58566243941365,39.41888804044504],[-75.5855063506629,39.419789096431096],[-75.58534293226806,39.42068937677871],[-75.58517219040223,39.421588845915856],[-75.58499413152853,39.42248746830115],[-75.58480876240009,39.423385208425294],[-75.5846160900596,39.424282030812506],[-75.58441612183928,39.42517790002186],[-75.58420886536057,39.426072780648774],[-75.58399432853376,39.42696663732634],[-75.58377251955791,39.42785943472676],[-75.5835434469204,39.42875113756275],[-75.58330711939678,39.42964171058892],[-75.58306354605034,39.430531118603206],[-75.58281273623189,39.431419326448214],[-75.58255469957935,39.43230629901269],[-75.58228944601753,39.43319200123281],[-75.58201698575763,39.4340763980937],[-75.58173732929701,39.4349594546307],[-75.58145048741873,39.43584113593082],[-75.5811564711912,39.43672140713415],[-75.58085529196781,39.43760023343517],[-75.58054696138642,39.43847758008419],[-75.58023149136912,39.43935341238869],[-75.57990889412159,39.44022769571478],[-75.57957918213282,39.44110039548845],[-75.57924236817459,39.441971477197036],[-75.578898465301,39.44284090639058],[-75.57854748684798,39.44370864868317],[-75.57818944643289,39.44457466975435],[-75.5778243579539,39.44543893535042],[-75.57745223558955,39.446301411285866],[-75.57707309379822,39.44716206344469],[-75.57668694731758,39.448020857781735],[-75.57629381116409,39.44887776032414],[-75.57589370063235,39.44973273717255],[-75.57548663129464,39.4505857545026],[-75.57507261900027,39.45143677856616],[-75.57465167987499,39.45228577569275],[-75.57422383032045,39.45313271229084],[-75.57378908701351,39.453977554849196],[-75.5733474669057,39.45482026993823],[-75.57289898722247,39.455660824211314],[-75.57244366546267,39.456499184406105],[-75.5719815193978,39.457335317345894],[-75.57151256707137,39.45816918994091],[-75.57103682679823,39.45900076918964],[-75.5705543171639,39.45983002218017],[-75.5700650570238,39.46065691609143],[-75.56956906550255,39.46148141819461],[-75.56906636199336,39.462303495854336],[-75.56855696615716,39.463123116530085],[-75.56804089792185,39.46394024777745],[-75.56751817748166,39.46475485724937],[-75.56698882529629,39.46556691269752],[-75.56645286209015,39.466376381973525],[-75.56591030885157,39.4671832330303],[-75.56536118683204,39.46798743392325],[-75.56480551754527,39.46878895281165],[-75.56424332276654,39.46958775795983],[-75.56367462453177,39.470383817738465],[-75.56309944513667,39.47117710062587],[-75.56251780713593,39.47196757520924],[-75.56192973334227,39.472755210185895],[-75.56133524682568,39.47353997436451],[-75.56073437091246,39.47432183666644],[-75.56012712918431,39.47510076612687],[-75.55951354547749,39.47587673189611],[-75.5588936438818,39.47664970324083],[-75.5582674487398,39.477419649545254],[-75.55763498464566,39.47818654031241],[-75.55699627644445,39.47895034516531],[-75.55635134923095,39.47971103384826],[-75.55570022834888,39.48046857622797],[-75.55504293938976,39.48122294229479],[-75.554379508192,39.48197410216396],[-75.5537099608399,39.482722026076715],[-75.55303432366259,39.48346668440157],[-75.55235262323306,39.48420804763544],[-75.55166488636708,39.484946086404854],[-75.55097114012219,39.485680771467116],[-75.55027141179664,39.486412073711485],[-75.54956572892833,39.487139964160356],[-75.54885411929372,39.487864413970364],[-75.54813661090675,39.48858539443361],[-75.54741323201777,39.489302876978776],[-75.5466840111124,39.490016833172284],[-75.54594897691047,39.49072723471939],[-75.54520815836484,39.49143405346539],[-75.54446158466031,39.492137261396714],[-75.54370928521244,39.49283683064203],[-75.54295128966646,39.49353273347339],[-75.54218762789601,39.49422494230733],[-75.54141833000209,39.494913429705974],[-75.54064342631175,39.49559816837816],[-75.53986294737702,39.49627913118049],[-75.53907692397365,39.49695629111849],[-75.53828538709992,39.49762962134755],[-75.53748836797534,39.49829909517421],[-75.53668589803956,39.498964686057064],[-75.53587800895107,39.49962636760788],[-75.53506473258591,39.50028411359268],[-75.53424610103647,39.50093789793278],[-75.5334221466102,39.50158769470579],[-75.5325929018284,39.50223347814675],[-75.53175839942482,39.50287522264908],[-75.53091867234444,39.50351290276566],[-75.53007375374219,39.50414649320981],[-75.52922367698162,39.50477596885635],[-75.52836847563354,39.50540130474259],[-75.52750818347475,39.50602247606931],[-75.5266428344867,39.5066394582018],[-75.52577246285405,39.50725222667084],[-75.52489710296352,39.507860757173646],[-75.5240167894023,39.50846502557488],[-75.52313155695683,39.509065007907616],[-75.52224144061138,39.50966068037434],[-75.52134647554664,39.51025201934781],[-75.52044669713835,39.51083900137211],[-75.51954214095592,39.51142160316354],[-75.51863284276095,39.511999801611545],[-75.51771883850584,39.51257357377968],[-75.51680016433245,39.51314289690653],[-75.5158768565705,39.513707748406574],[-75.51494895173626,39.51426810587116],[-75.51401648653103,39.51482394706938],[-75.51307949783973,39.51537524994896],[-75.51213802272936,39.51592199263713],[-75.5111920984476,39.516464153441575],[-75.5102417624213,39.5170017108512],[-75.50928705225496,39.51753464353711],[-75.5083280057293,39.51806293035339],[-75.50736466079964,39.51858655033797],[-75.50639705559452,39.51910548271352],[-75.50542522841411,39.51961970688822],[-75.50444921772866,39.520129202456616],[-75.50346906217702,39.520633949200466],[-75.50248480056506,39.521133927089515],[-75.50149647186417,39.521629116282334],[-75.50050411520958,39.52211949712709],[-75.499507769899,39.5226050501624],[-75.49850747539081,39.523085756117986],[-75.4975032713027,39.523561595915616],[-75.49649519740998,39.524032550669766],[-75.49548329364393,39.52449860168839],[-75.49446760009035,39.524959730473725],[-75.49344815698784,39.52541591872299],[-75.49242500472623,39.52586714832914],[-75.49139818384499,39.52631340138159],[-75.49036773503151,39.526754660166944],[-75.48933369911964,39.52719090716971],[-75.48829611708786,39.527622125073016],[-75.48725503005772,39.52804829675929],[-75.48621047929231,39.52846940531095],[-75.48516250619437,39.52888543401111],[-75.48411115230482,39.529296366344234],[-75.48305645930103,39.52970218599681],[-75.4819984689951,39.530102876857995],[-75.48093722333226,39.5304984230203],[-75.47987276438917,39.53088880878018],[-75.47880513437217,39.53127401863874],[-75.47773437561564,39.53165403730228],[-75.4766605305803,39.53202884968296],[-75.47558364185149,39.53239844089941],[-75.47450375213742,39.532762796277304],[-75.47342090426756,39.53312190135001],[-75.47233514119078,39.53347574185907],[-75.47124650597377,39.53382430375491],[-75.47015504179913,39.53416757319728],[-75.46906079196381,39.5345055365559],[-75.46796379987727,39.534838180410965],[-75.46686410905974,39.53516549155372],[-75.4657617631405,39.535487456986985],[-75.46465680585611,39.53580406392563],[-75.4635492810486,39.53611529979719],[-75.46243923266378,39.536421152242255],[-75.46132670474945,39.536721609115084],[-75.4602117414536,39.53701665848402],[-75.45909438702262,39.537306288632],[-75.45797468579957,39.53759048805702],[-75.45685268222236,39.53786924547261],[-75.45572842082196,39.53814254980828],[-75.45460194622056,39.538410390209954],[-75.45347330312991,39.53867275604047],[-75.45234253634933,39.53892963687993],[-75.45120969076409,39.53918102252617],[-75.45007481134338,39.53942690299515],[-75.44893794313873,39.5396672685214],[-75.44779913128205,39.53990210955833],[-75.44665842098381,39.54013141677872],[-75.44551585753129,39.540355181075014],[-75.44437148628668,39.54057339355974],[-75.44322535268527,39.54078604556583],[-75.44207750223366,39.540993128647],[-75.44092798050785,39.541194634578105],[-75.43977683315143,39.54139055535539],[-75.43862410587374,39.54158088319695],[-75.43746984444807,39.541765610542896],[-75.43631409470972,39.54194473005577],[-75.43515690255414,39.54211823462079],[-75.43399831393525,39.542286117346165],[-75.43283837486334,39.54244837156335],[-75.43167713140342,39.54260499082733],[-75.43051462967321,39.54275596891687],[-75.42935091584137,39.54290129983478],[-75.42818603612554,39.543040977808154],[-75.42702003679062,39.5431749972886],[-75.42585296414673,39.54330335295245],[-75.42468486454742,39.54342603970101],[-75.42351578438785,39.543543052660745],[-75.42234577010278,39.54365438718346],[-75.42117486816484,39.54376003884652],[-75.42000312508249,39.543860003453034],[-75.41883058739832,39.54395427703197],[-75.41765730168699,39.544042855838356],[-75.41648331455349,39.54412573635347],[-75.41530867263114,39.5442029152849],[-75.41413342257982,39.5442743895667],[-75.41295761108395,39.54434015635958],[-75.41178128485072,39.54440021305096],[-75.41060449060814,39.54445455725506],[-75.40942727510311,39.54450318681303],[-75.40824968509966,39.54454609979307],[-75.40707176737693,39.54458329449042],[-75.40589356872732,39.54461476942751],[-75.4047151359546,39.54464052335399],[-75.40353651587202,39.54466055524676],[-75.40235775530043,39.544674864310025],[-75.4011789010663,39.54468344997537],[-75.4,39.54468631190172]]]},"properties":{}},{"type":"Feature","geometry":{"type":"Point","coordinates":[-75.4,39.4]},"properties":{"name":"Location A","category":"Store"}}]} \ No newline at end of file +{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.7220799922943115,51.06318614557589],[3.7229782334105703,51.0631684016458],[3.7238729275207567,51.0631152399234],[3.7247605416497005,51.063026870335236],[3.7256375708281544,51.06290364183607],[3.7265005519562684,51.06274604102854],[3.727346077500311,51.062554690238464],[3.7281708089681302,51.062330345053255],[3.7289714901097333,51.06207389133348],[3.729744959790485,51.06178634170932],[3.7304881644857804,51.06146883157587],[3.731198170347575,51.061122614603306],[3.7318721747948973,51.06074905777972],[3.7325075175824303,51.0603496360063],[3.733101691303327,51.05992592626649],[3.733652351284774,51.05947960139204],[3.73415732483723,51.05901242345105],[3.7346146198209165,51.05852623678391],[3.7350224324958665,51.058022960715114],[3.7353791546247592,51.057504581969496],[3.7356833798007427,51.056973146823374],[3.7359339089755834,51.056430753021345],[3.7361297551666692,51.055879541490924],[3.7362701473247,51.05532168788785],[3.736354533347216,51.05475939400537],[3.736382582226557,51.054194879081685],[3.7363541853242475,51.05363037103967],[3.7362694567672925,51.053068097693675],[3.7361287329653234,51.05251027795802],[3.735932571251023,51.051959113091854],[3.7356817476496804,51.05141677801497],[3.7353772537871888,51.05088541272878],[3.7350202929491294,51.05036711387614],[3.73461227530694,51.04986392647339],[3.734154812330397,51.04937783584708],[3.733649710408814,51.048910759807065],[3.733098963706431,51.0484645410867],[3.73250474628043,51.04804094007996],[3.73186940349288,51.04764162790382],[3.731195442750628,51.0472681798133],[3.73048552360974,51.046922068994824],[3.7297424472835448,51.04660466076235],[3.728969145595631,51.04631720717902],[3.7281686694212577,51.04606084212531],[3.7273441766626023,51.04583657683308],[3.726498919805074,51.04564529590295],[3.725636233103477,51.04548775382058],[3.7247595194482592,51.045364571985665],[3.7238722369632815,51.04527623626493],[3.7229778853875675,51.04522309507902],[3.7220799922943115,51.04520535803059],[3.721182099201055,51.04522309507902],[3.7202877476253415,51.04527623626493],[3.7194004651403634,51.045364571985665],[3.718523751485146,51.04548775382058],[3.7176610647835484,51.04564529590295],[3.7168158079260203,51.04583657683308],[3.715991315167365,51.04606084212531],[3.7151908389929917,51.04631720717902],[3.714417537305078,51.04660466076235],[3.713674460978883,51.046922068994824],[3.712964541837995,51.0472681798133],[3.712290581095743,51.04764162790382],[3.7116552383081927,51.04804094007996],[3.7110610208821915,51.0484645410867],[3.7105102741798084,51.048910759807065],[3.7100051722582257,51.04937783584708],[3.7095477092816824,51.04986392647339],[3.709139691639493,51.05036711387614],[3.708782730801434,51.05088541272878],[3.708478236938942,51.05141677801497],[3.7082274133375996,51.051959113091854],[3.708031251623299,51.05251027795802],[3.70789052782133,51.053068097693675],[3.707805799264375,51.05363037103967],[3.7077774023620655,51.054194879081685],[3.7078054512414065,51.05475939400537],[3.7078898372639224,51.05532168788785],[3.7080302294219534,51.055879541490924],[3.708226075613039,51.056430753021345],[3.70847660478788,51.056973146823374],[3.708780829963864,51.057504581969496],[3.709137552092756,51.058022960715114],[3.7095453647677066,51.05852623678391],[3.7100026597513924,51.05901242345105],[3.7105076333038487,51.05947960139204],[3.7110582932852956,51.05992592626649],[3.7116524670061923,51.0603496360063],[3.7122878097937253,51.06074905777972],[3.7129618142410474,51.061122614603306],[3.7136718201028422,51.06146883157587],[3.714415024798138,51.06178634170932],[3.7151884944788893,51.06207389133348],[3.7159891756204924,51.062330345053255],[3.7168139070883117,51.062554690238464],[3.717659432632354,51.06274604102854],[3.718522413760468,51.06290364183607],[3.719399442938922,51.063026870335236],[3.720287057067866,51.0631152399234],[3.7211817511780523,51.0631684016458],[3.7220799922943115,51.06318614557589]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[3.7220799922943115,51.054195751803235]}}]} \ No newline at end of file diff --git a/fixtures/out/polygon.geojson b/fixtures/out/polygon.geojson new file mode 100644 index 0000000..f1caa68 --- /dev/null +++ b/fixtures/out/polygon.geojson @@ -0,0 +1 @@ +{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.6239356139608048,51.03768314391359],[3.623995646413216,51.03944516498373],[3.624601244321493,51.04116596327851],[3.6257291907574074,51.0427794013141],[3.6273361810400595,51.044223461301286],[3.6293604805605555,51.04544263062641],[3.670410471608452,51.06571985893848],[3.6373411569776652,51.08964894076741],[3.6369388955799216,51.089952999975104],[3.6354171638439845,51.09143375004424],[3.634384526159314,51.093072500807715],[3.633880711257676,51.09480628927196],[3.633925138269327,51.09656849377433],[3.634516161659739,51.098291393171166],[3.63563112506223,51.09990876941493],[3.637227223369592,51.10135845349178],[3.63924314126255,51.102584716695766],[3.641601406191085,51.10354041501686],[3.6442113658943267,51.10418880381395],[3.6469726759914995,51.10450495258563],[3.6497791630280725,51.104476705059255],[3.6999043663683437,51.100878835713615],[3.7235689763551,51.130604453138766],[3.7247688442182136,51.13184760536748],[3.7266285734205424,51.133168289955044],[3.728863261599383,51.13423588466668],[3.7313870144647447,51.135009343702166],[3.7341028075306277,51.135458928135556],[3.736906220510142,51.13556735110075],[3.7396894583365006,51.13533044357699],[3.7423455030331114,51.134757314965704],[3.744772235450565,51.13387000223231],[3.746876367087599,51.13270262121667],[3.7485770297645344,51.13130005300463],[3.7498088844923774,51.12971621623517],[3.7697190108376972,51.096104255967994],[3.817602981435303,51.08213050409087],[3.8189740985535288,51.081671491473706],[3.8212207534071783,51.08061597408976],[3.8230963474113944,51.07930535635888],[3.824528809095844,51.077790023873206],[3.825463119315293,51.07612822704082],[3.8258634210984677,51.074383839962415],[3.825714390291,51.07262390393199],[3.825021815435785,51.070916050245174],[3.8238123659801793,51.0693259014816],[3.8221325591396287,51.06791455107991],[3.8200469663741825,51.0667362178484],[3.7929560490125467,51.05421915589585],[3.806808409437143,51.02262311037757],[3.8068218866971537,51.02259212799537],[3.807287946480942,51.02085425622335],[3.8072060514457107,51.01909258392693],[3.8065794101993164,51.01737481005206],[3.8054321595784275,51.01576693924653],[3.8038084286587943,51.01433074662428],[3.801770636682713,51.01312140598429],[3.7993970912577018,51.01218537229461],[3.7967789795907025,51.01155859939318],[3.794016868297561,51.0112651609512],[3.791216845676353,51.01131632729171],[3.788486453631389,51.011710133243696],[3.749454282176116,51.01995186249333],[3.7224217498412844,51.000495351773715],[3.7216126822047624,50.99995884679903],[3.719421503589369,50.998861312109504],[3.716932286512153,50.99805384039214],[3.7142406545305717,50.99756744658318],[3.711449993460075,50.997420812266135],[3.7086674862412954,50.9976195693094],[3.706000003178978,50.99815608392442],[3.7035500040871088,50.99900974936876],[3.701411608433535,51.00014777614589],[3.6996669833478424,51.00152644959384],[3.6983831875433553,51.00309280691358],[3.6976095922011436,51.00478666963079],[3.689368787979985,51.03301492942801],[3.6398269862841484,51.029440308170216],[3.6392845995177066,51.02940759660506],[3.636482954436899,51.02944567766051],[3.6337469197250103,51.029826714205285],[3.631181583852597,51.03053607139071],[3.6288854896164318,51.03154650328271],[3.6269468535295326,51.032819197737595],[3.625440178924165,51.034305265163766],[3.624423392434488,51.03594761437765],[3.6239356139608048,51.03768314391359]],[[3.721762883390001,51.06247446604107],[3.7241810007220693,51.061699976913765],[3.726383013349649,51.06060871991698],[3.7282038708033167,51.05926840576461],[3.7289431699775766,51.05843837273931],[3.729006736474369,51.05845421114492],[3.731764979548568,51.05877152485842],[3.734383726106786,51.05874624721666],[3.7347767211245326,51.05989408839749],[3.735890175333468,51.06151162354705],[3.737484425699034,51.0629615351491],[3.7437709321235166,51.067625459005264],[3.7409731363186354,51.068089335943085],[3.7394863679210943,51.06839109477429],[3.7369797184523925,51.069181701475955],[3.7347665869642603,51.07026436802838],[3.733346769195304,51.07129611105415],[3.7309116053494655,51.07061820248756],[3.7281748752893753,51.07023233059856],[3.7253709434611517,51.070189296759715],[3.7244901157861885,51.0702302870011],[3.724734333618481,51.06967063460644],[3.724934048013095,51.06791268311181],[3.724584163690284,51.06616402651139],[3.723698186283896,51.064491859897075],[3.722310212779807,51.06296043207257],[3.721762883390001,51.06247446604107]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.7010192871093746,51.04290494383127],[3.7116622924804683,51.00641021333656],[3.7449645996093754,51.03038336319532],[3.7930297851562496,51.0202340830275],[3.7765502929687496,51.057796900048594],[3.811569213867187,51.07397837820157],[3.7583541870117188,51.08950727568543],[3.7363815307617188,51.12658298883994],[3.708229064941406,51.09123238697973],[3.6481475830078125,51.095544883691204],[3.6910629272460938,51.064485930202125],[3.638191223144531,51.03837165885956],[3.7010192871093746,51.04290494383127]],[[3.726425170898438,51.07915525654743],[3.7336349487304683,51.09231054886148],[3.7446212768554688,51.076782592536524],[3.769340515136719,51.072684068113695],[3.7483978271484375,51.057149523259795],[3.758697509765625,51.04463179285938],[3.7329483032226562,51.049811953719086],[3.7260818481445312,51.04031454959097],[3.7164688110351562,51.05412831189872],[3.6948394775390625,51.05412831189872],[3.71063232421875,51.06815369771887],[3.698616027832031,51.08044938563426],[3.726425170898438,51.07915525654743]]]}}]} \ No newline at end of file diff --git a/test.js b/test.js index 18da7f9..6f32bdd 100644 --- a/test.js +++ b/test.js @@ -1,30 +1,44 @@ var test = require('tape'); var buffer = require('./'); var fs = require('fs'); -var fc = require('turf-featurecollection') +var helpers = require('turf-helpers') test('buffer', function(t){ - var pt = JSON.parse(fs.readFileSync(__dirname+'/fixtures/Point.geojson')); - var multipt = JSON.parse(fs.readFileSync(__dirname+'/fixtures/MultiPoint.geojson')); - var line = JSON.parse(fs.readFileSync(__dirname+'/fixtures/LineString.geojson')); - var polygon = JSON.parse(fs.readFileSync(__dirname+'/fixtures/Polygon.geojson')); - - var buffPt = buffer(pt, 10, 'miles', 1000); - fs.writeFileSync(__dirname+'/fixtures/out/point.geojson', JSON.stringify(fc([buffPt, pt]))); - var buffMultiPt = buffer(multipt, 10, 'miles', 100); + var pt = JSON.parse(fs.readFileSync(__dirname+'/fixtures/point.geojson')); + var multipt = JSON.parse(fs.readFileSync(__dirname+'/fixtures/multiPoint.geojson')); + var line = JSON.parse(fs.readFileSync(__dirname+'/fixtures/lineString.geojson')); + var multiline = JSON.parse(fs.readFileSync(__dirname+'/fixtures/multiLineString.geojson')); + var polygon = JSON.parse(fs.readFileSync(__dirname+'/fixtures/polygon.geojson')); + var multipolygon = JSON.parse(fs.readFileSync(__dirname+'/fixtures/multiPolygon.geojson')); + + var buffPt = buffer(pt, 1, 'kilometers', 100); + fs.writeFileSync(__dirname+'/fixtures/out/point.geojson', JSON.stringify(helpers.featureCollection([buffPt, pt]))); + + var buffMultiPt = buffer(multipt, 1, 'kilometers'); buffMultiPt.features.push(multipt) fs.writeFileSync(__dirname+'/fixtures/out/multipoint.geojson', JSON.stringify(buffMultiPt)); - var buffLine = buffer(line, 0.4, 'miles'); - buffLine.features.push(line) - fs.writeFileSync(__dirname+'/fixtures/out/linestring.geojson', JSON.stringify(buffLine)); - //var buffPoly = buffer(pt, 10, 'miles'); - //var buffFC = buffer(fc, 10, 'miles'); + + var buffLine = buffer(line, 1, 'kilometers'); + fs.writeFileSync(__dirname+'/fixtures/out/line.geojson', JSON.stringify(helpers.featureCollection([buffLine, line]))); + + var buffMultiLine = buffer(multiline, 1, 'kilometers'); + buffMultiLine.features.push(multiline) + fs.writeFileSync(__dirname+'/fixtures/out/multiline.geojson', JSON.stringify(buffMultiLine)); + + var buffPolygon = buffer(polygon, 1, 'kilometers'); + fs.writeFileSync(__dirname+'/fixtures/out/polygon.geojson', JSON.stringify(helpers.featureCollection([buffPolygon, polygon]))); + + var buffMultiPolygon = buffer(multipolygon, 0.2, 'kilometers'); + buffMultiPolygon.features.push(multipolygon) + fs.writeFileSync(__dirname+'/fixtures/out/multipolygon.geojson', JSON.stringify(buffMultiPolygon)); + t.ok(buffPt, 'should buffer a point'); t.ok(buffMultiPt, 'should buffer a multipoint'); t.ok(buffLine, 'should buffer a line'); - //t.ok(buffPoly, 'should buffer a polygon'); - //t.ok(buffFC, 'should buffer featurecollection'); + t.ok(buffMultiLine, 'should buffer a multiline'); + t.ok(buffPolygon, 'should buffer a polygon'); + t.ok(buffMultiPolygon, 'should buffer a multipolygon'); t.end(); -}); \ No newline at end of file +}); From 723b6927b155beee49565f70f51e261c10ee088d Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Sun, 12 Jun 2016 17:26:48 +0200 Subject: [PATCH 22/42] strip simplepolygon features --- index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 0d7ac77..b5b12e7 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,4 @@ -var simplepolygon = require('../simplepolygon'); -var plot = require('../node-tests/plot.js'); - +var simplepolygon = require('simplepolygon'); var destination = require('turf-destination'); var bearing = require('turf-bearing'); var helpers = require('turf-helpers'); @@ -9,7 +7,8 @@ var difference = require('turf-difference'); module.exports = function(feature, radius, units, resolution){ if (!resolution) resolution = 32; // Same value as JSTS - if (radius <= 0) throw new Error("The buffer radius must be positive"); + if (radius < 0) throw new Error("The buffer radius must be positive"); + if (radius == 0) return feature; var geom = feature.geometry; if (geom === null) return feature; if(geom.type === 'Point') { @@ -179,6 +178,8 @@ function filterNetWinding(fc, filterFn) { while (i--) { if (!filterFn(fc.features[i].properties.netWinding)) { fc.features.splice(i, 1); + } else { + fc.features[i].properties = {}; } } return fc; From a07f2e7b375f23feae3e8501fadbb37c018583d1 Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Sun, 12 Jun 2016 17:27:18 +0200 Subject: [PATCH 23/42] add package --- package.json | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index f6bbdf3..9880191 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { "name": "turf-buffer", - "version": "0.0.2", + "version": "1.0.0", "description": "turf buffer module", "main": "index.js", "scripts": { - "test": "tape test.js" + "test": "tape test.js" }, "repository": { "type": "git", - "url": "https://github.com/morganherlocker/turf-buffer.git" + "url": "https://github.com/mclaeysb/turf-buffer.git" }, "keywords": [ "buffer", @@ -19,20 +19,21 @@ "geojson", "turf" ], - "author": "morganherlocker", + "author": "Manuel Claeys Bouuaert", "license": "MIT", "bugs": { - "url": "https://github.com/morganherlocker/turf-buffer/issues" + "url": "https://github.com/mclaeysb/turf-buffer/issues" }, - "homepage": "https://github.com/morganherlocker/turf-buffer", + "homepage": "https://github.com/mclaeysb/turf-buffer", "devDependencies": { "tape": "^2.13.3" }, "dependencies": { - "turf-bearing": "0.0.2", - "turf-destination": "0.0.5", - "turf-featurecollection": "^0.1.0", - "turf-point": "^0.1.6", - "turf-polygon": "^0.1.1" + "simplepolygon": "^1.0.0", + "turf-destination": "^3.0.0", + "turf-bearing": "^3.0.0", + "turf-helpers": "^3.0.0", + "turf-union": "^3.0.0", + "turf-difference": "^3.0.0" } } From 72fb68a3e599cb39f7c4850944d3312ff7b1a5e4 Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Sun, 12 Jun 2016 17:30:33 +0200 Subject: [PATCH 24/42] removed old fixtures --- fixtures/FeatureCollection.geojson | 141 ----------------------------- 1 file changed, 141 deletions(-) delete mode 100644 fixtures/FeatureCollection.geojson diff --git a/fixtures/FeatureCollection.geojson b/fixtures/FeatureCollection.geojson deleted file mode 100644 index 966478d..0000000 --- a/fixtures/FeatureCollection.geojson +++ /dev/null @@ -1,141 +0,0 @@ - { - "type": "FeatureCollection", - "features": [ - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [-75.833, 39.284]}, - "properties": { - "name": "Location B", - "category": "House", - "elevation": 25 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [-75.6, 39.984]}, - "properties": { - "name": "Location A", - "category": "Store", - "elevation": 23 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [ -75.221, 39.125]}, - "properties": { - "name": "Location C", - "category": "Office", - "elevation": 29 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [-75.358, 39.987]}, - "properties": { - "name": "Location A", - "category": "Store", - "elevation": 12 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [-75.9221, 39.27]}, - "properties": { - "name": "Location B", - "category": "House", - "elevation": 11 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [ -75.534, 39.123]}, - "properties": { - "name": "Location C", - "category": "Office", - "elevation": 49 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [-75.21, 39.12]}, - "properties": { - "name": "Location A", - "category": "Store", - "elevation": 50 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [-75.22, 39.33]}, - "properties": { - "name": "Location B", - "category": "House", - "elevation": 90 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [ -75.44, 39.55]}, - "properties": { - "name": "Location C", - "category": "Office", - "elevation": 22 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [-75.77, 39.66]}, - "properties": { - "name": "Location A", - "category": "Store", - "elevation": 99 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [-75.44, 39.11]}, - "properties": { - "name": "Location B", - "category": "House", - "elevation": 55 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [ -75.05, 39.92]}, - "properties": { - "name": "Location C", - "category": "Office", - "elevation": 41 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [-75.88, 39.98]}, - "properties": { - "name": "Location A", - "category": "Store", - "elevation": 52 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [-75.55, 39.55]}, - "properties": { - "name": "Location B", - "category": "House", - "elevation": 143 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [ -75.33, 39.44]}, - "properties": { - "name": "Location C", - "category": "Office", - "elevation": 76 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [ -75.56, 39.24]}, - "properties": { - "name": "Location C", - "category": "Office", - "elevation": 18 - } - }, - { "type": "Feature", - "geometry": {"type": "Point", "coordinates": [ -75.56, 39.36]}, - "properties": { - "name": "Location C", - "category": "Office", - "elevation": 52 - } - } - ] - } \ No newline at end of file From 8eb25731db7dce57a4648ed3364d60b697643e5a Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Mon, 13 Jun 2016 17:20:52 +0200 Subject: [PATCH 25/42] moved test.js and fixtures to tests dir --- {fixtures => tests/fixtures}/LineString.geojson | 0 {fixtures => tests/fixtures}/MultiPoint.geojson | 0 {fixtures => tests/fixtures}/Point.geojson | 0 {fixtures => tests/fixtures}/Polygon.geojson | 0 {fixtures => tests/fixtures}/multiLineString.geojson | 0 {fixtures => tests/fixtures}/multiPolygon.geojson | 0 {fixtures => tests/fixtures}/out/line.geojson | 0 {fixtures => tests/fixtures}/out/multiline.geojson | 0 {fixtures => tests/fixtures}/out/multipoint.geojson | 0 {fixtures => tests/fixtures}/out/multipolygon.geojson | 0 {fixtures => tests/fixtures}/out/point.geojson | 0 {fixtures => tests/fixtures}/out/polygon.geojson | 0 test.js => tests/test.js | 0 13 files changed, 0 insertions(+), 0 deletions(-) rename {fixtures => tests/fixtures}/LineString.geojson (100%) rename {fixtures => tests/fixtures}/MultiPoint.geojson (100%) rename {fixtures => tests/fixtures}/Point.geojson (100%) rename {fixtures => tests/fixtures}/Polygon.geojson (100%) rename {fixtures => tests/fixtures}/multiLineString.geojson (100%) rename {fixtures => tests/fixtures}/multiPolygon.geojson (100%) rename {fixtures => tests/fixtures}/out/line.geojson (100%) rename {fixtures => tests/fixtures}/out/multiline.geojson (100%) rename {fixtures => tests/fixtures}/out/multipoint.geojson (100%) rename {fixtures => tests/fixtures}/out/multipolygon.geojson (100%) rename {fixtures => tests/fixtures}/out/point.geojson (100%) rename {fixtures => tests/fixtures}/out/polygon.geojson (100%) rename test.js => tests/test.js (100%) diff --git a/fixtures/LineString.geojson b/tests/fixtures/LineString.geojson similarity index 100% rename from fixtures/LineString.geojson rename to tests/fixtures/LineString.geojson diff --git a/fixtures/MultiPoint.geojson b/tests/fixtures/MultiPoint.geojson similarity index 100% rename from fixtures/MultiPoint.geojson rename to tests/fixtures/MultiPoint.geojson diff --git a/fixtures/Point.geojson b/tests/fixtures/Point.geojson similarity index 100% rename from fixtures/Point.geojson rename to tests/fixtures/Point.geojson diff --git a/fixtures/Polygon.geojson b/tests/fixtures/Polygon.geojson similarity index 100% rename from fixtures/Polygon.geojson rename to tests/fixtures/Polygon.geojson diff --git a/fixtures/multiLineString.geojson b/tests/fixtures/multiLineString.geojson similarity index 100% rename from fixtures/multiLineString.geojson rename to tests/fixtures/multiLineString.geojson diff --git a/fixtures/multiPolygon.geojson b/tests/fixtures/multiPolygon.geojson similarity index 100% rename from fixtures/multiPolygon.geojson rename to tests/fixtures/multiPolygon.geojson diff --git a/fixtures/out/line.geojson b/tests/fixtures/out/line.geojson similarity index 100% rename from fixtures/out/line.geojson rename to tests/fixtures/out/line.geojson diff --git a/fixtures/out/multiline.geojson b/tests/fixtures/out/multiline.geojson similarity index 100% rename from fixtures/out/multiline.geojson rename to tests/fixtures/out/multiline.geojson diff --git a/fixtures/out/multipoint.geojson b/tests/fixtures/out/multipoint.geojson similarity index 100% rename from fixtures/out/multipoint.geojson rename to tests/fixtures/out/multipoint.geojson diff --git a/fixtures/out/multipolygon.geojson b/tests/fixtures/out/multipolygon.geojson similarity index 100% rename from fixtures/out/multipolygon.geojson rename to tests/fixtures/out/multipolygon.geojson diff --git a/fixtures/out/point.geojson b/tests/fixtures/out/point.geojson similarity index 100% rename from fixtures/out/point.geojson rename to tests/fixtures/out/point.geojson diff --git a/fixtures/out/polygon.geojson b/tests/fixtures/out/polygon.geojson similarity index 100% rename from fixtures/out/polygon.geojson rename to tests/fixtures/out/polygon.geojson diff --git a/test.js b/tests/test.js similarity index 100% rename from test.js rename to tests/test.js From 5b5d4f88188b4d32f3a8db9aba1763a5859743e9 Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Thu, 21 Jul 2016 13:04:37 +0200 Subject: [PATCH 26/42] renamed tests to test --- {tests => test}/fixtures/LineString.geojson | 0 {tests => test}/fixtures/MultiPoint.geojson | 0 {tests => test}/fixtures/Point.geojson | 0 {tests => test}/fixtures/Polygon.geojson | 0 {tests => test}/fixtures/multiLineString.geojson | 0 {tests => test}/fixtures/multiPolygon.geojson | 0 test/fixtures/out/line.geojson | 1 + {tests => test}/fixtures/out/multiline.geojson | 0 test/fixtures/out/multipoint.geojson | 1 + {tests => test}/fixtures/out/multipolygon.geojson | 0 test/fixtures/out/point.geojson | 1 + test/fixtures/out/polygon.geojson | 1 + {tests => test}/test.js | 0 tests/fixtures/out/line.geojson | 1 - tests/fixtures/out/multipoint.geojson | 1 - tests/fixtures/out/point.geojson | 1 - tests/fixtures/out/polygon.geojson | 1 - 17 files changed, 4 insertions(+), 4 deletions(-) rename {tests => test}/fixtures/LineString.geojson (100%) rename {tests => test}/fixtures/MultiPoint.geojson (100%) rename {tests => test}/fixtures/Point.geojson (100%) rename {tests => test}/fixtures/Polygon.geojson (100%) rename {tests => test}/fixtures/multiLineString.geojson (100%) rename {tests => test}/fixtures/multiPolygon.geojson (100%) create mode 100644 test/fixtures/out/line.geojson rename {tests => test}/fixtures/out/multiline.geojson (100%) create mode 100644 test/fixtures/out/multipoint.geojson rename {tests => test}/fixtures/out/multipolygon.geojson (100%) create mode 100644 test/fixtures/out/point.geojson create mode 100644 test/fixtures/out/polygon.geojson rename {tests => test}/test.js (100%) delete mode 100644 tests/fixtures/out/line.geojson delete mode 100644 tests/fixtures/out/multipoint.geojson delete mode 100644 tests/fixtures/out/point.geojson delete mode 100644 tests/fixtures/out/polygon.geojson diff --git a/tests/fixtures/LineString.geojson b/test/fixtures/LineString.geojson similarity index 100% rename from tests/fixtures/LineString.geojson rename to test/fixtures/LineString.geojson diff --git a/tests/fixtures/MultiPoint.geojson b/test/fixtures/MultiPoint.geojson similarity index 100% rename from tests/fixtures/MultiPoint.geojson rename to test/fixtures/MultiPoint.geojson diff --git a/tests/fixtures/Point.geojson b/test/fixtures/Point.geojson similarity index 100% rename from tests/fixtures/Point.geojson rename to test/fixtures/Point.geojson diff --git a/tests/fixtures/Polygon.geojson b/test/fixtures/Polygon.geojson similarity index 100% rename from tests/fixtures/Polygon.geojson rename to test/fixtures/Polygon.geojson diff --git a/tests/fixtures/multiLineString.geojson b/test/fixtures/multiLineString.geojson similarity index 100% rename from tests/fixtures/multiLineString.geojson rename to test/fixtures/multiLineString.geojson diff --git a/tests/fixtures/multiPolygon.geojson b/test/fixtures/multiPolygon.geojson similarity index 100% rename from tests/fixtures/multiPolygon.geojson rename to test/fixtures/multiPolygon.geojson diff --git a/test/fixtures/out/line.geojson b/test/fixtures/out/line.geojson new file mode 100644 index 0000000..15f1639 --- /dev/null +++ b/test/fixtures/out/line.geojson @@ -0,0 +1 @@ +{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-58.542642730865424,-34.61651680967873],[-58.54127457316263,-34.655499013609024],[-58.54100311692112,-34.65724723644642],[-58.54032222768283,-34.658918302580105],[-58.53925805062726,-34.66044798735197],[-58.53785146813851,-34.661777496499205],[-58.53749112853128,-34.66204503875536],[-58.46265134850689,-34.71512174031371],[-58.460898745066224,-34.71613700207815],[-58.458938819235684,-34.71685167508136],[-58.45684690758326,-34.717238286795684],[-58.45470342496167,-34.71728197530456],[-58.452590770576435,-34.71698106114521],[-58.450590157413814,-34.71634711193144],[-58.44877848748433,-34.715404497260444],[-58.44722539354153,-34.71418945109324],[-58.446296439413224,-34.7131656262641],[-58.40981842088211,-34.66632264898162],[-58.361814639261475,-34.66016871677381],[-58.35973994484731,-34.65972834992143],[-58.3578095937578,-34.65896348694723],[-58.35609778471125,-34.6579035295741],[-58.35467030884765,-34.6565892217751],[-58.35440149149119,-34.6562724971553],[-58.33655112427222,-34.634240277917755],[-58.33554339410652,-34.632685083853566],[-58.33492379869761,-34.63099800622624],[-58.33471612685466,-34.62924388447208],[-58.33492833349356,-34.62749013059239],[-58.33555223786177,-34.625804138231196],[-58.33656384184282,-34.62425069310079],[-58.337924255510934,-34.62288948422152],[-58.339581193862436,-34.6217728114771],[-58.34147098686903,-34.62094357737438],[-58.34352102549119,-34.6204336399373],[-58.34565254977336,-34.62026258978688],[-58.34778367221524,-34.620436998195856],[-58.34983252073949,-34.62095016487611],[-58.35172038106941,-34.62178237514302],[-58.35337471835351,-34.62290165662338],[-58.354731962422385,-34.62426500656613],[-58.36992349815493,-34.6430104297845],[-58.41805225428046,-34.64918035121087],[-58.42012643248252,-34.649621521326],[-58.422056165127124,-34.65038706855416],[-58.423767310058324,-34.65144758181403],[-58.425194116198305,-34.652762316579945],[-58.425571134641224,-34.653215572303075],[-58.457913165276054,-34.69473549399402],[-58.51956502429024,-34.65101707127775],[-58.52074222351177,-34.617725563259484],[-58.49263071240932,-34.55458664379626],[-58.45419183213516,-34.53641830449851],[-58.452449769095125,-34.5353952000337],[-58.45098352197715,-34.534111768528135],[-58.44984943624581,-34.532617342292795],[-58.44909108271561,-34.53096936097777],[-58.448737584896435,-34.5292311627237],[-58.448802502777696,-34.52746954902546],[-58.449283315492096,-34.52575221705436],[-58.45016152216585,-34.524145158194216],[-58.45140335647487,-34.52271012274876],[-58.45296108690268,-34.521502248140436],[-58.45477485233096,-34.52056794156051],[-58.45677496222563,-34.51994309820322],[-58.45888457306097,-34.519651723307085],[-58.461022638393935,-34.519705010733624],[-58.46310701967217,-34.52010091332792],[-58.46505763880128,-34.52082422149059],[-58.50694430643403,-34.54062095437875],[-58.5086866337948,-34.5416438797787],[-58.51015325744703,-34.54292712220878],[-58.51128781429208,-34.54442137814303],[-58.511758959822856,-34.5453239659329],[-58.54197972987419,-34.613162724222406],[-58.54251622669043,-34.61486894506955],[-58.542642730865424,-34.61651680967873]]]}},{"type":"Feature","properties":{},"geometry":{"type":"LineString","coordinates":[[-58.34564208984375,-34.62925297943919],[-58.363494873046875,-34.651285198954135],[-58.41636657714844,-34.65806316573297],[-58.45550537109375,-34.70831578223845],[-58.530349731445305,-34.65523908026755],[-58.531723022460945,-34.61625687562895],[-58.50151062011719,-34.54841811625336],[-58.45962524414062,-34.5286213832762]]}}]} \ No newline at end of file diff --git a/tests/fixtures/out/multiline.geojson b/test/fixtures/out/multiline.geojson similarity index 100% rename from tests/fixtures/out/multiline.geojson rename to test/fixtures/out/multiline.geojson diff --git a/test/fixtures/out/multipoint.geojson b/test/fixtures/out/multipoint.geojson new file mode 100644 index 0000000..5f6d8da --- /dev/null +++ b/test/fixtures/out/multipoint.geojson @@ -0,0 +1 @@ +{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-89.43283081054688,43.07988460444513],[-89.43042948417204,43.07971183144844],[-89.42812047875512,43.07920015488571],[-89.42599256141995,43.07836924633866],[-89.42412752910742,43.077251049335764],[-89.42259706177398,43.07588854992519],[-89.42145996658371,43.07433412255722],[-89.42075991917837,43.07264751517655],[-89.42052378864385,43.070893551289195],[-89.42076061002531,43.06913963759439],[-89.42146124310243,43.06745317315005],[-89.42259872962609,43.06589895970141],[-89.42412933437755,43.06453671262589],[-89.4259942292721,43.063418767958055],[-89.4281217552739,43.06258807333033],[-89.43043017501904,43.06207653970394],[-89.43283081054688,43.06190381689982],[-89.43523144607471,43.06207653970394],[-89.43753986581984,43.06258807333033],[-89.43966739182164,43.063418767958055],[-89.44153228671618,43.06453671262589],[-89.44306289146765,43.06589895970141],[-89.44420037799132,43.06745317315005],[-89.44490101106842,43.06913963759439],[-89.44513783244989,43.070893551289195],[-89.44490170191538,43.07264751517655],[-89.44420165451002,43.07433412255722],[-89.44306455931977,43.07588854992519],[-89.44153409198631,43.077251049335764],[-89.43966905967379,43.07836924633866],[-89.43754114233862,43.07920015488571],[-89.43523213692171,43.07971183144844],[-89.43283081054688,43.07988460444513]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-89.37103271484375,43.093551705216576],[-89.36863085264223,43.0933789322079],[-89.36632133201772,43.09286725561097],[-89.36419293991662,43.092036347012744],[-89.3623274915404,43.090918149949495],[-89.36079668284009,43.08955565047858],[-89.35965933409281,43.08800122305947],[-89.35895913066874,43.08631461564464],[-89.35872294762608,43.084560651745285],[-89.35895982200027,43.0828067380625],[-89.35966061150692,43.08112027365235],[-89.36079835186209,43.07956606025488],[-89.36232929807682,43.078203813239696],[-89.36419460893865,43.07708586863219],[-89.36632260943189,43.07625517405561],[-89.3686315439738,43.075743640463386],[-89.37103271484375,43.07557091767128],[-89.3734338857137,43.075743640463386],[-89.3757428202556,43.07625517405561],[-89.37787082074884,43.07708586863219],[-89.37973613161068,43.078203813239696],[-89.38126707782541,43.07956606025488],[-89.38240481818058,43.08112027365235],[-89.38310560768723,43.0828067380625],[-89.38334248206141,43.084560651745285],[-89.38310629901876,43.08631461564464],[-89.38240609559469,43.08800122305947],[-89.38126874684741,43.08955565047858],[-89.3797379381471,43.090918149949495],[-89.37787248977088,43.092036347012744],[-89.37574409766978,43.09286725561097],[-89.37343457704527,43.0933789322079],[-89.37103271484375,43.093551705216576]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-89.329833984375,43.11623988170934],[-89.3274312318401,43.11606710868072],[-89.32512085514308,43.115555432026994],[-89.3229916741676,43.11472452334378],[-89.3211255344571,43.113606326180296],[-89.31959415853927,43.112243826609145],[-89.31845638847997,43.11068939910506],[-89.31775592581415,43.10900279163348],[-89.31751965552368,43.10724882771422],[-89.31775661795102,43.105494914051405],[-89.31845766738216,43.10380844969806],[-89.31959582950552,43.102254236385555],[-89.32112734309794,43.100891989470604],[-89.32299334513388,43.09977404496331],[-89.32512213404532,43.09894335047169],[-89.32743192397702,43.09843181693621],[-89.329833984375,43.098259094164035],[-89.33223604477298,43.09843181693621],[-89.33454583470468,43.09894335047169],[-89.33667462361612,43.09977404496331],[-89.33854062565206,43.100891989470604],[-89.34007213924447,43.102254236385555],[-89.34121030136784,43.10380844969806],[-89.34191135079898,43.105494914051405],[-89.34214831322632,43.10724882771422],[-89.34191204293585,43.10900279163348],[-89.34121158027003,43.11068939910506],[-89.34007381021073,43.112243826609145],[-89.3385424342929,43.113606326180296],[-89.3366762945824,43.11472452334378],[-89.33454711360692,43.115555432026994],[-89.3322367369099,43.11606710868072],[-89.329833984375,43.11623988170934]]]}},{"type":"Feature","properties":{},"geometry":{"type":"MultiPoint","coordinates":[[-89.43283081054688,43.07089421067248],[-89.37103271484375,43.08456131144392],[-89.329833984375,43.107249487936684]]}}]} \ No newline at end of file diff --git a/tests/fixtures/out/multipolygon.geojson b/test/fixtures/out/multipolygon.geojson similarity index 100% rename from tests/fixtures/out/multipolygon.geojson rename to test/fixtures/out/multipolygon.geojson diff --git a/test/fixtures/out/point.geojson b/test/fixtures/out/point.geojson new file mode 100644 index 0000000..af832d2 --- /dev/null +++ b/test/fixtures/out/point.geojson @@ -0,0 +1 @@ +{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-75.4,39.40899039377264],[-75.39926936767758,39.40897265099946],[-75.3985416199388,39.40891949272955],[-75.3978196299656,39.40883112883496],[-75.39710624818191,39.408707908180624],[-75.39640429098748,39.40855031724542],[-75.39571652962704,39.40835897819938],[-75.39504567923856,39.408134646444644],[-75.39439438812435,39.40787820762989],[-75.39376522728739,39.407590674150114],[-75.39316068027439,39.40727318114572],[-75.39258313336595,39.40692698201667],[-75.39203486615253,39.406553443469534],[-75.39151804253359,39.406154040117215],[-75.39103470217545,39.40573034865255],[-75.39058675246174,39.40528404161902],[-75.39017596096797,39.404816880803324],[-75.38980394849013,39.40433071027574],[-75.38947218265464,39.40382744910619],[-75.38918197213476,39.403309083784556],[-75.38893446149623,39.40277766037547],[-75.38873062669217,39.402235276438454],[-75.38857127122499,39.40168407274549],[-75.38845702299024,39.40112622482875],[-75.38838833181444,39.40056393439188],[-75.3883654676965,39.39999942061881],[-75.38838851975946,39.39943491141433],[-75.38845739591629,39.39887263461119],[-75.3885718232508,39.39831480917831],[-75.38873134911195,39.397763636464745],[-75.38893534291702,39.39722129151411],[-75.38918299865601,39.39668991448354],[-75.38947333808748,39.39617160220114],[-75.38980521461271,39.395668399895094],[-75.39017731781279,39.39518229312696],[-75.39058817863054,39.39471519996114],[-75.3910361751767,39.39426896340104],[-75.39151953913716,39.393845344121935],[-75.39203636275612,39.39344601352891],[-75.39258460636721,39.39307254716733],[-75.39316210644321,39.39272641851171],[-75.39376658413225,39.3924089931572],[-75.39439565424699,39.39212152343688],[-75.39504683467145,39.391865143485624],[-75.39571755614833,39.39164086477013],[-75.39640517240831,39.391449572102616],[-75.39710697060174,39.391292020153784],[-75.39782018199143,39.39116883047885],[-75.39854199286486,39.39108048906812],[-75.39926955562261,39.39102734443195],[-75.4,39.39100960622736],[-75.4007304443774,39.39102734443195],[-75.40145800713515,39.39108048906812],[-75.40217981800858,39.39116883047885],[-75.40289302939827,39.391292020153784],[-75.4035948275917,39.391449572102616],[-75.40428244385168,39.39164086477013],[-75.40495316532856,39.391865143485624],[-75.40560434575302,39.39212152343688],[-75.40623341586776,39.3924089931572],[-75.4068378935568,39.39272641851171],[-75.4074153936328,39.39307254716733],[-75.4079636372439,39.39344601352891],[-75.40848046086285,39.393845344121935],[-75.4089638248233,39.39426896340104],[-75.40941182136947,39.39471519996114],[-75.40982268218723,39.39518229312696],[-75.4101947853873,39.395668399895094],[-75.41052666191253,39.39617160220114],[-75.410817001344,39.39668991448354],[-75.41106465708299,39.39722129151411],[-75.41126865088805,39.397763636464745],[-75.41142817674921,39.39831480917831],[-75.4115426040837,39.39887263461119],[-75.41161148024055,39.39943491141433],[-75.41163453230351,39.39999942061881],[-75.41161166818557,39.40056393439188],[-75.41154297700976,39.40112622482875],[-75.41142872877502,39.40168407274549],[-75.41126937330785,39.402235276438454],[-75.41106553850378,39.40277766037547],[-75.41081802786525,39.403309083784556],[-75.41052781734537,39.40382744910619],[-75.41019605150989,39.40433071027574],[-75.40982403903205,39.404816880803324],[-75.40941324753827,39.40528404161902],[-75.40896529782457,39.40573034865255],[-75.40848195746642,39.406154040117215],[-75.40796513384748,39.406553443469534],[-75.40741686663405,39.40692698201667],[-75.40683931972562,39.40727318114572],[-75.40623477271262,39.407590674150114],[-75.40560561187564,39.40787820762989],[-75.40495432076145,39.408134646444644],[-75.40428347037297,39.40835897819938],[-75.40359570901252,39.40855031724542],[-75.4028937518181,39.408707908180624],[-75.4021803700344,39.40883112883496],[-75.40145838006121,39.40891949272955],[-75.40073063232242,39.40897265099946],[-75.4,39.40899039377264]]]}},{"type":"Feature","geometry":{"type":"Point","coordinates":[-75.4,39.4]},"properties":{"name":"Location A","category":"Store"}}]} \ No newline at end of file diff --git a/test/fixtures/out/polygon.geojson b/test/fixtures/out/polygon.geojson new file mode 100644 index 0000000..80b88d5 --- /dev/null +++ b/test/fixtures/out/polygon.geojson @@ -0,0 +1 @@ +{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-79.9849887038998,32.83683591214674],[-79.9842928936063,32.76064829534015],[-79.984071463671,32.7588957347204],[-79.98344773383104,32.757213174888186],[-79.982445693391,32.75566526994679],[-79.98110386320529,32.75431149655146],[-79.9794738133657,32.75320386954351],[-79.97761818073721,32.752384944557676],[-79.97560826262581,32.751886184131905],[-79.97352127893576,32.75172674988109],[-79.97241962904334,32.751781676792525],[-79.94472608072554,32.75436923172295],[-79.94822036641213,32.74341178594307],[-79.94856222216308,32.741672974559805],[-79.94849420093801,32.73991147812454],[-79.94801894064798,32.738194989302386],[-79.94715472675587,32.73658946734588],[-79.9459347863079,32.735156603995925],[-79.94440600863459,32.733951453855056],[-79.94262714224914,32.733020320120986],[-79.94066653741295,32.732398976709604],[-79.9395850481398,32.732204712792466],[-79.80706212613109,32.71429875671359],[-79.8049712597958,32.71419227379111],[-79.80289587151414,32.71443100659214],[-79.80091569425777,32.715005783449016],[-79.79910680630014,32.71589452221195],[-79.79753871043647,32.71706307790994],[-79.79627166481986,32.718466553589735],[-79.79535436771548,32.720051024160654],[-79.79482208507906,32.7217556072302],[-79.79469529306343,32.72351480157398],[-79.79470199559525,32.72364103345045],[-79.80703753076527,32.923866798053545],[-79.80735097469159,32.92560947457513],[-79.8080634528841,32.927267334842],[-79.80914760380932,32.92877666174044],[-79.81056177544086,32.93007944371511],[-79.8122516242035,32.93112560548598],[-79.81415220302256,32.93187493395129],[-79.81418128437302,32.93188355508795],[-79.91786352854136,32.962425829008595],[-79.91990393392132,32.96284459212799],[-79.9220025120135,32.96292128890985],[-79.92407859152152,32.96265297105664],[-79.92605236678787,32.962049952929625],[-79.9278479681969,32.96113541470802],[-79.92939638062498,32.95994451059291],[-79.93063809735312,32.95852301647866],[-79.9314344195749,32.95713450690191],[-79.9842928953925,32.84009469482486],[-79.98484132033083,32.838393571313716],[-79.9849887038998,32.83683591214674]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-79.92141723632812,32.953944317478246],[-79.97428894042969,32.83690450361482],[-79.97360229492188,32.76071688548088],[-79.93034362792969,32.76475877693074],[-79.93789672851562,32.74108223150125],[-79.80537414550781,32.7231762754146],[-79.81773376464844,32.923402043498875],[-79.92141723632812,32.953944317478246]]]}}]} \ No newline at end of file diff --git a/tests/test.js b/test/test.js similarity index 100% rename from tests/test.js rename to test/test.js diff --git a/tests/fixtures/out/line.geojson b/tests/fixtures/out/line.geojson deleted file mode 100644 index d45fe57..0000000 --- a/tests/fixtures/out/line.geojson +++ /dev/null @@ -1 +0,0 @@ -{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.6586143206309583,51.016573022446345],[3.659092126750731,51.018309626832234],[3.6600993676097535,51.01995421620466],[3.661597381140627,51.021443576931546],[3.6635286258876567,51.022720456224995],[3.6658188882723826,51.02373576499673],[3.6826783020922234,51.029758410321854],[3.675050482833044,51.03030075900952],[3.673461589505872,51.03047025970008],[3.6708037456286027,51.03102895648357],[3.6683701976277754,51.031902963851174],[3.666254434096599,51.03305871086328],[3.664537754016948,51.03445180198013],[3.663286143801658,51.036028720240566],[3.662547739141385,51.03772888103503],[3.6623509695488514,51.03948695798198],[3.662703457759199,51.04123539188418],[3.663591717508776,51.042906986576064],[3.664981662719432,51.04443749196857],[3.6779154455560366,51.05590380317674],[3.6655945601914683,51.07121148484877],[3.6646501010667047,51.07269899749903],[3.6641141592902695,51.074428953171484],[3.6641256470277743,51.076191363760806],[3.664684184538928,51.077918500659045],[3.665768364386251,51.079543983396746],[3.6673365654528287,51.08100533175784],[3.6693285458192277,51.082246368963524],[3.6716677542929714,51.0832193832522],[3.6742642722999914,51.083886964369974],[3.6770182730734353,51.084223443946506],[3.712228816705203,51.08632396695713],[3.7243632262946176,51.09708160209229],[3.725273049559862,51.09780530912813],[3.727320785049455,51.09901049987022],[3.7297036792483076,51.09994161246693],[3.7323301315650204,51.10056284736865],[3.7350991624536887,51.100850318059486],[3.7379043010769353,51.100792970953854],[3.740637685837568,51.100393011131516],[3.7431942188381635,51.099665817405366],[3.7454756131818954,51.098639350014636],[3.7473941762912695,51.097353073905595],[3.748876182908117,51.095856439315966],[3.7498647076927347,51.09420697848032],[3.7503218086632746,51.09246809204847],[3.7507233048147324,51.08862039722229],[3.792717840902223,51.091125626629726],[3.793642970164616,51.09116141593518],[3.7964423149137536,51.09103978749103],[3.799150047178124,51.09057742012819],[3.8016620570439357,51.089792092190784],[3.803881772135169,51.0887139988731],[3.805723874507378,51.087384589476585],[3.8071175817313714,51.085854971675886],[3.808009365717739,51.084183944553],[3.8111252919617007,51.075643200345425],[3.8144444540888722,51.07682889615187],[3.8170063369502487,51.07754684811742],[3.819741986377078,51.07793693315809],[3.8225462172044824,51.077984152151004],[3.825311202760056,51.077686689457686],[3.8279306279754177,51.07705598285647],[3.830303783884625,51.07611628301165],[3.83233944480781,51.07490371955904],[3.8339593781561634,51.07346490999887],[3.8351013513616232,51.07185516526167],[3.8357215203027217,51.07013636135589],[3.8357961079204634,51.0683745593127],[3.8353223094755826,51.06663746522596],[3.8343183909513177,51.064991828189974],[3.832822978248621,51.06350087615373],[3.8308935658363508,51.06222188808001],[3.828604303228536,51.06120399540906],[3.817800975960516,51.057345171128894],[3.827219585120492,51.03152879251914],[3.82752980176853,51.030279298008864],[3.8274914724539033,51.02851703750731],[3.826907263180253,51.026793339667435],[3.8257996809856882,51.02517443733476],[3.824211331943632,51.023722529960885],[3.8222032774001464,51.02249339545404],[3.8198526840804075,51.0215342494172],[3.8172498588757513,51.02088193362307],[3.8144947822215127,51.020561502894175],[3.8116932727039083,51.02058526428451],[3.7574199132482016,51.02444417654771],[3.758879605459214,51.01045537454812],[3.758881426459545,51.01043762312298],[3.7587842210317888,51.008676259292656],[3.7581427829982146,51.00696066942304],[3.7569818174977034,51.00535677404485],[3.7553459801312385,51.00392619536408],[3.753298154735996,51.00272389137752],[3.7509170338286832,51.00179604665926],[3.7482940951497277,51.00117830044946],[3.7455300903971365,51.00089437969232],[3.742731180450636,51.00095518915433],[3.6709764784540857,51.00700318847275],[3.669059151051055,51.00724922976753],[3.666445557879873,51.00788302756216],[3.6640786037239828,51.00882542658476],[3.6620492229714716,51.01004022844987],[3.660435400516278,51.011480768323615],[3.659299175314227,51.01309170528695],[3.6586842531212866,51.01481114628271],[3.6586143206309583,51.016573022446345]],[[3.7525963294499016,51.07067046876077],[3.754199390603992,51.05530770604264],[3.78515381236269,51.06636547504246],[3.782919572755461,51.0724794282812],[3.7525963294499016,51.07067046876077]],[[3.7918389150641683,51.048071821496634],[3.773207730324847,51.041416976534954],[3.794832694022288,51.03987940359399],[3.7918389150641683,51.048071821496634]],[[3.724406715063373,51.06602525278393],[3.7112257837492377,51.0543450560593],[3.7184952733827568,51.04530712842166],[3.7249247041392595,51.044849984590336],[3.726567737676786,51.045436921263196],[3.724406715063373,51.06602525278393]]]}},{"type":"Feature","properties":{},"geometry":{"type":"LineString","coordinates":[[3.8215255737304688,51.069016659603896],[3.6728668212890625,51.01591456640252],[3.7446212768554688,51.0098665670808],[3.736038208007812,51.09187928712511],[3.676643371582031,51.03923517590972],[3.8132858276367188,51.029519681180965],[3.7940597534179683,51.082174834773625],[3.6783599853515625,51.07527265208853],[3.7229919433593746,51.01980214947295]]}}]} \ No newline at end of file diff --git a/tests/fixtures/out/multipoint.geojson b/tests/fixtures/out/multipoint.geojson deleted file mode 100644 index 480a62d..0000000 --- a/tests/fixtures/out/multipoint.geojson +++ /dev/null @@ -1 +0,0 @@ -{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.7276268005371094,51.06560042946088],[3.7304177744418525,51.06542764833891],[3.7331014322719107,51.06491594863794],[3.7355745912680947,51.064085005463895],[3.7377421750555526,51.06296676761904],[3.739520872592203,51.06160422737134],[3.740842341591027,51.060049765389394],[3.741655833033616,51.05836313488773],[3.741930136198847,51.05660916289145],[3.7416547702584415,51.054855257332854],[3.7408403778385426,51.053168816029746],[3.739518306825894,51.051614637203436],[3.7377393978900586,51.050252430960604],[3.7355720255016878,51.04913452712063],[3.7330994685192875,51.04830386710224],[3.73041671166658,51.047792356599835],[3.7276268005371094,51.047619641915574],[3.724836889407639,51.047792356599835],[3.722154132554931,51.04830386710224],[3.719681575572531,51.04913452712063],[3.71751420318416,51.050252430960604],[3.715735294248325,51.051614637203436],[3.7144132232356757,51.053168816029746],[3.7135988308157772,51.054855257332854],[3.7133234648753715,51.05660916289145],[3.7135977680406027,51.05836313488773],[3.7144112594831915,51.060049765389394],[3.7157327284820156,51.06160422737134],[3.717511426018666,51.06296676761904],[3.7196790098061236,51.064085005463895],[3.722152168802308,51.06491594863794],[3.7248358266323662,51.06542764833891],[3.7276268005371094,51.06560042946088]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.716640472412109,51.059557739214206],[3.719431082038513,51.059384958099415],[3.722114389610197,51.058873258418856],[3.724587225845964,51.05804231527536],[3.726754526786323,51.05692407746653],[3.728532992263004,51.05556153725485],[3.7298542889027426,51.054007075303446],[3.730667674298917,51.05232044482217],[3.730941941787947,51.05056647283305],[3.7306666118916287,51.04881256726728],[3.7298523258300236,51.04712612594375],[3.72853042738485,51.045571947086906],[3.7267517505821606,51.04420974080804],[3.7245846609677113,51.04309183693204],[3.7221124265373384,51.04226117688314],[3.7194300196311265,51.04174966636033],[3.716640472412109,51.041576951668915],[3.7138509251930913,51.04174966636033],[3.7111685182868794,51.04226117688314],[3.7086962838565065,51.04309183693204],[3.7065291942420573,51.04420974080804],[3.704750517439368,51.045571947086906],[3.7034286189941943,51.04712612594375],[3.702614332932589,51.04881256726728],[3.702339003036271,51.05056647283305],[3.7026132705253008,51.05232044482217],[3.7034266559214752,51.054007075303446],[3.7047479525612137,51.05556153725485],[3.7065264180378947,51.05692407746653],[3.708693718978254,51.05804231527536],[3.711166555214021,51.058873258418856],[3.713849862785705,51.059384958099415],[3.716640472412109,51.059557739214206]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.7492561340332027,51.04293627515394],[3.7520457422994267,51.04276349405885],[3.754728087050223,51.04225179443442],[3.757200036053871,51.04142085137491],[3.7593665594793086,51.04030261366514],[3.7611443870491494,51.03894007355252],[3.7624652098930422,51.03738561168505],[3.763278303779432,51.03569898125985],[3.7635524731984824,51.03394500929039],[3.763277242383212,51.03219110370489],[3.762463248688535,51.030504662325214],[3.761141824611932,51.028950483384406],[3.7593637859171976,51.02758827700651],[3.7571974736165554,51.02647037303149],[3.754726125845577,51.02563971289865],[3.752044680903109,51.02512820231977],[3.7492561340332027,51.02495548760865],[3.746467587163296,51.02512820231977],[3.7437861422208285,51.02563971289865],[3.74131479444985,51.02647037303149],[3.739148482149208,51.02758827700651],[3.7373704434544734,51.028950483384406],[3.736049019377871,51.030504662325214],[3.735235025683193,51.03219110370489],[3.7349597948679234,51.03394500929039],[3.7352339642869734,51.03569898125985],[3.736047058173363,51.03738561168505],[3.737367881017256,51.03894007355252],[3.7391457085870967,51.04030261366514],[3.7413122320125343,51.04142085137491],[3.7437841810161827,51.04225179443442],[3.7464665257669787,51.04276349405885],[3.7492561340332027,51.04293627515394]]]}},{"type":"Feature","properties":{},"geometry":{"type":"MultiPoint","coordinates":[[3.7276268005371094,51.05661003568822],[3.716640472412109,51.05056734544155],[3.7492561340332027,51.0339458813813]]}}]} \ No newline at end of file diff --git a/tests/fixtures/out/point.geojson b/tests/fixtures/out/point.geojson deleted file mode 100644 index e7c0629..0000000 --- a/tests/fixtures/out/point.geojson +++ /dev/null @@ -1 +0,0 @@ -{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.7220799922943115,51.06318614557589],[3.7229782334105703,51.0631684016458],[3.7238729275207567,51.0631152399234],[3.7247605416497005,51.063026870335236],[3.7256375708281544,51.06290364183607],[3.7265005519562684,51.06274604102854],[3.727346077500311,51.062554690238464],[3.7281708089681302,51.062330345053255],[3.7289714901097333,51.06207389133348],[3.729744959790485,51.06178634170932],[3.7304881644857804,51.06146883157587],[3.731198170347575,51.061122614603306],[3.7318721747948973,51.06074905777972],[3.7325075175824303,51.0603496360063],[3.733101691303327,51.05992592626649],[3.733652351284774,51.05947960139204],[3.73415732483723,51.05901242345105],[3.7346146198209165,51.05852623678391],[3.7350224324958665,51.058022960715114],[3.7353791546247592,51.057504581969496],[3.7356833798007427,51.056973146823374],[3.7359339089755834,51.056430753021345],[3.7361297551666692,51.055879541490924],[3.7362701473247,51.05532168788785],[3.736354533347216,51.05475939400537],[3.736382582226557,51.054194879081685],[3.7363541853242475,51.05363037103967],[3.7362694567672925,51.053068097693675],[3.7361287329653234,51.05251027795802],[3.735932571251023,51.051959113091854],[3.7356817476496804,51.05141677801497],[3.7353772537871888,51.05088541272878],[3.7350202929491294,51.05036711387614],[3.73461227530694,51.04986392647339],[3.734154812330397,51.04937783584708],[3.733649710408814,51.048910759807065],[3.733098963706431,51.0484645410867],[3.73250474628043,51.04804094007996],[3.73186940349288,51.04764162790382],[3.731195442750628,51.0472681798133],[3.73048552360974,51.046922068994824],[3.7297424472835448,51.04660466076235],[3.728969145595631,51.04631720717902],[3.7281686694212577,51.04606084212531],[3.7273441766626023,51.04583657683308],[3.726498919805074,51.04564529590295],[3.725636233103477,51.04548775382058],[3.7247595194482592,51.045364571985665],[3.7238722369632815,51.04527623626493],[3.7229778853875675,51.04522309507902],[3.7220799922943115,51.04520535803059],[3.721182099201055,51.04522309507902],[3.7202877476253415,51.04527623626493],[3.7194004651403634,51.045364571985665],[3.718523751485146,51.04548775382058],[3.7176610647835484,51.04564529590295],[3.7168158079260203,51.04583657683308],[3.715991315167365,51.04606084212531],[3.7151908389929917,51.04631720717902],[3.714417537305078,51.04660466076235],[3.713674460978883,51.046922068994824],[3.712964541837995,51.0472681798133],[3.712290581095743,51.04764162790382],[3.7116552383081927,51.04804094007996],[3.7110610208821915,51.0484645410867],[3.7105102741798084,51.048910759807065],[3.7100051722582257,51.04937783584708],[3.7095477092816824,51.04986392647339],[3.709139691639493,51.05036711387614],[3.708782730801434,51.05088541272878],[3.708478236938942,51.05141677801497],[3.7082274133375996,51.051959113091854],[3.708031251623299,51.05251027795802],[3.70789052782133,51.053068097693675],[3.707805799264375,51.05363037103967],[3.7077774023620655,51.054194879081685],[3.7078054512414065,51.05475939400537],[3.7078898372639224,51.05532168788785],[3.7080302294219534,51.055879541490924],[3.708226075613039,51.056430753021345],[3.70847660478788,51.056973146823374],[3.708780829963864,51.057504581969496],[3.709137552092756,51.058022960715114],[3.7095453647677066,51.05852623678391],[3.7100026597513924,51.05901242345105],[3.7105076333038487,51.05947960139204],[3.7110582932852956,51.05992592626649],[3.7116524670061923,51.0603496360063],[3.7122878097937253,51.06074905777972],[3.7129618142410474,51.061122614603306],[3.7136718201028422,51.06146883157587],[3.714415024798138,51.06178634170932],[3.7151884944788893,51.06207389133348],[3.7159891756204924,51.062330345053255],[3.7168139070883117,51.062554690238464],[3.717659432632354,51.06274604102854],[3.718522413760468,51.06290364183607],[3.719399442938922,51.063026870335236],[3.720287057067866,51.0631152399234],[3.7211817511780523,51.0631684016458],[3.7220799922943115,51.06318614557589]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[3.7220799922943115,51.054195751803235]}}]} \ No newline at end of file diff --git a/tests/fixtures/out/polygon.geojson b/tests/fixtures/out/polygon.geojson deleted file mode 100644 index f1caa68..0000000 --- a/tests/fixtures/out/polygon.geojson +++ /dev/null @@ -1 +0,0 @@ -{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.6239356139608048,51.03768314391359],[3.623995646413216,51.03944516498373],[3.624601244321493,51.04116596327851],[3.6257291907574074,51.0427794013141],[3.6273361810400595,51.044223461301286],[3.6293604805605555,51.04544263062641],[3.670410471608452,51.06571985893848],[3.6373411569776652,51.08964894076741],[3.6369388955799216,51.089952999975104],[3.6354171638439845,51.09143375004424],[3.634384526159314,51.093072500807715],[3.633880711257676,51.09480628927196],[3.633925138269327,51.09656849377433],[3.634516161659739,51.098291393171166],[3.63563112506223,51.09990876941493],[3.637227223369592,51.10135845349178],[3.63924314126255,51.102584716695766],[3.641601406191085,51.10354041501686],[3.6442113658943267,51.10418880381395],[3.6469726759914995,51.10450495258563],[3.6497791630280725,51.104476705059255],[3.6999043663683437,51.100878835713615],[3.7235689763551,51.130604453138766],[3.7247688442182136,51.13184760536748],[3.7266285734205424,51.133168289955044],[3.728863261599383,51.13423588466668],[3.7313870144647447,51.135009343702166],[3.7341028075306277,51.135458928135556],[3.736906220510142,51.13556735110075],[3.7396894583365006,51.13533044357699],[3.7423455030331114,51.134757314965704],[3.744772235450565,51.13387000223231],[3.746876367087599,51.13270262121667],[3.7485770297645344,51.13130005300463],[3.7498088844923774,51.12971621623517],[3.7697190108376972,51.096104255967994],[3.817602981435303,51.08213050409087],[3.8189740985535288,51.081671491473706],[3.8212207534071783,51.08061597408976],[3.8230963474113944,51.07930535635888],[3.824528809095844,51.077790023873206],[3.825463119315293,51.07612822704082],[3.8258634210984677,51.074383839962415],[3.825714390291,51.07262390393199],[3.825021815435785,51.070916050245174],[3.8238123659801793,51.0693259014816],[3.8221325591396287,51.06791455107991],[3.8200469663741825,51.0667362178484],[3.7929560490125467,51.05421915589585],[3.806808409437143,51.02262311037757],[3.8068218866971537,51.02259212799537],[3.807287946480942,51.02085425622335],[3.8072060514457107,51.01909258392693],[3.8065794101993164,51.01737481005206],[3.8054321595784275,51.01576693924653],[3.8038084286587943,51.01433074662428],[3.801770636682713,51.01312140598429],[3.7993970912577018,51.01218537229461],[3.7967789795907025,51.01155859939318],[3.794016868297561,51.0112651609512],[3.791216845676353,51.01131632729171],[3.788486453631389,51.011710133243696],[3.749454282176116,51.01995186249333],[3.7224217498412844,51.000495351773715],[3.7216126822047624,50.99995884679903],[3.719421503589369,50.998861312109504],[3.716932286512153,50.99805384039214],[3.7142406545305717,50.99756744658318],[3.711449993460075,50.997420812266135],[3.7086674862412954,50.9976195693094],[3.706000003178978,50.99815608392442],[3.7035500040871088,50.99900974936876],[3.701411608433535,51.00014777614589],[3.6996669833478424,51.00152644959384],[3.6983831875433553,51.00309280691358],[3.6976095922011436,51.00478666963079],[3.689368787979985,51.03301492942801],[3.6398269862841484,51.029440308170216],[3.6392845995177066,51.02940759660506],[3.636482954436899,51.02944567766051],[3.6337469197250103,51.029826714205285],[3.631181583852597,51.03053607139071],[3.6288854896164318,51.03154650328271],[3.6269468535295326,51.032819197737595],[3.625440178924165,51.034305265163766],[3.624423392434488,51.03594761437765],[3.6239356139608048,51.03768314391359]],[[3.721762883390001,51.06247446604107],[3.7241810007220693,51.061699976913765],[3.726383013349649,51.06060871991698],[3.7282038708033167,51.05926840576461],[3.7289431699775766,51.05843837273931],[3.729006736474369,51.05845421114492],[3.731764979548568,51.05877152485842],[3.734383726106786,51.05874624721666],[3.7347767211245326,51.05989408839749],[3.735890175333468,51.06151162354705],[3.737484425699034,51.0629615351491],[3.7437709321235166,51.067625459005264],[3.7409731363186354,51.068089335943085],[3.7394863679210943,51.06839109477429],[3.7369797184523925,51.069181701475955],[3.7347665869642603,51.07026436802838],[3.733346769195304,51.07129611105415],[3.7309116053494655,51.07061820248756],[3.7281748752893753,51.07023233059856],[3.7253709434611517,51.070189296759715],[3.7244901157861885,51.0702302870011],[3.724734333618481,51.06967063460644],[3.724934048013095,51.06791268311181],[3.724584163690284,51.06616402651139],[3.723698186283896,51.064491859897075],[3.722310212779807,51.06296043207257],[3.721762883390001,51.06247446604107]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.7010192871093746,51.04290494383127],[3.7116622924804683,51.00641021333656],[3.7449645996093754,51.03038336319532],[3.7930297851562496,51.0202340830275],[3.7765502929687496,51.057796900048594],[3.811569213867187,51.07397837820157],[3.7583541870117188,51.08950727568543],[3.7363815307617188,51.12658298883994],[3.708229064941406,51.09123238697973],[3.6481475830078125,51.095544883691204],[3.6910629272460938,51.064485930202125],[3.638191223144531,51.03837165885956],[3.7010192871093746,51.04290494383127]],[[3.726425170898438,51.07915525654743],[3.7336349487304683,51.09231054886148],[3.7446212768554688,51.076782592536524],[3.769340515136719,51.072684068113695],[3.7483978271484375,51.057149523259795],[3.758697509765625,51.04463179285938],[3.7329483032226562,51.049811953719086],[3.7260818481445312,51.04031454959097],[3.7164688110351562,51.05412831189872],[3.6948394775390625,51.05412831189872],[3.71063232421875,51.06815369771887],[3.698616027832031,51.08044938563426],[3.726425170898438,51.07915525654743]]]}}]} \ No newline at end of file From f68be484eb3e1cb56a70264186c84163ea98fd15 Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Thu, 21 Jul 2016 14:26:38 +0200 Subject: [PATCH 27/42] basic benchmarks comparing this branch to master which uses jsts --- bench/bench-run.js | 22 ++++ bench/bench-turf-buffer-lineString-large.js | 28 +++++ bench/bench-turf-buffer-lineString.js | 19 ++++ bench/bench-turf-buffer-point.js | 19 ++++ bench/bench-turf-buffer-polygon-large.js | 28 +++++ bench/bench-turf-buffer-polygon.js | 19 ++++ bench/fixtures/LineString-brazil.geojson | 1 + bench/fixtures/LineString.geojson | 41 +++++++ bench/fixtures/MultiLineString.geojson | 37 +++++++ bench/fixtures/MultiPoint.geojson | 21 ++++ bench/fixtures/MultiPolygon.geojson | 113 ++++++++++++++++++++ bench/fixtures/Point.geojson | 8 ++ bench/fixtures/Polygon-brazil.geojson | 1 + bench/fixtures/Polygon.geojson | 43 ++++++++ 14 files changed, 400 insertions(+) create mode 100644 bench/bench-run.js create mode 100644 bench/bench-turf-buffer-lineString-large.js create mode 100644 bench/bench-turf-buffer-lineString.js create mode 100644 bench/bench-turf-buffer-point.js create mode 100644 bench/bench-turf-buffer-polygon-large.js create mode 100644 bench/bench-turf-buffer-polygon.js create mode 100644 bench/fixtures/LineString-brazil.geojson create mode 100644 bench/fixtures/LineString.geojson create mode 100644 bench/fixtures/MultiLineString.geojson create mode 100644 bench/fixtures/MultiPoint.geojson create mode 100644 bench/fixtures/MultiPolygon.geojson create mode 100644 bench/fixtures/Point.geojson create mode 100644 bench/fixtures/Polygon-brazil.geojson create mode 100644 bench/fixtures/Polygon.geojson diff --git a/bench/bench-run.js b/bench/bench-run.js new file mode 100644 index 0000000..7fca99d --- /dev/null +++ b/bench/bench-run.js @@ -0,0 +1,22 @@ +'use strict'; + +var Benchmark = require('benchmark'); + +module.exports = function (config) { + var suite = new Benchmark.Suite(); + + for (var name in config) { + suite.add(name, config[name]); + } + + suite + .on('cycle', function (event) { + console.log(String(event.target)); + }) + .on('complete', function () { + var fastest = this.filter('fastest')[0]; + var slowest = this.filter('slowest')[0]; + console.log(fastest.name + ' is ' + (Math.round(10 * fastest.hz / slowest.hz) / 10) + 'x faster'); + }) + .run(); +}; diff --git a/bench/bench-turf-buffer-lineString-large.js b/bench/bench-turf-buffer-lineString-large.js new file mode 100644 index 0000000..b6aa137 --- /dev/null +++ b/bench/bench-turf-buffer-lineString-large.js @@ -0,0 +1,28 @@ +'use strict'; + +var runBench = require('./bench-run.js'); + +var buffer_geodesicconvolution = require('../'); +var buffer_master = require('turf-buffer'); + +var fs = require('fs'); + +var lineString = JSON.parse(fs.readFileSync(__dirname+'/fixtures/LineString-brazil.geojson')); + +runBench({ + 'turf-buffer-lineString-master': function () { + buffer_master(lineString, 1, 'kilometers'); + }, + 'turf-buffer-lineString-geodesicconvolution': function () { + buffer_geodesicconvolution(lineString, 1, 'kilometers'); + } +}); + +runBench({ + 'turf-buffer-lineString-master': function () { + buffer_master(lineString, 100, 'kilometers'); + }, + 'turf-buffer-lineString-geodesicconvolution': function () { + buffer_geodesicconvolution(lineString, 100, 'kilometers'); + } +}); diff --git a/bench/bench-turf-buffer-lineString.js b/bench/bench-turf-buffer-lineString.js new file mode 100644 index 0000000..78a1b82 --- /dev/null +++ b/bench/bench-turf-buffer-lineString.js @@ -0,0 +1,19 @@ +'use strict'; + +var runBench = require('./bench-run.js'); + +var buffer_geodesicconvolution = require('../'); +var buffer_master = require('turf-buffer'); + +var fs = require('fs'); + +var lineString = JSON.parse(fs.readFileSync(__dirname+'/fixtures/LineString.geojson')); + +runBench({ + 'turf-buffer-lineString-master': function () { + buffer_master(lineString, 1, 'kilometers'); + }, + 'turf-buffer-lineString-geodesicconvolution': function () { + buffer_geodesicconvolution(lineString, 1, 'kilometers'); + } +}); diff --git a/bench/bench-turf-buffer-point.js b/bench/bench-turf-buffer-point.js new file mode 100644 index 0000000..6dfc81e --- /dev/null +++ b/bench/bench-turf-buffer-point.js @@ -0,0 +1,19 @@ +'use strict'; + +var runBench = require('./bench-run.js'); + +var buffer_geodesicconvolution = require('../'); +var buffer_master = require('turf-buffer'); + +var fs = require('fs'); + +var point = JSON.parse(fs.readFileSync(__dirname+'/fixtures/Point.geojson')); + +runBench({ + 'turf-buffer-point-master': function () { + buffer_master(point, 1, 'kilometers'); + }, + 'turf-buffer-point-geodesicconvolution': function () { + buffer_geodesicconvolution(point, 1, 'kilometers'); + } +}); diff --git a/bench/bench-turf-buffer-polygon-large.js b/bench/bench-turf-buffer-polygon-large.js new file mode 100644 index 0000000..afbef74 --- /dev/null +++ b/bench/bench-turf-buffer-polygon-large.js @@ -0,0 +1,28 @@ +'use strict'; + +var runBench = require('./bench-run.js'); + +var buffer_geodesicconvolution = require('../'); +var buffer_master = require('turf-buffer'); + +var fs = require('fs'); + +var polygon = JSON.parse(fs.readFileSync(__dirname+'/fixtures/Polygon-brazil.geojson')); + +runBench({ + 'turf-buffer-polygon-master': function () { + buffer_master(polygon, 1, 'kilometers'); + }, + 'turf-buffer-polygon-geodesicconvolution': function () { + buffer_geodesicconvolution(polygon, 1, 'kilometers'); + } +}); + +runBench({ + 'turf-buffer-polygon-master': function () { + buffer_master(polygon, 100, 'kilometers'); + }, + 'turf-buffer-polygon-geodesicconvolution': function () { + buffer_geodesicconvolution(polygon, 100, 'kilometers'); + } +}); diff --git a/bench/bench-turf-buffer-polygon.js b/bench/bench-turf-buffer-polygon.js new file mode 100644 index 0000000..f7971fe --- /dev/null +++ b/bench/bench-turf-buffer-polygon.js @@ -0,0 +1,19 @@ +'use strict'; + +var runBench = require('./bench-run.js'); + +var buffer_geodesicconvolution = require('../'); +var buffer_master = require('turf-buffer'); + +var fs = require('fs'); + +var polygon = JSON.parse(fs.readFileSync(__dirname+'/fixtures/Polygon.geojson')); + +runBench({ + 'turf-buffer-polygon-master': function () { + buffer_master(polygon, 1, 'kilometers'); + }, + 'turf-buffer-polygon-geodesicconvolution': function () { + buffer_geodesicconvolution(polygon, 1, 'kilometers'); + } +}); diff --git a/bench/fixtures/LineString-brazil.geojson b/bench/fixtures/LineString-brazil.geojson new file mode 100644 index 0000000..5bcddc4 --- /dev/null +++ b/bench/fixtures/LineString-brazil.geojson @@ -0,0 +1 @@ +{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-57.62513342958296,-30.21629485445426],[-56.29089962423908,-28.852760512000895],[-55.16228634298457,-27.881915378533463],[-54.490725267135524,-27.47475676850579],[-53.64873531758789,-26.92347258881609],[-53.628348965048744,-26.124865004177472],[-54.13004960795439,-25.547639255477254],[-54.625290696823576,-25.739255466415514],[-54.42894609233059,-25.162184747012166],[-54.29347632507745,-24.570799655863965],[-54.29295956075452,-24.02101409271073],[-54.65283423523513,-23.83957813893396],[-55.02790178080955,-24.00127369557523],[-55.40074723979542,-23.956935316668805],[-55.517639329639636,-23.571997572526637],[-55.610682745981144,-22.655619398694846],[-55.79795813660691,-22.356929620047822],[-56.47331743022939,-22.086300144135283],[-56.8815095689029,-22.28215382252148],[-57.937155727761294,-22.090175876557172],[-57.8706739976178,-20.73268767668195],[-58.166392381408045,-20.176700941653678],[-57.85380164247451,-19.96999521248619],[-57.949997321185826,-19.40000416430682],[-57.67600887717431,-18.96183969490403],[-57.49837114117099,-18.174187513911292],[-57.734558274961,-17.55246835700777],[-58.28080400250225,-17.271710300366017],[-58.38805843772404,-16.877109063385276],[-58.24121985536668,-16.299573256091293],[-60.158389655179036,-16.258283786690086],[-60.54296566429515,-15.093910414289596],[-60.251148851142936,-15.07721892665932],[-60.26432634137737,-14.645979099183641],[-60.45919816755003,-14.354007256734555],[-60.503304002511136,-13.775954685117659],[-61.08412126325565,-13.479383640194598],[-61.71320431176078,-13.489202162330052],[-62.127080857986385,-13.198780612849724],[-62.803060268796386,-13.000653171442686],[-63.19649878605057,-12.627032565972435],[-64.3163529120316,-12.461978041232193],[-65.40228146021303,-11.566270440317155],[-65.32189876978302,-10.895872084194679],[-65.44483700220539,-10.511451104375432],[-65.33843522811642,-9.761987806846392],[-66.6469083319628,-9.931331475466862],[-67.17380123561074,-10.306812432499612],[-68.04819230820539,-10.712059014532485],[-68.27125362819326,-11.01452117273682],[-68.78615759954948,-11.03638030359628],[-69.52967810736496,-10.951734307502194],[-70.0937522040469,-11.123971856331012],[-70.54868567572841,-11.009146823778465],[-70.48189388699117,-9.490118096558845],[-71.30241227892154,-10.079436130415374],[-72.18489071316985,-10.053597914269432],[-72.56303300646564,-9.520193780152717],[-73.22671342639016,-9.462212823121234],[-73.01538265653255,-9.032833347208062],[-73.57105933296707,-8.424446709835834],[-73.98723548042966,-7.523829847853065],[-73.7234014553635,-7.340998630404414],[-73.72448666044164,-6.91859547285064],[-73.1200274319236,-6.629930922068239],[-73.21971126981461,-6.089188734566078],[-72.9645072089412,-5.741251315944893],[-72.89192765978726,-5.274561455916981],[-71.74840572781655,-4.593982842633011],[-70.92884334988358,-4.401591485210368],[-70.7947688463023,-4.251264743673303],[-69.89363521999663,-4.298186944194327],[-69.44410193548961,-1.556287123219818],[-69.42048580593223,-1.122618503426409],[-69.5770653957766,-0.549991957200163],[-70.02065589057005,-0.185156345219539],[-70.01556576198931,0.541414292804205],[-69.45239600287246,0.706158758950693],[-69.25243404811906,0.602650865070075],[-69.21863766140018,0.985676581217433],[-69.80459672715773,1.089081122233466],[-69.81697323269162,1.714805202639624],[-67.86856502955884,1.692455145673392],[-67.5378100246747,2.03716278727633],[-67.2599975246736,1.719998684084956],[-67.0650481838525,1.130112209473225],[-66.87632585312258,1.253360500489336],[-66.32576514348496,0.724452215982012],[-65.54826738143757,0.78925446207603],[-65.35471330428837,1.0952822941085],[-64.61101192895987,1.328730576987042],[-64.19930579289051,1.49285492594602],[-64.08308549666609,1.91636912679408],[-63.368788011311665,2.200899562993129],[-63.42286739770512,2.411067613124175],[-64.2699991522658,2.497005520025567],[-64.40882788761792,3.126786200366624],[-64.3684944322141,3.797210394705246],[-64.81606401229402,4.056445217297423],[-64.62865943058755,4.14848094320925],[-63.88834286157416,4.020530096854571],[-63.093197597899106,3.770571193858785],[-62.804533047116706,4.006965033377952],[-62.08542965355913,4.162123521334308],[-60.96689327660154,4.536467596856639],[-60.601179165271944,4.91809804933213],[-60.73357418480372,5.200277207861901],[-60.21368343773133,5.244486395687602],[-59.980958624904886,5.014061184098139],[-60.11100236676738,4.574966538914083],[-59.767405768458715,4.423502915866607],[-59.53803992373123,3.958802598481938],[-59.815413174057866,3.606498521332085],[-59.97452490908456,2.755232652188056],[-59.71854570172675,2.24963043864436],[-59.64604366722126,1.786893825686789],[-59.03086157900265,1.317697658692722],[-58.540012986878295,1.268088283692521],[-58.429477098205965,1.463941962078721],[-58.11344987652502,1.507195135907025],[-57.66097103537737,1.682584947105639],[-57.335822923396904,1.948537705895759],[-56.78270423036083,1.863710842288654],[-56.539385748914555,1.899522609866921],[-55.995698004771754,1.817667141116601],[-55.905600145070885,2.02199575439866],[-56.0733418442903,2.220794989425499],[-55.973322109589375,2.510363877773017],[-55.569755011606,2.421506252447131],[-55.09758744975514,2.523748073736613],[-54.524754197799716,2.311848863123785],[-54.08806250671725,2.105556545414629],[-53.77852067728892,2.376702785650082],[-53.554839240113544,2.334896551925951],[-53.41846513529531,2.053389187015981],[-52.939657151894956,2.124857692875636],[-52.55642473001842,2.504705308437053],[-52.249337531123956,3.241094468596245],[-51.65779741067889,4.156232408053029],[-51.31714636901086,4.203490505383954],[-51.069771287629656,3.650397650564031],[-50.508875291533656,1.901563828942457],[-49.97407589374506,1.736483465986069],[-49.94710079608871,1.046189683431223],[-50.699251268096916,0.222984117021682],[-50.38821082213214,-0.078444512536819],[-48.62056677915632,-0.235489190271821],[-48.58449662941659,-1.237805271005001],[-47.824956427590635,-0.5816179337628],[-46.566583624851226,-0.941027520352776],[-44.905703090990414,-1.551739597178134],[-44.417619187993665,-2.137750339367976],[-44.58158850765578,-2.691308282078524],[-43.418791266440195,-2.383110039889793],[-41.47265682632825,-2.912018324397116],[-39.97866533055404,-2.873054294449041],[-38.50038347019657,-3.700652357603396],[-37.2232521225352,-4.820945733258917],[-36.45293738457639,-5.109403578312154],[-35.59779578301047,-5.149504489770649],[-35.23538896334756,-5.464937432480247],[-34.89602983248683,-6.738193047719711],[-34.729993455533034,-7.343220716992967],[-35.12821204277422,-8.996401462442286],[-35.636966518687714,-9.649281508017815],[-37.046518724097,-11.040721123908803],[-37.68361161960736,-12.171194756725823],[-38.42387651218844,-13.038118584854288],[-38.67388709161652,-13.057652276260619],[-38.953275722802545,-13.793369642800023],[-38.88229814304965,-15.667053724838768],[-39.16109249526431,-17.208406670808472],[-39.2673392400564,-17.867746270420483],[-39.58352149103423,-18.262295830968938],[-39.76082333022764,-19.59911345792741],[-40.77474077001034,-20.904511814052423],[-40.94475623225061,-21.93731698983781],[-41.754164191238225,-22.370675551037458],[-41.98828426773656,-22.970070489190896],[-43.07470374202475,-22.96769337330547],[-44.64781185563781,-23.351959323827842],[-45.35213578955992,-23.796841729428582],[-46.47209326840554,-24.088968601174543],[-47.64897233742066,-24.885199069927722],[-48.4954581365777,-25.877024834905654],[-48.64100480812774,-26.623697605090932],[-48.474735887228654,-27.17591196056189],[-48.661520351747626,-28.18613453543572],[-48.8884574041574,-28.674115085567884],[-49.587329474472675,-29.224469089476337],[-50.696874152211485,-30.98446502047296],[-51.576226162306156,-31.77769825615321],[-52.256081305538046,-32.24536996839467],[-52.712099982297694,-33.19657805759118],[-53.373661668498244,-33.768377780900764],[-53.6505439927181,-33.20200408298183],[-53.209588995971544,-32.727666110974724],[-53.78795162618219,-32.047242526987624],[-54.57245154480512,-31.494511407193748],[-55.601510179249345,-30.853878676071393],[-55.97324459494094,-30.883075860316303],[-56.976025763564735,-30.109686374636127],[-57.62513342958296,-30.21629485445426]]}} diff --git a/bench/fixtures/LineString.geojson b/bench/fixtures/LineString.geojson new file mode 100644 index 0000000..991f184 --- /dev/null +++ b/bench/fixtures/LineString.geojson @@ -0,0 +1,41 @@ +{ + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + -58.45962524414062, + -34.5286213832762 + ], + [ + -58.50151062011719, + -34.54841811625336 + ], + [ + -58.531723022460945, + -34.61625687562895 + ], + [ + -58.530349731445305, + -34.65523908026755 + ], + [ + -58.45550537109375, + -34.70831578223845 + ], + [ + -58.41636657714844, + -34.65806316573297 + ], + [ + -58.363494873046875, + -34.651285198954135 + ], + [ + -58.34564208984375, + -34.62925297943919 + ] + ] + } +} \ No newline at end of file diff --git a/bench/fixtures/MultiLineString.geojson b/bench/fixtures/MultiLineString.geojson new file mode 100644 index 0000000..60d5690 --- /dev/null +++ b/bench/fixtures/MultiLineString.geojson @@ -0,0 +1,37 @@ +{ + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiLineString", + "coordinates": [ + [ + [ + 3.70513916015625, + 51.03945105265764 + ], + [ + 3.71063232421875, + 51.06545683812254 + ], + [ + 3.7278421020507812, + 51.04279701362964 + ], + [ + 3.746038208007812, + 51.0584442677861 + ] + ], + [ + [ + 3.7441062927246094, + 51.04387630433032 + ], + [ + 3.6912345886230464, + 51.059631085129986 + ] + ] + ] + } + } \ No newline at end of file diff --git a/bench/fixtures/MultiPoint.geojson b/bench/fixtures/MultiPoint.geojson new file mode 100644 index 0000000..f0b69d0 --- /dev/null +++ b/bench/fixtures/MultiPoint.geojson @@ -0,0 +1,21 @@ +{ + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + -89.43283081054688, + 43.07089421067248 + ], + [ + -89.37103271484375, + 43.08456131144392 + ], + [ + -89.329833984375, + 43.107249487936684 + ] + ] + } +} \ No newline at end of file diff --git a/bench/fixtures/MultiPolygon.geojson b/bench/fixtures/MultiPolygon.geojson new file mode 100644 index 0000000..09eaab2 --- /dev/null +++ b/bench/fixtures/MultiPolygon.geojson @@ -0,0 +1,113 @@ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ + 3.7075424194335938, + 51.03966692839972 + ], + [ + 3.733978271484375, + 51.02995152419996 + ], + [ + 3.7751770019531254, + 51.045279344649146 + ], + [ + 3.76556396484375, + 51.08907598780727 + ], + [ + 3.7140655517578125, + 51.09144802136697 + ], + [ + 3.742904663085937, + 51.06168097070514 + ], + [ + 3.68316650390625, + 51.061465197550305 + ], + [ + 3.7075424194335938, + 51.03966692839972 + ] + ], + [ + [ + 3.7199020385742188, + 51.04938029577453 + ], + [ + 3.730201721191406, + 51.05585474252802 + ], + [ + 3.7408447265625, + 51.04333666212316 + ], + [ + 3.720245361328125, + 51.04204149517769 + ], + [ + 3.7199020385742188, + 51.04938029577453 + ] + ] + ], + [ + [ + [ + 3.8119125366210938, + 51.03966692839972 + ], + [ + 3.8376617431640625, + 51.05089108097961 + ], + [ + 3.7902832031250004, + 51.10201287469917 + ], + [ + 3.773117065429687, + 51.0662119746483 + ], + [ + 3.8119125366210938, + 51.03966692839972 + ] + ], + [ + [ + 3.8002395629882812, + 51.06427017012091 + ], + [ + 3.8005828857421875, + 51.068585180672635 + ], + [ + 3.8174057006835933, + 51.06405440903407 + ], + [ + 3.8129425048828125, + 51.05002778118271 + ], + [ + 3.8002395629882812, + 51.06427017012091 + ] + ] + ] + ] + } + } diff --git a/bench/fixtures/Point.geojson b/bench/fixtures/Point.geojson new file mode 100644 index 0000000..8c290bf --- /dev/null +++ b/bench/fixtures/Point.geojson @@ -0,0 +1,8 @@ +{ + "type": "Feature", + "geometry": {"type": "Point", "coordinates": [-75.4, 39.4]}, + "properties": { + "name": "Location A", + "category": "Store" + } +} \ No newline at end of file diff --git a/bench/fixtures/Polygon-brazil.geojson b/bench/fixtures/Polygon-brazil.geojson new file mode 100644 index 0000000..2936e48 --- /dev/null +++ b/bench/fixtures/Polygon-brazil.geojson @@ -0,0 +1 @@ +{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-57.62513342958296,-30.21629485445426],[-56.29089962423908,-28.852760512000895],[-55.16228634298457,-27.881915378533463],[-54.490725267135524,-27.47475676850579],[-53.64873531758789,-26.92347258881609],[-53.628348965048744,-26.124865004177472],[-54.13004960795439,-25.547639255477254],[-54.625290696823576,-25.739255466415514],[-54.42894609233059,-25.162184747012166],[-54.29347632507745,-24.570799655863965],[-54.29295956075452,-24.02101409271073],[-54.65283423523513,-23.83957813893396],[-55.02790178080955,-24.00127369557523],[-55.40074723979542,-23.956935316668805],[-55.517639329639636,-23.571997572526637],[-55.610682745981144,-22.655619398694846],[-55.79795813660691,-22.356929620047822],[-56.47331743022939,-22.086300144135283],[-56.8815095689029,-22.28215382252148],[-57.937155727761294,-22.090175876557172],[-57.8706739976178,-20.73268767668195],[-58.166392381408045,-20.176700941653678],[-57.85380164247451,-19.96999521248619],[-57.949997321185826,-19.40000416430682],[-57.67600887717431,-18.96183969490403],[-57.49837114117099,-18.174187513911292],[-57.734558274961,-17.55246835700777],[-58.28080400250225,-17.271710300366017],[-58.38805843772404,-16.877109063385276],[-58.24121985536668,-16.299573256091293],[-60.158389655179036,-16.258283786690086],[-60.54296566429515,-15.093910414289596],[-60.251148851142936,-15.07721892665932],[-60.26432634137737,-14.645979099183641],[-60.45919816755003,-14.354007256734555],[-60.503304002511136,-13.775954685117659],[-61.08412126325565,-13.479383640194598],[-61.71320431176078,-13.489202162330052],[-62.127080857986385,-13.198780612849724],[-62.803060268796386,-13.000653171442686],[-63.19649878605057,-12.627032565972435],[-64.3163529120316,-12.461978041232193],[-65.40228146021303,-11.566270440317155],[-65.32189876978302,-10.895872084194679],[-65.44483700220539,-10.511451104375432],[-65.33843522811642,-9.761987806846392],[-66.6469083319628,-9.931331475466862],[-67.17380123561074,-10.306812432499612],[-68.04819230820539,-10.712059014532485],[-68.27125362819326,-11.01452117273682],[-68.78615759954948,-11.03638030359628],[-69.52967810736496,-10.951734307502194],[-70.0937522040469,-11.123971856331012],[-70.54868567572841,-11.009146823778465],[-70.48189388699117,-9.490118096558845],[-71.30241227892154,-10.079436130415374],[-72.18489071316985,-10.053597914269432],[-72.56303300646564,-9.520193780152717],[-73.22671342639016,-9.462212823121234],[-73.01538265653255,-9.032833347208062],[-73.57105933296707,-8.424446709835834],[-73.98723548042966,-7.523829847853065],[-73.7234014553635,-7.340998630404414],[-73.72448666044164,-6.91859547285064],[-73.1200274319236,-6.629930922068239],[-73.21971126981461,-6.089188734566078],[-72.9645072089412,-5.741251315944893],[-72.89192765978726,-5.274561455916981],[-71.74840572781655,-4.593982842633011],[-70.92884334988358,-4.401591485210368],[-70.7947688463023,-4.251264743673303],[-69.89363521999663,-4.298186944194327],[-69.44410193548961,-1.556287123219818],[-69.42048580593223,-1.122618503426409],[-69.5770653957766,-0.549991957200163],[-70.02065589057005,-0.185156345219539],[-70.01556576198931,0.541414292804205],[-69.45239600287246,0.706158758950693],[-69.25243404811906,0.602650865070075],[-69.21863766140018,0.985676581217433],[-69.80459672715773,1.089081122233466],[-69.81697323269162,1.714805202639624],[-67.86856502955884,1.692455145673392],[-67.5378100246747,2.03716278727633],[-67.2599975246736,1.719998684084956],[-67.0650481838525,1.130112209473225],[-66.87632585312258,1.253360500489336],[-66.32576514348496,0.724452215982012],[-65.54826738143757,0.78925446207603],[-65.35471330428837,1.0952822941085],[-64.61101192895987,1.328730576987042],[-64.19930579289051,1.49285492594602],[-64.08308549666609,1.91636912679408],[-63.368788011311665,2.200899562993129],[-63.42286739770512,2.411067613124175],[-64.2699991522658,2.497005520025567],[-64.40882788761792,3.126786200366624],[-64.3684944322141,3.797210394705246],[-64.81606401229402,4.056445217297423],[-64.62865943058755,4.14848094320925],[-63.88834286157416,4.020530096854571],[-63.093197597899106,3.770571193858785],[-62.804533047116706,4.006965033377952],[-62.08542965355913,4.162123521334308],[-60.96689327660154,4.536467596856639],[-60.601179165271944,4.91809804933213],[-60.73357418480372,5.200277207861901],[-60.21368343773133,5.244486395687602],[-59.980958624904886,5.014061184098139],[-60.11100236676738,4.574966538914083],[-59.767405768458715,4.423502915866607],[-59.53803992373123,3.958802598481938],[-59.815413174057866,3.606498521332085],[-59.97452490908456,2.755232652188056],[-59.71854570172675,2.24963043864436],[-59.64604366722126,1.786893825686789],[-59.03086157900265,1.317697658692722],[-58.540012986878295,1.268088283692521],[-58.429477098205965,1.463941962078721],[-58.11344987652502,1.507195135907025],[-57.66097103537737,1.682584947105639],[-57.335822923396904,1.948537705895759],[-56.78270423036083,1.863710842288654],[-56.539385748914555,1.899522609866921],[-55.995698004771754,1.817667141116601],[-55.905600145070885,2.02199575439866],[-56.0733418442903,2.220794989425499],[-55.973322109589375,2.510363877773017],[-55.569755011606,2.421506252447131],[-55.09758744975514,2.523748073736613],[-54.524754197799716,2.311848863123785],[-54.08806250671725,2.105556545414629],[-53.77852067728892,2.376702785650082],[-53.554839240113544,2.334896551925951],[-53.41846513529531,2.053389187015981],[-52.939657151894956,2.124857692875636],[-52.55642473001842,2.504705308437053],[-52.249337531123956,3.241094468596245],[-51.65779741067889,4.156232408053029],[-51.31714636901086,4.203490505383954],[-51.069771287629656,3.650397650564031],[-50.508875291533656,1.901563828942457],[-49.97407589374506,1.736483465986069],[-49.94710079608871,1.046189683431223],[-50.699251268096916,0.222984117021682],[-50.38821082213214,-0.078444512536819],[-48.62056677915632,-0.235489190271821],[-48.58449662941659,-1.237805271005001],[-47.824956427590635,-0.5816179337628],[-46.566583624851226,-0.941027520352776],[-44.905703090990414,-1.551739597178134],[-44.417619187993665,-2.137750339367976],[-44.58158850765578,-2.691308282078524],[-43.418791266440195,-2.383110039889793],[-41.47265682632825,-2.912018324397116],[-39.97866533055404,-2.873054294449041],[-38.50038347019657,-3.700652357603396],[-37.2232521225352,-4.820945733258917],[-36.45293738457639,-5.109403578312154],[-35.59779578301047,-5.149504489770649],[-35.23538896334756,-5.464937432480247],[-34.89602983248683,-6.738193047719711],[-34.729993455533034,-7.343220716992967],[-35.12821204277422,-8.996401462442286],[-35.636966518687714,-9.649281508017815],[-37.046518724097,-11.040721123908803],[-37.68361161960736,-12.171194756725823],[-38.42387651218844,-13.038118584854288],[-38.67388709161652,-13.057652276260619],[-38.953275722802545,-13.793369642800023],[-38.88229814304965,-15.667053724838768],[-39.16109249526431,-17.208406670808472],[-39.2673392400564,-17.867746270420483],[-39.58352149103423,-18.262295830968938],[-39.76082333022764,-19.59911345792741],[-40.77474077001034,-20.904511814052423],[-40.94475623225061,-21.93731698983781],[-41.754164191238225,-22.370675551037458],[-41.98828426773656,-22.970070489190896],[-43.07470374202475,-22.96769337330547],[-44.64781185563781,-23.351959323827842],[-45.35213578955992,-23.796841729428582],[-46.47209326840554,-24.088968601174543],[-47.64897233742066,-24.885199069927722],[-48.4954581365777,-25.877024834905654],[-48.64100480812774,-26.623697605090932],[-48.474735887228654,-27.17591196056189],[-48.661520351747626,-28.18613453543572],[-48.8884574041574,-28.674115085567884],[-49.587329474472675,-29.224469089476337],[-50.696874152211485,-30.98446502047296],[-51.576226162306156,-31.77769825615321],[-52.256081305538046,-32.24536996839467],[-52.712099982297694,-33.19657805759118],[-53.373661668498244,-33.768377780900764],[-53.6505439927181,-33.20200408298183],[-53.209588995971544,-32.727666110974724],[-53.78795162618219,-32.047242526987624],[-54.57245154480512,-31.494511407193748],[-55.601510179249345,-30.853878676071393],[-55.97324459494094,-30.883075860316303],[-56.976025763564735,-30.109686374636127],[-57.62513342958296,-30.21629485445426]]]}} diff --git a/bench/fixtures/Polygon.geojson b/bench/fixtures/Polygon.geojson new file mode 100644 index 0000000..b187016 --- /dev/null +++ b/bench/fixtures/Polygon.geojson @@ -0,0 +1,43 @@ +{ + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -79.92141723632812, + 32.953944317478246 + ], + [ + -79.97428894042969, + 32.83690450361482 + ], + [ + -79.97360229492188, + 32.76071688548088 + ], + [ + -79.93034362792969, + 32.76475877693074 + ], + [ + -79.93789672851562, + 32.74108223150125 + ], + [ + -79.80537414550781, + 32.7231762754146 + ], + [ + -79.81773376464844, + 32.923402043498875 + ], + [ + -79.92141723632812, + 32.953944317478246 + ] + ] + ] + } +} From 095be6434342cc8bb33c9b01b52d678e96f33d09 Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Thu, 21 Jul 2016 14:28:05 +0200 Subject: [PATCH 28/42] updated package with correct test ref and bench devDep --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9880191..98372a7 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "turf buffer module", "main": "index.js", "scripts": { - "test": "tape test.js" + "test": "tape test/test.js" }, "repository": { "type": "git", @@ -26,7 +26,9 @@ }, "homepage": "https://github.com/mclaeysb/turf-buffer", "devDependencies": { - "tape": "^2.13.3" + "benchmark": "^2.1.1", + "tape": "^2.13.3", + "turf-buffer": "^3.0.12" }, "dependencies": { "simplepolygon": "^1.0.0", From 77f4f96c8188122725d0c9fc0a03b51d3f4618f1 Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Thu, 21 Jul 2016 14:30:47 +0200 Subject: [PATCH 29/42] renamed test fixtures --- .gitignore | 5 ++- test/fixtures/out/line.geojson | 1 - test/fixtures/out/multiline.geojson | 1 - test/test.js | 56 ++++++++++++++--------------- 4 files changed, 32 insertions(+), 31 deletions(-) delete mode 100644 test/fixtures/out/line.geojson delete mode 100644 test/fixtures/out/multiline.geojson diff --git a/.gitignore b/.gitignore index c3e7e0b..ee12363 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,7 @@ build/Release # see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git node_modules -.DS_Store \ No newline at end of file +.DS_Store + +# Output of tests +test/fixtures/out diff --git a/test/fixtures/out/line.geojson b/test/fixtures/out/line.geojson deleted file mode 100644 index 15f1639..0000000 --- a/test/fixtures/out/line.geojson +++ /dev/null @@ -1 +0,0 @@ -{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-58.542642730865424,-34.61651680967873],[-58.54127457316263,-34.655499013609024],[-58.54100311692112,-34.65724723644642],[-58.54032222768283,-34.658918302580105],[-58.53925805062726,-34.66044798735197],[-58.53785146813851,-34.661777496499205],[-58.53749112853128,-34.66204503875536],[-58.46265134850689,-34.71512174031371],[-58.460898745066224,-34.71613700207815],[-58.458938819235684,-34.71685167508136],[-58.45684690758326,-34.717238286795684],[-58.45470342496167,-34.71728197530456],[-58.452590770576435,-34.71698106114521],[-58.450590157413814,-34.71634711193144],[-58.44877848748433,-34.715404497260444],[-58.44722539354153,-34.71418945109324],[-58.446296439413224,-34.7131656262641],[-58.40981842088211,-34.66632264898162],[-58.361814639261475,-34.66016871677381],[-58.35973994484731,-34.65972834992143],[-58.3578095937578,-34.65896348694723],[-58.35609778471125,-34.6579035295741],[-58.35467030884765,-34.6565892217751],[-58.35440149149119,-34.6562724971553],[-58.33655112427222,-34.634240277917755],[-58.33554339410652,-34.632685083853566],[-58.33492379869761,-34.63099800622624],[-58.33471612685466,-34.62924388447208],[-58.33492833349356,-34.62749013059239],[-58.33555223786177,-34.625804138231196],[-58.33656384184282,-34.62425069310079],[-58.337924255510934,-34.62288948422152],[-58.339581193862436,-34.6217728114771],[-58.34147098686903,-34.62094357737438],[-58.34352102549119,-34.6204336399373],[-58.34565254977336,-34.62026258978688],[-58.34778367221524,-34.620436998195856],[-58.34983252073949,-34.62095016487611],[-58.35172038106941,-34.62178237514302],[-58.35337471835351,-34.62290165662338],[-58.354731962422385,-34.62426500656613],[-58.36992349815493,-34.6430104297845],[-58.41805225428046,-34.64918035121087],[-58.42012643248252,-34.649621521326],[-58.422056165127124,-34.65038706855416],[-58.423767310058324,-34.65144758181403],[-58.425194116198305,-34.652762316579945],[-58.425571134641224,-34.653215572303075],[-58.457913165276054,-34.69473549399402],[-58.51956502429024,-34.65101707127775],[-58.52074222351177,-34.617725563259484],[-58.49263071240932,-34.55458664379626],[-58.45419183213516,-34.53641830449851],[-58.452449769095125,-34.5353952000337],[-58.45098352197715,-34.534111768528135],[-58.44984943624581,-34.532617342292795],[-58.44909108271561,-34.53096936097777],[-58.448737584896435,-34.5292311627237],[-58.448802502777696,-34.52746954902546],[-58.449283315492096,-34.52575221705436],[-58.45016152216585,-34.524145158194216],[-58.45140335647487,-34.52271012274876],[-58.45296108690268,-34.521502248140436],[-58.45477485233096,-34.52056794156051],[-58.45677496222563,-34.51994309820322],[-58.45888457306097,-34.519651723307085],[-58.461022638393935,-34.519705010733624],[-58.46310701967217,-34.52010091332792],[-58.46505763880128,-34.52082422149059],[-58.50694430643403,-34.54062095437875],[-58.5086866337948,-34.5416438797787],[-58.51015325744703,-34.54292712220878],[-58.51128781429208,-34.54442137814303],[-58.511758959822856,-34.5453239659329],[-58.54197972987419,-34.613162724222406],[-58.54251622669043,-34.61486894506955],[-58.542642730865424,-34.61651680967873]]]}},{"type":"Feature","properties":{},"geometry":{"type":"LineString","coordinates":[[-58.34564208984375,-34.62925297943919],[-58.363494873046875,-34.651285198954135],[-58.41636657714844,-34.65806316573297],[-58.45550537109375,-34.70831578223845],[-58.530349731445305,-34.65523908026755],[-58.531723022460945,-34.61625687562895],[-58.50151062011719,-34.54841811625336],[-58.45962524414062,-34.5286213832762]]}}]} \ No newline at end of file diff --git a/test/fixtures/out/multiline.geojson b/test/fixtures/out/multiline.geojson deleted file mode 100644 index 9efeb6d..0000000 --- a/test/fixtures/out/multiline.geojson +++ /dev/null @@ -1 +0,0 @@ -{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.6908709203873524,51.038871791996094],[3.6913250519741525,51.037132654681805],[3.6923099732994733,51.03548263837015],[3.6937877880190757,51.03398513951991],[3.6957016772138216,51.032697688821315],[3.697978087062685,51.031669742965285],[3.700529556098821,51.03094078699036],[3.7032580733055553,51.030538819685994],[3.7060588384598123,51.03047927983281],[3.708824281153005,51.030764454206846],[3.7114481853166645,51.03138338989874],[3.7138297621700467,51.03231231428764],[3.7158775164179634,51.03351554667293],[3.7175127581965555,51.034946866824974],[3.718336724659222,51.036086642373725],[3.7205380002362536,51.035068254536824],[3.723076093092268,51.03432080866716],[3.7257972417896177,51.03389904323796],[3.7285969286370704,51.03381915746115],[3.7313676245640996,51.034084219549094],[3.7340029120732185,51.0346840490715],[3.736401565860018,51.035595607308025],[3.738471435644681,51.036783880728095],[3.739385305991402,51.037491604950134],[3.757585311803368,51.05313885878894],[3.75901025785188,51.05465670425302],[3.7599368160758155,51.05632011891863],[3.7603293311783292,51.05806519078144],[3.7601726597800265,51.05982486308197],[3.75947276138718,51.06153151043965],[3.7582564787028594,51.063119537985614],[3.7565705143024637,51.06452790356173],[3.754479641745628,51.065702465842634],[3.75206421897527,51.06659806779266],[3.7494170991628986,51.06718027495988],[3.7466400578722934,51.06742670135814],[3.743839874534929,51.06732787159009],[3.741124219943501,51.0668875857995],[3.738597509182114,51.06612277330307],[3.736356880787111,51.06506284057693],[3.734488457911094,51.06374853887263],[3.73043054785144,51.060258299402456],[3.72354443620072,51.06932845597228],[3.7220944817489365,51.07083710681721],[3.7202038913635147,51.07213899428092],[3.7179453137269123,51.073184068248075],[3.7154055630211555,51.073932148593066],[3.7126822799221655,51.074354472100595],[3.709880173311074,51.074434800090984],[3.7071069880473577,51.074170043838464],[3.7044693550288237,51.07357038353831],[3.702068684446381,51.07265887620985],[3.699997261422613,51.07147056773736],[3.6983346951776,51.070051143460915],[3.6971448588435143,51.06845516957308],[3.696473437656884,51.066743993351565],[3.696450431114133,51.06663967164072],[3.6909650889196204,51.040633222435375],[3.6908709203873524,51.038871791996094]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.750236989394816,51.05199864633811],[3.6973673718607785,51.067753427047556],[3.694727904342417,51.06834931204938],[3.6919541157655464,51.06861009994649],[3.689152660276175,51.06852576313085],[3.6864312576647733,51.068099544472695],[3.683894544396781,51.067347832416324],[3.6816400441914365,51.06629952979493],[3.6797544142626886,51.06499494083164],[3.678310112387574,51.063484219446536],[3.6773626133016775,51.06182543893083],[3.676948281254109,51.060082357616906],[3.6770829798036613,51.05832196680558],[3.6777614711746285,51.056611915467236],[3.67895762688609,51.055017910814826],[3.680625440137984,51.053601194599274],[3.682700799789037,51.05241619190037],[3.6851039568480197,51.051508422421925],[3.7379777455759893,51.03575364171242],[3.740615479755015,51.03515797335935],[3.7433872891760087,51.03489728509951],[3.7461867136453204,51.034981589372066],[3.7489062341505015,51.035407648261184],[3.7514413954299113,51.03615909764593],[3.7536948118549995,51.037207074682534],[3.755579903939555,51.03851132471521],[3.7570242227916606,51.04002174542293],[3.7579722351707914,51.04168030928996],[3.7583874619886966,51.043423290966665],[3.758253887406625,51.0451837143211],[3.75757658327989,51.04689392542848],[3.7563815235888725,51.04848819275247],[3.7547145945655904,51.04990523455278],[3.7526398372922185,51.0510905761823],[3.750236989394816,51.05199864633811]]]}},{"type":"Feature","properties":{},"geometry":{"type":"MultiLineString","coordinates":[[[3.746038208007812,51.0584442677861],[3.727842102050781,51.04279701362964],[3.71063232421875,51.06545683812254],[3.70513916015625,51.03945105265764]],[[3.6912345886230464,51.059631085129986],[3.7441062927246094,51.04387630433032]]]}}]} \ No newline at end of file diff --git a/test/test.js b/test/test.js index 6f32bdd..1cc8396 100644 --- a/test/test.js +++ b/test/test.js @@ -1,44 +1,44 @@ var test = require('tape'); -var buffer = require('./'); +var buffer = require('../'); var fs = require('fs'); var helpers = require('turf-helpers') test('buffer', function(t){ - var pt = JSON.parse(fs.readFileSync(__dirname+'/fixtures/point.geojson')); - var multipt = JSON.parse(fs.readFileSync(__dirname+'/fixtures/multiPoint.geojson')); - var line = JSON.parse(fs.readFileSync(__dirname+'/fixtures/lineString.geojson')); - var multiline = JSON.parse(fs.readFileSync(__dirname+'/fixtures/multiLineString.geojson')); - var polygon = JSON.parse(fs.readFileSync(__dirname+'/fixtures/polygon.geojson')); - var multipolygon = JSON.parse(fs.readFileSync(__dirname+'/fixtures/multiPolygon.geojson')); + var point = JSON.parse(fs.readFileSync(__dirname+'/fixtures/Point.geojson')); + var multiPoint = JSON.parse(fs.readFileSync(__dirname+'/fixtures/MultiPoint.geojson')); + var lineString = JSON.parse(fs.readFileSync(__dirname+'/fixtures/LineString.geojson')); + var multiLineString = JSON.parse(fs.readFileSync(__dirname+'/fixtures/MultiLineString.geojson')); + var polygon = JSON.parse(fs.readFileSync(__dirname+'/fixtures/Polygon.geojson')); + var multiPolygon = JSON.parse(fs.readFileSync(__dirname+'/fixtures/MultiPolygon.geojson')); - var buffPt = buffer(pt, 1, 'kilometers', 100); - fs.writeFileSync(__dirname+'/fixtures/out/point.geojson', JSON.stringify(helpers.featureCollection([buffPt, pt]))); + var BufferedPoint = buffer(point, 1, 'kilometers', 100); + fs.writeFileSync(__dirname+'/fixtures/out/Point.geojson', JSON.stringify(helpers.featureCollection([BufferedPoint, point]))); - var buffMultiPt = buffer(multipt, 1, 'kilometers'); - buffMultiPt.features.push(multipt) - fs.writeFileSync(__dirname+'/fixtures/out/multipoint.geojson', JSON.stringify(buffMultiPt)); + var BufferedMultiPoint = buffer(multiPoint, 1, 'kilometers'); + BufferedMultiPoint.features.push(multiPoint) + fs.writeFileSync(__dirname+'/fixtures/out/MultiPoint.geojson', JSON.stringify(BufferedMultiPoint)); - var buffLine = buffer(line, 1, 'kilometers'); - fs.writeFileSync(__dirname+'/fixtures/out/line.geojson', JSON.stringify(helpers.featureCollection([buffLine, line]))); + var BufferedLineString = buffer(lineString, 1, 'kilometers'); + fs.writeFileSync(__dirname+'/fixtures/out/LineString.geojson', JSON.stringify(helpers.featureCollection([BufferedLineString, lineString]))); - var buffMultiLine = buffer(multiline, 1, 'kilometers'); - buffMultiLine.features.push(multiline) - fs.writeFileSync(__dirname+'/fixtures/out/multiline.geojson', JSON.stringify(buffMultiLine)); + var BufferedMultiLineString = buffer(multiLineString, 1, 'kilometers'); + BufferedMultiLineString.features.push(multiLineString) + fs.writeFileSync(__dirname+'/fixtures/out/MultiLineString.geojson', JSON.stringify(BufferedMultiLineString)); - var buffPolygon = buffer(polygon, 1, 'kilometers'); - fs.writeFileSync(__dirname+'/fixtures/out/polygon.geojson', JSON.stringify(helpers.featureCollection([buffPolygon, polygon]))); + var bufferedPolygon = buffer(polygon, 1, 'kilometers'); + fs.writeFileSync(__dirname+'/fixtures/out/Polygon.geojson', JSON.stringify(helpers.featureCollection([bufferedPolygon, polygon]))); - var buffMultiPolygon = buffer(multipolygon, 0.2, 'kilometers'); - buffMultiPolygon.features.push(multipolygon) - fs.writeFileSync(__dirname+'/fixtures/out/multipolygon.geojson', JSON.stringify(buffMultiPolygon)); + var bufferedMultiPolygon = buffer(multiPolygon, 0.2, 'kilometers'); + bufferedMultiPolygon.features.push(multiPolygon) + fs.writeFileSync(__dirname+'/fixtures/out/MultiPolygon.geojson', JSON.stringify(bufferedMultiPolygon)); - t.ok(buffPt, 'should buffer a point'); - t.ok(buffMultiPt, 'should buffer a multipoint'); - t.ok(buffLine, 'should buffer a line'); - t.ok(buffMultiLine, 'should buffer a multiline'); - t.ok(buffPolygon, 'should buffer a polygon'); - t.ok(buffMultiPolygon, 'should buffer a multipolygon'); + t.ok(BufferedPoint, 'should buffer a Point'); + t.ok(BufferedMultiPoint, 'should buffer a MultiPoint'); + t.ok(BufferedLineString, 'should buffer a LineString'); + t.ok(BufferedMultiLineString, 'should buffer a MultiLineString'); + t.ok(bufferedPolygon, 'should buffer a Polygon'); + t.ok(bufferedMultiPolygon, 'should buffer a multiPolygon'); t.end(); }); From f426516baa9977ee65389a5aeb3d04c008fe90ae Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Sat, 30 Jul 2016 13:39:03 +0200 Subject: [PATCH 30/42] fixed equal arrays and modulo function: no longer extending built-in objects --- index.js | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/index.js b/index.js index b5b12e7..0bd06d5 100644 --- a/index.js +++ b/index.js @@ -45,7 +45,7 @@ function pointBuffer(pt, radius, units, resolution) { var spoke = destination(pt, radius, i*resMultiple, units); pointOffset[0].push(spoke.geometry.coordinates); } - if(!(pointOffset[0][0].equals(pointOffset[0][pointOffset[0].length-1]))) { + if(!(equalArrays(pointOffset[0][0],pointOffset[0][pointOffset[0].length-1]))) { pointOffset[0].push(pointOffset[0][0]); } return helpers.polygon(pointOffset) @@ -56,7 +56,7 @@ function lineBuffer(line, radius, units, resolution) { line.geometry.coordinates = removeDuplicates(line.geometry.coordinates); - if (!(line.geometry.coordinates[0].equals(line.geometry.coordinates[line.geometry.coordinates.length-1]))) { + if (!(equalArrays(line.geometry.coordinates[0],line.geometry.coordinates[line.geometry.coordinates.length-1]))) { // situation at current point = point 0 var currentLinePoint = helpers.point(line.geometry.coordinates[0]); @@ -148,9 +148,9 @@ function arc(pt, radius, bearing1, bearing2, units, resolution, right, shortcut) if (shortcut === undefined) var shortcut = false; var arc = []; var resMultiple = 360/resolution; - var angle = (Math.pow(-1, right + 1) * (bearing1 - bearing2)).mod(360); + var angle = (Math.pow(-1, right + 1) * (bearing1 - bearing2)).modulo(360); var numSteps = Math.floor(angle/resMultiple); - var step = numSteps; // Counting steps first is easier than checking angle (angle involves checking 'right', 'mod(360)', lefthandedness of bearings + var step = numSteps; // Counting steps first is easier than checking angle (angle involves checking 'right', 'modulo(360)', lefthandedness of bearings var bearing = bearing1; // Add spoke for bearing1 var spoke = destination(pt, radius, bearing1, units); @@ -167,7 +167,7 @@ function arc(pt, radius, bearing1, bearing2, units, resolution, right, shortcut) } // Add spoke for bearing 2, but only if this spoke has not been added yet. Do this by checking the destination point, since slightly different bearings can create equal destination points. var spokeBearing2 = destination(pt, radius, bearing2, units); - if (!spokeBearing2.geometry.coordinates.equals(spoke.geometry.coordinates)) { + if (!equalArrays(spokeBearing2.geometry.coordinates,spoke.geometry.coordinates)) { arc.push(spokeBearing2.geometry.coordinates); } return helpers.lineString(arc) @@ -212,7 +212,7 @@ function winding(poly){ var coords = poly.geometry.coordinates[0]; var leftVtx = 0; for (var i = 0; i < coords.length-1; i++) { if (coords[i][0] < coords[leftVtx][0]) leftVtx = i; } - return (coords[(leftVtx-1).mod(coords.length-1)][1] > coords[(leftVtx+1).mod(coords.length-1)][1]) ? 1 : -1; + return (coords[(leftVtx-1).modulo(coords.length-1)][1] > coords[(leftVtx+1).modulo(coords.length-1)][1]) ? 1 : -1; } // This function awaits possible future use @@ -227,7 +227,7 @@ function rewind(poly){ function removeDuplicates(arr) { for (var i = arr.length-1; i > 0; i--) { - if (arr[i].equals(arr[i-1])) { + if (equalArrays(arr[i],arr[i-1])) { arr.splice(i,1); } } @@ -236,36 +236,31 @@ function removeDuplicates(arr) { // Function to compare Arrays of numbers. From http://stackoverflow.com/questions/7837456/how-to-compare-arrays-in-javascript -// Warn if overriding existing method -// if(Array.prototype.equals) console.warn("Overriding existing Array.prototype.equals. Possible causes: New API defines the method, there's a framework conflict or you've got double inclusions in your code."); -// attach the .equals method to Array's prototype to call it on any array -Array.prototype.equals = function (array) { +function equalArrays(array1, array2) { // if the other array is a falsy value, return - if (!array) + if (!array1 || !array2) return false; // compare lengths - can save a lot of time - if (this.length != array.length) + if (array1.length != array2.length) return false; - for (var i = 0, l=this.length; i < l; i++) { + for (var i = 0, l=array1.length; i < l; i++) { // Check if we have nested arrays - if (this[i] instanceof Array && array[i] instanceof Array) { + if (array1[i] instanceof Array && array2[i] instanceof Array) { // recurse into the nested arrays - if (!this[i].equals(array[i])) + if (!equalArrays(array1[i],array2[i])) return false; } - else if (this[i] != array[i]) { + else if (array1[i] != array2[i]) { // Warning - two different object instances will never be equal: {x:20} != {x:20} return false; } } return true; } -// Hide method from for-in loops -Object.defineProperty(Array.prototype, "equals", {enumerable: false}); // Fix Javascript modulo for negative number. From http://stackoverflow.com/questions/4467539/javascript-modulo-not-behaving -Number.prototype.mod = function(n) { +Number.prototype.modulo = function(n) { return ((this%n)+n)%n; } From 20f0eb894d7cff7a06c17421d6d5243a776ee80e Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Tue, 2 Aug 2016 23:44:02 +0200 Subject: [PATCH 31/42] single simplepolygon call in offsetToBuffer --- index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 0bd06d5..012ef67 100644 --- a/index.js +++ b/index.js @@ -197,8 +197,9 @@ function unionFeatureCollection(fc) { } function offsetToBuffer(polygonOffset) { - var unionWithWindingOne = unionFeatureCollection(filterNetWinding(simplepolygon(polygonOffset), function (netWinding){return netWinding == 1})); - var unionWithWindingZero = unionFeatureCollection(filterNetWinding(simplepolygon(polygonOffset), function (netWinding){return netWinding == 0})); + var sp = simplepolygon(polygonOffset); + var unionWithWindingOne = unionFeatureCollection(filterNetWinding(sp, function (netWinding){return netWinding == 1})); + var unionWithWindingZero = unionFeatureCollection(filterNetWinding(sp, function (netWinding){return netWinding == 0})); // This last one might have winding -1, so we might have to rewind it if the difference algorithm requires so if (unionWithWindingOne.geometry == null) return {type: "Feature", geometry: null}; @@ -206,7 +207,6 @@ function offsetToBuffer(polygonOffset) { return difference(unionWithWindingOne, unionWithWindingZero); } -// This function awaits possible future use function winding(poly){ // compute winding of first ring var coords = poly.geometry.coordinates[0]; @@ -215,7 +215,6 @@ function winding(poly){ return (coords[(leftVtx-1).modulo(coords.length-1)][1] > coords[(leftVtx+1).modulo(coords.length-1)][1]) ? 1 : -1; } -// This function awaits possible future use function rewind(poly){ // outer ring to winding +1, inner rings to winding -1 if (winding(helpers.polygon([poly.geometry.coordinates[0]])) == -1) poly.geometry.coordinates[0] = poly.geometry.coordinates[0].reverse(); From f75aee9dd5d70f310ee8289147a43747d71f72ae Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Sun, 7 Aug 2016 11:16:21 +0200 Subject: [PATCH 32/42] allow FeatureCollection input --- index.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 012ef67..dd82ad9 100644 --- a/index.js +++ b/index.js @@ -5,10 +5,24 @@ var helpers = require('turf-helpers'); var union = require('turf-union'); var difference = require('turf-difference'); -module.exports = function(feature, radius, units, resolution){ +module.exports = buffer; + +function buffer(feature, radius, units, resolution){ if (!resolution) resolution = 32; // Same value as JSTS if (radius < 0) throw new Error("The buffer radius must be positive"); if (radius == 0) return feature; + if (feature.type === 'FeatureCollection') { + var buffers = []; + feature.features.forEach(function(ft) { + var featureBuffer = buffer(ft, radius, units, resolution); + if (featureBuffer.type === 'Feature') { + buffers.push(featureBuffer); + } else { // featureBuffer.type === 'FeatureCollection' + buffers.push.apply(buffers,featureBuffer.features); + } + }); + return helpers.featureCollection(buffers) + } var geom = feature.geometry; if (geom === null) return feature; if(geom.type === 'Point') { From 5c5ac1bfce1fd9153ce10bf4d181fb1e0d32c964 Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Tue, 9 Aug 2016 11:53:18 +0200 Subject: [PATCH 33/42] small tweaks --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index dd82ad9..1ff5283 100644 --- a/index.js +++ b/index.js @@ -211,7 +211,11 @@ function unionFeatureCollection(fc) { } function offsetToBuffer(polygonOffset) { + // You can inspect the polygonOffset here + // console.log(JSON.stringify(polygonOffset)); var sp = simplepolygon(polygonOffset); + // You can inspect the polygonOffset here + // console.log(JSON.stringify(sp)); var unionWithWindingOne = unionFeatureCollection(filterNetWinding(sp, function (netWinding){return netWinding == 1})); var unionWithWindingZero = unionFeatureCollection(filterNetWinding(sp, function (netWinding){return netWinding == 0})); // This last one might have winding -1, so we might have to rewind it if the difference algorithm requires so From 92ef49bb84d4dfbbf7451874d927cd142040c3a8 Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Tue, 9 Aug 2016 12:18:00 +0200 Subject: [PATCH 34/42] added test that buffers circle with buffer radius equal to circle radius --- test/test.js | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/test/test.js b/test/test.js index 1cc8396..85df802 100644 --- a/test/test.js +++ b/test/test.js @@ -11,19 +11,20 @@ test('buffer', function(t){ var polygon = JSON.parse(fs.readFileSync(__dirname+'/fixtures/Polygon.geojson')); var multiPolygon = JSON.parse(fs.readFileSync(__dirname+'/fixtures/MultiPolygon.geojson')); - var BufferedPoint = buffer(point, 1, 'kilometers', 100); - fs.writeFileSync(__dirname+'/fixtures/out/Point.geojson', JSON.stringify(helpers.featureCollection([BufferedPoint, point]))); + // Tests for basic features + var bufferedPoint = buffer(point, 1, 'kilometers', 100); + fs.writeFileSync(__dirname+'/fixtures/out/Point.geojson', JSON.stringify(helpers.featureCollection([bufferedPoint, point]))); - var BufferedMultiPoint = buffer(multiPoint, 1, 'kilometers'); - BufferedMultiPoint.features.push(multiPoint) - fs.writeFileSync(__dirname+'/fixtures/out/MultiPoint.geojson', JSON.stringify(BufferedMultiPoint)); + var bufferedMultiPoint = buffer(multiPoint, 1, 'kilometers'); + bufferedMultiPoint.features.push(multiPoint) + fs.writeFileSync(__dirname+'/fixtures/out/MultiPoint.geojson', JSON.stringify(bufferedMultiPoint)); - var BufferedLineString = buffer(lineString, 1, 'kilometers'); - fs.writeFileSync(__dirname+'/fixtures/out/LineString.geojson', JSON.stringify(helpers.featureCollection([BufferedLineString, lineString]))); + var bufferedLineString = buffer(lineString, 1, 'kilometers'); + fs.writeFileSync(__dirname+'/fixtures/out/LineString.geojson', JSON.stringify(helpers.featureCollection([bufferedLineString, lineString]))); - var BufferedMultiLineString = buffer(multiLineString, 1, 'kilometers'); - BufferedMultiLineString.features.push(multiLineString) - fs.writeFileSync(__dirname+'/fixtures/out/MultiLineString.geojson', JSON.stringify(BufferedMultiLineString)); + var bufferedMultiLineString = buffer(multiLineString, 1, 'kilometers'); + bufferedMultiLineString.features.push(multiLineString) + fs.writeFileSync(__dirname+'/fixtures/out/MultiLineString.geojson', JSON.stringify(bufferedMultiLineString)); var bufferedPolygon = buffer(polygon, 1, 'kilometers'); fs.writeFileSync(__dirname+'/fixtures/out/Polygon.geojson', JSON.stringify(helpers.featureCollection([bufferedPolygon, polygon]))); @@ -32,13 +33,22 @@ test('buffer', function(t){ bufferedMultiPolygon.features.push(multiPolygon) fs.writeFileSync(__dirname+'/fixtures/out/MultiPolygon.geojson', JSON.stringify(bufferedMultiPolygon)); - - t.ok(BufferedPoint, 'should buffer a Point'); - t.ok(BufferedMultiPoint, 'should buffer a MultiPoint'); - t.ok(BufferedLineString, 'should buffer a LineString'); - t.ok(BufferedMultiLineString, 'should buffer a MultiLineString'); + // Test to buffer a circle LineString with buffer radius = circle radius + var disk = buffer(point, 1, 'kilometers'); + var circle = disk; + circle.geometry.type = "LineString"; + circle.geometry.coordinates = circle.geometry.coordinates[0]; + var bufferedCircle = buffer(circle, 1, 'kilometers'); + fs.writeFileSync(__dirname+'/fixtures/out/Circle.geojson', JSON.stringify(helpers.featureCollection([bufferedCircle, circle]))); + // the simplepolygon output has 32 rings, each with winding > 0 + + t.ok(bufferedPoint, 'should buffer a Point'); + t.ok(bufferedMultiPoint, 'should buffer a MultiPoint'); + t.ok(bufferedLineString, 'should buffer a LineString'); + t.ok(bufferedMultiLineString, 'should buffer a MultiLineString'); t.ok(bufferedPolygon, 'should buffer a Polygon'); t.ok(bufferedMultiPolygon, 'should buffer a multiPolygon'); + t.ok(bufferedMultiPolygon, 'should buffer a circle with buffer radius = circle radius, without creating a hole or error in the middle'); t.end(); }); From bbdb86f3ab07d6be9b156de5335e68529f5c5c07 Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Tue, 9 Aug 2016 21:43:42 +0200 Subject: [PATCH 35/42] removed test/fixtures/out/* --- test/fixtures/out/multipoint.geojson | 1 - test/fixtures/out/multipolygon.geojson | 1 - test/fixtures/out/point.geojson | 1 - test/fixtures/out/polygon.geojson | 1 - 4 files changed, 4 deletions(-) delete mode 100644 test/fixtures/out/multipoint.geojson delete mode 100644 test/fixtures/out/multipolygon.geojson delete mode 100644 test/fixtures/out/point.geojson delete mode 100644 test/fixtures/out/polygon.geojson diff --git a/test/fixtures/out/multipoint.geojson b/test/fixtures/out/multipoint.geojson deleted file mode 100644 index 5f6d8da..0000000 --- a/test/fixtures/out/multipoint.geojson +++ /dev/null @@ -1 +0,0 @@ -{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-89.43283081054688,43.07988460444513],[-89.43042948417204,43.07971183144844],[-89.42812047875512,43.07920015488571],[-89.42599256141995,43.07836924633866],[-89.42412752910742,43.077251049335764],[-89.42259706177398,43.07588854992519],[-89.42145996658371,43.07433412255722],[-89.42075991917837,43.07264751517655],[-89.42052378864385,43.070893551289195],[-89.42076061002531,43.06913963759439],[-89.42146124310243,43.06745317315005],[-89.42259872962609,43.06589895970141],[-89.42412933437755,43.06453671262589],[-89.4259942292721,43.063418767958055],[-89.4281217552739,43.06258807333033],[-89.43043017501904,43.06207653970394],[-89.43283081054688,43.06190381689982],[-89.43523144607471,43.06207653970394],[-89.43753986581984,43.06258807333033],[-89.43966739182164,43.063418767958055],[-89.44153228671618,43.06453671262589],[-89.44306289146765,43.06589895970141],[-89.44420037799132,43.06745317315005],[-89.44490101106842,43.06913963759439],[-89.44513783244989,43.070893551289195],[-89.44490170191538,43.07264751517655],[-89.44420165451002,43.07433412255722],[-89.44306455931977,43.07588854992519],[-89.44153409198631,43.077251049335764],[-89.43966905967379,43.07836924633866],[-89.43754114233862,43.07920015488571],[-89.43523213692171,43.07971183144844],[-89.43283081054688,43.07988460444513]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-89.37103271484375,43.093551705216576],[-89.36863085264223,43.0933789322079],[-89.36632133201772,43.09286725561097],[-89.36419293991662,43.092036347012744],[-89.3623274915404,43.090918149949495],[-89.36079668284009,43.08955565047858],[-89.35965933409281,43.08800122305947],[-89.35895913066874,43.08631461564464],[-89.35872294762608,43.084560651745285],[-89.35895982200027,43.0828067380625],[-89.35966061150692,43.08112027365235],[-89.36079835186209,43.07956606025488],[-89.36232929807682,43.078203813239696],[-89.36419460893865,43.07708586863219],[-89.36632260943189,43.07625517405561],[-89.3686315439738,43.075743640463386],[-89.37103271484375,43.07557091767128],[-89.3734338857137,43.075743640463386],[-89.3757428202556,43.07625517405561],[-89.37787082074884,43.07708586863219],[-89.37973613161068,43.078203813239696],[-89.38126707782541,43.07956606025488],[-89.38240481818058,43.08112027365235],[-89.38310560768723,43.0828067380625],[-89.38334248206141,43.084560651745285],[-89.38310629901876,43.08631461564464],[-89.38240609559469,43.08800122305947],[-89.38126874684741,43.08955565047858],[-89.3797379381471,43.090918149949495],[-89.37787248977088,43.092036347012744],[-89.37574409766978,43.09286725561097],[-89.37343457704527,43.0933789322079],[-89.37103271484375,43.093551705216576]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-89.329833984375,43.11623988170934],[-89.3274312318401,43.11606710868072],[-89.32512085514308,43.115555432026994],[-89.3229916741676,43.11472452334378],[-89.3211255344571,43.113606326180296],[-89.31959415853927,43.112243826609145],[-89.31845638847997,43.11068939910506],[-89.31775592581415,43.10900279163348],[-89.31751965552368,43.10724882771422],[-89.31775661795102,43.105494914051405],[-89.31845766738216,43.10380844969806],[-89.31959582950552,43.102254236385555],[-89.32112734309794,43.100891989470604],[-89.32299334513388,43.09977404496331],[-89.32512213404532,43.09894335047169],[-89.32743192397702,43.09843181693621],[-89.329833984375,43.098259094164035],[-89.33223604477298,43.09843181693621],[-89.33454583470468,43.09894335047169],[-89.33667462361612,43.09977404496331],[-89.33854062565206,43.100891989470604],[-89.34007213924447,43.102254236385555],[-89.34121030136784,43.10380844969806],[-89.34191135079898,43.105494914051405],[-89.34214831322632,43.10724882771422],[-89.34191204293585,43.10900279163348],[-89.34121158027003,43.11068939910506],[-89.34007381021073,43.112243826609145],[-89.3385424342929,43.113606326180296],[-89.3366762945824,43.11472452334378],[-89.33454711360692,43.115555432026994],[-89.3322367369099,43.11606710868072],[-89.329833984375,43.11623988170934]]]}},{"type":"Feature","properties":{},"geometry":{"type":"MultiPoint","coordinates":[[-89.43283081054688,43.07089421067248],[-89.37103271484375,43.08456131144392],[-89.329833984375,43.107249487936684]]}}]} \ No newline at end of file diff --git a/test/fixtures/out/multipolygon.geojson b/test/fixtures/out/multipolygon.geojson deleted file mode 100644 index b6e379a..0000000 --- a/test/fixtures/out/multipolygon.geojson +++ /dev/null @@ -1 +0,0 @@ -{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.6803055781507905,51.06145555810943],[3.6803575473737347,51.06180652667371],[3.6805174655777697,51.06214437932413],[3.680779189262147,51.06245613214903],[3.68113266192528,51.06272980402216],[3.6815643003183642,51.06295487712816],[3.6820575163647087,51.06312270127176],[3.6825933546995184,51.06322682641593],[3.6831512213192656,51.06326325065214],[3.7378306382680155,51.06346075172122],[3.711620474640772,51.09051278954986],[3.7115748072360093,51.09056160141862],[3.7113473261266856,51.090883830362095],[3.7112243011296537,51.09122774177523],[3.71121046226037,51.09158011966733],[3.7113063438072467,51.09192742239185],[3.711508263423456,51.092256303038596],[3.711808463283128,51.092554122387654],[3.7121954079313277,51.092809434706886],[3.712654227424106,51.0930124277118],[3.7131672887535063,51.09315529976419],[3.7137148736008445,51.09323255979597],[3.7142759363533058,51.09324123841548],[3.7657743386483107,51.09086920485579],[3.766288022418104,51.09081560331141],[3.7668144491360485,51.09069345104794],[3.7672928154663508,51.090509138677604],[3.767704736939327,51.09026974991328],[3.7680343834522643,51.08998448510474],[3.7682690876405154,51.089664307556475],[3.768399831560551,51.08932152210176],[3.7780101865721063,51.045524878997234],[3.778032716998368,51.04518136382425],[3.777947431367265,51.04483298094024],[3.7777556827259318,51.04450175263377],[3.777464841755237,51.04420040732483],[3.7770860864486435,51.0439405248574],[3.776633972374982,51.043732091597086],[3.735434760039935,51.028404271152844],[3.735229638266801,51.02833483213991],[3.734704110332295,51.028212358871336],[3.734150691917528,51.028156718351994],[3.7335906482420627,51.02817004857442],[3.733045499014854,51.02825183732417],[3.73253619181766,51.02839894185503],[3.706100037410384,51.038114346051714],[3.7060108638382894,51.0381484887072],[3.705569179936619,51.038365539348604],[3.7052033202144283,51.03863260087632],[3.6808263035311213,51.06043087000873],[3.6807962723567442,51.06045824293228],[3.6805292404765897,51.06076820932305],[3.6803635526321528,51.061104961299414],[3.6803055781507905,51.06145555810943]],[[3.7230138062675704,51.044022605650525],[3.736307962136751,51.04485846431389],[3.729497002181375,51.05286885990815],[3.722797264389476,51.04865747725591],[3.7230138062675704,51.044022605650525]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[3.7702690591424006,51.06638487908231],[3.7703774505440566,51.06673072019063],[3.7875414670873657,51.10253162020055],[3.787710736431538,51.10280268256536],[3.788005545439315,51.103102644726036],[3.7883878896656116,51.103360727491896],[3.7888430760148086,51.10356701211253],[3.78935361115175,51.1037135704487],[3.7898998738793854,51.10379476975848],[3.7904608694167163,51.10380748924982],[3.791015036553063,51.10375124006379],[3.7915410766088944,51.1036281840697],[3.7920187722895395,51.10344305074846],[3.792429764909248,51.10320295536389],[3.7927582600739647,51.10291712542141],[3.8401340669920425,51.0517953317495],[3.840284965542477,51.05160788622985],[3.8404570082217457,51.0512724025035],[3.840521627813269,51.05092226594181],[3.8404763434226505,51.05057093227391],[3.8403228977371286,51.05023190293085],[3.8400671896846164,51.04991820621216],[3.8397190474221126,51.04964189667777],[3.8392918504259734,51.04941359199372],[3.8135422489674324,51.038189439418375],[3.813399767346485,51.038131166858825],[3.812894710094598,51.037978237592355],[3.812351912540888,51.037890201579216],[3.8117922319344695,51.037870441619354],[3.81123717403883,51.037919716990224],[3.810708067050077,51.03803613428141],[3.8102252423267178,51.03821522012466],[3.809807253360191,51.038450093029454],[3.771010575109932,51.06499513926009],[3.7709086901554696,51.06506870093599],[3.7705961993451154,51.06536141326605],[3.7703805787326887,51.06568681261988],[3.7702701162357304,51.066032394633126],[3.7702690591424006,51.06638487908231]],[[3.8032352203277706,51.06591459171116],[3.803138312755336,51.06469756494578],[3.811654679869943,51.05514853734741],[3.8141449764644895,51.062976362300255],[3.8032352203277706,51.06591459171116]]]}},{"type":"Feature","properties":{},"geometry":{"type":"MultiPolygon","coordinates":[[[[3.7075424194335938,51.03966692839972],[3.733978271484375,51.02995152419996],[3.7751770019531254,51.045279344649146],[3.76556396484375,51.08907598780727],[3.7140655517578125,51.09144802136697],[3.742904663085937,51.06168097070514],[3.68316650390625,51.061465197550305],[3.7075424194335938,51.03966692839972]],[[3.7199020385742188,51.04938029577453],[3.730201721191406,51.05585474252802],[3.7408447265625,51.04333666212316],[3.720245361328125,51.04204149517769],[3.7199020385742188,51.04938029577453]]],[[[3.8119125366210938,51.03966692839972],[3.8376617431640625,51.05089108097961],[3.7902832031250004,51.10201287469917],[3.773117065429687,51.0662119746483],[3.8119125366210938,51.03966692839972]],[[3.8002395629882812,51.06427017012091],[3.8005828857421875,51.068585180672635],[3.8174057006835933,51.06405440903407],[3.8129425048828125,51.05002778118271],[3.8002395629882812,51.06427017012091]]]]}}]} \ No newline at end of file diff --git a/test/fixtures/out/point.geojson b/test/fixtures/out/point.geojson deleted file mode 100644 index af832d2..0000000 --- a/test/fixtures/out/point.geojson +++ /dev/null @@ -1 +0,0 @@ -{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-75.4,39.40899039377264],[-75.39926936767758,39.40897265099946],[-75.3985416199388,39.40891949272955],[-75.3978196299656,39.40883112883496],[-75.39710624818191,39.408707908180624],[-75.39640429098748,39.40855031724542],[-75.39571652962704,39.40835897819938],[-75.39504567923856,39.408134646444644],[-75.39439438812435,39.40787820762989],[-75.39376522728739,39.407590674150114],[-75.39316068027439,39.40727318114572],[-75.39258313336595,39.40692698201667],[-75.39203486615253,39.406553443469534],[-75.39151804253359,39.406154040117215],[-75.39103470217545,39.40573034865255],[-75.39058675246174,39.40528404161902],[-75.39017596096797,39.404816880803324],[-75.38980394849013,39.40433071027574],[-75.38947218265464,39.40382744910619],[-75.38918197213476,39.403309083784556],[-75.38893446149623,39.40277766037547],[-75.38873062669217,39.402235276438454],[-75.38857127122499,39.40168407274549],[-75.38845702299024,39.40112622482875],[-75.38838833181444,39.40056393439188],[-75.3883654676965,39.39999942061881],[-75.38838851975946,39.39943491141433],[-75.38845739591629,39.39887263461119],[-75.3885718232508,39.39831480917831],[-75.38873134911195,39.397763636464745],[-75.38893534291702,39.39722129151411],[-75.38918299865601,39.39668991448354],[-75.38947333808748,39.39617160220114],[-75.38980521461271,39.395668399895094],[-75.39017731781279,39.39518229312696],[-75.39058817863054,39.39471519996114],[-75.3910361751767,39.39426896340104],[-75.39151953913716,39.393845344121935],[-75.39203636275612,39.39344601352891],[-75.39258460636721,39.39307254716733],[-75.39316210644321,39.39272641851171],[-75.39376658413225,39.3924089931572],[-75.39439565424699,39.39212152343688],[-75.39504683467145,39.391865143485624],[-75.39571755614833,39.39164086477013],[-75.39640517240831,39.391449572102616],[-75.39710697060174,39.391292020153784],[-75.39782018199143,39.39116883047885],[-75.39854199286486,39.39108048906812],[-75.39926955562261,39.39102734443195],[-75.4,39.39100960622736],[-75.4007304443774,39.39102734443195],[-75.40145800713515,39.39108048906812],[-75.40217981800858,39.39116883047885],[-75.40289302939827,39.391292020153784],[-75.4035948275917,39.391449572102616],[-75.40428244385168,39.39164086477013],[-75.40495316532856,39.391865143485624],[-75.40560434575302,39.39212152343688],[-75.40623341586776,39.3924089931572],[-75.4068378935568,39.39272641851171],[-75.4074153936328,39.39307254716733],[-75.4079636372439,39.39344601352891],[-75.40848046086285,39.393845344121935],[-75.4089638248233,39.39426896340104],[-75.40941182136947,39.39471519996114],[-75.40982268218723,39.39518229312696],[-75.4101947853873,39.395668399895094],[-75.41052666191253,39.39617160220114],[-75.410817001344,39.39668991448354],[-75.41106465708299,39.39722129151411],[-75.41126865088805,39.397763636464745],[-75.41142817674921,39.39831480917831],[-75.4115426040837,39.39887263461119],[-75.41161148024055,39.39943491141433],[-75.41163453230351,39.39999942061881],[-75.41161166818557,39.40056393439188],[-75.41154297700976,39.40112622482875],[-75.41142872877502,39.40168407274549],[-75.41126937330785,39.402235276438454],[-75.41106553850378,39.40277766037547],[-75.41081802786525,39.403309083784556],[-75.41052781734537,39.40382744910619],[-75.41019605150989,39.40433071027574],[-75.40982403903205,39.404816880803324],[-75.40941324753827,39.40528404161902],[-75.40896529782457,39.40573034865255],[-75.40848195746642,39.406154040117215],[-75.40796513384748,39.406553443469534],[-75.40741686663405,39.40692698201667],[-75.40683931972562,39.40727318114572],[-75.40623477271262,39.407590674150114],[-75.40560561187564,39.40787820762989],[-75.40495432076145,39.408134646444644],[-75.40428347037297,39.40835897819938],[-75.40359570901252,39.40855031724542],[-75.4028937518181,39.408707908180624],[-75.4021803700344,39.40883112883496],[-75.40145838006121,39.40891949272955],[-75.40073063232242,39.40897265099946],[-75.4,39.40899039377264]]]}},{"type":"Feature","geometry":{"type":"Point","coordinates":[-75.4,39.4]},"properties":{"name":"Location A","category":"Store"}}]} \ No newline at end of file diff --git a/test/fixtures/out/polygon.geojson b/test/fixtures/out/polygon.geojson deleted file mode 100644 index 80b88d5..0000000 --- a/test/fixtures/out/polygon.geojson +++ /dev/null @@ -1 +0,0 @@ -{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-79.9849887038998,32.83683591214674],[-79.9842928936063,32.76064829534015],[-79.984071463671,32.7588957347204],[-79.98344773383104,32.757213174888186],[-79.982445693391,32.75566526994679],[-79.98110386320529,32.75431149655146],[-79.9794738133657,32.75320386954351],[-79.97761818073721,32.752384944557676],[-79.97560826262581,32.751886184131905],[-79.97352127893576,32.75172674988109],[-79.97241962904334,32.751781676792525],[-79.94472608072554,32.75436923172295],[-79.94822036641213,32.74341178594307],[-79.94856222216308,32.741672974559805],[-79.94849420093801,32.73991147812454],[-79.94801894064798,32.738194989302386],[-79.94715472675587,32.73658946734588],[-79.9459347863079,32.735156603995925],[-79.94440600863459,32.733951453855056],[-79.94262714224914,32.733020320120986],[-79.94066653741295,32.732398976709604],[-79.9395850481398,32.732204712792466],[-79.80706212613109,32.71429875671359],[-79.8049712597958,32.71419227379111],[-79.80289587151414,32.71443100659214],[-79.80091569425777,32.715005783449016],[-79.79910680630014,32.71589452221195],[-79.79753871043647,32.71706307790994],[-79.79627166481986,32.718466553589735],[-79.79535436771548,32.720051024160654],[-79.79482208507906,32.7217556072302],[-79.79469529306343,32.72351480157398],[-79.79470199559525,32.72364103345045],[-79.80703753076527,32.923866798053545],[-79.80735097469159,32.92560947457513],[-79.8080634528841,32.927267334842],[-79.80914760380932,32.92877666174044],[-79.81056177544086,32.93007944371511],[-79.8122516242035,32.93112560548598],[-79.81415220302256,32.93187493395129],[-79.81418128437302,32.93188355508795],[-79.91786352854136,32.962425829008595],[-79.91990393392132,32.96284459212799],[-79.9220025120135,32.96292128890985],[-79.92407859152152,32.96265297105664],[-79.92605236678787,32.962049952929625],[-79.9278479681969,32.96113541470802],[-79.92939638062498,32.95994451059291],[-79.93063809735312,32.95852301647866],[-79.9314344195749,32.95713450690191],[-79.9842928953925,32.84009469482486],[-79.98484132033083,32.838393571313716],[-79.9849887038998,32.83683591214674]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-79.92141723632812,32.953944317478246],[-79.97428894042969,32.83690450361482],[-79.97360229492188,32.76071688548088],[-79.93034362792969,32.76475877693074],[-79.93789672851562,32.74108223150125],[-79.80537414550781,32.7231762754146],[-79.81773376464844,32.923402043498875],[-79.92141723632812,32.953944317478246]]]}}]} \ No newline at end of file From a14757117da3cfcac335db8e13be0ede339cf2bf Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Tue, 9 Aug 2016 23:17:21 +0200 Subject: [PATCH 36/42] Fix neglecting of holes caused by f75aee9dd5d70f310ee8289147a43747d71f72ae due to shallow copy --- index.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 1ff5283..469d591 100644 --- a/index.js +++ b/index.js @@ -188,20 +188,19 @@ function arc(pt, radius, bearing1, bearing2, units, resolution, right, shortcut) } function filterNetWinding(fc, filterFn) { + var output = {type: 'FeatureCollection', features: []}; var i = fc.features.length; while (i--) { - if (!filterFn(fc.features[i].properties.netWinding)) { - fc.features.splice(i, 1); - } else { - fc.features[i].properties = {}; + if (filterFn(fc.features[i].properties.netWinding)) { + output.features.push({type: "Feature", geometry: fc.features[i].geometry, properties: {}}); } } - return fc; + return output; } function unionFeatureCollection(fc) { // Note: union takes a polygon, but return a polygon or multipolygon (which it can not take in). In case of buffes, however, it will always return a polygon - if (fc.features.length == 0) return {type: "Feature", geometry: null}; + if (fc.features.length == 0) return {type: "Feature", geometry: null, properties: {}}; var incrementalUnion = fc.features[0]; if (fc.features.length == 1) return incrementalUnion; for (var i = 1; i < fc.features.length; i++) { From 6eebbf347ae27cd5e47cab20c8a538cf9836dceb Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Mon, 15 Aug 2016 16:38:32 +0200 Subject: [PATCH 37/42] fix winding function --- index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 469d591..58aa1be 100644 --- a/index.js +++ b/index.js @@ -227,9 +227,14 @@ function offsetToBuffer(polygonOffset) { function winding(poly){ // compute winding of first ring var coords = poly.geometry.coordinates[0]; - var leftVtx = 0; - for (var i = 0; i < coords.length-1; i++) { if (coords[i][0] < coords[leftVtx][0]) leftVtx = i; } - return (coords[(leftVtx-1).modulo(coords.length-1)][1] > coords[(leftVtx+1).modulo(coords.length-1)][1]) ? 1 : -1; + var leftVtxIndex = 0; + for (var i = 0; i < coords.length-1; i++) { if (coords[i][0] < coords[leftVtxIndex][0]) leftVtxIndex = i; } + var prevVtx = coords[(leftVtxIndex-1).modulo(coords.length-1)]; + var leftVtx = coords[leftVtxIndex]; + var nxtVtx = coords[(leftVtxIndex+1).modulo(coords.length-1)]; + var atan1 = Math.atan((prevVtx[1]-leftVtx[1])/(prevVtx[0]-leftVtx[0])); + var atan2 = Math.atan((nxtVtx[1]-leftVtx[1])/(nxtVtx[0]-leftVtx[0])); + return (atan1 > atan2) ? 1 : -1; } function rewind(poly){ From 60f5ad1dd77c5f0f70a0c642cc74f295eae1d421 Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Mon, 15 Aug 2016 19:19:40 +0200 Subject: [PATCH 38/42] ignore extra fixtures and their test --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index ee12363..75e8543 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,7 @@ node_modules # Output of tests test/fixtures/out + +# Extra tests +test/test-extra.js +test/fixtures-extra From 3350d0755c96cb6452c1240940eaba47e03fb198 Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Wed, 17 Aug 2016 08:53:56 +0200 Subject: [PATCH 39/42] entab --- index.js | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/index.js b/index.js index 58aa1be..41625ab 100644 --- a/index.js +++ b/index.js @@ -219,7 +219,7 @@ function offsetToBuffer(polygonOffset) { var unionWithWindingZero = unionFeatureCollection(filterNetWinding(sp, function (netWinding){return netWinding == 0})); // This last one might have winding -1, so we might have to rewind it if the difference algorithm requires so - if (unionWithWindingOne.geometry == null) return {type: "Feature", geometry: null}; + if (unionWithWindingOne.geometry == null) return {type: "Feature", geometry: null, properties: {}}; if (unionWithWindingZero.geometry == null) return unionWithWindingOne; return difference(unionWithWindingOne, unionWithWindingZero); } @@ -258,27 +258,27 @@ function removeDuplicates(arr) { // Function to compare Arrays of numbers. From http://stackoverflow.com/questions/7837456/how-to-compare-arrays-in-javascript function equalArrays(array1, array2) { - // if the other array is a falsy value, return - if (!array1 || !array2) - return false; - - // compare lengths - can save a lot of time - if (array1.length != array2.length) - return false; - - for (var i = 0, l=array1.length; i < l; i++) { - // Check if we have nested arrays - if (array1[i] instanceof Array && array2[i] instanceof Array) { - // recurse into the nested arrays - if (!equalArrays(array1[i],array2[i])) - return false; - } - else if (array1[i] != array2[i]) { - // Warning - two different object instances will never be equal: {x:20} != {x:20} - return false; - } - } - return true; + // if the other array is a falsy value, return + if (!array1 || !array2) + return false; + + // compare lengths - can save a lot of time + if (array1.length != array2.length) + return false; + + for (var i = 0, l=array1.length; i < l; i++) { + // Check if we have nested arrays + if (array1[i] instanceof Array && array2[i] instanceof Array) { + // recurse into the nested arrays + if (!equalArrays(array1[i],array2[i])) + return false; + } + else if (array1[i] != array2[i]) { + // Warning - two different object instances will never be equal: {x:20} != {x:20} + return false; + } + } + return true; } // Fix Javascript modulo for negative number. From http://stackoverflow.com/questions/4467539/javascript-modulo-not-behaving From 173433a9bce1b26f47a52f83a2da01ac06328006 Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Sun, 21 Aug 2016 00:15:37 +0200 Subject: [PATCH 40/42] Always measure bearings from point where arc is made --- index.js | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/index.js b/index.js index 41625ab..d368693 100644 --- a/index.js +++ b/index.js @@ -72,19 +72,23 @@ function lineBuffer(line, radius, units, resolution) { if (!(equalArrays(line.geometry.coordinates[0],line.geometry.coordinates[line.geometry.coordinates.length-1]))) { - // situation at current point = point 0 - var currentLinePoint = helpers.point(line.geometry.coordinates[0]); - var nextLineBearing = bearing(helpers.point(line.geometry.coordinates[0]), helpers.point(line.geometry.coordinates[1])); - var currentBufferPoint = destination(currentLinePoint, radius, nextLineBearing + 90, units); - var previousLinePoint = helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-1]); - var previousLineBearing = bearing(helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-2]), helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-1])); + // situation at first point + var firstLinePoint = helpers.point(line.geometry.coordinates[0]); + var secondLinePoint = helpers.point(line.geometry.coordinates[1]); + var firstLineBearing = bearing(firstLinePoint, secondLinePoint); + var firstBufferPoint = destination(firstLinePoint, radius, firstLineBearing + 90, units); + + // situation at last point + var lastLinePoint = helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-1]); + var secondlastLinePoint = helpers.point(line.geometry.coordinates[line.geometry.coordinates.length-2]); + var lastLineBearing = bearing(lastLinePoint, secondlastLinePoint); lineOffset.push([]); - lineOffset[0].push.apply(lineOffset[0],[currentBufferPoint.geometry.coordinates]); // Add first buffer point in order to close ring + lineOffset[0].push.apply(lineOffset[0],[firstBufferPoint.geometry.coordinates]); // Add first buffer point in order to close ring lineOffset[0].push.apply(lineOffset[0],lineOffsetOneSide(line, radius, units, resolution, false, true).geometry.coordinates); - lineOffset[0].push.apply(lineOffset[0],arc(previousLinePoint, radius, previousLineBearing + 90, previousLineBearing - 90, units, resolution, true).geometry.coordinates); + lineOffset[0].push.apply(lineOffset[0],arc(lastLinePoint, radius, lastLineBearing - 90, lastLineBearing + 90, units, resolution, true).geometry.coordinates); lineOffset[0].push.apply(lineOffset[0],lineOffsetOneSide(line, radius, units, resolution, true, true).geometry.coordinates); - lineOffset[0].push.apply(lineOffset[0],arc(currentLinePoint, radius, nextLineBearing - 90, nextLineBearing + 90, units, resolution, true).geometry.coordinates); + lineOffset[0].push.apply(lineOffset[0],arc(firstLinePoint, radius, firstLineBearing - 90, firstLineBearing + 90, units, resolution, true).geometry.coordinates); return offsetToBuffer(helpers.polygon(lineOffset)); @@ -123,14 +127,13 @@ function lineOffsetOneSide(line, radius, units, resolution, reverse, right) { var lineOffset = []; if (coords.length == 2) return helpers.lineString(lineOffset) - var currentLinePoint = helpers.point(coords[1]); - var previousLineBearing = bearing(helpers.point(coords[0]), helpers.point(coords[1])); for (var i = 1; i < coords.length-1; i++) { + var previousLinePoint = helpers.point(coords[i-1]); + var currentLinePoint = helpers.point(coords[i]); var nextLinePoint = helpers.point(coords[i+1]); + var previousLineBearing = bearing(currentLinePoint, previousLinePoint); var nextLineBearing = bearing(currentLinePoint, nextLinePoint); - lineOffset.push.apply(lineOffset, arc(currentLinePoint, radius, previousLineBearing + Math.pow(-1, right + 1) * 90, nextLineBearing + Math.pow(-1, right + 1) * 90, units, resolution, right, true).geometry.coordinates); - var currentLinePoint = nextLinePoint; - var previousLineBearing = nextLineBearing; + lineOffset.push.apply(lineOffset, arc(currentLinePoint, radius, previousLineBearing - Math.pow(-1, right + 1) * 90, nextLineBearing + Math.pow(-1, right + 1) * 90, units, resolution, right, true).geometry.coordinates); } return helpers.lineString(lineOffset) @@ -144,15 +147,16 @@ function ringOffsetOneSide(ring, radius, units, resolution, reverse, right) { var ringOffset = []; // situation at current point = point 0 + var previousRingPoint = helpers.point(coords[coords.length-2]); var currentRingPoint = helpers.point(coords[0]); - var nextRingBearing = bearing(helpers.point(coords[0]), helpers.point(coords[1])); + var nextRingPoint = helpers.point(coords[1]); + var nextRingBearing = bearing(currentRingPoint, nextRingPoint); var currentBufferPoint = destination(currentRingPoint, radius, nextRingBearing + 90, units); - var previousRingPoint = helpers.point(coords[coords.length-1]); - var previousRingBearing = bearing(helpers.point(coords[coords.length-2]), helpers.point(coords[coords.length-1])); + var previousRingBearing = bearing(currentRingPoint, previousRingPoint); ringOffset.push.apply(ringOffset, [currentBufferPoint.geometry.coordinates]); // Add first buffer point in order to close ring ringOffset.push.apply(ringOffset, lineOffsetOneSide(ring, radius, units, resolution, false, right).geometry.coordinates); - ringOffset.push.apply(ringOffset, arc(currentRingPoint, radius, previousRingBearing + Math.pow(-1, right + 1) * 90, nextRingBearing + Math.pow(-1, right + 1) * 90, units, resolution, right, true).geometry.coordinates); + ringOffset.push.apply(ringOffset, arc(currentRingPoint, radius, previousRingBearing - Math.pow(-1, right + 1) * 90, nextRingBearing + Math.pow(-1, right + 1) * 90, units, resolution, right, true).geometry.coordinates); return helpers.lineString(ringOffset) } From 81756a3d0e4ce144b439bfd77749df9afc1666db Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Sun, 21 Aug 2016 11:41:55 +0200 Subject: [PATCH 41/42] fix to make shortcut arc for reflex angles pass through point, fully implementing the approach of Polygon Offsetting By Computing Winding Numbers paper and fixing the creation of false inner rings --- index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.js b/index.js index d368693..709448b 100644 --- a/index.js +++ b/index.js @@ -182,6 +182,8 @@ function arc(pt, radius, bearing1, bearing2, units, resolution, right, shortcut) arc.push(spoke.geometry.coordinates); step--; } + } else { + arc.push(pt.geometry.coordinates); } // Add spoke for bearing 2, but only if this spoke has not been added yet. Do this by checking the destination point, since slightly different bearings can create equal destination points. var spokeBearing2 = destination(pt, radius, bearing2, units); From e0b23e98f5061acd038d3d431bdfaf7ec47241e2 Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Fri, 26 Aug 2016 18:57:01 +0200 Subject: [PATCH 42/42] simplify linestrings and polygons before buffering > speedup --- index.js | 27 +++++++++++++++------------ package.json | 3 ++- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/index.js b/index.js index 709448b..192bb52 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,7 @@ var bearing = require('turf-bearing'); var helpers = require('turf-helpers'); var union = require('turf-union'); var difference = require('turf-difference'); +var simplify = require('turf-simplify'); module.exports = buffer; @@ -23,29 +24,31 @@ function buffer(feature, radius, units, resolution){ }); return helpers.featureCollection(buffers) } - var geom = feature.geometry; - if (geom === null) return feature; - if(geom.type === 'Point') { + if (feature.geometry === null) return feature; + if (['LineString', 'MultiLineString', 'Polygon', 'MultiPolygon'].indexOf(feature.geometry.type) > -1) { // turf-simplify() currently handles points and multipoints incorrectly + feature = simplify(feature, helpers.distanceToDegrees(radius/20, units)); // radius/20 seems like the optimal balance between speed and detail + } + if(feature.geometry.type === 'Point') { return pointBuffer(feature, radius, units, resolution); - } else if(geom.type === 'MultiPoint') { + } else if(feature.geometry.type === 'MultiPoint') { var buffers = []; - geom.coordinates.forEach(function(coords) { + feature.geometry.coordinates.forEach(function(coords) { buffers.push(pointBuffer(helpers.point(coords), radius, units, resolution)); }); return helpers.featureCollection(buffers) - } else if(geom.type === 'LineString') { + } else if(feature.geometry.type === 'LineString') { return lineBuffer(feature, radius, units, resolution); - } else if(geom.type === 'MultiLineString') { + } else if(feature.geometry.type === 'MultiLineString') { var buffers = []; - geom.coordinates.forEach(function(coords) { + feature.geometry.coordinates.forEach(function(coords) { buffers.push(lineBuffer(helpers.lineString(coords), radius, units, resolution)); }); return helpers.featureCollection(buffers) - } else if(geom.type === 'Polygon') { + } else if(feature.geometry.type === 'Polygon') { return polygonBuffer(feature, radius, units, resolution); - } else if(geom.type === 'MultiPolygon') { + } else if(feature.geometry.type === 'MultiPolygon') { var buffers = []; - geom.coordinates.forEach(function(coords) { + feature.geometry.coordinates.forEach(function(coords) { buffers.push(polygonBuffer(helpers.polygon(coords), radius, units, resolution)); }); return helpers.featureCollection(buffers) @@ -219,7 +222,7 @@ function offsetToBuffer(polygonOffset) { // You can inspect the polygonOffset here // console.log(JSON.stringify(polygonOffset)); var sp = simplepolygon(polygonOffset); - // You can inspect the polygonOffset here + // You can inspect the simplepolygon output here // console.log(JSON.stringify(sp)); var unionWithWindingOne = unionFeatureCollection(filterNetWinding(sp, function (netWinding){return netWinding == 1})); var unionWithWindingZero = unionFeatureCollection(filterNetWinding(sp, function (netWinding){return netWinding == 0})); diff --git a/package.json b/package.json index 98372a7..529d979 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "turf-bearing": "^3.0.0", "turf-helpers": "^3.0.0", "turf-union": "^3.0.0", - "turf-difference": "^3.0.0" + "turf-difference": "^3.0.0", + "turf-simplify": "^3.0.0" } }