johnwalley / d3-tube-map

Draw tube maps in the style of the London Underground using d3
https://observablehq.com/@johnwalley/d3-tube-map
BSD 3-Clause "New" or "Revised" License
168 stars 22 forks source link

Allow coordinates to be assigned to stations #223

Open JDDurrant opened 2 weeks ago

JDDurrant commented 2 weeks ago

Currently, in this library, a station has the following shape:

{
  label: 'Central',
}

To indicate that a line serves a station, the following is included in the line's nodes array:

{
  name: 'CEN',
  labelPos: 'W',
  coords: [0, 0], // Mandatory property.
}

It looks like each station gets its coordinates on the map from a line's node. If a station is included in the stations object, but not included on any of the lines, the library throws an error.


Since a station's coordinates are immutable, and since each station marker can only have one label, I think the coords and labelPos properties should be assigned to the station object instead.

{
  label: 'Central',
  labelPos: 'W',
  coords: [0, 0],
}

When a line serves a station, the node showing this can have just the name property.

{
  name: 'CEN',
}

This node can then get its coords property from the matching station from the stations object.

When a line turns a corner, it should still use a single coords property, as before.