Skip to content

remove dependency on wellknown in favor of terraformer-wkt-parser - #5682

Merged
janmeier merged 1 commit into
sequelize:masterfrom
daniel-pedersen:wellknown-to-terraformer
Apr 2, 2016
Merged

janmeier merged 1 commit into
sequelize:masterfrom
daniel-pedersen:wellknown-to-terraformer

Conversation

@daniel-pedersen

Copy link
Copy Markdown

terraformer-wkt-parser seems like a much better choice to wellknown for WKT parsing, here are a few reasons:

  • faster
  • better documentation
  • fewer dependencies
  • less unnecessary features such as a cli

These alternatives were turned down:

  • OpenLayers WKT -- needs to be put in it's own module
  • Wicket -- more unnecessary features, needs an instance to be created on each convert (so likely slower)

Benchmark:

Benchmarks for: polygon...

o wellknown x 108,678 ops/sec ±1.53% (135 runs sampled)
o terraformer x 124,363 ops/sec ±2.61% (133 runs sampled)

Fastest: terraformer
Slowest: wellknown

---

Benchmarks for: linestring...

o wellknown x 75,265 ops/sec ±2.82% (135 runs sampled)
o terraformer x 80,427 ops/sec ±3.51% (130 runs sampled)

Fastest: terraformer
Slowest: wellknown

---

Benchmarks for: points...

o wellknown x 109,672 ops/sec ±1.45% (140 runs sampled)
o terraformer x 120,631 ops/sec ±1.89% (139 runs sampled)

Fastest: terraformer
Slowest: wellknown

---
All benchmarks finished.

Benchmark code:

var Benchmark = require('test.benchmark')
global.wellknown = require('wellknown')
global.wkt = require('terraformer-wkt-parser')

global.polygon = { "type": "Polygon", "coordinates": [ [ [ 8.26171875, 49.03786794532644 ], [ 11.77734375, 33.87041555094183 ], [ 39.55078125, 50.401515322782366 ], [ 27.421875, 61.270232790000634 ], [ 10.1953125, 62.99515845212052 ], [ -9.667968749999998, 51.28940590271679 ], [ -7.3828125, 32.99023555965106 ], [ -36.73828124999999, 11.350796722383684 ], [ -11.42578125, -44.46515101351962 ], [ 25.6640625, -12.897489183755892 ], [ 23.73046875, 13.581920900545844 ], [ 31.113281249999996, 23.725011735951796 ], [ 8.26171875, 49.03786794532644 ] ] ] }
global.linestring = { "type": "LineString", "coordinates": [ [ -16.171875, 71.07405646336098 ], [ 49.04296875, 69.28725695167886 ], [ 46.58203125, 40.84706035607122 ], [ 29.70703125, -8.407168163601076 ], [ -13.886718749999998, -28.14950321154457 ], [ -108.10546875, 34.30714385628804 ], [ -81.73828125, 56.65622649350222 ], [ -88.24218749999999, 36.4566360115962 ], [ -94.21875, -7.01366792756663 ], [ -92.46093749999999, -6.315298538330021 ], [ -91.40625, -4.214943141390639 ], [ -89.6484375, -5.090944175033373 ], [ -88.76953125, -8.407168163601076 ], [ -81.03515625, -7.536764322084078 ], [ -48.8671875, 57.98480801923985 ], [ -40.78125, 47.39834920035926 ], [ -54.84375, 22.43134015636061 ], [ -57.30468749999999, -17.14079039331665 ], [ -47.63671875, -33.43144133557529 ], [ -36.9140625, -7.01366792756663 ] ] }
global.points = [ { "type": "Point", "coordinates": [ 16.69921875, 68.59248658252947 ] }, { "type": "Point", "coordinates": [ 54.4921875, 36.73888412439431 ] }, { "type": "Point", "coordinates": [ 8.7890625, 16.29905101458183 ] }, { "type": "Point", "coordinates": [ -6.85546875, 38.685509760012 ] }, { "type": "Point", "coordinates": [ 16.5234375, 58.63121664342478 ] }, { "type": "Point", "coordinates": [ -2.4609375, 59.88893689676585 ] }, { "type": "Point", "coordinates": [ -53.96484375, 70.25945200030638 ] }, { "type": "Point", "coordinates": [ -98.4375, 58.17070248348612 ] }, { "type": "Point", "coordinates": [ -104.94140625, 31.653381399664 ] }, { "type": "Point", "coordinates": [ -94.74609375, 39.774769485295465 ] }, { "type": "Point", "coordinates": [ -35.5078125, 40.3130432088809 ] }, { "type": "Point", "coordinates": [ -103.18359375, -34.161818161230386 ] }, { "type": "Point", "coordinates": [ -48.515625, -24.04646399966658 ] }, { "type": "Point", "coordinates": [ -61.34765625, -9.10209673872643 ] } ]

Benchmark.runWithDefaults([
  Benchmark.syncSuite('polygon', {
    wellknown: function() {
      wellknown.stringify(polygon)
    },
    terraformer: function() {
      wkt.convert(polygon)
    }
  }),
  Benchmark.syncSuite('linestring', {
    wellknown: function() {
      wellknown.stringify(linestring)
    },
    terraformer: function() {
      wkt.convert(linestring)
    }
  }),
  Benchmark.syncSuite('points', {
    wellknown: function() {
      points.forEach(function (x) { wellknown.stringify(x) })
    },
    terraformer: function() {
      points.forEach(function (x) { wkt.convert(x) })
    }
  })
])

@janmeier
janmeier merged commit 46d4068 into sequelize:master Apr 2, 2016
@janmeier

janmeier commented Apr 2, 2016

Copy link
Copy Markdown
Member

Sweet! Thanks for the thorough PR description

@daniel-pedersen

Copy link
Copy Markdown
Author

My pleasure, thank you for the awesome library!

@daniel-pedersen
daniel-pedersen deleted the wellknown-to-terraformer branch April 4, 2016 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants