Tile38 (ex_tile38 v0.2.0)

Elixir wrapper for Tile38 client. Formats responses to common queries for convenience.

Getting started

This package requires Redix.

# mix.exs
  defp deps do
    {:ex_tile38, ">= 0.0.0"},
    {:redix, ">= 0.0.0"}
  end

Before calling any commands, you must initialize a named Redix connection, i.e.

{:ok, _} = Redix.start_link("redis://localhost:9851/", name: :tile38)

If you want to use a name other than :tile38, you can pass the name as an atom to any method as the second argument.

Link to this section Summary

Functions

Clear the entire Tile38 database.

Send a get command withfields to Tile38 and and return the response as JSON.

Send a jget command to Tile38 and parse the response as JSON.

Send a nearby or scan command to Tile38 and and return the response as JSON.

Send any command to Tile38 and return the response with no special formatting applied.

Link to this section Functions

Link to this function

clear_database()

Clear the entire Tile38 database.

Link to this function

f38(command, redix_key \\ :tile38)

Send a get command withfields to Tile38 and and return the response as JSON.

Parameters

  • command: String of the exact command you wish to send to Tile38.
  • redix_key: (Optional) Atom with the name of the redix connection. Defaults to :tile38.

Examples

iex> Tile38.t38("set mycollection my_id field firstfield 10 field secondfield 20 point 10 -10 123")
iex> Tile38.f38("get mycollection my_id withfields")
%Tile38.Point{
  fields: %{
    firstfield: "10",
    secondfield: "20"
  },
  coordinates: %{
    lat: 10,
    lng: -10,
    timestamp: 123,
    type: "Point"
  }
}
Link to this function

j38(command, redix_key \\ :tile38)

Send a jget command to Tile38 and parse the response as JSON.

Parameters

  • command: String of the exact command you wish to send to Tile38.
  • redix_key: (Optional) Atom with the name of the redix connection. Defaults to :tile38.

Examples

iex> Tile38.t38("jset user 901 name.first Tom")
iex> Tile38.j38("jget user 901")
%{name: %{first: "Tom"}}
Link to this function

n38(command, redix_key \\ :tile38)

Send a nearby or scan command to Tile38 and and return the response as JSON.

Parameters

  • command: String of the exact command you wish to send to Tile38.
  • redix_key: (Optional) Atom with the name of the redix connection. Defaults to :tile38.

Examples

iex> Tile38.t38("set mycollection my_id field firstfield 10 point 10 -10 1000")
iex> Tile38.n38("nearby mycollection point 10 -10")
[
  %Tile38.Point{
    id: "my_id",
    coordinates: %{
      lat: 10,
      lng: -10,
      timestamp: 1000,
      type: "Point",
    },
    fields: %{
      firstfield: "10"
    }
  }
]
Link to this function

t38(command, redix_key \\ :tile38)

Send any command to Tile38 and return the response with no special formatting applied.

Parameters

  • command: String of the exact command you wish to send to Tile38.
  • redix_key: (Optional) Atom with the name of the redix connection. Defaults to :tile38.

Examples

iex> Tile38.t38("set mycollection my_id field firstfield 10 point 10 -10 1000")
iex> Tile38.t38("get mycollection my_id withfields")
[~s/{"type":"Point","coordinates":[-10,10,1000]}/, ["firstfield", "10"] ]