~ihabunek/triglav

699daff870ba2915b4badb40408e1702ddf3a3b7 — Ivan Habunek 9 months ago bd6c25c
Differentiate between whole roundabouts and fragments
2 files changed, 22 insertions(+), 6 deletions(-)

M lib/triglav/schemas/osmosis/way.ex
M lib/triglav/zet/osmosis.ex
M lib/triglav/schemas/osmosis/way.ex => lib/triglav/schemas/osmosis/way.ex +22 -5
@@ 30,10 30,10 @@ defmodule Triglav.Schemas.Osmosis.Way do
  @spec adjacent?(t(), t()) :: boolean()
  def adjacent?(%Way{} = one, %Way{} = other) do
    cond do
      roundabout?(one) ->
      is_whole_roundabout?(one) ->
        roundabout_adjacent?(one, other)

      roundabout?(other) ->
      is_whole_roundabout?(other) ->
        roundabout_adjacent?(other, one)

      true ->


@@ 53,8 53,25 @@ defmodule Triglav.Schemas.Osmosis.Way do
      List.last(one.node_ids) == List.last(other.node_ids)
  end

  @spec roundabout?(t()) :: boolean()
  def roundabout?(%Way{} = way) do
    has_tag?(way, "junction", "roundabout")
  @doc """
  Returns true if the given way is tagged with `junction=roundabout`.

  Meaning it will return true when the given way is part of a roundabout, not a
  full circular way. See `is_whole_roundabout?/1`.
  """
  @spec is_roundabout?(t()) :: boolean()
  def is_roundabout?(%Way{} = way) do
    has_tag?(way, "junction", "roundabout") and
      List.first(way.node_ids) == List.last(way.node_ids)
  end

  @doc """
  Returns true if the given way is circular and tagged with
  `junction=roundabout`.
  """
  @spec is_whole_roundabout?(t()) :: boolean()
  def is_whole_roundabout?(%Way{} = way) do
    has_tag?(way, "junction", "roundabout") and
      List.first(way.node_ids) == List.last(way.node_ids)
  end
end

M lib/triglav/zet/osmosis.ex => lib/triglav/zet/osmosis.ex +0 -1
@@ 10,7 10,6 @@ defmodule Triglav.Zet.Osmosis do
  alias Triglav.Schemas.Osmosis.Way

  import Ecto.Query
  import Geo.PostGIS

  def list_public_transport_relations(opts \\ []) do
    pt_relations()