~ihabunek/triglav

ref: f66c43139d76b7a26925de4e29498ff1473c0950 triglav/lib/triglav/schemas/public_transport/platform.ex -rw-r--r-- 946 bytes
f66c4313Ivan Habunek Store sample trip ID in derived data, simplify schemas 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
defmodule Triglav.Schemas.PublicTransport.Platform do
  @moduledoc """
  Contains extended information for a public transport stop.
  """
  use Ecto.Schema

  alias Triglav.Schemas.Osmosis
  alias Triglav.Schemas.PublicTransport.Trip
  alias Triglav.Schemas.Zet

  @type t :: %__MODULE__{}

  schema "public_transport_platforms" do
    belongs_to :trip, Trip
    belongs_to :relation, Osmosis.Relation

    # These are optional, populated if relation is matched to route
    belongs_to :stop, Zet.Stop, type: :binary
    belongs_to :route, Zet.Route, type: :binary

    # Platform can be either a way or node
    belongs_to :node, Osmosis.Node
    belongs_to :way, Osmosis.Way

    field :sequence_id, :integer
    field :geometry, Geo.PostGIS.Geometry

    # TODO: maybe make this a real field, we'd need to import data first, to get
    # it indexed, and then populate this field
    field :distance_from_route, :float, virtual: true
  end
end