Skip to content

Commit 4ba541f

Browse files
authored
Merge pull request #46 from conveyal/arc-segment
feat(renderer): Add support for direct arc-based segments
2 parents f6be7ef + 0d14d2f commit 4ba541f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/renderer/renderedsegment.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import d3 from 'd3'
22
import { forEach } from 'lodash'
33

44
import interpolateLine from '../util/interpolate-line'
5-
5+
import { distance } from '../util'
66
/**
77
* RenderedSegment
88
*/
@@ -85,6 +85,19 @@ export default class RenderedSegment {
8585
})
8686
}
8787

88+
// Check if this segment is to be drawn as an arc; if so replace render data
89+
if (this.pathSegment.journeySegment && this.pathSegment.journeySegment.arc) {
90+
const first = this.renderData[0]
91+
const last = this.renderData[this.renderData.length - 1]
92+
const arc = {
93+
x: last.x,
94+
y: last.y,
95+
arc: -45,
96+
radius: distance(first.x, first.y, last.x, last.y)
97+
}
98+
this.renderData = [first, arc, last]
99+
}
100+
88101
var lineData = this.line(this.renderData)
89102
this.lineGraph.attr('d', lineData)
90103
this.lineGraphFront.attr('d', lineData)

0 commit comments

Comments
 (0)