~ihabunek/triglav

ref: 1a8ba58407fc58b933347c9bec5bcb4358191cbb triglav/lib/triglav/schemas/zet/stop.ex -rw-r--r-- 723 bytes
1a8ba584Ivan Habunek Use derived data for route detail view 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
defmodule Triglav.Schemas.Zet.Stop do
  use Ecto.Schema
  alias Triglav.GeoJSON

  @primary_key false
  @schema_prefix :zet

  schema "stops" do
    field :id, :string, source: :stop_id, primary_key: true
    field :code, :string, source: :stop_code
    field :name, :string, source: :stop_name
    field :desc, :string, source: :stop_desc
    field :lat, :float, source: :stop_lat
    field :lon, :float, source: :stop_lon
    field :zone_id, :string
    field :url, :string, source: :stop_url
    field :location_type, :integer
    field :parent_station, :string
    field :geom, Geo.PostGIS.Geometry
  end

  def to_feature(%__MODULE__{} = stop) do
    GeoJSON.feature(stop.geom, Map.take(stop, [:id, :name]))
  end
end