public-transport / hafas-client

JavaScript client for HAFAS public transport APIs.
ISC License
274 stars 53 forks source link

refactor products/modes markup #29

Closed derhuerst closed 6 years ago

derhuerst commented 6 years ago

The current markup is a mess, spread over two places and with lots of explicitly or implicitly redundant values.

Let's make a new one. It might look like this:

// products.js
module.exports = [
  {
    id: 'subway',
    mode: 'train',
    name: 'U-Bahn',
    short: 'U',
    bitmasks: [64, 128], // some endpoints assign several digits to one product
    default: true
  }
  // ...
]
derhuerst commented 6 years ago

This would be a breaking change because you use hafas-client with other profiles than the bundled ones.

derhuerst commented 6 years ago

The unknown product should also be moved from the markup into the parsing code.

juliuste commented 6 years ago

By the way, we should agree on what the name key should represent. There's always the "original" names (mostly german), e.g. "Durchgangszug", which often don't have an accurate translation in English.

derhuerst commented 6 years ago

Looking at it theoretically, I think it would be good to have multiple names (at least the local one and English) for a product. But maybe this would be a bit over the top.

In the "Writing a profile" guide, I've used the following phrase:

A short, but distinct name for the means of transport, just precise enough in local context. In Berlin, S-Bahn commuter rail would be too much, because everyone knows what S-Bahn means.

Maybe we should add that it is about the name in the local language.