code
stringlengths 114
1.05M
| path
stringlengths 3
312
| quality_prob
float64 0.5
0.99
| learning_prob
float64 0.2
1
| filename
stringlengths 3
168
| kind
stringclasses 1
value |
---|---|---|---|---|---|
defmodule Map do
@moduledoc """
A `Dict` implementation that works on maps.
Maps are key-value stores where keys are compared using
the match operator (`===`). Maps can be created with
the `%{}` special form defined in the `Kernel.SpecialForms`
module.
For more information about the functions in this module and
their APIs, please consult the `Dict` module.
"""
use Dict
@type key :: any
@type value :: any
defdelegate [keys(map), values(map), merge(map1, map2), to_list(map)], to: :maps
@compile {:inline, fetch: 2, put: 3, delete: 2, has_key?: 2}
# TODO: Deprecate by 1.3
# TODO: Remove by 1.4
@doc false
def size(map) do
map_size(map)
end
@doc """
Returns a new empty map.
"""
@spec new :: map
def new, do: %{}
@doc """
Creates a map from an enumerable.
Duplicated keys are removed; the latest one prevails.
## Examples
iex> Map.new([{:b, 1}, {:a, 2}])
%{a: 2, b: 1}
iex> Map.new([a: 1, a: 2, a: 3])
%{a: 3}
"""
@spec new(Enum.t) :: map
def new(enumerable) do
Enum.reduce(enumerable, %{}, fn {k, v}, acc -> put(acc, k, v) end)
end
@doc """
Creates a map from an enumerable via the transformation function.
Duplicated entries are removed; the latest one prevails.
## Examples
iex> Map.new([:a, :b], fn x -> {x, x} end)
%{a: :a, b: :b}
"""
@spec new(Enum.t, (term -> {key, value})) :: map
def new(enumerable, transform) do
fun = fn el, acc ->
{k, v} = transform.(el)
put(acc, k, v)
end
Enum.reduce(enumerable, %{}, fun)
end
def has_key?(map, key), do: :maps.is_key(key, map)
def fetch(map, key), do: :maps.find(key, map)
def put(map, key, val) do
:maps.put(key, val, map)
end
def delete(map, key), do: :maps.remove(key, map)
def merge(map1, map2, callback) do
:maps.fold fn k, v2, acc ->
update(acc, k, v2, fn(v1) -> callback.(k, v1, v2) end)
end, map1, map2
end
@doc """
Updates the value in the map with the given function.
"""
def update!(%{} = map, key, fun) do
case fetch(map, key) do
{:ok, value} ->
put(map, key, fun.(value))
:error ->
:erlang.error({:badkey, key})
end
end
def update!(map, _key, _fun), do: :erlang.error({:badmap, map})
@doc """
Gets a value and updates a map in one operation.
"""
def get_and_update(%{} = map, key, fun) do
current_value = case :maps.find(key, map) do
{:ok, value} -> value
:error -> nil
end
{get, update} = fun.(current_value)
{get, :maps.put(key, update, map)}
end
def get_and_update(map, _key, _fun), do: :erlang.error({:badmap, map})
@doc """
Gets a value and updates a map only if the key exists in one operation.
"""
def get_and_update!(%{} = map, key, fun) do
case :maps.find(key, map) do
{:ok, value} ->
{get, update} = fun.(value)
{get, :maps.put(key, update, map)}
:error ->
:erlang.error({:badkey, key})
end
end
def get_and_update!(map, _key, _fun), do: :erlang.error({:badmap, map})
@doc """
Converts a struct to map.
It accepts the struct module or a struct itself and
simply removes the `__struct__` field from the struct.
## Example
defmodule User do
defstruct [:name]
end
Map.from_struct(User)
#=> %{name: nil}
Map.from_struct(%User{name: "john"})
#=> %{name: "john"}
"""
def from_struct(struct) when is_atom(struct) do
:maps.remove(:__struct__, struct.__struct__)
end
def from_struct(%{__struct__: _} = struct) do
:maps.remove(:__struct__, struct)
end
def equal?(map1, map2)
def equal?(%{} = map1, %{} = map2), do: map1 === map2
end | lib/elixir/lib/map.ex | 0.680348 | 0.666066 | map.ex | starcoder |
defmodule GenEvent.Behaviour do
@moduledoc """
This module is a convenience for defining GenEvent callbacks in Elixir.
GenEvent is an OTP behaviour that encapsulates event handling functionality.
## Example
Below is an example of a GenEvent that stores notifications
until they are fetched:
defmodule MyEventHandler do
use GenEvent.Behaviour
# Callbacks
def init(_) do
{ :ok, [] }
end
def handle_event({:notification, x}, notifications) do
{ :ok, [x|notifications] }
end
def handle_call(:notifications, notifications) do
{:ok, Enum.reverse(notifications), []}
end
end
{ :ok, pid } = :gen_event.start_link
#=> {:ok,#PID<0.42.0>}
:gen_event.add_handler(pid, MyEventHandler, [])
#=> :ok
:gen_event.notify(pid, {:notification, 1})
#=> :ok
:gen_event.notify(pid, {:notification, 2})
#=> :ok
:gen_event.call(pid, MyEventHandler, :notifications)
#=> [1, 2]
:gen_event.call(pid, MyEventHandler, :notifications)
#=> []
Notice we never call the server callbacks directly, they are called
by OTP whenever we interact with the server.
Starting and sending messages to the GenEvent is done
via Erlang's `:gen_event` module. For more information,
please refer to the following:
* http://www.erlang.org/doc/man/gen_event.html
* http://learnyousomeerlang.com/event-handlers
"""
@doc false
defmacro __using__(_) do
quote location: :keep do
@behaviour :gen_event
@doc false
def init(args) do
{ :ok, args }
end
@doc false
def handle_event(_event, state) do
{ :ok, state }
end
@doc false
def handle_call(_request, state) do
{ :ok, :ok, state }
end
@doc false
def handle_info(_msg, state) do
{ :ok, state }
end
@doc false
def terminate(reason, state) do
:ok
end
@doc false
def code_change(_old, state, _extra) do
{ :ok, state }
end
defoverridable [init: 1,
handle_event: 2,
handle_call: 2, handle_info: 2,
terminate: 2, code_change: 3]
end
end
end | lib/elixir/lib/gen_event/behaviour.ex | 0.678647 | 0.413862 | behaviour.ex | starcoder |
defmodule Seren.Player do
@moduledoc """
The Player context.
"""
import Ecto.Query, warn: false
alias Seren.Repo
alias Seren.Player.Track
@doc """
Returns the list of tracks.
## Examples
iex> list_tracks()
[%Track{}, ...]
"""
def list_tracks do
Repo.all(Track)
end
def list_tracks(limit) do
from(t in Track, join: artist in assoc(t, :artist), left_join: album in assoc(t, :album), limit: ^limit, order_by: [artist.name, album.title, :album_disc_number, :track_number, :title])
|> Repo.all
end
def list_tracks(limit, offset) do
from(t in Track, join: artist in assoc(t, :artist), left_join: album in assoc(t, :album), limit: ^limit, offset: ^offset, order_by: [artist.name, album.title, :album_disc_number, :track_number, :title])
|> Repo.all
end
@doc """
Returns list of tracks for various models
"""
def tracks_for_artist(id) do
from(t in Track, where: t.artist_id == ^id, left_join: album in assoc(t, :album), order_by: [album.title, :album_disc_number, :track_number, :title])
|> Repo.all
end
def tracks_for_genre(id) do
from(t in Track, join: artist in assoc(t, :artist), left_join: album in assoc(t, :album), where: t.genre_id == ^id, order_by: [artist.name, album.title, :album_disc_number, :track_number, :title])
|> Repo.all
end
def tracks_for_composer(id) do
from(t in Track, join: artist in assoc(t, :artist), left_join: album in assoc(t, :album), where: t.composer_id == ^id, order_by: [album.title, :album_disc_number, :track_number, artist.name, :title])
|> Repo.all
end
def tracks_for_album(id) do
from(t in Track, join: artist in assoc(t, :artist), where: t.album_id == ^id, order_by: [:album_disc_number, :track_number, artist.name, :title])
|> Repo.all
end
@doc """
Returns list of tracks for search query
"""
def tracks_for_search(query, limit) do
like_query = "%#{String.replace(query, "%", "\\%") |> String.replace("_", "\\_")}%"
from(t in Track, join: artist in assoc(t, :artist), left_join: album in assoc(t, :album), left_join: c in assoc(t, :composer), where: ilike(t.title, ^like_query) or ilike(artist.name, ^like_query) or ilike(album.title, ^like_query) or ilike(c.name, ^like_query), order_by: [artist.name, album.title, :album_disc_number, :track_number, :title], limit: ^limit)
|> Repo.all
end
@doc """
Gets a single track.
Raises `Ecto.NoResultsError` if the Track does not exist.
## Examples
iex> get_track!(123)
%Track{}
iex> get_track!(456)
** (Ecto.NoResultsError)
"""
def get_track!(id), do: Repo.get!(Track, id)
@doc """
Creates a track.
## Examples
iex> create_track(%{field: value})
{:ok, %Track{}}
iex> create_track(%{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def create_track(attrs \\ %{}) do
%Track{}
|> Track.changeset(attrs)
|> Repo.insert()
end
@doc """
Updates a track.
## Examples
iex> update_track(track, %{field: new_value})
{:ok, %Track{}}
iex> update_track(track, %{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def update_track(%Track{} = track, attrs) do
track
|> Track.changeset(attrs)
|> Repo.update()
end
@doc """
Deletes a Track.
## Examples
iex> delete_track(track)
{:ok, %Track{}}
iex> delete_track(track)
{:error, %Ecto.Changeset{}}
"""
def delete_track(%Track{} = track) do
Repo.delete(track)
end
@doc """
Returns an `%Ecto.Changeset{}` for tracking track changes.
## Examples
iex> change_track(track)
%Ecto.Changeset{source: %Track{}}
"""
def change_track(%Track{} = track) do
Track.changeset(track, %{})
end
alias Seren.Player.Artist
@doc """
Returns the list of artists.
## Examples
iex> list_artists()
[%Artist{}, ...]
"""
def list_artists do
from(Artist, order_by: :name)
|> Repo.all
end
@doc """
Gets a single artist.
Raises `Ecto.NoResultsError` if the Artist does not exist.
## Examples
iex> get_artist!(123)
%Artist{}
iex> get_artist!(456)
** (Ecto.NoResultsError)
"""
def get_artist!(id) do
Repo.get!(Artist, id)
end
@doc """
Creates a artist.
## Examples
iex> create_artist(%{field: value})
{:ok, %Artist{}}
iex> create_artist(%{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def create_artist(attrs \\ %{}) do
%Artist{}
|> Artist.changeset(attrs)
|> Repo.insert()
end
@doc """
Updates a artist.
## Examples
iex> update_artist(artist, %{field: new_value})
{:ok, %Artist{}}
iex> update_artist(artist, %{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def update_artist(%Artist{} = artist, attrs) do
artist
|> Artist.changeset(attrs)
|> Repo.update()
end
@doc """
Deletes a Artist.
## Examples
iex> delete_artist(artist)
{:ok, %Artist{}}
iex> delete_artist(artist)
{:error, %Ecto.Changeset{}}
"""
def delete_artist(%Artist{} = artist) do
Repo.delete(artist)
end
@doc """
Returns an `%Ecto.Changeset{}` for tracking artist changes.
## Examples
iex> change_artist(artist)
%Ecto.Changeset{source: %Artist{}}
"""
def change_artist(%Artist{} = artist) do
Artist.changeset(artist, %{})
end
alias Seren.Player.Genre
@doc """
Returns the list of genres.
## Examples
iex> list_genres()
[%Genre{}, ...]
"""
def list_genres do
from(Genre, order_by: :name)
|> Repo.all
end
@doc """
Gets a single genre.
Raises `Ecto.NoResultsError` if the Genre does not exist.
## Examples
iex> get_genre!(123)
%Genre{}
iex> get_genre!(456)
** (Ecto.NoResultsError)
"""
def get_genre!(id), do: Repo.get!(Genre, id)
@doc """
Creates a genre.
## Examples
iex> create_genre(%{field: value})
{:ok, %Genre{}}
iex> create_genre(%{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def create_genre(attrs \\ %{}) do
%Genre{}
|> Genre.changeset(attrs)
|> Repo.insert()
end
@doc """
Updates a genre.
## Examples
iex> update_genre(genre, %{field: new_value})
{:ok, %Genre{}}
iex> update_genre(genre, %{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def update_genre(%Genre{} = genre, attrs) do
genre
|> Genre.changeset(attrs)
|> Repo.update()
end
@doc """
Deletes a Genre.
## Examples
iex> delete_genre(genre)
{:ok, %Genre{}}
iex> delete_genre(genre)
{:error, %Ecto.Changeset{}}
"""
def delete_genre(%Genre{} = genre) do
Repo.delete(genre)
end
@doc """
Returns an `%Ecto.Changeset{}` for tracking genre changes.
## Examples
iex> change_genre(genre)
%Ecto.Changeset{source: %Genre{}}
"""
def change_genre(%Genre{} = genre) do
Genre.changeset(genre, %{})
end
alias Seren.Player.Composer
@doc """
Returns the list of composers.
## Examples
iex> list_composers()
[%Composer{}, ...]
"""
def list_composers do
from(Composer, order_by: :name)
|> Repo.all
end
@doc """
Gets a single composer.
Raises `Ecto.NoResultsError` if the Composer does not exist.
## Examples
iex> get_composer!(123)
%Composer{}
iex> get_composer!(456)
** (Ecto.NoResultsError)
"""
def get_composer!(id), do: Repo.get!(Composer, id)
@doc """
Creates a composer.
## Examples
iex> create_composer(%{field: value})
{:ok, %Composer{}}
iex> create_composer(%{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def create_composer(attrs \\ %{}) do
%Composer{}
|> Composer.changeset(attrs)
|> Repo.insert()
end
@doc """
Updates a composer.
## Examples
iex> update_composer(composer, %{field: new_value})
{:ok, %Composer{}}
iex> update_composer(composer, %{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def update_composer(%Composer{} = composer, attrs) do
composer
|> Composer.changeset(attrs)
|> Repo.update()
end
@doc """
Deletes a Composer.
## Examples
iex> delete_composer(composer)
{:ok, %Composer{}}
iex> delete_composer(composer)
{:error, %Ecto.Changeset{}}
"""
def delete_composer(%Composer{} = composer) do
Repo.delete(composer)
end
@doc """
Returns an `%Ecto.Changeset{}` for tracking composer changes.
## Examples
iex> change_composer(composer)
%Ecto.Changeset{source: %Composer{}}
"""
def change_composer(%Composer{} = composer) do
Composer.changeset(composer, %{})
end
alias Seren.Player.FileType
@doc """
Returns the list of file_types.
## Examples
iex> list_file_types()
[%FileType{}, ...]
"""
def list_file_types do
Repo.all(FileType)
end
@doc """
Gets a single file_type.
Raises `Ecto.NoResultsError` if the File type does not exist.
## Examples
iex> get_file_type!(123)
%FileType{}
iex> get_file_type!(456)
** (Ecto.NoResultsError)
"""
def get_file_type!(id), do: Repo.get!(FileType, id)
@doc """
Creates a file_type.
## Examples
iex> create_file_type(%{field: value})
{:ok, %FileType{}}
iex> create_file_type(%{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def create_file_type(attrs \\ %{}) do
%FileType{}
|> FileType.changeset(attrs)
|> Repo.insert()
end
@doc """
Updates a file_type.
## Examples
iex> update_file_type(file_type, %{field: new_value})
{:ok, %FileType{}}
iex> update_file_type(file_type, %{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def update_file_type(%FileType{} = file_type, attrs) do
file_type
|> FileType.changeset(attrs)
|> Repo.update()
end
@doc """
Deletes a FileType.
## Examples
iex> delete_file_type(file_type)
{:ok, %FileType{}}
iex> delete_file_type(file_type)
{:error, %Ecto.Changeset{}}
"""
def delete_file_type(%FileType{} = file_type) do
Repo.delete(file_type)
end
@doc """
Returns an `%Ecto.Changeset{}` for tracking file_type changes.
## Examples
iex> change_file_type(file_type)
%Ecto.Changeset{source: %FileType{}}
"""
def change_file_type(%FileType{} = file_type) do
FileType.changeset(file_type, %{})
end
alias Seren.Player.Album
@doc """
Returns the list of albums.
## Examples
iex> list_albums()
[%Album{}, ...]
"""
def list_albums do
Repo.all(Album)
end
@doc """
Gets a single album.
Raises `Ecto.NoResultsError` if the Album does not exist.
## Examples
iex> get_album!(123)
%Album{}
iex> get_album!(456)
** (Ecto.NoResultsError)
"""
def get_album!(id), do: Repo.get!(Album, id)
@doc """
Creates a album.
## Examples
iex> create_album(%{field: value})
{:ok, %Album{}}
iex> create_album(%{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def create_album(attrs \\ %{}) do
%Album{}
|> Album.changeset(attrs)
|> Repo.insert()
end
@doc """
Updates a album.
## Examples
iex> update_album(album, %{field: new_value})
{:ok, %Album{}}
iex> update_album(album, %{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def update_album(%Album{} = album, attrs) do
album
|> Album.changeset(attrs)
|> Repo.update()
end
@doc """
Deletes a Album.
## Examples
iex> delete_album(album)
{:ok, %Album{}}
iex> delete_album(album)
{:error, %Ecto.Changeset{}}
"""
def delete_album(%Album{} = album) do
Repo.delete(album)
end
@doc """
Returns an `%Ecto.Changeset{}` for tracking album changes.
## Examples
iex> change_album(album)
%Ecto.Changeset{source: %Album{}}
"""
def change_album(%Album{} = album) do
Album.changeset(album, %{})
end
end | lib/seren/player/player.ex | 0.843009 | 0.545225 | player.ex | starcoder |
defprotocol Phoenix.HTML.FormData do
@moduledoc """
Converts a data structure into a [`Phoenix.HTML.Form`](`t:Phoenix.HTML.Form.t/0`) struct.
"""
@doc """
Converts a data structure into a [`Phoenix.HTML.Form`](`t:Phoenix.HTML.Form.t/0`) struct.
The options are the same options given to `form_for/4`. It
can be used by implementations to configure their behaviour
and it must be stored in the underlying struct, with any
custom field removed.
"""
@spec to_form(t, Keyword.t()) :: Phoenix.HTML.Form.t()
def to_form(data, options)
@doc """
Converts the field in the given form based on the data structure
into a list of [`Phoenix.HTML.Form`](`t:Phoenix.HTML.Form.t/0`) structs.
The options are the same options given to `inputs_for/4`. It
can be used by implementations to configure their behaviour
and it must be stored in the underlying struct, with any
custom field removed.
"""
@spec to_form(t, Phoenix.HTML.Form.t(), Phoenix.HTML.Form.field(), Keyword.t()) ::
[Phoenix.HTML.Form.t()]
def to_form(data, form, field, options)
@doc """
Returns the value for the given field.
"""
@spec input_value(t, Phoenix.HTML.Form.t(), Phoenix.HTML.Form.field()) :: term
def input_value(data, form, field)
@doc """
Returns the HTML5 validations that would apply to
the given field.
"""
@spec input_validations(t, Phoenix.HTML.Form.t(), Phoenix.HTML.Form.field()) :: Keyword.t()
def input_validations(data, form, field)
@doc """
Receives the given field and returns its input type (:text_input,
:select, etc). Returns `nil` if the type is unknown.
"""
@spec input_type(t, Phoenix.HTML.Form.t(), Phoenix.HTML.Form.field()) :: atom | nil
def input_type(data, form, field)
end
defimpl Phoenix.HTML.FormData, for: [Plug.Conn, Atom] do
def to_form(conn_or_atom, opts) do
{name, params, opts} = name_params_and_opts(conn_or_atom, opts)
{errors, opts} = Keyword.pop(opts, :errors, [])
id = Keyword.get(opts, :id) || name
unless is_binary(id) or is_nil(id) do
raise ArgumentError, ":id option in form_for must be a binary/string, got: #{inspect(id)}"
end
%Phoenix.HTML.Form{
source: conn_or_atom,
impl: __MODULE__,
id: id,
name: name,
params: params,
data: %{},
errors: errors,
options: opts
}
end
case @for do
Atom ->
defp name_params_and_opts(atom, opts) do
{params, opts} = Keyword.pop(opts, :params, %{})
{Atom.to_string(atom), params, opts}
end
Plug.Conn ->
defp name_params_and_opts(conn, opts) do
case Keyword.pop(opts, :as) do
{nil, opts} ->
{nil, conn.params, opts}
{name, opts} ->
name = to_string(name)
{name, Map.get(conn.params, name) || %{}, opts}
end
end
end
def to_form(conn_or_atom, form, field, opts) when is_atom(field) or is_binary(field) do
{default, opts} = Keyword.pop(opts, :default, %{})
{prepend, opts} = Keyword.pop(opts, :prepend, [])
{append, opts} = Keyword.pop(opts, :append, [])
{name, opts} = Keyword.pop(opts, :as)
{id, opts} = Keyword.pop(opts, :id)
{hidden, opts} = Keyword.pop(opts, :hidden, [])
id = to_string(id || form.id <> "_#{field}")
name = to_string(name || form.name <> "[#{field}]")
params = Map.get(form.params, field_to_string(field))
cond do
# cardinality: one
is_map(default) ->
[
%Phoenix.HTML.Form{
source: conn_or_atom,
impl: __MODULE__,
id: id,
name: name,
data: default,
params: params || %{},
hidden: hidden,
options: opts
}
]
# cardinality: many
is_list(default) ->
entries =
if params do
params
|> Enum.sort_by(&elem(&1, 0))
|> Enum.map(&{nil, elem(&1, 1)})
else
Enum.map(prepend ++ default ++ append, &{&1, %{}})
end
for {{data, params}, index} <- Enum.with_index(entries) do
index_string = Integer.to_string(index)
%Phoenix.HTML.Form{
source: conn_or_atom,
impl: __MODULE__,
index: index,
id: id <> "_" <> index_string,
name: name <> "[" <> index_string <> "]",
data: data,
params: params,
hidden: hidden,
options: opts
}
end
end
end
def input_value(_conn_or_atom, %{data: data, params: params}, field)
when is_atom(field) or is_binary(field) do
key = field_to_string(field)
case params do
%{^key => value} -> value
%{} -> Map.get(data, field)
end
end
def input_type(_conn_or_atom, _form, _field), do: :text_input
def input_validations(_conn_or_atom, _form, _field), do: []
# Normalize field name to string version
defp field_to_string(field) when is_atom(field), do: Atom.to_string(field)
defp field_to_string(field) when is_binary(field), do: field
end | lib/phoenix_html/form_data.ex | 0.911559 | 0.692044 | form_data.ex | starcoder |
defmodule AshPostgres.DataLayer do
@manage_tenant %Ash.Dsl.Section{
name: :manage_tenant,
describe: """
Configuration for the behavior of a resource that manages a tenant
""",
examples: [
"""
manage_tenant do
template ["organization_", :id]
create? true
update? false
end
"""
],
schema: [
template: [
type: {:custom, __MODULE__, :tenant_template, []},
required: true,
doc: """
A template that will cause the resource to create/manage the specified schema.
Use this if you have a resource that, when created, it should create a new tenant
for you. For example, if you have a `customer` resource, and you want to create
a schema for each customer based on their id, e.g `customer_10` set this option
to `["customer_", :id]`. Then, when this is created, it will create a schema called
`["customer_", :id]`, and run your tenant migrations on it. Then, if you were to change
that customer's id to `20`, it would rename the schema to `customer_20`. Generally speaking
you should avoid changing the tenant id.
"""
],
create?: [
type: :boolean,
default: true,
doc: "Whether or not to automatically create a tenant when a record is created"
],
update?: [
type: :boolean,
default: true,
doc: "Whether or not to automatically update the tenant name if the record is udpated"
]
]
}
@reference %Ash.Dsl.Entity{
name: :reference,
describe: """
Configures the reference for a relationship in resource migrations.
Keep in mind that multiple relationships can theoretically involve the same destination and foreign keys.
In those cases, you only need to configure the `reference` behavior for one of them. Any conflicts will result
in an error, across this resource and any other resources that share a table with this one. For this reason,
instead of adding a reference configuration for `:nothing`, its best to just leave the configuration out, as that
is the default behavior if *no* relationship anywhere has configured the behavior of that reference.
""",
examples: [
"reference :post, on_delete: :delete, on_update: :update, name: \"comments_to_posts_fkey\""
],
args: [:relationship],
target: AshPostgres.Reference,
schema: AshPostgres.Reference.schema()
}
@references %Ash.Dsl.Section{
name: :references,
describe: """
A section for configuring the references (foreign keys) in resource migrations.
This section is only relevant if you are using the migration generator with this resource.
Otherwise, it has no effect.
""",
examples: [
"""
references do
reference :post, on_delete: :delete, on_update: :update, name: "comments_to_posts_fkey"
end
"""
],
entities: [@reference],
schema: [
polymorphic_on_delete: [
type: {:one_of, [:delete, :nilify, :nothing, :restrict]},
doc:
"For polymorphic resources, configures the on_delete behavior of the automatically generated foreign keys to source tables."
],
polymorphic_on_update: [
type: {:one_of, [:update, :nilify, :nothing, :restrict]},
doc:
"For polymorphic resources, configures the on_update behavior of the automatically generated foreign keys to source tables."
],
polymorphic_name: [
type: {:one_of, [:update, :nilify, :nothing, :restrict]},
doc:
"For polymorphic resources, configures the on_update behavior of the automatically generated foreign keys to source tables."
]
]
}
@check_constraint %Ash.Dsl.Entity{
name: :check_constraint,
describe: """
Add a check constraint to be validated.
If a check constraint exists on the table but not in this section, and it produces an error, a runtime error will be raised.
Provide a list of attributes instead of a single attribute to add the message to multiple attributes.
By adding the `check` option, the migration generator will include it when generating migrations.
""",
examples: [
"""
check_constraint :price, "price_must_be_positive", check: "price > 0", message: "price must be positive"
"""
],
args: [:attribute, :name],
target: AshPostgres.CheckConstraint,
schema: AshPostgres.CheckConstraint.schema()
}
@check_constraints %Ash.Dsl.Section{
name: :check_constraints,
describe: """
A section for configuring the check constraints for a given table.
This can be used to automatically create those check constraints, or just to provide message when they are raised
""",
examples: [
"""
check_constraints do
check_constraint :price, "price_must_be_positive", check: "price > 0", message: "price must be positive"
end
"""
],
entities: [@check_constraint]
}
@references %Ash.Dsl.Section{
name: :references,
describe: """
A section for configuring the references (foreign keys) in resource migrations.
This section is only relevant if you are using the migration generator with this resource.
Otherwise, it has no effect.
""",
examples: [
"""
references do
reference :post, on_delete: :delete, on_update: :update, name: "comments_to_posts_fkey"
end
"""
],
entities: [@reference],
schema: [
polymorphic_on_delete: [
type: {:one_of, [:delete, :nilify, :nothing, :restrict]},
doc:
"For polymorphic resources, configures the on_delete behavior of the automatically generated foreign keys to source tables."
],
polymorphic_on_update: [
type: {:one_of, [:update, :nilify, :nothing, :restrict]},
doc:
"For polymorphic resources, configures the on_update behavior of the automatically generated foreign keys to source tables."
],
polymorphic_name: [
type: {:one_of, [:update, :nilify, :nothing, :restrict]},
doc:
"For polymorphic resources, configures the on_update behavior of the automatically generated foreign keys to source tables."
]
]
}
@postgres %Ash.Dsl.Section{
name: :postgres,
describe: """
Postgres data layer configuration
""",
sections: [
@manage_tenant,
@references,
@check_constraints
],
modules: [
:repo
],
examples: [
"""
postgres do
repo MyApp.Repo
table "organizations"
end
"""
],
schema: [
repo: [
type: :atom,
required: true,
doc:
"The repo that will be used to fetch your data. See the `AshPostgres.Repo` documentation for more"
],
migrate?: [
type: :boolean,
default: true,
doc:
"Whether or not to include this resource in the generated migrations with `mix ash.generate_migrations`"
],
base_filter_sql: [
type: :string,
doc:
"A raw sql version of the base_filter, e.g `representative = true`. Required if trying to create a unique constraint on a resource with a base_filter"
],
skip_unique_indexes: [
type: {:custom, __MODULE__, :validate_skip_unique_indexes, []},
default: false,
doc: "Skip generating unique indexes when generating migrations"
],
unique_index_names: [
type: :any,
default: [],
doc: """
A list of unique index names that could raise errors, or an mfa to a function that takes a changeset
and returns the list. Must be in the format `{[:affected, :keys], "name_of_constraint"}` or `{[:affected, :keys], "name_of_constraint", "custom error message"}`
Note that this is *not* used to rename the unique indexes created from `identities`.
Use `identity_index_names` for that. This is used to tell ash_postgres about unique indexes that
exist in the database that it didn't create.
"""
],
identity_index_names: [
type: :any,
default: [],
doc: """
A keyword list of identity names to the unique index name that they should use when being managed by the migration
generator.
"""
],
foreign_key_names: [
type: :any,
default: [],
doc: """
A list of foreign keys that could raise errors, or an mfa to a function that takes a changeset and returns the list.
Must be in the format `{:key, "name_of_constraint"}` or `{:key, "name_of_constraint", "custom error message"}`
"""
],
table: [
type: :string,
doc:
"The table to store and read the resource from. Required unless `polymorphic?` is true."
],
polymorphic?: [
type: :boolean,
default: false,
doc: """
Declares this resource as polymorphic.
Polymorphic resources cannot be read or updated unless the table is provided in the query/changeset context.
For example:
PolymorphicResource
|> Ash.Query.set_context(%{data_layer: %{table: "table"}})
|> MyApi.read!()
When relating to polymorphic resources, you'll need to use the `context` option on relationships,
e.g
belongs_to :polymorphic_association, PolymorphicResource,
context: %{data_layer: %{table: "table"}}
"""
]
]
}
alias Ash.Filter
alias Ash.Query.{BooleanExpression, Not, Ref}
alias Ash.Query.Function.{Ago, Contains}
alias Ash.Query.Operator.IsNil
alias AshPostgres.Functions.{Fragment, TrigramSimilarity, Type}
import AshPostgres, only: [repo: 1]
@behaviour Ash.DataLayer
@sections [@postgres]
@moduledoc """
A postgres data layer that levereges Ecto's postgres capabilities.
# Table of Contents
#{Ash.Dsl.Extension.doc_index(@sections)}
#{Ash.Dsl.Extension.doc(@sections)}
"""
use Ash.Dsl.Extension,
sections: @sections,
transformers: [
AshPostgres.Transformers.VerifyRepo,
AshPostgres.Transformers.EnsureTableOrPolymorphic
]
@doc false
def tenant_template(value) do
value = List.wrap(value)
if Enum.all?(value, &(is_binary(&1) || is_atom(&1))) do
{:ok, value}
else
{:error, "Expected all values for `manages_tenant` to be strings or atoms"}
end
end
@doc false
def validate_skip_unique_indexes(indexes) do
indexes = List.wrap(indexes)
if Enum.all?(indexes, &is_atom/1) do
{:ok, indexes}
else
{:error, "All indexes to skip must be atoms"}
end
end
import Ecto.Query, only: [from: 2, subquery: 1]
@impl true
def can?(_, :async_engine), do: true
def can?(_, :transact), do: true
def can?(_, :composite_primary_key), do: true
def can?(_, :upsert), do: true
def can?(resource, {:join, other_resource}) do
data_layer = Ash.DataLayer.data_layer(resource)
other_data_layer = Ash.DataLayer.data_layer(other_resource)
data_layer == other_data_layer and repo(data_layer) == repo(other_data_layer)
end
def can?(resource, {:lateral_join, other_resource}) do
data_layer = Ash.DataLayer.data_layer(resource)
other_data_layer = Ash.DataLayer.data_layer(other_resource)
data_layer == other_data_layer and repo(data_layer) == repo(other_data_layer)
end
def can?(_, :boolean_filter), do: true
def can?(_, {:aggregate, :count}), do: true
def can?(_, {:aggregate, :sum}), do: true
def can?(_, :aggregate_filter), do: true
def can?(_, :aggregate_sort), do: true
def can?(_, :create), do: true
def can?(_, :select), do: true
def can?(_, :read), do: true
def can?(_, :update), do: true
def can?(_, :destroy), do: true
def can?(_, :filter), do: true
def can?(_, :limit), do: true
def can?(_, :offset), do: true
def can?(_, :multitenancy), do: true
def can?(_, {:filter_expr, _}), do: true
def can?(_, :nested_expressions), do: true
def can?(_, {:query_aggregate, :count}), do: true
def can?(_, :sort), do: true
def can?(_, :distinct), do: true
def can?(_, {:sort, _}), do: true
def can?(_, _), do: false
@impl true
def in_transaction?(resource) do
repo(resource).in_transaction?()
end
@impl true
def limit(query, nil, _), do: {:ok, query}
def limit(query, limit, _resource) do
{:ok, from(row in query, limit: ^limit)}
end
@impl true
def source(resource) do
AshPostgres.table(resource) || ""
end
@impl true
def set_context(resource, data_layer_query, context) do
if context[:data_layer][:table] do
{:ok,
%{
data_layer_query
| from: %{data_layer_query.from | source: {context[:data_layer][:table], resource}}
}}
else
{:ok, data_layer_query}
end
end
@impl true
def offset(query, nil, _), do: query
def offset(%{offset: old_offset} = query, 0, _resource) when old_offset in [0, nil] do
{:ok, query}
end
def offset(query, offset, _resource) do
{:ok, from(row in query, offset: ^offset)}
end
@impl true
def run_query(query, resource) do
if AshPostgres.polymorphic?(resource) && no_table?(query) do
raise_table_error!(resource, :read)
else
{:ok, repo(resource).all(query, repo_opts(query))}
end
end
defp no_table?(%{from: %{source: {"", _}}}), do: true
defp no_table?(_), do: false
defp repo_opts(%Ash.Changeset{tenant: tenant, resource: resource}) do
repo_opts(%{tenant: tenant, resource: resource})
end
defp repo_opts(%{tenant: tenant, resource: resource}) when not is_nil(tenant) do
if Ash.Resource.Info.multitenancy_strategy(resource) == :context do
[prefix: tenant]
else
[]
end
end
defp repo_opts(_), do: []
@impl true
def functions(resource) do
config = repo(resource).config()
functions = [AshPostgres.Functions.Type, AshPostgres.Functions.Fragment]
if "pg_trgm" in (config[:installed_extensions] || []) do
functions ++
[
AshPostgres.Functions.TrigramSimilarity
]
else
functions
end
end
@impl true
def run_aggregate_query(query, aggregates, resource) do
subquery = from(row in subquery(query), select: %{})
query =
Enum.reduce(
aggregates,
subquery,
&add_subquery_aggregate_select(&2, &1, resource)
)
{:ok, repo(resource).one(query, repo_opts(query))}
end
@impl true
def set_tenant(_resource, query, tenant) do
{:ok, Ecto.Query.put_query_prefix(query, to_string(tenant))}
end
@impl true
def run_aggregate_query_with_lateral_join(
query,
aggregates,
root_data,
source_resource,
destination_resource,
source_field,
destination_field
) do
lateral_join_query =
lateral_join_query(
query,
root_data,
source_resource,
source_field,
destination_field
)
subquery = from(row in subquery(lateral_join_query), select: %{})
query =
Enum.reduce(
aggregates,
subquery,
&add_subquery_aggregate_select(&2, &1, destination_resource)
)
{:ok, repo(source_resource).one(query, repo_opts(:query))}
end
@impl true
def run_query_with_lateral_join(
query,
root_data,
source_resource,
_destination_resource,
source_field,
destination_field
) do
query =
lateral_join_query(
query,
root_data,
source_resource,
source_field,
destination_field
)
{:ok, repo(source_resource).all(query, repo_opts(query))}
end
defp lateral_join_query(
query,
root_data,
source_resource,
source_field,
destination_field
) do
source_values = Enum.map(root_data, &Map.get(&1, source_field))
subquery =
subquery(
from(destination in query,
where:
field(destination, ^destination_field) ==
field(parent_as(:source_record), ^source_field)
)
)
source_resource
|> Ash.Query.new()
|> Ash.Query.data_layer_query()
|> case do
{:ok, data_layer_query} ->
from(source in data_layer_query,
as: :source_record,
where: field(source, ^source_field) in ^source_values,
inner_lateral_join: destination in ^subquery,
on: field(source, ^source_field) == field(destination, ^destination_field),
select: destination
)
{:error, error} ->
{:error, error}
end
end
@impl true
def resource_to_query(resource, _),
do: Ecto.Queryable.to_query({AshPostgres.table(resource) || "", resource})
@impl true
def create(resource, changeset) do
changeset.data
|> Map.update!(:__meta__, &Map.put(&1, :source, table(resource, changeset)))
|> ecto_changeset(changeset, :create)
|> repo(resource).insert(repo_opts(changeset))
|> handle_errors()
|> case do
{:ok, result} ->
maybe_create_tenant!(resource, result)
{:ok, result}
{:error, error} ->
{:error, error}
end
end
defp maybe_create_tenant!(resource, result) do
if AshPostgres.manage_tenant_create?(resource) do
tenant_name = tenant_name(resource, result)
AshPostgres.MultiTenancy.create_tenant!(tenant_name, repo(resource))
else
:ok
end
end
defp maybe_update_tenant(resource, changeset, result) do
if AshPostgres.manage_tenant_update?(resource) do
changing_tenant_name? =
resource
|> AshPostgres.manage_tenant_template()
|> Enum.filter(&is_atom/1)
|> Enum.any?(&Ash.Changeset.changing_attribute?(changeset, &1))
if changing_tenant_name? do
old_tenant_name = tenant_name(resource, changeset.data)
new_tenant_name = tenant_name(resource, result)
AshPostgres.MultiTenancy.rename_tenant(repo(resource), old_tenant_name, new_tenant_name)
end
end
:ok
end
defp tenant_name(resource, result) do
resource
|> AshPostgres.manage_tenant_template()
|> Enum.map_join(fn item ->
if is_binary(item) do
item
else
result
|> Map.get(item)
|> to_string()
end
end)
end
defp handle_errors({:error, %Ecto.Changeset{errors: errors}}) do
{:error, Enum.map(errors, &to_ash_error/1)}
end
defp handle_errors({:ok, val}), do: {:ok, val}
defp to_ash_error({field, {message, vars}}) do
Ash.Error.Changes.InvalidAttribute.exception(field: field, message: message, vars: vars)
end
defp ecto_changeset(record, changeset, type) do
ecto_changeset =
record
|> set_table(changeset, type)
|> Ecto.Changeset.change(changeset.attributes)
|> add_configured_foreign_key_constraints(record.__struct__)
|> add_unique_indexes(record.__struct__, changeset)
|> add_check_constraints(record.__struct__)
case type do
:create ->
ecto_changeset
|> add_my_foreign_key_constraints(record.__struct__)
type when type in [:upsert, :update] ->
ecto_changeset
|> add_my_foreign_key_constraints(record.__struct__)
|> add_related_foreign_key_constraints(record.__struct__)
:delete ->
ecto_changeset
|> add_related_foreign_key_constraints(record.__struct__)
end
end
defp set_table(record, changeset, operation) do
if AshPostgres.polymorphic?(record.__struct__) do
table = changeset.context[:data_layer][:table] || AshPostgres.table(record.__struct)
if table do
Ecto.put_meta(record, source: table)
else
raise_table_error!(changeset.resource, operation)
end
else
record
end
end
defp add_check_constraints(changeset, resource) do
resource
|> AshPostgres.check_constraints()
|> Enum.reduce(changeset, fn constraint, changeset ->
constraint.attribute
|> List.wrap()
|> Enum.reduce(changeset, fn attribute, changeset ->
Ecto.Changeset.check_constraint(changeset, attribute,
name: constraint.name,
message: constraint.message || "is invalid"
)
end)
end)
end
defp add_related_foreign_key_constraints(changeset, resource) do
# TODO: this doesn't guarantee us to get all of them, because if something is related to this
# schema and there is no back-relation, then this won't catch it's foreign key constraints
resource
|> Ash.Resource.Info.relationships()
|> Enum.map(& &1.destination)
|> Enum.uniq()
|> Enum.flat_map(fn related ->
related
|> Ash.Resource.Info.relationships()
|> Enum.filter(&(&1.destination == resource))
|> Enum.map(&Map.take(&1, [:source, :source_field, :destination_field]))
end)
|> Enum.uniq()
|> Enum.reduce(changeset, fn %{
source: source,
source_field: source_field,
destination_field: destination_field
},
changeset ->
Ecto.Changeset.foreign_key_constraint(changeset, destination_field,
name: "#{AshPostgres.table(source)}_#{source_field}_fkey",
message: "would leave records behind"
)
end)
end
defp add_my_foreign_key_constraints(changeset, resource) do
resource
|> Ash.Resource.Info.relationships()
|> Enum.reduce(changeset, &Ecto.Changeset.foreign_key_constraint(&2, &1.source_field))
end
defp add_configured_foreign_key_constraints(changeset, resource) do
resource
|> AshPostgres.foreign_key_names()
|> case do
{m, f, a} -> List.wrap(apply(m, f, [changeset | a]))
value -> List.wrap(value)
end
|> Enum.reduce(changeset, fn
{key, name}, changeset ->
Ecto.Changeset.foreign_key_constraint(changeset, key, name: name)
{key, name, message}, changeset ->
Ecto.Changeset.foreign_key_constraint(changeset, key, name: name, message: message)
end)
end
defp add_unique_indexes(changeset, resource, ash_changeset) do
changeset =
resource
|> Ash.Resource.Info.identities()
|> Enum.reduce(changeset, fn identity, changeset ->
name =
AshPostgres.identity_index_names(resource)[identity.name] ||
"#{table(resource, ash_changeset)}_#{identity.name}_index"
opts =
if Map.get(identity, :message) do
[name: name, message: identity.message]
else
[name: name]
end
Ecto.Changeset.unique_constraint(changeset, identity.keys, opts)
end)
names =
resource
|> AshPostgres.unique_index_names()
|> case do
{m, f, a} -> List.wrap(apply(m, f, [changeset | a]))
value -> List.wrap(value)
end
names = [
{Ash.Resource.Info.primary_key(resource), table(resource, ash_changeset) <> "_pkey"} | names
]
Enum.reduce(names, changeset, fn
{keys, name}, changeset ->
Ecto.Changeset.unique_constraint(changeset, List.wrap(keys), name: name)
{keys, name, message}, changeset ->
Ecto.Changeset.unique_constraint(changeset, List.wrap(keys), name: name, message: message)
end)
end
@impl true
def upsert(resource, changeset) do
repo_opts =
changeset
|> repo_opts()
|> Keyword.put(:on_conflict, {:replace, Map.keys(changeset.attributes)})
|> Keyword.put(:conflict_target, Ash.Resource.Info.primary_key(resource))
if AshPostgres.manage_tenant_update?(resource) do
{:error, "Cannot currently upsert a resource that owns a tenant"}
else
changeset.data
|> Map.update!(:__meta__, &Map.put(&1, :source, table(resource, changeset)))
|> ecto_changeset(changeset, :upsert)
|> repo(resource).insert(repo_opts)
|> handle_errors()
end
end
@impl true
def update(resource, changeset) do
changeset.data
|> Map.update!(:__meta__, &Map.put(&1, :source, table(resource, changeset)))
|> ecto_changeset(changeset, :update)
|> repo(resource).update(repo_opts(changeset))
|> handle_errors()
|> case do
{:ok, result} ->
maybe_update_tenant(resource, changeset, result)
{:ok, result}
{:error, error} ->
{:error, error}
end
end
@impl true
def destroy(resource, %{data: record} = changeset) do
record
|> ecto_changeset(changeset, :delete)
|> repo(resource).delete(repo_opts(changeset))
|> case do
{:ok, _record} ->
:ok
{:error, error} ->
handle_errors({:error, error})
end
end
@impl true
def sort(query, sort, resource) do
query = default_bindings(query, resource)
sort
|> sanitize_sort()
|> Enum.reduce({:ok, query}, fn {order, sort}, {:ok, query} ->
binding =
case Map.fetch(query.__ash_bindings__.aggregates, sort) do
{:ok, binding} ->
binding
:error ->
0
end
new_query =
Map.update!(query, :order_bys, fn order_bys ->
order_bys = order_bys || []
sort_expr = %Ecto.Query.QueryExpr{
expr: [
{order, {{:., [], [{:&, [], [binding]}, sort]}, [], []}}
]
}
order_bys ++ [sort_expr]
end)
{:ok, new_query}
end)
end
@impl true
def select(query, select, resource) do
query = default_bindings(query, resource)
{:ok,
from(row in query,
select: struct(row, ^select)
)}
end
@impl true
def distinct(query, distinct_on, resource) do
query = default_bindings(query, resource)
query =
query
|> default_bindings(resource)
|> Map.update!(:distinct, fn distinct ->
distinct =
distinct ||
%Ecto.Query.QueryExpr{
expr: []
}
expr =
Enum.map(distinct_on, fn distinct_on_field ->
binding =
case Map.fetch(query.__ash_bindings__.aggregates, distinct_on_field) do
{:ok, binding} ->
binding
:error ->
0
end
{:asc, {{:., [], [{:&, [], [binding]}, distinct_on_field]}, [], []}}
end)
%{distinct | expr: distinct.expr ++ expr}
end)
{:ok, query}
end
defp sanitize_sort(sort) do
sort
|> List.wrap()
|> Enum.map(fn
{sort, :asc_nils_last} -> {:asc_nulls_last, sort}
{sort, :asc_nils_first} -> {:asc_nulls_first, sort}
{sort, :desc_nils_last} -> {:desc_nulls_last, sort}
{sort, :desc_nils_first} -> {:desc_nulls_first, sort}
{sort, order} -> {order, sort}
sort -> sort
end)
end
@impl true
def filter(query, %{expression: false}, _resource) do
impossible_query = from(row in query, where: false)
{:ok, Map.put(impossible_query, :__impossible__, true)}
end
def filter(query, filter, _resource) do
relationship_paths =
filter
|> Filter.relationship_paths()
|> Enum.map(fn path ->
if can_inner_join?(path, filter) do
{:inner, relationship_path_to_relationships(filter.resource, path)}
else
{:left, relationship_path_to_relationships(filter.resource, path)}
end
end)
new_query =
query
|> join_all_relationships(relationship_paths)
|> add_filter_expression(filter)
{:ok, new_query}
end
defp default_bindings(query, resource) do
Map.put_new(query, :__ash_bindings__, %{
current: Enum.count(query.joins) + 1,
aggregates: %{},
bindings: %{0 => %{path: [], type: :root, source: resource}}
})
end
@known_inner_join_operators [
Eq,
GreaterThan,
GreaterThanOrEqual,
In,
LessThanOrEqual,
LessThan,
NotEq
]
|> Enum.map(&Module.concat(Ash.Query.Operator, &1))
@known_inner_join_functions [
Ago,
Contains
]
|> Enum.map(&Module.concat(Ash.Query.Function, &1))
@known_inner_join_predicates @known_inner_join_functions ++ @known_inner_join_operators
# For consistency's sake, this logic was removed.
# We can revisit it sometime though.
defp can_inner_join?(path, expr, seen_an_or? \\ false)
defp can_inner_join?(path, %{expression: expr}, seen_an_or?),
do: can_inner_join?(path, expr, seen_an_or?)
defp can_inner_join?(_path, expr, _seen_an_or?) when expr in [nil, true, false], do: true
defp can_inner_join?(path, %BooleanExpression{op: :and, left: left, right: right}, seen_an_or?) do
can_inner_join?(path, left, seen_an_or?) || can_inner_join?(path, right, seen_an_or?)
end
defp can_inner_join?(path, %BooleanExpression{op: :or, left: left, right: right}, _) do
can_inner_join?(path, left, true) && can_inner_join?(path, right, true)
end
defp can_inner_join?(
_,
%Not{},
_
) do
false
end
defp can_inner_join?(
search_path,
%struct{__operator__?: true, left: %Ref{relationship_path: relationship_path}},
seen_an_or?
)
when search_path == relationship_path and struct in @known_inner_join_predicates do
not seen_an_or?
end
defp can_inner_join?(
search_path,
%struct{__operator__?: true, right: %Ref{relationship_path: relationship_path}},
seen_an_or?
)
when search_path == relationship_path and struct in @known_inner_join_predicates do
not seen_an_or?
end
defp can_inner_join?(
search_path,
%struct{__function__?: true, arguments: arguments},
seen_an_or?
)
when struct in @known_inner_join_predicates do
if Enum.any?(arguments, &match?(%Ref{relationship_path: ^search_path}, &1)) do
not seen_an_or?
else
true
end
end
defp can_inner_join?(_, _, _), do: false
@impl true
def add_aggregate(query, aggregate, _resource) do
resource = aggregate.resource
query = default_bindings(query, resource)
{query, binding} =
case get_binding(resource, aggregate.relationship_path, query, :aggregate) do
nil ->
relationship = Ash.Resource.Info.relationship(resource, aggregate.relationship_path)
subquery = aggregate_subquery(relationship, aggregate)
new_query =
join_all_relationships(
query,
[
{{:aggregate, aggregate.name, subquery},
relationship_path_to_relationships(resource, aggregate.relationship_path)}
]
)
{new_query, get_binding(resource, aggregate.relationship_path, new_query, :aggregate)}
binding ->
{query, binding}
end
query_with_aggregate_binding =
put_in(
query.__ash_bindings__.aggregates,
Map.put(query.__ash_bindings__.aggregates, aggregate.name, binding)
)
new_query =
query_with_aggregate_binding
|> add_aggregate_to_subquery(resource, aggregate, binding)
|> select_aggregate(resource, aggregate)
{:ok, new_query}
end
defp select_aggregate(query, resource, aggregate) do
binding = get_binding(resource, aggregate.relationship_path, query, :aggregate)
query =
if query.select do
query
else
from(row in query,
select: row,
select_merge: %{aggregates: %{}}
)
end
%{query | select: add_to_select(query.select, binding, aggregate)}
end
defp add_to_select(
%{expr: {:merge, _, [first, {:%{}, _, [{:aggregates, {:%{}, [], fields}}]}]}} = select,
binding,
%{load: nil} = aggregate
) do
accessed = {{:., [], [{:&, [], [binding]}, aggregate.name]}, [], []}
field =
{:type, [],
[
accessed,
Ash.Type.ecto_type(aggregate.type)
]}
field_with_default =
if is_nil(aggregate.default_value) do
field
else
{:coalesce, [],
[
field,
{:type, [],
[
aggregate.default_value,
Ash.Type.ecto_type(aggregate.type)
]}
]}
end
new_fields = [
{aggregate.name, field_with_default}
| fields
]
%{select | expr: {:merge, [], [first, {:%{}, [], [{:aggregates, {:%{}, [], new_fields}}]}]}}
end
defp add_to_select(
%{expr: expr} = select,
binding,
%{load: load_as} = aggregate
) do
accessed = {{:., [], [{:&, [], [binding]}, aggregate.name]}, [], []}
field =
{:type, [],
[
accessed,
Ash.Type.ecto_type(aggregate.type)
]}
field_with_default =
if is_nil(aggregate.default_value) do
field
else
{:coalesce, [],
[
field,
{:type, [],
[
aggregate.default_value,
Ash.Type.ecto_type(aggregate.type)
]}
]}
end
%{select | expr: {:merge, [], [expr, {:%{}, [], [{load_as, field_with_default}]}]}}
end
defp add_aggregate_to_subquery(query, resource, aggregate, binding) do
new_joins =
List.update_at(query.joins, binding - 1, fn join ->
aggregate_query =
if aggregate.authorization_filter do
{:ok, filter} =
filter(
join.source.from.source.query,
aggregate.authorization_filter,
Ash.Resource.Info.related(resource, aggregate.relationship_path)
)
filter
else
join.source.from.source.query
end
new_aggregate_query = add_subquery_aggregate_select(aggregate_query, aggregate, resource)
put_in(join.source.from.source.query, new_aggregate_query)
end)
%{
query
| joins: new_joins
}
end
defp aggregate_subquery(relationship, aggregate) do
query =
from(row in relationship.destination,
group_by: ^relationship.destination_field,
select: field(row, ^relationship.destination_field)
)
if aggregate.query && aggregate.query.tenant do
Ecto.Query.put_query_prefix(query, aggregate.query.tenant)
else
query
end
end
defp order_to_postgres_order(dir) do
case dir do
:asc -> nil
:asc_nils_last -> " ASC NULLS LAST"
:asc_nils_first -> " ASC NULLS FIRST"
:desc -> " DESC"
:desc_nils_last -> " DESC NULLS LAST"
:desc_nils_first -> " DESC NULLS FIRST"
end
end
defp add_subquery_aggregate_select(query, %{kind: kind} = aggregate, _resource)
when kind in [:first, :list] do
query = default_bindings(query, aggregate.resource)
key = aggregate.field
type = Ash.Type.ecto_type(aggregate.type)
field =
if aggregate.query && aggregate.query.sort && aggregate.query.sort != [] do
sort_expr =
aggregate.query.sort
|> Enum.map(fn {sort, order} ->
case order_to_postgres_order(order) do
nil ->
[expr: {{:., [], [{:&, [], [0]}, sort]}, [], []}]
order ->
[expr: {{:., [], [{:&, [], [0]}, sort]}, [], []}, raw: order]
end
end)
|> Enum.intersperse(raw: ", ")
|> List.flatten()
{:fragment, [],
[
raw: "array_agg(",
expr: {{:., [], [{:&, [], [0]}, key]}, [], []},
raw: " ORDER BY "
] ++
sort_expr ++ [raw: ")"]}
else
{:fragment, [],
[
raw: "array_agg(",
expr: {{:., [], [{:&, [], [0]}, key]}, [], []},
raw: ")"
]}
end
{params, filtered} =
if aggregate.query && aggregate.query.filter &&
not match?(%Ash.Filter{expression: nil}, aggregate.query.filter) do
{params, expr} =
filter_to_expr(
aggregate.query.filter,
query.__ash_bindings__.bindings,
query.select.params
)
{params, {:filter, [], [field, expr]}}
else
{[], field}
end
casted =
if kind == :first do
{:type, [],
[
{:fragment, [],
[
raw: "(",
expr: filtered,
raw: ")[1]"
]},
type
]}
else
{:type, [],
[
filtered,
{:array, type}
]}
end
new_expr = {:merge, [], [query.select.expr, {:%{}, [], [{aggregate.name, casted}]}]}
%{query | select: %{query.select | expr: new_expr, params: params}}
end
defp add_subquery_aggregate_select(query, %{kind: :list} = aggregate, _resource) do
query = default_bindings(query, aggregate.resource)
key = aggregate.field
type = Ash.Type.ecto_type(aggregate.type)
field =
if aggregate.query && aggregate.query.sort && aggregate.query.sort != [] do
sort_expr =
aggregate.query.sort
|> Enum.map(fn {sort, order} ->
case order_to_postgres_order(order) do
nil ->
[expr: {{:., [], [{:&, [], [0]}, sort]}, [], []}]
order ->
[expr: {{:., [], [{:&, [], [0]}, sort]}, [], []}, raw: order]
end
end)
|> Enum.intersperse(raw: ", ")
|> List.flatten()
{:fragment, [],
[
raw: "array_agg(",
expr: {{:., [], [{:&, [], [0]}, key]}, [], []},
raw: " ORDER BY "
] ++
sort_expr ++ [raw: ")"]}
else
{:fragment, [],
[
raw: "array_agg(",
expr: {{:., [], [{:&, [], [0]}, key]}, [], []},
raw: ")"
]}
end
{params, filtered} =
if aggregate.query && aggregate.query.filter &&
not match?(%Ash.Filter{expression: nil}, aggregate.query.filter) do
{params, expr} =
filter_to_expr(
aggregate.query.filter,
query.__ash_bindings__.bindings,
query.select.params
)
{params, {:filter, [], [field, expr]}}
else
{[], field}
end
cast = {:type, [], [filtered, {:array, type}]}
new_expr = {:merge, [], [query.select.expr, {:%{}, [], [{aggregate.name, cast}]}]}
%{query | select: %{query.select | expr: new_expr, params: params}}
end
defp add_subquery_aggregate_select(query, %{kind: kind} = aggregate, resource)
when kind in [:count, :sum] do
query = default_bindings(query, aggregate.resource)
key = aggregate.field || List.first(Ash.Resource.Info.primary_key(resource))
type = Ash.Type.ecto_type(aggregate.type)
field = {kind, [], [{{:., [], [{:&, [], [0]}, key]}, [], []}]}
{params, filtered} =
if aggregate.query && aggregate.query.filter &&
not match?(%Ash.Filter{expression: nil}, aggregate.query.filter) do
{params, expr} =
filter_to_expr(
aggregate.query.filter,
query.__ash_bindings__.bindings,
query.select.params
)
{params, {:filter, [], [field, expr]}}
else
{[], field}
end
cast = {:type, [], [filtered, type]}
new_expr = {:merge, [], [query.select.expr, {:%{}, [], [{aggregate.name, cast}]}]}
%{query | select: %{query.select | expr: new_expr, params: params}}
end
defp relationship_path_to_relationships(resource, path, acc \\ [])
defp relationship_path_to_relationships(_resource, [], acc), do: Enum.reverse(acc)
defp relationship_path_to_relationships(resource, [relationship | rest], acc) do
relationship = Ash.Resource.Info.relationship(resource, relationship)
relationship_path_to_relationships(relationship.destination, rest, [relationship | acc])
end
defp join_all_relationships(query, relationship_paths, path \\ [], source \\ nil) do
query = default_bindings(query, source)
Enum.reduce(relationship_paths, query, fn
{_join_type, []}, query ->
query
{join_type, [relationship | rest_rels]}, query ->
source = source || relationship.source
current_path = path ++ [relationship]
current_join_type =
case join_type do
{:aggregate, _name, _agg} when rest_rels != [] ->
:left
other ->
other
end
if has_binding?(source, Enum.reverse(current_path), query, current_join_type) do
query
else
joined_query =
join_relationship(
query,
relationship,
Enum.map(path, & &1.name),
current_join_type,
source
)
joined_query_with_distinct = add_distinct(relationship, join_type, joined_query)
join_all_relationships(
joined_query_with_distinct,
[{join_type, rest_rels}],
current_path,
source
)
end
end)
end
defp has_binding?(resource, path, query, {:aggregate, _, _}),
do: has_binding?(resource, path, query, :aggregate)
defp has_binding?(resource, candidate_path, %{__ash_bindings__: _} = query, type) do
Enum.any?(query.__ash_bindings__.bindings, fn
{_, %{path: path, source: source, type: ^type}} ->
Ash.SatSolver.synonymous_relationship_paths?(resource, path, candidate_path, source)
_ ->
false
end)
end
defp has_binding?(_, _, _, _), do: false
defp get_binding(resource, path, %{__ash_bindings__: _} = query, type) do
paths =
Enum.flat_map(query.__ash_bindings__.bindings, fn
{binding, %{path: path, type: ^type}} ->
[{binding, path}]
_ ->
[]
end)
Enum.find_value(paths, fn {binding, candidate_path} ->
Ash.SatSolver.synonymous_relationship_paths?(resource, candidate_path, path) && binding
end)
end
defp get_binding(_, _, _, _), do: nil
defp add_distinct(relationship, join_type, joined_query) do
if relationship.cardinality == :many and join_type == :left && !joined_query.distinct do
from(row in joined_query,
distinct: ^Ash.Resource.Info.primary_key(relationship.destination)
)
else
joined_query
end
end
defp join_relationship(query, relationship, path, join_type, source) do
case Map.get(query.__ash_bindings__.bindings, path) do
%{type: existing_join_type} when join_type != existing_join_type ->
raise "unreachable?"
nil ->
do_join_relationship(query, relationship, path, join_type, source)
_ ->
query
end
end
defp do_join_relationship(query, %{type: :many_to_many} = relationship, path, kind, source) do
relationship_through = maybe_get_resource_query(relationship.through)
relationship_destination =
Ecto.Queryable.to_query(maybe_get_resource_query(relationship.destination))
current_binding =
Enum.find_value(query.__ash_bindings__.bindings, 0, fn {binding, data} ->
if data.type == kind && data.path == Enum.reverse(path) do
binding
end
end)
new_query =
case kind do
{:aggregate, _, subquery} ->
subquery =
subquery(
from(destination in subquery,
where:
field(destination, ^relationship.destination_field) ==
field(
parent_as(:rel_through),
^relationship.destination_field_on_join_table
)
)
)
from([{row, current_binding}] in query,
left_join: through in ^relationship_through,
as: :rel_through,
on:
field(row, ^relationship.source_field) ==
field(through, ^relationship.source_field_on_join_table),
left_lateral_join: destination in ^subquery,
on:
field(destination, ^relationship.destination_field) ==
field(through, ^relationship.destination_field_on_join_table)
)
:inner ->
from([{row, current_binding}] in query,
join: through in ^relationship_through,
on:
field(row, ^relationship.source_field) ==
field(through, ^relationship.source_field_on_join_table),
join: destination in ^relationship_destination,
on:
field(destination, ^relationship.destination_field) ==
field(through, ^relationship.destination_field_on_join_table)
)
_ ->
from([{row, current_binding}] in query,
left_join: through in ^relationship_through,
on:
field(row, ^relationship.source_field) ==
field(through, ^relationship.source_field_on_join_table),
left_join: destination in ^relationship_destination,
on:
field(destination, ^relationship.destination_field) ==
field(through, ^relationship.destination_field_on_join_table)
)
end
join_path =
Enum.reverse([String.to_existing_atom(to_string(relationship.name) <> "_join_assoc") | path])
full_path = Enum.reverse([relationship.name | path])
binding_data =
case kind do
{:aggregate, name, _agg} ->
%{type: :aggregate, name: name, path: full_path, source: source}
_ ->
%{type: kind, path: full_path, source: source}
end
new_query
|> add_binding(%{path: join_path, type: :left, source: source})
|> add_binding(binding_data)
end
defp do_join_relationship(query, relationship, path, kind, source) do
relationship_destination =
Ecto.Queryable.to_query(maybe_get_resource_query(relationship.destination))
current_binding =
Enum.find_value(query.__ash_bindings__.bindings, 0, fn {binding, data} ->
if data.type == kind && data.path == Enum.reverse(path) do
binding
end
end)
new_query =
case kind do
{:aggregate, _, subquery} ->
subquery =
from(
sub in subquery(
from(destination in subquery,
where:
field(destination, ^relationship.destination_field) ==
field(parent_as(:rel_source), ^relationship.source_field)
)
),
select: field(sub, ^relationship.destination_field)
)
from([{row, current_binding}] in query,
as: :rel_source,
left_lateral_join: destination in ^subquery,
on:
field(row, ^relationship.source_field) ==
field(destination, ^relationship.destination_field)
)
:inner ->
from([{row, current_binding}] in query,
join: destination in ^relationship_destination,
on:
field(row, ^relationship.source_field) ==
field(destination, ^relationship.destination_field)
)
_ ->
from([{row, current_binding}] in query,
left_join: destination in ^relationship_destination,
on:
field(row, ^relationship.source_field) ==
field(destination, ^relationship.destination_field)
)
end
full_path = Enum.reverse([relationship.name | path])
binding_data =
case kind do
{:aggregate, name, _agg} ->
%{type: :aggregate, name: name, path: full_path, source: source}
_ ->
%{type: kind, path: full_path, source: source}
end
new_query
|> add_binding(binding_data)
end
defp add_filter_expression(query, filter) do
wheres =
filter
|> split_and_statements()
|> Enum.map(fn filter ->
{params, expr} = filter_to_expr(filter, query.__ash_bindings__.bindings, [])
%Ecto.Query.BooleanExpr{
expr: expr,
op: :and,
params: params
}
end)
%{query | wheres: query.wheres ++ wheres}
end
defp split_and_statements(%Filter{expression: expression}) do
split_and_statements(expression)
end
defp split_and_statements(%BooleanExpression{op: :and, left: left, right: right}) do
split_and_statements(left) ++ split_and_statements(right)
end
defp split_and_statements(%Not{expression: %Not{expression: expression}}) do
split_and_statements(expression)
end
defp split_and_statements(%Not{
expression: %BooleanExpression{op: :or, left: left, right: right}
}) do
split_and_statements(%BooleanExpression{
op: :and,
left: %Not{expression: left},
right: %Not{expression: right}
})
end
defp split_and_statements(other), do: [other]
defp filter_to_expr(expr, bindings, params, embedded? \\ false, type \\ nil)
defp filter_to_expr(%Filter{expression: expression}, bindings, params, embedded?, type) do
filter_to_expr(expression, bindings, params, embedded?, type)
end
# A nil filter means "everything"
defp filter_to_expr(nil, _, _, _, _), do: {[], true}
# A true filter means "everything"
defp filter_to_expr(true, _, _, _, _), do: {[], true}
# A false filter means "nothing"
defp filter_to_expr(false, _, _, _, _), do: {[], false}
defp filter_to_expr(expression, bindings, params, embedded?, type) do
do_filter_to_expr(expression, bindings, params, embedded?, type)
end
defp do_filter_to_expr(expr, bindings, params, embedded?, type \\ nil)
defp do_filter_to_expr(
%BooleanExpression{op: op, left: left, right: right},
bindings,
params,
embedded?,
_type
) do
{params, left_expr} = do_filter_to_expr(left, bindings, params, embedded?)
{params, right_expr} = do_filter_to_expr(right, bindings, params, embedded?)
{params, {op, [], [left_expr, right_expr]}}
end
defp do_filter_to_expr(%Not{expression: expression}, bindings, params, embedded?, _type) do
{params, new_expression} = do_filter_to_expr(expression, bindings, params, embedded?)
{params, {:not, [], [new_expression]}}
end
defp do_filter_to_expr(
%TrigramSimilarity{arguments: [arg1, arg2], embedded?: pred_embedded?},
bindings,
params,
embedded?,
_type
) do
{params, arg1} = do_filter_to_expr(arg1, bindings, params, pred_embedded? || embedded?)
{params, arg2} = do_filter_to_expr(arg2, bindings, params, pred_embedded? || embedded?)
{params, {:fragment, [], [raw: "similarity(", expr: arg1, raw: ", ", expr: arg2, raw: ")"]}}
end
defp do_filter_to_expr(
%Type{arguments: [arg1, arg2], embedded?: pred_embedded?},
bindings,
params,
embedded?,
_type
)
when pred_embedded? or embedded? do
{params, arg1} = do_filter_to_expr(arg1, bindings, params, true)
{params, arg2} = do_filter_to_expr(arg2, bindings, params, true)
case maybe_ecto_type(arg2) do
nil ->
{params, {:type, [], [arg1, arg2]}}
type ->
case arg1 do
%{__predicate__?: _} ->
{params, {:type, [], [arg1, arg2]}}
value ->
{params, %Ecto.Query.Tagged{value: value, type: type}}
end
end
end
defp do_filter_to_expr(
%Type{arguments: [arg1, arg2], embedded?: pred_embedded?},
bindings,
params,
embedded?,
_type
) do
{params, arg1} = do_filter_to_expr(arg1, bindings, params, pred_embedded? || embedded?)
{params, arg2} = do_filter_to_expr(arg2, bindings, params, pred_embedded? || embedded?)
arg2 = maybe_ecto_type(arg2)
{params, {:type, [], [arg1, arg2]}}
end
defp do_filter_to_expr(
%Fragment{arguments: arguments, embedded?: pred_embedded?},
bindings,
params,
embedded?,
_type
) do
{params, fragment_data} =
Enum.reduce(arguments, {params, []}, fn
{:raw, str}, {params, fragment_data} ->
{params, fragment_data ++ [{:raw, str}]}
{:expr, expr}, {params, fragment_data} ->
{params, expr} = do_filter_to_expr(expr, bindings, params, pred_embedded? || embedded?)
{params, fragment_data ++ [{:expr, expr}]}
end)
{params, {:fragment, [], fragment_data}}
end
defp do_filter_to_expr(
%IsNil{left: left, right: right, embedded?: pred_embedded?},
bindings,
params,
embedded?,
_type
) do
{params, left_expr} = do_filter_to_expr(left, bindings, params, pred_embedded? || embedded?)
{params, right_expr} = do_filter_to_expr(right, bindings, params, pred_embedded? || embedded?)
{params,
{:==, [],
[
{:is_nil, [], [left_expr]},
right_expr
]}}
end
defp do_filter_to_expr(
%Ago{arguments: [left, right], embedded?: _pred_embedded?},
_bindings,
params,
_embedded?,
_type
)
when is_integer(left) and (is_binary(right) or is_atom(right)) do
{params ++ [{DateTime.utc_now(), {:param, :any_datetime}}],
{:datetime_add, [], [{:^, [], [Enum.count(params)]}, left * -1, to_string(right)]}}
end
defp do_filter_to_expr(
%Contains{arguments: [left, %Ash.CiString{} = right], embedded?: pred_embedded?},
bindings,
params,
embedded?,
type
) do
do_filter_to_expr(
%Fragment{
embedded?: pred_embedded?,
arguments: [
raw: "strpos(",
expr: left,
raw: "::citext, ",
expr: right,
raw: ") > 0"
]
},
bindings,
params,
embedded?,
type
)
end
defp do_filter_to_expr(
%Contains{arguments: [left, right], embedded?: pred_embedded?},
bindings,
params,
embedded?,
type
) do
do_filter_to_expr(
%Fragment{
embedded?: pred_embedded?,
arguments: [
raw: "strpos(",
expr: left,
raw: ", ",
expr: right,
raw: ") > 0"
]
},
bindings,
params,
embedded?,
type
)
end
defp do_filter_to_expr(
%mod{
__predicate__?: _,
left: left,
right: right,
embedded?: pred_embedded?,
operator: op
},
bindings,
params,
embedded?,
_type
) do
[left_type, right_type] = determine_types(mod, [left, right])
{params, left_expr} =
do_filter_to_expr(left, bindings, params, pred_embedded? || embedded?, left_type)
{params, right_expr} =
do_filter_to_expr(right, bindings, params, pred_embedded? || embedded?, right_type)
{params,
{op, [],
[
left_expr,
right_expr
]}}
end
defp do_filter_to_expr(
%Ref{attribute: %{name: name}} = ref,
bindings,
params,
_embedded?,
_type
) do
{params, {{:., [], [{:&, [], [ref_binding(ref, bindings)]}, name]}, [], []}}
end
defp do_filter_to_expr({:embed, other}, _bindings, params, _true, _type) do
{params, other}
end
defp do_filter_to_expr(%Ash.CiString{string: string}, bindings, params, embedded?, type) do
do_filter_to_expr(
%Fragment{
embedded?: embedded?,
arguments: [
raw: "",
expr: string,
raw: "::citext"
]
},
bindings,
params,
embedded?,
type
)
end
defp do_filter_to_expr(%MapSet{} = mapset, bindings, params, embedded?, type) do
do_filter_to_expr(Enum.to_list(mapset), bindings, params, embedded?, type)
end
defp do_filter_to_expr(other, _bindings, params, true, _type) do
{params, other}
end
defp do_filter_to_expr(value, _bindings, params, false, type) do
type = type || :any
value = last_ditch_cast(value, type)
{params ++ [{value, type}], {:^, [], [Enum.count(params)]}}
end
defp maybe_ecto_type({:array, type}), do: {:array, maybe_ecto_type(type)}
defp maybe_ecto_type(type) when is_atom(type) do
if Ash.Type.ash_type?(type) do
Ash.Type.ecto_type(type)
end
end
defp maybe_ecto_type(_type), do: nil
defp last_ditch_cast(value, {:in, type}) when is_list(value) do
Enum.map(value, &last_ditch_cast(&1, type))
end
defp last_ditch_cast(value, _) when is_atom(value) do
to_string(value)
end
defp last_ditch_cast(value, _type) do
value
end
defp determine_types(mod, values) do
mod.types()
|> Enum.map(fn types ->
case types do
:same ->
types =
for _ <- values do
:same
end
closest_fitting_type(types, values)
:any ->
for _ <- values do
:any
end
types ->
closest_fitting_type(types, values)
end
end)
|> Enum.min_by(fn types ->
types
|> Enum.map(&vagueness/1)
|> Enum.sum()
end)
end
defp closest_fitting_type(types, values) do
types_with_values = Enum.zip(types, values)
types_with_values
|> fill_in_known_types()
|> clarify_types()
end
defp clarify_types(types) do
basis =
types
|> Enum.map(&elem(&1, 0))
|> Enum.min_by(&vagueness(&1))
Enum.map(types, fn {type, _value} ->
replace_same(type, basis)
end)
end
defp replace_same({:in, type}, basis) do
{:in, replace_same(type, basis)}
end
defp replace_same(:same, :same) do
:any
end
defp replace_same(:same, {:in, :same}) do
{:in, :any}
end
defp replace_same(:same, basis) do
basis
end
defp replace_same(other, _basis) do
other
end
defp fill_in_known_types(types) do
Enum.map(types, &fill_in_known_type/1)
end
defp fill_in_known_type({vague_type, %Ref{attribute: %{type: type}}} = ref)
when vague_type in [:any, :same] do
if Ash.Type.ash_type?(type) do
{type |> Ash.Type.storage_type() |> array_to_in(), ref}
else
{type |> array_to_in(), ref}
end
end
defp fill_in_known_type(
{{:array, type}, %Ref{attribute: %{type: {:array, type}} = attribute} = ref}
) do
{:in, fill_in_known_type({type, %{ref | attribute: %{attribute | type: type}}})}
end
defp fill_in_known_type({type, value}), do: {array_to_in(type), value}
defp array_to_in({:array, v}), do: {:in, array_to_in(v)}
defp array_to_in(v), do: v
defp vagueness({:in, type}), do: vagueness(type)
defp vagueness(:same), do: 2
defp vagueness(:any), do: 1
defp vagueness(_), do: 0
defp ref_binding(ref, bindings) do
case ref.attribute do
%Ash.Resource.Attribute{} ->
Enum.find_value(bindings, fn {binding, data} ->
data.path == ref.relationship_path && data.type in [:inner, :left, :root] && binding
end)
%Ash.Query.Aggregate{} = aggregate ->
Enum.find_value(bindings, fn {binding, data} ->
data.path == aggregate.relationship_path && data.type == :aggregate && binding
end)
end
end
defp add_binding(query, data) do
current = query.__ash_bindings__.current
bindings = query.__ash_bindings__.bindings
new_ash_bindings = %{
query.__ash_bindings__
| bindings: Map.put(bindings, current, data),
current: current + 1
}
%{query | __ash_bindings__: new_ash_bindings}
end
@impl true
def transaction(resource, func) do
repo(resource).transaction(func)
end
@impl true
def rollback(resource, term) do
repo(resource).rollback(term)
end
defp maybe_get_resource_query(resource) do
case Ash.Query.data_layer_query(Ash.Query.new(resource), only_validate_filter?: false) do
{:ok, query} -> query
{:error, error} -> {:error, error}
end
end
defp table(resource, changeset) do
changeset.context[:data_layer][:table] || AshPostgres.table(resource)
end
defp raise_table_error!(resource, operation) do
if AshPostgres.polymorphic?(resource) do
raise """
Could not determine table for #{operation} on #{inspect(resource)}.
Polymorphic resources require that the `data_layer[:table]` context is provided.
See the guide on polymorphic resources for more information.
"""
else
raise """
Could not determine table for #{operation} on #{inspect(resource)}.
"""
end
end
end | lib/data_layer.ex | 0.935942 | 0.52074 | data_layer.ex | starcoder |
defmodule Absinthe.Type.Union do
@moduledoc """
A unions is an abstract type made up of multiple possible concrete types.
No common fields are declared in a union. Compare to `Absinthe.Type.Interface`.
Because it's necessary for the union to determine the concrete type of a
resolved object, you must either:
* Provide a `:resolve_type` function on the union
* Provide a `:is_type_of` function on each possible concrete type
```
union :search_result do
description "A search result"
types [:person, :business]
resolve_type fn
%Person{}, _ -> :person
%Business{}, _ -> :business
end
end
```
"""
use Absinthe.Introspection.Kind
alias Absinthe.{Schema, Type}
@typedoc """
* `:name` - The name of the union type. Should be a TitleCased `binary`. Set automatically.
* `:description` - A nice description for introspection.
* `:types` - The list of possible types.
* `:resolve_type` - A function used to determine the concrete type of a resolved object. See also `Absinthe.Type.Object`'s `:is_type_of`. Either `resolve_type` is specified in the union type, or every object type in the union must specify `is_type_of`
The `:resolve_type` function will be passed two arguments; the object whose type needs to be identified, and the `Absinthe.Execution` struct providing the full execution context.
The `__private__` and `:__reference__` keys are for internal use.
"""
@type t :: %__MODULE__{
name: binary,
description: binary,
types: [Type.identifier_t],
resolve_type: ((any, Absinthe.Resolution.t) -> atom | nil),
identifier: atom,
__private__: Keyword.t,
__reference__: Type.Reference.t,
}
defstruct [
name: nil,
description: nil,
resolve_type: nil,
identifier: nil,
types: [],
__private__: [],
__reference__: nil,
]
def build(%{attrs: attrs}) do
quote do: %unquote(__MODULE__){unquote_splicing(attrs)}
end
@doc false
@spec member?(t, Type.t) :: boolean
def member?(%{types: types}, %{__reference__: %{identifier: ident}}) do
ident in types
end
def member?(_, _) do
false
end
@doc false
@spec resolve_type(t, any, Absinthe.Resolution.t) :: Type.t | nil
def resolve_type(type, object, env, opts \\ [lookup: true])
def resolve_type(%{resolve_type: nil, types: types}, obj, %{schema: schema}, opts) do
type_name = Enum.find(types, fn
%{is_type_of: nil} ->
false
type ->
case Schema.lookup_type(schema, type) do
nil ->
false
%{is_type_of: nil} ->
false
%{is_type_of: check} ->
check.(obj)
end
end)
if opts[:lookup] do
Schema.lookup_type(schema, type_name)
else
type_name
end
end
def resolve_type(%{resolve_type: resolver}, obj, %{schema: schema} = env, opts) do
case resolver.(obj, env) do
nil ->
nil
ident when is_atom(ident) ->
if opts[:lookup] do
Absinthe.Schema.lookup_type(schema, ident)
else
ident
end
end
end
end | deps/absinthe/lib/absinthe/type/union.ex | 0.858422 | 0.881615 | union.ex | starcoder |
defmodule Slack do
@moduledoc """
Slack is a genserver-ish interface for working with the Slack real time
messaging API through a Websocket connection.
To use this module you'll need a valid Slack API token. You can find your
personal token on the [Slack Web API] page, or you can add a new
[bot integration].
[Slack Web API]: https://api.slack.com/web
[bot integration]: https://api.slack.com/bot-users
## Example
```
defmodule Bot do
use Slack
def handle_message(message = %{type: "message"}, slack) do
if message.text == "Hi" do
send_message("Hello to you too!", message.channel, slack)
end
end
end
Bot.start_link("API_TOKEN")
```
`handle_*` methods are always passed `slack` and `state` arguments. The
`slack` argument holds the state of Slack and is kept up to date
automatically.
In this example we're just matching against the message type and checking if
the text content is "Hi" and if so, we reply with our own greeting.
The message type is pattern matched against because the
[Slack RTM API](https://api.slack.com/rtm) defines many different types of
messages that we can receive. Because of this it's wise to write a catch-all
`handle_message/3` in your bots to prevent crashing.
## Callbacks
* `handle_connect(slack)` - called when connected to Slack.
* `handle_message(message, slack)` - called when a message is received.
* `handle_close(reason, slack)` - called when websocket is closed.
* `handle_info(message, slack)` - called when any other message is received in the process mailbox.
## Slack argument
The Slack argument that's passed to each callback is what contains all of the
state related to Slack including a list of channels, users, groups, bots, and
even the socket.
Here's a list of what's stored:
* me - The current bot/users information stored as a map of properties.
* team - The current team's information stored as a map of properties.
* bots - Stored as a map with id's as keys.
* channels - Stored as a map with id's as keys.
* groups - Stored as a map with id's as keys.
* users - Stored as a map with id's as keys.
* ims (direct message channels) - Stored as a map with id's as keys.
* socket - The connection to Slack.
* client - The client that makes calls to Slack.
For all but `socket` and `client`, you can see what types of data to expect each of the
types to contain from the [Slack API types] page.
[Slack API types]: https://api.slack.com/types
"""
defmacro __using__(_) do
quote do
@behaviour :websocket_client_handler
require Logger
import Slack
import Slack.Lookups
import Slack.Sends
def start_link(token, client \\ :websocket_client) do
case Slack.Rtm.start(token) do
{:ok, rtm} ->
state = %{
rtm: rtm,
client: client,
token: token
}
url = String.to_char_list(rtm.url)
client.start_link(url, __MODULE__, state)
{:error, %HTTPoison.Error{reason: :connect_timeout}} ->
{:error, "Timed out while connecting to the Slack RTM API"}
{:error, %HTTPoison.Error{reason: :nxdomain}} ->
{:error, "Could not connect to the Slack RTM API"}
{:error, error} ->
{:error, error}
end
end
def init(%{rtm: rtm, client: client, token: token}, socket) do
slack = %Slack.State{
socket: socket,
client: client,
token: token,
me: rtm.self,
team: rtm.team,
bots: rtm_list_to_map(rtm.bots),
channels: rtm_list_to_map(rtm.channels),
groups: rtm_list_to_map(rtm.groups),
users: rtm_list_to_map(rtm.users),
ims: rtm_list_to_map(rtm.ims)
}
handle_connect(slack)
{:ok, slack}
end
def websocket_info(:start, _connection, state) do
{:ok, state}
end
def websocket_info(message, _connection, slack) do
try do
handle_info(message, slack)
rescue
e -> handle_exception(e)
end
{:ok, slack}
end
def websocket_terminate(reason, _conn, slack) do
try do
handle_close(reason, slack)
rescue
e -> handle_exception(e)
end
end
def websocket_handle({:ping, data}, _conn, state) do
{:reply, {:pong, data}, state}
end
def websocket_handle({:text, message}, _conn, slack) do
message = prepare_message message
slack = Slack.State.update(message, slack)
slack = if Map.has_key?(message, :type) do
try do
handle_message(message, slack)
slack
rescue
e -> handle_exception(e)
end
else
slack
end
{:ok, slack}
end
defp rtm_list_to_map(list) do
Enum.reduce(list, %{}, fn (item, map) ->
Map.put(map, item.id, item)
end)
end
defp prepare_message(binstring) do
binstring
|> :binary.split(<<0>>)
|> List.first
|> JSX.decode!([{:labels, :atom}])
end
defp handle_exception(e) do
message = Exception.message(e)
Logger.error(message)
System.stacktrace |> Exception.format_stacktrace |> Logger.error
raise message
end
def handle_connect(_slack ), do: :ok
def handle_message(_message, _slack), do: :ok
def handle_close(_reason, _slack), do: :ok
def handle_info(_message, _slack), do: :ok
defoverridable [handle_connect: 1, handle_message: 2, handle_close: 2, handle_info: 2]
end
end
end | lib/slack.ex | 0.824073 | 0.820073 | slack.ex | starcoder |
defmodule Bolt.Sips.Metadata do
@moduledoc false
defstruct [:bookmarks, :tx_timeout, :metadata]
@type t :: %__MODULE__{
bookmarks: [String.t()],
tx_timeout: non_neg_integer(),
metadata: map()
}
alias Bolt.Sips.Metadata
@doc """
Create a new metadata structure.
Data must be valid.
"""
@spec new(map()) :: {:ok, Bolt.Sips.Metadata.t()} | {:error, String.t()}
def new(data) do
with {:ok, data} <- check_keys(data),
{:ok, bookmarks} <- validate_bookmarks(Map.get(data, :bookmarks, [])),
{:ok, tx_timeout} <- validate_timeout(Map.get(data, :tx_timeout)),
{:ok, metadata} <- validate_metadata(Map.get(data, :metadata, %{})) do
{:ok,
%__MODULE__{
bookmarks: bookmarks,
tx_timeout: tx_timeout,
metadata: metadata
}}
else
error -> error
end
end
@doc """
Convert the Metadata struct to a map.
All `nil` will be stripped
"""
@spec to_map(Bolt.Sips.Metadata.t()) :: map()
def to_map(metadata) do
with {:ok, metadata} <- check_keys(Map.from_struct(metadata)) do
metadata
|> Map.from_struct()
|> Enum.filter(fn {_, value} -> value != nil end)
|> Enum.into(%{})
else
error -> error
end
end
defp check_keys(data) do
try do
{:ok, struct!(Metadata, data)}
rescue
_ in KeyError -> {:error, "[Metadata] Invalid keys"}
end
end
@spec validate_bookmarks(any()) :: {:ok, list()} | {:ok, nil} | {:error, String.t()}
defp validate_bookmarks(bookmarks)
when (is_list(bookmarks) and length(bookmarks) > 0) or is_nil(bookmarks) do
{:ok, bookmarks}
end
defp validate_bookmarks([]) do
{:ok, nil}
end
defp validate_bookmarks(_) do
{:error, "[Metadata] Invalid bookmkarks. Should be a list."}
end
@spec validate_timeout(any()) :: {:ok, integer()} | {:error, String.t()}
defp validate_timeout(timeout) when (is_integer(timeout) and timeout > 0) or is_nil(timeout) do
{:ok, timeout}
end
defp validate_timeout(nil) do
{:ok, nil}
end
defp validate_timeout(_) do
{:error, "[Metadata] Invalid timeout. Should be a positive integer."}
end
@spec validate_metadata(any()) :: {:ok, map()} | {:ok, nil} | {:error, String.t()}
defp validate_metadata(metadata)
when (is_map(metadata) and map_size(metadata) > 0) or is_nil(metadata) do
{:ok, metadata}
end
defp validate_metadata(%{}) do
{:ok, nil}
end
defp validate_metadata(_) do
{:error, "[Metadata] Invalid timeout. Should be a valid map or nil."}
end
end | lib/bolt_sips/metadata.ex | 0.803829 | 0.492371 | metadata.ex | starcoder |
defmodule Elastix.Bulk do
@moduledoc """
The bulk API makes it possible to perform many index/delete operations in a single API call.
[Elastic documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html)
"""
import Elastix.HTTP, only: [prepare_url: 2]
alias Elastix.{HTTP, JSON}
@doc """
Excepts a list of actions and sources for the `lines` parameter.
## Examples
iex> Elastix.Bulk.post("http://localhost:9200", [%{index: %{_id: "1"}}, %{user: "kimchy"}], index: "twitter", type: "tweet")
{:ok, %HTTPoison.Response{...}}
"""
@spec post(
elastic_url :: String.t(),
lines :: list,
opts :: Keyword.t(),
query_params :: Keyword.t()
) :: HTTP.resp()
def post(elastic_url, lines, options \\ [], query_params \\ []) do
data =
Enum.reduce(lines, [], fn l, acc -> ["\n", JSON.encode!(l) | acc] end)
|> Enum.reverse()
|> IO.iodata_to_binary()
path =
Keyword.get(options, :index)
|> make_path(Keyword.get(options, :type), query_params)
httpoison_options = Keyword.get(options, :httpoison_options, [])
elastic_url
|> prepare_url(path)
|> HTTP.put(data, [], httpoison_options)
end
@doc """
Deprecated: use `post/4` instead.
"""
@spec post_to_iolist(
elastic_url :: String.t(),
lines :: list,
opts :: Keyword.t(),
query_params :: Keyword.t()
) :: HTTP.resp()
def post_to_iolist(elastic_url, lines, options \\ [], query_params \\ []) do
IO.warn(
"This function is deprecated and will be removed in future releases; use Elastix.Bulk.post/4 instead."
)
httpoison_options = Keyword.get(options, :httpoison_options, [])
(elastic_url <>
make_path(Keyword.get(options, :index), Keyword.get(options, :type), query_params))
|> HTTP.put(Enum.map(lines, fn line -> JSON.encode!(line) <> "\n" end), [], httpoison_options)
end
@doc """
Same as `post/4` but instead of sending a list of maps you must send raw binary data in
the format described in the [Elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html).
"""
@spec post_raw(
elastic_url :: String.t(),
raw_data :: String.t(),
opts :: Keyword.t(),
query_params :: Keyword.t()
) :: HTTP.resp()
def post_raw(elastic_url, raw_data, options \\ [], query_params \\ []) do
httpoison_options = Keyword.get(options, :httpoison_options, [])
(elastic_url <>
make_path(Keyword.get(options, :index), Keyword.get(options, :type), query_params))
|> HTTP.put(raw_data, [], httpoison_options)
end
@doc false
def make_path(index_name, type_name, query_params) do
path = make_base_path(index_name, type_name)
case query_params do
[] -> path
_ -> HTTP.append_query_string(path, query_params)
end
end
defp make_base_path(nil, nil), do: "/_bulk"
defp make_base_path(index_name, nil), do: "/#{index_name}/_bulk"
defp make_base_path(index_name, type_name), do: "/#{index_name}/#{type_name}/_bulk"
end | lib/elastix/bulk.ex | 0.839718 | 0.472318 | bulk.ex | starcoder |
defmodule AWS.Synthetics do
@moduledoc """
Amazon CloudWatch Synthetics
You can use Amazon CloudWatch Synthetics to continually monitor your
services. You can create and manage *canaries*, which are modular,
lightweight scripts that monitor your endpoints and APIs from the
outside-in. You can set up your canaries to run 24 hours a day, once per
minute. The canaries help you check the availability and latency of your
web services and troubleshoot anomalies by investigating load time data,
screenshots of the UI, logs, and metrics. The canaries seamlessly integrate
with CloudWatch ServiceLens to help you trace the causes of impacted nodes
in your applications. For more information, see [Using ServiceLens to
Monitor the Health of Your
Applications](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ServiceLens.html)
in the *Amazon CloudWatch User Guide*.
Before you create and manage canaries, be aware of the security
considerations. For more information, see [Security Considerations for
Synthetics
Canaries](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/servicelens_canaries_security.html).
"""
@doc """
Creates a canary. Canaries are scripts that monitor your endpoints and APIs
from the outside-in. Canaries help you check the availability and latency
of your web services and troubleshoot anomalies by investigating load time
data, screenshots of the UI, logs, and metrics. You can set up a canary to
run continuously or just once.
Do not use `CreateCanary` to modify an existing canary. Use
[UpdateCanary](https://docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/API_UpdateCanary.html)
instead.
To create canaries, you must have the `CloudWatchSyntheticsFullAccess`
policy. If you are creating a new IAM role for the canary, you also need
the the `iam:CreateRole`, `iam:CreatePolicy` and `iam:AttachRolePolicy`
permissions. For more information, see [Necessary Roles and
Permissions](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_Roles).
Do not include secrets or proprietary information in your canary names. The
canary name makes up part of the Amazon Resource Name (ARN) for the canary,
and the ARN is included in outbound calls over the internet. For more
information, see [Security Considerations for Synthetics
Canaries](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/servicelens_canaries_security.html).
"""
def create_canary(client, input, options \\ []) do
path_ = "/canary"
headers = []
query_ = []
request(client, :post, path_, query_, headers, input, options, nil)
end
@doc """
Permanently deletes the specified canary.
When you delete a canary, resources used and created by the canary are not
automatically deleted. After you delete a canary that you do not intend to
use again, you should also delete the following:
<ul> <li> The Lambda functions and layers used by this canary. These have
the prefix `cwsyn-*MyCanaryName* `.
</li> <li> The CloudWatch alarms created for this canary. These alarms have
a name of `Synthetics-SharpDrop-Alarm-*MyCanaryName* `.
</li> <li> Amazon S3 objects and buckets, such as the canary's artifact
location.
</li> <li> IAM roles created for the canary. If they were created in the
console, these roles have the name `
role/service-role/CloudWatchSyntheticsRole-*MyCanaryName* `.
</li> <li> CloudWatch Logs log groups created for the canary. These logs
groups have the name `/aws/lambda/cwsyn-*MyCanaryName* `.
</li> </ul> Before you delete a canary, you might want to use `GetCanary`
to display the information about this canary. Make note of the information
returned by this operation so that you can delete these resources after you
delete the canary.
"""
def delete_canary(client, name, input, options \\ []) do
path_ = "/canary/#{URI.encode(name)}"
headers = []
query_ = []
request(client, :delete, path_, query_, headers, input, options, nil)
end
@doc """
This operation returns a list of the canaries in your account, along with
full details about each canary.
This operation does not have resource-level authorization, so if a user is
able to use `DescribeCanaries`, the user can see all of the canaries in the
account. A deny policy can only be used to restrict access to all canaries.
It cannot be used on specific resources.
"""
def describe_canaries(client, input, options \\ []) do
path_ = "/canaries"
headers = []
query_ = []
request(client, :post, path_, query_, headers, input, options, nil)
end
@doc """
Use this operation to see information from the most recent run of each
canary that you have created.
"""
def describe_canaries_last_run(client, input, options \\ []) do
path_ = "/canaries/last-run"
headers = []
query_ = []
request(client, :post, path_, query_, headers, input, options, nil)
end
@doc """
Returns a list of Synthetics canary runtime versions. For more information,
see [ Canary Runtime
Versions](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_Library.html).
"""
def describe_runtime_versions(client, input, options \\ []) do
path_ = "/runtime-versions"
headers = []
query_ = []
request(client, :post, path_, query_, headers, input, options, nil)
end
@doc """
Retrieves complete information about one canary. You must specify the name
of the canary that you want. To get a list of canaries and their names, use
[DescribeCanaries](https://docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/API_DescribeCanaries.html).
"""
def get_canary(client, name, options \\ []) do
path_ = "/canary/#{URI.encode(name)}"
headers = []
query_ = []
request(client, :get, path_, query_, headers, nil, options, nil)
end
@doc """
Retrieves a list of runs for a specified canary.
"""
def get_canary_runs(client, name, input, options \\ []) do
path_ = "/canary/#{URI.encode(name)}/runs"
headers = []
query_ = []
request(client, :post, path_, query_, headers, input, options, nil)
end
@doc """
Displays the tags associated with a canary.
"""
def list_tags_for_resource(client, resource_arn, options \\ []) do
path_ = "/tags/#{URI.encode(resource_arn)}"
headers = []
query_ = []
request(client, :get, path_, query_, headers, nil, options, nil)
end
@doc """
Use this operation to run a canary that has already been created. The
frequency of the canary runs is determined by the value of the canary's
`Schedule`. To see a canary's schedule, use
[GetCanary](https://docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/API_GetCanary.html).
"""
def start_canary(client, name, input, options \\ []) do
path_ = "/canary/#{URI.encode(name)}/start"
headers = []
query_ = []
request(client, :post, path_, query_, headers, input, options, nil)
end
@doc """
Stops the canary to prevent all future runs. If the canary is currently
running, Synthetics stops waiting for the current run of the specified
canary to complete. The run that is in progress completes on its own,
publishes metrics, and uploads artifacts, but it is not recorded in
Synthetics as a completed run.
You can use `StartCanary` to start it running again with the canary’s
current schedule at any point in the future.
"""
def stop_canary(client, name, input, options \\ []) do
path_ = "/canary/#{URI.encode(name)}/stop"
headers = []
query_ = []
request(client, :post, path_, query_, headers, input, options, nil)
end
@doc """
Assigns one or more tags (key-value pairs) to the specified canary.
Tags can help you organize and categorize your resources. You can also use
them to scope user permissions, by granting a user permission to access or
change only resources with certain tag values.
Tags don't have any semantic meaning to AWS and are interpreted strictly as
strings of characters.
You can use the `TagResource` action with a canary that already has tags.
If you specify a new tag key for the alarm, this tag is appended to the
list of tags associated with the alarm. If you specify a tag key that is
already associated with the alarm, the new tag value that you specify
replaces the previous value for that tag.
You can associate as many as 50 tags with a canary.
"""
def tag_resource(client, resource_arn, input, options \\ []) do
path_ = "/tags/#{URI.encode(resource_arn)}"
headers = []
query_ = []
request(client, :post, path_, query_, headers, input, options, nil)
end
@doc """
Removes one or more tags from the specified canary.
"""
def untag_resource(client, resource_arn, input, options \\ []) do
path_ = "/tags/#{URI.encode(resource_arn)}"
headers = []
{query_, input} =
[
{"TagKeys", "tagKeys"},
]
|> AWS.Request.build_params(input)
request(client, :delete, path_, query_, headers, input, options, nil)
end
@doc """
Use this operation to change the settings of a canary that has already been
created.
You can't use this operation to update the tags of an existing canary. To
change the tags of an existing canary, use
[TagResource](https://docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/API_TagResource.html).
"""
def update_canary(client, name, input, options \\ []) do
path_ = "/canary/#{URI.encode(name)}"
headers = []
query_ = []
request(client, :patch, path_, query_, headers, input, options, nil)
end
@spec request(AWS.Client.t(), binary(), binary(), list(), list(), map(), list(), pos_integer()) ::
{:ok, Poison.Parser.t(), Poison.Response.t()}
| {:error, Poison.Parser.t()}
| {:error, HTTPoison.Error.t()}
defp request(client, method, path, query, headers, input, options, success_status_code) do
client = %{client | service: "synthetics"}
host = build_host("synthetics", client)
url = host
|> build_url(path, client)
|> add_query(query)
additional_headers = [{"Host", host}, {"Content-Type", "application/x-amz-json-1.1"}]
headers = AWS.Request.add_headers(additional_headers, headers)
payload = encode_payload(input)
headers = AWS.Request.sign_v4(client, method, url, headers, payload)
perform_request(method, url, payload, headers, options, success_status_code)
end
defp perform_request(method, url, payload, headers, options, nil) do
case HTTPoison.request(method, url, payload, headers, options) do
{:ok, %HTTPoison.Response{status_code: 200, body: ""} = response} ->
{:ok, response}
{:ok, %HTTPoison.Response{status_code: status_code, body: body} = response}
when status_code == 200 or status_code == 202 or status_code == 204 ->
{:ok, Poison.Parser.parse!(body, %{}), response}
{:ok, %HTTPoison.Response{body: body}} ->
error = Poison.Parser.parse!(body, %{})
{:error, error}
{:error, %HTTPoison.Error{reason: reason}} ->
{:error, %HTTPoison.Error{reason: reason}}
end
end
defp perform_request(method, url, payload, headers, options, success_status_code) do
case HTTPoison.request(method, url, payload, headers, options) do
{:ok, %HTTPoison.Response{status_code: ^success_status_code, body: ""} = response} ->
{:ok, %{}, response}
{:ok, %HTTPoison.Response{status_code: ^success_status_code, body: body} = response} ->
{:ok, Poison.Parser.parse!(body, %{}), response}
{:ok, %HTTPoison.Response{body: body}} ->
error = Poison.Parser.parse!(body, %{})
{:error, error}
{:error, %HTTPoison.Error{reason: reason}} ->
{:error, %HTTPoison.Error{reason: reason}}
end
end
defp build_host(_endpoint_prefix, %{region: "local"}) do
"localhost"
end
defp build_host(endpoint_prefix, %{region: region, endpoint: endpoint}) do
"#{endpoint_prefix}.#{region}.#{endpoint}"
end
defp build_url(host, path, %{:proto => proto, :port => port}) do
"#{proto}://#{host}:#{port}#{path}"
end
defp add_query(url, []) do
url
end
defp add_query(url, query) do
querystring = AWS.Util.encode_query(query)
"#{url}?#{querystring}"
end
defp encode_payload(input) do
if input != nil, do: Poison.Encoder.encode(input, %{}), else: ""
end
end | lib/aws/synthetics.ex | 0.809953 | 0.595875 | synthetics.ex | starcoder |
defmodule Yyzzy.Enum do
### Protocols and Behaviors: Enum
## Note, this implementation might have to change if we want fully qualified uids..
defimpl Enumerable, for: Yyzzy do
def count(yyzzy) do
{:ok, Enum.reduce(yyzzy,0,fn _x, acc -> acc + 1 end) }
end
@doc """
entities are in a tree like form so membership is done via DFS
"""
def member?(_, nil), do: {:ok, false}
def member?(%Yyzzy{uid: uid}, value) when is_atom(value) and uid == value, do: {:ok, true}
def member?(e, value) when is_atom(value) do
{:ok, Enum.reduce_while(e, false, fn x, _acc ->
case x.uid == value do
true -> {:halt, true}
false -> {:cont, false}
end
end)}
end
def member?(yyzzy, %Yyzzy{uid: value}), do: member?(yyzzy, value)
def member?(_,_), do: {:error, __MODULE__}
@doc """
reduce is done via DFS and has three cases:
Root node, many children
level of nodes which may have children
level of only leafs
"""
def reduce(_, {:halt, acc}, _fun), do: {:halted, acc}
def reduce(yyzzy, {:suspend, acc}, fun), do: {:suspended, acc, &reduce(yyzzy, &1, fun)}
def reduce(y = %Yyzzy{entities: es}, {:cont, acc}, fun) when map_size(es) == 0 do
{:cont, acc} = fun.(y, acc)
{:done, acc}
end
def reduce(y = %Yyzzy{entities: es}, {:cont, acc}, fun) do
new_acc = fun.(y,acc)
[h | rest] = Map.values(es)
rest = for child <- rest, into: %{} do
case child.uid do
{_heirarchy, uid} -> {uid, child}
uid -> {uid, child}
end
end
new_y = case h do
f when is_function(f) ->
f.({:update, fn x -> %Yyzzy{x | entities: Map.merge(x.entities, rest)} end })
f
h -> %Yyzzy{h | entities: Map.merge(h.entities, rest)}
end
reduce(new_y, new_acc, fun)
end
def reduce(y, {:cont, acc}, fun) when is_function(y) do
root = y.(:get)
{:cont, new_acc} = fun.(root, acc)
case Enum.count(root.entities) do
0 -> {:done, new_acc}
n ->
[h | _] = Map.keys(root.entities)
reduce(Yyzzy.retree(root, h), new_acc, fun)
end
end
end
end | lib/yyzzy/enum.ex | 0.610453 | 0.405154 | enum.ex | starcoder |
defmodule ElixirBoilerplateWeb.Errors do
alias Ecto.Changeset
alias ElixirBoilerplateWeb.Errors.View
@doc """
Generates a human-readable block containing all errors in a changeset. Errors
are then localized using translations in the `ecto` domain.
For example, you could have an `ecto.po` file in the french locale:
```
msgid ""
msgstr ""
"Language: fr"
msgid "can't be blank"
msgstr "ne peut être vide"
```
"""
def error_messages(changeset) do
changeset
|> Changeset.traverse_errors(&translate_error/1)
|> convert_errors_to_html(changeset.data.__struct__)
end
defp translate_error({message, options}) do
if options[:count] do
Gettext.dngettext(ElixirBoilerplate.Gettext, "ecto", message, message, options[:count], options)
else
Gettext.dgettext(ElixirBoilerplate.Gettext, "ecto", message, options)
end
end
defp convert_errors_to_html(errors, schema) do
errors = Enum.reduce(errors, [], &convert_error_field(&1, &2, schema))
View.render("error_messages.html", %{errors: errors})
end
defp convert_error_field({field, errors}, memo, schema) when is_list(errors), do: memo ++ Enum.flat_map(errors, &convert_error_subfield(&1, field, [], schema))
defp convert_error_field({field, errors}, memo, schema) when is_map(errors), do: memo ++ Enum.flat_map(Map.keys(errors), &convert_error_subfield(&1, field, errors[&1], schema))
defp convert_error_subfield(message, field, _, _schema) when is_binary(message) do
# NOTE `schema` is available here if we want to use something like
# `schema.humanize_field(field)` to be able to display `"Email address is
# invalid"` instead of `email is invalid"`.
["#{field} #{message}"]
end
defp convert_error_subfield(message, field, memo, schema) when is_map(message) do
Enum.reduce(message, memo, fn {subfield, errors}, memo ->
memo ++ convert_error_field({"#{field}.#{subfield}", errors}, memo, schema)
end)
end
defp convert_error_subfield(subfield, field, errors, schema) do
field = "#{field}.#{subfield}"
convert_error_field({field, errors}, [], schema)
end
end | lib/elixir_boilerplate_web/errors/errors.ex | 0.819424 | 0.622631 | errors.ex | starcoder |
defmodule Flop do
@moduledoc """
Flop is a helper library for filtering, ordering and pagination with Ecto.
## Usage
The simplest way of using this library is just to use
`Flop.validate_and_run/3` and `Flop.validate_and_run!/3`. Both functions
take a queryable and a parameter map, validate the parameters, run the query
and return the query results and the meta information.
iex> Flop.Repo.insert_all(Flop.Pet, [
...> %{name: "Harry", age: 4, species: "C. lupus"},
...> %{name: "Maggie", age: 1, species: "O. cuniculus"},
...> %{name: "Patty", age: 2, species: "C. aegagrus"}
...> ])
iex> params = %{order_by: ["name", "age"], page: 1, page_size: 2}
iex> {:ok, {results, meta}} =
...> Flop.validate_and_run(
...> Flop.Pet,
...> params,
...> repo: Flop.Repo
...> )
iex> Enum.map(results, & &1.name)
["Harry", "Maggie"]
iex> meta.total_count
3
iex> meta.total_pages
2
iex> meta.has_next_page?
true
Under the hood, these functions just call `Flop.validate/2` and `Flop.run/3`,
which in turn calls `Flop.all/3` and `Flop.meta/3`. If you need finer control
about if and when to execute each step, you can call those functions directly.
See `Flop.Meta` for descriptions of the meta fields.
## Global configuration
You can set some global options like the default Ecto repo via the application
environment. All global options can be overridden by passing them directly to
the functions or configuring the options for a schema module via
`Flop.Schema`.
import Config
config :flop, repo: MyApp.Repo
See `t:Flop.option/0` for a description of all available options.
## Schema options
You can set some options for a schema by deriving `Flop.Schema`. The options
are evaluated at the validation step.
defmodule Pet do
use Ecto.Schema
@derive {Flop.Schema,
filterable: [:name, :species],
sortable: [:name, :age],
default_limit: 20,
max_limit: 100}
schema "pets" do
field :name, :string
field :age, :integer
field :species, :string
field :social_security_number, :string
end
end
You need to pass the schema to `Flop.validate/2` or any function that
includes the validation step with the `:for` option.
iex> params = %{"order_by" => ["name", "age"], "limit" => 5}
iex> {:ok, flop} = Flop.validate(params, for: Flop.Pet)
iex> flop.limit
5
iex> params = %{"order_by" => ["name", "age"], "limit" => 10_000}
iex> {:error, meta} = Flop.validate(params, for: Flop.Pet)
iex> [limit: [{msg, _}]] = meta.errors
iex> msg
"must be less than or equal to %{number}"
iex> params = %{"order_by" => ["name", "age"], "limit" => 10_000}
iex> {:error, %Flop.Meta{} = meta} =
...> Flop.validate_and_run(
...> Flop.Pet,
...> params,
...> for: Flop.Pet
...> )
iex> [limit: [{msg, _}]] = meta.errors
iex> msg
"must be less than or equal to %{number}"
## Ordering
To add an ordering clause to a query, you need to set the `:order_by` and
optionally the `:order_directions` parameter. `:order_by` should be the list
of fields, while `:order_directions` is a list of `t:Flop.order_direction/0`.
`:order_by` and `:order_directions` are zipped when generating the `ORDER BY`
clause. If no order directions are given, `:asc` is used as default.
iex> params = %{
...> "order_by" => ["name", "age"],
...> "order_directions" => ["asc", "desc"]
...> }
iex> {:ok, flop} = Flop.validate(params)
iex> flop.order_by
[:name, :age]
iex> flop.order_directions
[:asc, :desc]
Flop uses these two fields instead of a keyword list, so that the order
instructions can be easily passed in a query string.
## Pagination
For queries using `OFFSET` and `LIMIT`, you have the choice between
page-based pagination parameters:
%{page: 5, page_size: 20}
and offset-based pagination parameters:
%{offset: 100, limit: 20}
For cursor-based pagination, you can either use `:first`/`:after` or
`:last`/`:before`. You also need to pass the `:order_by` parameter or set a
default order for the schema via `Flop.Schema`.
iex> Flop.Repo.insert_all(Flop.Pet, [
...> %{name: "Harry", age: 4, species: "C. lupus"},
...> %{name: "Maggie", age: 1, species: "O. cuniculus"},
...> %{name: "Patty", age: 2, species: "C. aegagrus"}
...> ])
iex>
iex> # forward (first/after)
iex>
iex> params = %{first: 2, order_by: [:species, :name]}
iex> {:ok, {results, meta}} = Flop.validate_and_run(Flop.Pet, params)
iex> Enum.map(results, & &1.name)
["Patty", "Harry"]
iex> meta.has_next_page?
true
iex> end_cursor = meta.end_cursor
"g3QAAAACZAAEbmFtZW0AAAAFSGFycnlkAAdzcGVjaWVzbQAAAAhDLiBsdXB1cw=="
iex> params = %{first: 2, after: end_cursor, order_by: [:species, :name]}
iex> {:ok, {results, meta}} = Flop.validate_and_run(Flop.Pet, params)
iex> Enum.map(results, & &1.name)
["Maggie"]
iex> meta.has_next_page?
false
iex>
iex> # backward (last/before)
iex>
iex> params = %{last: 2, order_by: [:species, :name]}
iex> {:ok, {results, meta}} = Flop.validate_and_run(Flop.Pet, params)
iex> Enum.map(results, & &1.name)
["Harry", "Maggie"]
iex> meta.has_previous_page?
true
iex> start_cursor = meta.start_cursor
"g3QAAAACZAAEbmFtZW0AAAAFSGFycnlkAAdzcGVjaWVzbQAAAAhDLiBsdXB1cw=="
iex> params = %{last: 2, before: start_cursor, order_by: [:species, :name]}
iex> {:ok, {results, meta}} = Flop.validate_and_run(Flop.Pet, params)
iex> Enum.map(results, & &1.name)
["Patty"]
iex> meta.has_previous_page?
false
By default, it is assumed that the query result is a list of maps or structs.
If your query returns a different data structure, you can pass the
`:cursor_value_func` option to retrieve the cursor values. See
`t:Flop.option/0` and `Flop.Cursor` for more information.
You can restrict which pagination types are available. See `t:Flop.option/0`
for details.
## Filters
Filters can be passed as a list of maps. It is recommended to define the
filterable fields for a schema using `Flop.Schema`.
iex> Flop.Repo.insert_all(Flop.Pet, [
...> %{name: "Harry", age: 4, species: "C. lupus"},
...> %{name: "Maggie", age: 1, species: "O. cuniculus"},
...> %{name: "Patty", age: 2, species: "C. aegagrus"}
...> ])
iex>
iex> params = %{filters: [%{field: :name, op: :=~, value: "Mag"}]}
iex> {:ok, {results, meta}} = Flop.validate_and_run(Flop.Pet, params)
iex> meta.total_count
1
iex> [pet] = results
iex> pet.name
"Maggie"
See `t:Flop.Filter.op/0` for a list of all available filter operators.
## GraphQL and Relay
The parameters used for cursor-based pagination follow the Relay
specification, so you can just pass the arguments you get from the client on
to Flop.
`Flop.Relay` can convert the query results returned by
`Flop.validate_and_run/3` into `Edges` and `PageInfo` formats required for
Relay connections.
For example, if you have a context module like this:
defmodule MyApp.Flora
import Ecto.query, warn: false
alias MyApp.Flora.Plant
def list_plants_by_continent(%Continent{} = continent, %{} = args) do
Plant
|> where(continent_id: ^continent.id)
|> Flop.validate_and_run(args, for: Plant)
end
end
Then your Absinthe resolver for the `plants` connection may look something
like this:
def list_plants(args, %{source: %Continent{} = continent}) do
with {:ok, result} <-
Flora.list_plants_by_continent(continent, args) do
{:ok, Flop.Relay.connection_from_result(result)}
end
end
"""
use Ecto.Schema
import Ecto.Changeset
alias Ecto.Changeset
alias Ecto.Query
alias Ecto.Queryable
alias Flop.Builder
alias Flop.Cursor
alias Flop.CustomTypes.ExistingAtom
alias Flop.Filter
alias Flop.Meta
require Ecto.Query
require Logger
@typedoc """
Options that can be passed to most of the functions or that can be set via
the application environment.
- `:cursor_value_func` - 2-arity function used to get the (unencoded)
cursor value from a record. Only used with cursor-based pagination. The
first argument is the record, the second argument is the list of fields used
in the `ORDER BY` clause. Needs to return a map with the order fields as
keys and the the record values of these fields as values. Defaults to
`Flop.Cursor.get_cursor_from_node/2`.
- `:default_limit` - Sets a global default limit for queries that is used if
no default limit is set for a schema and no limit is set in the parameters.
Can only be set in the application configuration.
- `:default_pagination_type` - The pagination type to use when setting default
parameters and the pagination type cannot be determined from the parameters.
Parameters for other pagination types can still be passed when setting this
option. To restrict which pagination types can be used, set the
`:pagination_types` option.
- `:filtering` (boolean) - Can be set to `false` to silently ignore filter
parameters.
- `:for` - The schema module to be used for validation. `Flop.Schema` must be
derived for the given module. This option is optional and can not be set
globally. If it is not set, schema specific validation will be omitted. Used
by the validation functions. It is also used to determine which fields are
join and compound fields.
- `:max_limit` - Sets a global maximum limit for queries that is used if no
maximum limit is set for a schema. Can only be set in the application
configuration.
- `:pagination` (boolean) - Can be set to `false` to silently ignore
pagination parameters.
- `:pagination_types` - Defines which pagination types are allowed. Parameters
for other pagination types will not be cast. By default, all pagination
types are allowed. See also `t:Flop.pagination_type/0`.
- `:prefix` - Configures the query to be executed with the given query prefix.
See the Ecto documentation on
["Query prefix"](https://hexdocs.pm/ecto/Ecto.Query.html#module-query-prefix).
- `:ordering` (boolean) - Can be set to `false` to silently ignore order
parameters. Default orders are still applied.
- `:repo` - The Ecto Repo module to use for the database query. Used by all
functions that execute a database query.
All options can be passed directly to the functions. Some of the options can
be set on a schema level via `Flop.Schema`.
All options except `:for` can be set globally via the application environment.
import Config
config :flop,
default_limit: 25,
filtering: false,
cursor_value_func: &MyApp.Repo.get_cursor_value/2,
max_limit: 100,
ordering: false,
pagination_types: [:first, :last, :page],
repo: MyApp.Repo,
prefix: "some-prefix"
The look up order is:
1. option passed to function
2. option set for schema using `Flop.Schema` (only `:max_limit`,
`:default_limit` and `:pagination_types`)
3. option set in global config (except `:for`)
4. default value (only `:cursor_value_func`)
"""
@type option ::
{:cursor_value_func, (any, [atom] -> map)}
| {:default_limit, pos_integer}
| {:default_pagination_type, pagination_type()}
| {:filtering, boolean}
| {:for, module}
| {:max_limit, pos_integer}
| {:ordering, boolean}
| {:pagination, boolean}
| {:pagination_types, [pagination_type()]}
| {:prefix, binary}
| {:repo, module}
@typedoc """
Represents the supported order direction values.
"""
@type order_direction ::
:asc
| :asc_nulls_first
| :asc_nulls_last
| :desc
| :desc_nulls_first
| :desc_nulls_last
@typedoc """
Represents the pagination type.
- `:offset` - pagination using the `offset` and `limit` parameters
- `:page` - pagination using the `page` and `page_size` parameters
- `:first` - cursor-based pagination using the `first` and `after` parameters
- `:last` - cursor-based pagination using the `last` and `before` parameters
"""
@type pagination_type :: :offset | :page | :first | :last
@typedoc """
Represents the query parameters for filtering, ordering and pagination.
### Fields
- `after`: Used for cursor-based pagination. Must be used with `first` or a
default limit.
- `before`: Used for cursor-based pagination. Must be used with `last` or a
default limit.
- `limit`, `offset`: Used for offset-based pagination.
- `first` Used for cursor-based pagination. Can be used alone to begin
pagination or with `after`
- `last` Used for cursor-based pagination.
- `page`, `page_size`: Used for offset-based pagination as an alternative to
`offset` and `limit`.
- `order_by`: List of fields to order by. Fields can be restricted by
deriving `Flop.Schema` in your Ecto schema.
- `order_directions`: List of order directions applied to the fields defined
in `order_by`. If empty or the list is shorter than the `order_by` list,
`:asc` will be used as a default for each missing order direction.
- `filters`: List of filters, see `t:Flop.Filter.t/0`.
"""
@type t :: %__MODULE__{
after: String.t() | nil,
before: String.t() | nil,
filters: [Filter.t()] | nil,
first: pos_integer | nil,
last: pos_integer | nil,
limit: pos_integer | nil,
offset: non_neg_integer | nil,
order_by: [atom | String.t()] | nil,
order_directions: [order_direction()] | nil,
page: pos_integer | nil,
page_size: pos_integer | nil
}
@primary_key false
embedded_schema do
field :after, :string
field :before, :string
field :first, :integer
field :last, :integer
field :limit, :integer
field :offset, :integer
field :order_by, {:array, ExistingAtom}
field :order_directions, {:array, Ecto.Enum},
values: [
:asc,
:asc_nulls_first,
:asc_nulls_last,
:desc,
:desc_nulls_first,
:desc_nulls_last
]
field :page, :integer
field :page_size, :integer
embeds_many :filters, Filter
end
@doc """
Adds clauses for filtering, ordering and pagination to a
`t:Ecto.Queryable.t/0`.
The parameters are represented by the `t:Flop.t/0` type. Any `nil` values
will be ignored.
## Examples
iex> flop = %Flop{limit: 10, offset: 19}
iex> Flop.query(Flop.Pet, flop)
#Ecto.Query<from p0 in Flop.Pet, limit: ^10, offset: ^19>
Or enhance an already defined query:
iex> require Ecto.Query
iex> flop = %Flop{limit: 10}
iex> Flop.Pet |> Ecto.Query.where(species: "dog") |> Flop.query(flop)
#Ecto.Query<from p0 in Flop.Pet, where: p0.species == \"dog\", limit: ^10>
Note that when using cursor-based pagination, the applied limit will be
`first + 1` or `last + 1`. The extra record is removed by `Flop.run/3`.
"""
@spec query(Queryable.t(), Flop.t(), [option()]) :: Queryable.t()
def query(q, %Flop{} = flop, opts \\ []) do
q
|> filter(flop, opts)
|> order_by(flop, opts)
|> paginate(flop, opts)
end
@doc """
Applies the given Flop to the given queryable and returns all matchings
entries.
iex> Flop.all(Flop.Pet, %Flop{}, repo: Flop.Repo)
[]
You can also configure a default repo in your config files:
config :flop, repo: MyApp.Repo
This allows you to omit the third argument:
iex> Flop.all(Flop.Pet, %Flop{})
[]
Note that when using cursor-based pagination, the applied limit will be
`first + 1` or `last + 1`. The extra record is removed by `Flop.run/3`, but
not by this function.
"""
@doc since: "0.6.0"
@spec all(Queryable.t(), Flop.t(), [option()]) :: [any]
def all(q, %Flop{} = flop, opts \\ []) do
apply_on_repo(:all, "all", [query(q, flop, opts)], opts)
end
@doc """
Applies the given Flop to the given queryable, retrieves the data and the
meta data.
This function does not validate the given flop parameters. You can validate
the parameters with `Flop.validate/2` or `Flop.validate!/2`, or you can use
`Flop.validate_and_run/3` or `Flop.validate_and_run!/3` instead of this
function.
iex> {data, meta} = Flop.run(Flop.Pet, %Flop{})
iex> data == []
true
iex> match?(%Flop.Meta{}, meta)
true
"""
@doc since: "0.6.0"
@spec run(Queryable.t(), Flop.t(), [option()]) :: {[any], Meta.t()}
def run(q, flop, opts \\ [])
def run(
q,
%Flop{
before: nil,
first: first,
last: nil
} = flop,
opts
)
when is_integer(first) do
results = all(q, flop, opts)
{Enum.take(results, first), meta(results, flop, opts)}
end
def run(
q,
%Flop{
after: nil,
first: nil,
last: last
} = flop,
opts
)
when is_integer(last) do
results = all(q, flop, opts)
page_data =
results
|> Enum.take(last)
|> Enum.reverse()
{page_data, meta(results, flop, opts)}
end
def run(q, %Flop{} = flop, opts) do
{all(q, flop, opts), meta(q, flop, opts)}
end
@doc """
Validates the given flop parameters and retrieves the data and meta data on
success.
iex> {:ok, {[], %Flop.Meta{}}} =
...> Flop.validate_and_run(Flop.Pet, %Flop{}, for: Flop.Pet)
iex> {:error, %Flop.Meta{} = meta} =
...> Flop.validate_and_run(Flop.Pet, %Flop{limit: -1})
iex> meta.errors
[
limit: [
{"must be greater than %{number}",
[validation: :number, kind: :greater_than, number: 0]}
]
]
## Options
- `for`: Passed to `Flop.validate/2`.
- `repo`: The `Ecto.Repo` module. Required if no default repo is configured.
- `cursor_value_func`: An arity-2 function to be used to retrieve an
unencoded cursor value from a query result item and the `order_by` fields.
Defaults to `Flop.Cursor.get_cursor_from_node/2`.
"""
@doc since: "0.6.0"
@spec validate_and_run(Queryable.t(), map | Flop.t(), [option()]) ::
{:ok, {[any], Meta.t()}} | {:error, Meta.t()}
def validate_and_run(q, map_or_flop, opts \\ []) do
with {:ok, flop} <- validate(map_or_flop, opts) do
{:ok, run(q, flop, opts)}
end
end
@doc """
Same as `Flop.validate_and_run/3`, but raises on error.
"""
@doc since: "0.6.0"
@spec validate_and_run!(Queryable.t(), map | Flop.t(), [option()]) ::
{[any], Meta.t()}
def validate_and_run!(q, map_or_flop, opts \\ []) do
flop = validate!(map_or_flop, opts)
run(q, flop, opts)
end
@doc """
Returns the total count of entries matching the filter conditions of the
Flop.
The pagination and ordering option are disregarded.
iex> Flop.count(Flop.Pet, %Flop{}, repo: Flop.Repo)
0
You can also configure a default repo in your config files:
config :flop, repo: MyApp.Repo
This allows you to omit the third argument:
iex> Flop.count(Flop.Pet, %Flop{})
0
"""
@doc since: "0.6.0"
@spec count(Queryable.t(), Flop.t(), [option()]) :: non_neg_integer
def count(q, %Flop{} = flop, opts \\ []) do
apply_on_repo(:aggregate, "count", [filter(q, flop, opts), :count], opts)
end
@doc """
Returns meta information for the given query and flop that can be used for
building the pagination links.
iex> Flop.meta(Flop.Pet, %Flop{limit: 10}, repo: Flop.Repo)
%Flop.Meta{
current_offset: 0,
current_page: 1,
end_cursor: nil,
flop: %Flop{limit: 10},
has_next_page?: false,
has_previous_page?: false,
next_offset: nil,
next_page: nil,
page_size: 10,
previous_offset: nil,
previous_page: nil,
start_cursor: nil,
total_count: 0,
total_pages: 0
}
The function returns both the current offset and the current page, regardless
of the pagination type. If the offset lies in between pages, the current page
number is rounded up. This means that it is possible that the values for
`current_page` and `next_page` can be identical. This can only occur if you
use offset/limit based pagination with arbitrary offsets, but in that case,
you will use the `previous_offset`, `current_offset` and `next_offset` values
to render the pagination links anyway, so this shouldn't be a problem.
Unless cursor-based pagination is used, this function will run a query to
figure get the total count of matching records.
"""
@doc since: "0.6.0"
@spec meta(Queryable.t() | [any], Flop.t(), [option()]) :: Meta.t()
def meta(query_or_results, flop, opts \\ [])
def meta(
results,
%Flop{
first: first,
order_by: order_by,
before: nil,
last: nil
} = flop,
opts
)
when is_list(results) and is_integer(first) do
{start_cursor, end_cursor} =
results
|> Enum.take(first)
|> Cursor.get_cursors(order_by, opts)
%Meta{
flop: flop,
start_cursor: start_cursor,
end_cursor: end_cursor,
has_next_page?: length(results) > first,
has_previous_page?: !is_nil(flop.after),
page_size: first,
schema: opts[:for]
}
end
def meta(
results,
%Flop{
after: nil,
first: nil,
order_by: order_by,
last: last
} = flop,
opts
)
when is_list(results) and is_integer(last) do
{start_cursor, end_cursor} =
results
|> Enum.take(last)
|> Enum.reverse()
|> Cursor.get_cursors(order_by, opts)
%Meta{
flop: flop,
start_cursor: start_cursor,
end_cursor: end_cursor,
has_next_page?: !is_nil(flop.before),
has_previous_page?: length(results) > last,
page_size: last,
schema: opts[:for]
}
end
def meta(q, %Flop{} = flop, opts) do
repo = option_or_default(opts, :repo) || raise no_repo_error("meta")
opts = Keyword.put(opts, :repo, repo)
total_count = count(q, flop, opts)
page_size = flop.page_size || flop.limit
total_pages = get_total_pages(total_count, page_size)
current_offset = get_current_offset(flop)
current_page = get_current_page(flop, total_pages)
{has_previous_page?, previous_offset, previous_page} =
get_previous(current_offset, current_page, page_size)
{has_next_page?, next_offset, next_page} =
get_next(
current_offset,
current_page,
page_size,
total_count,
total_pages
)
%Meta{
current_offset: current_offset,
current_page: current_page,
flop: flop,
has_next_page?: has_next_page?,
has_previous_page?: has_previous_page?,
next_offset: next_offset,
next_page: next_page,
page_size: page_size,
previous_offset: previous_offset,
previous_page: previous_page,
schema: opts[:for],
total_count: total_count,
total_pages: total_pages
}
end
defp get_previous(offset, current_page, limit) do
has_previous? = offset > 0
previous_offset = if has_previous?, do: max(0, offset - limit), else: nil
previous_page = if current_page > 1, do: current_page - 1, else: nil
{has_previous?, previous_offset, previous_page}
end
defp get_next(_, _, nil = _page_size, _, _) do
{false, nil, nil}
end
defp get_next(current_offset, _, page_size, total_count, _)
when current_offset + page_size >= total_count do
{false, nil, nil}
end
defp get_next(current_offset, current_page, page_size, _, total_pages) do
{true, current_offset + page_size, min(total_pages, current_page + 1)}
end
defp get_total_pages(0, _), do: 0
defp get_total_pages(_, nil), do: 1
defp get_total_pages(total_count, limit), do: ceil(total_count / limit)
defp get_current_offset(%Flop{offset: nil, page: nil}), do: 0
defp get_current_offset(%Flop{offset: nil, page: page, page_size: page_size}),
do: (page - 1) * page_size
defp get_current_offset(%Flop{offset: offset}), do: offset
defp get_current_page(%Flop{offset: nil, page: nil}, _), do: 1
defp get_current_page(%Flop{offset: nil, page: page}, _), do: page
defp get_current_page(%Flop{limit: limit, offset: offset, page: nil}, total),
do: min(ceil(offset / limit) + 1, total)
## Ordering
@doc """
Applies the `order_by` and `order_directions` parameters of a `t:Flop.t/0`
to an `t:Ecto.Queryable.t/0`.
Used by `Flop.query/2`.
"""
@spec order_by(Queryable.t(), Flop.t(), [option()]) :: Queryable.t()
def order_by(q, flop, opts \\ [])
def order_by(q, %Flop{order_by: nil}, _opts), do: q
# For backwards cursor pagination
def order_by(
q,
%Flop{
last: last,
order_by: fields,
order_directions: directions,
first: nil,
after: nil,
offset: nil
},
opts
)
when is_integer(last) do
reversed_order =
fields
|> prepare_order(directions)
|> reverse_ordering()
case opts[:for] do
nil ->
Query.order_by(q, ^reversed_order)
module ->
struct = struct(module)
Enum.reduce(reversed_order, q, fn expr, acc_q ->
Flop.Schema.apply_order_by(struct, acc_q, expr)
end)
end
end
def order_by(
q,
%Flop{order_by: fields, order_directions: directions},
opts
) do
case opts[:for] do
nil ->
Query.order_by(q, ^prepare_order(fields, directions))
module ->
struct = struct(module)
fields
|> prepare_order(directions)
|> Enum.reduce(q, fn expr, acc_q ->
Flop.Schema.apply_order_by(struct, acc_q, expr)
end)
end
end
@spec prepare_order([atom], [order_direction()]) :: [
{order_direction(), atom}
]
defp prepare_order(fields, directions) do
directions = directions || []
field_count = length(fields)
direction_count = length(directions)
directions =
if direction_count < field_count,
do: directions ++ List.duplicate(:asc, field_count - direction_count),
else: directions
Enum.zip(directions, fields)
end
## Pagination
@doc """
Applies the pagination parameters of a `t:Flop.t/0` to an
`t:Ecto.Queryable.t/0`.
The function supports both `offset`/`limit` based pagination and
`page`/`page_size` based pagination.
If you validated the `t:Flop.t/0` with `Flop.validate/1` before, you can be
sure that the given `t:Flop.t/0` only has pagination parameters set for one
pagination method. If you pass an unvalidated `t:Flop.t/0` that has
pagination parameters set for multiple pagination methods, this function
will arbitrarily only apply one of the pagination methods.
Used by `Flop.query/2`.
"""
@spec paginate(Queryable.t(), Flop.t(), [option()]) :: Queryable.t()
def paginate(q, flop, opts \\ [])
def paginate(q, %Flop{limit: limit, offset: offset}, _)
when (is_integer(limit) and limit >= 1) or
(is_integer(offset) and offset >= 0) do
q
|> limit(limit)
|> offset(offset)
end
def paginate(q, %Flop{page: page, page_size: page_size}, _)
when is_integer(page) and is_integer(page_size) and
page >= 1 and page_size >= 1 do
q
|> limit(page_size)
|> offset((page - 1) * page_size)
end
def paginate(
q,
%Flop{
first: first,
after: nil,
before: nil,
last: nil,
limit: nil
},
_
)
when is_integer(first),
do: limit(q, first + 1)
def paginate(
q,
%Flop{
first: first,
after: after_,
order_by: order_by,
order_directions: order_directions,
before: nil,
last: nil,
limit: nil
},
opts
)
when is_integer(first) do
orderings = prepare_order(order_by, order_directions)
q
|> apply_cursor(after_, orderings, opts)
|> limit(first + 1)
end
def paginate(
q,
%Flop{
last: last,
before: before,
order_by: order_by,
order_directions: order_directions,
first: nil,
after: nil,
limit: nil
},
opts
)
when is_integer(last) do
prepared_order_reversed =
order_by
|> prepare_order(order_directions)
|> reverse_ordering()
q
|> apply_cursor(before, prepared_order_reversed, opts)
|> limit(last + 1)
end
def paginate(q, _, _), do: q
## Offset/limit pagination
@spec limit(Queryable.t(), pos_integer | nil) :: Queryable.t()
defp limit(q, nil), do: q
defp limit(q, limit), do: Query.limit(q, ^limit)
@spec offset(Queryable.t(), non_neg_integer | nil) :: Queryable.t()
defp offset(q, nil), do: q
defp offset(q, offset), do: Query.offset(q, ^offset)
## Cursor pagination helpers
@spec apply_cursor(
Queryable.t(),
map() | nil,
[order_direction()],
keyword
) :: Queryable.t()
defp apply_cursor(q, nil, _, _), do: q
defp apply_cursor(q, cursor, ordering, opts) do
cursor = Cursor.decode!(cursor)
where_dynamic =
case opts[:for] do
nil ->
cursor_dynamic(ordering, cursor)
module ->
module
|> struct()
|> Flop.Schema.cursor_dynamic(ordering, cursor)
end
Query.where(q, ^where_dynamic)
end
defp cursor_dynamic([], _), do: true
defp cursor_dynamic([{direction, field}], cursor) do
field_cursor = cursor[field]
if is_nil(field_cursor) do
true
else
case direction do
dir when dir in [:asc, :asc_nulls_first, :asc_nulls_last] ->
Query.dynamic([r], field(r, ^field) > ^field_cursor)
dir when dir in [:desc, :desc_nulls_first, :desc_nulls_last] ->
Query.dynamic([r], field(r, ^field) < ^field_cursor)
end
end
end
defp cursor_dynamic([{direction, field} | [{_, _} | _] = tail], cursor) do
field_cursor = cursor[field]
if is_nil(field_cursor) do
cursor_dynamic(tail, cursor)
else
case direction do
dir when dir in [:asc, :asc_nulls_first, :asc_nulls_last] ->
Query.dynamic(
[r],
field(r, ^field) >= ^field_cursor and
(field(r, ^field) > ^field_cursor or
^cursor_dynamic(tail, cursor))
)
dir when dir in [:desc, :desc_nulls_first, :desc_nulls_last] ->
Query.dynamic(
[r],
field(r, ^field) <= ^field_cursor and
(field(r, ^field) < ^field_cursor or
^cursor_dynamic(tail, cursor))
)
end
end
end
@spec reverse_ordering([order_direction()]) :: [order_direction()]
defp reverse_ordering(order_directions) do
Enum.map(order_directions, fn
{:desc, field} -> {:asc, field}
{:desc_nulls_last, field} -> {:asc_nulls_first, field}
{:desc_nulls_first, field} -> {:asc_nulls_last, field}
{:asc, field} -> {:desc, field}
{:asc_nulls_last, field} -> {:desc_nulls_first, field}
{:asc_nulls_first, field} -> {:desc_nulls_last, field}
end)
end
## Filter
@doc """
Applies the `filter` parameter of a `t:Flop.t/0` to an `t:Ecto.Queryable.t/0`.
Used by `Flop.query/2`.
"""
@spec filter(Queryable.t(), Flop.t(), [option()]) :: Queryable.t()
def filter(q, flop, opt \\ [])
def filter(q, %Flop{filters: nil}, _), do: q
def filter(q, %Flop{filters: []}, _), do: q
def filter(q, %Flop{filters: filters}, opts) when is_list(filters) do
schema_struct =
case opts[:for] do
nil -> nil
module -> struct(module)
end
conditions =
Enum.reduce(filters, true, &Builder.filter(schema_struct, &1, &2))
Query.where(q, ^conditions)
end
## Validation
@doc """
Validates a `t:Flop.t/0`.
## Examples
iex> params = %{"limit" => 10, "offset" => 0, "texture" => "fluffy"}
iex> Flop.validate(params)
{:ok,
%Flop{
filters: [],
limit: 10,
offset: 0,
order_by: nil,
order_directions: nil,
page: nil,
page_size: nil
}}
iex> flop = %Flop{offset: -1}
iex> {:error, %Flop.Meta{} = meta} = Flop.validate(flop)
iex> meta.errors
[
offset: [
{"must be greater than or equal to %{number}",
[validation: :number, kind: :greater_than_or_equal_to, number: 0]}
]
]
It also makes sure that only one pagination method is used.
iex> params = %{limit: 10, offset: 0, page: 5, page_size: 10}
iex> {:error, %Flop.Meta{} = meta} = Flop.validate(params)
iex> meta.errors
[limit: [{"cannot combine multiple pagination types", []}]]
If you derived `Flop.Schema` in your Ecto schema to define the filterable
and sortable fields, you can pass the module name to the function to validate
that only allowed fields are used. The function will also apply any default
values set for the schema.
iex> params = %{"order_by" => ["species"]}
iex> {:error, %Flop.Meta{} = meta} = Flop.validate(params, for: Flop.Pet)
iex> [order_by: [{msg, [_, {_, enum}]}]] = meta.errors
iex> msg
"has an invalid entry"
iex> enum
[:name, :age, :owner_name, :owner_age]
Note that currently, trying to use an existing field that is not allowed as
seen above will result in the error message `has an invalid entry`, while
trying to use a field name that does not exist in the schema (or more
precisely: a field name that doesn't exist as an atom) will result in
the error message `is invalid`. This might change in the future.
"""
@spec validate(Flop.t() | map, [option()]) ::
{:ok, Flop.t()} | {:error, Meta.t()}
def validate(flop_or_map, opts \\ [])
def validate(%Flop{} = flop, opts) do
flop
|> flop_struct_to_map()
|> validate(opts)
end
def validate(%{} = params, opts) do
result =
params
|> Flop.Validation.changeset(opts)
|> apply_action(:replace)
case result do
{:ok, _} = r ->
r
{:error, %Changeset{} = changeset} ->
Logger.debug("Invalid Flop: #{inspect(changeset)}")
{:error,
%Meta{
errors: convert_errors(changeset),
params: convert_params(params),
schema: opts[:for]
}}
end
end
defp convert_errors(changeset) do
changeset
|> Changeset.traverse_errors(& &1)
|> map_to_keyword()
end
defp map_to_keyword(%{} = map) do
Enum.into(map, [], fn {key, value} -> {key, map_to_keyword(value)} end)
end
defp map_to_keyword(list) when is_list(list) do
Enum.map(list, &map_to_keyword/1)
end
defp map_to_keyword(value), do: value
defp flop_struct_to_map(%Flop{} = flop) do
flop
|> Map.from_struct()
|> Map.update!(:filters, &filters_to_maps/1)
|> Enum.reject(fn {_, value} -> is_nil(value) end)
|> Enum.into(%{})
end
defp filters_to_maps(nil), do: nil
defp filters_to_maps(filters) when is_list(filters),
do: Enum.map(filters, &filter_to_map/1)
defp filter_to_map(%Filter{} = filter) do
filter
|> Map.from_struct()
|> Enum.reject(fn {_, value} -> is_nil(value) end)
|> Enum.into(%{})
end
defp filter_to_map(%{} = filter), do: filter
defp convert_params(params) do
params
|> map_to_string_keys()
|> filters_to_list()
end
defp filters_to_list(%{"filters" => filters} = params) when is_map(filters) do
filters =
filters
|> Enum.map(fn {index, filter} -> {String.to_integer(index), filter} end)
|> Enum.sort_by(fn {index, _} -> index end)
|> Enum.map(fn {_, filter} -> filter end)
Map.put(params, "filters", filters)
end
defp filters_to_list(params), do: params
defp map_to_string_keys(%{} = params) do
Enum.into(params, %{}, fn
{key, value} when is_atom(key) ->
{Atom.to_string(key), map_to_string_keys(value)}
{key, value} when is_binary(key) ->
{key, map_to_string_keys(value)}
end)
end
defp map_to_string_keys(values) when is_list(values),
do: Enum.map(values, &map_to_string_keys/1)
defp map_to_string_keys(value), do: value
@doc """
Same as `Flop.validate/2`, but raises an `Ecto.InvalidChangesetError` if the
parameters are invalid.
"""
@doc since: "0.5.0"
@spec validate!(Flop.t() | map, [option()]) :: Flop.t()
def validate!(flop_or_map, opts \\ []) do
case validate(flop_or_map, opts) do
{:ok, flop} ->
flop
{:error, %Meta{errors: errors, params: params}} ->
raise Flop.InvalidParamsError, errors: errors, params: params
end
end
@doc """
Sets the page value of a `Flop` struct while also removing/converting
pagination parameters for other pagination types.
iex> set_page(%Flop{page: 2, page_size: 10}, 6)
%Flop{page: 6, page_size: 10}
iex> set_page(%Flop{limit: 10, offset: 20}, 8)
%Flop{limit: nil, offset: nil, page: 8, page_size: 10}
iex> set_page(%Flop{page: 2, page_size: 10}, "6")
%Flop{page: 6, page_size: 10}
The page number will not be allowed to go below 1.
iex> set_page(%Flop{}, -5)
%Flop{page: 1}
"""
@doc since: "0.12.0"
@spec set_page(Flop.t(), pos_integer | binary) :: Flop.t()
def set_page(%Flop{} = flop, page) when is_integer(page) do
%{
flop
| after: nil,
before: nil,
first: nil,
last: nil,
limit: nil,
offset: nil,
page_size: flop.page_size || flop.limit || flop.first || flop.last,
page: max(page, 1)
}
end
def set_page(%Flop{} = flop, page) when is_binary(page) do
set_page(flop, String.to_integer(page))
end
@doc """
Sets the page of a Flop struct to the previous page, but not less than 1.
## Examples
iex> to_previous_page(%Flop{page: 5})
%Flop{page: 4}
iex> to_previous_page(%Flop{page: 1})
%Flop{page: 1}
iex> to_previous_page(%Flop{page: -2})
%Flop{page: 1}
"""
@doc since: "0.15.0"
@spec to_previous_page(Flop.t()) :: Flop.t()
def to_previous_page(%Flop{page: 1} = flop), do: flop
def to_previous_page(%Flop{page: page} = flop)
when is_integer(page) and page < 1,
do: %{flop | page: 1}
def to_previous_page(%Flop{page: page} = flop) when is_integer(page),
do: %{flop | page: page - 1}
@doc """
Sets the page of a Flop struct to the next page.
If the total number of pages is given as the second argument, the page number
will not be increased if the last page has already been reached. You can get
the total number of pages from the `Flop.Meta` struct.
## Examples
iex> to_next_page(%Flop{page: 5})
%Flop{page: 6}
iex> to_next_page(%Flop{page: 5}, 6)
%Flop{page: 6}
iex> to_next_page(%Flop{page: 6}, 6)
%Flop{page: 6}
iex> to_next_page(%Flop{page: 7}, 6)
%Flop{page: 6}
iex> to_next_page(%Flop{page: -5})
%Flop{page: 1}
"""
@doc since: "0.15.0"
@spec to_next_page(Flop.t(), non_neg_integer | nil) :: Flop.t()
def to_next_page(flop, total_pages \\ nil)
def to_next_page(%Flop{page: page} = flop, _)
when is_integer(page) and page < 0,
do: %{flop | page: 1}
def to_next_page(%Flop{page: page} = flop, nil), do: %{flop | page: page + 1}
def to_next_page(%Flop{page: page} = flop, total_pages)
when is_integer(total_pages) and page < total_pages,
do: %{flop | page: page + 1}
def to_next_page(%Flop{} = flop, total_pages)
when is_integer(total_pages),
do: %{flop | page: total_pages}
@doc """
Sets the offset value of a `Flop` struct while also removing/converting
pagination parameters for other pagination types.
iex> set_offset(%Flop{limit: 10, offset: 10}, 20)
%Flop{offset: 20, limit: 10}
iex> set_offset(%Flop{page: 5, page_size: 10}, 20)
%Flop{limit: 10, offset: 20, page: nil, page_size: nil}
iex> set_offset(%Flop{limit: 10, offset: 10}, "20")
%Flop{offset: 20, limit: 10}
The offset will not be allowed to go below 0.
iex> set_offset(%Flop{}, -5)
%Flop{offset: 0}
"""
@doc since: "0.15.0"
@spec set_offset(Flop.t(), non_neg_integer | binary) :: Flop.t()
def set_offset(%Flop{} = flop, offset) when is_integer(offset) do
%{
flop
| after: nil,
before: nil,
first: nil,
last: nil,
limit: flop.limit || flop.page_size || flop.first || flop.last,
offset: max(offset, 0),
page_size: nil,
page: nil
}
end
def set_offset(%Flop{} = flop, offset) when is_binary(offset) do
set_offset(flop, String.to_integer(offset))
end
@doc """
Sets the offset of a Flop struct to the page depending on the limit.
## Examples
iex> to_previous_offset(%Flop{offset: 20, limit: 10})
%Flop{offset: 10, limit: 10}
iex> to_previous_offset(%Flop{offset: 5, limit: 10})
%Flop{offset: 0, limit: 10}
iex> to_previous_offset(%Flop{offset: -2, limit: 10})
%Flop{offset: 0, limit: 10}
"""
@doc since: "0.15.0"
@spec to_previous_offset(Flop.t()) :: Flop.t()
def to_previous_offset(%Flop{offset: 0} = flop), do: flop
def to_previous_offset(%Flop{offset: offset, limit: limit} = flop)
when is_integer(limit) and is_integer(offset),
do: %{flop | offset: max(offset - limit, 0)}
@doc """
Sets the offset of a Flop struct to the next page depending on the limit.
If the total count is given as the second argument, the offset will not be
increased if the last page has already been reached. You can get the total
count from the `Flop.Meta` struct. If the Flop has an offset beyond the total
count, the offset will be set to the last page.
## Examples
iex> to_next_offset(%Flop{offset: 10, limit: 5})
%Flop{offset: 15, limit: 5}
iex> to_next_offset(%Flop{offset: 15, limit: 5}, 21)
%Flop{offset: 20, limit: 5}
iex> to_next_offset(%Flop{offset: 15, limit: 5}, 20)
%Flop{offset: 15, limit: 5}
iex> to_next_offset(%Flop{offset: 28, limit: 5}, 22)
%Flop{offset: 20, limit: 5}
iex> to_next_offset(%Flop{offset: -5, limit: 20})
%Flop{offset: 0, limit: 20}
"""
@doc since: "0.15.0"
@spec to_next_offset(Flop.t(), non_neg_integer | nil) :: Flop.t()
def to_next_offset(flop, total_count \\ nil)
def to_next_offset(%Flop{limit: limit, offset: offset} = flop, _)
when is_integer(limit) and is_integer(offset) and offset < 0,
do: %{flop | offset: 0}
def to_next_offset(%Flop{limit: limit, offset: offset} = flop, nil)
when is_integer(limit) and is_integer(offset),
do: %{flop | offset: offset + limit}
def to_next_offset(%Flop{limit: limit, offset: offset} = flop, total_count)
when is_integer(limit) and
is_integer(offset) and
is_integer(total_count) and offset >= total_count do
%{flop | offset: (ceil(total_count / limit) - 1) * limit}
end
def to_next_offset(%Flop{limit: limit, offset: offset} = flop, total_count)
when is_integer(limit) and
is_integer(offset) and
is_integer(total_count) do
case offset + limit do
new_offset when new_offset >= total_count -> flop
new_offset -> %{flop | offset: new_offset}
end
end
@doc """
Takes a `Flop.Meta` struct and returns a `Flop` struct with updated cursor
pagination params for going to either the previous or the next page.
See `to_previous_cursor/1` and `to_next_cursor/1` for details.
## Examples
iex> set_cursor(
...> %Flop.Meta{
...> flop: %Flop{first: 5, after: "a"},
...> has_previous_page?: true, start_cursor: "b"
...> },
...> :previous
...> )
%Flop{last: 5, before: "b"}
iex> set_cursor(
...> %Flop.Meta{
...> flop: %Flop{first: 5, after: "a"},
...> has_next_page?: true, end_cursor: "b"
...> },
...> :next
...> )
%Flop{first: 5, after: "b"}
"""
@doc since: "0.15.0"
@spec set_cursor(Meta.t(), :previous | :next) :: Flop.t()
def set_cursor(%Meta{} = meta, :previous), do: to_previous_cursor(meta)
def set_cursor(%Meta{} = meta, :next), do: to_next_cursor(meta)
@doc """
Takes a `Flop.Meta` struct and returns a `Flop` struct with updated cursor
pagination params for going to the previous page.
If there is no previous page, the `Flop` struct is return unchanged.
## Examples
iex> to_previous_cursor(
...> %Flop.Meta{
...> flop: %Flop{first: 5, after: "a"},
...> has_previous_page?: true, start_cursor: "b"
...> }
...> )
%Flop{last: 5, before: "b"}
iex> to_previous_cursor(
...> %Flop.Meta{
...> flop: %Flop{last: 5, before: "b"},
...> has_previous_page?: true, start_cursor: "a"
...> }
...> )
%Flop{last: 5, before: "a"}
iex> to_previous_cursor(
...> %Flop.Meta{
...> flop: %Flop{first: 5, after: "b"},
...> has_previous_page?: false, start_cursor: "a"
...> }
...> )
%Flop{first: 5, after: "b"}
"""
@doc since: "0.15.0"
@spec to_previous_cursor(Meta.t()) :: Flop.t()
def to_previous_cursor(%Meta{flop: flop, has_previous_page?: false}), do: flop
def to_previous_cursor(%Meta{
flop: flop,
has_previous_page?: true,
start_cursor: start_cursor
})
when is_binary(start_cursor) do
%{
flop
| before: start_cursor,
last: flop.last || flop.first || flop.page_size || flop.limit,
after: nil,
first: nil,
page: nil,
page_size: nil,
limit: nil,
offset: nil
}
end
@doc """
Takes a `Flop.Meta` struct and returns a `Flop` struct with updated cursor
pagination params for going to the next page.
If there is no next page, the `Flop` struct is return unchanged.
## Examples
iex> to_next_cursor(
...> %Flop.Meta{
...> flop: %Flop{first: 5, after: "a"},
...> has_next_page?: true, end_cursor: "b"
...> }
...> )
%Flop{first: 5, after: "b"}
iex> to_next_cursor(
...> %Flop.Meta{
...> flop: %Flop{last: 5, before: "b"},
...> has_next_page?: true, end_cursor: "a"
...> }
...> )
%Flop{first: 5, after: "a"}
iex> to_next_cursor(
...> %Flop.Meta{
...> flop: %Flop{first: 5, after: "a"},
...> has_next_page?: false, start_cursor: "b"
...> }
...> )
%Flop{first: 5, after: "a"}
"""
@doc since: "0.15.0"
@spec to_next_cursor(Meta.t()) :: Flop.t()
def to_next_cursor(%Meta{flop: flop, has_next_page?: false}), do: flop
def to_next_cursor(%Meta{
flop: flop,
has_next_page?: true,
end_cursor: end_cursor
})
when is_binary(end_cursor) do
%{
flop
| after: end_cursor,
first: flop.first || flop.last || flop.page_size || flop.limit,
before: nil,
last: nil,
page: nil,
page_size: nil,
limit: nil,
offset: nil
}
end
@doc """
Removes the `after` and `before` cursors from a Flop struct.
## Example
iex> reset_cursors(%Flop{after: "A"})
%Flop{}
iex> reset_cursors(%Flop{before: "A"})
%Flop{}
"""
@doc since: "0.15.0"
@spec reset_cursors(Flop.t()) :: Flop.t()
def reset_cursors(%Flop{} = flop), do: %{flop | after: nil, before: nil}
@doc """
Removes all filters from a Flop struct.
## Example
iex> reset_filters(%Flop{filters: [
...> %Flop.Filter{field: :name, value: "Jim"}
...> ]})
%Flop{filters: []}
"""
@doc since: "0.15.0"
@spec reset_filters(Flop.t()) :: Flop.t()
def reset_filters(%Flop{} = flop), do: %{flop | filters: []}
@doc """
Returns the current order direction for the given field.
## Examples
iex> flop = %Flop{order_by: [:name, :age], order_directions: [:desc]}
iex> current_order(flop, :name)
:desc
iex> current_order(flop, :age)
:asc
iex> current_order(flop, :species)
nil
"""
@doc since: "0.15.0"
@spec current_order(Flop.t(), atom) :: order_direction() | nil
def current_order(
%Flop{order_by: order_by, order_directions: order_directions},
field
)
when is_atom(field) do
get_order_direction(order_directions, get_index(order_by, field))
end
@doc """
Removes the order parameters from a Flop struct.
## Example
iex> reset_order(%Flop{order_by: [:name], order_directions: [:asc]})
%Flop{order_by: nil, order_directions: nil}
"""
@doc since: "0.15.0"
@spec reset_order(Flop.t()) :: Flop.t()
def reset_order(%Flop{} = flop),
do: %{flop | order_by: nil, order_directions: nil}
@doc """
Updates the `order_by` and `order_directions` values of a `Flop` struct.
- If the field is not in the current `order_by` value, it will be prepended to
the list. The order direction for the field will be set to `:asc`.
- If the field is already at the front of the `order_by` list, the order
direction will be reversed.
- If the field is already in the list, but not at the front, it will be moved
to the front and the order direction will be set to `:asc`.
## Example
iex> flop = push_order(%Flop{}, :name)
iex> flop.order_by
[:name]
iex> flop.order_directions
[:asc]
iex> flop = push_order(flop, :age)
iex> flop.order_by
[:age, :name]
iex> flop.order_directions
[:asc, :asc]
iex> flop = push_order(flop, :age)
iex> flop.order_by
[:age, :name]
iex> flop.order_directions
[:desc, :asc]
iex> flop = push_order(flop, :species)
iex> flop.order_by
[:species, :age, :name]
iex> flop.order_directions
[:asc, :desc, :asc]
iex> flop = push_order(flop, :age)
iex> flop.order_by
[:age, :species, :name]
iex> flop.order_directions
[:asc, :asc, :asc]
If a string is passed as the second argument, it will be converted to an atom
using `String.to_existing_atom/1`. If the atom does not exist, the `Flop`
struct will be returned unchanged.
iex> flop = push_order(%Flop{}, "name")
iex> flop.order_by
[:name]
iex> flop = push_order(%Flop{}, "this_atom_does_not_exist")
iex> flop.order_by
nil
Since the pagination cursor depends on the sort order, the `:before` and
`:after` parameters are reset.
iex> push_order(%Flop{order_by: [:id], after: "ABC"}, :name)
%Flop{order_by: [:name, :id], order_directions: [:asc], after: nil}
iex> push_order(%Flop{order_by: [:id], before: "DEF"}, :name)
%Flop{order_by: [:name, :id], order_directions: [:asc], before: nil}
"""
@spec push_order(Flop.t(), atom | String.t()) :: Flop.t()
@doc since: "0.10.0"
def push_order(
%Flop{order_by: order_by, order_directions: order_directions} = flop,
field
)
when is_atom(field) do
previous_index = get_index(order_by, field)
previous_direction = get_order_direction(order_directions, previous_index)
new_direction = new_order_direction(previous_index, previous_direction)
{order_by, order_directions} =
get_new_order(
order_by,
order_directions,
field,
new_direction,
previous_index
)
%{
flop
| after: nil,
before: nil,
order_by: order_by,
order_directions: order_directions
}
end
def push_order(flop, field) when is_binary(field) do
push_order(flop, String.to_existing_atom(field))
rescue
_e in ArgumentError -> flop
end
defp get_index(nil, _field), do: nil
defp get_index(order_by, field), do: Enum.find_index(order_by, &(&1 == field))
defp get_order_direction(_, nil), do: nil
defp get_order_direction(nil, _), do: :asc
defp get_order_direction(directions, index),
do: Enum.at(directions, index, :asc)
defp new_order_direction(0, :asc), do: :desc
defp new_order_direction(0, :asc_nulls_first), do: :desc_nulls_last
defp new_order_direction(0, :asc_nulls_last), do: :desc_nulls_first
defp new_order_direction(0, :desc), do: :asc
defp new_order_direction(0, :desc_nulls_first), do: :asc_nulls_last
defp new_order_direction(0, :desc_nulls_last), do: :asc_nulls_first
defp new_order_direction(_, _), do: :asc
defp get_new_order(
order_by,
order_directions,
field,
new_direction,
previous_index
) do
{order_by, order_directions} =
if previous_index do
{List.delete_at(order_by, previous_index),
List.delete_at(order_directions, previous_index)}
else
{order_by, order_directions}
end
{[field | order_by || []], [new_direction | order_directions || []]}
end
defp apply_on_repo(repo_fn, flop_fn, args, opts) do
repo = option_or_default(opts, :repo) || raise no_repo_error(flop_fn)
opts =
if prefix = option_or_default(opts, :prefix) do
[prefix: prefix]
else
[]
end
apply(repo, repo_fn, args ++ [opts])
end
defp option_or_default(opts, key) do
opts[key] || Application.get_env(:flop, key)
end
@doc """
Returns the option with the given key.
The look-up order is:
1. the keyword list passed as the second argument
2. the schema module that derives `Flop.Schema`, if the passed list includes
the `:for` option
3. the application environment
4. the default passed as the last argument
"""
@doc since: "0.11.0"
@spec get_option(atom, [option()], any) :: any
def get_option(key, opts, default \\ nil) do
case opts[key] do
nil ->
case schema_option(opts[:for], key) do
nil -> global_option(key, default)
v -> v
end
v ->
v
end
end
defp schema_option(module, key)
when is_atom(module) and module != nil and
key in [
:default_limit,
:default_order,
:filterable_fields,
:max_limit,
:pagination_types,
:sortable
] do
apply(Flop.Schema, key, [struct(module)])
end
defp schema_option(_, _), do: nil
defp global_option(key, default) when is_atom(key) do
Application.get_env(:flop, key, default)
end
@doc """
Converts key/value filter parameters at the root of a map, converts them into
a list of filter parameter maps and nests them under the `:filters` key.
The second argument is a list of fields as atoms.
The `opts` argument is passed to `map_to_filter_params/2`.
## Examples
iex> nest_filters(%{name: "Peter", page_size: 10}, [:name])
%{filters: [%{field: :name, op: :==, value: "Peter"}], page_size: 10}
iex> nest_filters(%{"name" => "Peter"}, [:name])
%{"filters" => [%{"field" => "name", "op" => :==, "value" => "Peter"}]}
iex> nest_filters(%{name: "Peter"}, [:name], operators: %{name: :!=})
%{filters: [%{field: :name, op: :!=, value: "Peter"}]}
"""
@doc since: "0.15.0"
def nest_filters(%{} = args, fields, opts \\ []) when is_list(fields) do
fields = fields ++ Enum.map(fields, &Atom.to_string/1)
filters =
args
|> Map.take(fields)
|> map_to_filter_params(opts)
key = if has_atom_keys?(args), do: :filters, else: "filters"
args
|> Map.put(key, filters)
|> Map.drop(fields)
end
defp has_atom_keys?(%{} = map) do
map
|> Map.keys()
|> List.first()
|> is_atom()
end
@doc """
Converts a map of filter conditions into a list of Flop filter params.
The default operator is `:==`. `nil` values are excluded from the result.
iex> map_to_filter_params(%{name: "George", age: 8, species: nil})
[
%{field: :age, op: :==, value: 8},
%{field: :name, op: :==, value: "George"}
]
iex> map_to_filter_params(%{"name" => "George", "age" => 8, "cat" => true})
[
%{"field" => "age", "op" => :==, "value" => 8},
%{"field" => "cat", "op" => :==, "value" => true},
%{"field" => "name", "op" => :==, "value" => "George"}
]
You can optionally pass a mapping from field names to operators as a map
with atom keys.
iex> map_to_filter_params(
...> %{name: "George", age: 8, species: nil},
...> operators: %{name: :ilike_and}
...> )
[
%{field: :age, op: :==, value: 8},
%{field: :name, op: :ilike_and, value: "George"}
]
iex> map_to_filter_params(
...> %{"name" => "George", "age" => 8, "cat" => true},
...> operators: %{name: :ilike_and, age: :<=}
...> )
[
%{"field" => "age", "op" => :<=, "value" => 8},
%{"field" => "cat", "op" => :==, "value" => true},
%{"field" => "name", "op" => :ilike_and, "value" => "George"}
]
"""
@doc since: "0.14.0"
@spec map_to_filter_params(map, keyword) :: [map]
def map_to_filter_params(%{} = map, opts \\ []) do
operators = opts[:operators]
map
|> Stream.reject(fn
{_, nil} -> true
_ -> false
end)
|> Enum.map(fn
{field, value} when is_atom(field) ->
%{
field: field,
op: op_from_mapping(field, operators),
value: value
}
{field, value} when is_binary(field) ->
%{
"field" => field,
"op" => op_from_mapping(field, operators),
"value" => value
}
end)
end
defp op_from_mapping(_field, nil), do: :==
defp op_from_mapping(field, %{} = operators) when is_atom(field) do
Map.get(operators, field, :==)
end
defp op_from_mapping(field, %{} = operators) when is_binary(field) do
atom_key = String.to_existing_atom(field)
Map.get(operators, atom_key, :==)
rescue
ArgumentError -> :==
end
# coveralls-ignore-start
defp no_repo_error(function_name),
do: """
No repo specified. You can specify the repo either by passing it
explicitly:
Flop.#{function_name}(MyApp.Item, %Flop{}, repo: MyApp.Repo)
Or you can configure a default repo in your config:
config :flop, repo: MyApp.Repo
"""
# coveralls-ignore-end
end | lib/flop.ex | 0.806853 | 0.617686 | flop.ex | starcoder |
defmodule PersistentList.Day02 do
alias PersistentList.Day02, as: List
defstruct [:head, :tail]
defimpl String.Chars, for: PersistentList.Day02 do
def to_string(list), do: "[" <> stringify(list) <> "]"
defp stringify(%List{head: nil}), do: ""
defp stringify(
%List{
head: head,
tail: %List{
head: nil
}
}
), do: "#{head}"
defp stringify(%List{head: head, tail: tail}), do: "#{head}, " <> stringify(tail)
end
def new(), do: %List{}
def append(list, item), do: %List{head: item, tail: list}
def prepend(%List{head: nil, tail: nil} = empty, item),
do: empty
|> append(item)
def prepend(%List{head: head, tail: tail}, item),
do: tail
|> prepend(item)
|> append(head)
def concat(%List{head: nil, tail: nil}, other), do: other
def concat(%List{head: head, tail: tail}, other),
do: tail
|> concat(other)
|> append(head)
def drop(%List{head: nil} = empty, _), do: empty
def drop(list, num) when num == 0, do: list
def drop(%List{tail: tail}, num),
do: tail
|> drop(num - 1)
def drop_while(%List{head: nil} = empty, _), do: empty
def drop_while(%List{head: head, tail: tail} = list, predicate), do:
unless predicate.(head),
do: list,
else: tail
|> drop_while(predicate)
def take(%List{head: nil} = empty, _), do: empty
def take(_, num) when num == 0, do: %List{}
def take(%List{head: head, tail: tail}, num),
do: tail
|> take(num - 1)
|> append(head)
def take_while(%List{head: nil} = empty, _), do: empty
def take_while(%List{head: head, tail: tail}, predicate), do:
if predicate.(head),
do: tail
|> take_while(predicate)
|> append(head),
else: %List{}
def filter(%List{head: nil} = empty, _), do: empty
def filter(%List{head: head, tail: tail}, predicate) do
unless predicate.(head),
do: tail
|> filter(predicate)
|> append(head),
else:
tail
|> filter(predicate)
end
end | persistent_list/lib/persistent_list/day02.ex | 0.583441 | 0.461502 | day02.ex | starcoder |
defmodule Meeseeks.Selector.Combinator do
@moduledoc """
Combinator structs package some method for finding related nodes and a
`Meeseeks.Selector` to be run on found nodes.
For instance, the css selector `ul > li` contains the combinator `> li`,
which roughly translates to "find a node's children and match any that are
`li`s."
In Meeseeks, this combinator could be represented as:
```elixir
alias Meeseeks.Selector.Combinator
alias Meeseeks.Selector.Element
%Combinator.ChildElements{
selector: %Element{selectors: [%Element.Tag{value: "li"}]}}
```
When defining a combinator using `use Meeseeks.Selector.Combinator`, the
default implementation of `selector/1` expects the selector to be stored
in field `selector`. If this is different in your struct, you must
implement `selector/1`.
## Examples
```elixir
defmodule Selector.Combinator.Parent do
use Meeseeks.Selector.Combinator
defstruct selector: nil
def next(_combinator, node, _document) do
node.parent
end
end
```
"""
alias Meeseeks.{Document, Selector}
@type t :: struct
@doc """
Invoked in order to find the node or nodes that a combinator wishes its
selector to be run on.
Returns the applicable node or nodes, or `nil` if there are no applicable
nodes.
"""
@callback next(combinator :: t, node :: Document.node_t(), document :: Document.t()) ::
[Document.node_t()]
| Document.node_t()
| nil
| no_return
@doc """
Invoked to return the combinator's selector.
"""
@callback selector(combinator :: t) :: Selector.t()
# next
@doc """
Finds the node or nodes that a combinator wishes its selector to be run on.
Returns the applicable node or nodes, or `nil` if there are no applicable
nodes.
"""
@spec next(t, Document.node_t(), Document.t()) ::
[Document.node_t()] | Document.node_t() | nil | no_return
def next(%{__struct__: struct} = combinator, node, document) do
struct.next(combinator, node, document)
end
# combinator
@doc """
Returns the combinator's selector.
"""
@spec selector(t) :: Selector.t()
def selector(%{__struct__: struct} = combinator) do
struct.selector(combinator)
end
# __using__
@doc false
defmacro __using__(_) do
quote do
@behaviour Selector.Combinator
@impl Selector.Combinator
def next(_, _, _), do: raise("next/3 not implemented")
@impl Selector.Combinator
def selector(combinator), do: combinator.selector
defoverridable next: 3, selector: 1
end
end
end | lib/meeseeks/selector/combinator.ex | 0.900717 | 0.726013 | combinator.ex | starcoder |
defmodule Protobuf.Parser do
defmodule ParserError do
defexception [:message]
end
def parse_files!(files, options \\ []) do
files
|> Enum.flat_map(fn path ->
schema = File.read!(path)
parse!(path, schema, options)
end)
|> finalize!(options)
end
def parse_string!(file, string, options \\ []) do
file
|> parse!(string, options)
|> finalize!(options)
end
defp finalize!(defs, options) do
case :gpb_parse.post_process_all_files(defs, options) do
{:ok, defs} ->
defs
{:error, error} ->
msg =
case error do
[ref_to_undefined_msg_or_enum: {{root_path, field}, type}] ->
type_ref =
type
|> Enum.map(&Atom.to_string/1)
|> Enum.join()
invalid_ref =
[field | root_path]
|> Enum.reverse()
|> Enum.map(&Atom.to_string/1)
|> Enum.join()
"Reference to undefined message or enum #{type_ref} at #{invalid_ref}"
_ ->
Macro.to_string(error)
end
raise ParserError, message: msg
end
end
defp parse(path, string, options) when is_binary(string) or is_list(string) do
case :gpb_scan.string('#{string}') do
{:ok, tokens, _} ->
lines =
string
|> String.split("\n", parts: :infinity)
|> Enum.count()
case :gpb_parse.parse(tokens ++ [{:"$end", lines + 1}]) do
{:ok, defs} ->
:gpb_parse.post_process_one_file(path, defs, options)
error ->
error
end
error ->
error
end
end
defp parse!(path, string, options) do
case parse(path, string, options) do
{:ok, defs} ->
defs
{:error, error} ->
msg =
case error do
[ref_to_undefined_msg_or_enum: {{root_path, field}, type}] ->
type_ref =
type
|> Enum.map(&Atom.to_string/1)
|> Enum.join()
invalid_ref =
[field | root_path]
|> Enum.reverse()
|> Enum.map(&Atom.to_string/1)
|> Enum.join()
"Reference to undefined message or enum #{type_ref} at #{invalid_ref}"
_ when is_binary(error) ->
error
_ ->
Macro.to_string(error)
end
raise ParserError, message: msg
end
end
end | lib/exprotobuf/parser.ex | 0.592077 | 0.485722 | parser.ex | starcoder |
defmodule HelloOperator.Controller.V1.Greeting do
@moduledoc """
HelloOperator: Greeting CRD.
## Kubernetes CRD Spec
By default all CRD specs are assumed from the module name, you can override them using attributes.
### Examples
```
# Kubernetes API version of this CRD, defaults to value in module name
@version "v2alpha1"
# Kubernetes API group of this CRD, defaults to "hello-operator.example.com"
@group "kewl.example.io"
The scope of the CRD. Defaults to `:namespaced`
@scope :cluster
CRD names used by kubectl and the kubernetes API
@names %{
plural: "foos",
singular: "foo",
kind: "Foo"
}
```
## Declare RBAC permissions used by this module
RBAC rules can be declared using `@rule` attribute and generated using `mix bonny.manifest`
This `@rule` attribute is cumulative, and can be declared once for each Kubernetes API Group.
### Examples
```
@rule {apiGroup, resources_list, verbs_list}
@rule {"", ["pods", "secrets"], ["*"]}
@rule {"apiextensions.k8s.io", ["foo"], ["*"]}
```
"""
use Bonny.Controller
@rule {"apps", ["deployments"], ["*"]}
@rule {"", ["services"], ["*"]}
# @group "your-operator.your-domain.com"
# @version "v1"
@scope :namespaced
@names %{
plural: "greetings",
singular: "greeting",
kind: "Greeting"
}
@doc """
Creates a kubernetes `deployment` and `service` that runs a "Hello, World" app.
"""
@spec add(map()) :: :ok | :error
def add(payload) do
resources = parse(payload)
conf = Bonny.Config.kubeconfig()
with :ok <- K8s.Client.post(resources.deployment, conf),
:ok <- K8s.Client.post(resources.service, conf) do
:ok
else
{:error, error} -> {:error, error}
end
end
@doc """
Updates `deployment` and `service` resources.
"""
@spec modify(map()) :: :ok | :error
def modify(payload) do
resources = parse(payload)
conf = Bonny.Config.kubeconfig()
with :ok <- K8s.Client.patch(resources.deployment, conf),
:ok <- K8s.Client.patch(resources.service, conf) do
:ok
else
{:error, error} -> {:error, error}
end
end
@doc """
Deletes `deployment` and `service` resources.
"""
@spec delete(map()) :: :ok | :error
def delete(payload) do
resources = parse(payload)
conf = Bonny.Config.kubeconfig()
with :ok <- K8s.Client.delete(resources.deployment, conf),
:ok <- K8s.Client.delete(resources.service, conf) do
:ok
else
{:error, error} -> {:error, error}
end
end
defp parse(%{"metadata" => %{"name" => name, "namespace" => ns}, "spec" => %{"greeting" => greeting}}) do
deployment = gen_deployment(ns, name, greeting)
service = gen_service(ns, name, greeting)
%{
deployment: deployment,
service: service
}
end
defp gen_service(ns, name, greeting) do
%{
apiVersion: "v1",
kind: "Service",
metadata: %{
name: name,
namespace: ns,
labels: %{app: name}
},
spec: %{
ports: [%{port: 5000, protocol: "TCP"}],
selector: %{app: name},
type: "NodePort"
}
}
end
defp gen_deployment(ns, name, greeting) do
%{
apiVersion: "apps/v1",
kind: "Deployment",
metadata: %{
name: name,
namespace: ns,
labels: %{app: name}
},
spec: %{
replicas: 2,
selector: %{
matchLabels: %{app: name}
},
template: %{
metadata: %{
labels: %{app: name}
},
spec: %{
containers: [
%{
name: name,
image: "quay.io/coryodaniel/greeting-server",
env: [%{name: "GREETING", value: greeting}],
ports: [%{containerPort: 5000}]
}
]
}
}
}
}
end
end | lib/hello_operator/controllers/v1/greeting.ex | 0.88499 | 0.824108 | greeting.ex | starcoder |
defmodule Holidefs.Definition.Rule do
@moduledoc """
A definition rule has the information about the event and
when it happens on a year.
"""
alias Holidefs.Definition.CustomFunctions
alias Holidefs.Definition.Rule
defstruct [
:name,
:month,
:day,
:week,
:weekday,
:function,
:regions,
:observed,
:year_ranges,
informal?: false
]
@type t :: %Rule{
name: String.t(),
month: integer,
day: integer,
week: integer,
weekday: integer,
function: function,
regions: [String.t()],
observed: function,
year_ranges: map | nil,
informal?: boolean
}
@valid_weeks [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5]
@valid_weekdays 1..7
@doc """
Builds a new rule from its month and definition map
"""
@spec build(atom, integer, map) :: t
def build(code, month, %{"name" => name, "function" => func} = map) do
%Rule{
name: name,
month: month,
day: map["mday"],
week: map["week"],
weekday: map["wday"],
year_ranges: map["year_ranges"],
informal?: map["type"] == "informal",
observed: observed_from_name(map["observed"]),
regions: load_regions(map, code),
function:
func
|> function_from_name()
|> load_function(map["function_modifier"])
}
end
def build(code, month, %{"name" => name, "week" => week, "wday" => wday} = map)
when week in @valid_weeks and wday in @valid_weekdays do
%Rule{
name: name,
month: month,
week: week,
weekday: wday,
year_ranges: map["year_ranges"],
informal?: map["type"] == "informal",
observed: observed_from_name(map["observed"]),
regions: load_regions(map, code)
}
end
def build(code, month, %{"name" => name, "mday" => day} = map) do
%Rule{
name: name,
month: month,
day: day,
year_ranges: map["year_ranges"],
informal?: map["type"] == "informal",
observed: observed_from_name(map["observed"]),
regions: load_regions(map, code)
}
end
defp load_regions(%{"regions" => regions}, code) do
Enum.map(regions, &String.replace(&1, "#{code}_", ""))
end
defp load_regions(_, _) do
[]
end
defp load_function(function, nil) do
function
end
defp load_function(function, modifier) do
fn year, rule ->
case function.(year, rule) do
%Date{} = date -> Date.add(date, modifier)
other -> other
end
end
end
defp observed_from_name(nil), do: nil
defp observed_from_name(name), do: function_from_name(name)
@custom_functions :exports
|> CustomFunctions.module_info()
|> Keyword.keys()
defp function_from_name(name) when is_binary(name) do
name
|> String.replace(~r/\(.+\)/, "")
|> String.to_atom()
|> function_from_name()
end
defp function_from_name(name) when is_atom(name) and name in @custom_functions do
&apply(CustomFunctions, name, [&1, &2])
end
end | lib/holidefs/definition/rule.ex | 0.852752 | 0.433382 | rule.ex | starcoder |
defmodule Unicode.EastAsianWidth do
@moduledoc """
Functions to introspect Unicode
east asian width categories for binaries
(Strings) and codepoints.
"""
@behaviour Unicode.Property.Behaviour
alias Unicode.Utils
@east_asian_width_categories Utils.east_asian_width()
|> Utils.remove_annotations()
@doc """
Returns the map of Unicode
east asian width categorys.
The east asian width category name is the map
key and a list of codepoint
ranges as tuples as the value.
"""
def east_asian_width_categories do
@east_asian_width_categories
end
@doc """
Returns a list of known Unicode
east asian width category names.
This function does not return the
names of any east asian width category aliases.
"""
@known_east_asian_width_categories Map.keys(@east_asian_width_categories)
def known_east_asian_width_categories do
@known_east_asian_width_categories
end
@east_asian_width_alias Utils.property_value_alias()
|> Map.get("ea")
|> Utils.atomize_values()
|> Utils.downcase_keys_and_remove_whitespace()
|> Utils.add_canonical_alias()
@doc """
Returns a map of aliases for
Unicode east asian width categorys.
An alias is an alternative name
for referring to a east asian width category. Aliases
are resolved by the `fetch/1` and
`get/1` functions.
"""
@impl Unicode.Property.Behaviour
def aliases do
@east_asian_width_alias
end
@doc """
Returns the Unicode ranges for
a given east asian width category as a list of
ranges as 2-tuples.
Aliases are resolved by this function.
Returns either `{:ok, range_list}` or
`:error`.
"""
@impl Unicode.Property.Behaviour
def fetch(east_asian_width_category) when is_atom(east_asian_width_category) do
Map.fetch(east_asian_width_categories(), east_asian_width_category)
end
def fetch(east_asian_width_category) do
east_asian_width_category = Utils.downcase_and_remove_whitespace(east_asian_width_category)
east_asian_width_category = Map.get(aliases(), east_asian_width_category, east_asian_width_category)
Map.fetch(east_asian_width_categories(), east_asian_width_category)
end
@doc """
Returns the Unicode ranges for
a given east asian width category as a list of
ranges as 2-tuples.
Aliases are resolved by this function.
Returns either `range_list` or
`nil`.
"""
@impl Unicode.Property.Behaviour
def get(east_asian_width_category) do
case fetch(east_asian_width_category) do
{:ok, east_asian_width_category} -> east_asian_width_category
_ -> nil
end
end
@doc """
Returns the count of the number of characters
for a given east asian width category.
## Example
iex> Unicode.IndicSyllabicCategory.count(:bindu)
91
"""
@impl Unicode.Property.Behaviour
def count(east_asian_width_category) do
with {:ok, east_asian_width_category} <- fetch(east_asian_width_category) do
Enum.reduce(east_asian_width_category, 0, fn {from, to}, acc -> acc + to - from + 1 end)
end
end
@doc """
Returns the east asian width category name(s) for the
given binary or codepoint.
In the case of a codepoint, a single
east asian width category name is returned.
For a binary a list of distinct east asian width category
names represented by the lines in
the binary is returned.
"""
def east_asian_width_category(string) when is_binary(string) do
string
|> String.to_charlist()
|> Enum.map(&east_asian_width_category/1)
|> Enum.uniq()
end
for {east_asian_width_category, ranges} <- @east_asian_width_categories do
def east_asian_width_category(codepoint) when unquote(Utils.ranges_to_guard_clause(ranges)) do
unquote(east_asian_width_category)
end
end
def east_asian_width_category(codepoint)
when is_integer(codepoint) and codepoint in 0..0x10FFFF do
:other
end
end | lib/unicode/east_asia_width.ex | 0.933726 | 0.670744 | east_asia_width.ex | starcoder |
defmodule ELA.Matrix do
alias ELA.Vector, as: Vector
@moduledoc"""
Contains operations for working with matrices.
"""
@doc"""
Returns an identity matrix with the provided dimension.
## Examples
iex> Matrix.identity(3)
[[1, 0, 0],
[0, 1, 0],
[0, 0, 1]]
"""
@spec identity(number) ::[[number]]
def identity(n) do
for i <- 1..n, do: for j <- 1..n, do: (fn
i, j when i === j -> 1
_, _ -> 0
end).(i, j)
end
@doc"""
Returns a matrix filled wiht zeroes as with n rows and m columns.
## Examples
iex> Matrix.new(3, 2)
[[0, 0],
[0, 0],
[0, 0]]
"""
@spec new(number, number) :: [[number]]
def new(n, m) do
for _ <- 1..n, do: for _ <- 1..m, do: 0
end
@doc"""
Transposes a matrix.
## Examples
iex> Matrix.transp([[1, 2, 3], [4, 5, 6]])
[[1, 4],
[2, 5],
[3, 6]]
"""
@spec transp([[number]]) :: [[number]]
def transp(a) do
List.zip(a) |> Enum.map(&Tuple.to_list(&1))
end
@doc"""
Performs elmentwise addition
## Examples
iex> Matrix.add([[1, 2, 3],
...> [1, 1, 1]],
...> [[1, 2, 2],
...> [1, 2, 1]])
[[2, 4, 5],
[2, 3, 2]]
"""
@spec add([[number]], [[number]]) :: [[number]]
def add(a, b) do
if dim(a) !== dim(b) do
raise(ArgumentError, "Matrices #{inspect a}, #{inspect b} must have same dimensions for addition.")
end
Enum.map(Enum.zip(a, b), fn({a, b}) -> Vector.add(a, b) end)
end
@doc"""
Performs elementwise subtraction
## Examples
iex> Matrix.sub([[1, 2, 3],
...> [1, 2, 2]],
...> [[1, 2, 3],
...> [2, 2, 2]])
[[0, 0, 0],
[-1, 0, 0]]
"""
@spec sub([[number]], [[number]]) :: [[number]]
def sub(a, b) when length(a) !== length(b),
do: raise(ArgumentError, "The number of rows in the matrices must match.")
def sub(a, b) do
Enum.map(Enum.zip(a, b), fn({a, b}) -> Vector.add(a, Vector.scalar(b, -1)) end)
end
@doc"""
Elementwise mutiplication with a scalar.
## Examples
iex> Matrix.scalar([[2, 2, 2],
...> [1, 1, 1]], 2)
[[4, 4, 4],
[2, 2, 2]]
"""
@spec scalar([[number]], number) :: [[number]]
def scalar(a, s) do
Enum.map(a, fn(r) -> Vector.scalar(r, s) end)
end
@doc"""
Elementwise multiplication with two matrices.
This is known as the Hadmard product.
## Examples
iex> Matrix.hadmard([[1, 2],
...> [1, 1]],
...> [[1, 2],
...> [0, 2]])
[[1, 4],
[0, 2]]
"""
@spec hadmard([[number]], [[number]]) :: [[number]]
def hadmard(a, b) when length(a) !== length(b),
do: raise(ArgumentError, "The number of rows in the matrices must match.")
def hadmard(a, b) do
Enum.map(Enum.zip(a, b), fn({u, v}) -> Vector.hadmard(u, v) end)
end
@doc"""
Matrix multiplication. Can also multiply matrices with vectors.
Always returns a matrix.
## Examples
iex> Matrix.mult([1, 1],
...> [[1, 0, 1],
...> [1, 1, 1]])
[[2, 1, 2]]
iex> Matrix.mult([[1, 0, 1],
...> [1, 1, 1]],
...> [[1],
...> [1],
...> [1]])
[[2],
[3]]
"""
@spec mult([number], [[number]]) :: [[number]]
def mult(v, b) when is_number(hd(v)) and is_list(hd(b)), do: mult([v], b)
def mult(a, v) when is_number(hd(v)) and is_list(hd(a)), do: mult(a, [v])
def mult(a, b) do
Enum.map(a, fn(r) ->
Enum.map(transp(b), &Vector.dot(r, &1))
end)
end
@doc"""
Returns a tuple with the matrix dimensions as {rows, cols}.
## Examples
Matrix.dim([[1, 1, 1],
...> [2, 2, 2]])
{2, 3}
"""
@spec dim([[number]]) :: {integer, integer}
def dim(a) when length(a) === 0, do: 0
def dim(a) do
{length(a), length(Enum.at(a, 0))}
end
@doc"""
Pivots them matrix a on the element on row n, column m (zero indexed).
Pivoting performs row operations to make the
pivot element 1 and all others in the same column 0.
## Examples
iex> Matrix.pivot([[2.0, 3.0],
...> [2.0, 3.0],
...> [3.0, 6.0]], 1, 0)
[[0.0, 0.0],
[1.0, 1.5],
[0.0, 1.5]]
"""
@spec pivot([[number]], number, number) :: [[number]]
def pivot(a, n, m) do
pr = Enum.at(a, n) #Pivot row
pe = Enum.at(pr, m) #Pivot element
a
|> List.delete_at(n)
|> Enum.map(&Vector.sub(&1, Vector.scalar(pr, Enum.at(&1, m) / pe)))
|> List.insert_at(n, Vector.scalar(pr, 1 / pe))
end
@doc"""
Returns a row equivalent matrix on reduced row echelon form.
## Examples
iex> Matrix.reduce([[1.0, 1.0, 2.0, 1.0],
...> [2.0, 1.0, 6.0, 4.0],
...> [1.0, 2.0, 2.0, 3.0]])
[[1.0, 0.0, 0.0, -5.0],
[0.0, 1.0, 0.0, 2.0],
[0.0, 0.0, 1.0, 2.0]]
"""
@spec reduce([[number]]) :: [[number]]
def reduce(a), do: reduce(a, 0)
defp reduce(a, i) do
r = Enum.at(a, i)
j = Enum.find_index(r, fn(e) -> e != 0 end)
a = pivot(a, i, j)
unless j === length(r) - 1 or
i === length(a) - 1
do
reduce(a, i + 1)
else
a
end
end
@doc"""
Returns the determinat of the matrix. Uses LU-decomposition to calculate it.
## Examples
iex> Matrix.det([[1, 3, 5],
...> [2, 4, 7],
...> [1, 1, 0]])
4
"""
@spec det([[number]]) :: number
def det(a) when length(a) !== length(hd(a)),
do: raise(ArgumentError, "Matrix #{inspect a} must be square to have a determinant.")
def det(a) do
{_, u, p} = lu(a)
u_dia = diagonal(u)
p_dia = diagonal(p)
u_det = Enum.reduce(u_dia, 1, &*/2)
exp = Enum.count(Enum.filter(p_dia, &(&1 === 0)))/2
u_det * :math.pow(-1, exp)
end
@doc"""
Returns a list of the matrix diagonal elements.
## Examples
iex> Matrix.diagonal([[1, 3, 5],
...> [2, 4, 7],
...> [1, 1, 0]])
[1, 4, 0]
"""
@spec diagonal([[number]]) :: [number]
def diagonal(a) when length(a) !== length(hd(a)),
do: raise(ArgumentError, "Matrix #{inspect a} must be square to have a diagonal.")
def diagonal(a), do: diagonal(a, 0)
defp diagonal([], _), do: []
defp diagonal([h | t], i) do
[Enum.at(h, i)] ++ diagonal(t, i + 1)
end
@doc"""
Returns an LU-decomposition on Crout's form with the permutation matrix used on the form {l, u, p}.
## Examples
iex> Matrix.lu([[1, 3, 5],
...> [2, 4, 7],
...> [1, 1, 0]])
{[[1, 0, 0],
[0.5, 1, 0],
[0.5, -1, 1]],
[[2, 4, 7],
[0, 1.0, 1.5],
[0, 0, -2.0]]
[[0, 1, 0],
[1, 0, 0],
[0, 0, 1]]}
"""
@spec lu([[number]]) :: {[[number]], [[number]], [[number]]}
def lu(a) do
p = lu_perm_matrix(a)
a = mult(p, a)
a = lu_map_matrix(a)
n = map_size(a)
u = lu_map_matrix(new(n, n))
l = lu_map_matrix(identity(n))
{l, u} = lu_rows(a, l, u)
l = Enum.map(l, fn({_, v}) -> Enum.map(v, fn({_, v}) -> v end) end)
u = Enum.map(u, fn({_, v}) -> Enum.map(v, fn({_, v}) -> v end) end)
{l, u, p}
end
@spec lu_rows([[number]], [[number]], [[number]]) :: {[[number]], [[number]]}
defp lu_rows(a, l, u), do: lu_rows(a, l, u, 1)
defp lu_rows(a, l, u, i) when i === map_size(a) + 1, do: {l, u}
defp lu_rows(a, l, u, i) do
{l, u} = lu_row(a, l, u, i)
lu_rows(a, l, u, i + 1)
end
@spec lu_row([[number]], [[number]], [[number]], number) :: {[[number]], [[number]]}
defp lu_row(a, l, u, i), do: lu_row(a, l, u, i, 1)
defp lu_row(a, l, u, _, j) when j === map_size(a) + 1, do: {l, u}
defp lu_row(a, l, u, i, j) do
{l, u} =
case {i, j} do
{i, j} when i > j -> {Map.put(l, i, Map.put(l[i], j, calc_lower(a, l, u, i, j))), u}
{i, j} when i <= j -> {l, Map.put(u, i, Map.put(u[i], j, calc_upper(a, l, u, i, j)))}
end
lu_row(a, l, u, i, j + 1)
end
@spec calc_upper([[number]], [[number]], [[number]], number, number) :: number
defp calc_upper(a, _, _, 1, j), do: a[1][j] #Guard for the case where k <- 1..0
defp calc_upper(a, l, u, i, j) do
a[i][j] - Enum.sum(for k <- 1..i-1, do: u[k][j] * l[i][k])
end
@spec calc_lower([[number]], [[number]], [[number]], number, number) :: number
defp calc_lower(a, _, u, i, 1), do: a[i][1]/u[1][1] #Guard for the case where k <- 1..0
defp calc_lower(a, l, u, i, j) do
(a[i][j] - Enum.sum(for k <- 1..j-1, do: u[k][j] * l[i][k]))/u[j][j]
end
@spec lu_perm_matrix([[number]]) :: [[number]]
defp lu_perm_matrix(a), do: lu_perm_matrix(transp(a), identity(length(a)), 0)
defp lu_perm_matrix(a, p, i) when i === length(a) - 1, do: p
defp lu_perm_matrix(a, p, i) do
r = Enum.drop(Enum.at(a, i), i)
j = i + Enum.find_index(r, fn(x) ->
x === abs(Enum.max(r))
end)
p =
case {i, j} do
{i, i} -> p
_ -> p
|> List.update_at(i, &(&1 = Enum.at(p, j)))
|> List.update_at(j, &(&1 = Enum.at(p, i)))
end
lu_perm_matrix(a, p, i + 1)
end
@spec lu_map_matrix([]) :: %{}
defp lu_map_matrix(l, m \\ %{}, i \\ 1)
defp lu_map_matrix([], m, _), do: m
defp lu_map_matrix([h|t], m, i) do
m = Map.put(m, i, lu_map_matrix(h))
lu_map_matrix(t, m, i + 1)
end
defp lu_map_matrix(other, _, _), do: other
end | lib/matrix.ex | 0.913233 | 0.677904 | matrix.ex | starcoder |
defmodule ETSMap do
@moduledoc """
`ETSMap` is a [`Map`](http://elixir-lang.org/docs/stable/elixir/Map.html)-like
Elixir data structure that is backed by an
[ETS](http://www.erlang.org/doc/man/ets.html) table.
*If you are not familiar with ETS, you should first familiarize yourself with
it before using this module. This is not a drop-in replacement for the
[`Map`](http://elixir-lang.org/docs/stable/elixir/Map.html) module. There are
many critically important differences between a regular
[`Map`](http://elixir-lang.org/docs/stable/elixir/Map.html) and an `ETSMap`.*
That being said, being able to use the Elixir
[`Map`](http://elixir-lang.org/docs/stable/elixir/Map.html) API with an ETS
table is a nice convenience. If necessary, you can always use the normal ETS
API by retrieving the underlying ETS table via the `ETSMap` struct field
`table`.
## Access
`ETSMap` supports the [`Access`](http://elixir-lang.org/docs/stable/elixir/Access.html) protocol,
so you can use the access syntax:
iex> ets_map[:key]
:value
as well as the *_in family of functions from
[`Kernel`](http://elixir-lang.org/docs/stable/elixir/Kernel.html):
iex> put_in ets_map[:key], :value
#ETSMap<table: ..., [key: :value]>
## Enumerable
`ETSMap` supports the
[`Enumerable`](http://elixir-lang.org/docs/stable/elixir/Enumerable.html)
protocol, so all of the functions in
[`Enum`](http://elixir-lang.org/docs/stable/elixir/Enum.html)
and [`Stream`](http://elixir-lang.org/docs/stable/elixir/Stream.html) work
as expected, as well as for comprehensions:
iex> Enum.map ets_map, fn {key, value} ->
{key, value + 1}
end
[b: 3, a: 2]
iex> for {key, value} <- ets_map, do: {key, value + 1}
[b: 3, a: 2]
## Collectable
`ETSMap` also supports the
[`Collectable`](http://elixir-lang.org/docs/stable/elixir/Collectable.html)
protocol, so
[`Enum.into`](http://elixir-lang.org/docs/master/elixir/Enum.html#into/2) and
[`Stream.into`](http://elixir-lang.org/docs/master/elixir/Stream.html#into/3)
will function as expected, as well:
iex> ets_map = [a: 1, b: 2] |> Enum.into(ETSMap.new)
#ETSMap<table: ..., [b: 2, a: 1]>
iex> [c: 3, d: 4] |> Enum.into(ets_map)
#ETSMap<table: ..., [d: 4, c: 3, b: 2, a: 1]>
iex> for {k, v} <- ets_map, into: ets_map, do: {k, v + 1}
#ETSMap<table: ..., [d: 5, c: 4, b: 3, a: 2]>
iex> ets_map
#ETSMap<table: ..., [d: 5, c: 4, b: 3, a: 2]>
## ETSMap vs. Map Semantics
This section should not be considered an exhaustive specification of the
behavior of ETS (which you can find in the official ETS docs that you
should have read already). The intention, instead, is to cover some of the
largest differences that this behavior manifests between
[`Map`](http://elixir-lang.org/docs/stable/elixir/Map.html)s and `ETSMap`s.
One of the important differences between a
[`Map`](http://elixir-lang.org/docs/stable/elixir/Map.html) and an `ETSMap`
is that `ETSMap`s are not immutable. Thus, any functions which would normally
return a new (modified) copy of the input value will actually mutate all
references to that value. However, this has the advantage of allowing the
`ETSMap`/table to be written and read from multiple processes concurrently.
ETS tables are linked to their owner. By default, a table's owner is the
process that created it. If the process that created it dies, the table will
be deleted, even if references to it still exist in other processes. If no
references to a table still exist, and the table's owner still exists, the
table will be leaked. Ultimately `ETSMap`s are backed by ETS tables, so this
behavior is important to keep in mind.
"""
defstruct [:table]
@opaque t :: %__MODULE__{table: :ets.tab}
@type key :: any
@type value :: any
@type new_opts :: [new_opt]
@type new_opt ::
{:enumerable, Enum.t} |
{:transform, ({key, value} -> {key, value})} |
{:name, atom} |
{:ets_opts, Keyword.t}
@compile {:inline, delete: 2, fetch: 2, put: 3}
@doc """
Returns a new `ETSMap`.
If the appropriate options are provided, will call
[`:ets.new`](http://www.erlang.org/doc/man/ets.html#new-2) to create table
`name` using options `ets_opts` and then insert `enumerable`, using
`transform` to transform the elements.
By default, `name` is set to `:ets_map_table` and `ets_opts` is set to
`[:set, :public]`. The only supported table types are `:set`
and `:ordered_set`.
There is also a convenience clause provided which takes a single argument (a
map) which is inserted into the new `ETSMap`
## Examples
iex> ETSMap.new(enumerable: %{a: 1, b: 2}, transform: fn {k, v} -> {k, v + 1} end)
#ETSMap<table: ..., [b: 3, a: 2]>
iex> ETSMap.new(%{a: 1})
#ETSMap<table: ..., [a: 2]>
"""
@spec new(map | new_opts) :: t
def new(opts \\ [])
def new(%{} = map) do
new(enumerable: map)
end
def new(opts) do
enumerable = Keyword.get(opts, :enumerable, [])
transform = Keyword.get(opts, :transform, fn x -> x end)
name = Keyword.get(opts, :name, :ets_map_table)
ets_opts = Keyword.get(opts, :ets_opts, [:set, :public])
ets_map = %__MODULE__{table: :ets.new(name, ets_opts)}
:ets.insert(ets_map.table, enumerable |> Enum.map(transform))
ets_map
end
@doc """
Deletes an `ETSMap` using [`:ets.delete`](http://www.erlang.org/doc/man/ets.html#delete-1).
"""
@spec delete(t) :: :ok
def delete(%__MODULE__{} = map) do
:ets.delete(map.table)
:ok
end
@doc """
Deletes the entries for a specific `key`.
If the `key` does not exist, does nothing.
## Examples
iex> ETSMap.delete(ETSMap.new(%{a: 1, b: 2}), :a)
#ETSMap<table: ..., [b: 2]>
iex> ETSMap.delete(ETSMap.new(%{b: 2}), :a)
#ETSMap<table: ..., [b: 2]>
"""
@spec delete(t, key) :: t
def delete(%__MODULE__{table: table} = map, key) do
:ets.delete(table, key)
map
end
@doc """
Drops the given keys from the map.
## Examples
iex> ETSMap.drop(ETSMap.new(%{a: 1, b: 2, c: 3}), [:b, :d])
#ETSMap<table: ..., [a: 1, c: 3]>
"""
@spec drop(t, [key]) :: t
def drop(%__MODULE__{} = map, keys) do
Enum.reduce(keys, map, &delete(&2, &1))
end
@doc """
Checks if two `ETSMap`s are equal.
Two maps are considered to be equal if they contain
the same keys and those keys contain the same values.
## Examples
iex> ETSMap.equal?(ETSMap.new(%{a: 1, b: 2}), ETSMap.new(%{b: 2, a: 1}))
true
iex> ETSMap.equal?(ETSMap.new(%{a: 1, b: 2}), ETSMap.new(%{b: 1, a: 2}))
false
"""
@spec equal?(t, t) :: boolean
def equal?(%__MODULE__{} = map1, %__MODULE__{} = map2), do: to_list(map1) === to_list(map2)
@doc """
Fetches the value for a specific `key` and returns it in a tuple.
If the `key` does not exist, returns `:error`.
## Examples
iex> ETSMap.fetch(ETSMap.new(%{a: 1}), :a)
{:ok, 1}
iex> ETSMap.fetch(ETSMap.new(%{a: 1}), :b)
:error
"""
@spec fetch(t, key) :: {:ok, value} | :error
def fetch(%__MODULE__{} = map, key) do
case :ets.lookup(map.table, key) do
[{^key, value}] -> {:ok, value}
[] -> :error
end
end
@doc """
Fetches the value for specific `key`.
If `key` does not exist, a `KeyError` is raised.
## Examples
iex> ETSMap.fetch!(ETSMap.new(%{a: 1}), :a)
1
iex> ETSMap.fetch!(ETSMap.new(%{a: 1}), :b)
** (KeyError) key :b not found in: #ETSMap<table: ..., [a: 1]>
"""
@spec fetch!(t, key) :: value | no_return
def fetch!(%__MODULE__{} = map, key) do
case fetch(map, key) do
{:ok, value} -> value
:error -> raise KeyError, key: key, term: map
end
end
@doc """
Gets the value for a specific `key`.
If `key` does not exist, return the default value
(`nil` if no default value).
## Examples
iex> ETSMap.get(ETSMap.new(%{}), :a)
nil
iex> ETSMap.get(ETSMap.new(%{a: 1}), :a)
1
iex> ETSMap.get(ETSMap.new(%{a: 1}), :b)
nil
iex> ETSMap.get(ETSMap.new(%{a: 1}), :b, 3)
3
"""
@spec get(t, key, value) :: value
def get(%__MODULE__{} = map, key, default \\ nil) do
case fetch(map, key) do
{:ok, value} -> value
:error -> default
end
end
@doc """
Gets the value for a specific `key`.
If `key` does not exist, lazily evaluates `fun` and returns its result.
This is useful if the default value is very expensive to calculate or
generally difficult to setup and teardown again.
## Examples
iex> map = ETSMap.new(%{a: 1})
iex> fun = fn ->
...> # some expensive operation here
...> 13
...> end
iex> ETSMap.get_lazy(map, :a, fun)
1
iex> ETSMap.get_lazy(map, :b, fun)
13
"""
@spec get_lazy(t, key, (() -> value)) :: value
def get_lazy(%__MODULE__{} = map, key, fun) when is_function(fun, 0) do
case fetch(map, key) do
{:ok, value} -> value
:error -> fun.()
end
end
@doc """
Gets the value from `key` and updates it, all in one pass.
This `fun` argument receives the value of `key` (or `nil` if `key`
is not present) and must return a two-elements tuple: the "get" value (the
retrieved value, which can be operated on before being returned) and the new
value to be stored under `key`.
The returned value is a tuple with the "get" value returned by `fun` and a
new map with the updated value under `key`.
## Examples
iex> ETSMap.get_and_update(ETSMap.new(%{a: 1}), :a, fn current_value ->
...> {current_value, "new value!"}
...> end)
{1, #ETSMap<table: ..., [a: "new value!"]>}
iex> ETSMap.get_and_update(ETSMap.new(%{a: 1}), :b, fn current_value ->
...> {current_value, "new value!"}
...> end)
{nil, #ETSMap<table: ..., [b: "new value!", a: 1]>}
"""
@spec get_and_update(t, key, (value -> {get, value})) :: {get, t} when get: value
def get_and_update(%__MODULE__{} = map, key, fun) do
current_value = case fetch(map, key) do
{:ok, value} -> value
:error -> nil
end
{get, update} = fun.(current_value)
{get, put(map, key, update)}
end
@doc """
Gets the value from `key` and updates it. Raises if there is no `key`.
This `fun` argument receives the value of `key` and must return a
two-elements tuple: the "get" value (the retrieved value, which can be
operated on before being returned) and the new value to be stored under
`key`.
The returned value is a tuple with the "get" value returned by `fun` and a
new map with the updated value under `key`.
## Examples
iex> ETSMap.get_and_update(ETSMap.new(%{a: 1}), :a, fn current_value ->
...> {current_value, "new value!"}
...> end)
{1, #ETSMap<table: ..., [a: "new value!"]>}
iex> ETSMap.get_and_update(ETSMap.new(%{a: 1}), :b, fn current_value ->
...> {current_value, "new value!"}
...> end)
** (KeyError) key :b not found
"""
@spec get_and_update!(t, key, (value -> {get, value})) :: {get, t} | no_return when get: value
def get_and_update!(%__MODULE__{} = map, key, fun) do
case fetch(map, key) do
{:ok, value} ->
{get, update} = fun.(value)
{get, :maps.put(key, update, map)}
:error ->
:erlang.error({:badkey, key})
end
end
@doc """
Returns whether a given `key` exists.
## Examples
iex> ETSMap.has_key?(ETSMap.new(%{a: 1}), :a)
true
iex> ETSMap.has_key?(ETSMap.new(%{a: 1}), :b)
false
"""
@spec has_key?(t, key) :: boolean
def has_key?(%__MODULE__{} = map, key),
do: match? {:ok, _}, fetch(map, key)
@doc """
Returns all keys.
## Examples
iex> ETSMap.keys(ETSMap.new(%{a: 1, b: 2}))
[:a, :b]
"""
@spec keys(t) :: [key]
def keys(%__MODULE__{} = map) do
:ets.select(map.table, [{{:"$1", :"_"}, [], [:"$1"]}])
end
@doc """
Merges two maps into one.
All keys in `map2` will be added to `map1`, overriding any existing one.
## Examples
iex> ETSMap.merge(ETSMap.new(%{a: 1, b: 2}), ETSMap.new(%{a: 3, d: 4}))
#ETSMap<table: ..., [d: 4, b: 2, a: 3]>
iex> ETSMap.merge(ETSMap.new(%{a: 1, b: 2}), %{a: 3, d: 4})
#ETSMap<table: ..., [d: 4, b: 2, a: 3]>
"""
@spec merge(Enum.t, Enum.t) :: Enum.t
def merge(%__MODULE__{} = map1, map2) do
map2 |> Enum.into(map1)
end
@doc """
Merges two maps into one.
All keys in `map2` will be added to `map1`. The given function will
be invoked with the key, value1 and value2 to solve conflicts.
## Examples
iex> ETSMap.merge(ETSMap.new(%{a: 1, b: 2}), %{a: 3, d: 4}, fn _k, v1, v2 ->
...> v1 + v2
...> end)
#ETSMap<table: ..., [a: 4, b: 2, d: 4]>
"""
@spec merge(Enum.t, Enum.t, (key, value, value -> value)) :: map
def merge(%__MODULE__{} = map1, map2, callback) do
Enum.reduce map2, map1, fn {k, v2}, acc ->
update(acc, k, v2, fn(v1) -> callback.(k, v1, v2) end)
end
end
@doc """
Returns and removes all values associated with `key`.
## Examples
iex> ETSMap.pop(ETSMap.new(%{a: 1}), :a)
{1, #ETSMap<table: ..., []>}
iex> ETSMap.pop(%{a: 1}, :b)
{nil, #ETSMap<table: ..., [a: 1]>}
iex> ETSMap.pop(%{a: 1}, :b, 3)
{3, #ETSMap<table: ..., [a: 1]>}
"""
@spec pop(t, key, value) :: {value, t}
def pop(%__MODULE__{} = map, key, default \\ nil) do
case fetch(map, key) do
{:ok, value} -> {value, delete(map, key)}
:error -> {default, map}
end
end
@doc """
Lazily returns and removes all values associated with `key` in the `map`.
This is useful if the default value is very expensive to calculate or
generally difficult to setup and teardown again.
## Examples
iex> map = ETSMap.new(%{a: 1})
iex> fun = fn ->
...> # some expensive operation here
...> 13
...> end
iex> ETSMap.pop_lazy(map, :a, fun)
{1, #ETSMap<table: ..., []>}
iex> ETSMap.pop_lazy(map, :a, fun)
{13, #ETSMap<table: ..., []>}
"""
@spec pop_lazy(t, key, (() -> value)) :: {value, t}
def pop_lazy(%__MODULE__{} = map, key, fun) when is_function(fun, 0) do
case fetch(map, key) do
{:ok, value} -> {value, delete(map, key)}
:error -> {fun.(), map}
end
end
@doc """
Puts the given `value` under `key`.
## Examples
iex> ETSMap.put(ETSMap.new(%{a: 1}), :b, 2)
#ETSMap<table: ..., [a: 1, b: 2]>
iex> ETSMap.put(ETSMap.new(%{a: 1, b: 2}), :a, 3)
#ETSMap<table: ..., [a: 3, b: 2]>
"""
@spec put(map, key, value) :: map
def put(%__MODULE__{table: table} = map, key, value) do
:ets.insert(table, {key, value})
map
end
@doc """
Puts the given `value` under `key` unless the entry `key`
already exists.
## Examples
iex> ETSMap.put_new(ETSMap.new(%{a: 1}), :b, 2)
#ETSMap<table: ..., [b: 2, a: 1]>
iex> ETSMap.put_new(ETSMap.new(%{a: 1, b: 2}), :a, 3)
#ETSMap<table: ..., [a: 1, b: 2]>
"""
@spec put_new(t, key, value) :: t
def put_new(%__MODULE__{} = map, key, value) do
case has_key?(map, key) do
true -> map
false -> put(map, key, value)
end
end
@doc """
Evaluates `fun` and puts the result under `key`
in map unless `key` is already present.
This is useful if the value is very expensive to calculate or
generally difficult to setup and teardown again.
## Examples
iex> map = ETSMap.new(%{a: 1})
iex> fun = fn ->
...> # some expensive operation here
...> 3
...> end
iex> ETSMap.put_new_lazy(map, :a, fun)
#ETSMap<table: ..., [a: 1]>
iex> ETSMap.put_new_lazy(map, :b, fun)
#ETSMap<table: ..., [a: 1, b: 3]>
"""
@spec put_new_lazy(t, key, (() -> value)) :: map
def put_new_lazy(%__MODULE__{} = map, key, fun) when is_function(fun, 0) do
case has_key?(map, key) do
true -> map
false -> put(map, key, fun.())
end
end
@doc false
def size(%__MODULE__{table: table}),
do: :ets.info(table, :size)
@doc """
Takes all entries corresponding to the given keys and extracts them into a
separate `ETSMap`.
Returns a tuple with the new map and the old map with removed keys.
Keys for which there are no entires in the map are ignored.
## Examples
iex> ETSMap.split(ETSMap.new(%{a: 1, b: 2, c: 3}), [:a, :c, :e])
{#ETSMap<table: ..., [a: 1, c: 3]>, #ETSMap<table: ..., [b: 2]>}
"""
@spec split(t, [key], new_opts) :: t
def split(%__MODULE__{} = map, keys, new_opts \\ []) do
Enum.reduce(keys, {new(new_opts), map}, fn key, {inc, exc} = acc ->
case fetch(exc, key) do
{:ok, value} ->
{put(inc, key, value), delete(exc, key)}
:error ->
acc
end
end)
end
@doc """
Takes all entries corresponding to the given keys and
returns them in a new `ETSMap`.
## Examples
iex> ETSMap.take(ETSMap.new(%{a: 1, b: 2, c: 3}), [:a, :c, :e])
#ETSMap<table: ..., [a: 1, c: 3]>
"""
@spec take(t, [key], Keyword.t) :: t
def take(%__MODULE__{} = map, keys, new_opts \\ []) do
Enum.reduce(keys, new(new_opts), fn key, acc ->
case fetch(map, key) do
{:ok, value} -> put(acc, key, value)
:error -> acc
end
end)
end
@doc """
Converts the `ETSMap` to a list.
## Examples
iex> ETSMap.to_list(ETSMap.new([a: 1]))
[a: 1]
iex> ETSMap.to_list(ETSMap.new(%{1 => 2}))
[{1, 2}]
"""
@spec to_list(t) :: [{key, value}]
def to_list(%__MODULE__{} = map),
do: :ets.tab2list(map.table)
@doc """
Updates the `key` in `map` with the given function.
If the `key` does not exist, inserts the given `initial` value.
## Examples
iex> ETSMap.update(ETSMap.new(%{a: 1}), :a, 13, &(&1 * 2))
#ETSMap<table: ..., [a: 2]>
iex> ETSMap.update(ETSMap.new(%{a: 1}), :b, 11, &(&1 * 2))
#ETSMap<table: ..., [a: 1, b: 11]>
"""
@spec update(t, key, value, (value -> value)) :: t
def update(%__MODULE__{} = map, key, initial, fun) do
case fetch(map, key) do
{:ok, value} ->
put(map, key, fun.(value))
:error ->
put(map, key, initial)
end
end
@doc """
Updates the `key` with the given function.
If the `key` does not exist, raises `KeyError`.
## Examples
iex> ETSMap.update!(ETSMap.new(%{a: 1}), :a, &(&1 * 2))
#ETSMap<table: ..., [a: 2]>
iex> ETSMap.update!(ETSMap.new(%{a: 1}), :b, &(&1 * 2))
** (KeyError) key :b not found
"""
@spec update!(map, key, (value -> value)) :: map | no_return
def update!(%__MODULE__{} = map, key, fun) do
case fetch(map, key) do
{:ok, value} ->
put(map, key, fun.(value))
:error ->
:erlang.error({:badkey, key})
end
end
@doc """
Returns all values.
## Examples
iex> ETSMap.values(ETSMap.new(%{a: 1, b: 2}))
[1, 2]
"""
@spec values(t) :: [value]
def values(%__MODULE__{} = map) do
:ets.select(map.table, [{{:"_", :"$1"}, [], [:"$1"]}])
end
defimpl Enumerable do
def count(map),
do: {:ok, ETSMap.size(map)}
def member?(map, {key, value}) do
case ETSMap.fetch(map, key) do
{:ok, ^value} -> {:ok, true}
_ -> {:ok, false}
end
end
def member?(_map, _value),
do: {:ok, false}
def reduce(map, acc, fun),
do: Enumerable.List.reduce(ETSMap.to_list(map), acc, fun)
end
defimpl Collectable do
def into(original) do
{original, fn
map, {:cont, {key, value}} -> ETSMap.put(map, key, value)
map, :done -> map
_, :halt -> :ok
end}
end
end
defimpl Inspect do
import Inspect.Algebra
def inspect(map, opts),
do: concat [
"#ETSMap<table: #{map.table}, ",
Inspect.List.inspect(ETSMap.to_list(map), opts),
">"
]
end
end | lib/ets_map.ex | 0.875001 | 0.777025 | ets_map.ex | starcoder |
defmodule AWS.Transcribe do
@moduledoc """
Operations and objects for transcribing speech to text.
"""
@doc """
Creates a new custom language model.
Use Amazon S3 prefixes to provide the location of your input files. The time it
takes to create your model depends on the size of your training data.
"""
def create_language_model(client, input, options \\ []) do
request(client, "CreateLanguageModel", input, options)
end
@doc """
Creates a new custom vocabulary that you can use to change how Amazon Transcribe
Medical transcribes your audio file.
"""
def create_medical_vocabulary(client, input, options \\ []) do
request(client, "CreateMedicalVocabulary", input, options)
end
@doc """
Creates a new custom vocabulary that you can use to change the way Amazon
Transcribe handles transcription of an audio file.
"""
def create_vocabulary(client, input, options \\ []) do
request(client, "CreateVocabulary", input, options)
end
@doc """
Creates a new vocabulary filter that you can use to filter words, such as
profane words, from the output of a transcription job.
"""
def create_vocabulary_filter(client, input, options \\ []) do
request(client, "CreateVocabularyFilter", input, options)
end
@doc """
Deletes a custom language model using its name.
"""
def delete_language_model(client, input, options \\ []) do
request(client, "DeleteLanguageModel", input, options)
end
@doc """
Deletes a transcription job generated by Amazon Transcribe Medical and any
related information.
"""
def delete_medical_transcription_job(client, input, options \\ []) do
request(client, "DeleteMedicalTranscriptionJob", input, options)
end
@doc """
Deletes a vocabulary from Amazon Transcribe Medical.
"""
def delete_medical_vocabulary(client, input, options \\ []) do
request(client, "DeleteMedicalVocabulary", input, options)
end
@doc """
Deletes a previously submitted transcription job along with any other generated
results such as the transcription, models, and so on.
"""
def delete_transcription_job(client, input, options \\ []) do
request(client, "DeleteTranscriptionJob", input, options)
end
@doc """
Deletes a vocabulary from Amazon Transcribe.
"""
def delete_vocabulary(client, input, options \\ []) do
request(client, "DeleteVocabulary", input, options)
end
@doc """
Removes a vocabulary filter.
"""
def delete_vocabulary_filter(client, input, options \\ []) do
request(client, "DeleteVocabularyFilter", input, options)
end
@doc """
Gets information about a single custom language model.
Use this information to see details about the language model in your AWS
account. You can also see whether the base language model used to create your
custom language model has been updated. If Amazon Transcribe has updated the
base model, you can create a new custom language model using the updated base
model. If the language model wasn't created, you can use this operation to
understand why Amazon Transcribe couldn't create it.
"""
def describe_language_model(client, input, options \\ []) do
request(client, "DescribeLanguageModel", input, options)
end
@doc """
Returns information about a transcription job from Amazon Transcribe Medical.
To see the status of the job, check the `TranscriptionJobStatus` field. If the
status is `COMPLETED`, the job is finished. You find the results of the
completed job in the `TranscriptFileUri` field.
"""
def get_medical_transcription_job(client, input, options \\ []) do
request(client, "GetMedicalTranscriptionJob", input, options)
end
@doc """
Retrieves information about a medical vocabulary.
"""
def get_medical_vocabulary(client, input, options \\ []) do
request(client, "GetMedicalVocabulary", input, options)
end
@doc """
Returns information about a transcription job.
To see the status of the job, check the `TranscriptionJobStatus` field. If the
status is `COMPLETED`, the job is finished and you can find the results at the
location specified in the `TranscriptFileUri` field. If you enable content
redaction, the redacted transcript appears in `RedactedTranscriptFileUri`.
"""
def get_transcription_job(client, input, options \\ []) do
request(client, "GetTranscriptionJob", input, options)
end
@doc """
Gets information about a vocabulary.
"""
def get_vocabulary(client, input, options \\ []) do
request(client, "GetVocabulary", input, options)
end
@doc """
Returns information about a vocabulary filter.
"""
def get_vocabulary_filter(client, input, options \\ []) do
request(client, "GetVocabularyFilter", input, options)
end
@doc """
Provides more information about the custom language models you've created.
You can use the information in this list to find a specific custom language
model. You can then use the operation to get more information about it.
"""
def list_language_models(client, input, options \\ []) do
request(client, "ListLanguageModels", input, options)
end
@doc """
Lists medical transcription jobs with a specified status or substring that
matches their names.
"""
def list_medical_transcription_jobs(client, input, options \\ []) do
request(client, "ListMedicalTranscriptionJobs", input, options)
end
@doc """
Returns a list of vocabularies that match the specified criteria.
If you don't enter a value in any of the request parameters, returns the entire
list of vocabularies.
"""
def list_medical_vocabularies(client, input, options \\ []) do
request(client, "ListMedicalVocabularies", input, options)
end
@doc """
Lists transcription jobs with the specified status.
"""
def list_transcription_jobs(client, input, options \\ []) do
request(client, "ListTranscriptionJobs", input, options)
end
@doc """
Returns a list of vocabularies that match the specified criteria.
If no criteria are specified, returns the entire list of vocabularies.
"""
def list_vocabularies(client, input, options \\ []) do
request(client, "ListVocabularies", input, options)
end
@doc """
Gets information about vocabulary filters.
"""
def list_vocabulary_filters(client, input, options \\ []) do
request(client, "ListVocabularyFilters", input, options)
end
@doc """
Starts a batch job to transcribe medical speech to text.
"""
def start_medical_transcription_job(client, input, options \\ []) do
request(client, "StartMedicalTranscriptionJob", input, options)
end
@doc """
Starts an asynchronous job to transcribe speech to text.
"""
def start_transcription_job(client, input, options \\ []) do
request(client, "StartTranscriptionJob", input, options)
end
@doc """
Updates a vocabulary with new values that you provide in a different text file
from the one you used to create the vocabulary.
The `UpdateMedicalVocabulary` operation overwrites all of the existing
information with the values that you provide in the request.
"""
def update_medical_vocabulary(client, input, options \\ []) do
request(client, "UpdateMedicalVocabulary", input, options)
end
@doc """
Updates an existing vocabulary with new values.
The `UpdateVocabulary` operation overwrites all of the existing information with
the values that you provide in the request.
"""
def update_vocabulary(client, input, options \\ []) do
request(client, "UpdateVocabulary", input, options)
end
@doc """
Updates a vocabulary filter with a new list of filtered words.
"""
def update_vocabulary_filter(client, input, options \\ []) do
request(client, "UpdateVocabularyFilter", input, options)
end
@spec request(AWS.Client.t(), binary(), map(), list()) ::
{:ok, map() | nil, map()}
| {:error, term()}
defp request(client, action, input, options) do
client = %{client | service: "transcribe"}
host = build_host("transcribe", client)
url = build_url(host, client)
headers = [
{"Host", host},
{"Content-Type", "application/x-amz-json-1.1"},
{"X-Amz-Target", "Transcribe.#{action}"}
]
payload = encode!(client, input)
headers = AWS.Request.sign_v4(client, "POST", url, headers, payload)
post(client, url, payload, headers, options)
end
defp post(client, url, payload, headers, options) do
case AWS.Client.request(client, :post, url, payload, headers, options) do
{:ok, %{status_code: 200, body: body} = response} ->
body = if body != "", do: decode!(client, body)
{:ok, body, response}
{:ok, response} ->
{:error, {:unexpected_response, response}}
error = {:error, _reason} -> error
end
end
defp build_host(_endpoint_prefix, %{region: "local", endpoint: endpoint}) do
endpoint
end
defp build_host(_endpoint_prefix, %{region: "local"}) do
"localhost"
end
defp build_host(endpoint_prefix, %{region: region, endpoint: endpoint}) do
"#{endpoint_prefix}.#{region}.#{endpoint}"
end
defp build_url(host, %{:proto => proto, :port => port}) do
"#{proto}://#{host}:#{port}/"
end
defp encode!(client, payload) do
AWS.Client.encode!(client, payload, :json)
end
defp decode!(client, payload) do
AWS.Client.decode!(client, payload, :json)
end
end | lib/aws/generated/transcribe.ex | 0.908405 | 0.566318 | transcribe.ex | starcoder |
defmodule GrowthBook.Config do
@moduledoc """
A set of helper functions to convert config maps to structs.
This module is used to convert the configuration maps that are retrieved from GrowthBook's API
(or your local cache) to values that can be used directly with the `GrowthBook.Context` module.
"""
alias GrowthBook.Context
alias GrowthBook.Feature
alias GrowthBook.FeatureRule
alias GrowthBook.Experiment
alias GrowthBook.ExperimentOverride
@typedoc """
A map with string keys, as returned when decoding JSON using Jason/Poison
"""
@type json_map() :: %{required(String.t()) => term()}
@doc """
Converts feature configuration to a map of features.
Use this function to take the configuration retrieved from the `/features` API endpoint and
convert it into a usable map of `GrowthBook.Feature` structs.
"""
@spec features_from_config(json_map()) :: Context.features()
def features_from_config(%{"features" => features_config}) when is_map(features_config) do
Map.new(features_config, fn {feature_key, feature_config} ->
rules = feature_config |> Map.get("rules") |> feature_rules_from_config(feature_key)
feature = %Feature{
default_value: Map.get(feature_config, "defaultValue"),
rules: rules
}
{feature_key, feature}
end)
end
def features_from_config(_features_not_found_or_empty), do: %{}
@doc """
Converts feature rule configuration to a list of feature rules.
Use this function to take the configuration retrieved from the `/features` API endpoint and
convert it into a usable list of `GrowthBook.FeatureRule` structs. This function is used by
`features_from_config`.
"""
@spec feature_rules_from_config([json_map()], String.t()) :: [FeatureRule.t()]
def feature_rules_from_config([_ | _] = feature_rules, feature_key) do
Enum.map(feature_rules, fn feature_rule ->
namespace = feature_rule |> Map.get("namespace") |> namespace_from_config()
%FeatureRule{
key: Map.get(feature_rule, "key") || feature_key,
force: Map.get(feature_rule, "force"),
condition: Map.get(feature_rule, "condition"),
coverage: feature_rule |> Map.get("coverage") |> ensure_float(),
hash_attribute: Map.get(feature_rule, "hashAttribute"),
namespace: namespace,
variations: Map.get(feature_rule, "variations"),
weights: Map.get(feature_rule, "weights")
}
end)
end
def feature_rules_from_config(_feature_rules_not_found_or_empty, _feature_key), do: []
@doc """
Converts experiment overrides configuration to a map of experiment overrides.
Use this function to take the configuration retrieved from the `/config` API endpoint and
convert it into a usable map of `GrowthBook.ExperimentOverride` structs.
"""
@spec experiment_overrides_from_config(json_map()) :: Context.experiment_overrides()
def experiment_overrides_from_config(experiment_overrides_config) do
Map.new(experiment_overrides_config, fn {experiment_key, override_config} ->
namespace = override_config |> Map.get("namespace") |> namespace_from_config()
experiment_override = %ExperimentOverride{
active?: Map.get(override_config, "active"),
namespace: namespace,
condition: Map.get(override_config, "condition"),
coverage: override_config |> Map.get("coverage") |> ensure_float(),
hash_attribute: Map.get(override_config, "hashAttribute"),
force: Map.get(override_config, "force"),
weights: Map.get(override_config, "weights")
}
{experiment_key, experiment_override}
end)
end
@doc """
Converts experiment configuration into an `GrowthBook.Experiment`.
Use this function to take the configuration from GrowthBook and
convert it into a usable `GrowthBook.Experiment` struct.
"""
@spec experiment_from_config(json_map()) :: Experiment.t()
def experiment_from_config(experiment_config) do
namespace = experiment_config |> Map.get("namespace") |> namespace_from_config()
%Experiment{
key: Map.get(experiment_config, "key"),
variations: Map.get(experiment_config, "variations"),
active?: Map.get(experiment_config, "active", true),
namespace: namespace,
condition: Map.get(experiment_config, "condition"),
coverage: experiment_config |> Map.get("coverage") |> ensure_float(),
hash_attribute: Map.get(experiment_config, "hashAttribute"),
force: Map.get(experiment_config, "force"),
weights: Map.get(experiment_config, "weights")
}
end
@doc """
Convert namespace configuration to a namespace.
Namespaces are represented by tuples, not lists, in the Elixir SDK, so this function converts
a list to the corresponding tuple.
"""
@spec namespace_from_config(term()) :: GrowthBook.namespace() | nil
def namespace_from_config([namespace_id, range_from, range_to]),
do: {namespace_id, ensure_float(range_from), ensure_float(range_to)}
def namespace_from_config(_namespace_not_found_or_empty), do: nil
@spec ensure_float(nil) :: nil
@spec ensure_float(number()) :: float()
defp ensure_float(nil), do: nil
defp ensure_float(number) when is_float(number), do: number
defp ensure_float(number) when is_integer(number), do: number / 1.0
end | lib/growth_book/config.ex | 0.912304 | 0.558628 | config.ex | starcoder |
defmodule Stopsel.Builder do
@moduledoc """
DSL to build a Stopsel router.
A router is declared using the `router/2` macro.
Within this macro you can declare commands, scopes and `Stopsel`.
The commands defined in the router will be used to route the messages
to the appropriate functions defined in other modules, parallely to the
router module.
Note: You can only define one router per module and you cannot use
builder functions outside of the router definition.
## Scopes
A scope encapsulates commands, stopsel from the parent scope.
The router-declaration acts as the root scope.
## Aliasing
Every scope can add an alias to the scopes and commands within it.
An alias is a module which implements a command that has been declared
in the router.
In the following example the router applies the initial alias `MyApp` and
the scope adds the alias Commands, resulting in the alias `MyApp.Commands`
for all commands defined within the scope.
```elixir
router MyApp do
scope "command", Commands do
# Define your commands here
end
end
```
## Paths
A path is a string with segments that are separated with a space.
There are 2 types of segments: Static segments and parameters.
Note: Avoid adding spaces in path segments as they can confuse
the `Stopsel.Invoker` module.
### Static segments
Text against which the content of a `Stopsel.Message` is matched against.
### Parameter
A parameter segment is defined by prepending `:` in front of the segment name.
These parameters will be available in the `:params` of the `Stopsel.Message`.
## Commands
A commands is defined with a name and optionally with path and assigns.
The name of a command must be the name of a function defined in the
current alias.
In this example the command `:execute` would be used to execute the function
`MyApp.Commands.execute/2`
```elixir
router MyApp do
scope "command", Commands do
command :execute
end
end
```
Similar to scopes you can define a path segment against which the message must
match against in order to execute the command. By default this will use the
name of the command, if no path was given.
Additionally assigns can be added to a command. These will be added to the
message before any stopsel are applied.
## Stopsel
A stopsel can be defined as a function or a module.
A message will pass through each of the stopsel that applies to the current
scope. Each stopsel can edit the message or halt the message from being
passed down to the command function.
For more information on stopsel see `Stopsel`
"""
alias Stopsel.Builder.{Helper, Scope}
@type do_block :: [do: term()]
@type stopsel :: module() | atom()
@type options :: any()
@type path :: String.t() | nil
@type assigns :: map() | Keyword.t()
@type name :: atom()
@type alias :: module()
@doc """
Starts the router definition.
Optionally a module can be provided to scope all command definitions.
Note that only one router can be defined per module.
"""
@spec router(alias() | nil, do_block()) :: Macro.t()
defmacro router(module \\ nil, do: block) do
quote location: :keep do
# Ensure only one router per module
if Module.get_attribute(__MODULE__, :router_defined?, false) do
raise Stopsel.RouterAlreadyDefinedError,
"The router has already been defined for #{__MODULE__}"
end
@in_router? true
@scope [%Scope{module: unquote(module)}]
Module.register_attribute(__MODULE__, :commands, accumulate: true, persist: true)
unquote(block)
def __commands__(), do: Enum.reject(@commands, &is_nil/1)
Module.delete_attribute(__MODULE__, :commands)
@in_router? false
@router_defined? true
end
end
@doc """
Adds a stopsel to the current scope.
A stopsel only active after the point it has been declared and does not
leave its scope. See `Stopsel` for more details.
Cannot be declared outside of the router.
"""
@spec stopsel(stopsel(), options()) :: Macro.t()
defmacro stopsel(stopsel, opts \\ []) do
quote location: :keep do
unquote(in_router!({:stopsel, 2}))
@scope Helper.put_stopsel(@scope, unquote(stopsel), unquote(opts), __ENV__)
end
end
@doc """
Scopes the stopsel and commands defined within the scope.
See the section "Paths" for more details on how paths are declared.
Cannot be declared outside of the router.
"""
@spec scope(path(), alias() | nil, do_block()) :: Macro.t()
defmacro scope(path \\ nil, module \\ nil, do: block) do
quote location: :keep do
unquote(in_router!({:scope, 3}))
@scope Helper.push_scope(@scope, unquote(path), unquote(module))
unquote(block)
@scope Helper.pop_scope(@scope)
end
end
@doc """
Adds a command to the router.
See the section "Paths" for more details on how paths are declared.
Additionally to the path you can also specify assigns that will be
added to the message before the stopsel are executed.
Cannot be declared outside of the router.
Options:
* `:path` - Aliases the path used for the current command.
Uses the name of the command by default
* `:assigns` - add additional assigns to the message
"""
@spec command(name(), [{:path, path()}, {:assigns, assigns()}]) :: Macro.t()
defmacro command(name, opts \\ []) do
path = Keyword.get(opts, :path)
assigns = Keyword.get(opts, :assigns, [])
quote location: :keep do
unquote(in_router!({:command, 2}))
@commands Helper.command(
@scope,
unquote(name),
unquote(path),
unquote(assigns)
)
end
end
defp in_router!(function) do
quote location: :keep do
unless Module.get_attribute(__MODULE__, :in_router?, false),
do: raise(Stopsel.OutsideOfRouterError, unquote(function))
end
end
end | lib/stopsel/builder.ex | 0.909327 | 0.891055 | builder.ex | starcoder |
defmodule Adventofcode2016.Solution.Day1 do
alias Adventofcode2016.Solution.Struct.Position
@input "L1, L3, L5, L3, R1, L4, L5, R1, R3, L5, R1, L3, L2, L3, R2, R2, L3, L3, R1, L2, R1, L3, L2, R4, R2, L5, R4, L5, R4, L2, R3, L2, R4, R1, L5, L4, R1, L2, R3, R1, R2, L4, R1, L2, R3, L2, L3, R5, L192, R4, L5, R4, L1, R4, L4, R2, L5, R45, L2, L5, R4, R5, L3, R5, R77, R2, R5, L5, R1, R4, L4, L4, R2, L4, L1, R191, R1, L1, L2, L2, L4, L3, R1, L3, R1, R5, R3, L1, L4, L2, L3, L1, L1, R5, L4, R1, L3, R1, L2, R1, R4, R5, L4, L2, R4, R5, L1, L2, R3, L4, R2, R2, R3, L2, L3, L5, R3, R1, L4, L3, R4, R2, R2, R2, R1, L4, R4, R1, R2, R1, L2, L2, R4, L1, L2, R3, L3, L5, L4, R4, L3, L1, L5, L3, L5, R5, L5, L4, L2, R1, L2, L4, L2, L4, L1, R4, R4, R5, R1, L4, R2, L4, L2, L4, R2, L4, L1, L2, R1, R4, R3, R2, R2, R5, L1, L2"
def solve() do
position =
%Position{}
|> insert_zero()
@input
|> split_input()
|> move(position)
|> calculate_distance()
|> IO.puts()
end
defp calculate_distance(%Position{x: x, y: y}) do
abs(x) + abs(y)
end
defp move(_list, %Position{stopped: true} = position) do
position
end
defp move([], position) do
position
end
defp move([{rotation, steps}| tail], position) do
new_position =
position
|> rotate(rotation)
|> jumping(steps)
move(tail, new_position)
end
defp rotate(%Position{direction: :W} = position, :L), do: %{position | direction: :S}
defp rotate(%Position{direction: :N} = position, :L), do: %{position | direction: :W}
defp rotate(%Position{direction: :S} = position, :L), do: %{position | direction: :E}
defp rotate(%Position{direction: :E} = position, :L), do: %{position | direction: :N}
defp rotate(%Position{direction: :N} = position, :R), do: %{position | direction: :E}
defp rotate(%Position{direction: :E} = position, :R), do: %{position | direction: :S}
defp rotate(%Position{direction: :S} = position, :R), do: %{position | direction: :W}
defp rotate(%Position{direction: :W} = position, :R), do: %{position | direction: :N}
defp jumping(%Position{direction: :N, x: x ,y: y} = position, steps), do: Enum.map((y+1)..(y+steps), &{x, &1}) |> moving(position)
defp jumping(%Position{direction: :S, x: x ,y: y} = position, steps), do: Enum.map((y-1)..(y-steps), &{x, &1}) |> moving(position)
defp jumping(%Position{direction: :E, x: x, y: y} = position, steps), do: Enum.map((x+1)..(x+steps), &{&1, y}) |> moving(position)
defp jumping(%Position{direction: :W, x: x, y: y} = position, steps), do: Enum.map((x-1)..(x-steps), &{&1, y}) |> moving(position)
defp moving([], position) do
position
end
defp moving([coordinate = {x,y}|tail], %Position{visited: set} = position) do
if MapSet.member?(set, coordinate) do
%{position| x: x, y: y, stopped: true}
else
moving(tail,%{position| visited: MapSet.put(set, coordinate), x: x, y: y})
end
end
defp split_input(string) do
string
|> String.split(", ")
|> Enum.map(&parse/1)
end
defp parse("L" <> n), do: {:L, String.to_integer(n)}
defp parse("R" <> n), do: {:R, String.to_integer(n)}
defp insert_zero(%Position{visited: mapset} = position) do
%{position| visited: MapSet.put(mapset, {0,0})}
end
end | lib/solutions/day1.ex | 0.661595 | 0.775307 | day1.ex | starcoder |
defmodule Excoverage.Settings do
@moduledoc """
Module provides application settings
"""
@args [
help: :boolean,
all: :boolean,
function: :boolean,
line: :boolean,
branch: :boolean,
include_folders: :string,
ignore_files: :string,
detailed_report: :boolean,
general_report: :boolena,
test_folders: :string
]
@aliases [
h: :help,
f: :function,
l: :line,
b: :branch,
i: :include_folders,
if: :ignore_files,
d: :detailed_report,
g: :general_report,
t: :test_folders
]
@type t :: %__MODULE__ {
help: boolean,
ignore_files: list(),
include_folders: list(),
mode: list(),
reports: list(),
test_folders: list()
}
defstruct help: false,
ignore_files: [],
include_folders: [],
mode: [],
reports: [:general],
test_folders: []
@doc """
Parse provided arguments
"""
@spec parse_args(argv :: [binary()]) ::
{:ok, keyword()} | {:error, [{String.t(), String.t() | nil}]}
def parse_args(argv) do
IO.inspect argv
IO.inspect argv[:include_folders]
case OptionParser.parse(argv, strict: @args, aliases: @aliases) do
{opts, _, []} -> IO.inspect(opts)
{:ok, opts}
{_, _, issues} -> {:error, issues}
end
end
@doc """
Validate parsed arguments
"""
@spec validate_opts(opts :: keyword())
:: {:ok, %__MODULE__{} | {:error, []}}
def validate_opts(opts) do
{
:ok, %__MODULE__{
help: opts[:help],
ignore_files: split_argument(opts[:ignore_files]),
include_folders: split_argument(opts[:include_folders], ["lib"]),
mode: get_modes(opts),
reports: get_reports(opts),
test_folders: split_argument(opts[:test_folders], ["test"])
}
}
end
@spec get_modes(opts :: keyword()) :: [atom()]
defp get_modes(opts) do
if(opts[:all]) do
[:line, :branch, :function]
else
if !opts[:line] && !opts[:branch] && !opts[:function] do
[:function]
else
Keyword.take(opts, [:line, :branch, :function])
|> parse_param_set()
end
end
end
@spec get_reports(opts :: keyword()) :: [atom()]
defp get_reports(opts) do
if(!opts[:general_report] && !opts[:detailed_report]) do
[:general_report]
else
Keyword.take(opts, [:general_report, :detailed_report])
|> parse_param_set()
end
end
@spec parse_param_set(opts :: keyword()) :: [atom()]
defp parse_param_set(opts) do
Enum.reduce(opts,[], fn({key, value}, acc) ->
if value do
[key | acc]
else
acc
end
end)
end
@spec split_argument(argument :: String.t, defaul_value :: list()) :: list()
defp split_argument(argument, default_value \\ [])
defp split_argument(:nil, default_value) do
default_value
end
@spec split_argument(argument :: String.t, defaul_value :: list()) :: list()
defp split_argument(argument, _default_value) do
IO.inspect argument
String.split(argument, " ")
end
end | lib/settings.ex | 0.673621 | 0.423428 | settings.ex | starcoder |
use Croma
defmodule Antikythera.Crypto do
@doc """
Checks equality of the given two binaries in constant-time to avoid [timing attacks](http://codahale.com/a-lesson-in-timing-attacks/).
"""
defun secure_compare(left :: v[binary], right :: v[binary]) :: boolean do
if byte_size(left) == byte_size(right) do
secure_compare_impl(left, right, 0) == 0
else
false
end
end
defp secure_compare_impl(<<x, left :: binary>>, <<y, right :: binary>>, acc) do
use Bitwise
secure_compare_impl(left, right, acc ||| (x ^^^ y))
end
defp secure_compare_impl(<<>>, <<>>, acc) do
acc
end
defmodule Aes do
@moduledoc """
Easy to use data encryption/decryption utilities.
Both Counter (CTR) mode and Galois/Counter mode (GCM) are supported.
When only secrecy of data is required, use CTR mode.
If you need not only secrecy but also data integrity, use GCM.
## Deriving an AES key from given password
The functions defined in this module accept arbitrary binary as password.
To make an AES key (which is 128bit length) from a given password, the functions by default use MD5 hash algorithm.
If you need to increase computational cost of key derivation and make attacks such as dictionary attacks more difficult,
you may pass your own key derivation function.
To implement your key derivation function you can use `:pbkdf2` library.
## Transparent handling of initialization vector
When encrypting given data, the encrypt function generates a random initialization vector and prepends it to the encrypted data.
The decrypt function extracts the initialization vector and use it to decrypt the rest.
## Associated Authenticated Data (AAD) for GCM
For GCM you may pass AAD (arbitrary binary) as an additional argument.
AAD is used only for generating/validating authentication tag; it doesn't affect resulting cipher text.
AAD can be used to provide contextual information for the authentication of cipher text.
For example, you could pass "login user ID" as AAD when encrypting/decrypting each user's data,
This way, even when a malicious user who somehow copied another user's encrypted data and secret key into his own account,
you could prevent him from decrypting the data because of the difference in AAD.
If you don't have any suitable data for AAD you can pass an empty string (which is the default value).
"""
alias Croma.Result, as: R
@iv_len 16
@auth_tag_len 16
@type key128 :: <<_::_ * 128>>
defun ctr128_encrypt(plain :: v[binary], password :: v[binary], key_derivation_fun :: (binary -> key128) \\ &md5/1) :: binary do
iv = :crypto.strong_rand_bytes(@iv_len)
key = key_derivation_fun.(password)
{_, encrypted} = :crypto.stream_init(:aes_ctr, key, iv) |> :crypto.stream_encrypt(plain)
iv <> encrypted
end
defun ctr128_decrypt(encrypted :: v[binary], password :: v[binary], key_derivation_fun :: (binary -> key128) \\ &md5/1) :: R.t(binary) do
split_16(encrypted)
|> R.map(fn {iv, enc} ->
key = key_derivation_fun.(password)
{_, plain} = :crypto.stream_init(:aes_ctr, key, iv) |> :crypto.stream_decrypt(enc)
plain
end)
end
defun gcm128_encrypt(plain :: v[binary], password :: v[binary], aad :: v[binary] \\ "", key_derivation_fun :: (binary -> key128) \\ &md5/1) :: binary do
iv = :crypto.strong_rand_bytes(@iv_len)
key = key_derivation_fun.(password)
{encrypted, auth_tag} = :crypto.block_encrypt(:aes_gcm, key, iv, {aad, plain, @auth_tag_len})
iv <> auth_tag <> encrypted
end
defun gcm128_decrypt(encrypted :: v[binary], password :: v[binary], aad :: v[binary] \\ "", key_derivation_fun :: (binary -> key128) \\ &md5/1) :: R.t(binary) do
R.m do
{iv , enc1} <- split_16(encrypted)
{tag, enc2} <- split_16(enc1)
key = key_derivation_fun.(password)
case :crypto.block_decrypt(:aes_gcm, key, iv, {aad, enc2, tag}) do
:error -> {:error, :decryption_failed}
plain -> {:ok, plain}
end
end
end
defunp md5(password :: v[binary]) :: key128 do
:crypto.hash(:md5, password)
end
defp split_16(<<iv :: binary-size(16), rest :: binary>>), do: {:ok, {iv, rest}}
defp split_16(_ ), do: {:error, :invalid_input}
end
end | lib/util/crypto.ex | 0.828592 | 0.487063 | crypto.ex | starcoder |
defmodule AWS.Textract do
@moduledoc """
Amazon Textract detects and analyzes text in documents and converts it into
machine-readable text.
This is the API reference documentation for Amazon Textract.
"""
alias AWS.Client
alias AWS.Request
def metadata do
%AWS.ServiceMetadata{
abbreviation: nil,
api_version: "2018-06-27",
content_type: "application/x-amz-json-1.1",
credential_scope: nil,
endpoint_prefix: "textract",
global?: false,
protocol: "json",
service_id: "Textract",
signature_version: "v4",
signing_name: "textract",
target_prefix: "Textract"
}
end
@doc """
Analyzes an input document for relationships between detected items.
The types of information returned are as follows:
* Form data (key-value pairs). The related information is returned
in two `Block` objects, each of type `KEY_VALUE_SET`: a KEY `Block` object and a
VALUE `Block` object. For example, *Name: <NAME>* contains a key and
value. *Name:* is the key. *<NAME>* is the value.
* Table and table cell data. A TABLE `Block` object contains
information about a detected table. A CELL `Block` object is returned for each
cell in a table.
* Lines and words of text. A LINE `Block` object contains one or
more WORD `Block` objects. All lines and words that are detected in the document
are returned (including text that doesn't have a relationship with the value of
`FeatureTypes`).
Selection elements such as check boxes and option buttons (radio buttons) can be
detected in form data and in tables. A SELECTION_ELEMENT `Block` object contains
information about a selection element, including the selection status.
You can choose which type of analysis to perform by specifying the
`FeatureTypes` list.
The output is returned in a list of `Block` objects.
`AnalyzeDocument` is a synchronous operation. To analyze documents
asynchronously, use `StartDocumentAnalysis`.
For more information, see [Document Text Analysis](https://docs.aws.amazon.com/textract/latest/dg/how-it-works-analyzing.html).
"""
def analyze_document(%Client{} = client, input, options \\ []) do
Request.request_post(client, metadata(), "AnalyzeDocument", input, options)
end
@doc """
`AnalyzeExpense` synchronously analyzes an input document for financially
related relationships between text.
Information is returned as `ExpenseDocuments` and seperated as follows.
* `LineItemGroups`- A data set containing `LineItems` which store
information about the lines of text, such as an item purchased and its price on
a receipt.
* `SummaryFields`- Contains all other information a receipt, such as
header information or the vendors name.
"""
def analyze_expense(%Client{} = client, input, options \\ []) do
Request.request_post(client, metadata(), "AnalyzeExpense", input, options)
end
@doc """
Analyzes identity documents for relevant information.
This information is extracted and returned as `IdentityDocumentFields`, which
records both the normalized field and value of the extracted text.
"""
def analyze_id(%Client{} = client, input, options \\ []) do
Request.request_post(client, metadata(), "AnalyzeID", input, options)
end
@doc """
Detects text in the input document.
Amazon Textract can detect lines of text and the words that make up a line of
text. The input document must be an image in JPEG or PNG format.
`DetectDocumentText` returns the detected text in an array of `Block` objects.
Each document page has as an associated `Block` of type PAGE. Each PAGE `Block`
object is the parent of LINE `Block` objects that represent the lines of
detected text on a page. A LINE `Block` object is a parent for each word that
makes up the line. Words are represented by `Block` objects of type WORD.
`DetectDocumentText` is a synchronous operation. To analyze documents
asynchronously, use `StartDocumentTextDetection`.
For more information, see [Document Text Detection](https://docs.aws.amazon.com/textract/latest/dg/how-it-works-detecting.html).
"""
def detect_document_text(%Client{} = client, input, options \\ []) do
Request.request_post(client, metadata(), "DetectDocumentText", input, options)
end
@doc """
Gets the results for an Amazon Textract asynchronous operation that analyzes
text in a document.
You start asynchronous text analysis by calling `StartDocumentAnalysis`, which
returns a job identifier (`JobId`). When the text analysis operation finishes,
Amazon Textract publishes a completion status to the Amazon Simple Notification
Service (Amazon SNS) topic that's registered in the initial call to
`StartDocumentAnalysis`. To get the results of the text-detection operation,
first check that the status value published to the Amazon SNS topic is
`SUCCEEDED`. If so, call `GetDocumentAnalysis`, and pass the job identifier
(`JobId`) from the initial call to `StartDocumentAnalysis`.
`GetDocumentAnalysis` returns an array of `Block` objects. The following types
of information are returned:
* Form data (key-value pairs). The related information is returned
in two `Block` objects, each of type `KEY_VALUE_SET`: a KEY `Block` object and a
VALUE `Block` object. For example, *Name: <NAME>* contains a key and
value. *Name:* is the key. *<NAME>* is the value.
* Table and table cell data. A TABLE `Block` object contains
information about a detected table. A CELL `Block` object is returned for each
cell in a table.
* Lines and words of text. A LINE `Block` object contains one or
more WORD `Block` objects. All lines and words that are detected in the document
are returned (including text that doesn't have a relationship with the value of
the `StartDocumentAnalysis` `FeatureTypes` input parameter).
Selection elements such as check boxes and option buttons (radio buttons) can be
detected in form data and in tables. A SELECTION_ELEMENT `Block` object contains
information about a selection element, including the selection status.
Use the `MaxResults` parameter to limit the number of blocks that are returned.
If there are more results than specified in `MaxResults`, the value of
`NextToken` in the operation response contains a pagination token for getting
the next set of results. To get the next page of results, call
`GetDocumentAnalysis`, and populate the `NextToken` request parameter with the
token value that's returned from the previous call to `GetDocumentAnalysis`.
For more information, see [Document Text Analysis](https://docs.aws.amazon.com/textract/latest/dg/how-it-works-analyzing.html).
"""
def get_document_analysis(%Client{} = client, input, options \\ []) do
Request.request_post(client, metadata(), "GetDocumentAnalysis", input, options)
end
@doc """
Gets the results for an Amazon Textract asynchronous operation that detects text
in a document.
Amazon Textract can detect lines of text and the words that make up a line of
text.
You start asynchronous text detection by calling `StartDocumentTextDetection`,
which returns a job identifier (`JobId`). When the text detection operation
finishes, Amazon Textract publishes a completion status to the Amazon Simple
Notification Service (Amazon SNS) topic that's registered in the initial call to
`StartDocumentTextDetection`. To get the results of the text-detection
operation, first check that the status value published to the Amazon SNS topic
is `SUCCEEDED`. If so, call `GetDocumentTextDetection`, and pass the job
identifier (`JobId`) from the initial call to `StartDocumentTextDetection`.
`GetDocumentTextDetection` returns an array of `Block` objects.
Each document page has as an associated `Block` of type PAGE. Each PAGE `Block`
object is the parent of LINE `Block` objects that represent the lines of
detected text on a page. A LINE `Block` object is a parent for each word that
makes up the line. Words are represented by `Block` objects of type WORD.
Use the MaxResults parameter to limit the number of blocks that are returned. If
there are more results than specified in `MaxResults`, the value of `NextToken`
in the operation response contains a pagination token for getting the next set
of results. To get the next page of results, call `GetDocumentTextDetection`,
and populate the `NextToken` request parameter with the token value that's
returned from the previous call to `GetDocumentTextDetection`.
For more information, see [Document Text Detection](https://docs.aws.amazon.com/textract/latest/dg/how-it-works-detecting.html).
"""
def get_document_text_detection(%Client{} = client, input, options \\ []) do
Request.request_post(client, metadata(), "GetDocumentTextDetection", input, options)
end
@doc """
Gets the results for an Amazon Textract asynchronous operation that analyzes
invoices and receipts.
Amazon Textract finds contact information, items purchased, and vendor name,
from input invoices and receipts.
You start asynchronous invoice/receipt analysis by calling
`StartExpenseAnalysis`, which returns a job identifier (`JobId`). Upon
completion of the invoice/receipt analysis, Amazon Textract publishes the
completion status to the Amazon Simple Notification Service (Amazon SNS) topic.
This topic must be registered in the initial call to `StartExpenseAnalysis`. To
get the results of the invoice/receipt analysis operation, first ensure that the
status value published to the Amazon SNS topic is `SUCCEEDED`. If so, call
`GetExpenseAnalysis`, and pass the job identifier (`JobId`) from the initial
call to `StartExpenseAnalysis`.
Use the MaxResults parameter to limit the number of blocks that are returned. If
there are more results than specified in `MaxResults`, the value of `NextToken`
in the operation response contains a pagination token for getting the next set
of results. To get the next page of results, call `GetExpenseAnalysis`, and
populate the `NextToken` request parameter with the token value that's returned
from the previous call to `GetExpenseAnalysis`.
For more information, see [Analyzing Invoices and Receipts](https://docs.aws.amazon.com/textract/latest/dg/invoices-receipts.html).
"""
def get_expense_analysis(%Client{} = client, input, options \\ []) do
Request.request_post(client, metadata(), "GetExpenseAnalysis", input, options)
end
@doc """
Starts the asynchronous analysis of an input document for relationships between
detected items such as key-value pairs, tables, and selection elements.
`StartDocumentAnalysis` can analyze text in documents that are in JPEG, PNG,
TIFF, and PDF format. The documents are stored in an Amazon S3 bucket. Use
`DocumentLocation` to specify the bucket name and file name of the document.
`StartDocumentAnalysis` returns a job identifier (`JobId`) that you use to get
the results of the operation. When text analysis is finished, Amazon Textract
publishes a completion status to the Amazon Simple Notification Service (Amazon
SNS) topic that you specify in `NotificationChannel`. To get the results of the
text analysis operation, first check that the status value published to the
Amazon SNS topic is `SUCCEEDED`. If so, call `GetDocumentAnalysis`, and pass the
job identifier (`JobId`) from the initial call to `StartDocumentAnalysis`.
For more information, see [Document Text Analysis](https://docs.aws.amazon.com/textract/latest/dg/how-it-works-analyzing.html).
"""
def start_document_analysis(%Client{} = client, input, options \\ []) do
Request.request_post(client, metadata(), "StartDocumentAnalysis", input, options)
end
@doc """
Starts the asynchronous detection of text in a document.
Amazon Textract can detect lines of text and the words that make up a line of
text.
`StartDocumentTextDetection` can analyze text in documents that are in JPEG,
PNG, TIFF, and PDF format. The documents are stored in an Amazon S3 bucket. Use
`DocumentLocation` to specify the bucket name and file name of the document.
`StartTextDetection` returns a job identifier (`JobId`) that you use to get the
results of the operation. When text detection is finished, Amazon Textract
publishes a completion status to the Amazon Simple Notification Service (Amazon
SNS) topic that you specify in `NotificationChannel`. To get the results of the
text detection operation, first check that the status value published to the
Amazon SNS topic is `SUCCEEDED`. If so, call `GetDocumentTextDetection`, and
pass the job identifier (`JobId`) from the initial call to
`StartDocumentTextDetection`.
For more information, see [Document Text Detection](https://docs.aws.amazon.com/textract/latest/dg/how-it-works-detecting.html).
"""
def start_document_text_detection(%Client{} = client, input, options \\ []) do
Request.request_post(client, metadata(), "StartDocumentTextDetection", input, options)
end
@doc """
Starts the asynchronous analysis of invoices or receipts for data like contact
information, items purchased, and vendor names.
`StartExpenseAnalysis` can analyze text in documents that are in JPEG, PNG, and
PDF format. The documents must be stored in an Amazon S3 bucket. Use the
`DocumentLocation` parameter to specify the name of your S3 bucket and the name
of the document in that bucket.
`StartExpenseAnalysis` returns a job identifier (`JobId`) that you will provide
to `GetExpenseAnalysis` to retrieve the results of the operation. When the
analysis of the input invoices/receipts is finished, Amazon Textract publishes a
completion status to the Amazon Simple Notification Service (Amazon SNS) topic
that you provide to the `NotificationChannel`. To obtain the results of the
invoice and receipt analysis operation, ensure that the status value published
to the Amazon SNS topic is `SUCCEEDED`. If so, call `GetExpenseAnalysis`, and
pass the job identifier (`JobId`) that was returned by your call to
`StartExpenseAnalysis`.
For more information, see [Analyzing Invoices and Receipts](https://docs.aws.amazon.com/textract/latest/dg/invoice-receipts.html).
"""
def start_expense_analysis(%Client{} = client, input, options \\ []) do
Request.request_post(client, metadata(), "StartExpenseAnalysis", input, options)
end
end | lib/aws/generated/textract.ex | 0.917635 | 0.674955 | textract.ex | starcoder |
defmodule Regulator.Limit.AIMD do
@moduledoc """
Loss based dynamic limit algorithm. Additively increases the concurrency
limit when there are no errors and multiplicatively decrements the limit
when there are errors.
To use this regulator you must specify a "target average latency". Regulator collects
measurements of your service calls and averages them over a sliding window. If the
average latency is above the target specified, regulator considers it an error
and will begin to multiplicatively decrease the concurrency limit. If the avg latency
is *below* the target **and** over half of the concurrency tokens were utilized
during the window, then regulator will increase the concurrency limit by a fixed value.
If less than half of the concurrency tokens were utilized in the window, Regulator
leaves the concurrency limit as is, since there is no need for additional tokens.
Finally, if there was any errors that occured during the window, Regulator treats that
as a backoff situation and will begin to reduce the concurrency limit.
## Options
* `:min_limit` - The minimum concurrency limit (defaults to 5)
* `:initial_limit` - The initial concurrency limit when the regulator is installed (deafults to 20)
* `:max_limit` - The maximum concurrency limit (defaults to 200)
* `:step_increase` - The number of tokens to add when regulator is increasing the concurrency limit (defaults to 10).
* `:backoff_ratio` - Floating point value for how quickly to reduce the concurrency limit (defaults to 0.9)
* `:target_avg_latency` - This is the average latency in milliseconds for the system regulator is protecting. If the average latency drifts above this value Regulator considers it an error and backs off. Defaults to 5.
* `:timeout` - alias for `target_avg_latency`.
"""
@behaviour Regulator.Limit
alias Regulator.Window
defstruct [
min_limit: 5,
initial_limit: 20,
max_limit: 200,
backoff_ratio: 0.9,
target_avg_latency: 5,
step_increase: 10,
]
@impl true
def new(opts) do
legacy_timeout = opts[:timeout] || 5
opts =
opts
|> Keyword.new()
|> Keyword.put_new(:target_avg_latency, legacy_timeout)
config = struct(__MODULE__, opts)
%{config | target_avg_latency: System.convert_time_unit(config.target_avg_latency, :millisecond, :native)}
end
@impl true
def initial(config) do
config.initial_limit
end
@impl true
def update(config, current_limit, window) do
current_limit = cond do
# If we've dropped a request or if the avg rtt is greater than the timeout
# we backoff
window.did_drop? || Window.avg_rtt(window) > config.target_avg_latency ->
# Floors the value and converts to integer
trunc(current_limit * config.backoff_ratio)
# If we're halfway to the current limit go ahead and increase the limit.
window.max_inflight * 2 >= current_limit ->
current_limit + config.step_increase
true ->
current_limit
end
# If we're at the max limit reset to 50% of the maximum limit
current_limit = if config.max_limit <= current_limit do
div(current_limit, 2)
else
current_limit
end
# Return the new limit bounded by the configured min and max
{config, min(config.max_limit, max(config.min_limit, current_limit))}
end
end | lib/regulator/limit/aimd.ex | 0.884978 | 0.757481 | aimd.ex | starcoder |
defmodule Quantum.Job do
@moduledoc """
This Struct defines a Job.
## Usage
The struct should never be defined by hand. Use `Acme.Scheduler.new_job/0` to create a new job and use the setters mentioned
below to mutate the job.
This is to ensure type safety.
"""
alias Crontab.CronExpression
@enforce_keys [:name, :run_strategy, :overlap, :timezone]
defstruct [
:run_strategy,
:overlap,
:timezone,
:name,
schedule: nil,
task: nil,
state: :active
]
@type name :: atom | reference()
@type state :: :active | :inactive
@type task :: {atom, atom, [any]} | (() -> any)
@type timezone :: :utc | String.t()
@type schedule :: Crontab.CronExpression.t()
@type t :: %__MODULE__{
name: name,
schedule: schedule | nil,
task: task | nil,
state: state,
run_strategy: Quantum.RunStrategy.NodeList,
overlap: boolean,
timezone: timezone
}
@doc """
Takes some config from a scheduler and returns a new job
### Examples
iex> Acme.Scheduler.config
...> |> Quantum.Job.new
%Quantum.Job{...}
"""
@spec new(config :: Keyword.t()) :: t
def new(config) do
{run_strategy_name, options} =
case Keyword.fetch!(config, :run_strategy) do
{module, option} -> {module, option}
module -> {module, nil}
end
with run_strategy <- run_strategy_name.normalize_config!(options),
name <- make_ref(),
overlap when is_boolean(overlap) <- Keyword.fetch!(config, :overlap),
timezone when timezone == :utc or is_binary(timezone) <-
Keyword.fetch!(config, :timezone),
state when is_atom(state) <- Keyword.fetch!(config, :state),
schedule <- Keyword.get(config, :schedule) do
%__MODULE__{
name: name,
overlap: Keyword.fetch!(config, :overlap),
timezone: Keyword.fetch!(config, :timezone),
run_strategy: run_strategy,
schedule: schedule,
state: state
}
end
end
@doc """
Sets a job's name.
### Parameters
1. `job` - The job struct to modify
2. `name` - The name to set
### Examples
iex> Acme.Scheduler.new_job()
...> |> Quantum.Job.set_name(:name)
...> |> Map.get(:name)
:name
"""
@spec set_name(t, atom) :: t
def set_name(%__MODULE__{} = job, name) when is_atom(name), do: Map.put(job, :name, name)
@doc """
Sets a job's schedule.
### Parameters
1. `job` - The job struct to modify
2. `schedule` - The schedule to set. May only be of type `%Crontab.CronExpression{}`
### Examples
iex> Acme.Scheduler.new_job()
...> |> Quantum.Job.set_schedule(Crontab.CronExpression.Parser.parse!("*/7"))
...> |> Map.get(:schedule)
Crontab.CronExpression.Parser.parse!("*/7")
"""
@spec set_schedule(t, CronExpression.t()) :: t
def set_schedule(%__MODULE__{} = job, %CronExpression{} = schedule),
do: %{job | schedule: schedule}
@doc """
Sets a job's task.
### Parameters
1. `job` - The job struct to modify
2. `task` - The function to be performed, ex: `{Heartbeat, :send, []}` or `fn -> :something end`
### Examples
iex> Acme.Scheduler.new_job()
...> |> Quantum.Job.set_task({Backup, :backup, []})
...> |> Map.get(:task)
{Backup, :backup, []}
"""
@spec set_task(t, task) :: t
def set_task(%__MODULE__{} = job, {module, function, args} = task)
when is_atom(module) and is_atom(function) and is_list(args),
do: Map.put(job, :task, task)
def set_task(%__MODULE__{} = job, task) when is_function(task, 0), do: Map.put(job, :task, task)
@doc """
Sets a job's state.
### Parameters
1. `job` - The job struct to modify
2. `state` - The state to set
### Examples
iex> Acme.Scheduler.new_job()
...> |> Quantum.Job.set_state(:active)
...> |> Map.get(:state)
:active
"""
@spec set_state(t, state) :: t
def set_state(%__MODULE__{} = job, :active), do: Map.put(job, :state, :active)
def set_state(%__MODULE__{} = job, :inactive), do: Map.put(job, :state, :inactive)
@doc """
Sets a job's run strategy.
### Parameters
1. `job` - The job struct to modify
2. `run_strategy` - The run strategy to set
### Examples
iex> Acme.Scheduler.new_job()
...> |> Quantum.Job.run_strategy(%Quantum.RunStrategy.All{nodes: [:one, :two]})
...> |> Map.get(:run_strategy)
[:one, :two]
"""
@spec set_run_strategy(t, Quantum.RunStrategy.NodeList) :: t
def set_run_strategy(%__MODULE__{} = job, run_strategy),
do: Map.put(job, :run_strategy, run_strategy)
@doc """
Sets a job's overlap.
### Parameters
1. `job` - The job struct to modify
2. `overlap` - Enable / Disable Overlap
### Examples
iex> Acme.Scheduler.new_job()
...> |> Quantum.Job.set_overlap(false)
...> |> Map.get(:overlap)
false
"""
@spec set_overlap(t, boolean) :: t
def set_overlap(%__MODULE__{} = job, overlap?) when is_boolean(overlap?),
do: Map.put(job, :overlap, overlap?)
@doc """
Sets a job's timezone.
### Parameters
1. `job` - The job struct to modify
2. `timezone` - The timezone to set.
### Examples
iex> Acme.Scheduler.new_job()
...> |> Quantum.Job.set_timezone("Europe/Zurich")
...> |> Map.get(:timezone)
"Europe/Zurich"
"""
@spec set_timezone(t, String.t() | :utc) :: t
def set_timezone(%__MODULE__{} = job, timezone), do: Map.put(job, :timezone, timezone)
end | lib/quantum/job.ex | 0.904173 | 0.525917 | job.ex | starcoder |
defmodule RedisGraph do
@moduledoc """
Provides the components to construct and interact with Graph
entities in a RedisGraph database.
This library uses [Redix](https://github.com/whatyouhide/redix) to
communicate with a redisgraph server.
To launch ``redisgraph`` locally with Docker, use
```bash
docker run -p 6379:6379 -it --rm redislabs/redisgraph
```
Here is a simple example:
```elixir
alias RedisGraph.{Node, Edge, Graph, QueryResult}
# Create a connection using Redix
{:ok, conn} = Redix.start_link("redis://localhost:6379")
# Create a graph
graph = Graph.new(%{
name: "social"
})
# Create a node
john = Node.new(%{
label: "person",
properties: %{
name: "<NAME>",
age: 33,
gender: "male",
status: "single"
}
})
# Add the node to the graph
# The graph and node are returned
# The node may be modified if no alias has been set
# For this reason, nodes should always be added to the graph
# before creating edges between them.
{graph, john} = Graph.add_node(graph, john)
# Create a second node
japan = Node.new(%{
label: "country",
properties: %{
name: "Japan"
}
})
# Add the second node
{graph, japan} = Graph.add_node(graph, japan)
# Create an edge connecting the two nodes
edge = Edge.new(%{
src_node: john,
dest_node: japan,
relation: "visited"
})
# Add the edge to the graph
# If the nodes are not present, an {:error, error} is returned
{:ok, graph} = Graph.add_edge(graph, edge)
# Commit the graph to the database
{:ok, commit_result} = RedisGraph.commit(conn, graph)
# Print the transaction statistics
IO.inspect(commit_result.statistics)
# Create a query to fetch some data
query = "MATCH (p:person)-[v:visited]->(c:country) RETURN p.name, p.age, v.purpose, c.name"
# Execute the query
{:ok, query_result} = RedisGraph.query(conn, graph.name, query)
# Pretty print the results using the Scribe lib
IO.puts(QueryResult.pretty_print(query_result))
```
which gives the following results:
```elixir
# Commit result statistics
%{
"Labels added" => nil,
"Nodes created" => "2",
"Nodes deleted" => nil,
"Properties set" => "5",
"Query internal execution time" => "0.228669",
"Relationships created" => "1",
"Relationships deleted" => nil
}
# Query result pretty-printed
+----------------+-------------+-----------------+--------------+
| "p.name" | "p.age" | "v.purpose" | "c.name" |
+----------------+-------------+-----------------+--------------+
| "<NAME>" | 33 | nil | "Japan" |
+----------------+-------------+-----------------+--------------+
```
"""
alias RedisGraph.Edge
alias RedisGraph.Graph
alias RedisGraph.Node
alias RedisGraph.QueryResult
alias RedisGraph.Util
require Logger
@type connection() :: GenServer.server()
@doc """
Execute arbitrary command against the database.
https://oss.redislabs.com/redisgraph/commands/
Query commands will be a list of strings. They
will begin with either ``GRAPH.QUERY``,
``GRAPH.EXPLAIN``, or ``GRAPH.DELETE``.
The next element will be the name of the graph.
The third element will be the query command.
Optionally pass the last element ``--compact``
for compact results.
## Example:
[
"GRAPH.QUERY",
"imdb",
"MATCH (a:actor)-[:act]->(m:movie {title:'straight outta compton'})",
"--compact"
]
"""
@spec command(connection(), list(String.t())) ::
{:ok, QueryResult.t()} | {:error, any()}
def command(conn, c) do
Logger.debug(Enum.join(c, " "))
case Redix.command(conn, c) do
{:ok, result} ->
{:ok, QueryResult.new(%{conn: conn, graph_name: Enum.at(c, 1), raw_result_set: result})}
{:error, _reason} = error ->
error
end
end
@doc """
Query on a graph in the database.
Returns a `RedisGraph.QueryResult` containing the result set
and metadata associated with the query.
https://oss.redislabs.com/redisgraph/commands/#graphquery
"""
@spec query(connection(), String.t(), String.t()) ::
{:ok, QueryResult.t()} | {:error, any()}
def query(conn, name, q) do
c = ["GRAPH.QUERY", name, q, "--compact"]
command(conn, c)
end
@doc """
Fetch the execution plan for a query on a graph.
Returns a raw result containing the query plan.
https://oss.redislabs.com/redisgraph/commands/#graphexplain
"""
@spec execution_plan(connection(), String.t(), String.t()) ::
{:ok, QueryResult.t()} | {:error, any()}
def execution_plan(conn, name, q) do
c = ["GRAPH.EXPLAIN", name, q]
case Redix.command(conn, c) do
{:error, _reason} = error ->
error
{:ok, result} ->
Logger.debug(result)
{:ok, result}
end
end
@doc """
Commit a `RedisGraph.Graph` to the database using ``CREATE``.
Returns a `RedisGraph.QueryResult` which contains query
statistics related to entities created.
https://oss.redislabs.com/redisgraph/commands/#create
"""
@spec commit(connection(), Graph.t()) ::
{:ok, QueryResult.t()} | {:error, any()}
def commit(conn, graph) do
if length(graph.edges) == 0 and map_size(graph.nodes) == 0 do
{:error, "graph is empty"}
else
nodes_string =
graph.nodes
|> Enum.map(fn {_label, node} -> Node.to_query_string(node) end)
|> Enum.join(",")
edges_string =
graph.edges
|> Enum.map(&Edge.to_query_string/1)
|> Enum.join(",")
query_string = "CREATE " <> nodes_string <> "," <> edges_string
query_string =
if String.at(query_string, -1) == "," do
String.slice(query_string, 0..-2)
else
query_string
end
RedisGraph.query(conn, graph.name, query_string)
end
end
@doc """
Delete a graph from the database.
Returns a `RedisGraph.QueryResult` with statistic for
query execution time.
https://oss.redislabs.com/redisgraph/commands/#delete
"""
@spec delete(connection(), String.t()) ::
{:ok, QueryResult.t()} | {:error, any()}
def delete(conn, name) do
command = ["GRAPH.DELETE", name]
RedisGraph.command(conn, command)
end
@doc """
Merge a pattern into the graph.
Creates or updates the graph pattern into the graph specified
using the ``MERGE`` command.
Returns a `RedisGraph.QueryResult` with statistics for
entities created.
https://oss.redislabs.com/redisgraph/commands/#merge
"""
@spec merge(connection(), String.t(), String.t()) ::
{:ok, QueryResult.t()} | {:error, any()}
def merge(conn, name, pattern) do
RedisGraph.query(conn, name, "MERGE " <> pattern)
end
@doc """
Execute a procedure call against the graph specified.
Returns the raw result of the procedure call.
https://oss.redislabs.com/redisgraph/commands/#procedures
"""
@spec call_procedure(connection(), String.t(), String.t(), list(), map()) ::
{:ok, list()} | {:error, any()}
def call_procedure(conn, name, procedure, args \\ [], kwargs \\ %{}) do
args =
args
|> Enum.map(&Util.quote_string/1)
|> Enum.join(",")
yields = Map.get(kwargs, "y", [])
yields =
if length(yields) > 0 do
" YIELD " <> Enum.join(yields, ",")
else
""
end
q = "CALL " <> procedure <> "(" <> args <> ")" <> yields
c = ["GRAPH.QUERY", name, q, "--compact"]
case Redix.command(conn, c) do
{:ok, result} ->
{:ok, result}
{:error, _reason} = error ->
error
end
end
@doc "Fetch the raw response of the ``db.labels()`` procedure call against the specified graph."
@spec labels(connection(), String.t()) :: {:ok, list()} | {:error, any()}
def labels(conn, name) do
call_procedure(conn, name, "db.labels")
end
@doc "Fetch the raw response of the ``db.relationshipTypes()`` procedure call against the specified graph."
@spec relationship_types(connection(), String.t()) :: {:ok, list()} | {:error, any()}
def relationship_types(conn, name) do
call_procedure(conn, name, "db.relationshipTypes")
end
@doc "Fetch the raw response of the ``db.propertyKeys()`` procedure call against the specified graph."
@spec property_keys(connection(), String.t()) :: {:ok, list()} | {:error, any()}
def property_keys(conn, name) do
call_procedure(conn, name, "db.propertyKeys")
end
end | lib/redis_graph.ex | 0.909684 | 0.86916 | redis_graph.ex | starcoder |
defmodule Hook do
@moduledoc """
An interface to define and leverage runtime resolution.
In various module and function docs it is common to document options like so:
> # Options
>
> - `:option1_name` - `type`. # since no default is specified, this option is required
> - `:option2_name` - `type`. Descriptive text. # since no default is specified, this option is required
> - `:option3_name` - `type`. `default`. # since a default is specified, this option is not required
> - `:option4_name` - `type`. `default`. Descriptive text. # since a default is specified, this option is not required
# Compile time Configuration
These options can be set compile time to configure how `m:Hook.hook/1` behaves. `m:Hook.hook/1`
will be referred to as "the macro".
- `mappings` - `keyword()`. Mappings that the macro will resolve against.
- `resolve_at` - `:compile_time | :run_time | :never`. When `:compile_time` or `:run_time`, the
macro will resolve its term at the respective time. When `:never`, the macro will compile
directly into its term with no attempt to resolve against mappings.
- `top_level_module_allowlist` - `[module()]`. When the macro's calling module's
top-level-module is in this list, the `:resolve_at` option will be respected. Otherwise, it
will behave as if `resolve_at: :never` for that instance of the macro. This allows developers
to control whether or not individual instances of the macro should ever attempt resolution or
not with a top-level-module granularity. The common value for this option is the top level
module of your application so that any instance of the macro throughout your application's
code will respect the `:resolve_at` option, and any instance of the macro outside your
application's code will behave as if `resolve_at: :never`. An example of "code outside your
application" is if any of your application's dependencies happen to also use the macro.
# Groups
Mappings are defined under `t:group/0`s. Hook defaults the group to be the calling process
making process isolation of mappings frictionless. Any term can also be supplied as the group.
Putting `:foo` under `:bar` in the `:red` group, than fetching it from the `:blue` group will
fail.
# Resolution
Starting with the calling process:
1. does the process define a mapping for the term
1.1. the term has been resolved
2. does the process define fallbacks
2.1. for each fallback in order: goto step 1
3. does the process have :"$ancestors"
3.1. for each ancestor in order: goto step 1
3. does the process have :"$callers"
3.1. for each caller in order: goto step 1
4. the term has not been resolved
# Performance
In general, the thing to focus on with respect to performance is whether the function call is
getting serialized through a GenServer or not. You will find that only calls that result in a
write get serialized and those that only read do not.
Functions that get serialized through a GenServer:
- `callback/3,4`
- `fallback/1,2`
- `put/2,3`
- `resolve_callback/3`
Functions that do not get serialized through a GenServer:
- `assert/0,1`
- `callbacks/0,1`
- `fetch!/1,2`
- `fetch/1,2`
- `get/1,2,3`
- `get_all/0,1`
- `hook/1`
This means that a "hot path" that is resolving a term via these functions should remain
performant outside of extreme cases.
"""
alias Hook.Server
@resolve_at Application.compile_env!(:hook, :resolve_at)
@top_level_module_allowlist Application.compile_env!(:hook, :top_level_module_allowlist)
@mappings Application.compile_env!(:hook, :mappings)
@type callback_opt() :: {:group, group()} | {:count, count()}
@type callback_opts() :: [callback_opt()]
@type config() :: %{hook?: boolean() | (any() -> boolean())}
@type count() :: pos_integer() | :infinity
@type fun_key() :: {function_name :: atom(), arity :: non_neg_integer()}
@type group() :: pid() | atom()
@type key() :: any()
@type mappings() :: [{key(), value()} | {key(), value(), group()}]
@type value() :: any()
@callback assert(group()) :: :ok
@callback callback(module(), function_name :: atom(), fun(), callback_opts()) :: :ok
@callback callbacks(group()) :: %{resolved: [], unresolved: [{count(), pid(), function()}]}
@callback fallback(dest :: group(), src :: group()) ::
:ok | {:error, {:invalid_group, :destination | :source}}
@callback fetch!(any(), group()) :: any()
@callback fetch(key(), group()) :: {:ok, any()} | :error
@callback get(key(), default :: any(), group()) :: {:ok, any()} | :error
@callback get_all(group()) :: {:ok, %{}} | :error
@callback put(key(), value(), group()) :: :ok
@callback put_all(mappings()) :: :ok
@callback put_all(mappings(), group()) :: :ok
@callback resolve_callback(module(), fun_key(), args :: [any()]) :: any()
defmacro __using__(_opts) do
quote do
import Hook, only: [hook: 1]
end
end
@doc """
A macro that compiles into `term` itself or a `Hook.fetch(term)` call.
Check the "Compile time Configuration" section for information about configuring this
functionality.
"""
defmacro hook(term) do
caller_top_level_module =
__CALLER__.module
|> Module.split()
|> hd()
|> List.wrap()
|> Module.concat()
valid_caller_module = caller_top_level_module in @top_level_module_allowlist
cond do
valid_caller_module ->
case @resolve_at do
:run_time ->
quote do
Hook.get(unquote(term), unquote(term))
end
:compile_time ->
expanded = Macro.expand(term, __CALLER__)
value =
case List.keyfind(@mappings, expanded, 0) do
mapping when tuple_size(mapping) >= 2 -> elem(mapping, 1)
_ -> expanded
end
quote do
unquote(value)
end
:never ->
quote do
unquote(term)
end
end
true ->
quote do
unquote(term)
end
end
end
@doc """
Asserts that all callbacks defined via `Hook.callback/4` have been satisfied.
Returns `:ok` if the assertion holds, raises otherwise.
Infinity-callbacks and 0-callbacks are inherently satisfied.
"""
defdelegate assert(group \\ self()), to: Server
@doc """
Defines a callback that can be consumed and asserted on.
**Note:** `module` will be defined under the calling process.
This function will raise when the specified callback is not a public function on `module`.
# Options
`:count` - How many times the callback can be consumed.
- `:infinity` - The callback can be consumed an infinite number of times. For a module,
function, and arity, only a single infinity-callback will be defined at once, last write
wins. Infinity-callbacks are always consumed after non-infinity-callbacks.
- `0` - The callback should never be consumed. Raises an error if it is. The callback is
removed upon raising.
"""
defdelegate callback(module, function_name, function, opts \\ []), to: Server
@doc """
Return `group`'s callbacks.
"""
defdelegate callbacks(group \\ self()), to: Server
@doc """
Prepend `group` to the calling process' fallbacks.
**NOTE:** `:global` cannot be used as a `src_group`.
"""
defdelegate fallback(src_group \\ self(), dest_group), to: Server
@doc """
Gets the value for `key` for `group` returning `default` if it is not defined.
"""
defdelegate get(key, default \\ nil, group \\ self()), to: Server
@doc """
Gets all values for `group`.
"""
defdelegate get_all(group \\ self()), to: Server
@doc """
Puts `value` under `key` for `group`.
"""
defdelegate put(key, value, group \\ self()), to: Server
@doc """
Puts all key value pairs under `group`.
"""
defdelegate put_all(kvps, group \\ self()), to: Server
@doc """
Fetches the value for `key` for `group`.
"""
defdelegate fetch(key, group \\ self()), to: Server
@doc """
See `Hook.fetch/2`.
"""
defdelegate fetch!(key, group \\ self()), to: Server
@doc """
Resolves a callback for the calling process and executes it with `args`.
"""
defdelegate resolve_callback(module, fun_key, args), to: Server
end | lib/hook.ex | 0.881653 | 0.579073 | hook.ex | starcoder |
defmodule ExUUID do
@moduledoc """
UUID generator according to [RFC 4122](https://www.ietf.org/rfc/rfc4122.txt).
"""
import ExUUID.Impl,
only: [
uuid: 3,
uuid: 5,
timestamp: 0,
clock_sequence: 0,
node_id: 0,
random_node_id: 1,
hash: 3
]
alias ExUUID.Impl
@type bin :: <<_::128>>
@type str :: <<_::288>>
@type hex :: <<_::256>>
@type uuid :: bin() | str() | hex()
@type namespace :: :dns | :url | :oid | :x500 | nil | uuid
@type name :: binary()
@type version :: 1 | 3 | 4 | 5 | 6
@type variant ::
:rfc4122
| :reserved_future
| :reserved_microsoft
| :reserved_ncs
@type format :: :default | :hex | :binary
@namespaces [:dns, :url, :oid, :x500, nil]
@doc """
Builds a new UUID of the given `version` and `format`.
- Version `:v1` returns a UUID generated by a timestamp and node id.
- Version `:v4` return a UUID generated by a (pseudo) random number generator.
- Version `:v6` returns a UUID generated by a timestamp and node id. With the
option `random: true` the node is generated by a (pseudo) random number
generator. The default is `true`.
The option `:format` specifies the type of the UUID, possible values are
`:default`, `:hex`, and `binary`. The default is `:default`.
## Examples
```elixir
iex> ExUUID.new(:v1)
"58044c1e-51e1-11eb-b72d-0982c5a64d6d"
iex> ExUUID.new(:v1, format: :hex)
"58044c1e51e111ebb72d0982c5a64d6d"
iex> ExUUID.new(:v1, fromat: :binary)
<<88, 4, 76, 30, 81, 225, 17, 235, 183, 45, 9, 130, 197, 166, 77, 109>>
iex> ExUUID.new(:v4)
"be134339-2dba-465b-9961-1ac281f111d8"
iex> ExUUID.new(:v6)
"1eb51e21-bd8e-606e-a438-33b3c732d898"
iex> ExUUID.new(:v6, random: false)
"1eb51e23-1704-66ce-a6ef-0982c5a64d6d"
```
"""
@spec new(:v1 | :v4 | :v6, keyword()) :: uuid()
def new(version, opts \\ [])
def new(:v1, opts) do
uuid(:v1, timestamp(), clock_sequence(), node_id(), format(opts))
end
def new(:v4, opts) do
uuid(:v4, :crypto.strong_rand_bytes(16), format(opts))
end
def new(:v6, opts) do
node_id = random_node_id(Keyword.get(opts, :random, true))
uuid(:v6, timestamp(), clock_sequence(), node_id, format(opts))
end
@doc """
Builds a new UUID of the given `version` and `format`.
- Version `:v3` returns a UUID generated using MD5 and a given `name` within a
`namespace`.
- Version `:v5` returns a UUID generated using SHA1 and a given `name`
within a `namespace`.
The option `:format` specifies the type of the UUID, possible values are
`:default`, `:hex`, and `binary`. The default is `:default`.
## Examples
```elixir
iex> ExUUID.new(:v3, :dns, "example.com")
"9073926b-929f-31c2-abc9-fad77ae3e8eb"
iex> ExUUID.new(:v5, :dns, "example.com", format: :hex)
"cfbff0d193755685968c48ce8b15ae17"
iex> ExUUID.new(:v5, :dns, "example.com", format: :binary)
<<207, 191, 240, 209, 147, 117, 86, 133, 150, 140, 72, 206, 139, 21, 174, 23>>
iex> ns = "58044c1e-51e1-11eb-b72d-0982c5a64d6d"
...> ExUUID.new(:v3, ns, "example.com")
"c2e032d5-369d-39f3-a274-a7cf0f556202"
iex> {:ok, ns_bin} = ExUUID.to_binary(ns)
iex> ExUUID.new(:v3, ns_bin, "example.com")
"c2e032d5-369d-39f3-a274-a7cf0f556202"
```
"""
@spec new(:v3 | :v5, namespace(), name(), keyword()) :: uuid()
def new(version, namespace, name, opts \\ [])
when (namespace in @namespaces or is_binary(namespace)) and
version in [:v3, :v5] and
is_binary(name) do
case hash(version, namespace, name) do
{:ok, hash} -> uuid(version, hash, format(opts))
:error -> raise ArgumentError, "invalid namespace"
end
end
@doc """
Converts the `uuid` to binary.
Returns `{:ok, binary}` for a valid UUID, otherwise `error`.
## Examples
```elixir
iex> ExUUID.to_binary("58044c1e-51e1-11eb-b72d-0982c5a64d6d")
{:ok, <<88, 4, 76, 30, 81, 225, 17, 235, 183, 45, 9, 130, 197, 166, 77, 109>>}
iex> ExUUID.to_binary("58044c1e-xxxx-11eb-b72d-0982c5a64d6d")
:error
```
"""
@spec to_binary(uuid()) :: {:ok, bin()} | :error
def to_binary(uuid), do: Impl.to_binary(uuid)
@doc """
Converts the binary `uuid` to a string in the given `:format` option.
Returns `{:ok, string}` for a valid UUID, otherwise `error`.
## Examples
```elixir
iex> ExUUID.to_string(
...> <<88, 4, 76, 30, 81, 225, 17, 235, 183, 45, 9, 130, 197, 166, 77, 109>>)
{:ok, "58044c1e-51e1-11eb-b72d-0982c5a64d6d"}
iex> ExUUID.to_string(
...> <<88, 4, 76, 30, 81, 225, 17, 235, 183, 45, 9, 130, 197, 166, 77, 109>>,
...> format: :hex)
{:ok, "58044c1e51e111ebb72d0982c5a64d6d"}
```
"""
@spec to_string(uuid(), keyword()) :: {:ok, uuid()} | :error
def to_string(uuid, opts \\ []), do: Impl.to_string(uuid, format(opts))
@doc """
Returns `true` if the given `uuid` is valid, otherwise `false`.
## Examples
```elixir
iex> ExUUID.valid?("58044c1e-51e1-11eb-b72d-0982c5a64d6d")
true
iex> ExUUID.valid?("58044c1e-51e1-ffff-b72d-0982c5a64d6d")
false
```
"""
@spec valid?(uuid()) :: boolean()
def valid?(uuid), do: Impl.valid?(uuid)
@doc """
Returns the variant for the given `uuid`.
Returns `{:ok, variant}` for a valid UUID, otherwise `:error`.
## Examples
```elixir
iex> ExUUID.variant("58044c1e51e111ebb72d0982c5a64d6d")
{:ok, :rfc4122}
```
"""
@spec variant(uuid()) :: {:ok, variant()} | :error
def variant(uuid), do: Impl.variant(uuid)
@doc """
Returns the version for the given `uuid`.
Returns `{:ok, version}` for a valid UUID, otherwise `:error`.
## Examples
```elixir
iex> :v1 |> ExUUID.new() |> ExUUID.version()
{:ok, 1}
```
"""
@spec version(uuid()) :: {:ok, version()} | :error
def version(uuid), do: Impl.version(uuid)
defp format(opts), do: Keyword.get(opts, :format, :default)
end | lib/ex_uuid.ex | 0.898461 | 0.758734 | ex_uuid.ex | starcoder |
defmodule Elixush.Instructions.Common do
@moduledoc "Common instructions that operate on many stacks."
import Elixush.PushState
@doc "Takes a type and a state and pops the appropriate stack of the state."
def popper(type, state), do: pop_item(type, state)
@doc """
Takes a type and a state and duplicates the top item of the appropriate
stack of the state.
"""
def duper(type, state) do
if Enum.empty?(state[type]) do
state
else
type |> top_item(state) |> push_item(type, state)
end
end
@doc """
Takes a type and a state and swaps the top 2 items of the appropriate
stack of the state.
"""
def swapper(type, state) do
if not(Enum.empty?(Enum.drop(state[type], 1))) do
first_item = stack_ref(type, 0, state)
second_item = stack_ref(type, 1, state)
push_item(second_item, type, push_item(first_item, type, pop_item(type, pop_item(type, state))))
else
state
end
end
@doc """
Takes a type and a state and rotates the top 3 items of the appropriate
stack of the state.
"""
def rotter(type, state) do
if not(Enum.empty?(Enum.drop(Enum.drop(state[type], 1), 1))) do
first = stack_ref(type, 0, state)
second = stack_ref(type, 1, state)
third = stack_ref(type, 2, state)
push_item(third, type, push_item(first, type, push_item(second, type, pop_item(type, pop_item(type, pop_item(type, state))))))
else
state
end
end
@doc "Empties the type stack of the given state."
def flusher(type, state), do: Map.merge(state, %{type => []})
@doc "Compares the top two items of the type stack of the given state."
def eqer(type, state) do
if not(Enum.empty?(Enum.drop(state[type], 1))) do
first = stack_ref(type, 0, state)
second = stack_ref(type, 1, state)
push_item(first == second, :boolean, pop_item(type, pop_item(type, state)))
else
state
end
end
@doc "Pushes the depth of the type stack of the given state."
def stackdepther(type, state), do: state[type] |> length |> push_item(:integer, state)
@doc """
Yanks an item from deep in the specified stack, using the top integer
to indicate how deep.
"""
def yanker(:integer, state) do
if not(Enum.empty?(Enum.drop(state[:integer], 1))) do
raw_index = stack_ref(:integer, 0, state)
with_index_popped = pop_item(:integer, state)
actual_index =
raw_index
|> min(length(with_index_popped[:integer]) - 1)
|> max(0)
item = stack_ref(:integer, actual_index, with_index_popped)
stk = with_index_popped[:integer]
new_type_stack =
stk
|> Enum.take(actual_index)
|> Enum.concat(Enum.drop(Enum.drop(stk, actual_index), 1))
with_item_pulled =
with_index_popped
|> Map.merge(%{:integer => new_type_stack})
push_item(item, :integer, with_item_pulled)
else
state
end
end
def yanker(type, state) do
if not(Enum.empty?(state[type])) and not(Enum.empty?(state[:integer])) do
raw_index = stack_ref(:integer, 0, state)
with_index_popped = pop_item(:integer, state)
actual_index =
raw_index
|> min(length(with_index_popped[type]) - 1)
|> max(0)
item = stack_ref(type, actual_index, with_index_popped)
stk = with_index_popped[type]
new_type_stack =
stk
|> Enum.take(actual_index)
|> Enum.concat(Enum.drop(Enum.drop(stk, actual_index), 1))
with_item_pulled =
with_index_popped
|> Map.merge(%{type => new_type_stack})
push_item(item, type, with_item_pulled)
else
state
end
end
@doc """
Yanks a copy of an item from deep in the specified stack, using the top
integer to indicate how deep.
"""
def yankduper(:integer, state) do
if not(Enum.empty?(Enum.drop(state[:integer], 1))) do
raw_index = stack_ref(:integer, 0, state)
with_index_popped = pop_item(:integer, state)
actual_index =
raw_index |> min(length(with_index_popped[:integer]) - 1) |> max(0)
item = stack_ref(:integer, actual_index, with_index_popped)
push_item(item, :integer, with_index_popped)
else
state
end
end
def yankduper(type, state) do
if not(Enum.empty?(state[type])) and not(Enum.empty?(state[:integer])) do
raw_index = stack_ref(:integer, 0, state)
with_index_popped = pop_item(:integer, state)
actual_index =
raw_index |> min(length(with_index_popped[type]) - 1) |> max(0)
item = stack_ref(type, actual_index, with_index_popped)
push_item(item, type, with_index_popped)
else
state
end
end
@doc """
Shoves an item deep in the specified stack, using the top integer to
indicate how deep.
"""
def shover(type, state) do
if (type == :integer and not(Enum.empty?(Enum.drop(state[type], 1)))) or (type != :integer and (not(Enum.empty?(state[type])) and not(Enum.empty?(state[:integer])))) do
raw_index = stack_ref(:integer, 0, state)
with_index_popped = pop_item(:integer, state)
item = top_item(type, with_index_popped)
with_args_popped = pop_item(type, with_index_popped)
actual_index = raw_index |> min(length(with_args_popped[type])) |> max(0)
stk = with_args_popped[type]
Map.merge(with_args_popped, %{type => Enum.concat(Enum.take(stk, actual_index), Enum.concat([item], Enum.drop(stk, actual_index)))})
else
state
end
end
@doc "Takes a type and a state and tells whether that stack is empty."
def emptyer(type, state), do: push_item(Enum.empty?(state[type]), :boolean, state)
### EXEC
def exec_pop(state), do: popper(:exec, state)
def exec_dup(state), do: duper(:exec, state)
def exec_swap(state), do: swapper(:exec, state)
def exec_rot(state), do: rotter(:exec, state)
def exec_flush(state), do: flusher(:exec, state)
def exec_eq(state), do: eqer(:exec, state)
def exec_stackdepth(state), do: stackdepther(:exec, state)
def exec_yank(state), do: yanker(:exec, state)
def exec_yankdup(state), do: yankduper(:exec, state)
def exec_shove(state), do: shover(:exec, state)
def exec_empty(state), do: emptyer(:exec, state)
### INTEGER
def integer_pop(state), do: popper(:integer, state)
def integer_dup(state), do: duper(:integer, state)
def integer_swap(state), do: swapper(:integer, state)
def integer_rot(state), do: rotter(:integer, state)
def integer_flush(state), do: flusher(:integer, state)
def integer_eq(state), do: eqer(:integer, state)
def integer_stackdepth(state), do: stackdepther(:integer, state)
def integer_yank(state), do: yanker(:integer, state)
def integer_yankdup(state), do: yankduper(:integer, state)
def integer_shove(state), do: shover(:integer, state)
def integer_empty(state), do: emptyer(:integer, state)
### FLOAT
def float_pop(state), do: popper(:float, state)
def float_dup(state), do: duper(:float, state)
def float_swap(state), do: swapper(:float, state)
def float_rot(state), do: rotter(:float, state)
def float_flush(state), do: flusher(:float, state)
def float_eq(state), do: eqer(:float, state)
def float_stackdepth(state), do: stackdepther(:float, state)
def float_yank(state), do: yanker(:float, state)
def float_yankdup(state), do: yankduper(:float, state)
def float_shove(state), do: shover(:float, state)
def float_empty(state), do: emptyer(:float, state)
### CODE
def code_pop(state), do: popper(:code, state)
def code_dup(state), do: duper(:code, state)
def code_swap(state), do: swapper(:code, state)
def code_rot(state), do: rotter(:code, state)
def code_flush(state), do: flusher(:code, state)
def code_eq(state), do: eqer(:code, state)
def code_stackdepth(state), do: stackdepther(:code, state)
def code_yank(state), do: yanker(:code, state)
def code_yankdup(state), do: yankduper(:code, state)
def code_shove(state), do: shover(:code, state)
def code_empty(state), do: emptyer(:code, state)
### BOOLEAN
def boolean_pop(state), do: popper(:boolean, state)
def boolean_dup(state), do: duper(:boolean, state)
def boolean_swap(state), do: swapper(:boolean, state)
def boolean_rot(state), do: rotter(:boolean, state)
def boolean_flush(state), do: flusher(:boolean, state)
def boolean_eq(state), do: eqer(:boolean, state)
def boolean_stackdepth(state), do: stackdepther(:boolean, state)
def boolean_yank(state), do: yanker(:boolean, state)
def boolean_yankdup(state), do: yankduper(:boolean, state)
def boolean_shove(state), do: shover(:boolean, state)
def boolean_empty(state), do: emptyer(:boolean, state)
### STRING
def string_pop(state), do: popper(:string, state)
def string_dup(state), do: duper(:string, state)
def string_swap(state), do: swapper(:string, state)
def string_rot(state), do: rotter(:string, state)
def string_flush(state), do: flusher(:string, state)
def string_eq(state), do: eqer(:string, state)
def string_stackdepth(state), do: stackdepther(:string, state)
def string_yank(state), do: yanker(:string, state)
def string_yankdup(state), do: yankduper(:string, state)
def string_shove(state), do: shover(:string, state)
def string_empty(state), do: emptyer(:string, state)
### CHAR
def char_pop(state), do: popper(:char, state)
def char_dup(state), do: duper(:char, state)
def char_swap(state), do: swapper(:char, state)
def char_rot(state), do: rotter(:char, state)
def char_flush(state), do: flusher(:char, state)
def char_eq(state), do: eqer(:char, state)
def char_stackdepth(state), do: stackdepther(:char, state)
def char_yank(state), do: yanker(:char, state)
def char_yankdup(state), do: yankduper(:char, state)
def char_shove(state), do: shover(:char, state)
def char_empty(state), do: emptyer(:char, state)
end | lib/instructions/common.ex | 0.665954 | 0.557905 | common.ex | starcoder |
defmodule Ueberauth.Strategy.Gitlab do
@moduledoc """
Provides an Ueberauth strategy for Gitlab. This is based on the GitHub
strategy.
## Configuration
Create a [Gitlab application](https://gitlab.com/profile/applications), and
write down its `client_id` and `client_secret` values.
Include the Gitlab provider in your Ueberauth configuration:
config :ueberauth, Ueberauth,
providers: [
...
gitlab: { Ueberauth.Strategy.Gitlab, [] }
]
The configure the Gitlab strategy:
config :ueberauth, Ueberauth.Strategy.Gitlab.OAuth,
client_id: System.get_env("GITLAB_CLIENT_ID"),
client_secret: System.get_env("GITLAB_CLIENT_SECRET")
You can edit the behaviour of the Strategy by including some options when you register your provider.
To set the `uid_field`
config :ueberauth, Ueberauth,
providers: [
...
gitlab: { Ueberauth.Strategy.Gitlab, [uid_field: :email] }
]
Default is `:username`.
To set the default 'scopes' (permissions):
config :ueberauth, Ueberauth,
providers: [
gitlab: { Ueberauth.Strategy.Gitlab, [default_scope: "read_user,api"] }
]
Default is "read_user"
"""
use Ueberauth.Strategy, uid_field: :username,
default_scope: "read_user",
oauth2_module: Ueberauth.Strategy.Gitlab.OAuth
@gitlab_api_version "v3"
@gitlab_user_endpoint "/api/#{@gitlab_api_version}/user"
alias Ueberauth.Auth.Info
alias Ueberauth.Auth.Credentials
alias Ueberauth.Auth.Extra
@doc """
Handles the initial redirect to the gitlab authentication page.
To customize the scope (permissions) that are requested by gitlab include them as part of your url:
"/auth/gitlab?scope=read_user,api"
You can also include a `state` param that gitlab will return to you.
"""
def handle_request!(conn) do
scopes = conn.params["scope"] || option(conn, :default_scope)
opts = [redirect_uri: callback_url(conn), scope: scopes]
opts = if conn.params["state"], do: Keyword.put(opts, :state, conn.params["state"]), else: opts
module = option(conn, :oauth2_module)
redirect!(conn, apply(module, :authorize_url!, [opts]))
end
@doc """
Handles the callback from Gitlab. When there is a failure from Gitlab the failure is included in the
`ueberauth_failure` struct. Otherwise the information returned from Gitlab is returned in the `Ueberauth.Auth` struct.
"""
def handle_callback!(%Plug.Conn{params: %{"code" => code}} = conn) do
module = option(conn, :oauth2_module)
token = apply(module, :get_token!, [[code: code, redirect_uri: callback_url(conn)]])
if is_nil(token.access_token) do
set_errors!(conn, [error(token.other_params["error"], token.other_params["error_description"])])
else
fetch_user(conn, token)
end
end
@doc """
Called when no code is received from Gitlab.
"""
def handle_callback!(conn) do
set_errors!(conn, [error("missing_code", "No code received")])
end
@doc """
Cleans up the private area of the connection used for passing the raw Gitlab response around during the callback.
"""
def handle_cleanup!(conn) do
conn
|> put_private(:gitlab_user, nil)
|> put_private(:gitlab_token, nil)
end
@doc """
Fetches the uid field from the Gitlab response. This defaults to the option `uid_field` which in-turn
defaults to `username`
"""
def uid(conn) do
user = conn |> option(:uid_field) |> to_string
conn.private.gitlab_user[user]
end
@doc """
Includes the credentials from the Gitlab response.
"""
def credentials(conn) do
token = conn.private.gitlab_token
scope_string = (token.other_params["scope"] || "")
scopes = String.split(scope_string, ",")
%Credentials {
token: token.access_token,
refresh_token: token.refresh_token,
expires_at: token.expires_at,
token_type: token.token_type,
expires: !!token.expires_at,
scopes: scopes
}
end
@doc """
Fetches the fields to populate the info section of the `Ueberauth.Auth` struct.
"""
def info(conn) do
user = conn.private.gitlab_user
%Info {
name: user["name"],
email: user["email"] || Enum.find(user["emails"] || [], &(&1["primary"]))["email"],
nickname: user["login"],
location: user["location"],
urls: %{
avatar_url: user["avatar_url"],
web_url: user["web_url"],
website_url: user["website_url"]
}
}
end
@doc """
Stores the raw information (including the token) obtained from the Gitlab callback.
"""
def extra(conn) do
%Extra {
raw_info: %{
token: conn.private.gitlab_token,
user: conn.private.gitlab_user
}
}
end
defp fetch_user(conn, token) do
conn = put_private(conn, :gitlab_token, token)
# Unlike github, gitlab returns the email in the main call, so a simple `case`
# statement works very well here.
case Ueberauth.Strategy.Gitlab.OAuth.get(token, @gitlab_user_endpoint) do
{:ok, %OAuth2.Response{status_code: status_code_user, body: user}} when status_code_user in 200..399 ->
put_private(conn, :gitlab_user, user)
{:ok, %OAuth2.Response{status_code: 401, body: body}} ->
set_errors!(conn, [error("token", "unauthorized: #{inspect body}")])
{:error, %OAuth2.Error{reason: reason}} ->
set_errors!(conn, [error("OAuth2", reason)])
_ ->
set_errors!(conn, [error("OAuth2", "An undefined error occured")])
end
end
defp option(conn, key) do
Keyword.get(options(conn), key, Keyword.get(default_options(), key))
end
end | lib/ueberauth/strategy/gitlab.ex | 0.695131 | 0.427098 | gitlab.ex | starcoder |
defmodule Oban.Peer do
@moduledoc """
The `Peer` module maintains leadership for a particular Oban instance within a cluster.
Leadership is used by plugins, primarily, to prevent duplicate work accross nodes. For example,
only the leader's `Cron` plugin will insert new jobs. You can use peer leadership to extend Oban
with custom plugins, or even within your own application.
Note a few important details about how peer leadership operates:
* Each Oban instances supervises a distinct `Oban.Peer` instance. That means that with multiple
Oban instances on the same node one instance may be the leader, while the others aren't.
* Leadership is coordinated through the `oban_peers` table in your database. It doesn't require
distributed Erlang or any other interconnectivity.
* Without leadership some plugins may not run on any node.
## Examples
Check leadership for the default Oban instance:
Oban.Peer.leader?()
# => true
That is identical to using the name `Oban`:
Oban.Peer.leader?(Oban)
# => true
Check leadership for a couple of instances:
Oban.Peer.leader?(Oban.A)
# => true
Oban.Peer.leader?(Oban.B)
# => false
"""
use GenServer
import Ecto.Query, only: [where: 3]
alias Oban.{Backoff, Config, Registry, Repo}
require Logger
@type option ::
{:name, module()}
| {:conf, Config.t()}
| {:interval, timeout()}
defmodule State do
@moduledoc false
defstruct [
:conf,
:name,
:timer,
interval: :timer.seconds(30),
leader?: false,
leader_boost: 2
]
end
@doc """
Check whether the current instance leads the cluster.
## Example
Check leadership for the default Oban instance:
Oban.Peer.leader?()
# => true
Check leadership for an alternate instance named `Oban.Private`:
Oban.Peer.leader?(Oban.Private)
# => true
"""
@spec leader?(Config.t() | GenServer.server()) :: boolean()
def leader?(name \\ Oban)
def leader?(%Config{name: name}), do: leader?(name)
def leader?(pid) when is_pid(pid) do
GenServer.call(pid, :leader?)
end
def leader?(name) do
name
|> Registry.whereis(__MODULE__)
|> leader?()
end
@doc false
@spec child_spec(Keyword.t()) :: Supervisor.child_spec()
def child_spec(opts) do
name = Keyword.get(opts, :name, __MODULE__)
opts
|> super()
|> Supervisor.child_spec(id: name)
end
@doc false
@spec start_link([option]) :: GenServer.on_start()
def start_link(opts) do
GenServer.start_link(__MODULE__, opts, name: opts[:name])
end
@impl GenServer
def init(opts) do
Process.flag(:trap_exit, true)
case Keyword.fetch!(opts, :conf) do
%{plugins: []} ->
:ignore
_ ->
{:ok, struct!(State, opts), {:continue, :start}}
end
end
@impl GenServer
def terminate(_reason, %State{timer: timer}) do
if is_reference(timer), do: Process.cancel_timer(timer)
:ok
end
@impl GenServer
def handle_continue(:start, %State{} = state) do
handle_info(:election, state)
end
@impl GenServer
def handle_info(:election, %State{} = state) do
state =
state
|> delete_expired_peers()
|> upsert_peer()
{:noreply, schedule_election(state)}
rescue
error in [Postgrex.Error] ->
if error.postgres.code == :undefined_table do
Logger.warn("""
The `oban_peers` table is undefined and leadership is disabled.
Run migrations up to v11 to restore peer leadership. In the meantime, distributed plugins
(e.g. Cron, Pruner, Stager) will not run on any nodes.
""")
end
{:noreply, schedule_election(%{state | leader?: false})}
end
@impl GenServer
def handle_call(:leader?, _from, %State{} = state) do
{:reply, state.leader?, state}
end
# Helpers
defp schedule_election(%State{interval: interval} = state) do
base = if state.leader?, do: div(interval, state.leader_boost), else: interval
time = Backoff.jitter(base, mode: :dec)
%{state | timer: Process.send_after(self(), :election, time)}
end
defp delete_expired_peers(%State{conf: conf} = state) do
query =
"oban_peers"
|> where([p], p.name == ^inspect(conf.name))
|> where([p], p.expires_at < ^DateTime.utc_now())
Repo.delete_all(conf, query)
state
end
defp upsert_peer(%State{conf: conf} = state) do
started_at = DateTime.utc_now()
expires_at = DateTime.add(started_at, state.interval, :millisecond)
peer_data = %{
name: inspect(conf.name),
node: conf.node,
started_at: started_at,
expires_at: expires_at
}
repo_opts =
if state.leader? do
[conflict_target: :name, on_conflict: [set: [expires_at: expires_at]]]
else
[on_conflict: :nothing]
end
case Repo.insert_all(conf, "oban_peers", [peer_data], repo_opts) do
{1, _} -> %{state | leader?: true}
{0, _} -> %{state | leader?: false}
end
end
end | lib/oban/peer.ex | 0.846324 | 0.498657 | peer.ex | starcoder |
defmodule ExCell do
@moduledoc """
ExCell is used to split larger views in smaller cells that can be reused and
easily packaged with Javascript and CSS.
A cell consists of a couple of files:
```
cells
|- avatar
| |- template.html.eex
| |- view.html.eex
| |- style.css (optional)
| |- index.js (optional)
|- header
...
```
You can render the cell in a view, controller or another cell by adding the following code:
```ex
cell(AvatarCell, class: "CustomClassName", user: %User{})
```
This would generate the following HTML when you render the cell:
```html
<span class="AvatarCell" data-cell="AvatarCell" data-cell-params="{}">
<img src="/images/foo/avatar.jpg" class="AvatarCell-Image" alt="foo" />
</span>
```
"""
@dialyzer [{:no_match, relative_name: 2}]
def module_relative_to(module, relative_to) do
module
|> Module.split
|> Kernel.--(Module.split(relative_to))
end
def config(keyword, fallback \\ nil) do
:ex_cell
|> Application.get_env(__MODULE__, [])
|> Keyword.get(keyword, fallback)
end
def relative_name(module, namespace) do
parts = case namespace do
nil -> Module.split(module)
_ -> ExCell.module_relative_to(module, namespace)
end
Enum.join(parts, "-")
end
def class_name(name, classes) do
[name, classes]
|> List.flatten
|> Enum.reject(&is_nil/1)
|> Enum.join(" ")
end
def container(module, id, params, attributes, callback) when is_function(callback) do
module
|> options(id, params, attributes, nil)
|> module.__adapter__().container(callback)
end
def container(module, id, params, attributes, [do: content]) do
module
|> options(id, params, attributes, content)
|> module.__adapter__().container()
end
def options(module, id, params, attributes, content) do
%{
name: module.cell_name(),
id: id,
params: module.params(params),
attributes: Keyword.put(attributes, :class,
class_name(module.class_name(), Keyword.get(attributes, :class))),
content: content
}
end
end | lib/ex_cell/ex_cell.ex | 0.810554 | 0.829077 | ex_cell.ex | starcoder |
defmodule MarcoPolo.FetchPlan do
@moduledoc """
Provides facilities for traversing links to OrientDB records.
"""
alias MarcoPolo.RID
defmodule RecordNotFoundError do
@moduledoc """
Raised when a record is not found in a set of linked records.
"""
defexception [:message]
end
@doc """
Transforms RIDs to OrientDB records based on a set of linked records.
`linked` is a dict with RIDs as keys and OrientDB records
(`MarcoPolo.Document` and `MarcoPolo.BinaryRecord` structs) as values. Each
RID key is the RID of the record in the corresponding value. Usually, this
dict is the set of linked records that some functions from the `MarcoPolo`
return alongside the queried records; what records get in this set depends on
the fetch plan used in the query.
`rids` can be:
* a single RID: this function returns the record in `linked` with that RID.
* a list of RIDs: this function returns a list as long as `rids` where each
RID has been replaced by the record with that RID in `linked`.
* a map where the values are RIDs: this function returns a map with the same
keys as `rids` but where each RID value has been replaced by the record
with that RID in `linked`.
When all the RIDs in `rids` are found in `linked`, then the response is always
`{:ok, records}` where the result `records` depends on `rids` and is described
in the list above. If one or more RIDs are not found in `linked`, then
`:error` is returned.
## Examples
iex> rid = %MarcoPolo.RID{cluster_id: 1, position: 10}
iex> linked = HashDict.new
...> |> Dict.put(rid, %MarcoPolo.Document{rid: rid, fields: %{"foo" => "bar"}})
iex> {:ok, doc} = MarcoPolo.FetchPlan.resolve_links(rid, linked)
iex> doc.fields
%{"foo" => "bar"}
iex> doc.rid == rid
true
iex> rids = [%MarcoPolo.RID{cluster_id: 1, position: 10},
...> %MarcoPolo.RID{cluster_id: 1, position: 11}]
iex> MarcoPolo.FetchPlan.resolve_links(rids, %{})
:error
"""
@spec resolve_links(RID.t, [MarcoPolo.rec]) :: {:ok, MarcoPolo.rec} | :error
@spec resolve_links([RID.t], [MarcoPolo.rec]) :: {:ok, [MarcoPolo.rec]} | :error
@spec resolve_links(%{term => RID.t}, [MarcoPolo.rec]) :: {:ok, %{term => MarcoPolo.rec}} | :error
def resolve_links(rids, linked)
def resolve_links(%RID{} = rid, linked) do
Dict.fetch(linked, rid)
end
def resolve_links(rids, linked) when is_list(rids) do
catch_missing fn ->
followed = Enum.map rids, fn(%RID{} = rid) ->
case resolve_links(rid, linked) do
{:ok, record} -> record
:error -> throw(:missing_link)
end
end
{:ok, followed}
end
end
def resolve_links(rids, linked) when is_map(rids) do
catch_missing fn ->
map = for {key, rid} <- rids, into: %{} do
case resolve_links(rid, linked) do
{:ok, record} -> {key, record}
:error -> throw(:missing_link)
end
end
{:ok, map}
end
end
@doc """
Transforms RIDs to OrientDB records based on a set of linked records, raising
an exception for not found records.
This function behaves exactly like `resolve_links/2`, except it returns the
result directly (not as `{:ok, res}` but just as `res`) or raises a
`MarcoPolo.FetchPlan.RecordNotFoundError` in case one of the RIDs is not
found.
## Examples
iex> rid = %MarcoPolo.RID{cluster_id: 1, position: 10}
iex> linked = HashDict.new
...> |> Dict.put(rid, %MarcoPolo.Document{rid: rid, fields: %{"foo" => "bar"}})
iex> MarcoPolo.FetchPlan.resolve_links!(rid, linked).fields
%{"foo" => "bar"}
"""
@spec resolve_links!(RID.t, [MarcoPolo.rec]) :: MarcoPolo.rec
@spec resolve_links!([RID.t], [MarcoPolo.rec]) :: [MarcoPolo.rec]
@spec resolve_links!(%{term => RID.t}, [MarcoPolo.rec]) :: %{term => MarcoPolo.rec}
def resolve_links!(rids, linked) do
case resolve_links(rids, linked) do
{:ok, res} ->
res
:error ->
raise RecordNotFoundError, message: """
the linked records don't include one of these RIDs:
#{inspect rids}
"""
end
end
defp catch_missing(fun) do
try do
fun.()
catch
:missing_link -> :error
end
end
end | lib/marco_polo/fetch_plan.ex | 0.876125 | 0.782205 | fetch_plan.ex | starcoder |
defmodule Structex.Load.Seismic do
@moduledoc """
Functions to calculates the seismic load.
The seismic load can be defined by following 3 ways.
## As a static load
The instant difinition without modal characteristics.
## As an input acceleration history
The time dependent continuous momentary acceleration definition.
## As an acceleration response spectrum
The acceleration response spectrum definition for linear modal analysis.
The code example below shows how to get the acceleration response spectrum following to
'Recommendations for Loads on Buildings (2004, Architectural Institute of Japan)' under the
conditions of:
* At 137.166296 east longitude and 34.910602 north latitude
* 100 years of recurrence period
* 0.37 seconds of soil's natural period
* 5% of soil's damping ratio
* 0.35 of soil's impedance ratio
* 400m^2 of the area of foundation base
* 1m of the foundation depth
* 414m/s of the shear wave velocity in the surface soil
* 13.2% of building's damping ratio
iex> a0 = Structex.Load.Seismic.standard_maximum_acceleration(137.166296, 34.910602, 100)
...> sa0 = Structex.Load.Seismic.normalized_acceleration_response_spectrum(2.5, 0.16, 0.64)
...>
...> response_spectrum =
...> Stream.iterate(0.1, &(&1 * 1.2))
...> |> Stream.take_while(&(&1 <= 7))
...> |> Enum.map(&{&1, a0 * sa0.(&1)})
...> |> Structex.Load.Seismic.reverse_convert_spectrum(0.5, 20, 0.05)
...> |> Enum.map(fn {angular_frequency, ga0} ->
...> hgs = Structex.Load.Seismic.squared_soil_amplification(angular_frequency, 0.37, 0.05, 0.35)
...> hss = Structex.Load.Seismic.squared_interaction_correction(angular_frequency, 400, 1, 414)
...> {angular_frequency, hgs * hss * ga0}
...> end)
...> |> Structex.Load.Seismic.convert_spectrum(0.5, 20, 3)
...>
...> Stream.iterate(0.12, &(&1 * 1.44))
...> |> Stream.take_while(&(&1 <= 5))
...> |> Enum.map(&{&1, response_spectrum.(&1, 0.132)})
[
{0.12 , 3.8881302745930872},
{0.17279999999999998, 3.898028341960903 },
{0.24883199999999997, 4.761133181314824 },
{0.3583180799999999 , 6.2276287305690445},
{0.5159780351999999 , 5.333778430470842 },
{0.7430083706879997 , 3.7829667118408845},
{1.0699320537907195 , 2.4466780606725713},
{1.5407021574586361 , 1.6738460327263076},
{2.218611106740436 , 1.1945148783584574},
{3.194799993706228 , 0.876302394029604 },
{4.600511990936968 , 0.6530624748928214}
]
"""
@doc """
Returns the normalized acceleration spectrum.
The spectrum is normalized at natural period of 0.
iex> Structex.Load.Seismic.normalized_acceleration_response_spectrum(2.5, 0.16, 0.64).(0)
1.0
iex> Structex.Load.Seismic.normalized_acceleration_response_spectrum(2.5, 0.16, 0.64).(0.08)
1.75
iex> Structex.Load.Seismic.normalized_acceleration_response_spectrum(2.5, 0.16, 0.64).(0.43)
2.5
iex> Structex.Load.Seismic.normalized_acceleration_response_spectrum(2.5, 0.16, 0.64).(0.8)
2.0
"""
@spec normalized_acceleration_response_spectrum(number, number, number) ::
(natural_period :: number -> number)
def normalized_acceleration_response_spectrum(
maximum_response,
minimum_natural_period_of_constant_acceleration_range,
minimum_natural_period_of_constant_velocity_range
)
when is_number(maximum_response) and maximum_response > 0 and
is_number(minimum_natural_period_of_constant_velocity_range) and
minimum_natural_period_of_constant_velocity_range >
minimum_natural_period_of_constant_acceleration_range and
minimum_natural_period_of_constant_acceleration_range > 0 do
fn natural_period when is_number(natural_period) ->
cond do
natural_period > minimum_natural_period_of_constant_velocity_range ->
maximum_response * minimum_natural_period_of_constant_velocity_range / natural_period
natural_period >= minimum_natural_period_of_constant_acceleration_range ->
maximum_response
natural_period >= 0 ->
1 +
(maximum_response - 1) * natural_period /
minimum_natural_period_of_constant_acceleration_range
end
end
end
@doc """
Calculates the squared soil amplification between bedrock to surface of the soil.
iex> Structex.Load.Seismic.squared_soil_amplification(31.4, 0.22, 0.05, 0.5)
2.76118724738556
iex> Structex.Load.Seismic.squared_soil_amplification(7.85, 0.56, 0.05, 0.2)
3.752662171536526
"""
@spec squared_soil_amplification(number, number, number, number) :: number
def squared_soil_amplification(
angular_frequency,
soil_natural_period,
damping_ratio,
impedance_ratio
)
when is_number(angular_frequency) and angular_frequency > 0 and
is_number(soil_natural_period) and soil_natural_period > 0 and
is_number(damping_ratio) and damping_ratio >= 0 and
is_number(impedance_ratio) and impedance_ratio >= 0 do
radius =
angular_frequency * soil_natural_period * 0.25 /
:math.pow(1 + 4 * damping_ratio * damping_ratio, 0.25)
theta = :math.atan(damping_ratio * 2) * 0.5
x = radius * :math.cos(theta)
y = -radius * :math.sin(theta)
1 /
(:math.pow((:math.cosh(y) - impedance_ratio * :math.sinh(y)) * :math.cos(x), 2) +
:math.pow((impedance_ratio * :math.cosh(y) - :math.sinh(y)) * :math.sin(x), 2))
end
@doc """
Calculates the squared interaction correction factor between the building and the soil.
iex> Structex.Load.Seismic.squared_interaction_correction(56.5, 49, 3.5, 120)
0.5
iex> Structex.Load.Seismic.squared_interaction_correction(22.5, 100, 3.5, 120)
0.89112335163758
"""
@spec squared_interaction_correction(number, number, number, number) :: number
def squared_interaction_correction(
angular_frequency,
foundation_base_area,
depth,
shear_wave_velocity
)
when is_number(angular_frequency) and angular_frequency > 0 and
is_number(foundation_base_area) and foundation_base_area > 0 and
is_number(depth) and depth >= 0 and
is_number(shear_wave_velocity) and shear_wave_velocity > 0 do
case 2 * angular_frequency * depth / shear_wave_velocity / :math.pi() do
d when d <= 1 -> 1 / (1 + 2 * d * d * depth / :math.sqrt(foundation_base_area))
_ -> 1 / (1 + 2 * depth / :math.sqrt(foundation_base_area))
end
end
@doc """
Converts a acceleration response spectrum to the power spectrum.
iex> Stream.iterate(0.1, &(&1 * 1.2))
...> |> Stream.take_while(&(&1 <= 5))
...> |> Enum.map(fn natural_period ->
...> {natural_period, (:math.exp(-natural_period) + natural_period / (:math.pow(natural_period, 4) + 1)) * 200}
...> end)
...> |> Structex.Load.Seismic.reverse_convert_spectrum(0.5, 20, 0.05)
...> |> Enum.map(fn {angular_frequency, power_density} ->
...> {angular_frequency, Float.round(power_density, 6)}
...> end)
[
{ 1.3657578372923482, 0.031703},
{ 1.6389094047508177, 0.161461},
{ 1.966691285700981 , 0.613031},
{ 2.3600295428411773, 1.746503},
{ 2.8320354514094124, 4.212474},
{ 3.3984425416912947, 9.037214},
{ 4.078131050029554 , 17.465641},
{ 4.893757260035464 , 29.632575},
{ 5.872508712042557 , 41.544155},
{ 7.047010454451068 , 45.785216},
{ 8.456412545341282 , 40.604292},
{10.147695054409537 , 31.501341},
{12.177234065291444 , 23.131867},
{14.612680878349732 , 16.830928},
{17.53521705401968 , 12.369644},
{21.042260464823617 , 9.229817},
{25.250712557788336 , 6.988087},
{30.300855069346003 , 5.356212},
{36.3610260832152 , 4.146664},
{43.63323129985824 , 3.238046},
{52.35987755982989 , 2.554588},
{62.83185307179586 , 4.645955}
]
"""
@spec reverse_convert_spectrum([{number, number}, ...], number, number, number, number, number) ::
[{number, number}, ...]
def reverse_convert_spectrum(
response_spectrum,
non_exceedance_probability,
duration,
damping_ratio,
relative_tolerance \\ 1.0e-3,
absolute_tolerance \\ 1.0e-6
)
when is_list(response_spectrum) and is_number(duration) and duration > 0 and
non_exceedance_probability < 1 and non_exceedance_probability > 0 and
is_number(damping_ratio) and damping_ratio > 0 and
is_number(relative_tolerance) and relative_tolerance >= 0 and
is_number(absolute_tolerance) and absolute_tolerance >= 0 do
ordered_response = Enum.sort(response_spectrum, :desc)
expected =
Enum.map(ordered_response, fn {natural_period, response} ->
angular_frequency = 2 * :math.pi() / natural_period
expected_value =
response * response * damping_ratio / angular_frequency / :math.pi() /
(1 - :math.exp(-2 * damping_ratio * angular_frequency * duration)) /
(0.424 + :math.log(1.78 + 2 * damping_ratio * angular_frequency * duration))
{angular_frequency, expected_value}
end)
Stream.iterate(expected, fn prev ->
new_response_spectrum = convert_spectrum(prev, non_exceedance_probability, duration)
ordered_response
|> Stream.map(&(elem(&1, 1) / new_response_spectrum.(elem(&1, 0), damping_ratio)))
|> Stream.zip(prev)
|> Enum.map(fn {modification_factor, {angular_frequency, prev_value}} ->
{angular_frequency, prev_value * modification_factor * modification_factor}
end)
end)
|> Enum.find(fn curr ->
new_response_spectrum = convert_spectrum(curr, non_exceedance_probability, duration)
ordered_response
|> Stream.zip(curr)
|> Enum.all?(fn {{natural_period, target}, {_, curr_value}} ->
response = new_response_spectrum.(natural_period, damping_ratio)
abs((target - response) / target) <= relative_tolerance or
curr_value <= absolute_tolerance
end)
end)
end
@doc """
Converts a power spectrum to a response spectrum function.
It expects the power spectrum data set to be represented by an enumerable of two-element tuples.
Each tuple has the angular frequency and corresponding power density value.
iex> (Stream.iterate(1, &(&1 * 1.2))
...> |> Stream.take_while(&(&1 <= 40))
...> |> Enum.map(&{&1, (1 + :math.pow(2 * 0.3 * &1 / 6.283184, 2)) / (:math.pow(1 - :math.pow(&1 / 6.283184, 2), 2) + :math.pow(2 * 0.3 * &1 / 6.283184, 2))})
...> |> Structex.Load.Seismic.convert_spectrum(0.5, 20)).(1.256, 0.05)
37.24430207043126
iex> (Stream.iterate(1, &(&1 * 1.2))
...> |> Stream.take_while(&(&1 <= 40))
...> |> Enum.map(&{&1, (1 + :math.pow(2 * 0.3 * &1 / 6.283184, 2)) / (:math.pow(1 - :math.pow(&1 / 6.283184, 2), 2) + :math.pow(2 * 0.3 * &1 / 6.283184, 2))})
...> |> Structex.Load.Seismic.convert_spectrum(0.5, 20, 3)).(1.256, 0.05)
50.78221903368188
"""
@spec convert_spectrum([{number, number}, ...], number, number, number | nil) ::
(number, number -> number)
def convert_spectrum(power_spectrum, non_exceedance_probability, duration, peak_factor \\ nil)
when is_list(power_spectrum) and is_number(duration) and duration > 0 and
is_number(non_exceedance_probability) and non_exceedance_probability > 0 and
((is_number(peak_factor) and peak_factor > 0) or is_nil(peak_factor)) do
fn natural_period, damping_ratio
when is_number(natural_period) and natural_period >= 0 and
is_number(damping_ratio) and damping_ratio >= 0 ->
natural_angular_frequency = 2 * :math.pi() / natural_period
moments =
power_spectrum
|> Stream.map(fn {angular_frequency, density} ->
{
angular_frequency,
transfer_factor(angular_frequency, natural_angular_frequency, damping_ratio) * density
}
end)
|> Stream.chunk_every(2, 1, :discard)
|> Stream.map(fn [{f1, d1}, {f2, d2}] ->
Stream.iterate(0, &(&1 + 1))
|> Stream.map(&((d1 * :math.pow(f1, &1) + d2 * :math.pow(f2, &1)) * (f2 - f1) * 0.5))
end)
|> Stream.zip()
|> Stream.map(&Tuple.to_list/1)
|> Stream.map(&Enum.sum/1)
unless peak_factor do
[m0, m1, m2] = Enum.take(moments, 3)
n = :math.sqrt(m2 / m0) * duration / -:math.log(non_exceedance_probability) / :math.pi()
d = 1 - m1 * m1 / m0 / m2
t = n * (1 - :math.exp(-:math.pow(d, 0.6) * :math.sqrt(:math.pi() * :math.log(n))))
:math.sqrt(2 * m0 * :math.log(t))
else
:math.sqrt(Enum.at(moments, 0)) * peak_factor
end
end
end
@spec transfer_factor(number, number, number) :: float
defp transfer_factor(angular_frequency, natural_angular_frequency, damping_ratio) do
r = angular_frequency / natural_angular_frequency
dr = damping_ratio * r
(1 + 4 * dr * dr) / (1 + (r * r - 2) * r * r + 4 * dr * dr)
end
@doc """
Returns the standard maximum acceleration (m/s^2) at the specified point defined in the
'Recommendations for Loads on Buildings (2004, Architectural Institute of Japan)'.
The source of the hazard analysis result is on AIJ's website:
http://news-sv.aij.or.jp/kouzou/s10/outcome.html
iex> Structex.Load.Seismic.standard_maximum_acceleration(137.0422, 35.0302, 250)
3.147818612267014
iex> Structex.Load.Seismic.standard_maximum_acceleration(136.0433, 34.5104, 120)
1.980340437419472
"""
@spec standard_maximum_acceleration(number, number, number) :: number
def standard_maximum_acceleration(longitude, latitude, recurrence_period)
when -180 < longitude and longitude <= 180 and -90 <= latitude and latitude <= 90 and
is_number(recurrence_period) and recurrence_period > 0 do
{values, sum_of_effectiveness} =
[
[
123.375,
23.916667,
25.75605264,
41.34344039,
69.24439187,
97.24776245,
131.92684385,
188.34315547,
238.63340861,
295.10412957
],
[
123.625,
23.583333,
25.81445664,
42.68868494,
71.85706983,
99.25359858,
131.78620334,
183.20293544,
228.72101438,
279.62597726
],
[
123.625,
23.75,
26.33937956,
41.85631026,
68.36608354,
93.44513161,
123.35000472,
170.83188627,
213.01279902,
260.15814203
],
[
123.625,
23.916667,
26.85447997,
42.27379801,
68.70896094,
93.98830464,
124.12397916,
171.63432885,
213.41623508,
259.79738414
],
[
123.875,
23.75,
26.26013202,
42.2977543,
69.75332627,
95.77328885,
126.67080382,
175.73851106,
219.18792865,
268.11483576
],
[
123.875,
23.916667,
27.09594101,
42.35834252,
68.20142182,
92.63668224,
121.75796276,
167.93303065,
208.79744004,
254.43799549
],
[
123.375,
24.083333,
26.1346614,
42.82682322,
75.72327285,
112.4399532,
161.45223076,
243.65087281,
316.26023619,
396.23636465
],
[
123.375,
24.25,
25.76747757,
42.73811861,
76.95574097,
114.93846382,
164.62245999,
246.76692603,
319.00831909,
398.69868885
],
[
123.375,
24.416667,
24.00058677,
39.4293177,
71.3536463,
107.83892484,
156.91869013,
239.56152951,
312.78320567,
393.32778094
],
[
123.375,
24.583333,
21.26383277,
34.78498837,
61.0155886,
90.17091934,
129.00622855,
195.85275773,
257.4815664,
327.56189636
],
[
123.625,
24.083333,
27.41634094,
43.84324459,
74.55276481,
107.42840768,
150.95511452,
226.04565559,
294.48427384,
371.29733088
],
[
123.625,
24.25,
27.49447074,
44.81721633,
78.95823829,
116.74309127,
166.07652028,
247.8470668,
319.88793053,
399.45350776
],
[
123.625,
24.416667,
26.32277168,
42.92894745,
76.50123695,
113.92241588,
163.20729875,
245.24863462,
317.66026749,
397.55930434
],
[
123.625,
24.583333,
23.86643459,
38.40710035,
67.80646066,
101.02473932,
146.41264471,
225.24600821,
296.57609389,
375.84139677
],
[
123.875,
24.083333,
27.70443829,
43.60814998,
71.84486871,
100.17668975,
135.64324546,
193.93807316,
246.88372372,
307.10449987
],
[
123.875,
24.25,
28.08827002,
45.15064486,
78.24996777,
115.02726809,
163.75981757,
245.49672772,
317.83030521,
397.67675428
],
[
123.875,
24.416667,
27.60112298,
44.83087274,
78.86566158,
116.51147132,
165.71134214,
247.40189376,
319.46708935,
399.09382888
],
[
123.875,
24.583333,
25.6767738,
41.28102093,
73.26700532,
109.44131271,
158.26639711,
240.66824034,
313.75933851,
394.17135800
],
[
123.125,
24.75,
15.98043784,
25.44750515,
44.26256532,
65.86027634,
96.54153698,
154.92142546,
213.326459,
282.00923533
],
[
123.125,
24.916667,
14.18804402,
22.2695192,
39.13189638,
59.29791137,
89.0521916,
147.86931808,
207.73198852,
277.97392197
],
[
123.375,
24.75,
18.67178833,
29.73512084,
51.65122693,
75.59005884,
107.76479424,
165.96462457,
222.65770977,
289.42229765
],
[
123.375,
24.916667,
16.57001617,
26.17747884,
45.47058274,
67.42174795,
98.24296035,
156.33747346,
214.36609514,
282.78772700
],
[
123.375,
25.083333,
14.76649922,
23.24372911,
40.98341268,
62.10693123,
92.40660239,
150.94513083,
210.19092593,
279.78506978
],
[
123.625,
24.75,
20.82077866,
33.37999839,
57.27487285,
83.07354726,
117.10590785,
176.64554684,
233.3029465,
299.15402976
],
[
123.625,
24.916667,
18.33974482,
28.80553392,
49.3513002,
72.20049638,
103.42220161,
160.97114085,
218.05168471,
285.60956459
],
[
123.625,
25.083333,
16.36172328,
25.62956151,
44.39232962,
65.90810393,
96.27696622,
154.15937155,
212.5379267,
281.44465662
],
[
123.875,
24.75,
22.83563494,
36.38322095,
62.74280472,
91.64630051,
130.07451837,
196.54428336,
257.76822909,
327.23162813
],
[
123.875,
24.916667,
19.77303153,
31.30629961,
53.34935749,
77.09134767,
108.93585245,
166.59936267,
222.96565723,
289.55375489
],
[
123.875,
25.083333,
17.62899277,
27.52073782,
47.15219434,
69.09865276,
99.71280018,
157.30239521,
214.97287381,
283.21506687
],
[
124.125,
23.75,
26.49457318,
43.10618271,
71.74128538,
98.73083725,
130.81053146,
181.66552274,
226.74413367,
277.23412688
],
[
124.125,
23.916667,
27.13017734,
42.55146261,
68.73572282,
93.56176025,
123.17160022,
170.22857338,
212.0857604,
258.87907423
],
[
124.375,
23.75,
26.65817214,
43.92541215,
73.96679294,
102.20847532,
135.69893037,
188.51882794,
235.24979154,
287.62991158
],
[
124.375,
23.916667,
26.59479988,
42.45828461,
69.56540116,
95.29212801,
125.89020039,
174.51746004,
217.63204693,
266.10398700
],
[
124.625,
23.916667,
26.63004501,
43.0522626,
71.3055719,
98.00493388,
129.72325978,
180.08485146,
224.75903011,
274.85268940
],
[
124.875,
23.916667,
26.62987894,
43.69668229,
73.2905468,
101.10707756,
134.17204818,
186.37451059,
232.59109006,
284.35120561
],
[
124.125,
24.083333,
27.69417787,
43.23394506,
69.88316737,
95.70844261,
126.63109374,
175.66293492,
218.7788476,
266.98560856
],
[
124.125,
24.25,
28.25289301,
44.89985577,
76.23330861,
110.22712083,
155.89596243,
234.46993854,
305.52881101,
384.66578559
],
[
124.125,
24.416667,
28.27684671,
45.71047658,
79.79297235,
117.45646718,
166.60000855,
248.16062904,
320.09433508,
399.59612587
],
[
124.125,
24.583333,
27.0048775,
43.61074216,
76.93006998,
114.1013721,
163.17284412,
245.08059716,
317.44238079,
397.26130655
],
[
124.375,
24.083333,
27.54185662,
42.85230341,
68.71943004,
93.25095767,
122.45350753,
168.68871406,
209.5795272,
255.18000579
],
[
124.375,
24.25,
28.16174667,
44.28164932,
73.25192776,
102.91270628,
140.65118516,
204.2495885,
262.39671873,
328.79509633
],
[
124.375,
24.416667,
28.50436045,
45.76024039,
79.26579117,
116.48616946,
165.47597013,
247.2008455,
319.35940009,
399.05210518
],
[
124.375,
24.583333,
27.89915222,
45.11729613,
79.02983181,
116.5517132,
165.62915609,
247.20952102,
319.21368904,
398.75682449
],
[
124.625,
24.083333,
27.3297973,
42.68327672,
68.68740324,
93.34739797,
122.7673264,
169.52451984,
211.09000851,
257.55757793
],
[
124.625,
24.25,
27.92180393,
43.56798377,
70.51656624,
96.75731071,
128.3087284,
178.42346993,
222.49849077,
271.66546134
],
[
124.625,
24.416667,
28.45641797,
45.27118067,
77.06413346,
111.77182417,
158.27831907,
238.08684326,
309.97131371,
389.67900664
],
[
124.625,
24.583333,
28.38924813,
45.87772118,
80.01224051,
117.69074748,
166.81378189,
248.33068313,
320.22601548,
399.67177938
],
[
124.875,
24.083333,
26.59861851,
42.33117939,
69.20184822,
94.68246049,
125.01581675,
173.22006535,
215.99985261,
264.00503875
],
[
124.875,
24.25,
27.5670126,
42.95323074,
69.00358312,
93.76947843,
123.22025519,
169.73628546,
210.82969332,
256.56246909
],
[
124.875,
24.416667,
28.17218692,
44.49618339,
74.24440488,
105.25760866,
145.47138378,
214.30580084,
277.63936474,
349.78091804
],
[
124.875,
24.583333,
28.44480862,
45.863066,
79.76359171,
117.31260841,
166.45782873,
248.14873872,
320.18801455,
399.75312407
],
[
124.125,
24.75,
24.50548099,
38.9558848,
68.0731588,
100.6506354,
145.06033013,
222.53129978,
293.34887202,
372.42777668
],
[
124.125,
24.916667,
21.4405757,
33.96569989,
57.67784928,
83.17958016,
116.7742052,
175.74128119,
232.12409611,
297.87505932
],
[
124.125,
25.083333,
18.77856643,
29.30255772,
49.89569464,
72.7528077,
103.83547103,
161.19959395,
218.20208694,
285.76107076
],
[
124.125,
25.25,
16.78629811,
26.14952286,
45.01122223,
66.49375533,
96.75863618,
154.46228042,
212.75501941,
281.62676995
],
[
124.375,
24.75,
25.88352443,
41.42154466,
73.12904305,
108.9494577,
157.36286785,
239.4249986,
312.45343828,
392.89121931
],
[
124.375,
24.916667,
22.99216661,
36.47920789,
62.71087638,
91.41130822,
129.55096682,
195.65063152,
256.87658202,
326.59409045
],
[
124.375,
25.083333,
19.8590945,
31.39826224,
53.4249245,
77.15637078,
108.98935874,
166.65173393,
223.03796793,
289.65418241
],
[
124.375,
25.25,
17.69119873,
27.56951571,
47.18425121,
69.11077725,
99.69812293,
157.26423434,
214.94520219,
283.19939502
],
[
124.625,
24.75,
26.98599411,
43.57678324,
76.91526336,
114.10951605,
163.2064285,
245.15847293,
317.57254503,
397.47858013
],
[
124.625,
24.916667,
24.37594753,
38.79738401,
67.9409331,
100.67144649,
145.42398829,
223.62994883,
294.98261355,
374.54025927
],
[
124.625,
25.083333,
21.22142031,
33.69269988,
57.38262729,
82.87962886,
116.50148193,
175.47315554,
231.84952997,
297.59224676
],
[
124.625,
25.25,
18.56255106,
28.99860154,
49.48144226,
72.24665768,
103.33894036,
160.74228226,
217.80071696,
285.36748774
],
[
124.875,
24.75,
27.67046414,
44.86932719,
78.83835691,
116.40253325,
165.51164293,
247.13050194,
319.19936427,
398.86148581
],
[
124.875,
24.916667,
25.75700339,
41.09176671,
72.49117634,
108.07894463,
156.31598562,
238.44597229,
311.59379241,
392.16276468
],
[
124.875,
25.083333,
23.21083893,
36.39719091,
62.02935423,
90.00550485,
127.11575705,
190.71850426,
249.5555338,
316.48963444
],
[
124.875,
25.25,
20.23834354,
31.52474967,
53.04414375,
76.42303686,
108.01069115,
165.57305631,
222.02313081,
288.78222992
],
[
124.875,
25.416667,
18.24089457,
27.96262858,
47.17026205,
68.72544032,
99.06716053,
156.6313273,
214.46633655,
282.85433838
],
[
125.125,
23.916667,
26.56839798,
44.34841899,
75.48135482,
104.71860977,
139.19431575,
193.53090116,
241.39006291,
295.11260318
],
[
125.125,
24.083333,
26.43198385,
42.71609832,
70.65363093,
97.08347218,
128.46013429,
178.28173917,
222.43313555,
272.06345713
],
[
125.125,
24.25,
27.13428158,
42.48029265,
68.46879984,
93.06519378,
122.38698131,
168.93334244,
210.23650825,
256.39350218
],
[
125.125,
24.416667,
27.99083089,
43.76102357,
71.28253767,
98.38644521,
131.45320759,
184.5289499,
231.55603106,
284.06026601
],
[
125.125,
24.583333,
28.48415908,
45.45232971,
77.93811299,
113.80211452,
161.6239029,
242.7498144,
315.04627865,
394.91384640
],
[
125.375,
24.083333,
26.61050278,
43.43589198,
72.59875892,
100.02501283,
132.69948127,
184.32162421,
230.04577039,
281.20780616
],
[
125.375,
24.25,
26.60269499,
42.17447112,
68.80499186,
94.05441795,
124.1466584,
171.95028165,
214.39464646,
261.91795595
],
[
125.375,
24.416667,
27.5101969,
42.91604847,
69.22979546,
94.43383121,
124.46181851,
171.86462321,
213.60477037,
259.98150615
],
[
125.375,
24.583333,
28.20551488,
44.51910911,
74.83516598,
107.17539394,
149.96323367,
224.1769071,
292.21647104,
368.75329680
],
[
125.625,
24.083333,
26.46047319,
43.94643593,
74.54881028,
103.30832398,
137.31413003,
190.88677747,
238.18180006,
291.25877506
],
[
125.625,
24.25,
26.27063058,
42.28349661,
69.820017,
95.96709139,
127.03551295,
176.39530211,
220.08326137,
269.30753263
],
[
125.625,
24.416667,
26.79811088,
41.88871438,
67.63208538,
91.99505433,
121.14085378,
167.49153069,
208.56604734,
254.49040166
],
[
125.625,
24.583333,
27.39959262,
42.73039861,
69.65797296,
96.28683584,
128.61410613,
180.34589164,
226.09048412,
277.05785474
],
[
125.875,
24.25,
25.72904237,
42.2443136,
70.93166927,
98.03817143,
130.21145562,
181.29046166,
226.56775234,
277.27087413
],
[
125.875,
24.416667,
25.45054068,
40.56487625,
66.77218217,
91.49904579,
121.17100329,
168.49836871,
210.61745261,
257.77288182
],
[
125.875,
24.583333,
26.19013031,
40.55883944,
65.42541295,
88.93179573,
117.22691864,
162.1574417,
201.91171481,
246.50416081
],
[
125.125,
24.75,
28.49875051,
45.8943308,
80.01281646,
117.74726403,
166.92454887,
248.48251493,
320.42731155,
399.96765224
],
[
125.125,
24.916667,
27.09702979,
43.44344352,
76.55996922,
113.72512338,
162.9097405,
245.01436332,
317.52260703,
397.49128088
],
[
125.125,
25.083333,
24.63531067,
38.75844007,
67.49242351,
100.02441138,
144.89964814,
223.31280452,
294.67842259,
374.12215042
],
[
125.125,
25.25,
21.77420797,
33.94503665,
57.16847591,
82.32388741,
115.82308994,
174.93018848,
231.54066675,
297.50162499
],
[
125.375,
24.75,
28.48054442,
45.76025403,
79.67635329,
117.37751221,
166.69049651,
248.50808174,
320.60639417,
400.23954228
],
[
125.375,
24.916667,
27.77908487,
44.71702199,
78.44354514,
115.98424479,
165.21549905,
247.02555081,
319.18075894,
398.86038160
],
[
125.375,
25.083333,
25.83653477,
40.93419223,
72.12096819,
107.81638412,
156.352994,
238.84887584,
312.14926467,
392.78723397
],
[
125.375,
25.25,
23.24765829,
36.32327973,
61.72451034,
89.64937078,
127.01236213,
191.92023869,
252.42963651,
321.37555540
],
[
125.625,
24.75,
27.81981317,
44.14859801,
75.55207198,
110.16425078,
156.93930695,
237.06278282,
309.08663294,
388.92700911
],
[
125.625,
24.916667,
27.73774253,
44.63474952,
78.29238608,
115.86094001,
165.2249578,
247.23093092,
319.47865143,
399.22146342
],
[
125.625,
25.083333,
26.58690875,
42.55381472,
75.24588671,
112.1839624,
161.46356049,
243.93769965,
316.74342623,
396.94641971
],
[
125.625,
25.25,
24.54282887,
38.50647481,
66.6739442,
98.38319926,
141.99481782,
218.85332417,
289.33496969,
368.00600882
],
[
125.875,
24.75,
26.61629164,
41.47329274,
68.38787604,
95.62501399,
129.69200491,
186.22010691,
237.59379097,
296.21033741
],
[
125.875,
24.916667,
26.95447035,
42.81971925,
74.23501276,
109.56249406,
157.59395766,
239.33433972,
312.1962879,
392.50145968
],
[
125.875,
25.083333,
26.77192974,
43.00684586,
76.04599281,
113.2059701,
162.5495353,
244.93390266,
317.61277567,
397.73971410
],
[
125.875,
25.25,
25.66306307,
40.74502788,
72.1116758,
108.02832508,
156.81798507,
239.56691554,
313.00813218,
393.75322695
],
[
125.125,
25.416667,
19.27705086,
29.58033725,
49.66126405,
71.9426715,
102.61324384,
159.88329327,
217.15343754,
284.94623770
],
[
125.125,
25.583333,
17.61257995,
26.85658214,
45.18019009,
65.99474447,
95.64238512,
153.1176096,
211.69216894,
280.85761361
],
[
125.375,
25.416667,
20.55167616,
31.78676888,
53.07687264,
76.11427615,
107.276552,
164.46563184,
220.95431001,
287.98775750
],
[
125.375,
25.583333,
18.66997221,
28.48609006,
47.64190375,
68.85943514,
98.61606321,
155.50348322,
213.33146644,
281.95499176
],
[
125.375,
25.75,
17.27847342,
26.25256492,
44.01128045,
64.231693,
93.14132315,
150.15705563,
209.22549271,
279.09849211
],
[
125.625,
25.416667,
22.17435102,
34.36747863,
57.38495918,
82.02212807,
114.6957435,
172.6687714,
228.83184372,
294.75657335
],
[
125.625,
25.583333,
19.8948127,
30.57282358,
50.88282139,
73.01935895,
103.1160431,
159.30641775,
216.06797079,
283.73918049
],
[
125.625,
25.75,
18.45283675,
28.09299493,
46.83996562,
67.57153035,
96.62027129,
152.71022232,
210.66670046,
279.77359761
],
[
125.625,
25.916667,
17.23736059,
26.15485657,
43.68852857,
63.53467232,
91.8279734,
148.26426307,
207.41615732,
277.76182332
],
[
125.875,
25.416667,
23.87697554,
37.39890877,
64.34194997,
94.6968392,
136.60498698,
211.72730867,
281.27561591,
359.47791703
],
[
125.875,
25.583333,
21.84604059,
33.84382584,
56.53842729,
80.8293773,
113.31502051,
171.25680401,
227.69903215,
294.04588631
],
[
125.875,
25.75,
19.87494898,
30.52876993,
50.71174633,
72.60081353,
102.27932254,
157.94920501,
214.59890787,
282.41739555
],
[
125.875,
25.916667,
18.55005321,
28.22711655,
46.9223997,
67.45056912,
96.10688748,
151.63173861,
209.54742932,
278.87728770
],
[
125.875,
26.083333,
17.37731187,
26.34745742,
43.84249538,
63.48070123,
91.3829576,
147.41045112,
206.58681164,
277.15259603
],
[
126.125,
24.416667,
24.22329191,
39.38560384,
66.00430308,
91.10675742,
121.22984437,
169.28763013,
212.15763653,
260.21010069
],
[
126.125,
24.583333,
24.70230833,
38.62203007,
62.82685782,
85.94535307,
113.77036909,
158.35406777,
198.11072006,
242.97989775
],
[
126.375,
24.583333,
22.74534964,
37.13694477,
62.39166135,
86.57881125,
115.58824574,
161.99952127,
203.51496928,
250.43488237
],
[
126.125,
24.75,
25.04802293,
38.71960708,
62.48798696,
85.25259228,
112.56178854,
156.07162818,
194.535914,
237.68341453
],
[
126.125,
24.916667,
25.64641017,
39.9393046,
66.84973261,
94.72777933,
130.70564291,
192.24884667,
249.39544457,
314.89303443
],
[
126.125,
25.083333,
26.169279,
41.65339521,
73.0966388,
108.9612158,
157.83147357,
240.62045746,
313.99964029,
394.68291138
],
[
126.125,
25.25,
26.17903504,
42.07788076,
74.7921987,
111.71591209,
161.08389705,
243.77716379,
316.72558611,
397.02005069
],
[
126.375,
24.75,
23.71305088,
37.22012923,
60.6828015,
83.34552193,
110.53399941,
154.31949343,
193.40622403,
237.65178539
],
[
126.375,
24.916667,
24.42415223,
38.05469961,
61.91463555,
84.95863983,
112.65594913,
156.84577078,
195.96107061,
239.83453032
],
[
126.375,
25.083333,
25.3140747,
39.77493176,
67.46401346,
96.90882186,
136.00335758,
204.40902552,
268.24760694,
341.08095993
],
[
126.375,
25.25,
26.06067596,
41.75872421,
73.7965619,
110.27609326,
159.71524157,
242.85805234,
316.141353,
396.65911957
],
[
126.625,
24.75,
22.09685393,
36.61935025,
62.25695654,
86.83927911,
116.29065853,
163.42376729,
205.63272606,
253.32500645
],
[
126.625,
24.916667,
23.18754427,
36.92002518,
60.80936333,
83.86263249,
111.51365879,
155.9800745,
195.70881813,
240.65216345
],
[
126.625,
25.083333,
24.40332737,
38.31809489,
62.87873723,
86.61494684,
115.27106171,
160.9485149,
201.42228611,
246.84436587
],
[
126.625,
25.25,
25.4418876,
40.26319912,
68.87349464,
99.73039882,
141.1278501,
213.40417917,
279.89497392,
355.16686875
],
[
126.875,
24.916667,
21.94534422,
36.75053795,
63.0587742,
88.22207363,
118.35712918,
166.51410862,
209.58659745,
258.11611867
],
[
126.875,
25.083333,
23.34122661,
37.36192994,
61.89753509,
85.4528164,
113.71484875,
158.97374669,
199.40571632,
245.20563199
],
[
126.875,
25.25,
23.96436202,
38.47128043,
64.32359485,
89.40022664,
119.91259845,
168.71616808,
211.9704351,
260.20830754
],
[
126.125,
25.416667,
25.31252815,
40.19198641,
71.38374731,
107.2865374,
156.19324865,
239.29072264,
312.95702947,
393.85388447
],
[
126.125,
25.583333,
23.79879472,
37.38722329,
64.56132341,
95.20173382,
137.35641289,
212.36088546,
281.42408524,
358.98419617
],
[
126.125,
25.75,
21.96921116,
34.11607297,
57.20092967,
82.15335359,
115.51737403,
174.94797187,
232.26338068,
299.07206141
],
[
126.125,
25.916667,
20.06552526,
30.91060865,
51.2943549,
73.27068582,
102.98392837,
158.61146281,
215.21989093,
282.97094835
],
[
126.375,
25.416667,
26.22306004,
42.24540793,
75.01469335,
111.95997993,
161.37148282,
244.1227683,
317.07916307,
397.37096596
],
[
126.375,
25.583333,
25.47084435,
40.59108989,
72.25377219,
108.55881028,
157.82258395,
241.02248494,
314.599045,
395.42513179
],
[
126.375,
25.75,
24.04247185,
37.82829222,
65.78431589,
97.93110136,
143.22117141,
224.10190365,
297.65514191,
379.02630407
],
[
126.375,
25.916667,
22.27151991,
34.61621059,
58.0835895,
83.54036691,
117.31339996,
177.00582748,
234.06231288,
300.34902985
],
[
126.625,
25.416667,
26.26597628,
42.29456519,
74.89906166,
111.88674944,
161.5534744,
244.63109396,
317.71527713,
398.08071204
],
[
126.625,
25.583333,
26.4473879,
42.63727663,
75.52079234,
112.55275835,
161.98821652,
244.68001488,
317.57411776,
397.85704996
],
[
126.625,
25.75,
25.12613735,
40.47164506,
72.50176708,
109.04745465,
158.46620218,
241.66223407,
315.1209294,
395.80954585
],
[
126.625,
25.916667,
23.78497282,
37.84843663,
66.61197735,
100.04128786,
147.29635801,
230.21459543,
304.43095572,
386.07906341
],
[
126.875,
25.416667,
25.22608511,
40.69803664,
70.80534295,
104.08503093,
149.26267739,
228.47223149,
300.25384353,
380.12904292
],
[
126.875,
25.583333,
26.16867053,
42.68309797,
76.01098912,
113.44515232,
163.19301894,
246.03071627,
318.83890006,
398.96305825
],
[
126.875,
25.75,
26.37135106,
42.81907504,
75.98174207,
113.15919678,
162.59435451,
245.14821194,
317.87448786,
397.93955241
],
[
126.875,
25.916667,
25.66844958,
41.23964509,
73.43015866,
109.98071816,
159.35372607,
242.36240441,
315.61600473,
396.09779054
],
[
126.125,
26.083333,
18.737675,
28.49848606,
47.24133665,
67.6988587,
96.21209559,
151.55116987,
209.42905378,
278.75687890
],
[
126.125,
26.25,
17.28001712,
26.30948353,
43.84577739,
63.44867809,
91.25575284,
147.20071073,
206.38829177,
276.99736644
],
[
126.375,
26.083333,
20.06273478,
31.08261046,
51.70595245,
73.8579757,
103.77673541,
159.59167342,
216.21178343,
283.87127310
],
[
126.375,
26.25,
18.39281197,
28.1911961,
47.01170285,
67.59980235,
96.31889445,
151.95859165,
209.90134955,
279.18939215
],
[
126.375,
26.416667,
17.22489024,
26.2685636,
43.80229398,
63.43341844,
91.3420481,
147.45256497,
206.68190313,
277.25064537
],
[
126.625,
26.083333,
22.07032274,
34.66793268,
58.80763567,
85.60041311,
121.81962506,
186.76957798,
248.29745959,
318.59973902
],
[
126.625,
26.25,
20.19984327,
31.375653,
52.29043517,
74.72677345,
104.98708598,
161.0967294,
217.59705445,
285.03230120
],
[
126.625,
26.416667,
18.79887777,
28.7341723,
47.72941684,
68.40576795,
97.20635417,
152.79361622,
210.50264999,
279.53044563
],
[
126.625,
26.583333,
17.5716157,
26.73196089,
44.39578596,
64.07593991,
92.01177269,
147.95375475,
206.98376284,
277.38723636
],
[
126.875,
26.083333,
24.29505854,
38.50366915,
67.73082659,
101.84322478,
149.75402002,
233.411163,
307.84454342,
389.52032005
],
[
126.875,
26.25,
22.55374746,
35.32463417,
59.84435538,
87.22137811,
124.01498524,
188.8744045,
249.66113494,
318.86164859
],
[
126.875,
26.416667,
20.64277457,
31.97235651,
53.17952764,
75.89975022,
106.50384294,
162.92943686,
219.28893102,
286.52262195
],
[
126.875,
26.583333,
19.08106133,
29.13164894,
48.31277978,
69.13530353,
98.09666539,
153.74160997,
211.26722437,
280.07755570
],
[
126.875,
26.75,
17.81125864,
27.06729402,
44.86899275,
64.64731522,
92.67683021,
148.53177204,
207.39922492,
277.62846702
],
[
127.125,
25.083333,
21.54915513,
36.84206337,
64.04494944,
89.93356542,
120.92636359,
170.21292606,
214.23632415,
263.83980751
],
[
127.125,
25.25,
23.3274801,
37.82305163,
63.25877153,
87.46679025,
116.47007123,
162.73169666,
204.00352014,
250.57557696
],
[
127.375,
25.25,
21.84235687,
37.36350446,
65.27340018,
91.90410558,
123.67223023,
174.08703228,
218.92059027,
269.66147809
],
[
127.125,
25.416667,
24.6032797,
39.52272735,
66.66037313,
93.41905557,
126.42939607,
180.01082137,
228.03433945,
281.86923172
],
[
127.125,
25.583333,
25.79896071,
41.84014231,
73.32867856,
108.31220185,
155.83469139,
237.29357223,
310.06746855,
390.29871564
],
[
127.125,
25.75,
26.62975602,
43.46176622,
77.12353177,
114.72009034,
164.40070428,
246.97441832,
319.5452328,
399.46550649
],
[
127.125,
25.916667,
26.71691252,
43.29880305,
76.52759609,
113.71706221,
163.06962884,
245.45537489,
318.07391737,
398.08810280
],
[
127.375,
25.416667,
22.87682193,
38.0593986,
64.57272932,
89.5573384,
119.41973422,
166.90058984,
209.15419396,
256.63016707
],
[
127.375,
25.583333,
24.89509227,
40.16449589,
68.38435875,
96.73287369,
132.24918742,
191.1477867,
244.68520298,
305.39076858
],
[
127.375,
25.75,
26.00853892,
42.32845265,
74.53079438,
110.42599894,
159.10587272,
241.64747469,
314.79008469,
395.20213078
],
[
127.375,
25.916667,
26.75797144,
43.67435179,
77.43100387,
115.09832256,
164.80934774,
247.37504955,
319.91397131,
399.80941338
],
[
127.625,
25.416667,
21.93968026,
37.72021741,
66.37382501,
93.75572463,
126.28556628,
177.79548648,
223.58177548,
275.21616803
],
[
127.625,
25.583333,
22.9042511,
38.31631322,
65.39594418,
90.91106257,
121.34933886,
169.63881274,
212.6554443,
260.93181663
],
[
127.625,
25.75,
24.86673933,
40.13110682,
68.07338219,
95.51879054,
129.03969462,
183.2327477,
231.53778335,
285.68996937
],
[
127.625,
25.916667,
25.88945194,
41.97294636,
73.1001395,
107.10570404,
152.91759377,
232.16737813,
303.63107127,
383.01398700
],
[
127.875,
25.583333,
21.81402675,
37.81377368,
67.26782348,
95.56686562,
129.08975829,
182.10815565,
229.14140739,
281.96506419
],
[
127.875,
25.75,
22.71403096,
38.1319009,
65.35305825,
91.07323609,
121.77370965,
170.51900418,
213.99561522,
262.91736272
],
[
127.875,
25.916667,
24.58604928,
39.61696166,
66.6434609,
92.51898762,
123.61968526,
173.00453867,
216.67289927,
265.57926676
],
[
127.125,
26.083333,
25.99159788,
41.74937854,
74.10813563,
110.73374757,
160.01055182,
242.82436565,
315.892736,
396.21297066
],
[
127.125,
26.25,
24.62820817,
39.01575353,
68.83372287,
103.68248375,
152.01135881,
235.4167767,
309.44782542,
390.69248992
],
[
127.125,
26.416667,
22.88370121,
35.8571659,
61.07469409,
89.27441769,
127.56139416,
195.02876807,
257.84067787,
329.15041611
],
[
127.125,
26.583333,
20.95267453,
32.45165901,
54.05901375,
77.23614694,
108.41919014,
165.4836242,
221.93288385,
288.97123516
],
[
127.375,
26.083333,
26.83910028,
43.50120416,
76.82525479,
114.09121883,
163.47346196,
245.82575769,
318.36201443,
398.25579437
],
[
127.375,
26.25,
26.18126531,
42.08744774,
74.59302614,
111.31294119,
160.58465486,
243.2887152,
316.26386664,
396.53641419
],
[
127.375,
26.416667,
24.87636,
39.43220893,
69.78755977,
105.39237519,
154.36860831,
237.98550178,
311.96370941,
393.08415580
],
[
127.375,
26.583333,
23.16035351,
36.33993425,
62.24429825,
91.47629087,
131.71508133,
203.22443058,
269.3893428,
343.77932714
],
[
127.625,
26.083333,
26.61250389,
43.36617407,
76.87275579,
114.4059237,
164.17254369,
246.95944052,
319.65246052,
399.62362056
],
[
127.625,
26.25,
26.80042362,
43.51165881,
76.94992467,
114.33406944,
163.82415614,
246.25669496,
318.81501672,
398.74903046
],
[
127.625,
26.416667,
26.26623874,
42.32101295,
75.00736036,
111.86334221,
161.18823027,
243.85133544,
316.75984345,
396.99127369
],
[
127.625,
26.583333,
25.04765404,
39.79973457,
70.63889214,
106.46721531,
155.47773978,
238.85672693,
312.63082945,
393.52892427
],
[
127.875,
26.083333,
25.57290999,
41.25083924,
70.88191156,
102.25192822,
143.43718926,
214.4677031,
279.60800518,
353.33395365
],
[
127.875,
26.25,
26.33759667,
42.8087983,
75.67273048,
112.60573287,
162.13295724,
245.09491986,
318.09243618,
398.35181345
],
[
127.875,
26.416667,
26.66100462,
43.3688957,
76.86678891,
114.34298288,
163.95279459,
246.50883558,
319.11086522,
399.06744171
],
[
127.875,
26.583333,
26.28350651,
42.49718257,
75.38625917,
112.38780572,
161.77723775,
244.40744653,
317.22462187,
397.34158155
],
[
127.125,
26.75,
19.28020391,
29.44383825,
48.82954448,
69.82484609,
98.97094139,
154.71517641,
212.09406517,
280.70832707
],
[
127.125,
26.916667,
17.97298536,
27.31985603,
45.27701076,
65.17991445,
93.32910745,
149.13995579,
207.87772517,
277.94755328
],
[
127.125,
27.083333,
16.78563531,
25.43836231,
42.23204486,
61.30551315,
88.97772175,
145.56046766,
205.52285829,
276.68056101
],
[
127.375,
26.75,
21.22559744,
32.94305415,
54.96870021,
78.50113375,
110.05086568,
167.39300441,
223.76253907,
290.45778536
],
[
127.375,
26.916667,
19.44460625,
29.75268137,
49.40878916,
70.70934999,
99.98037544,
155.79670865,
212.9502763,
281.28543997
],
[
127.375,
27.083333,
18.08431457,
27.53382444,
45.67953996,
65.72536378,
93.98605784,
149.68957041,
208.2213666,
278.09176653
],
[
127.375,
27.25,
16.84226912,
25.56931473,
42.51383418,
61.70257482,
89.38757212,
145.85857239,
205.63310169,
276.64719516
],
[
127.625,
26.75,
23.35563988,
36.76201321,
63.46024652,
94.13348583,
137.36795674,
215.75689214,
288.04296254,
368.48649276
],
[
127.625,
26.916667,
21.42375496,
33.3756437,
55.9671748,
80.23234241,
113.00542591,
171.72436326,
228.80568644,
295.60055937
],
[
127.625,
27.083333,
19.56511215,
30.03908827,
49.97508122,
71.6048535,
101.06642014,
156.86430433,
213.82255065,
281.92661541
],
[
127.625,
27.25,
18.14730724,
27.7124864,
46.08616707,
66.31252078,
94.7141175,
150.35211781,
208.68206308,
278.34469884
],
[
127.875,
26.75,
25.1699895,
40.17685075,
71.56002913,
107.70146202,
156.89479433,
240.14821061,
313.77729292,
394.55289373
],
[
127.875,
26.916667,
23.53667447,
37.24901851,
64.76081417,
96.26507969,
140.26723472,
218.91753767,
290.88290556,
370.77895163
],
[
127.875,
27.083333,
21.60652262,
33.89496359,
57.2527766,
82.6414323,
116.6950643,
177.31616364,
235.34611844,
302.63037058
],
[
127.875,
27.25,
19.66147771,
30.49487537,
51.07542575,
73.26077842,
103.25852943,
159.2760641,
216.03615942,
283.79205735
],
[
127.625,
27.416667,
16.83339777,
25.63797724,
42.76702792,
62.12093727,
89.86120837,
146.25948393,
205.85806779,
276.73444882
],
[
127.625,
27.583333,
15.58777838,
23.68289525,
39.76928101,
58.62526127,
86.22697039,
143.44754291,
204.2571943,
275.97700159
],
[
127.875,
27.416667,
18.84370724,
28.55126393,
47.14989163,
67.5186639,
96.06634261,
151.65030014,
209.66528984,
279.02297068
],
[
127.875,
27.583333,
17.74140288,
26.69678217,
43.93693878,
63.25106534,
90.89922874,
147.00094613,
206.36633797,
277.06982421
],
[
127.875,
27.75,
16.7888738,
25.11226622,
41.22674291,
59.74287064,
87.14067522,
143.97304698,
204.58274215,
276.21764751
],
[
127.875,
27.916667,
15.95860714,
23.7395592,
39.13134492,
57.22122663,
84.23085091,
142.00496246,
203.63343975,
275.82004696
],
[
128.125,
25.75,
21.5743493,
37.84716548,
68.32536789,
97.82604087,
132.75679694,
187.68196849,
236.20364892,
290.75468225
],
[
128.125,
25.916667,
22.43100174,
37.99310456,
65.80514523,
92.22946157,
123.71386088,
173.6526627,
218.0588706,
268.25342132
],
[
128.125,
26.083333,
24.20235096,
39.11042342,
65.67989594,
90.86765582,
121.02578887,
168.8848185,
211.38559395,
258.95104049
],
[
128.125,
26.25,
25.12114365,
40.34603485,
68.40778627,
96.54184261,
131.54124838,
189.01704348,
240.76100966,
299.26448035
],
[
128.125,
26.416667,
25.86214661,
41.82155469,
73.11406597,
107.90759327,
155.23357803,
236.58823353,
309.36208376,
389.65573798
],
[
128.125,
26.583333,
26.27211153,
42.79431555,
76.11556595,
113.56267205,
163.33873896,
246.20871121,
319.02290334,
399.15028007
],
[
128.375,
26.083333,
21.89934551,
37.59788835,
66.07371199,
93.32861433,
125.75246321,
177.10845776,
222.74428692,
274.26274344
],
[
128.375,
26.25,
23.63927784,
38.44623561,
64.80168315,
89.7998541,
119.76640179,
167.47842339,
209.97870645,
257.74459495
],
[
128.375,
26.416667,
24.5576069,
39.52721677,
66.6475366,
93.06657183,
125.25387459,
176.87025712,
222.67158176,
274.04420171
],
[
128.375,
26.583333,
25.32260278,
40.94236667,
71.08035022,
103.9486924,
148.1204019,
225.17928456,
295.44116179,
374.00467766
],
[
128.625,
26.25,
21.41480101,
37.32808656,
66.29973397,
94.02351332,
126.92159942,
178.95647297,
225.20925359,
277.25599639
],
[
128.625,
26.416667,
23.03399971,
37.83926694,
64.18832992,
89.2659306,
119.32125352,
167.24372243,
210.00711622,
258.12544650
],
[
128.625,
26.583333,
23.79196806,
38.49022022,
64.52956391,
89.41687347,
119.39659813,
167.08993119,
209.33810525,
256.56797131
],
[
128.875,
26.583333,
22.16606558,
37.14646176,
64.06659845,
89.79668733,
120.62438406,
169.67008978,
213.46377417,
262.77280213
],
[
128.125,
26.75,
26.06964862,
42.36855158,
75.44550872,
112.61488143,
162.1482148,
244.86788392,
317.68790516,
397.80496969
],
[
128.125,
26.916667,
25.10630939,
40.36564489,
72.19502545,
108.62756351,
157.9992473,
241.22082228,
314.70485699,
395.35919132
],
[
128.125,
27.083333,
23.56414177,
37.65032234,
66.31108271,
99.37971287,
145.76479269,
227.2458693,
300.59685867,
381.65949961
],
[
128.125,
27.25,
22.3364232,
34.94052109,
59.4809105,
87.27973499,
125.28149693,
193.22061817,
256.93081815,
329.23797642
],
[
128.375,
26.75,
25.77820035,
42.06335482,
75.02508071,
112.2396365,
162.07283959,
245.24415185,
318.30076677,
398.59878881
],
[
128.375,
26.916667,
25.71400458,
42.0309572,
75.24549446,
112.55437946,
162.23281838,
245.08281808,
317.97363626,
398.19061305
],
[
128.375,
27.083333,
26.39987833,
42.02661243,
74.2138693,
110.73549944,
159.96710731,
242.83390787,
316.02754544,
396.56126946
],
[
128.375,
27.25,
25.5945749,
40.12684127,
70.8558164,
106.57970219,
155.48979303,
238.85685488,
312.73827846,
393.81573873
],
[
128.625,
26.75,
24.39568197,
39.3573777,
67.24945598,
96.04598749,
133.2281496,
196.65712713,
255.22747356,
321.96596398
],
[
128.625,
26.916667,
25.98513956,
41.42215157,
71.72906969,
105.57979566,
151.7220234,
231.99083817,
304.2202595,
384.28351978
],
[
128.625,
27.083333,
26.81881696,
42.59427679,
74.68865536,
111.21085457,
160.54325623,
243.51261725,
316.69387903,
397.19179882
],
[
128.625,
27.25,
27.05596962,
42.90829709,
75.29088636,
111.92980798,
161.07372407,
243.65887794,
316.61071265,
396.92652252
],
[
128.875,
26.75,
24.22772266,
38.46796308,
63.56707991,
87.43358022,
116.05327144,
161.71430922,
202.47664508,
248.55508785
],
[
128.875,
26.916667,
25.3997746,
39.40230889,
64.42488931,
88.4164653,
117.37861,
163.45437673,
204.2532065,
249.98793162
],
[
128.875,
27.083333,
26.35530039,
40.67594691,
67.38279427,
94.79254086,
129.73937746,
188.85838351,
243.34607694,
305.79856145
],
[
128.875,
27.25,
27.35793816,
42.44136788,
71.83032899,
104.62222659,
149.24207826,
227.57252181,
298.81869523,
378.33193650
],
[
128.125,
27.416667,
21.69237968,
33.07782884,
54.70251018,
77.99952217,
109.44363299,
167.03466053,
223.87011182,
291.07410747
],
[
128.125,
27.583333,
20.26334517,
30.60014229,
50.03992308,
71.14503581,
99.97310524,
155.29212875,
212.37633273,
280.83503108
],
[
128.125,
27.75,
19.27842467,
28.85121529,
47.03841474,
66.80423192,
94.56085428,
149.57012327,
207.93136015,
277.86940140
],
[
128.125,
27.916667,
18.50025705,
27.53965073,
44.73243917,
63.68845733,
90.7567694,
146.39155285,
205.84559117,
276.75755653
],
[
128.375,
27.416667,
24.51261614,
38.00056163,
65.82643392,
98.25322059,
144.39851172,
226.81179604,
301.22017519,
383.20929417
],
[
128.375,
27.583333,
23.31848471,
35.69031256,
59.89694039,
87.39286107,
125.17983287,
193.82419238,
259.01677952,
333.36247200
],
[
128.375,
27.75,
22.11719885,
33.43687936,
54.99766531,
78.18933478,
109.49915703,
167.01923435,
223.96336313,
291.34898007
],
[
128.375,
27.916667,
20.95877382,
31.39960804,
50.99684758,
72.09976222,
100.81734562,
155.87857916,
212.83648302,
281.20805014
],
[
128.625,
27.416667,
26.93287063,
42.39648391,
74.27665543,
110.47042105,
159.3803594,
241.97781865,
315.15256206,
395.69098832
],
[
128.625,
27.583333,
26.46424754,
41.09569136,
71.7680464,
107.26115966,
155.86367327,
238.89238703,
312.6794792,
393.77798104
],
[
128.625,
27.75,
25.72444029,
39.32157565,
67.56478897,
100.09295037,
146.10209417,
227.6829135,
301.35206399,
382.72310862
],
[
128.625,
27.916667,
24.76801692,
37.45464104,
62.49408708,
90.25904965,
128.48770014,
197.06727906,
261.30861598,
334.04263559
],
[
128.875,
27.416667,
28.34583296,
44.30632561,
76.30986595,
112.71789907,
161.75394181,
244.28438304,
317.16269764,
397.41330567
],
[
128.875,
27.583333,
29.12482306,
45.67675645,
78.63629845,
115.74654468,
164.94567525,
247.22000061,
319.78403208,
399.82929103
],
[
128.875,
27.75,
29.3827597,
45.96679141,
78.86342445,
115.85179874,
164.9462638,
247.27472021,
319.95317827,
400.09138877
],
[
128.875,
27.916667,
28.95815975,
44.93378461,
76.90372681,
113.15423869,
161.99020747,
244.65464278,
317.80973042,
398.32554344
],
[
128.125,
28.083333,
17.82288334,
26.43086826,
42.83390745,
61.17650556,
88.09604454,
144.36617396,
204.74485973,
276.26302899
],
[
128.375,
28.083333,
19.89897328,
29.71529287,
48.28670955,
68.24287284,
96.09562207,
150.92481403,
208.97500711,
278.56622932
],
[
128.375,
28.25,
19.16882266,
28.52368148,
46.22898767,
65.48845529,
92.74575577,
148.00085341,
206.98142758,
277.43685651
],
[
128.625,
28.083333,
23.63144309,
35.38819423,
57.66781707,
81.54516022,
113.54480102,
171.40827041,
228.27076432,
295.12757443
],
[
128.625,
28.25,
22.49699354,
33.37548792,
53.69339196,
75.32062079,
104.56372447,
159.60961812,
216.067178,
283.76941333
],
[
128.625,
28.416667,
21.43330138,
31.6085391,
50.57934923,
71.04394775,
99.19157665,
153.95397723,
211.25214029,
280.05500317
],
[
128.625,
28.583333,
20.51825501,
30.19961851,
48.5150157,
68.13998454,
95.61468369,
150.25294029,
208.49146576,
278.26922996
],
[
128.875,
28.083333,
27.94688136,
42.65674875,
71.99188352,
105.4132858,
151.68609375,
233.33540453,
306.95466124,
388.23295920
],
[
128.875,
28.25,
26.72682926,
39.86830543,
65.90936442,
93.92536112,
131.35468469,
197.13069031,
258.37430928,
328.02569494
],
[
128.875,
28.416667,
25.39768456,
37.51015992,
60.22563094,
84.44631967,
116.24474029,
173.35050205,
229.33407608,
295.34813452
],
[
128.875,
28.583333,
24.27305463,
35.57211666,
56.4465755,
78.34963188,
107.78329924,
162.58646661,
218.32547017,
285.40707866
],
[
128.875,
28.75,
23.5916401,
34.57991644,
54.72337562,
75.85738818,
104.32146083,
158.24591077,
214.27051803,
281.96318535
],
[
128.125,
32.083333,
5.20972147,
6.7780039,
8.85116051,
11.3935517,
16.60399265,
24.91733464,
32.81105543,
42.29670832
],
[
128.125,
32.25,
5.15660669,
6.70889998,
8.76092009,
11.10101581,
16.55767762,
25.35936075,
33.90309159,
44.28475691
],
[
128.125,
32.416667,
5.15267097,
6.70377949,
8.75423342,
11.16777757,
17.09997838,
27.13940165,
37.18326341,
49.44120192
],
[
128.125,
32.583333,
5.18438789,
6.74504416,
8.80811952,
11.55795341,
18.15120021,
30.18297774,
42.91060036,
58.40776690
],
[
128.375,
32.083333,
5.91327777,
7.69335175,
10.17734683,
16.96908384,
25.35152461,
40.22346486,
55.12609016,
72.86526228
],
[
128.375,
32.25,
5.80418602,
7.55142012,
9.86113795,
16.45864318,
25.25048469,
42.4963937,
60.59954752,
83.43645656
],
[
128.375,
32.416667,
5.73884921,
7.46641496,
9.75013266,
16.45774852,
26.39041705,
48.23232002,
73.71883553,
107.48504852
],
[
128.375,
32.583333,
5.71550547,
7.43604406,
9.71047236,
16.88706218,
28.51054979,
57.21769956,
92.82474028,
141.66313183
],
[
128.625,
32.083333,
6.57432897,
8.5533992,
15.33858685,
26.58485692,
44.01763016,
79.89565063,
120.00115752,
172.79443205
],
[
128.625,
32.25,
7.13865845,
9.28760878,
16.97203942,
26.72777237,
42.86925037,
82.51156956,
133.17256844,
200.29240833
],
[
128.625,
32.416667,
7.15562735,
9.30968582,
16.91558592,
26.64299799,
43.82903203,
89.51771055,
145.91642106,
215.15799994
],
[
128.625,
32.583333,
7.16437978,
9.32107299,
17.00590605,
27.09580875,
45.83339499,
94.85629939,
151.59485503,
219.95708312
],
[
128.875,
32.083333,
8.03263986,
11.54419637,
24.31572558,
42.99947949,
75.9328413,
144.66064147,
212.02558285,
287.91453245
],
[
128.875,
32.25,
8.16075142,
11.94998956,
23.73327863,
39.65293415,
66.60935185,
121.9152862,
177.89839674,
243.56224638
],
[
128.875,
32.416667,
8.28962281,
12.32130848,
23.40792417,
37.67141137,
60.26891589,
109.16625276,
162.32970435,
227.36405560
],
[
128.875,
32.583333,
8.36054813,
12.49129001,
23.12457964,
36.4705961,
57.54519465,
104.8336717,
158.17422944,
224.04321448
],
[
128.125,
32.75,
5.23548784,
6.81152672,
8.8949368,
12.20513938,
19.58425798,
35.43119506,
51.83883104,
72.45024830
],
[
128.375,
32.75,
5.72320726,
7.44606432,
9.72355747,
17.63355206,
31.71966558,
68.75949924,
116.21207967,
179.63487955
],
[
128.375,
32.916667,
5.74654812,
7.47643148,
9.76321289,
18.55578742,
35.79946663,
81.64220005,
138.56504935,
208.97266577
],
[
128.375,
33.083333,
5.62496496,
7.31824814,
9.55664674,
18.90633796,
39.4178891,
91.00859503,
148.98060276,
218.14065146
],
[
128.375,
33.25,
5.67620368,
7.38491125,
9.64369979,
19.89070452,
42.67209859,
95.61291556,
152.86208625,
221.03611617
],
[
128.625,
32.75,
7.14432744,
9.2949843,
17.08282891,
27.6470562,
47.64538292,
97.78652107,
154.08324653,
221.77194491
],
[
128.625,
32.916667,
7.08518424,
9.21803722,
17.03265956,
28.01210737,
48.82339299,
99.30837928,
155.23084344,
222.51572179
],
[
128.625,
33.083333,
6.98346768,
9.08570093,
16.78548731,
28.06071473,
49.38606225,
100.0564508,
155.74566138,
222.80950096
],
[
128.625,
33.25,
6.84545755,
8.9061456,
16.31926084,
27.79458994,
49.51736539,
100.3983139,
155.95492541,
222.91430514
],
[
128.875,
32.75,
8.31987264,
12.31404527,
22.59915338,
35.58860478,
56.2707255,
103.40259792,
157.10451024,
223.35246619
],
[
128.875,
32.916667,
8.15873885,
11.74943335,
21.62708362,
34.45214777,
55.06898861,
102.5628143,
156.68356804,
223.16326207
],
[
128.875,
33.083333,
7.89778562,
10.81309561,
20.16355606,
32.88819498,
53.6079565,
101.80758862,
156.40431988,
223.07243005
],
[
128.875,
33.25,
7.58850892,
9.87287773,
19.08875802,
31.18714236,
52.25260231,
101.31655575,
156.26734017,
223.03730088
],
[
128.625,
33.416667,
6.00819493,
7.81684183,
11.42571629,
25.57835185,
48.94506634,
100.38098796,
155.97451489,
222.92644749
],
[
128.625,
33.583333,
5.96932442,
7.76627013,
10.96979887,
24.85042322,
48.23504789,
99.8865031,
155.71263771,
222.80202543
],
[
128.625,
33.75,
5.88365095,
7.65480637,
9.99614648,
23.01189989,
46.08140262,
98.22895699,
154.63010849,
222.16922845
],
[
128.625,
33.916667,
5.75862175,
7.49213963,
9.78372562,
19.99249918,
41.05271153,
92.73340777,
150.32523865,
219.12685530
],
[
128.875,
33.416667,
7.28138388,
9.47329884,
18.0684703,
29.72046471,
51.23522036,
101.07480336,
156.21667125,
223.02542690
],
[
128.875,
33.583333,
6.1923157,
8.05638847,
13.2284503,
27.03534221,
49.9659949,
100.87230363,
156.1744466,
223.01716773
],
[
128.875,
33.75,
6.13670352,
7.98403535,
12.69482757,
26.47519269,
49.49343868,
100.60670629,
156.06773513,
222.97827442
],
[
128.875,
33.916667,
6.04061506,
7.85902138,
11.70650687,
25.29256495,
48.42661824,
99.90801784,
155.71239668,
222.81000119
],
[
128.625,
34.083333,
5.60048938,
7.28640468,
9.51506347,
17.6127086,
34.31345735,
77.85851492,
132.32849029,
201.46364108
],
[
128.625,
34.25,
5.41410086,
7.04390762,
9.19839496,
14.98929166,
27.49682913,
58.11977938,
96.2007142,
148.44768974
],
[
128.625,
34.416667,
5.20228695,
6.76833137,
8.83852948,
12.28485126,
21.69530841,
42.28508479,
65.03651376,
94.00547074
],
[
128.625,
34.583333,
4.99919223,
6.50409904,
8.49347764,
9.99838445,
17.62496568,
31.35491573,
45.79049143,
63.41374463
],
[
128.875,
34.083333,
5.90819371,
7.68673723,
10.25019509,
23.12068478,
46.03794357,
98.13299658,
154.56896142,
222.14367791
],
[
128.875,
34.25,
5.7438401,
7.47290826,
9.75861203,
19.84332291,
40.79713211,
92.55992646,
150.22858985,
219.08310710
],
[
128.875,
34.416667,
5.58827159,
7.27050897,
9.49430581,
17.40282233,
33.80090001,
77.00082878,
131.38259331,
200.57039256
],
[
128.875,
34.583333,
5.38070714,
7.00046139,
9.14166004,
14.59459167,
26.82272469,
56.42032813,
92.5024571,
141.40096187
],
[
128.625,
34.75,
4.75115165,
6.18139081,
8.07206414,
9.50230331,
14.30511246,
24.21963674,
34.19830861,
46.45825576
],
[
128.625,
34.916667,
4.48525139,
5.83544659,
7.62030757,
8.97050277,
11.37041189,
18.99750923,
26.66659413,
35.90313215
],
[
128.625,
35.083333,
4.21285805,
5.48105469,
7.15751945,
8.42571609,
9.69391273,
15.58481111,
21.07089363,
28.41929830
],
[
128.625,
35.25,
3.94766523,
5.13603088,
6.70696482,
7.89533047,
9.08369612,
12.5994204,
17.31821064,
22.91628589
],
[
128.875,
34.75,
5.14621526,
6.69538042,
8.74326536,
11.66287984,
20.70496766,
40.39303166,
61.85741566,
88.85668989
],
[
128.875,
34.916667,
4.8842776,
6.35459166,
8.29824113,
9.76855519,
16.50923932,
29.55212724,
43.4206557,
60.19338751
],
[
128.875,
35.083333,
4.59883575,
5.98322326,
7.813284,
9.1976715,
12.78287983,
22.1351743,
31.67225081,
43.55424893
],
[
128.875,
35.25,
4.29940204,
5.59365101,
7.3045551,
8.59880407,
9.89305305,
17.03153641,
23.8176406,
32.28171336
],
[
128.625,
35.416667,
3.70018961,
4.81405768,
6.28651116,
7.40037923,
8.51424729,
9.98670078,
14.29551141,
18.64292957
],
[
128.875,
35.416667,
4.00204804,
5.20678454,
6.79935957,
8.00409607,
9.20883258,
13.30184797,
18.26543546,
24.62845955
],
[
129.125,
26.75,
23.56054427,
38.56264126,
66.23854591,
92.76761359,
124.40981885,
174.62425023,
219.27380687,
269.85258803
],
[
129.125,
26.916667,
24.84950568,
38.91129133,
64.20623059,
88.37057293,
117.40821267,
163.70044802,
204.98188961,
251.56368179
],
[
129.125,
27.083333,
26.10682237,
39.7628901,
63.9857454,
87.09552169,
114.92625918,
159.23984432,
198.53914011,
242.69474798
],
[
129.125,
27.25,
27.65156377,
41.76501482,
66.52842535,
90.36896428,
119.22621622,
165.04083035,
205.37142775,
250.30032973
],
[
129.375,
27.083333,
27.13239862,
42.2111715,
68.98555579,
94.83156971,
125.75635516,
174.93349711,
218.47237426,
267.42315707
],
[
129.375,
27.25,
29.25819206,
44.73597688,
71.15247111,
96.76530198,
127.66294114,
177.15685965,
221.09775451,
270.55276565
],
[
129.625,
27.25,
33.19008806,
52.4272524,
85.31824678,
116.33526581,
153.30929428,
212.07164224,
263.93008143,
322.26251840
],
[
129.125,
27.416667,
29.42006759,
44.72400394,
72.01429826,
99.7380923,
134.56271257,
191.45266616,
242.48398287,
299.88107226
],
[
129.125,
27.583333,
31.34916107,
47.85494565,
79.04036136,
113.07792909,
158.44275521,
236.56288538,
307.25402959,
385.99112049
],
[
129.125,
27.75,
32.80280291,
50.1720772,
84.63036216,
122.45320005,
172.31179385,
255.04463913,
327.7386645,
407.66893002
],
[
129.125,
27.916667,
33.27058374,
51.05749413,
86.31050995,
124.71682925,
174.73197186,
257.15667796,
329.53525575,
409.09827688
],
[
129.375,
27.416667,
31.74525844,
47.80955134,
75.27817676,
101.74277176,
133.93851524,
185.61438329,
231.71860445,
283.49371990
],
[
129.375,
27.583333,
33.93962797,
50.58914933,
79.42831713,
107.40763707,
141.23642429,
195.47652922,
243.62218242,
297.64393501
],
[
129.375,
27.75,
35.33685243,
52.7315677,
83.64775919,
114.44430751,
152.34498771,
213.53614385,
267.60469833,
328.02930384
],
[
129.375,
27.916667,
35.9847049,
54.05523062,
87.69300323,
123.31870463,
169.45799891,
246.88793932,
316.05151877,
393.01277483
],
[
129.625,
27.416667,
35.82735723,
55.35258965,
88.33494674,
119.68314393,
157.36947198,
217.39335924,
270.62486982,
330.39449528
],
[
129.625,
27.583333,
37.14743078,
56.12318272,
88.24986401,
119.10853806,
156.42419299,
216.0504203,
268.85874549,
328.06425721
],
[
129.625,
27.75,
37.58525569,
55.90215103,
87.09502211,
117.25369824,
153.79319985,
212.29838249,
263.9168243,
321.74731003
],
[
129.625,
27.916667,
37.71370521,
55.70892131,
86.54508292,
116.40736901,
152.49694593,
210.09960655,
260.64851479,
317.24377474
],
[
129.875,
27.583333,
40.87334926,
63.41363462,
100.93127715,
136.17357649,
177.8779923,
243.57268205,
301.15073324,
365.52652010
],
[
129.875,
27.75,
40.45154873,
61.50774578,
96.9450031,
130.45681513,
170.5125655,
233.87315915,
289.44555158,
351.48492296
],
[
129.875,
27.916667,
39.82164364,
59.63016118,
93.31584971,
125.4721657,
164.04703914,
225.24059765,
278.94706662,
338.99910140
],
[
129.125,
28.083333,
32.75364448,
50.12343243,
84.86697792,
122.71852859,
172.26255168,
254.38425382,
326.65376585,
406.24773070
],
[
129.125,
28.25,
31.40961641,
48.07680877,
81.12936828,
118.01213799,
166.97197625,
249.09889455,
321.63795407,
401.64189376
],
[
129.125,
28.416667,
29.74809474,
45.247519,
75.2273735,
108.6781069,
154.4380867,
234.2592338,
306.47628722,
386.58393933
],
[
129.125,
28.583333,
28.52013621,
42.48889361,
68.80940737,
96.97320611,
134.2080363,
199.69367364,
261.46600665,
332.33271276
],
[
129.375,
28.083333,
36.04752601,
54.58882212,
90.34298773,
129.31587693,
179.78755433,
262.4837078,
334.81382303,
414.25185077
],
[
129.375,
28.25,
35.5796524,
54.07774662,
89.99359346,
128.99493953,
179.22394696,
261.40896494,
333.45139379,
412.67400172
],
[
129.375,
28.416667,
34.62060269,
52.52500327,
87.63942315,
125.79136303,
175.34890935,
257.1254086,
329.09996234,
408.34664698
],
[
129.375,
28.583333,
33.38120711,
50.32985253,
83.98693243,
120.73700301,
169.40148631,
251.01733217,
323.20009828,
402.87734280
],
[
129.625,
28.083333,
37.73527688,
55.85949569,
87.7226365,
119.22384649,
157.73157449,
219.07625772,
272.98213225,
332.79693195
],
[
129.625,
28.25,
37.65433805,
56.16979959,
90.1725859,
125.8667619,
171.37055359,
246.92278634,
314.28900262,
389.40667700
],
[
129.625,
28.416667,
37.29118351,
56.24399886,
92.44972438,
131.41781359,
181.72230146,
264.05042208,
336.08610393,
415.27940543
],
[
129.625,
28.583333,
37.21768113,
56.38534532,
93.10183486,
132.26610496,
182.41869795,
264.26139653,
335.94360093,
414.87682647
],
[
129.875,
28.083333,
39.20956582,
58.11760896,
90.23621441,
121.23240592,
158.52997772,
217.79240961,
269.99616281,
328.23359343
],
[
129.875,
28.25,
38.76374148,
57.16313642,
88.52750906,
118.78699925,
155.25663699,
213.16069784,
263.97128212,
320.68870122
],
[
129.875,
28.416667,
38.71459079,
57.17934939,
89.33118462,
120.89802456,
159.11305523,
219.6490892,
272.69030816,
331.46912745
],
[
129.875,
28.583333,
38.97511201,
58.16252795,
93.33687479,
129.61683541,
175.71023058,
251.42459586,
318.59760169,
393.48852303
],
[
129.125,
28.75,
27.86880156,
41.13686526,
65.62298367,
90.48278567,
122.78229833,
179.40269315,
234.36827869,
299.16752087
],
[
129.125,
28.916667,
28.19149552,
43.04105205,
71.3400134,
101.21703898,
139.6587862,
204.68324658,
264.08074793,
331.63751591
],
[
129.125,
29.083333,
29.30249799,
47.58054799,
88.20711516,
137.63873397,
202.76329691,
303.94113076,
388.12002206,
478.04524616
],
[
129.125,
29.25,
30.48139225,
51.56763018,
98.55076924,
151.7311973,
217.53944092,
317.51150462,
400.71425324,
489.99956236
],
[
129.375,
28.75,
32.756012,
49.42998637,
81.64464133,
116.28005548,
161.91850026,
239.8581233,
310.35456046,
388.80896999
],
[
129.375,
28.916667,
33.13771204,
51.21319574,
88.18289034,
129.73183714,
184.89053207,
275.385527,
353.70635722,
438.86961453
],
[
129.375,
29.083333,
34.00931572,
54.72802294,
99.95236409,
151.73779704,
216.71061017,
316.26676098,
399.31734442,
488.46176073
],
[
129.375,
29.25,
34.55000883,
56.39589364,
103.28804203,
155.33692067,
219.87793526,
318.83081645,
401.57906204,
490.53300565
],
[
129.625,
28.75,
37.27119431,
56.9770086,
95.52100515,
137.06636479,
190.23373922,
276.22616689,
350.74144461,
432.20312618
],
[
129.625,
28.916667,
37.4442562,
58.0003617,
99.28791678,
144.46786193,
201.87774949,
293.13667382,
371.19748849,
455.97154665
],
[
129.625,
29.083333,
37.44998371,
58.51207586,
101.05051495,
147.1808824,
205.29432434,
296.78976409,
374.8939815,
459.62205704
],
[
129.625,
29.25,
37.03210258,
58.22477253,
101.43170455,
148.39991691,
207.51363934,
300.16293439,
379.12145545,
464.73821886
],
[
129.875,
28.75,
39.45045928,
60.00031947,
100.57480572,
144.92643827,
201.60745039,
292.2010899,
369.90201995,
454.40550708
],
[
129.875,
28.916667,
39.83837943,
61.60738045,
104.83925928,
151.25541011,
209.49658682,
300.67989519,
378.50244999,
462.99636876
],
[
129.875,
29.083333,
39.69484321,
61.4071666,
104.26113761,
150.08703868,
207.80290558,
298.56279256,
376.2222182,
460.57285274
],
[
129.875,
29.25,
39.06033596,
60.27015199,
102.39825411,
147.66395492,
204.91470481,
295.62064116,
373.38838554,
457.95640590
],
[
129.125,
29.416667,
30.49949712,
51.85188558,
98.96355364,
152.13112343,
217.83163206,
317.67227047,
400.77911957,
489.95828865
],
[
129.125,
29.583333,
29.40397215,
49.9939655,
97.08593213,
150.64224952,
216.88235585,
317.1305868,
400.37490783,
489.60653664
],
[
129.125,
29.75,
27.87289812,
47.29008476,
93.35888259,
147.60309895,
214.73767716,
315.80039285,
399.46120166,
489.03566415
],
[
129.125,
29.916667,
26.01855879,
43.45727408,
85.76328813,
138.65345924,
206.43502655,
308.85790026,
393.31673785,
483.41534388
],
[
129.375,
29.416667,
34.19281002,
55.99124883,
102.65248434,
154.6445242,
219.26206723,
318.3307459,
401.12630334,
490.09661313
],
[
129.375,
29.583333,
33.3137437,
54.95262534,
101.52506901,
153.7609066,
218.66997848,
317.96468019,
400.82405529,
489.79797192
],
[
129.375,
29.75,
32.0871579,
53.55321796,
100.19945658,
152.85788187,
218.14055751,
317.71902144,
400.73367183,
489.86313110
],
[
129.375,
29.916667,
30.41350093,
51.64108715,
98.60529283,
151.76026923,
217.53194818,
317.43766128,
400.57382661,
489.77996570
],
[
129.625,
29.416667,
36.33227956,
57.63575702,
102.1211445,
151.65073814,
214.37771913,
311.9299921,
394.09058339,
482.57645965
],
[
129.625,
29.583333,
35.5132696,
57.03789923,
102.9169363,
154.31355941,
218.65052484,
317.62019983,
400.39876547,
489.37369463
],
[
129.625,
29.75,
34.58293432,
56.23509335,
102.62670025,
154.48647802,
219.07551952,
318.17760068,
401.03047069,
490.08520125
],
[
129.625,
29.916667,
33.4980314,
55.15111158,
101.70798522,
153.86838462,
218.71043283,
317.99435358,
400.92667429,
490.04357760
],
[
129.875,
29.416667,
38.1785849,
59.0441632,
100.55657836,
145.48975847,
202.45714996,
293.20292689,
371.05518435,
455.74525471
],
[
129.875,
29.583333,
37.22313171,
57.92704512,
99.25731913,
143.94336835,
200.48355299,
290.75939225,
368.28135845,
452.69446423
],
[
129.875,
29.75,
36.20645199,
57.05620388,
99.80830601,
147.16501256,
207.26909567,
301.59370924,
381.70293353,
468.36696959
],
[
129.875,
29.916667,
36.23676585,
57.11101691,
101.52587101,
151.86394749,
215.67500534,
314.47766876,
397.39147555,
486.60150898
],
[
129.125,
30.083333,
22.25627544,
37.6173833,
73.43602942,
118.39705075,
178.90398255,
274.96542891,
355.855469,
442.79578717
],
[
129.125,
30.25,
20.1964085,
33.85429468,
63.00522706,
97.92068611,
145.2098745,
223.6143186,
292.3276751,
367.87027082
],
[
129.125,
30.416667,
18.75285293,
30.19781566,
54.7854526,
83.01563803,
122.34068842,
192.52528102,
257.83069843,
331.62383156
],
[
129.125,
30.583333,
17.17137815,
27.44745423,
48.70403522,
73.99032123,
110.8289761,
180.77729104,
247.48669078,
322.75618240
],
[
129.375,
30.083333,
28.68338371,
48.9961188,
96.02389923,
149.84591198,
216.34922827,
316.76536635,
400.05203817,
489.29141898
],
[
129.375,
30.25,
26.70265932,
45.45282036,
90.61216831,
145.00860721,
212.58114499,
314.10972878,
397.96637459,
487.61310412
],
[
129.375,
30.416667,
22.91091625,
39.44057106,
80.02909689,
131.13301476,
197.71199492,
299.80441593,
384.31394073,
474.45658188
],
[
129.375,
30.583333,
20.68717511,
35.7144701,
69.80188906,
112.27402451,
169.05693215,
259.86847822,
336.96017459,
420.11613471
],
[
129.625,
30.083333,
32.17559812,
53.76648136,
100.50616062,
153.07327245,
218.24833392,
317.73275189,
400.68677684,
489.75104785
],
[
129.625,
30.25,
31.7307171,
52.79440001,
99.33228811,
152.22179509,
217.76791628,
317.51492175,
400.58012751,
489.73125897
],
[
129.625,
30.416667,
31.12728815,
51.62596211,
97.9442459,
151.13694088,
217.12632186,
317.21575789,
400.45064938,
489.75646150
],
[
129.625,
30.583333,
29.60807027,
49.33238268,
95.39653567,
149.16943066,
215.85715568,
316.47878769,
399.89422377,
489.26835913
],
[
129.875,
30.083333,
35.6821898,
56.66730424,
101.91653701,
153.38928659,
218.03355983,
317.34422391,
400.33739307,
489.52151229
],
[
129.875,
30.25,
35.20017747,
56.26854792,
101.79117838,
153.53049423,
218.32769085,
317.71065606,
400.72650659,
489.92247842
],
[
129.875,
30.416667,
34.72442819,
55.86557018,
101.53391173,
153.44393595,
218.36420407,
317.83006353,
400.90824215,
490.18922208
],
[
129.875,
30.583333,
34.09945261,
55.17650646,
100.82588131,
152.94300584,
218.07482249,
317.6761144,
400.76817981,
490.01007551
],
[
129.125,
30.75,
15.81473769,
25.0985852,
44.66358976,
68.60486835,
105.3624773,
176.57155537,
244.46693126,
320.64813673
],
[
129.125,
30.916667,
14.50195809,
22.94796508,
41.37086045,
65.17032416,
102.19892357,
174.7037765,
243.35250903,
320.00205568
],
[
129.125,
31.083333,
13.24104764,
20.94478164,
38.95348478,
62.73065453,
100.38012733,
173.90010612,
242.95753383,
319.82741279
],
[
129.125,
31.25,
11.99097526,
19.41350006,
37.22008867,
61.02651583,
99.42894253,
173.59318658,
242.84420242,
319.77581260
],
[
129.375,
30.75,
18.95683437,
31.83096919,
60.45406746,
94.92891402,
141.33380914,
218.55320336,
286.50965854,
361.36099895
],
[
129.375,
30.916667,
17.44985259,
28.49833427,
52.59942189,
80.68651749,
119.88433142,
190.08447989,
255.6151089,
329.58116518
],
[
129.375,
31.083333,
15.66693904,
25.54204345,
46.58116395,
71.81306774,
109.03308707,
179.49731811,
246.55691187,
322.07218814
],
[
129.375,
31.25,
14.22773838,
23.03960391,
42.33417591,
66.65489304,
103.81872303,
175.67563681,
243.89876231,
320.28360162
],
[
129.625,
30.75,
27.19175922,
45.3120545,
89.18388671,
143.45443487,
211.34861768,
313.19835079,
397.19627971,
486.92528432
],
[
129.625,
30.916667,
24.3425405,
40.21876254,
78.91934038,
128.29481965,
193.80493505,
295.23870539,
379.41220008,
469.37260343
],
[
129.625,
31.083333,
18.89651187,
33.09048946,
66.10387442,
106.27116663,
159.92993606,
246.9500748,
321.4800494,
402.38844441
],
[
129.625,
31.25,
17.31929066,
29.20537385,
56.43817937,
88.08298747,
130.70550836,
203.4136122,
269.1287608,
342.60074682
],
[
129.875,
30.75,
33.16508184,
54.08749139,
99.77103179,
152.22214238,
217.67920438,
317.48662453,
400.62082835,
489.84757955
],
[
129.875,
30.916667,
31.79417855,
52.33792023,
98.10760691,
150.97561088,
216.94943862,
317.14588643,
400.47635158,
489.88673234
],
[
129.875,
31.083333,
29.32271535,
48.93003507,
94.25694203,
147.8619325,
214.78439666,
315.78590825,
399.47254764,
489.12454300
],
[
129.875,
31.25,
27.78816608,
45.57915572,
87.01227511,
139.06886422,
206.57599708,
308.9431484,
393.40027266,
483.50256080
],
[
129.125,
31.416667,
10.72368905,
18.31983792,
35.72599497,
59.81781973,
98.88759717,
173.46232324,
242.80492897,
319.75071499
],
[
129.125,
31.583333,
9.7745463,
17.24478763,
34.33253578,
58.94021001,
98.48014113,
173.36371956,
242.77192219,
319.75779552
],
[
129.125,
31.75,
9.29492376,
16.1733029,
33.09298699,
58.1312562,
98.01835896,
173.20159998,
242.70292844,
319.73109370
],
[
129.125,
31.916667,
9.34310984,
16.1522073,
32.51033173,
57.25687508,
97.1891282,
172.74370551,
242.44957571,
319.57267396
],
[
129.375,
31.416667,
12.85545662,
20.80352981,
39.31503959,
63.54575191,
101.166292,
174.25033454,
243.1095942,
319.84547285
],
[
129.375,
31.583333,
12.70514517,
19.95936503,
37.98753604,
61.83818155,
99.88925905,
173.72557934,
242.8738053,
319.75913994
],
[
129.375,
31.75,
10.98775626,
18.78932886,
36.80271423,
60.85748361,
99.3429056,
173.53787999,
242.80348366,
319.73535753
],
[
129.375,
31.916667,
11.49926942,
19.17266982,
37.24594067,
61.12506343,
99.36351602,
173.50995092,
242.79241931,
319.71412581
],
[
129.625,
31.416667,
16.35856167,
26.73921299,
49.2968935,
76.30629621,
114.42769578,
184.37421928,
250.44998216,
325.06248413
],
[
129.625,
31.583333,
15.17684826,
24.55926162,
44.93833197,
69.66839241,
106.87302608,
177.71807515,
245.21266033,
321.09709437
],
[
129.625,
31.75,
13.9557346,
22.92230221,
42.48263239,
66.77933942,
103.66403023,
175.35655451,
243.64569973,
320.11329218
],
[
129.625,
31.916667,
14.80147097,
23.95127854,
43.39883371,
67.31934835,
103.69453368,
175.01222224,
243.34921384,
319.90071113
],
[
129.875,
31.416667,
26.0631112,
41.67517586,
76.95504951,
120.76396292,
180.95011747,
277.53251763,
358.97836652,
446.50234312
],
[
129.875,
31.583333,
18.44678516,
31.84113646,
63.36712617,
100.97421728,
151.16825521,
233.38643766,
304.67828595,
382.61602847
],
[
129.875,
31.75,
17.70498931,
29.85284339,
56.84813867,
87.38486104,
128.39757407,
199.3499988,
264.52639307,
337.87031056
],
[
129.875,
31.916667,
18.92817954,
31.54880331,
56.40460808,
83.59833691,
120.76035323,
188.2979369,
252.68779118,
326.21564572
],
[
129.125,
32.083333,
9.51138447,
16.41020829,
32.04046485,
55.67948265,
94.97955331,
171.01803957,
241.23137193,
318.73698739
],
[
129.125,
32.25,
9.4255179,
16.32324917,
31.5449867,
53.14290762,
89.05729943,
163.52342934,
234.44972699,
312.84944340
],
[
129.125,
32.416667,
9.79270625,
17.23575205,
32.18972719,
51.23975002,
81.32821063,
144.07487549,
207.64995594,
280.59333605
],
[
129.125,
32.583333,
9.99866452,
17.866636,
32.86041756,
50.22231805,
75.93840778,
126.43177081,
178.75282166,
241.99776826
],
[
129.375,
32.083333,
12.50183062,
20.26408689,
38.78579176,
62.71572192,
100.2064497,
173.70575013,
242.84002512,
319.72848489
],
[
129.375,
32.25,
13.89095213,
22.8308922,
42.11352439,
66.23990021,
102.94804034,
174.72998179,
243.21914129,
319.86627331
],
[
129.375,
32.416667,
15.47200745,
26.19436015,
47.89499073,
73.11814807,
109.51814442,
178.83799297,
245.53577181,
321.03836706
],
[
129.375,
32.583333,
16.59385734,
29.51478099,
57.20768957,
87.00876724,
126.17119792,
194.33869404,
257.97139463,
330.46434791
],
[
129.625,
32.083333,
16.46560158,
26.79889011,
47.69908353,
72.21176008,
108.12423797,
177.49873111,
244.65694215,
320.56114060
],
[
129.625,
32.25,
19.06713789,
32.32097871,
57.65124162,
84.96645443,
121.88705822,
188.91035175,
253.06134717,
326.44674118
],
[
129.625,
32.416667,
23.05804886,
41.33524172,
77.26491496,
114.08222292,
159.53490713,
232.80179412,
297.32970745,
369.31999277
],
[
129.625,
32.583333,
26.87707198,
53.70727224,
110.48315277,
168.15455665,
235.12381712,
334.37233764,
416.62088605,
504.97984786
],
[
129.875,
32.083333,
21.98392278,
37.50358201,
67.11259075,
97.93564908,
137.5949819,
205.27222303,
267.76704884,
338.98051544
],
[
129.875,
32.25,
27.33750456,
49.39175147,
93.50678994,
137.76307091,
190.47397401,
271.71859493,
340.97706641,
416.81446066
],
[
129.875,
32.416667,
34.42017604,
66.85451274,
136.71318434,
206.67857766,
284.98335398,
397.44927112,
488.88339784,
586.12536694
],
[
129.875,
32.583333,
41.30541959,
81.56888663,
158.23568586,
228.61210477,
305.91519898,
417.06914105,
507.89614226,
604.51946723
],
[
129.125,
32.75,
9.95895206,
17.71398247,
32.17694571,
48.53985544,
71.76612007,
117.89891562,
167.70330301,
230.18544154
],
[
129.125,
32.916667,
9.67373825,
16.62987949,
29.51918473,
44.79358714,
66.6199845,
111.84438249,
162.36513325,
226.16267602
],
[
129.125,
33.083333,
9.18010623,
14.91808386,
26.36400414,
39.68884734,
60.52835911,
106.2169686,
158.41732133,
223.91234301
],
[
129.125,
33.25,
8.57833687,
13.04113827,
23.21766062,
35.92545677,
56.20532605,
102.95801971,
156.81380511,
223.24887532
],
[
129.375,
32.75,
16.2110388,
29.9622046,
62.35907661,
99.35164128,
147.24657513,
224.3142315,
291.15270643,
364.51629262
],
[
129.375,
32.916667,
14.89126879,
26.73131611,
51.69571937,
78.76851482,
113.31511354,
170.8572737,
223.74789253,
284.46492759
],
[
129.375,
33.083333,
12.6593298,
21.34161792,
38.24089278,
56.15433002,
80.13244831,
125.86519197,
173.81396744,
234.07075282
],
[
129.375,
33.25,
10.21080615,
17.27114173,
29.65206348,
44.25304507,
65.19974204,
109.39238136,
160.11206685,
224.67412551
],
[
129.625,
32.75,
27.20430446,
59.63478416,
138.77388413,
213.90631632,
294.61704202,
408.68266799,
500.95219707,
598.90273069
],
[
129.625,
32.916667,
23.26600853,
46.92459712,
99.15867291,
154.0819429,
219.44096412,
317.93990736,
399.99855046,
488.23858062
],
[
129.625,
33.083333,
18.25891407,
32.23827756,
58.4635847,
84.63090943,
116.83508891,
170.1612924,
219.65469988,
277.40738025
],
[
129.625,
33.25,
14.17411849,
23.05671948,
39.42695578,
56.88961456,
80.056499,
124.42129571,
171.63471776,
231.90078519
],
[
129.875,
32.75,
43.03992302,
84.36627634,
160.6183773,
230.47515531,
307.3924628,
418.27833181,
509.08749799,
605.77023784
],
[
129.875,
32.916667,
36.10465958,
72.53463871,
148.41047359,
220.23388404,
298.96862934,
411.4561023,
502.87189944,
600.01171659
],
[
129.875,
33.083333,
26.50699237,
48.69309282,
94.54203636,
142.13072912,
199.15081445,
286.03676813,
359.20998424,
438.61095570
],
[
129.875,
33.25,
18.81907192,
31.89332248,
55.91897938,
79.68400565,
109.4600087,
159.84867028,
207.91094358,
264.80190246
],
[
129.125,
33.416667,
8.00954166,
11.19572554,
20.43298,
32.93655538,
53.41522107,
101.65023406,
156.39412252,
223.12780057
],
[
129.125,
33.583333,
7.541445,
9.81164616,
18.85158057,
30.66032241,
51.80698231,
101.23079892,
156.30794169,
223.11336306
],
[
129.125,
33.75,
6.2783983,
8.16838451,
13.93890859,
27.56645297,
50.36793808,
101.04376904,
156.27980032,
223.10960674
],
[
129.125,
33.916667,
6.22315843,
8.09651579,
13.48200018,
27.19186789,
50.05653632,
100.93274677,
156.24405483,
223.09753439
],
[
129.375,
33.416667,
9.09081563,
14.41731353,
25.01006042,
37.69931464,
57.72768467,
103.6151497,
157.02008858,
223.33192355
],
[
129.375,
33.583333,
8.27746033,
12.06196492,
21.4915338,
33.8450248,
53.99141885,
101.78325366,
156.44219013,
223.17575629
],
[
129.375,
33.75,
7.64675382,
9.94865609,
19.16334062,
31.1004918,
52.0460513,
101.29049775,
156.34472155,
223.15850614
],
[
129.375,
33.916667,
6.30200162,
8.19909314,
14.12731869,
27.72818598,
50.51167769,
101.10510913,
156.31835293,
223.15257688
],
[
129.625,
33.416667,
10.88444751,
17.73542113,
30.00300224,
44.49936078,
65.07825764,
108.72394989,
159.44394115,
224.24698970
],
[
129.625,
33.583333,
9.16802279,
14.5612945,
25.09835174,
37.76805228,
57.8047273,
103.65786195,
157.01435256,
223.30212399
],
[
129.625,
33.75,
8.25599861,
11.99677013,
21.42486362,
33.90101162,
54.33376543,
102.20103548,
156.61581938,
223.20926588
],
[
129.625,
33.916667,
7.83376175,
10.5487567,
19.46043086,
31.4620855,
52.54262488,
101.71864738,
156.50704048,
223.18303059
],
[
129.875,
33.416667,
14.14355325,
22.49663771,
38.18093524,
54.93004722,
77.58204192,
121.24802848,
168.58768133,
229.38702306
],
[
129.875,
33.583333,
10.91525211,
17.48431553,
29.29794533,
43.33945832,
64.00406343,
108.4663101,
159.47637671,
224.11849479
],
[
129.875,
33.75,
9.247624,
14.61087217,
24.81350763,
37.29126216,
57.56680167,
104.55420869,
157.86921088,
223.61097104
],
[
129.875,
33.916667,
8.45979788,
12.53571607,
21.73954791,
34.00258504,
54.59535814,
103.1200015,
157.2662464,
223.35038366
],
[
129.125,
34.083333,
6.12861359,
7.97351012,
12.62261708,
26.43613792,
49.48923195,
100.64748663,
156.1320119,
223.05672624
],
[
129.125,
34.25,
6.03171107,
7.84743702,
11.60638909,
25.13481501,
48.32903548,
99.90627777,
155.75880728,
222.88255677
],
[
129.125,
34.416667,
5.87119411,
7.63859965,
9.97498269,
22.61916502,
45.60448331,
97.89083868,
154.44330036,
222.09929907
],
[
129.125,
34.583333,
5.67440572,
7.38257204,
9.6406451,
19.17162836,
39.62017497,
91.21189821,
149.14444474,
218.28141243
],
[
129.375,
34.083333,
6.28022512,
8.17076127,
13.93239888,
27.5081303,
50.32420364,
101.05368423,
156.30618407,
223.15014170
],
[
129.375,
34.25,
6.19224778,
8.0563001,
13.20323554,
26.93297763,
49.89534368,
100.90779605,
156.26382259,
223.14010024
],
[
129.375,
34.416667,
6.05914627,
7.88313104,
11.93533948,
25.82044804,
49.08304946,
100.50624653,
156.10775175,
223.08239667
],
[
129.375,
34.583333,
5.87704211,
7.64620807,
9.98491826,
23.57461346,
47.22808909,
99.40394539,
155.54476383,
222.81721432
],
[
129.625,
34.083333,
6.63381452,
8.63079167,
15.95706174,
28.70395972,
51.29731205,
101.4502229,
156.4209298,
223.15556388
],
[
129.625,
34.25,
6.57676006,
8.55656211,
15.587804,
28.2454006,
50.76235197,
101.18106512,
156.32263848,
223.12635846
],
[
129.625,
34.416667,
6.45420084,
8.39710889,
14.74273847,
27.15236454,
49.58928091,
100.60726443,
156.10400752,
223.04585086
],
[
129.625,
34.583333,
5.97416919,
7.77257331,
10.99264904,
24.39364144,
47.50351413,
99.24861874,
155.28907237,
222.58031509
],
[
129.875,
34.083333,
6.91535237,
8.99708086,
17.26212887,
29.85103775,
52.49234683,
102.23990036,
156.6760294,
222.99021983
],
[
129.875,
34.25,
6.88514787,
8.9577839,
17.02267627,
29.43862805,
51.76874159,
101.42180667,
156.12299036,
222.70137483
],
[
129.875,
34.416667,
6.77439091,
8.81368578,
16.27774046,
28.19192946,
49.87674393,
99.92678763,
155.25198056,
222.24999733
],
[
129.875,
34.583333,
6.58810615,
8.57132371,
15.00792895,
25.78860972,
45.75368616,
94.77001207,
150.85017622,
218.95328121
],
[
129.125,
34.75,
5.44227845,
7.08056751,
9.24626785,
15.96614187,
31.61023938,
73.71178573,
126.7436754,
195.51261038
],
[
129.125,
34.916667,
5.18011502,
6.73948502,
8.80086004,
12.32064888,
23.76007237,
51.94221107,
86.18337777,
131.78859662
],
[
129.125,
35.083333,
4.89492467,
6.36844382,
8.31633019,
9.78984934,
17.42602869,
34.73001267,
54.60173925,
79.94613197
],
[
129.125,
35.25,
4.59122389,
5.97331999,
7.80035167,
9.18244777,
12.92466755,
23.48993526,
34.93425136,
49.37311364
],
[
129.375,
34.75,
5.6527392,
7.35438326,
9.60383435,
19.48299536,
42.44953662,
96.02288431,
153.38550567,
221.54348059
],
[
129.375,
34.916667,
5.39969823,
7.02516936,
9.17392532,
15.63149632,
32.61653238,
83.18978523,
143.22623803,
214.24909978
],
[
129.375,
35.083333,
5.12526311,
6.66812104,
8.70766828,
11.63969396,
22.86236757,
53.68541878,
97.35718743,
161.28242349
],
[
129.375,
35.25,
4.83241534,
6.2871173,
8.21012871,
9.66483067,
16.57430032,
33.01446135,
53.20940097,
80.90792122
],
[
129.625,
34.75,
5.77602826,
7.51478603,
9.81329877,
20.97208838,
42.65197778,
93.43208594,
150.19942869,
218.65619964
],
[
129.625,
34.916667,
5.5437582,
7.21259571,
9.41867889,
17.48663476,
35.36334438,
78.27781269,
127.74702758,
190.15898480
],
[
129.625,
35.083333,
5.28512909,
6.87611148,
8.97927579,
13.78066716,
26.94761438,
60.63300621,
101.30750196,
154.87462000
],
[
129.125,
35.416667,
4.27612755,
5.5633702,
7.26501244,
8.55225509,
9.83949775,
17.0077942,
24.07212948,
33.00593709
],
[
129.375,
35.416667,
4.52479657,
5.88689606,
7.68749364,
9.04959313,
12.11742284,
22.02589612,
32.92684366,
46.94099001
],
[
130.125,
27.75,
43.23837668,
68.22160888,
109.62540747,
147.81429827,
192.4187518,
261.85404984,
322.42103679,
389.91265410
],
[
130.125,
27.916667,
42.62852705,
65.65563369,
104.06889521,
139.86260608,
182.18108868,
248.53264702,
306.52371301,
371.24969063
],
[
130.125,
28.083333,
41.55058035,
63.07497669,
99.12698999,
133.19874918,
173.64371942,
237.36097179,
293.29391581,
355.67968067
],
[
130.125,
28.25,
40.63839373,
60.82476665,
95.03047742,
127.51579872,
166.40441971,
227.98286198,
281.97344985,
342.37559478
],
[
130.125,
28.416667,
39.9306977,
59.1102789,
91.68747497,
122.93169672,
160.42107187,
219.95947399,
272.48337938,
331.05381565
],
[
130.125,
28.583333,
39.66948984,
58.33906163,
90.02518381,
120.54590892,
157.22900452,
215.37853871,
266.45373656,
323.43090773
],
[
130.375,
28.083333,
44.02811247,
69.45975119,
111.6973977,
150.42576593,
195.63903369,
265.88781095,
327.06882439,
395.18214166
],
[
130.375,
28.25,
43.29191055,
66.67236899,
105.64168358,
141.85997281,
184.55418777,
251.44376696,
309.91210171,
375.13153727
],
[
130.375,
28.416667,
42.25030999,
64.03165786,
100.4564983,
134.84561666,
175.59024308,
239.70348804,
296.05614478,
358.87903519
],
[
130.375,
28.583333,
41.27402098,
61.70328951,
96.21984796,
128.94406362,
168.10494188,
230.0904468,
284.44818066,
345.23579056
],
[
130.625,
28.25,
45.27430523,
73.50642644,
120.69750169,
163.62268285,
213.07187892,
288.79020002,
354.22552779,
426.78888458
],
[
130.625,
28.416667,
44.49374929,
70.26668866,
113.15382453,
152.40768486,
198.1162355,
269.1275868,
330.88267641,
399.56514971
],
[
130.625,
28.583333,
43.42337789,
67.28849981,
106.87101426,
143.55643258,
186.67344975,
254.16238109,
313.14076735,
378.87516273
],
[
130.875,
28.416667,
45.58413714,
76.81272573,
130.46370213,
179.03610594,
234.22952471,
317.37708095,
388.40231844,
466.49554984
],
[
130.875,
28.583333,
45.46123626,
74.01274566,
121.80758451,
165.21962697,
215.15519243,
291.57130197,
357.49423563,
430.61762330
],
[
130.125,
28.75,
39.827897,
58.844462,
91.94113514,
124.14941451,
162.86995787,
223.97247874,
277.21792109,
336.29257218
],
[
130.125,
28.916667,
40.19563327,
60.16140219,
97.14616451,
135.2028404,
182.85601665,
259.84287707,
327.55837467,
402.42533657
],
[
130.125,
29.083333,
40.47392853,
61.6021308,
102.96357068,
147.97502883,
205.47739764,
296.70348013,
374.75362136,
459.44136959
],
[
130.125,
29.25,
40.45179464,
62.2932114,
105.47550073,
151.87408882,
210.09847147,
301.30321467,
379.15132798,
463.72063532
],
[
130.375,
28.75,
40.55012803,
59.89846301,
92.8725806,
124.36139386,
162.12525928,
222.05734682,
274.84123665,
333.78520175
],
[
130.375,
28.916667,
40.16104827,
58.97589143,
90.90567521,
121.55567052,
158.3543435,
216.74159255,
268.09378884,
325.38725620
],
[
130.375,
29.083333,
40.12269815,
59.05558865,
91.65639063,
123.09059888,
160.69257449,
219.93193172,
271.76672068,
329.21952301
],
[
130.375,
29.25,
40.26283166,
59.95618097,
95.81996722,
131.91832338,
176.50556392,
247.79746312,
310.06632587,
378.90604911
],
[
130.625,
28.75,
42.65480209,
64.72920373,
101.63215515,
136.34573462,
177.45132739,
242.131831,
298.84588812,
362.20103125
],
[
130.625,
28.916667,
41.6328247,
62.35763633,
97.2799458,
130.34227039,
169.84879389,
232.36392747,
287.18128655,
348.44094663
],
[
130.625,
29.083333,
40.75170704,
60.36932055,
93.74115566,
125.54248476,
163.66101186,
224.11726505,
277.2632355,
336.68878091
],
[
130.625,
29.25,
40.18044537,
59.0985813,
91.22352061,
122.04493803,
159.03385108,
217.75277239,
269.44405218,
327.11255606
],
[
130.875,
28.75,
44.73038812,
70.89882221,
114.44764706,
154.25714124,
200.50477952,
272.26845511,
334.59776153,
403.94817008
],
[
130.875,
28.916667,
43.67787837,
67.89736611,
108.067293,
145.23611686,
188.7982377,
256.90941456,
316.40982583,
382.74231476
],
[
130.875,
29.083333,
42.82320494,
65.23502902,
102.66524921,
137.73738527,
179.22297141,
244.49249017,
301.61259954,
365.46753884
],
[
130.875,
29.25,
41.68228046,
62.70196385,
98.03771686,
131.47255636,
171.31387847,
234.26132764,
289.48122548,
351.14803685
],
[
130.125,
29.416667,
39.95145966,
61.78723909,
104.79403474,
150.79029095,
208.62478663,
299.47713866,
377.22212522,
461.70220858
],
[
130.125,
29.583333,
39.12664726,
60.42736873,
102.76969947,
148.24018785,
205.68164649,
296.46673603,
374.22134472,
458.71260382
],
[
130.125,
29.75,
38.39529061,
59.12992444,
100.56046734,
145.57445127,
202.67872729,
293.55321245,
371.47086908,
456.20733206
],
[
130.125,
29.916667,
38.16900303,
58.56102505,
99.38518248,
144.0308875,
200.9455688,
291.91506958,
369.9536558,
454.84552764
],
[
130.375,
29.416667,
40.36316822,
61.19846136,
101.53580053,
145.31061349,
201.41456915,
291.57610918,
369.11867229,
453.52435620
],
[
130.375,
29.583333,
40.23085853,
61.97301119,
104.99614341,
151.36557795,
209.67242962,
300.97163655,
378.82480862,
463.30431683
],
[
130.375,
29.75,
40.78303571,
62.44381628,
105.28422081,
151.32170354,
209.2314151,
300.12074348,
377.82798576,
462.22524518
],
[
130.375,
29.916667,
40.3212582,
61.643803,
103.68852707,
149.01387811,
206.44607818,
297.20939058,
374.96825582,
459.47409287
],
[
130.625,
29.416667,
39.9141632,
58.76596271,
90.98593972,
121.97624703,
159.04186338,
217.53967341,
268.73826487,
325.62732320
],
[
130.625,
29.583333,
39.82669937,
59.30689091,
94.13881077,
128.61457564,
170.57274339,
236.99331166,
294.80471076,
358.68097404
],
[
130.625,
29.75,
41.02684809,
61.32280097,
100.05973122,
141.88994632,
195.77526341,
283.44201873,
359.63006316,
443.04457372
],
[
130.625,
29.916667,
41.43811361,
62.64229784,
104.45444869,
149.96749419,
207.94594103,
299.31532089,
377.40038478,
462.13882560
],
[
130.875,
29.416667,
40.6038903,
60.4495222,
94.16713448,
126.25581443,
164.6928785,
225.60098587,
279.05060863,
338.85643335
],
[
130.875,
29.583333,
40.5065911,
59.41475713,
91.60129545,
122.49645114,
159.62094718,
218.65230228,
270.68045538,
328.71808588
],
[
130.875,
29.75,
40.6490125,
59.1999601,
90.87335929,
121.31410652,
157.88807424,
215.88831424,
266.81425598,
323.56970552
],
[
130.875,
29.916667,
41.02432531,
59.81021194,
92.59401227,
124.29451134,
162.35160273,
222.40527934,
274.85523148,
333.03144583
],
[
130.125,
30.083333,
37.61906654,
57.8932525,
98.5772878,
143.08813556,
199.82554757,
290.4691743,
368.18916946,
452.74955649
],
[
130.125,
30.25,
37.28488986,
57.80827527,
99.76324994,
146.55678853,
206.22713144,
299.95282799,
379.51780258,
465.55700305
],
[
130.125,
30.416667,
37.10798149,
58.1487793,
102.55909343,
152.98947944,
217.15054532,
316.46077965,
399.6320363,
489.04446661
],
[
130.125,
30.583333,
36.94662362,
58.27363043,
103.3723601,
154.2227208,
218.43374361,
317.53721113,
400.48371929,
489.64886451
],
[
130.375,
30.083333,
39.79280166,
60.65662436,
101.79078614,
146.38574576,
203.25017069,
293.96316372,
371.79149954,
456.39673967
],
[
130.375,
30.25,
39.45574839,
59.98415986,
100.38928797,
144.29206512,
200.56338112,
291.17172657,
369.10615987,
453.91683584
],
[
130.375,
30.416667,
39.35861931,
59.91289418,
100.12736389,
143.64377805,
199.49345912,
289.84414616,
367.7835246,
452.71937217
],
[
130.375,
30.583333,
39.38177462,
60.27630294,
101.2719778,
145.42171459,
201.75389834,
292.1429983,
369.89572563,
454.53253920
],
[
130.625,
30.083333,
41.80044637,
63.42626126,
105.84199674,
151.4078878,
208.98846958,
299.76053618,
377.49807057,
461.93787413
],
[
130.625,
30.25,
42.17174956,
63.92029927,
106.11089304,
151.00659023,
207.77083572,
297.78980834,
375.22853403,
459.53194699
],
[
130.625,
30.416667,
42.55495746,
64.31867729,
106.1626614,
150.37176312,
206.32396175,
295.56932897,
372.7013992,
456.93262210
],
[
130.625,
30.583333,
42.79735708,
64.55530824,
106.07325463,
149.69744986,
204.95268678,
293.55308162,
370.3853464,
454.45135229
],
[
130.875,
30.083333,
41.84141346,
61.37612692,
96.6447091,
132.12723879,
176.26154503,
247.88690739,
311.24712287,
381.80241855
],
[
130.875,
30.25,
43.19622449,
63.93150966,
102.674647,
143.17675808,
194.54117999,
278.26752037,
351.87859039,
432.99441500
],
[
130.875,
30.416667,
44.78561257,
66.79332981,
108.89616641,
153.33066064,
209.12551731,
297.77450254,
374.41277449,
458.16817517
],
[
130.875,
30.583333,
45.99184465,
68.87199493,
112.63389947,
157.73601605,
213.44955072,
301.22933019,
377.06881811,
460.09295308
],
[
130.125,
30.75,
36.63161377,
58.05879102,
103.2659211,
154.17966006,
218.44376502,
317.5738636,
400.49638859,
489.60168205
],
[
130.125,
30.916667,
36.0932734,
57.59134224,
102.92368543,
154.00957662,
218.41404685,
317.64447034,
400.63817642,
489.83706660
],
[
130.125,
31.083333,
35.18768174,
56.64907108,
102.07803005,
153.46219903,
218.13205417,
317.53611732,
400.59286437,
489.83487578
],
[
130.125,
31.25,
33.3295848,
54.64101631,
100.36885834,
152.41905474,
217.60510274,
317.29997006,
400.39749711,
489.59051099
],
[
130.375,
30.75,
39.36279973,
60.78875942,
103.45740242,
149.93764192,
209.67864331,
304.45907945,
385.39821004,
473.05680966
],
[
130.375,
30.916667,
39.16204207,
61.10463729,
105.63803088,
154.98630983,
218.03481717,
316.67985307,
399.66202298,
488.95997419
],
[
130.375,
31.083333,
42.22273532,
64.82298243,
108.9141742,
157.67329453,
220.09880612,
318.17494625,
400.84136459,
489.87296828
],
[
130.375,
31.25,
42.1291799,
65.14600985,
109.64715782,
158.52029898,
220.90259079,
318.82110426,
401.46052524,
490.52131633
],
[
130.625,
30.75,
42.8472248,
64.68689375,
106.08258965,
149.35095408,
204.1451175,
292.36710433,
369.07140086,
453.11140836
],
[
130.625,
30.916667,
46.19005871,
68.5509756,
109.33652776,
151.44358192,
205.03315358,
292.35026683,
368.85881395,
452.93192728
],
[
130.625,
31.083333,
46.57128236,
69.59276166,
111.17024961,
153.47022116,
206.93409782,
293.90429036,
370.21202337,
454.09791581
],
[
130.625,
31.25,
47.79436501,
71.69371047,
114.5833382,
157.97295582,
212.70512268,
301.13795302,
378.37565879,
463.01654394
],
[
130.875,
30.75,
49.87723343,
73.86929415,
117.24626972,
161.17359953,
215.57140586,
302.01413802,
377.15750207,
459.71935307
],
[
130.875,
30.916667,
51.11446453,
75.89848368,
119.6927947,
163.28834771,
216.83379972,
302.34004814,
377.07263103,
459.48122064
],
[
130.875,
31.083333,
52.77722084,
78.29754164,
122.78755327,
166.02305648,
218.67289168,
303.01105337,
377.090315,
459.11671700
],
[
130.875,
31.25,
53.58213689,
80.04281246,
125.8303592,
169.3681,
221.76024866,
305.11611309,
378.35854206,
459.73609995
],
[
130.125,
31.416667,
31.59040113,
52.30101034,
98.08842937,
150.73418748,
216.59529593,
316.75632682,
400.04383311,
489.37616251
],
[
130.125,
31.583333,
29.70040871,
49.19849928,
93.83706416,
146.86090764,
213.60713936,
314.67313914,
398.44362757,
488.15142910
],
[
130.125,
31.75,
28.40413258,
46.48944706,
87.40868219,
138.20629449,
204.66710448,
306.55619114,
390.94667507,
481.03705445
],
[
130.125,
31.916667,
28.91429605,
47.48893605,
86.47872719,
130.79987299,
188.49074826,
280.56993098,
359.11058901,
444.13567790
],
[
130.375,
31.416667,
42.58248517,
65.98158347,
110.80684063,
159.8618557,
222.66092278,
320.91232402,
403.62616965,
492.56884845
],
[
130.375,
31.583333,
42.24054117,
65.81230082,
110.95549385,
160.30440069,
223.47506559,
322.24314239,
405.29969026,
494.51365537
],
[
130.375,
31.75,
41.70746956,
65.08709357,
110.04166435,
159.32424999,
222.05346378,
320.0022407,
402.55237506,
491.45707981
],
[
130.375,
31.916667,
41.99709082,
65.59407446,
111.18780746,
161.10518012,
224.60207869,
323.47832089,
406.58265103,
495.87004358
],
[
130.625,
31.416667,
47.89924288,
72.79974838,
117.59752848,
163.30863514,
221.04411935,
314.32078178,
394.88289629,
482.53071024
],
[
130.625,
31.583333,
47.94681525,
73.81648698,
121.10958728,
170.22226672,
232.79749991,
333.4598545,
420.57297549,
516.09522544
],
[
130.625,
31.75,
47.64883268,
73.61783397,
120.82788276,
169.25779845,
230.13716755,
326.83276502,
409.64644741,
499.33276722
],
[
130.625,
31.916667,
47.09989158,
72.65649088,
119.29233432,
167.21163001,
227.18437662,
322.12984238,
403.43779361,
491.64662195
],
[
130.875,
31.416667,
53.84372921,
81.35570824,
128.56409503,
172.97549235,
225.70939468,
308.68197678,
381.3636744,
462.22976958
],
[
130.875,
31.583333,
54.09007784,
82.26491644,
130.45111798,
175.53568194,
228.67647604,
311.69815149,
384.20715822,
464.76288210
],
[
130.875,
31.75,
53.73749792,
82.14120559,
130.64361141,
175.88469149,
229.12373798,
312.20138886,
384.71641491,
465.22342631
],
[
130.875,
31.916667,
52.90098041,
81.16377976,
129.65505664,
175.39155185,
229.86365826,
315.60412754,
390.59930553,
473.53223772
],
[
130.125,
32.083333,
30.75394238,
55.20432706,
111.77299912,
174.50943824,
247.90773144,
354.80792607,
442.04332929,
535.02278046
],
[
130.125,
32.25,
36.07260508,
72.64101542,
149.91248902,
222.04936284,
300.72390431,
413.16751011,
504.6719417,
601.95865907
],
[
130.125,
32.416667,
44.60393911,
85.14896824,
160.9139755,
230.572019,
307.3647325,
418.13157274,
508.85698642,
605.45911073
],
[
130.125,
32.583333,
48.64706011,
88.73669469,
163.03484652,
231.82701043,
308.10371035,
418.46235404,
508.98289816,
605.40662255
],
[
130.375,
32.083333,
44.14299524,
70.01286398,
121.33913537,
176.12206213,
244.18673765,
351.48311294,
444.88105835,
549.16758194
],
[
130.375,
32.25,
42.54825201,
73.98948051,
139.21031504,
205.40982208,
281.08644691,
391.49485638,
481.80492749,
578.23072281
],
[
130.375,
32.416667,
45.31344625,
82.49982566,
156.90760445,
227.15033786,
304.89338081,
416.97882069,
508.66214438,
606.24196013
],
[
130.375,
32.583333,
48.44945486,
88.23371839,
162.90613062,
232.08587844,
308.64420198,
419.23550063,
509.90047468,
606.43887786
],
[
130.625,
32.083333,
46.9010209,
72.0548557,
118.36820261,
166.59837518,
227.3975506,
323.40415614,
405.15470367,
493.53429251
],
[
130.625,
32.25,
47.69970266,
73.16146437,
119.87403294,
168.74235289,
230.15060916,
326.60999235,
408.58649836,
497.20408439
],
[
130.625,
32.416667,
50.17570947,
78.47204951,
132.73809428,
189.11518899,
257.3078098,
361.43168894,
449.41633053,
545.04358365
],
[
130.625,
32.583333,
48.36710549,
82.62489047,
152.52478285,
221.02616243,
298.59521625,
412.18209034,
506.18316174,
607.36105766
],
[
130.875,
32.083333,
51.89532317,
79.66088594,
128.3174265,
175.53090393,
233.09011751,
324.58612536,
404.12569017,
491.31494437
],
[
130.875,
32.25,
50.83851193,
77.94192398,
125.99071384,
173.59286333,
232.24688067,
325.26653682,
405.56291676,
493.15359789
],
[
130.875,
32.416667,
50.79146877,
77.30486289,
124.72546259,
172.73223258,
232.58656478,
327.31930026,
408.44511644,
496.43637227
],
[
130.875,
32.583333,
53.02625505,
81.64204138,
134.27292119,
187.86824265,
253.51087417,
355.52668652,
442.66494792,
538.12643737
],
[
130.125,
32.75,
49.13774253,
89.06895438,
163.12233505,
231.8284489,
308.11401754,
418.60124841,
509.29734106,
605.94552865
],
[
130.125,
32.916667,
45.74641671,
85.9330951,
161.08335043,
230.53481312,
307.26021627,
418.01356792,
508.74024429,
605.34646176
],
[
130.125,
33.083333,
35.91113724,
69.79012074,
142.63909305,
213.78622736,
292.51763058,
405.21399074,
496.78076549,
594.15465376
],
[
130.125,
33.25,
25.43137844,
45.52121619,
86.2107318,
128.02496605,
178.33973642,
256.07505235,
322.42589105,
395.03986450
],
[
130.375,
32.75,
50.17106662,
89.80645357,
163.72877668,
232.3307489,
308.50803755,
418.88695586,
509.55494281,
606.20745544
],
[
130.375,
32.916667,
49.45221618,
89.29964936,
163.3274359,
231.94430741,
308.12884128,
418.50394728,
509.1307177,
605.72195242
],
[
130.375,
33.083333,
44.20608648,
84.33153812,
160.13834798,
229.94699137,
306.84855407,
417.70196217,
508.45026534,
605.06620217
],
[
130.375,
33.25,
32.4987948,
62.32043373,
128.92064825,
197.8142562,
275.8521527,
388.25724352,
479.66004677,
577.00962560
],
[
130.625,
32.75,
51.4611657,
90.18789299,
164.57184537,
234.35897344,
311.88266038,
423.89697099,
515.6616195,
613.27514914
],
[
130.625,
32.916667,
51.10477813,
90.49965737,
164.68106077,
233.51861896,
309.82816927,
420.17875618,
510.73406691,
607.18000643
],
[
130.625,
33.083333,
49.27632368,
89.06794316,
163.67325531,
232.62526468,
308.93599199,
419.22285453,
509.67312803,
606.00150457
],
[
130.625,
33.25,
39.55837977,
77.49495444,
154.61063943,
226.72095835,
305.94850525,
419.85518292,
513.15105813,
612.53416739
],
[
130.875,
32.75,
56.3873122,
91.1828177,
160.13173205,
229.50026935,
308.87478032,
425.26952749,
521.4782123,
624.48501335
],
[
130.875,
32.916667,
58.74181998,
96.09325913,
167.38491569,
235.71477378,
312.46988376,
424.07107643,
515.81292538,
613.56957000
],
[
130.875,
33.083333,
53.44846004,
92.09733036,
165.50286305,
234.08518679,
310.26066598,
420.44494064,
510.84112401,
607.09479971
],
[
130.875,
33.25,
47.29102894,
86.59787123,
162.48988344,
232.91441939,
310.75171188,
423.08609784,
515.12818058,
613.06979614
],
[
130.125,
33.416667,
18.07354294,
29.58299396,
51.31083556,
73.44513456,
101.63815925,
150.71739589,
198.30212326,
255.53298693
],
[
130.125,
33.583333,
13.66088334,
21.13987794,
35.89582907,
51.69141882,
74.43176132,
120.27495427,
170.48105523,
233.15377387
],
[
130.125,
33.75,
10.67030642,
17.09683034,
28.61887839,
42.37865574,
63.5213814,
111.08670417,
165.22341127,
230.90065198
],
[
130.125,
33.916667,
9.31029581,
14.77859823,
25.13627358,
37.84196019,
58.72969778,
107.67186141,
162.46623297,
228.52179878
],
[
130.375,
33.416667,
22.73626385,
39.02736756,
70.63201481,
102.67378008,
141.88031792,
205.22089394,
261.62567116,
325.28752610
],
[
130.375,
33.583333,
16.54988935,
26.29460679,
44.45857436,
63.78717431,
90.36758124,
143.23369326,
200.77799631,
274.13176082
],
[
130.375,
33.75,
13.03436003,
19.79613304,
33.9635465,
49.7182243,
73.99736901,
126.16765277,
185.67957375,
260.07945881
],
[
130.375,
33.916667,
10.87024757,
17.53176937,
29.78939647,
45.05920744,
67.95496185,
118.42888604,
175.79457271,
247.31441830
],
[
130.625,
33.416667,
27.93843205,
50.29670162,
96.96313288,
145.44151927,
203.77713515,
293.10843954,
368.69011013,
450.72722661
],
[
130.625,
33.583333,
19.51178792,
32.22821203,
55.66913267,
79.77941039,
111.892174,
171.07002075,
232.37902947,
309.45433787
],
[
130.625,
33.75,
15.57657153,
24.15397508,
40.24023181,
58.74575748,
86.22198575,
145.73317094,
212.63471028,
295.86934057
],
[
130.625,
33.916667,
13.57939808,
21.62405765,
38.45044978,
57.31584111,
83.63964618,
134.81434672,
188.87282422,
255.75022975
],
[
130.875,
33.416667,
35.30292275,
63.61067914,
126.51734792,
193.03821885,
269.78154149,
381.12749682,
471.95627334,
568.62841392
],
[
130.875,
33.583333,
25.88365383,
41.18082378,
69.84536863,
98.71638207,
134.54115344,
193.53987534,
247.3707972,
308.76166903
],
[
130.875,
33.75,
18.13453068,
28.51988748,
47.40556756,
66.82963853,
92.37881486,
139.40290578,
188.00998071,
248.46617728
],
[
130.875,
33.916667,
16.61511706,
27.79306611,
50.58830759,
75.14234623,
106.81212271,
161.62062167,
213.5400414,
273.80373797
],
[
130.125,
34.083333,
8.68020996,
13.2146476,
23.02493627,
35.75271599,
56.93521542,
105.78602157,
159.71151412,
225.36415717
],
[
130.125,
34.25,
7.43456788,
9.67259582,
19.28583119,
32.46432082,
54.34752841,
103.20487791,
157.125877,
223.19363797
],
[
130.125,
34.416667,
7.31046238,
9.51113084,
18.34172738,
29.78409835,
49.55134375,
95.81049568,
149.78430688,
217.31645783
],
[
130.375,
34.083333,
9.7024103,
16.33099599,
28.91797665,
44.83438485,
68.67951267,
118.52032137,
171.5460626,
235.67712729
],
[
130.375,
34.25,
9.21246736,
15.22513179,
27.69990986,
43.19827798,
66.35238725,
113.37656596,
163.84156154,
226.53194465
],
[
130.375,
34.416667,
8.22268615,
12.24783315,
24.0545175,
37.3741036,
56.49302013,
94.57709334,
135.88252124,
188.81355321
],
[
130.625,
34.083333,
12.40405233,
21.52150885,
44.7526276,
75.06241026,
118.37065023,
191.85523398,
256.35286041,
327.12899768
],
[
130.625,
34.25,
11.26733248,
20.8265045,
47.35133682,
84.0180039,
136.44047503,
222.19554992,
295.04256522,
373.52283129
],
[
130.625,
34.416667,
9.42578529,
18.14101623,
38.50401707,
60.75341704,
88.94579591,
136.19575998,
180.26711859,
232.06629884
],
[
130.625,
34.583333,
9.07383168,
15.47104553,
28.75665673,
43.00715145,
61.63713144,
96.02149992,
131.8178579,
178.18929263
],
[
130.875,
34.083333,
16.16742115,
31.68875034,
76.31445377,
130.1390958,
198.04761265,
301.29174672,
386.64470542,
477.62350239
],
[
130.875,
34.25,
15.75912487,
34.90531541,
97.32500137,
166.39802943,
244.41864678,
357.72898633,
451.6030661,
553.39451303
],
[
130.875,
34.416667,
13.12410666,
29.47117164,
69.40939036,
115.87898312,
176.16764179,
271.88075086,
352.85867408,
440.00543812
],
[
130.875,
34.583333,
11.43461299,
22.61827827,
44.73866843,
67.43556697,
95.70418184,
142.35500069,
185.40929397,
235.58435465
],
[
130.625,
34.75,
8.4427292,
12.6483306,
22.44382575,
33.10450389,
47.82034609,
77.20529215,
110.97883784,
158.65304209
],
[
130.875,
34.75,
9.71829872,
17.32723584,
31.09269582,
45.58773094,
64.20643726,
97.77109486,
132.38706254,
177.28533106
],
[
130.875,
34.916667,
8.82842305,
13.76599827,
23.83940768,
34.63345086,
49.18709399,
78.0536224,
111.03947111,
158.14619541
],
[
130.875,
35.083333,
7.97069923,
10.95129018,
19.10369822,
28.13956104,
40.71679623,
67.8501481,
101.91200849,
152.45732433
],
[
130.875,
35.25,
7.19784612,
9.36461371,
16.262129,
23.83474127,
35.42666292,
62.123411,
98.28942596,
151.06296161
],
[
131.125,
28.916667,
45.52211787,
74.5821454,
123.39890432,
167.64447677,
218.39909767,
295.95769375,
362.74912398,
436.69150442
],
[
131.125,
29.083333,
44.8306049,
71.4898423,
115.83452381,
156.28735326,
203.23485367,
275.75210204,
338.71383692,
408.80676235
],
[
131.125,
29.25,
43.72553142,
68.3549641,
109.17859407,
146.87069243,
190.93814925,
259.66946546,
319.70287879,
386.67215931
],
[
131.125,
29.416667,
42.67733187,
65.4583611,
103.45603358,
138.93180649,
180.861171,
246.71967828,
304.29991671,
368.61340072
],
[
131.125,
29.583333,
42.12064813,
63.24294005,
98.74026641,
132.39893696,
172.49539502,
235.83306655,
291.43973224,
353.50174866
],
[
131.125,
29.75,
41.49431134,
61.30049272,
94.92625501,
126.96762113,
165.44351038,
226.57719045,
280.28740358,
340.45470213
],
[
131.125,
29.916667,
41.17888798,
60.08688787,
92.30924645,
123.06276116,
159.96378416,
218.78154046,
270.8046055,
328.99546454
],
[
131.375,
29.583333,
44.08880659,
68.8220436,
110.02111188,
148.11786012,
192.66964116,
262.07347684,
322.6365737,
390.13546949
],
[
131.375,
29.75,
42.98970914,
65.94434456,
104.12711053,
139.73474129,
181.91942896,
248.23045126,
306.26913953,
371.08606875
],
[
131.375,
29.916667,
42.2790445,
63.63529087,
99.27020822,
132.91757171,
172.91955527,
236.20303085,
291.92812475,
354.25160870
],
[
131.125,
30.083333,
41.73828722,
60.297525,
91.9238177,
121.99958167,
157.91645793,
214.73276328,
264.62708256,
320.44518912
],
[
131.125,
30.25,
43.48384829,
62.65138564,
95.1758875,
125.91734129,
162.20970541,
218.69170664,
267.73052061,
321.91550429
],
[
131.125,
30.416667,
45.76128893,
66.16417344,
100.91547317,
133.75106532,
172.02335453,
230.6858707,
280.59335633,
335.37188934
],
[
131.125,
30.583333,
50.46294088,
72.56954514,
110.22690674,
146.30002521,
188.98470189,
255.51083667,
313.08561937,
376.80458560
],
[
131.375,
30.083333,
42.46184047,
62.73996609,
96.80857886,
128.97656313,
167.34234299,
227.94448732,
281.08041602,
340.64046872
],
[
131.375,
30.25,
43.97457466,
64.77243076,
99.59968794,
132.48924358,
171.31007959,
232.08167036,
284.86286653,
343.46993516
],
[
131.375,
30.416667,
46.48194989,
68.38126298,
105.09574207,
139.39225749,
179.71915644,
242.10104714,
295.80952659,
354.85791097
],
[
131.375,
30.583333,
52.38112171,
75.3104631,
112.9705111,
147.99448159,
188.98217111,
252.21687946,
306.32575502,
365.60105095
],
[
131.625,
30.25,
40.08421245,
60.98887928,
95.86928577,
128.178342,
166.07865326,
225.05229198,
276.34879497,
333.49584317
],
[
131.625,
30.416667,
45.7990971,
67.55132377,
103.31200712,
136.33099489,
175.01428162,
235.24991396,
287.58639138,
345.61717217
],
[
131.625,
30.583333,
49.90723465,
74.07600642,
113.19594182,
149.09835971,
191.1461133,
256.69634745,
313.78607262,
377.12550521
],
[
131.125,
30.75,
52.94886456,
76.9629651,
118.59475904,
158.90741261,
207.56230991,
284.27985624,
351.5782742,
426.43031174
],
[
131.125,
30.916667,
55.72876265,
81.9458674,
127.80540944,
172.08163253,
225.32164457,
309.04391748,
381.8873511,
462.48506316
],
[
131.125,
31.083333,
58.01972248,
86.74208784,
136.0543009,
182.13706777,
236.11955752,
319.5268079,
391.83044266,
471.69323731
],
[
131.125,
31.25,
59.9849803,
90.95589598,
143.50341216,
191.38688414,
246.31807732,
329.7149934,
401.142595,
479.92799194
],
[
131.375,
30.75,
54.97936263,
79.10363195,
118.74447822,
155.007749,
196.71801138,
260.01839168,
313.88893951,
372.54299921
],
[
131.375,
30.916667,
58.00597745,
84.22231531,
126.99390007,
165.18444096,
208.14992433,
271.73480821,
324.91545649,
382.44303491
],
[
131.375,
31.083333,
61.01622038,
90.46516105,
139.18408017,
182.04324494,
229.37167872,
298.15221909,
355.05486672,
416.17739520
],
[
131.375,
31.25,
64.37047221,
98.10742004,
155.56203255,
206.33800926,
262.17166476,
343.63046822,
411.15587294,
483.99370124
],
[
131.625,
30.75,
54.5513191,
80.88255986,
123.62408677,
162.3540679,
207.18135033,
275.81656677,
335.03150313,
400.32985825
],
[
131.625,
30.916667,
59.04679433,
88.04219688,
135.37999395,
177.70729425,
225.4874281,
296.5651892,
356.35100178,
421.26946306
],
[
131.625,
31.083333,
63.37215223,
95.79049658,
150.50007241,
199.25085259,
253.15345403,
331.32312653,
395.54730972,
464.19234554
],
[
131.625,
31.25,
67.8127281,
104.69838012,
169.79850434,
228.02841561,
291.55292001,
382.6473593,
456.84604267,
535.84417332
],
[
131.875,
30.75,
45.52633583,
69.59444787,
108.74693613,
143.36444557,
182.16087707,
239.93458004,
288.72580501,
341.76557812
],
[
131.875,
30.916667,
51.97998392,
80.49900778,
127.96447163,
170.20532612,
217.44694354,
287.01299418,
344.89669253,
407.38520840
],
[
131.875,
31.083333,
59.77587571,
94.12057011,
153.63873667,
207.83991497,
268.29782111,
356.68074852,
429.60956254,
507.73334814
],
[
131.875,
31.25,
68.199735,
109.14309289,
183.84888894,
252.06755567,
327.04173084,
434.72040056,
522.51322262,
615.46840729
],
[
131.125,
31.416667,
61.48687605,
94.35058851,
149.9870225,
200.14093943,
256.79947876,
341.55607167,
413.44934143,
492.14840177
],
[
131.125,
31.583333,
62.57227652,
96.551572,
154.09203031,
205.51952208,
263.00920576,
348.52865378,
420.52861195,
499.20435648
],
[
131.125,
31.75,
62.7112199,
96.90952704,
154.40372971,
205.46847288,
262.42488989,
347.16925543,
418.61934402,
496.80812314
],
[
131.125,
31.916667,
61.76061074,
95.26501045,
151.15671455,
200.81187055,
256.58663475,
339.97797959,
410.95962188,
488.88399000
],
[
131.375,
31.416667,
68.2501457,
106.44075677,
172.49704589,
230.65869562,
294.15632496,
385.98907853,
461.5543521,
542.82236696
],
[
131.375,
31.583333,
71.8673718,
113.02879092,
182.9426669,
243.1589198,
308.23485232,
401.51396283,
477.93850535,
559.86762813
],
[
131.375,
31.75,
74.38428578,
116.71480021,
186.95815151,
246.74596991,
311.09854084,
403.28092543,
478.78088931,
559.78456304
],
[
131.375,
31.916667,
74.51988142,
116.50493075,
185.1983523,
243.47924382,
306.35104343,
396.67500348,
470.92119816,
550.58537049
],
[
131.625,
31.416667,
73.1452828,
114.70926596,
189.3482016,
254.87863671,
325.22045325,
424.80349226,
505.26702698,
590.33093961
],
[
131.625,
31.583333,
78.99178842,
124.91199753,
204.81582,
272.62405824,
344.44059387,
445.31789485,
526.57294991,
612.01204915
],
[
131.625,
31.75,
84.0106344,
132.90256771,
214.56720953,
282.1974722,
353.41816683,
453.16269351,
533.40502943,
617.82680310
],
[
131.625,
31.916667,
85.72921068,
135.67636277,
216.89779092,
283.62179763,
353.87666782,
452.50261553,
532.07537546,
615.97415711
],
[
131.875,
31.416667,
77.00938671,
124.34696341,
211.88019861,
288.76178122,
370.86850254,
486.44114768,
579.55596905,
677.63046174
],
[
131.875,
31.583333,
86.29466633,
139.8853607,
235.27160713,
315.21732451,
399.07762777,
516.28889577,
610.02489623,
708.72947153
],
[
131.875,
31.75,
92.97999318,
150.84476767,
248.98398293,
328.89082614,
412.10640898,
528.02754045,
620.61780486,
717.97899860
],
[
131.875,
31.916667,
94.71941783,
153.81291193,
251.03108309,
329.13494924,
410.23721544,
523.07031038,
613.08057796,
707.67688619
],
[
131.125,
32.083333,
59.725161,
91.92293864,
145.45060288,
193.27243963,
247.61163447,
329.92089705,
400.59329836,
478.86581320
],
[
131.125,
32.25,
57.42119314,
87.90232476,
138.77508448,
184.83770911,
237.88247725,
319.65476563,
390.86386319,
469.96414473
],
[
131.125,
32.416667,
55.43862137,
84.28022288,
133.02309294,
178.13930162,
231.24293517,
314.18157351,
386.71095586,
467.24605614
],
[
131.125,
32.583333,
54.99082532,
83.11092601,
131.71273836,
178.7138131,
236.04346296,
327.76722848,
408.14031451,
496.80963936
],
[
131.375,
32.083333,
72.24793958,
112.71501884,
178.57432098,
234.68961981,
295.5110061,
383.52844598,
456.32337381,
535.10308140
],
[
131.375,
32.25,
68.60388732,
106.54806203,
168.4447274,
221.70198736,
280.03070475,
365.47685295,
436.79535844,
514.59597126
],
[
131.375,
32.416667,
64.52679733,
99.23111806,
156.60172067,
206.88574169,
262.76526491,
346.02928442,
416.52891407,
493.95021925
],
[
131.375,
32.583333,
60.89225219,
92.52528766,
145.18088864,
192.49400573,
246.54000224,
328.80103223,
399.63661517,
478.19031200
],
[
131.625,
32.083333,
84.39307504,
133.60253142,
212.74317753,
277.75355754,
346.51985035,
443.53188925,
522.26866907,
605.49418223
],
[
131.625,
32.25,
80.92727764,
127.64441799,
202.7178256,
264.91056405,
331.05952494,
424.97374243,
501.41968392,
583.13597115
],
[
131.625,
32.416667,
76.27434258,
118.98420564,
188.57148056,
247.23226077,
310.2579308,
400.60283072,
474.8140451,
554.46609879
],
[
131.625,
32.583333,
70.94508696,
109.22063832,
172.43428326,
227.06809493,
286.76391029,
373.74175711,
446.04358734,
524.61795361
],
[
131.875,
32.083333,
92.98363663,
150.20984932,
243.24286497,
317.87312519,
395.41648607,
503.20641255,
589.40289337,
679.95627746
],
[
131.875,
32.25,
89.12285291,
142.1409139,
228.50534538,
298.45555458,
371.4839672,
473.21213322,
554.65782215,
640.33264077
],
[
131.875,
32.416667,
84.13867863,
131.61234835,
209.95526507,
274.56686414,
342.53808875,
437.7459182,
514.32451429,
594.75474693
],
[
131.875,
32.583333,
78.45616108,
120.8725736,
191.54578222,
251.36098315,
315.10185411,
405.34479301,
478.35184863,
555.85062483
],
[
131.125,
32.75,
56.94181988,
87.97626824,
143.4875418,
198.28572939,
264.00016988,
364.74493934,
449.87940601,
542.15290605
],
[
131.125,
32.916667,
60.23597632,
96.67092446,
165.28774833,
232.10714175,
307.98056722,
418.75826591,
509.83328268,
606.86114256
],
[
131.125,
33.083333,
61.06506388,
98.52332569,
168.4501948,
235.52893708,
311.29430155,
421.76182001,
512.63121774,
609.44205812
],
[
131.125,
33.25,
57.70214434,
95.39720053,
167.43126834,
236.4598822,
314.36214839,
428.83354604,
524.26439072,
627.36875007
],
[
131.375,
32.75,
59.53797946,
89.63012747,
139.28786677,
184.68646386,
237.55605129,
319.77991732,
391.6529163,
471.47616813
],
[
131.375,
32.916667,
61.88408912,
95.8505311,
155.69798543,
213.59455166,
281.63906207,
385.01734205,
471.75634622,
565.39850605
],
[
131.375,
33.083333,
64.32332506,
102.32532602,
171.34236106,
237.10452942,
311.8164153,
421.31332931,
511.64581595,
607.99658558
],
[
131.375,
33.25,
62.49641348,
100.87348241,
172.70047529,
242.0859798,
321.16640301,
438.1823521,
536.3723065,
643.21860977
],
[
131.625,
32.75,
66.32530735,
100.4010752,
157.11512958,
207.4362387,
263.67109996,
347.62037477,
418.64707418,
496.59272908
],
[
131.625,
32.916667,
65.05789116,
98.09223849,
152.40818988,
201.13793665,
256.69668169,
340.97650387,
413.30054706,
492.94871658
],
[
131.625,
33.083333,
66.53674706,
104.26685645,
171.27366665,
234.8059393,
307.47743484,
415.06961018,
504.25896191,
599.78717443
],
[
131.625,
33.25,
66.15980808,
106.80826349,
179.9923644,
249.32530678,
328.21412039,
444.86477433,
541.75520759,
645.65743010
],
[
131.875,
32.75,
76.07902673,
116.12328788,
181.28380896,
237.3056611,
298.37132489,
386.99393993,
460.17805737,
539.26935417
],
[
131.875,
32.916667,
71.53223933,
108.4718726,
168.15503627,
219.97583275,
277.42723133,
362.26190343,
433.61365503,
511.58013536
],
[
131.875,
33.083333,
69.55620063,
107.75389196,
170.24419254,
225.66852617,
287.91411206,
380.91256968,
459.51731992,
545.29598722
],
[
131.875,
33.25,
65.96614402,
106.2999797,
177.23899443,
242.85787567,
317.30560167,
427.32728085,
518.58378739,
616.12936794
],
[
131.125,
33.416667,
46.28897636,
78.16985205,
147.30539903,
217.54577354,
296.08651164,
408.84052623,
500.55491997,
598.14025321
],
[
131.125,
33.583333,
30.72606686,
49.0356352,
84.383713,
120.46918341,
164.58071398,
233.88541322,
293.97473163,
360.45861194
],
[
131.125,
33.75,
24.84623769,
37.28577603,
58.91774666,
80.17194732,
106.96124072,
153.02315579,
198.05849573,
253.30247030
],
[
131.125,
33.916667,
23.353978,
37.64872676,
66.75199923,
98.54537936,
139.77174853,
207.79161219,
267.90466828,
334.77040762
],
[
131.375,
33.416667,
53.5510413,
89.08223538,
160.9830114,
231.77765502,
310.83007813,
424.49266419,
517.11228565,
615.32368589
],
[
131.375,
33.583333,
39.46517047,
61.70419691,
103.74665923,
148.2398277,
204.17242528,
292.00700222,
366.88733267,
448.29413686
],
[
131.375,
33.75,
28.03074057,
41.96719092,
66.38883744,
89.90196132,
118.9256914,
167.35713573,
213.21777255,
267.80086839
],
[
131.375,
33.916667,
25.85103998,
41.28073443,
74.90058468,
115.8140958,
173.63715415,
269.89743135,
352.0253951,
440.33975762
],
[
131.625,
33.416667,
57.16439072,
95.63239347,
169.79372789,
240.99319842,
321.05972668,
437.53190664,
533.21732379,
635.10285052
],
[
131.625,
33.583333,
42.11312102,
66.05773035,
113.09849085,
165.42379753,
232.05670975,
334.61090643,
419.98097901,
511.54218811
],
[
131.625,
33.75,
33.49090669,
48.63170647,
73.38475669,
95.85432122,
121.97945955,
163.09820567,
199.82276035,
242.12778055
],
[
131.625,
33.916667,
26.90876868,
40.8605043,
66.98083132,
93.01369278,
125.28541865,
178.34147997,
226.64976544,
281.48141967
],
[
131.875,
33.416667,
55.5835941,
87.34689893,
144.26525748,
199.40587079,
265.17088968,
366.2197692,
451.70942669,
544.15221492
],
[
131.875,
33.583333,
43.97746435,
66.37439359,
103.93798632,
137.37294661,
174.65072383,
229.89586575,
276.3687035,
327.43108439
],
[
131.875,
33.75,
34.42517885,
49.24978281,
73.52334423,
95.26171848,
119.98597133,
157.76683396,
190.38992682,
227.09046463
],
[
131.875,
33.916667,
27.42582774,
39.88490471,
61.69434099,
82.26851163,
106.71924845,
145.9886743,
182.42682853,
226.96458778
],
[
131.125,
34.083333,
23.53590505,
45.39223265,
100.09671114,
163.23877015,
238.06811555,
347.90379801,
438.08960117,
534.81115275
],
[
131.125,
34.25,
24.62730621,
52.50027926,
114.7176235,
177.44540303,
249.51475477,
354.9947377,
441.61664846,
534.26721533
],
[
131.125,
34.416667,
19.3835818,
45.6690471,
105.57682227,
168.86652202,
241.76846147,
347.81089234,
434.43558919,
526.88188672
],
[
131.125,
34.583333,
16.61877533,
34.25340478,
74.33000867,
119.98900556,
178.37651603,
270.20994193,
348.02667578,
432.16212891
],
[
131.375,
34.083333,
27.3285571,
50.22540774,
107.93674003,
171.10255382,
243.94513983,
349.89652208,
436.58018155,
529.22859803
],
[
131.375,
34.25,
29.44328027,
57.22477091,
116.86644939,
178.00596384,
248.79127662,
352.93723895,
438.76778508,
530.82841167
],
[
131.375,
34.416667,
28.75610499,
56.58827018,
116.34475507,
177.41482955,
248.19892458,
352.41679658,
438.28188328,
530.33263544
],
[
131.375,
34.583333,
22.07608583,
47.95557062,
107.80406587,
170.70085985,
243.21384333,
349.02981718,
435.70616506,
528.35709694
],
[
131.625,
34.083333,
27.6764199,
46.98118212,
92.13588767,
147.52324603,
218.4347128,
325.3497794,
413.04266017,
506.31975844
],
[
131.625,
34.25,
29.71859564,
55.76714378,
114.40761573,
176.02511164,
247.49943453,
352.31531047,
438.41666744,
530.58867830
],
[
131.625,
34.416667,
31.11863521,
58.84670969,
117.73684061,
178.24574957,
248.71423123,
352.68074658,
438.39109965,
530.28190623
],
[
131.625,
34.583333,
29.46098495,
57.41591668,
116.70464221,
177.52653029,
248.23325694,
352.42371497,
438.26658111,
530.28176234
],
[
131.875,
34.083333,
27.24492371,
42.0956403,
70.83766228,
101.37338148,
141.12310554,
210.49444518,
277.3078044,
359.03153473
],
[
131.875,
34.25,
28.62701282,
49.16073311,
98.24822327,
156.86619119,
229.12068538,
336.07667459,
423.54478148,
516.68457967
],
[
131.875,
34.416667,
30.61432529,
57.07385614,
115.75074502,
176.86893681,
247.84700375,
352.21642171,
438.10889554,
530.13645241
],
[
131.875,
34.583333,
31.40712876,
59.08617646,
117.84645732,
178.20310888,
248.58018928,
352.57344074,
438.40774603,
530.50042819
],
[
131.125,
34.75,
13.39941008,
24.88153983,
47.89201556,
71.98888942,
102.0233378,
151.20582015,
196.07095427,
247.91362541
],
[
131.125,
34.916667,
10.38306504,
18.42669604,
32.97763371,
47.85387029,
67.02097127,
101.0043886,
135.82572346,
180.64841144
],
[
131.125,
35.083333,
9.06273988,
14.43780832,
24.79856408,
35.74434896,
50.31416586,
79.03541717,
111.85249353,
158.65488534
],
[
131.125,
35.25,
8.11157118,
11.39088426,
19.50379038,
28.60688819,
41.22930052,
68.1201632,
102.07182601,
152.52190974
],
[
131.375,
34.75,
17.88632545,
35.77859556,
77.50738121,
127.54561947,
192.77030972,
294.28859039,
378.82676564,
469.26288327
],
[
131.375,
34.916667,
14.15145052,
25.80312119,
49.18129982,
73.74733616,
104.16785382,
153.84074295,
198.95925025,
251.02310241
],
[
131.375,
35.083333,
10.87354251,
18.92351596,
33.72390065,
48.57087929,
67.75575489,
101.81249088,
136.60254821,
181.33359010
],
[
131.375,
35.25,
9.22779563,
14.85437895,
25.3053516,
36.2942911,
50.98348799,
79.73771672,
112.68050216,
159.33126872
],
[
131.625,
34.75,
24.37695737,
49.566759,
108.87318587,
171.43014487,
243.71340106,
349.31994265,
435.85867004,
528.37078484
],
[
131.625,
34.916667,
18.62267926,
37.17827709,
79.92257204,
130.13617337,
194.36002332,
293.70142024,
376.57764867,
465.38460201
],
[
131.625,
35.083333,
14.78594515,
26.74509632,
51.35220464,
77.71918688,
110.76995094,
164.76489451,
213.34483291,
268.46422238
],
[
131.625,
35.25,
11.32776355,
19.44221595,
34.95534559,
50.47139814,
70.58281283,
106.08541672,
141.67733132,
186.91162559
],
[
131.875,
34.75,
28.71309003,
57.06555525,
116.64768987,
177.45765026,
248.12512923,
352.28285768,
438.11206074,
530.11831272
],
[
131.875,
34.916667,
24.77119077,
49.98034191,
109.35700069,
171.82922858,
243.99783344,
349.46511893,
435.89230977,
528.27726395
],
[
131.875,
35.083333,
18.85140835,
37.57051529,
81.53059694,
133.64741497,
200.00947647,
301.82698407,
386.34790649,
476.65439369
],
[
131.875,
35.25,
14.96086861,
27.01441709,
52.16870353,
79.40192488,
114.03030988,
170.42864375,
220.93311668,
278.00018867
],
[
131.125,
35.416667,
7.34302003,
9.55348931,
16.71234187,
24.39481176,
35.94669034,
62.52518054,
98.45540413,
151.09828221
],
[
131.375,
35.416667,
8.21879001,
11.70969871,
19.77980627,
28.96162114,
41.738838,
68.60651662,
102.50848061,
152.77229470
],
[
131.625,
35.416667,
9.34470234,
15.1965447,
25.87183246,
37.07426603,
52.14160072,
81.21463248,
114.18128064,
160.52478723
],
[
131.625,
35.583333,
8.2752853,
11.88183341,
19.96775334,
29.25635638,
42.25598373,
69.20043737,
103.07362657,
153.10032445
],
[
131.875,
35.416667,
11.34543465,
19.50919691,
35.18378633,
50.87300787,
71.15693928,
106.83857527,
142.54719558,
187.75008088
],
[
131.875,
35.583333,
9.29137587,
15.08716205,
25.79291045,
37.05357049,
52.231194,
81.50048198,
114.5377968,
160.83190149
],
[
131.875,
35.75,
8.17573872,
11.58894026,
19.70590526,
28.94460069,
41.91290995,
69.09058133,
103.12276815,
153.18722607
],
[
131.875,
35.916667,
7.2636343,
9.4502061,
16.40262113,
23.94347498,
35.56457618,
62.46209396,
98.58530194,
151.26797077
],
[
131.875,
36.083333,
6.55150877,
8.52370943,
13.49084752,
19.5790585,
30.27815362,
58.2389902,
96.4948619,
150.52345404
],
[
132.125,
31.416667,
69.08648689,
115.64429546,
205.12636325,
286.396917,
374.22890208,
498.4613561,
598.60813913,
704.36544506
],
[
132.125,
31.583333,
82.99937069,
138.46918743,
240.76032246,
328.30755883,
420.40124833,
548.98010424,
651.91563693,
760.28141367
],
[
132.125,
31.75,
95.39644821,
158.04862004,
266.31709745,
355.20925767,
447.87413455,
576.88910854,
679.91980529,
788.20457357
],
[
132.125,
31.916667,
100.78536594,
166.69799782,
276.15353623,
364.11810502,
455.37842133,
582.2265477,
683.45422207,
789.79724981
],
[
132.375,
31.916667,
96.56884022,
160.06834881,
267.95202049,
358.39630814,
453.97431507,
587.99071982,
695.38182873,
808.56492125
],
[
132.125,
32.083333,
100.23006172,
165.70096792,
272.94982453,
358.33353366,
446.72400182,
569.44114397,
667.31018005,
770.13852051
],
[
132.125,
32.25,
99.37367114,
161.13031942,
261.17295111,
341.63638334,
425.35410298,
541.87489147,
635.03231934,
732.92154189
],
[
132.125,
32.416667,
93.43918716,
148.77168552,
239.93878201,
314.4314942,
392.36295683,
501.12460622,
588.37002032,
680.09945628
],
[
132.125,
32.583333,
86.26920753,
134.59516283,
215.07633273,
282.13980405,
353.09235979,
452.77931832,
533.12004064,
617.70317460
],
[
132.375,
32.083333,
103.47792296,
168.88395979,
277.41391364,
366.94154417,
460.98152035,
592.59463768,
697.98971302,
809.04863719
],
[
132.375,
32.25,
102.95354199,
166.67786567,
272.22093606,
358.61893696,
449.21867335,
575.95150742,
677.44948504,
784.30003789
],
[
132.375,
32.416667,
97.42311955,
156.65844874,
255.92390194,
337.36515455,
422.76064827,
542.28745157,
638.19011011,
739.21648876
],
[
132.375,
32.583333,
88.316061,
141.26768143,
232.40760436,
307.86866121,
387.09665806,
497.99322112,
587.22603013,
681.24204421
],
[
132.625,
32.083333,
85.87782256,
143.19497719,
242.01354316,
325.4044713,
414.02829263,
539.3943184,
640.68732341,
747.92696659
],
[
132.625,
32.25,
94.90757397,
153.87757807,
255.66893242,
341.54489633,
432.45305906,
560.32466715,
663.25776377,
772.01305740
],
[
132.625,
32.416667,
93.97218039,
151.10518618,
251.81613145,
336.93710698,
426.60743344,
551.98606478,
652.54583949,
758.54834589
],
[
132.625,
32.583333,
83.53290868,
135.75963723,
233.14852835,
316.83995337,
404.6972333,
526.9796886,
624.48555572,
726.89355957
],
[
132.875,
32.083333,
60.55367798,
103.47330176,
186.13905281,
263.58597443,
348.79748405,
469.73389861,
566.95170016,
668.99052581
],
[
132.875,
32.25,
70.29037095,
116.69852584,
207.38345224,
294.61177402,
391.38923028,
528.81465478,
638.79281139,
754.17320708
],
[
132.875,
32.416667,
75.31523318,
123.88340519,
220.29322021,
315.98818583,
423.02273815,
574.87198604,
696.02798696,
823.06427683
],
[
132.875,
32.583333,
69.37920225,
115.01927071,
211.88376044,
312.90404397,
427.01743678,
587.75801328,
715.32559156,
848.34471796
],
[
132.125,
32.75,
79.31824387,
122.61580586,
194.15871611,
254.40595188,
318.56964547,
409.48665229,
483.01426503,
561.06735504
],
[
132.125,
32.916667,
72.20850193,
112.41440942,
180.22206395,
238.40378335,
301.29940239,
391.88905767,
466.38793503,
546.49494881
],
[
132.125,
33.083333,
64.93962633,
99.8205317,
158.94541916,
210.66875616,
267.2599656,
349.78356041,
418.44556672,
493.07985265
],
[
132.125,
33.25,
57.98653314,
88.26966761,
139.68825447,
185.2531062,
235.37866709,
308.20537082,
368.49511844,
433.63847675
],
[
132.375,
32.75,
77.3441049,
123.00780164,
204.60929681,
273.60817896,
346.24094869,
447.8803019,
529.635113,
615.64828823
],
[
132.375,
32.916667,
67.20602149,
105.88268465,
176.74684016,
238.69648503,
304.5513898,
396.83154881,
470.86736883,
548.81524362
],
[
132.375,
33.083333,
59.23094949,
91.33522046,
149.9190718,
203.78568047,
262.80049642,
346.8927728,
414.70246906,
486.21078037
],
[
132.375,
33.25,
53.14206089,
80.27712877,
130.14577275,
178.56455987,
234.28410357,
315.77577319,
382.20817887,
452.49577948
],
[
132.625,
32.75,
69.38670871,
113.71126452,
203.39163336,
284.17172794,
369.47169341,
487.81535554,
582.10904175,
680.79312143
],
[
132.625,
32.916667,
58.89980121,
94.99921302,
170.17070386,
243.52349195,
323.96404924,
437.25810557,
527.94139726,
622.87192506
],
[
132.625,
33.083333,
52.47460232,
82.92555098,
144.33005432,
208.5658857,
284.29381842,
394.86945211,
483.9199487,
577.39826442
],
[
132.625,
33.25,
48.30507565,
74.69008013,
126.55554397,
184.06413379,
256.45559331,
363.99265587,
450.16765578,
540.02635922
],
[
132.875,
32.75,
59.25748439,
98.32353391,
186.23691529,
283.71621478,
396.63635003,
555.80498391,
681.62297276,
812.42527081
],
[
132.875,
32.916667,
52.05074401,
85.16882449,
158.06383754,
242.93793739,
347.54293221,
497.45321192,
615.59476393,
737.88989485
],
[
132.875,
33.083333,
46.88543674,
74.77712629,
134.22454027,
206.18449129,
300.31337821,
437.30276482,
544.54719653,
655.11172926
],
[
132.875,
33.25,
43.23872159,
66.97844576,
116.69887049,
179.44356949,
265.10055834,
389.15124794,
485.59256436,
584.89127371
],
[
132.125,
33.416667,
50.2870747,
74.91838594,
116.42598053,
153.88892283,
195.48906709,
255.7785133,
305.03299821,
357.41416682
],
[
132.125,
33.583333,
43.14293649,
63.72117119,
99.63723147,
133.24644935,
171.11011875,
226.46713358,
271.81807191,
320.11605844
],
[
132.125,
33.75,
37.82149339,
55.62850651,
87.22716787,
117.52880654,
152.28941958,
203.5544837,
245.83500017,
291.13987953
],
[
132.125,
33.916667,
28.73904062,
41.71485666,
64.11074853,
85.85355581,
112.48935299,
156.24785584,
196.28125467,
242.52890165
],
[
132.375,
33.416667,
47.93160457,
71.82254564,
115.97028063,
160.22467994,
212.43648497,
289.17527787,
351.58578035,
417.37318375
],
[
132.375,
33.583333,
44.05566482,
65.41826338,
105.15194386,
145.99454966,
194.48906674,
265.8588376,
323.75553668,
384.84088728
],
[
132.375,
33.75,
40.2124743,
59.46895979,
95.21565585,
131.83401191,
175.60039057,
240.88806583,
294.86047398,
352.60667300
],
[
132.375,
33.916667,
33.51304714,
50.09418127,
82.04574188,
114.8736851,
153.66753783,
211.81557403,
260.364531,
313.28095562
],
[
132.625,
33.416667,
45.53661188,
68.92855669,
115.17150162,
168.08898956,
235.15467747,
333.10246565,
410.84897492,
491.63400255
],
[
132.625,
33.583333,
43.72081832,
65.70670397,
108.92032402,
158.48503702,
220.96174018,
314.62616722,
391.75628065,
474.48248770
],
[
132.625,
33.75,
38.2274996,
58.53609965,
100.62514308,
149.16773947,
210.30665472,
307.92348792,
396.05760715,
497.06027802
],
[
132.625,
33.916667,
36.48330226,
55.01836498,
89.81223203,
126.37367788,
171.27457718,
243.30665849,
308.18691019,
382.59248184
],
[
132.875,
33.416667,
40.96138631,
62.11733588,
105.84551691,
163.05966777,
241.89944891,
354.26368416,
441.04666538,
530.33531931
],
[
132.875,
33.583333,
40.67735857,
61.28869478,
102.64446799,
154.68912922,
224.3531429,
326.49970189,
408.29637612,
494.60204811
],
[
132.875,
33.75,
38.71539832,
61.22346072,
110.29755234,
167.13262632,
237.79374609,
352.95492833,
460.51166804,
587.17221200
],
[
132.875,
33.916667,
38.50607902,
59.9791848,
102.15494161,
146.11459054,
200.79976688,
294.59194228,
387.70762534,
501.40686951
],
[
132.125,
34.083333,
27.72570196,
40.79513524,
63.97131887,
86.85732629,
115.79942942,
166.09732643,
216.58432084,
282.32588055
],
[
132.125,
34.25,
28.04357228,
44.27372395,
76.93973425,
113.07463368,
159.73366901,
236.16519562,
304.0337997,
380.41251234
],
[
132.125,
34.416667,
29.28553771,
51.64336374,
105.28989432,
166.47761792,
239.1423671,
345.62986754,
432.64249894,
525.42715776
],
[
132.125,
34.583333,
30.76984451,
57.61432088,
116.56349133,
177.6186085,
248.45576559,
352.68179991,
438.55784199,
530.65831822
],
[
132.375,
34.083333,
28.96845066,
42.41042249,
65.231855,
87.6337696,
116.09166166,
165.27488698,
212.0557303,
266.02115346
],
[
132.375,
34.25,
27.83308324,
41.49027939,
65.50278448,
89.16234262,
119.14670038,
170.80063427,
220.76727888,
281.43064169
],
[
132.375,
34.416667,
27.85659155,
44.90136857,
81.04718671,
123.8123936,
180.91814698,
276.62232783,
363.43139361,
463.03341133
],
[
132.375,
34.583333,
29.0856686,
52.4900951,
109.140155,
171.60900196,
244.68727933,
351.90235125,
439.80915202,
533.75200202
],
[
132.625,
34.083333,
30.92506352,
45.4008451,
69.40021337,
93.02199651,
122.90468318,
176.03673442,
229.33584979,
293.59557909
],
[
132.625,
34.25,
27.89570246,
40.86910926,
62.65877688,
83.57684378,
109.57294736,
154.73460639,
198.42959264,
250.26544134
],
[
132.625,
34.416667,
26.47704916,
39.71841936,
63.3981571,
86.71407692,
115.76137675,
163.81613571,
207.40790634,
256.45014270
],
[
132.625,
34.583333,
26.6087015,
43.69550633,
81.97182341,
127.8554423,
187.47797152,
281.25248121,
360.60000904,
446.32956375
],
[
132.875,
34.083333,
34.91699545,
52.29996063,
83.79046054,
115.57563334,
154.84756997,
220.49140189,
283.85847211,
360.49987779
],
[
132.875,
34.25,
28.32661291,
41.30226445,
62.74620569,
83.01909834,
108.084342,
152.73820282,
199.69887586,
259.60974998
],
[
132.875,
34.416667,
25.38203534,
36.91194329,
56.06579969,
74.26149483,
96.67844225,
135.19657515,
172.80760435,
218.09567400
],
[
132.875,
34.583333,
23.82585433,
36.55093157,
59.92210776,
84.3464883,
114.92451601,
164.62062788,
208.62638852,
257.59795878
],
[
132.125,
34.75,
31.28684221,
58.98022153,
117.81230124,
178.15792112,
248.47919252,
352.3793793,
438.13418691,
530.13567991
],
[
132.125,
34.916667,
28.9784241,
57.25820191,
116.66712602,
177.37641403,
247.97906093,
352.08966322,
437.89840929,
529.88935115
],
[
132.125,
35.083333,
25.03904821,
50.84277643,
110.84657501,
173.21326445,
245.11457478,
350.34811782,
436.73081072,
529.17541273
],
[
132.125,
35.25,
19.0350064,
38.30860305,
84.85322318,
140.76062644,
211.45326004,
317.67988795,
404.93939757,
497.72969202
],
[
132.375,
34.75,
30.40324749,
57.63199416,
116.77909599,
177.75238287,
248.50896745,
352.63335582,
438.38932687,
530.31076205
],
[
132.375,
34.916667,
30.43034475,
58.69512107,
117.73971374,
178.1250025,
248.50163782,
352.41539102,
438.09570765,
529.94634207
],
[
132.375,
35.083333,
28.87030265,
57.28355505,
116.77999488,
177.54125279,
248.17930647,
352.31213825,
438.12929592,
530.12671174
],
[
132.375,
35.25,
24.06881507,
50.57287985,
110.85318003,
173.28002339,
245.20034843,
350.40038374,
436.70783714,
529.03281859
],
[
132.625,
34.75,
27.28959363,
51.02081362,
108.9611407,
171.40799069,
243.68755936,
349.31610778,
435.90459389,
528.49726581
],
[
132.625,
34.916667,
29.53960576,
57.44324986,
116.74506925,
177.53430848,
248.21400152,
352.40557766,
438.27545242,
530.33644874
],
[
132.625,
35.083333,
30.01796815,
58.51362814,
117.65547673,
178.09747736,
248.53461668,
352.58705652,
438.45477674,
530.57752808
],
[
132.625,
35.25,
27.63235197,
56.57547491,
116.52433061,
177.47975964,
248.21377035,
352.46490048,
438.42610326,
530.63324739
],
[
132.875,
34.75,
24.3207643,
42.05142072,
85.08797001,
137.09230657,
203.31510346,
304.72407986,
389.00433687,
479.10804723
],
[
132.875,
34.916667,
26.77058782,
51.79562298,
111.00176599,
173.22758179,
245.08266582,
350.20567007,
436.41390262,
528.59398853
],
[
132.875,
35.083333,
28.94402643,
57.33471735,
116.74336719,
177.43011635,
248.00725097,
352.07495421,
437.83971653,
529.77389009
],
[
132.875,
35.25,
28.79499726,
57.55558061,
117.03007533,
177.62796684,
248.11737426,
352.13208591,
437.90703991,
529.88791429
],
[
132.125,
35.416667,
14.83970141,
27.25358053,
53.57959438,
81.63000766,
116.6055906,
172.79990701,
222.76486962,
279.05678148
],
[
132.125,
35.583333,
10.95003536,
19.25325785,
35.23716556,
51.37445127,
72.16647481,
108.51410484,
144.76504663,
190.16655672
],
[
132.125,
35.75,
9.06679738,
14.49783472,
25.05878583,
36.30745607,
51.47255796,
81.07961197,
114.56349794,
161.23140845
],
[
132.125,
35.916667,
7.92039712,
10.78227094,
18.8748331,
27.78099179,
40.22864715,
67.7404407,
102.20677808,
152.86930973
],
[
132.375,
35.416667,
18.27362569,
37.34276214,
84.99354098,
142.05260661,
213.01090967,
318.69432905,
405.26852565,
497.25919429
],
[
132.375,
35.583333,
13.67878965,
25.23685237,
50.68175963,
80.04088895,
118.44975258,
181.55934897,
237.53009414,
299.89420230
],
[
132.375,
35.75,
9.87982969,
17.534262,
31.54569571,
46.64691378,
66.22684767,
101.31371259,
137.24716434,
183.19191877
],
[
132.375,
35.916667,
8.56404949,
12.86368183,
22.08508616,
32.21025286,
46.35538092,
74.71857219,
108.24554067,
156.59537917
],
[
132.625,
35.416667,
21.80516777,
47.37312573,
108.0422627,
171.37604649,
243.97014621,
349.70927239,
436.28511718,
528.82116063
],
[
132.625,
35.583333,
16.21232899,
31.45198339,
69.07989378,
113.67293308,
170.71781269,
260.2997162,
336.33068043,
418.59608744
],
[
132.625,
35.75,
11.61637376,
20.55970741,
38.87157899,
57.84522417,
81.70707548,
122.3294584,
161.25608491,
208.50749913
],
[
132.625,
35.916667,
9.15697021,
14.75674293,
25.44760465,
36.79284978,
52.11235009,
81.77407871,
115.1444222,
161.61919668
],
[
132.875,
35.416667,
24.34977289,
51.53154354,
112.27092168,
174.43221876,
246.04404989,
350.91826088,
437.02320479,
529.16169490
],
[
132.875,
35.583333,
18.03813069,
36.03496366,
78.96535602,
130.90805386,
197.70944183,
300.01041521,
384.72154575,
475.06506926
],
[
132.875,
35.75,
13.17315249,
23.50565924,
44.28750267,
65.88219453,
92.88248591,
137.76450914,
179.48164244,
228.71567457
],
[
132.875,
35.916667,
9.63989962,
16.24250654,
27.9291356,
40.10096557,
56.66799811,
87.26790651,
120.48989702,
166.03332171
],
[
132.125,
36.083333,
7.01108489,
9.12163174,
15.43605581,
22.44401522,
33.89397911,
60.96289389,
97.90230027,
151.07533008
],
[
132.125,
36.25,
6.31981058,
8.22226314,
12.37190144,
18.49320102,
28.60070335,
56.40546877,
95.29889836,
149.88902660
],
[
132.125,
36.416667,
4.82697309,
6.28003678,
8.20088249,
9.65394618,
18.40300422,
45.88208854,
85.07701732,
141.57758306
],
[
132.375,
36.083333,
7.46439449,
9.71140113,
17.15613396,
25.12745128,
36.98627537,
64.03439682,
99.52425668,
151.70331638
],
[
132.375,
36.25,
6.64199609,
8.64143615,
13.88337251,
19.92794661,
30.9715564,
58.70858135,
96.78503001,
150.70738004
],
[
132.375,
36.416667,
6.02436794,
7.8378834,
10.80035439,
16.97097076,
26.14102262,
53.05858425,
92.77969899,
148.30093395
],
[
132.375,
36.583333,
4.740285,
6.16725297,
8.05360202,
9.48056999,
16.59840329,
39.0013414,
72.55568494,
125.43764905
],
[
132.625,
36.083333,
7.89703798,
10.69652855,
18.67686881,
27.40929664,
39.64504272,
66.93420201,
101.43496199,
152.45879473
],
[
132.625,
36.25,
6.94969128,
9.04175681,
15.15492591,
21.92951287,
33.24802586,
60.31283858,
97.62073168,
151.02280377
],
[
132.625,
36.416667,
6.26200575,
8.14705731,
12.08290492,
18.22786486,
28.26942476,
56.32415321,
95.47074321,
150.07683669
],
[
132.625,
36.583333,
4.84725292,
6.30642144,
8.23533731,
9.69450583,
18.71782016,
46.89350334,
86.70694159,
143.27417725
],
[
132.875,
36.083333,
8.26770264,
11.84842815,
19.88700881,
29.16058881,
42.17201445,
69.21780546,
103.14944623,
153.16821601
],
[
132.875,
36.25,
7.22161389,
9.39553629,
16.15952317,
23.45444853,
34.89553476,
61.65654528,
98.15168941,
151.12371659
],
[
132.875,
36.416667,
6.47690289,
8.42664494,
13.13034467,
19.20900725,
29.68219317,
57.90830747,
96.5047002,
150.60693426
],
[
132.875,
36.583333,
4.94447718,
6.43291312,
8.40051841,
9.88895435,
20.97285526,
52.43026531,
93.08529303,
148.55148550
],
[
132.375,
36.75,
4.51589016,
5.87530855,
7.67236192,
9.03178031,
12.52586692,
26.35457018,
43.50003791,
68.00125303
],
[
132.625,
36.75,
4.64355594,
6.04140557,
7.88926226,
9.28711189,
14.73627404,
32.62593628,
57.59039889,
95.78428612
],
[
132.625,
36.916667,
4.40016897,
5.72475182,
7.4757551,
8.80033794,
10.74882369,
21.84710376,
34.57395742,
51.18809930
],
[
132.875,
36.75,
4.76222252,
6.19579434,
8.09087321,
9.52444504,
16.96684382,
40.07613289,
74.73460543,
128.13639469
],
[
132.875,
36.916667,
4.53887396,
5.90521116,
7.7114107,
9.07774791,
12.88373012,
27.16132448,
45.32404446,
71.41500515
],
[
133.125,
32.083333,
45.79504432,
78.17870561,
143.53555168,
231.64900787,
382.09454687,
598.04318971,
757.3006671,
917.98024743
],
[
133.125,
32.25,
53.96410893,
91.5201689,
168.58380519,
280.21381207,
483.17819224,
760.23723304,
961.92712358,
1165.11309976
],
[
133.125,
32.416667,
60.75480716,
103.27695665,
191.2272212,
314.11726198,
505.66455986,
771.62022403,
970.3095545,
1171.91139779
],
[
133.125,
32.583333,
60.87424823,
102.15350655,
188.78564114,
303.55751461,
461.70001823,
683.20195247,
852.50765964,
1025.86195677
],
[
133.375,
32.25,
46.43148208,
83.12365621,
170.41850959,
338.38606355,
605.03772833,
932.80227161,
1173.33827019,
1416.78603843
],
[
133.375,
32.416667,
56.87544817,
105.38067657,
217.05621779,
372.68967474,
578.09523764,
856.31322264,
1067.94729545,
1284.16742457
],
[
133.375,
32.583333,
59.94478278,
103.44304474,
196.74486008,
328.24074589,
503.39498733,
740.55745743,
921.21301409,
1106.11545044
],
[
133.625,
32.25,
37.88135376,
65.5613036,
128.39677301,
246.04859374,
467.7747352,
739.22387083,
934.91410426,
1132.03877202
],
[
133.625,
32.416667,
48.41539097,
91.12968136,
219.54456933,
412.06069832,
637.00854956,
934.14827523,
1161.02493168,
1393.41870747
],
[
133.625,
32.583333,
56.22602429,
101.83511882,
211.46135273,
362.45810354,
549.77034642,
801.50114701,
994.19592851,
1191.96783238
],
[
133.875,
32.416667,
39.8464773,
72.39166103,
173.58957709,
376.1482864,
640.68265338,
967.1593473,
1209.80386023,
1456.62800221
],
[
133.875,
32.583333,
50.51396679,
97.64618592,
223.53361885,
389.62380959,
590.87388422,
861.77188436,
1069.40958716,
1282.36108975
],
[
133.125,
32.75,
56.07296426,
92.87198759,
172.33798807,
275.97866408,
411.99325714,
601.91865596,
748.19511142,
898.36770373
],
[
133.125,
32.916667,
50.27602999,
82.00187678,
150.84553455,
241.54021008,
361.26973816,
528.36468238,
656.96839645,
789.03616381
],
[
133.125,
33.083333,
45.39912489,
72.52350039,
131.19413369,
209.48218335,
315.32785865,
464.01844737,
578.37592064,
695.58295306
],
[
133.125,
33.25,
40.7396114,
63.42305678,
112.43181819,
180.95607688,
276.86291312,
410.4821849,
512.78966128,
617.61061608
],
[
133.375,
32.75,
56.489089,
93.579648,
175.49253175,
291.80279056,
442.80529406,
646.87655538,
802.83567845,
962.80800717
],
[
133.375,
32.916667,
51.26637927,
83.16891423,
155.02585023,
257.20923433,
388.7809415,
566.78785651,
703.05793248,
842.97898857
],
[
133.375,
33.083333,
46.42913055,
73.94727665,
136.11753765,
224.19501693,
339.38862728,
496.52160871,
617.01005863,
740.63167652
],
[
133.375,
33.25,
41.02712436,
64.23003051,
116.42388716,
192.82132447,
295.71543345,
436.21380794,
543.72272501,
653.96773035
],
[
133.625,
32.75,
55.66146171,
94.23915396,
185.7741576,
317.10336863,
478.82125631,
695.20567068,
861.0079261,
1031.48077574
],
[
133.625,
32.916667,
51.79844517,
84.6214067,
163.13825475,
277.3242285,
418.0455389,
606.45817627,
750.88999313,
899.32938285
],
[
133.625,
33.083333,
47.67098294,
76.05166367,
143.36978454,
240.8939909,
363.98245986,
529.95326265,
657.19699662,
787.95379763
],
[
133.625,
33.25,
42.83083703,
66.97545228,
123.54508926,
206.9026489,
315.68651854,
463.55055064,
576.86138962,
693.06665572
],
[
133.875,
32.75,
54.50241823,
95.74325669,
196.13466719,
336.77054123,
510.01528574,
742.19640315,
919.98371863,
1102.44544693
],
[
133.875,
32.916667,
52.26389064,
86.52284228,
169.87509082,
291.77660052,
442.71837358,
644.44412233,
798.75820022,
957.20631975
],
[
133.875,
33.083333,
45.97471514,
75.38968553,
146.70013591,
251.89942436,
384.46367343,
561.81769415,
697.28479002,
836.33025259
],
[
133.875,
33.25,
42.68792802,
68.22522095,
128.82641178,
217.46695086,
333.49039318,
490.63919808,
610.71306891,
733.80437478
],
[
133.125,
33.416667,
37.72751758,
56.96929198,
98.33798847,
159.75217978,
249.23549788,
371.1476718,
463.49243284,
557.93243790
],
[
133.125,
33.583333,
33.66348459,
50.88592651,
89.01928079,
146.20931545,
227.98326628,
340.65807935,
427.11949403,
516.34687288
],
[
133.125,
33.75,
37.49000128,
60.04486852,
108.67523102,
163.86482693,
232.69404203,
342.47523885,
442.54033488,
558.89869133
],
[
133.125,
33.916667,
39.16013216,
65.07658532,
126.30248046,
196.04553709,
282.78881103,
426.93587311,
558.43259111,
705.21697901
],
[
133.375,
33.416667,
36.81012624,
56.19386599,
99.21886647,
166.75699176,
261.87462315,
389.22894913,
485.80514573,
584.73269516
],
[
133.375,
33.583333,
32.41498904,
49.16486329,
87.32438657,
148.93312307,
238.99382328,
357.69103263,
446.95201624,
538.14265124
],
[
133.375,
33.75,
35.64388646,
55.97994907,
98.74307073,
154.42853874,
229.82865289,
343.15878707,
437.34254233,
539.86824573
],
[
133.375,
33.916667,
37.99485715,
64.74689295,
133.46481346,
217.59317473,
327.73529046,
516.56936013,
683.13666707,
862.14423626
],
[
133.625,
33.416667,
35.66608723,
55.67588403,
103.55435636,
177.4588953,
276.57115161,
409.7277991,
511.21054665,
615.20355646
],
[
133.625,
33.583333,
34.01787403,
51.82486283,
93.31189645,
158.82890746,
251.14395965,
373.55642342,
465.9205042,
560.32803865
],
[
133.625,
33.75,
35.11199968,
53.99114107,
95.24518675,
154.2074987,
236.20508932,
351.91813299,
442.65213145,
537.64124611
],
[
133.625,
33.916667,
36.67314659,
61.83152671,
126.03895651,
197.4188778,
280.82570227,
415.62337775,
541.86821471,
687.80331998
],
[
133.875,
33.416667,
39.05484136,
61.27949968,
112.99691603,
188.80309796,
291.44391444,
431.59312866,
538.66852534,
648.32181160
],
[
133.875,
33.583333,
36.76448663,
56.40338873,
101.48942007,
169.04817041,
262.34172028,
388.6626518,
484.69759462,
583.09264813
],
[
133.875,
33.75,
36.15545863,
55.23771876,
97.92268555,
160.12674661,
246.16425373,
364.42214858,
455.09284882,
548.35978452
],
[
133.875,
33.916667,
36.52188646,
60.09705113,
115.23216581,
178.51778233,
255.79062433,
375.91580228,
482.06411035,
602.11991505
],
[
133.125,
34.083333,
36.08990327,
55.16586365,
89.59216982,
125.00069134,
169.59028915,
247.11179213,
323.9056197,
417.12340623
],
[
133.125,
34.25,
28.20160863,
41.45161828,
63.17696175,
83.71815766,
109.40142535,
157.61476031,
212.36789795,
283.30378989
],
[
133.125,
34.416667,
23.64741032,
34.71116897,
52.86988293,
69.99664509,
91.4830321,
129.82026972,
170.31540779,
221.59371970
],
[
133.125,
34.583333,
21.46726612,
31.67432483,
48.82721008,
65.47383809,
86.15183479,
121.94833145,
156.64905134,
197.66554186
],
[
133.375,
34.083333,
35.70214639,
56.89625986,
97.17131905,
139.07328211,
192.13876393,
284.52649456,
376.03641927,
485.26133332
],
[
133.375,
34.25,
29.4411868,
45.19039222,
74.2812381,
105.23147334,
144.44576786,
209.68489913,
270.43457976,
341.44337639
],
[
133.375,
34.416667,
22.31943755,
32.8713262,
50.40868469,
67.64652101,
89.57796884,
131.51700798,
178.13429159,
236.98755336
],
[
133.375,
34.583333,
19.50522462,
28.41500436,
43.1745503,
57.37534337,
75.50477783,
108.93266559,
144.93891249,
190.07991976
],
[
133.625,
34.083333,
34.31765391,
56.93843148,
106.90826248,
159.87408162,
224.52887012,
334.33020321,
441.71323192,
568.44293175
],
[
133.625,
34.25,
28.33136519,
43.60225301,
73.90751612,
108.7870548,
154.42326814,
229.71865629,
299.02468608,
379.52809352
],
[
133.625,
34.416667,
20.23647109,
29.82111524,
46.48316239,
63.05531419,
85.54765233,
132.58008081,
188.56433326,
256.89607205
],
[
133.625,
34.583333,
18.02636751,
26.1229247,
39.70491465,
53.77322289,
72.26703185,
109.49011942,
151.62136136,
203.10660964
],
[
133.875,
34.083333,
33.61909126,
57.90440265,
122.57257742,
193.24352543,
275.76809323,
410.35489235,
536.47746908,
680.98928094
],
[
133.875,
34.25,
28.06926367,
44.21410312,
78.04009184,
118.22792343,
170.5581662,
256.56161166,
335.91133204,
427.68182789
],
[
133.875,
34.416667,
22.77331505,
34.43442774,
58.86178095,
89.59248148,
130.77796043,
196.2261511,
253.64653838,
317.85104038
],
[
133.875,
34.583333,
17.83160456,
25.73695884,
39.36968264,
53.84813668,
73.61850695,
115.96958999,
164.85211937,
222.31254771
],
[
133.125,
34.75,
20.79114484,
33.76054039,
59.15748354,
86.92041843,
121.87260799,
177.76217038,
226.70742034,
281.09504603
],
[
133.125,
34.916667,
22.63492848,
42.00439419,
89.62116728,
146.77405695,
217.69115318,
323.63798693,
410.62601866,
503.25648168
],
[
133.125,
35.083333,
26.77012784,
53.83717371,
113.82757801,
175.51169687,
246.86091392,
351.62303808,
437.78113201,
530.06962033
],
[
133.125,
35.25,
28.60466819,
57.48664537,
117.17559519,
177.88587859,
248.45055721,
352.52129227,
438.31822652,
530.31109682
],
[
133.375,
34.75,
19.04629924,
28.97886122,
46.88788543,
64.79261073,
87.34407305,
125.18307561,
159.67557683,
198.99353099
],
[
133.375,
34.916667,
19.62866617,
35.07832632,
68.71785235,
107.09404395,
155.87914418,
233.23215472,
299.54098188,
372.08335243
],
[
133.375,
35.083333,
24.25318005,
48.60596959,
107.34606892,
170.02610004,
242.56876446,
348.4460822,
435.11817138,
527.71147773
],
[
133.375,
35.25,
27.84451292,
56.78076878,
116.85195138,
177.72153294,
248.34641443,
352.41897064,
438.17289629,
530.08922792
],
[
133.625,
34.75,
17.84835028,
26.4803617,
41.68691041,
57.43982199,
77.99902158,
114.54684422,
149.14464362,
188.96653429
],
[
133.625,
34.916667,
18.97006144,
31.19075704,
57.65796428,
87.37505243,
125.14114613,
185.32709507,
237.77494661,
295.93641569
],
[
133.625,
35.083333,
21.87325505,
43.65114252,
98.26671492,
160.37393953,
233.73645684,
340.75719389,
428.16174668,
521.27118065
],
[
133.625,
35.25,
26.86752764,
55.6213246,
116.41208096,
177.79321063,
248.64381289,
352.7828146,
438.54132292,
530.46913030
],
[
133.875,
34.75,
17.42975628,
25.45753518,
39.4747319,
54.34180513,
74.18429623,
111.96497569,
149.7556358,
193.40156150
],
[
133.875,
34.916667,
18.74884051,
29.74891187,
52.45525549,
76.62826712,
106.62633232,
153.97343434,
195.1406155,
240.94306944
],
[
133.875,
35.083333,
20.3307649,
39.27920443,
85.48343625,
140.46528398,
209.53000979,
313.56784295,
399.34463196,
490.88209242
],
[
133.875,
35.25,
25.85011259,
53.89788039,
115.3183553,
177.81229271,
249.62898408,
354.53359456,
440.57339828,
532.60511171
],
[
133.125,
35.416667,
25.71115422,
53.92000396,
114.51284875,
176.13805458,
247.36258831,
351.99729931,
438.10266093,
530.37154288
],
[
133.125,
35.583333,
19.34471741,
39.30298266,
88.01403138,
146.17095282,
218.28703325,
325.53450059,
413.22204181,
506.45920796
],
[
133.125,
35.75,
14.46635631,
25.94949939,
49.47686632,
74.57977187,
105.75159702,
156.56599414,
202.5919404,
255.37193293
],
[
133.125,
35.916667,
10.19928434,
17.61280464,
30.37888666,
44.01660875,
61.42691724,
93.37048137,
126.96721346,
171.74067294
],
[
133.375,
35.416667,
26.40440624,
55.09796774,
115.58865742,
176.88656397,
247.82234761,
352.17804895,
438.10908179,
530.20408462
],
[
133.375,
35.583333,
20.41468629,
42.14046722,
94.26148797,
154.12080393,
226.38578061,
332.96772251,
420.14877373,
513.10037619
],
[
133.375,
35.75,
15.43169867,
27.83856589,
54.15281687,
82.23504283,
117.51247156,
174.77559575,
225.97453502,
283.67686531
],
[
133.375,
35.916667,
11.06621696,
18.73136605,
32.84969193,
47.30283242,
65.99167425,
99.30350069,
133.64919737,
178.17868619
],
[
133.625,
35.416667,
27.07195473,
56.2414061,
116.93610049,
178.24362709,
249.07245317,
353.213633,
439.00292851,
530.99546537
],
[
133.625,
35.583333,
21.90498839,
45.63977906,
102.38376992,
164.93351316,
237.99392075,
344.55791425,
431.64067157,
524.54505758
],
[
133.625,
35.75,
16.54125618,
30.30639863,
61.1752461,
94.6889005,
136.13480351,
201.3663921,
257.87549535,
320.31303632
],
[
133.625,
35.916667,
11.97894869,
20.04249391,
35.99404579,
51.91609535,
72.4080485,
108.28159137,
144.01713466,
188.85055766
],
[
133.875,
35.416667,
27.69613208,
57.36010761,
118.61050213,
180.55280594,
252.42240868,
358.53411643,
446.27463987,
540.33902172
],
[
133.875,
35.583333,
23.40435676,
48.85764131,
108.84026451,
172.3502427,
245.51589572,
352.04717008,
439.13079538,
532.09960005
],
[
133.875,
35.75,
17.58519311,
33.17690556,
68.34627468,
108.66718375,
160.64213325,
243.60322611,
314.7198972,
392.14426433
],
[
133.875,
35.916667,
12.97563101,
22.00597749,
39.54352962,
57.70179208,
80.44746696,
119.48123981,
157.16513962,
203.07665923
],
[
133.125,
36.083333,
8.61919974,
12.8773177,
21.51591701,
31.04041948,
44.57917882,
71.75881875,
105.14724073,
154.24121205
],
[
133.125,
36.25,
7.486338,
9.73995029,
17.06056047,
24.7838858,
36.34519896,
62.94863837,
98.74488575,
151.33534673
],
[
133.125,
36.416667,
6.68581925,
8.6984514,
14.04252154,
20.05230539,
31.10679623,
58.90181052,
97.06366994,
150.87698310
],
[
133.125,
36.583333,
5.03112697,
6.54564711,
8.54773382,
10.47773952,
23.23779658,
55.30305245,
95.46092785,
150.15011529
],
[
133.375,
36.083333,
8.9451006,
13.8062118,
23.08591588,
33.18608386,
47.14569396,
75.04153574,
107.93452082,
155.91283535
],
[
133.375,
36.25,
7.72542256,
10.12772733,
17.82608972,
25.89745197,
37.57932076,
64.14138425,
99.33534203,
151.53054137
],
[
133.375,
36.416667,
6.87409034,
8.94339773,
14.78694576,
21.20187832,
32.29414357,
59.58873115,
97.37135676,
150.97370617
],
[
133.375,
36.583333,
5.10358585,
6.63991828,
8.67083928,
11.55475901,
24.65296241,
56.58890338,
96.36632274,
150.66893854
],
[
133.625,
36.083333,
9.27656179,
14.75685193,
24.72817328,
35.41536213,
49.8199222,
78.64694368,
111.59630648,
158.52581683
],
[
133.625,
36.25,
7.99772516,
10.98616825,
18.73042198,
27.31596596,
39.38976818,
66.4851012,
100.99155699,
152.18210955
],
[
133.625,
36.416667,
7.06476453,
9.19147057,
15.48935559,
22.26441641,
33.40438416,
60.28078266,
97.61412858,
151.00284137
],
[
133.625,
36.583333,
6.41840813,
8.3505415,
12.8595108,
18.96657474,
29.43252658,
58.07752276,
96.84515329,
150.82312866
],
[
133.875,
36.083333,
9.5939927,
15.68699138,
26.3572056,
37.64846998,
53.04308955,
82.65285246,
115.77264479,
161.84674814
],
[
133.875,
36.25,
8.24855609,
11.73524343,
19.52046603,
28.47974239,
41.01499768,
68.17764085,
102.36161903,
152.81177596
],
[
133.875,
36.416667,
7.24935836,
9.43163268,
16.13551767,
23.23413953,
34.43594466,
61.06566834,
97.88985012,
151.06140976
],
[
133.875,
36.583333,
6.56738298,
8.54436225,
13.52194252,
19.53583734,
30.173055,
58.58823431,
97.05464315,
150.88478902
],
[
133.125,
36.75,
4.87086751,
6.33714473,
8.27545779,
9.74173501,
19.06275359,
47.84091019,
87.97562492,
144.43105197
],
[
133.125,
36.916667,
4.66730854,
6.07230841,
7.9296172,
9.33461707,
15.10499348,
33.63519904,
59.69382684,
100.50704498
],
[
133.375,
36.75,
4.96782625,
6.46329096,
8.44018778,
9.9356525,
21.42332762,
53.01003115,
93.61777941,
148.95365896
],
[
133.375,
36.916667,
4.78467506,
6.22500577,
8.1290194,
9.56935011,
17.30337717,
41.16136802,
77.01388052,
132.10885539
],
[
133.625,
36.75,
5.05295796,
6.57404988,
8.58482401,
10.79992767,
23.53378063,
55.516469,
95.59990142,
150.22087064
],
[
133.625,
36.916667,
4.89224546,
6.36495809,
8.31177828,
9.78449091,
19.35329679,
48.63461229,
89.11522276,
145.52932942
],
[
133.875,
36.75,
5.12430201,
6.66687063,
8.70603542,
11.83207805,
24.84595715,
56.6679842,
96.38803121,
150.65330084
],
[
133.875,
36.916667,
4.98817769,
6.4897688,
8.47476427,
9.97635538,
21.75819669,
53.34182977,
93.8708964,
149.10466319
],
[
134.125,
32.416667,
30.78261989,
55.04308106,
121.91281075,
251.97360809,
481.15186367,
758.7863971,
959.18827137,
1161.15431221
],
[
134.125,
32.583333,
42.55338832,
84.99942554,
219.18602925,
406.74977949,
628.26414768,
922.94099419,
1148.00442077,
1378.51653665
],
[
134.375,
32.583333,
43.37433309,
78.42932456,
180.11214653,
374.60214278,
645.46910192,
980.09836328,
1227.75793829,
1479.14304538
],
[
134.625,
32.583333,
45.57539104,
79.56878945,
177.40524686,
379.08492548,
657.12840702,
996.92092056,
1248.19540696,
1503.14651853
],
[
134.875,
32.583333,
45.71738283,
76.82949446,
150.5594422,
284.99246665,
517.05859203,
808.01973355,
1019.72587404,
1233.38320977
],
[
134.125,
32.75,
51.43227043,
95.82735923,
202.35849686,
348.31680767,
535.23592109,
787.35391279,
979.58413841,
1176.49508076
],
[
134.125,
32.916667,
51.62792545,
87.6784504,
172.9353686,
298.60180221,
462.05211358,
680.43455951,
846.46971778,
1016.53495974
],
[
134.125,
33.083333,
48.54256676,
78.32774569,
149.06919653,
257.88005956,
401.36410959,
592.28632722,
737.2584478,
885.59152280
],
[
134.125,
33.25,
45.45969294,
71.32869144,
132.01853346,
223.75180748,
348.60066502,
516.84288267,
644.59142709,
775.31744982
],
[
134.375,
32.75,
52.87816473,
95.55965075,
201.05123669,
352.02138079,
556.78590382,
833.27337529,
1042.33309093,
1255.45017738
],
[
134.375,
32.916667,
53.54975165,
88.35197094,
170.55182079,
299.7802561,
478.31611833,
714.80363138,
893.05515388,
1075.00862253
],
[
134.375,
33.083333,
49.92632684,
78.77967101,
147.05835512,
255.86864401,
403.65169555,
599.79620036,
748.23548177,
899.93349406
],
[
134.375,
33.25,
46.81544451,
72.17611756,
130.88603315,
218.68041789,
338.64297081,
501.5048853,
625.55565819,
752.45392909
],
[
134.625,
32.75,
54.89163983,
97.62451777,
203.28904785,
352.28522582,
549.57318304,
816.18919879,
1018.61148312,
1225.38362720
],
[
134.625,
32.916667,
55.73599194,
91.26758394,
175.08695108,
300.10225589,
464.55140706,
684.64149627,
851.96314033,
1023.36785957
],
[
134.625,
33.083333,
52.08953614,
81.84112217,
152.33069589,
258.28562903,
395.63483982,
579.91805859,
720.57310797,
864.75590225
],
[
134.625,
33.25,
48.49587937,
74.83246414,
135.12617217,
221.74290215,
336.40230086,
493.17039272,
613.35399792,
736.66578641
],
[
134.875,
32.75,
54.76240829,
98.74621811,
226.10003034,
405.13910697,
619.8833897,
906.69119605,
1126.02789465,
1350.91356743
],
[
134.875,
32.916667,
58.11074195,
98.48452859,
196.32153284,
337.50014443,
514.8235338,
751.5092072,
932.14424184,
1117.39476776
],
[
134.875,
33.083333,
54.8518167,
87.62848094,
167.11229563,
285.86871567,
434.25758745,
631.95609639,
783.03073321,
938.05027212
],
[
134.875,
33.25,
51.52688424,
80.26380168,
147.1910658,
242.96261588,
366.46515237,
533.95497899,
662.34100175,
794.15106505
],
[
134.125,
33.416667,
41.88568803,
64.9317186,
117.63308087,
195.52843465,
304.18094404,
453.20981422,
566.70304953,
682.77032242
],
[
134.125,
33.583333,
39.19467829,
59.97540184,
107.40247301,
175.78405664,
270.91396216,
402.04251293,
502.17049952,
604.76348128
],
[
134.125,
33.75,
37.90214135,
57.78629494,
102.15378439,
164.64931802,
250.35894494,
368.71270976,
459.19889185,
551.97002549
],
[
134.125,
33.916667,
37.94436312,
60.12130831,
108.47453665,
167.31195866,
243.21890812,
357.51731053,
452.80433663,
556.31850344
],
[
134.375,
33.416667,
43.47620295,
66.371416,
118.02455245,
189.78631738,
287.0182545,
422.87803541,
527.48057632,
634.80740334
],
[
134.375,
33.583333,
40.86462916,
62.17893856,
109.08856719,
170.54972322,
251.07836488,
364.93276522,
453.47148267,
544.81033923
],
[
134.375,
33.75,
39.31210644,
59.51691882,
103.41933379,
158.4681074,
229.54990807,
330.69658122,
409.70397032,
491.32308972
],
[
134.375,
33.916667,
38.72676609,
59.29132446,
102.47111613,
153.45853039,
219.31392197,
320.30757107,
405.04928566,
496.95453770
],
[
134.625,
33.416667,
44.99345576,
68.32795083,
120.6886729,
192.08316781,
287.93435176,
422.61268041,
526.62061888,
633.43681518
],
[
134.625,
33.583333,
42.52864844,
64.0326664,
110.8228551,
171.99918371,
253.08192652,
368.87062189,
459.07072847,
552.12188786
],
[
134.625,
33.75,
41.43889432,
61.92531062,
105.1471171,
158.73346088,
228.44704113,
328.43053149,
406.69590994,
487.56466068
],
[
134.625,
33.916667,
41.21926973,
61.49019059,
102.28924472,
149.24212242,
209.28542115,
299.30565368,
372.83905996,
450.77418908
],
[
134.875,
33.416667,
48.03678886,
73.81895229,
131.26285901,
208.32724978,
310.36788089,
453.66684813,
564.33637182,
678.06494378
],
[
134.875,
33.583333,
46.1533266,
69.53333725,
120.2996643,
184.46048328,
269.15151031,
391.57147864,
487.33439854,
586.21576286
],
[
134.875,
33.75,
48.48126281,
74.79382696,
127.64196174,
185.13602945,
254.57758006,
355.79651873,
436.91673484,
521.84849747
],
[
134.875,
33.916667,
53.27520995,
86.16295585,
150.16262354,
210.68364168,
276.74304575,
370.30575821,
445.58795395,
525.23197398
],
[
134.125,
34.083333,
35.35688695,
60.54313684,
133.09668921,
219.69390109,
330.72486455,
519.85779361,
686.29032847,
864.66578768
],
[
134.125,
34.25,
29.56024049,
48.0428005,
87.50325336,
131.3330525,
187.29715644,
283.5950254,
377.29171383,
487.58501211
],
[
134.125,
34.416667,
24.20275924,
36.87214324,
64.25990514,
96.96417946,
139.44182256,
209.1859288,
272.68725576,
345.21099937
],
[
134.125,
34.583333,
18.63181015,
27.11791704,
42.42822255,
58.83618946,
81.92282392,
130.10139145,
183.45300404,
245.16024185
],
[
134.375,
34.083333,
37.14453137,
59.9910165,
114.92111637,
176.90457092,
253.94489911,
383.51472415,
506.49580359,
648.23641553
],
[
134.375,
34.25,
32.47463442,
51.65849972,
92.51958928,
135.55777065,
189.2043103,
284.29245683,
381.52686472,
498.62924277
],
[
134.375,
34.416667,
26.96673984,
40.78146544,
70.38902735,
103.67729204,
145.42570912,
215.0924612,
280.89762849,
357.97523626
],
[
134.375,
34.583333,
20.43616731,
29.94638987,
48.02707406,
67.78385933,
95.85827315,
150.2127593,
204.05142569,
264.87218208
],
[
134.625,
34.083333,
40.45940136,
62.58842548,
107.77796666,
155.91856232,
214.96142054,
311.3075081,
401.38487568,
508.06043289
],
[
134.625,
34.25,
36.97110409,
58.28954397,
103.71287217,
151.41413034,
210.13072888,
308.4413609,
402.19683021,
513.02031852
],
[
134.625,
34.416667,
28.52918475,
43.03898113,
70.19140559,
100.42474375,
143.39566744,
223.24805506,
296.88068636,
377.44288215
],
[
134.625,
34.583333,
25.05114631,
37.0511077,
59.36913053,
84.83559435,
121.85124496,
189.17775072,
247.80923652,
309.99416589
],
[
134.875,
34.083333,
55.05139478,
87.69931979,
143.01608996,
192.5870289,
248.54711078,
333.21946486,
407.09935125,
491.09528403
],
[
134.875,
34.25,
49.35574459,
82.89536889,
147.59325987,
211.1797208,
288.48370107,
415.70076843,
532.32733674,
664.74065123
],
[
134.875,
34.416667,
39.01151973,
64.62315324,
122.94817777,
190.43600502,
279.53394607,
428.81056619,
561.89714618,
709.13552734
],
[
134.875,
34.583333,
30.75329954,
49.20870424,
88.50548874,
134.5278685,
196.4740704,
299.82477789,
390.62215476,
489.98154338
],
[
134.125,
34.75,
17.9634745,
26.38980926,
41.40110346,
57.39490734,
78.94709529,
120.35122422,
162.1189614,
210.23622647
],
[
134.125,
34.916667,
19.49424043,
30.78474187,
51.98679734,
73.55416966,
100.54880075,
145.53915421,
186.69714836,
234.34158186
],
[
134.125,
35.083333,
22.60853168,
39.96126924,
79.44627329,
124.81203283,
183.38154052,
276.85051142,
356.80089301,
443.58839552
],
[
134.125,
35.25,
26.31963507,
53.53333961,
114.43402556,
177.74414037,
250.83722287,
357.547817,
444.99622223,
538.31437704
],
[
134.375,
34.75,
19.74265636,
29.65249049,
48.22119457,
67.93168966,
94.5090284,
142.05043709,
186.85088323,
237.62888932
],
[
134.375,
34.916667,
21.52236556,
35.50818752,
63.13061159,
91.75686001,
127.05454366,
184.92279852,
238.97479006,
303.58179103
],
[
134.375,
35.083333,
24.93551007,
45.61974304,
94.39296449,
152.08147299,
226.64845992,
347.34847355,
455.63797883,
579.73445364
],
[
134.375,
35.25,
28.51239263,
56.79308583,
117.97707506,
181.09997288,
254.19979768,
361.50529785,
449.83679498,
544.25342423
],
[
134.625,
34.75,
24.29572033,
37.6538461,
64.37607749,
93.46264738,
130.65966812,
190.37607316,
242.35283039,
299.90997154
],
[
134.625,
34.916667,
25.51669201,
45.4548664,
93.48586503,
147.33020575,
214.24799344,
320.11674966,
412.68498939,
515.70982644
],
[
134.625,
35.083333,
28.76148136,
56.39449614,
118.58708712,
182.52691336,
256.95858474,
367.85614051,
460.26304048,
560.14507952
],
[
134.625,
35.25,
31.85384035,
60.83220041,
121.57648889,
183.53030859,
255.20376809,
360.46344178,
447.08973161,
539.68793541
],
[
134.875,
34.75,
29.63601692,
50.28058101,
97.00579534,
150.44715553,
216.39505265,
315.96752776,
398.9333343,
488.30829244
],
[
134.875,
34.916667,
30.73253224,
57.75354044,
122.39856121,
190.08408816,
268.37052608,
384.71994841,
482.44507787,
589.27840794
],
[
134.875,
35.083333,
33.01638792,
62.74632341,
123.9784901,
185.44488918,
256.66706972,
361.78208813,
448.51002478,
541.31086269
],
[
134.875,
35.25,
34.0259809,
63.33904566,
123.73852829,
184.91459807,
255.95797026,
360.99236905,
447.84457485,
540.92276311
],
[
134.125,
35.416667,
28.71654217,
59.00314763,
122.50727181,
186.7636609,
261.10142357,
371.67037781,
464.17693554,
564.94338710
],
[
134.125,
35.583333,
25.31240908,
53.19101591,
115.26062357,
178.25742332,
250.88204676,
357.50889583,
445.33323985,
539.30826444
],
[
134.125,
35.75,
18.95467888,
37.0109752,
78.56128008,
127.65382834,
191.07686812,
289.73951009,
372.0909657,
460.30570972
],
[
134.125,
35.916667,
14.18286747,
24.48987882,
44.91771091,
65.99097556,
92.26445517,
136.0345051,
176.80946423,
224.98968144
],
[
134.375,
35.416667,
30.19434098,
60.1692665,
122.01670805,
184.47416558,
256.81362642,
363.94237391,
452.84788689,
548.47989373
],
[
134.375,
35.583333,
27.2901305,
56.25699563,
118.17907297,
180.69204486,
252.98035995,
359.64812425,
447.94739302,
542.67383412
],
[
134.375,
35.75,
20.60070519,
41.18324561,
90.54542951,
147.99922876,
218.81505451,
324.70293401,
411.61789072,
504.14688520
],
[
134.375,
35.916667,
15.50282369,
27.26718456,
51.65866262,
77.32896271,
108.84629803,
159.65832269,
205.45241849,
257.63215314
],
[
134.625,
35.416667,
32.04566516,
61.43710823,
122.41562185,
184.4508608,
256.45023407,
363.02145243,
451.40726354,
546.44764645
],
[
134.625,
35.583333,
28.91192551,
57.97676215,
119.05094741,
180.82728277,
251.92068102,
356.12511921,
441.87668599,
533.75306751
],
[
134.625,
35.75,
22.67661529,
45.31476733,
100.40581473,
162.71898526,
235.90157354,
342.66077141,
429.93937239,
523.04092426
],
[
134.625,
35.916667,
16.83971859,
29.97764702,
58.88802481,
90.02942645,
128.90770487,
190.79726553,
245.12604753,
305.62615655
],
[
134.875,
35.416667,
33.68989825,
63.82023956,
125.89799014,
188.68858765,
261.71370939,
370.38010347,
460.69034562,
558.01588254
],
[
134.875,
35.583333,
31.15766555,
61.43131893,
123.33318128,
185.51166993,
257.34606618,
363.10462896,
450.22248726,
543.37339776
],
[
134.875,
35.75,
25.54473359,
50.59467806,
110.47013214,
174.2558838,
247.70907299,
354.55694682,
441.8741505,
535.02441623
],
[
134.875,
35.916667,
19.01737914,
34.66535852,
68.64266169,
107.54714154,
158.03213377,
239.58532394,
310.15558369,
387.16772280
],
[
134.125,
36.083333,
10.04342248,
17.01098479,
28.76275569,
41.21417524,
57.81748621,
88.60474498,
121.88483959,
167.07293602
],
[
134.125,
36.25,
8.55252474,
12.61586923,
20.78895382,
29.94620116,
43.3047388,
70.46997474,
104.31223606,
153.83855610
],
[
134.125,
36.416667,
7.46722466,
9.71508327,
16.88477124,
24.37115151,
35.69260823,
62.14689465,
98.34617866,
151.21872451
],
[
134.125,
36.583333,
6.73050596,
8.75659013,
14.20381561,
20.24845518,
31.2524984,
59.08904154,
97.24526374,
150.96649743
],
[
134.375,
36.083333,
11.08751242,
18.4727916,
31.8698334,
45.85125285,
63.91573713,
96.55852313,
130.33706187,
174.85623383
],
[
134.375,
36.25,
8.94903982,
13.76178034,
22.86403958,
32.8114798,
46.66199896,
74.39047701,
107.32765189,
155.47464049
],
[
134.375,
36.416667,
7.74895025,
10.20318052,
17.87968432,
25.92998736,
37.52716949,
63.91516041,
99.12560405,
151.40510789
],
[
134.375,
36.583333,
6.91118508,
8.99165909,
14.92691967,
21.4082443,
32.44711009,
59.64431641,
97.38502036,
150.94634258
],
[
134.625,
36.083333,
12.20436073,
20.0557459,
35.52113417,
50.92940915,
70.86047196,
105.79382274,
140.5169614,
184.77273922
],
[
134.625,
36.25,
9.35435829,
14.9356119,
24.97022973,
35.72486794,
50.14402391,
78.6121607,
111.0139584,
157.71550478
],
[
134.625,
36.416667,
8.03613504,
11.10653484,
18.87933252,
27.49095515,
39.43226179,
66.03041581,
100.29355548,
151.72127316
],
[
134.875,
36.083333,
14.67543921,
23.85242634,
41.24496692,
59.09873003,
81.59471535,
119.80100246,
156.67851534,
201.71765180
],
[
134.875,
36.25,
11.13066488,
17.62234804,
28.87610497,
40.74313465,
56.65324312,
85.95112996,
117.9586401,
162.80545267
],
[
134.875,
36.416667,
9.18437996,
14.06414415,
22.57316669,
31.87714476,
44.98099179,
71.26695244,
104.09207557,
153.28310194
],
[
134.125,
36.75,
5.18002456,
6.73936733,
8.80070635,
12.57774005,
25.62866788,
57.27059501,
96.76837067,
150.85663942
],
[
135.125,
32.583333,
42.81734262,
70.73069951,
130.68497667,
231.74396758,
418.35814945,
657.84219107,
831.63806405,
1006.83768822
],
[
135.375,
32.583333,
39.16797408,
67.75749286,
127.39366471,
213.04849828,
353.56465301,
548.43165599,
692.79993576,
838.88984979
],
[
135.625,
32.583333,
31.83466852,
58.75716607,
121.63080099,
202.35566906,
312.98580012,
469.8623512,
589.99351629,
712.80168742
],
[
135.875,
32.583333,
24.30063183,
43.25054924,
98.90630659,
180.95590562,
280.07849972,
412.59232024,
514.22829251,
618.63915083
],
[
135.125,
32.75,
51.83828304,
90.97036491,
210.26892416,
423.50495372,
675.17199459,
995.49840735,
1237.52089566,
1484.89489691
],
[
135.125,
32.916667,
60.0848592,
106.12502541,
218.3529814,
373.63872885,
564.82597168,
821.00825842,
1017.10060368,
1218.29625589
],
[
135.125,
33.083333,
58.53995755,
96.33326915,
186.29489915,
315.07718498,
474.02993186,
686.5548045,
849.28458937,
1016.59690982
],
[
135.125,
33.25,
54.08374621,
85.62752733,
160.90159791,
267.03804397,
399.1644291,
577.97232083,
715.35467297,
856.56259710
],
[
135.375,
32.75,
48.81396874,
84.1244665,
169.86948384,
320.33597071,
555.10284058,
853.91381916,
1074.08956696,
1296.94731103
],
[
135.375,
32.916667,
57.44249627,
105.73430983,
234.62302186,
406.93576677,
614.66382186,
893.95067269,
1108.06729479,
1327.94622810
],
[
135.375,
33.083333,
59.54713396,
101.90563316,
202.59925441,
340.37945908,
511.19341419,
741.42771414,
917.96099441,
1099.17580876
],
[
135.375,
33.25,
56.52032188,
91.48733739,
176.02789771,
290.76657576,
431.17252938,
622.59441699,
770.2162522,
922.12942491
],
[
135.625,
32.75,
41.2615231,
71.95627203,
141.70689614,
254.13785131,
442.52983494,
690.04876224,
871.39897532,
1054.63827067
],
[
135.625,
32.916667,
50.42098808,
94.86863175,
228.35511192,
429.79506881,
666.32438906,
975.42378181,
1210.73803068,
1452.01809239
],
[
135.625,
33.083333,
57.41381363,
104.7283961,
218.23768656,
365.25860834,
548.04768068,
798.05735064,
990.2425608,
1187.60356508
],
[
135.625,
33.25,
56.95220164,
95.35470988,
188.05196614,
313.07438522,
464.01987944,
669.69163983,
828.57602825,
992.17760215
],
[
135.875,
32.75,
31.27820563,
55.74592618,
120.23971846,
229.94519955,
382.33139464,
580.89456638,
729.60569375,
880.94659778
],
[
135.875,
32.916667,
39.97091924,
75.74788746,
182.35482626,
359.8494942,
596.94464854,
905.85883476,
1137.05163997,
1372.04022839
],
[
135.875,
33.083333,
48.35364676,
95.54111164,
225.9890513,
391.87389609,
591.00050883,
862.49684654,
1071.6916681,
1286.50164610
],
[
135.875,
33.25,
51.64422377,
90.06999113,
188.57562123,
334.67484087,
506.51110804,
731.58517775,
903.48589256,
1080.22549834
],
[
135.125,
33.416667,
49.87751933,
77.26495283,
140.7743839,
227.259348,
337.09440843,
489.1434615,
606.69538428,
727.74319459
],
[
135.125,
33.583333,
48.58605261,
73.57772597,
128.57349223,
199.39797705,
290.62646029,
420.27338493,
521.66252774,
626.29523450
],
[
135.125,
33.75,
55.18922799,
88.65867939,
153.97967943,
217.97180696,
290.46766574,
394.75762804,
478.86847006,
567.51736560
],
[
135.125,
33.916667,
72.82250909,
135.88833992,
236.11516386,
315.77311039,
398.7102947,
514.860709,
608.16628789,
706.88202962
],
[
135.375,
33.416667,
52.81923426,
83.02092967,
155.3659588,
251.323205,
367.76018583,
528.38155299,
653.1060754,
781.97794726
],
[
135.375,
33.583333,
49.60400541,
75.9582908,
137.44150829,
219.20448239,
318.74270694,
456.06171078,
563.03821208,
673.62519675
],
[
135.375,
33.75,
51.32320297,
79.25466033,
139.27536787,
208.76708528,
291.06737505,
407.26441116,
498.97828489,
594.43414043
],
[
135.375,
33.916667,
59.77956623,
101.91046077,
184.78916697,
258.84352888,
337.17492138,
446.35155818,
533.82547282,
625.81498833
],
[
135.625,
33.416667,
54.36309902,
87.34371413,
167.68225417,
275.81402493,
402.73200597,
574.56858631,
707.6272078,
845.02923632
],
[
135.625,
33.583333,
50.48475468,
78.96648544,
148.65591889,
243.53981371,
353.84300354,
501.86536106,
616.28941396,
734.31513976
],
[
135.625,
33.75,
47.13633172,
71.65010792,
131.39034696,
214.98773332,
312.68804887,
442.99429223,
543.37576779,
646.78013541
],
[
135.625,
33.916667,
45.65319812,
68.60124849,
121.52201545,
193.29975389,
278.74276035,
393.54725837,
482.07567508,
573.47157610
],
[
135.875,
33.416667,
51.26120309,
84.0162472,
168.81871761,
298.45259153,
445.68939458,
636.35009798,
781.81576611,
931.21766856
],
[
135.875,
33.583333,
49.93703475,
79.95756127,
156.37070208,
266.52559909,
391.00575591,
553.66879098,
678.22486251,
806.22645035
],
[
135.875,
33.75,
47.07301711,
73.7068159,
140.40676916,
234.5259894,
340.93236924,
480.88381915,
588.34535951,
698.86333768
],
[
135.875,
33.916667,
43.19076584,
66.36200021,
124.07394265,
205.48193836,
298.03013897,
420.12101083,
514.06655487,
610.79812182
],
[
135.125,
34.083333,
81.46212822,
143.84182425,
238.14062759,
314.97273079,
396.57422233,
512.65859991,
606.88422386,
707.19726732
],
[
135.125,
34.25,
67.25863916,
120.47840913,
210.0508923,
289.26920433,
379.96892773,
522.31849371,
648.82737766,
793.49592433
],
[
135.125,
34.416667,
49.44867421,
82.46522997,
142.17780128,
198.91633665,
265.45220669,
367.51361003,
454.64900807,
549.76512775
],
[
135.125,
34.583333,
36.42418704,
61.28002645,
119.28917787,
186.59692742,
270.33433096,
399.06222296,
507.73575666,
625.00242927
],
[
135.375,
34.083333,
68.63487986,
122.36778826,
213.69273794,
289.68690165,
370.04148566,
483.42549672,
575.38585566,
672.76403173
],
[
135.375,
34.25,
64.06050051,
121.25274839,
218.14225567,
299.0013911,
386.37052036,
513.47226146,
619.33049641,
734.41533051
],
[
135.375,
34.416667,
49.73226384,
85.7046575,
148.83132889,
205.56052792,
270.44938918,
371.17769848,
459.93617962,
560.11665350
],
[
135.375,
34.583333,
42.20815256,
71.76219147,
129.88378229,
186.0418847,
251.7485299,
351.86563126,
436.56152466,
528.57195361
],
[
135.625,
34.083333,
45.72939243,
69.79149467,
120.79187565,
180.12572598,
250.17474613,
347.9411768,
424.80133313,
504.72749167
],
[
135.625,
34.25,
45.34079783,
73.49734293,
129.65510153,
183.64668417,
243.6425159,
331.11546303,
404.49116272,
485.57381201
],
[
135.625,
34.416667,
42.92582231,
73.46130398,
138.17395122,
199.77770755,
269.86704742,
376.72192841,
469.83277334,
574.36243817
],
[
135.625,
34.583333,
40.78746271,
71.3002407,
134.33158699,
195.19883633,
267.27962629,
380.78553169,
481.02110521,
593.94365232
],
[
135.875,
34.083333,
40.02460242,
60.965617,
111.50550973,
180.8004879,
260.87021216,
367.6248573,
450.01208729,
535.15531676
],
[
135.875,
34.25,
38.80197806,
59.62910797,
107.53566478,
164.23068774,
229.13671711,
318.92074478,
389.77511516,
463.72657941
],
[
135.875,
34.416667,
38.77041992,
63.88401734,
121.84719333,
180.08106675,
244.0150814,
336.0952018,
412.22172701,
494.47576215
],
[
135.875,
34.583333,
39.37204798,
68.99828185,
132.71643094,
193.09401718,
261.79110926,
366.10970371,
455.88326665,
555.61644781
],
[
135.125,
34.75,
34.44894894,
62.67314347,
131.27495413,
204.42180771,
289.91142251,
419.52652843,
530.93722485,
653.75678472
],
[
135.125,
34.916667,
35.24675158,
65.39616729,
129.06719278,
192.75914854,
266.10783643,
374.07331873,
462.98595266,
558.04681895
],
[
135.125,
35.083333,
35.5949281,
64.78028836,
125.32983723,
185.95913645,
255.89398424,
359.01481334,
444.25224316,
535.72466946
],
[
135.125,
35.25,
34.93378504,
63.94745819,
123.44060532,
183.53343527,
253.3315595,
356.58750715,
441.99434577,
533.70342407
],
[
135.375,
34.75,
36.32672175,
64.89687248,
128.8684128,
194.30871495,
271.35440734,
389.99605278,
492.39715274,
605.45482144
],
[
135.375,
34.916667,
36.67121679,
67.24212871,
132.09452779,
196.89230477,
271.8211717,
382.97738545,
475.3112546,
574.67572595
],
[
135.375,
35.083333,
36.82552034,
65.93789683,
126.65751715,
187.78245264,
258.16373783,
361.70127771,
447.09909096,
538.60329188
],
[
135.375,
35.25,
35.96841164,
64.51205561,
123.6345033,
183.40850248,
252.82531788,
355.6370736,
440.76482224,
532.27273195
],
[
135.625,
34.75,
38.94905274,
68.75578779,
129.9585146,
191.01535867,
263.96239471,
377.4906531,
475.89061937,
585.18507675
],
[
135.625,
34.916667,
36.67789764,
65.76054907,
131.34581252,
200.02457808,
279.74226208,
398.41547053,
497.76883821,
605.58041595
],
[
135.625,
35.083333,
36.6410903,
65.98978991,
129.18484731,
194.58105807,
270.90688502,
384.94335085,
481.03859832,
586.58313259
],
[
135.625,
35.25,
36.74132128,
65.48521131,
125.27218564,
186.20290222,
257.04506164,
361.50766208,
447.58334236,
539.65469398
],
[
135.875,
34.75,
38.06790934,
66.13499328,
125.04020801,
184.39667607,
254.7596459,
362.55853338,
454.22471401,
554.03286424
],
[
135.875,
34.916667,
35.53301725,
60.93989854,
116.43293395,
176.59951357,
250.19899751,
363.19711474,
458.85658986,
562.86767218
],
[
135.875,
35.083333,
36.19001773,
62.92773693,
121.76795385,
185.77442012,
264.15503259,
386.59102377,
493.39532327,
613.28918556
],
[
135.875,
35.25,
36.38846318,
63.38768961,
121.23113556,
182.05342614,
255.67212898,
370.85480525,
471.58916354,
584.79295643
],
[
135.125,
35.416667,
34.98909094,
64.90981498,
125.74347834,
187.09107942,
258.43466759,
363.89223752,
450.82807499,
543.78020070
],
[
135.125,
35.583333,
33.39828022,
64.20203755,
130.82683695,
200.36504711,
282.15734547,
405.27220318,
509.20471816,
622.40840633
],
[
135.125,
35.75,
28.65418475,
56.56824941,
117.69563956,
180.5764605,
253.31662642,
359.80542223,
447.23414693,
540.52474965
],
[
135.125,
35.916667,
22.39941296,
41.32589896,
85.00532622,
135.56069028,
199.78801351,
298.83782084,
381.48066973,
470.11140510
],
[
135.375,
35.416667,
35.40910161,
64.06112015,
122.78370935,
182.47049643,
252.11515371,
355.31113632,
440.64683261,
532.27042609
],
[
135.375,
35.583333,
34.68918427,
63.66558008,
122.77288117,
182.95200021,
253.39780616,
357.86511111,
444.23825113,
536.79547556
],
[
135.375,
35.75,
31.60787395,
59.99831522,
119.46219082,
179.98450621,
250.41713722,
354.34079038,
440.06224885,
532.01968466
],
[
135.375,
35.916667,
26.56283684,
50.89850179,
108.38840539,
169.96678729,
241.90265449,
347.46484673,
434.03309159,
526.54868152
],
[
135.625,
35.416667,
36.27588601,
64.61197641,
123.4239373,
183.2217188,
252.86964585,
355.97561505,
441.25158123,
532.83801047
],
[
135.625,
35.583333,
35.47923884,
63.96921204,
122.68270108,
182.24682102,
251.68435506,
354.61090742,
439.78596384,
531.31240896
],
[
135.625,
35.75,
34.14761555,
62.70306767,
121.71874202,
181.41476244,
250.93467174,
354.01672046,
439.37574772,
531.13324440
],
[
135.625,
35.916667,
30.82010921,
59.14059069,
119.0623493,
179.66800806,
249.92059258,
353.57899586,
439.16074714,
531.02500064
],
[
135.875,
35.416667,
36.7087578,
63.65339615,
120.48016961,
180.26892978,
251.79960406,
359.85968971,
450.5343427,
548.42641124
],
[
135.875,
35.583333,
36.88347087,
64.82159612,
124.12970416,
185.67521559,
257.3082439,
362.74148777,
449.46428247,
542.10317648
],
[
135.875,
35.75,
36.3808698,
65.67661746,
126.48193079,
187.72931946,
258.27399783,
362.13157168,
447.85841975,
539.75045348
],
[
135.875,
35.916667,
35.05276518,
64.55540107,
125.80577097,
187.38401615,
258.4948454,
363.64488154,
450.71181373,
544.19280999
],
[
135.125,
36.083333,
17.11381922,
28.66175421,
51.85953893,
75.65522985,
104.89239262,
152.486039,
195.88482006,
246.19916856
],
[
135.125,
36.25,
13.16546798,
20.58242654,
35.07071098,
49.44674024,
68.17210754,
101.08895405,
134.70788065,
178.38601572
],
[
135.125,
36.416667,
10.20770057,
16.39278589,
26.70172532,
37.62517505,
52.38091177,
80.57952727,
112.77923967,
158.87137118
],
[
135.375,
36.083333,
20.57867425,
37.48841535,
75.11295657,
118.11815806,
174.22186231,
264.93202407,
342.91878022,
427.62663148
],
[
135.375,
36.25,
16.32415856,
27.02292501,
48.41170996,
70.50086835,
97.88873518,
142.72335377,
184.07605685,
232.66494753
],
[
135.375,
36.416667,
12.77343367,
19.91804155,
34.1447586,
48.42993618,
67.14142047,
100.5030784,
134.88486229,
179.33010602
],
[
135.625,
36.083333,
25.97070643,
49.57265043,
106.69415044,
168.63019082,
240.94192447,
346.77480142,
433.40644486,
525.91343268
],
[
135.625,
36.25,
20.41637088,
37.29830905,
74.7641969,
117.59043838,
173.02612522,
261.83056687,
337.95294197,
420.59254746
],
[
135.625,
36.416667,
16.47647614,
27.56127934,
49.99991485,
73.69912347,
103.02785065,
151.20185088,
195.45883995,
246.97074027
],
[
135.625,
36.583333,
13.06216322,
20.65291061,
35.83948326,
51.30450304,
71.71183718,
108.22709581,
145.09758373,
191.45465361
],
[
135.875,
36.083333,
31.96618853,
61.00278936,
121.73651683,
182.94635802,
253.73441934,
358.09861432,
444.36193046,
536.96883167
],
[
135.875,
36.25,
27.1502713,
52.89270546,
113.36081384,
177.12127143,
250.75431566,
358.49054055,
447.15519232,
542.07567988
],
[
135.875,
36.416667,
21.53944413,
40.0546476,
84.54690794,
135.91873137,
200.80916974,
301.14736173,
385.30592669,
475.80879372
],
[
135.875,
36.583333,
17.17768031,
29.39873838,
55.72295035,
83.52927408,
118.11140231,
174.0816522,
224.34638169,
281.44907023
],
[
135.625,
36.75,
10.47649834,
16.92935678,
28.00110634,
39.8488255,
56.47616609,
87.8388725,
122.09657546,
168.29467053
],
[
135.875,
36.75,
13.93456104,
22.40247351,
38.90694743,
56.28197305,
78.5897814,
117.87314448,
156.37698821,
203.57104182
],
[
135.875,
36.916667,
11.37320637,
18.08978556,
30.14212028,
43.5486283,
61.18070304,
94.28426073,
128.92684124,
174.46560092
],
[
135.875,
37.083333,
9.65551387,
15.44989071,
25.48816045,
36.50299996,
51.62259861,
81.19020468,
114.54046174,
161.08787364
],
[
135.875,
37.25,
8.70683233,
13.12196304,
21.96343045,
32.03187017,
46.22371222,
74.47456165,
107.78404825,
156.05687859
],
[
135.875,
37.416667,
8.14621114,
11.4975098,
19.6090654,
29.07985925,
42.57201371,
70.2157287,
104.31261368,
153.96830300
],
[
135.875,
37.583333,
7.6523531,
9.95594092,
18.00370469,
26.70132469,
39.22357859,
66.93750794,
101.64009574,
152.62340314
],
[
136.125,
32.75,
23.73209955,
40.92773363,
99.0068043,
215.20868568,
349.80606015,
516.1173209,
640.89372998,
768.36858591
],
[
136.125,
32.916667,
30.349893,
55.97399209,
133.08851426,
297.47183261,
509.22023207,
762.00817523,
949.12728526,
1139.58917143
],
[
136.125,
33.083333,
38.69755253,
72.7240349,
174.36472603,
362.76733072,
586.66475698,
861.10473465,
1066.0660584,
1274.88340916
],
[
136.125,
33.25,
44.88743292,
79.95452297,
176.89769295,
342.32492321,
528.00962432,
761.19392859,
937.44533609,
1118.13368043
],
[
136.375,
32.916667,
24.20753344,
43.26596125,
109.55553395,
247.44994755,
401.22818873,
590.71083636,
733.83006876,
880.67704422
],
[
136.375,
33.083333,
31.25270061,
60.30669633,
158.44828697,
322.13218877,
517.12339103,
783.62493121,
991.48119533,
1206.46777869
],
[
136.375,
33.25,
39.30301156,
78.50408359,
193.6789389,
343.8807549,
524.07352857,
776.56830892,
973.96939736,
1177.95808724
],
[
136.625,
33.25,
34.13917015,
68.68080941,
174.43063274,
326.22237916,
537.81151774,
836.21487222,
1063.34867963,
1294.88084156
],
[
136.125,
33.416667,
47.25347767,
79.34888513,
166.70938889,
306.3727125,
459.73815746,
655.95480429,
805.65277481,
959.65044112
],
[
136.125,
33.583333,
48.18347808,
78.53866413,
157.75760492,
272.92584652,
400.68802934,
568.05618379,
696.79273202,
829.76437962
],
[
136.125,
33.75,
47.62676219,
76.52351938,
147.9389848,
243.3066491,
350.92818657,
495.14657011,
607.1084269,
723.05914887
],
[
136.125,
33.916667,
45.09261748,
70.91831861,
133.40055491,
214.28552943,
307.0042154,
433.05978742,
531.5097957,
633.56666312
],
[
136.375,
33.416667,
45.14042934,
81.89075318,
177.57272176,
309.61967817,
468.21571778,
686.26289469,
855.51457096,
1030.30350098
],
[
136.375,
33.583333,
46.73398273,
78.91893347,
161.79011689,
276.25768669,
412.58450381,
599.52179573,
744.80963771,
894.79870749
],
[
136.375,
33.75,
47.37468662,
77.67217884,
151.23946465,
247.58930941,
363.15911399,
523.77813635,
649.13803872,
778.99342918
],
[
136.375,
33.916667,
46.79181553,
75.42880628,
140.77106388,
221.79029907,
320.04912743,
458.89599572,
568.22042496,
681.53206561
],
[
136.625,
33.416667,
41.95724981,
83.10536576,
186.2505991,
323.44334508,
508.7975959,
764.45707364,
958.94572404,
1157.81306799
],
[
136.625,
33.583333,
45.80538797,
81.60715241,
168.06122512,
289.7789308,
450.41286507,
668.5652646,
834.57742018,
1004.37032743
],
[
136.625,
33.75,
46.48830128,
77.83154108,
152.76298713,
257.28132223,
393.25042651,
579.11783741,
721.32993213,
867.09331995
],
[
136.625,
33.916667,
46.6079658,
75.96150847,
142.44078579,
230.11524929,
343.73278526,
502.71452555,
625.55630018,
751.74156584
],
[
136.875,
33.416667,
36.56459361,
74.29641528,
178.07551045,
333.51019226,
547.8444241,
835.97064922,
1053.87756815,
1276.19592543
],
[
136.875,
33.583333,
43.50365077,
83.17161185,
175.79066241,
312.3205837,
499.47484072,
746.70857417,
933.03060419,
1123.27326691
],
[
136.875,
33.75,
45.65237587,
79.29894665,
157.81619837,
276.707679,
436.44044264,
647.15471002,
806.39972601,
969.15408879
],
[
136.875,
33.916667,
44.82016652,
73.21824433,
138.83842259,
240.46102876,
376.80232594,
557.37636208,
694.23876664,
834.31215820
],
[
136.125,
34.083333,
41.51285747,
64.46299596,
118.30581948,
187.44017604,
268.28620086,
379.40822579,
466.50002054,
557.04485299
],
[
136.125,
34.25,
38.83142924,
60.16775535,
108.52127543,
166.08187562,
234.16182585,
330.19495119,
406.32723483,
485.81143362
],
[
136.125,
34.416667,
38.43967194,
62.26122865,
115.54545556,
170.29862778,
231.32286458,
318.22162072,
388.74177178,
463.68276648
],
[
136.125,
34.583333,
39.21186662,
67.44291771,
127.94338102,
185.2369063,
248.80875843,
341.71376494,
419.09020831,
502.90850622
],
[
136.375,
34.083333,
44.19866965,
69.54471168,
126.12334652,
195.00975,
280.02031059,
401.8031846,
498.05773102,
598.05298623
],
[
136.375,
34.25,
41.14585909,
63.97783324,
112.94446068,
171.29655523,
244.54173386,
351.49062807,
436.69215204,
525.55929161
],
[
136.375,
34.416667,
39.78983922,
63.14594359,
111.77331041,
164.10575691,
226.34321431,
317.35077976,
390.91001223,
468.18885341
],
[
136.375,
34.583333,
38.79643612,
63.80938415,
120.49998828,
181.0808476,
249.59157076,
348.00195875,
428.40130263,
514.56867887
],
[
136.625,
34.083333,
45.6865971,
73.1514508,
132.10256576,
205.68600475,
301.28908863,
438.46379748,
545.53974829,
655.97777240
],
[
136.625,
34.25,
43.0370728,
67.38544304,
118.25109561,
180.36366218,
262.43645042,
382.57629592,
477.03949972,
574.77020936
],
[
136.625,
34.416667,
39.72114625,
61.23289295,
105.45415575,
159.4031086,
231.20276396,
336.81796549,
420.25831827,
506.78316618
],
[
136.625,
34.583333,
39.9194546,
64.71331498,
120.10537672,
182.57599436,
254.07199752,
355.11032958,
436.13571493,
521.87364600
],
[
136.875,
34.083333,
44.38995503,
71.24355895,
130.67239335,
214.51775072,
327.35849282,
482.38994654,
601.05014715,
722.84767727
],
[
136.875,
34.25,
42.65392204,
67.67219504,
120.63063957,
190.47304227,
285.38438255,
419.90132791,
523.94412418,
630.84160690
],
[
136.875,
34.416667,
40.48944778,
63.37362089,
110.18192897,
169.2341523,
249.74656163,
367.17858739,
458.90285719,
553.49975213
],
[
136.875,
34.583333,
40.71153671,
66.32067636,
122.40398535,
186.87420827,
263.00255124,
370.95215098,
456.91117597,
547.14175047
],
[
136.125,
34.75,
38.21480526,
65.39318936,
123.50009863,
180.42615564,
245.58077101,
343.84382852,
427.8699648,
520.66824220
],
[
136.125,
34.916667,
38.36655007,
65.08192779,
119.54801861,
173.6045184,
237.2407111,
334.84280749,
417.95256172,
508.67256313
],
[
136.125,
35.083333,
36.22396934,
59.71962888,
109.2474177,
162.7159422,
228.24036657,
328.32795597,
412.1084155,
502.11390734
],
[
136.125,
35.25,
37.29114611,
62.06959099,
114.23794573,
170.1734098,
237.79775839,
340.54278512,
427.05544874,
520.91952890
],
[
136.375,
34.75,
39.9231365,
67.77694571,
126.74198928,
185.15582885,
251.83012427,
351.40306762,
435.76914675,
528.65467639
],
[
136.375,
34.916667,
40.62358342,
68.92953762,
126.57265297,
183.80038508,
251.93462139,
358.87548572,
452.91033574,
558.06776904
],
[
136.375,
35.083333,
41.38953164,
69.90336866,
126.34484167,
181.96483774,
248.21424468,
351.19711304,
440.36518815,
539.29525605
],
[
136.375,
35.25,
39.97975674,
67.80684843,
125.54587147,
186.31071806,
259.02497187,
369.40175014,
462.26961946,
563.20411073
],
[
136.625,
34.75,
41.99203474,
71.01860206,
132.71101688,
193.16403338,
260.24685442,
357.04187598,
436.4960134,
521.94005535
],
[
136.625,
34.916667,
43.92612427,
75.63857744,
141.75299196,
206.24106934,
279.7141435,
389.94383261,
483.14660375,
585.38549963
],
[
136.625,
35.083333,
45.37855011,
79.00977569,
146.96846622,
212.47612032,
287.81063326,
401.28129185,
497.28865966,
601.97216500
],
[
136.625,
35.25,
43.33466066,
74.6721679,
140.82928073,
209.12966374,
288.83800471,
408.62233169,
510.00326579,
621.01186735
],
[
136.875,
34.75,
43.74455623,
76.41533643,
149.10810532,
219.55102329,
296.42146813,
406.71768384,
497.69334909,
596.32383340
],
[
136.875,
34.916667,
47.14949028,
82.32058493,
152.02871296,
217.01356965,
289.0501387,
394.07507252,
481.12281862,
575.27684720
],
[
136.875,
35.083333,
47.15230033,
81.60384189,
148.97979885,
212.37408886,
283.85520407,
389.72674119,
477.96231101,
573.41207097
],
[
136.875,
35.25,
47.31125153,
81.12298636,
146.25982572,
208.42586338,
279.50162307,
385.37800432,
473.46468686,
568.36979066
],
[
136.125,
35.416667,
38.43319559,
64.83903067,
118.79316959,
176.66635325,
247.81125265,
357.64450642,
451.02662993,
552.80959550
],
[
136.125,
35.583333,
39.11044054,
67.69045075,
126.94436345,
188.70823215,
262.41505798,
374.44692386,
469.14440675,
572.39950992
],
[
136.125,
35.75,
39.15107806,
70.19938286,
136.49905405,
204.62835437,
283.3645113,
399.91385592,
497.11120049,
602.46602523
],
[
136.125,
35.916667,
38.21596111,
69.40163445,
133.42851901,
197.47623476,
271.6489284,
381.35153615,
472.19187333,
569.68453546
],
[
136.375,
35.416667,
41.69702347,
72.03410945,
138.79014167,
210.19975251,
294.42627836,
422.49784106,
533.11204187,
656.32814572
],
[
136.375,
35.583333,
42.92357898,
74.7165428,
139.67798838,
205.89237514,
282.24756613,
394.19351819,
485.89869076,
583.70559355
],
[
136.375,
35.75,
42.21535786,
76.01752285,
144.679681,
212.38881573,
290.9512443,
410.15261256,
511.95498061,
623.63617366
],
[
136.375,
35.916667,
40.26153963,
73.27137486,
141.27481535,
209.7024723,
289.98651727,
413.14646776,
519.78639391,
638.16565562
],
[
136.625,
35.416667,
44.75579738,
77.5605563,
143.4987571,
209.77571334,
286.7532774,
400.93362206,
495.33670684,
596.29193731
],
[
136.625,
35.583333,
44.88252248,
79.99517499,
153.92306452,
228.53593943,
316.33000343,
451.05898563,
566.42540806,
692.34213463
],
[
136.625,
35.75,
43.58987659,
77.97172188,
147.33636755,
214.99929596,
293.37480508,
412.81463768,
515.74384948,
629.59856237
],
[
136.625,
35.916667,
41.42454578,
73.41328058,
138.25171307,
203.0552394,
277.53809585,
387.60433838,
478.73358505,
576.79495131
],
[
136.875,
35.416667,
44.49029818,
77.29183127,
144.55260283,
211.28665365,
288.43081127,
404.78087426,
503.66993169,
612.20190067
],
[
136.875,
35.583333,
44.53748686,
77.86991676,
144.68150155,
210.67176424,
287.59800322,
404.74146662,
504.98237943,
615.35876650
],
[
136.875,
35.75,
43.28816962,
75.44353395,
140.86203112,
207.12765715,
283.81839507,
397.50640566,
491.86992628,
593.45095700
],
[
136.875,
35.916667,
42.26890136,
74.74272766,
141.02252924,
208.0924849,
285.36639344,
399.6026834,
494.67156219,
597.46970164
],
[
136.125,
36.083333,
36.3437333,
66.98404075,
129.84777502,
193.18782638,
266.53284302,
374.67278369,
463.84805822,
559.36782782
],
[
136.125,
36.25,
32.991161,
63.40170287,
126.96209337,
190.55405661,
263.77402911,
371.70617323,
460.91689112,
556.75258447
],
[
136.125,
36.416667,
28.10313155,
55.80713767,
118.97346985,
183.46537212,
257.2257203,
365.25115337,
454.18675172,
549.36674681
],
[
136.125,
36.583333,
22.79769075,
43.17986018,
92.21263795,
148.60030528,
218.23405439,
323.51336328,
410.79410861,
504.24962276
],
[
136.375,
36.083333,
38.39483272,
69.75236629,
134.5344912,
199.06603533,
273.6633213,
384.31855338,
476.33865231,
575.59326522
],
[
136.375,
36.25,
36.55034575,
67.5489914,
131.71587345,
195.40993312,
268.37431732,
375.82932221,
464.81259976,
560.51096968
],
[
136.375,
36.416667,
33.93469916,
64.59463692,
128.31928381,
191.65718117,
264.16255066,
370.75798733,
458.76777548,
553.23116237
],
[
136.375,
36.583333,
29.46203083,
58.52494134,
122.10876859,
185.9093053,
258.88633657,
366.02601038,
454.32380922,
548.89248309
],
[
136.625,
36.083333,
39.63263552,
70.76198726,
135.41804547,
200.29458657,
274.27650174,
382.00478849,
470.45642493,
565.10541271
],
[
136.625,
36.25,
38.53119808,
69.68976299,
134.23220894,
198.86185884,
272.86246167,
381.12062294,
470.25942519,
565.71721911
],
[
136.625,
36.416667,
37.04060625,
68.17717552,
132.36150762,
196.37466262,
269.92995729,
378.23905345,
467.86603501,
564.14180653
],
[
136.625,
36.583333,
34.8671932,
65.65229395,
129.02144687,
192.29601828,
265.11102579,
372.5542981,
461.44085083,
556.94919357
],
[
136.875,
36.083333,
42.37967882,
75.7978694,
143.40644824,
211.50396459,
290.03365823,
405.86751744,
501.63736067,
604.46933300
],
[
136.875,
36.25,
41.80841941,
77.03072982,
148.94713484,
221.2061848,
306.89694556,
440.17522996,
556.7563018,
686.61654301
],
[
136.875,
36.416667,
40.40750987,
74.22068639,
141.52426442,
208.49542825,
286.24138936,
402.8451365,
500.81050677,
607.37520319
],
[
136.875,
36.583333,
38.29064367,
69.88648347,
133.93105747,
197.38584906,
270.58578968,
378.77883897,
468.52921733,
565.07492559
],
[
136.125,
36.75,
18.39407025,
32.32873766,
61.67416323,
92.83084264,
131.25475631,
192.8507931,
247.51881758,
308.94025005
],
[
136.125,
36.916667,
15.23509676,
24.87456676,
43.44721965,
62.60324305,
86.96218214,
128.56846438,
168.43310257,
216.42746990
],
[
136.125,
37.083333,
12.48745166,
19.85760661,
34.34640294,
49.00834092,
68.46635574,
103.45022467,
138.89638964,
184.13352059
],
[
136.125,
37.25,
10.60330547,
17.3972375,
29.15319428,
41.94805812,
58.95716451,
90.69644045,
124.66548432,
169.93146425
],
[
136.375,
36.75,
24.63199392,
47.16937625,
100.77958015,
160.88919768,
233.34486238,
340.97230229,
429.63716319,
524.46867228
],
[
136.375,
36.916667,
20.10448084,
36.77266252,
71.67401597,
109.95262003,
158.59432674,
237.1712487,
306.02801686,
382.13922975
],
[
136.375,
37.083333,
17.272991,
29.47890951,
53.77472177,
78.23673308,
108.46960026,
158.09650818,
203.63609313,
256.27869385
],
[
136.375,
37.25,
15.15070002,
25.42989001,
45.04457655,
65.02862342,
90.10783823,
132.9544647,
173.66989558,
222.35684257
],
[
136.625,
36.75,
31.38808806,
61.39481553,
124.5698456,
187.78474537,
260.50318368,
367.62351164,
456.00668462,
550.72798637
],
[
136.625,
36.916667,
27.38770444,
53.70314456,
114.100607,
177.85404584,
251.7509956,
360.00892877,
449.14196288,
544.50485191
],
[
136.625,
37.083333,
24.1959309,
46.35294116,
97.44000782,
155.5539826,
227.13107669,
334.69341491,
423.5513848,
518.71001342
],
[
136.625,
37.25,
21.05068344,
40.30548148,
84.77207303,
135.24171409,
198.34816543,
295.73857279,
377.60117029,
465.97115687
],
[
136.875,
36.75,
36.10775217,
67.08093644,
130.39253672,
193.02361036,
264.8406395,
370.77584242,
458.42264885,
552.56610300
],
[
136.875,
36.916667,
34.0687766,
64.79977067,
127.87343595,
190.23628291,
261.93997029,
367.96384614,
455.78570994,
550.09183301
],
[
136.875,
37.083333,
31.91139558,
62.38880392,
125.42591875,
187.95163008,
260.00321543,
366.57297436,
454.71687843,
549.26703215
],
[
136.875,
37.25,
29.25632331,
58.74451885,
121.53020118,
184.91778466,
257.91735416,
365.25046276,
453.69987079,
548.38857909
],
[
136.125,
37.416667,
9.55422699,
15.56589029,
26.28922345,
37.896556,
53.92065779,
84.50900109,
118.15460123,
164.36507103
],
[
136.125,
37.583333,
8.90132069,
13.83921269,
23.66639674,
34.59453903,
49.59861005,
79.62243192,
113.6850958,
160.87153867
],
[
136.125,
37.75,
8.25838116,
11.91725367,
20.58872035,
30.64125443,
45.19838251,
74.43421768,
108.71715337,
157.32169734
],
[
136.125,
37.916667,
7.60763107,
9.89775622,
17.90615327,
26.48717811,
38.75177649,
65.65638779,
99.30107905,
149.49021070
],
[
136.375,
37.416667,
13.23861607,
22.25395804,
39.52929337,
57.49441098,
80.26780241,
120.11529319,
159.09801059,
206.82565788
],
[
136.375,
37.583333,
11.29511672,
19.44388645,
35.29916444,
51.42297898,
72.57382183,
110.15977516,
147.95696155,
194.99613412
],
[
136.375,
37.75,
9.65808764,
16.86008152,
30.13521707,
44.8869076,
64.1527521,
99.5407577,
136.35031929,
183.30749209
],
[
136.375,
37.916667,
8.7775943,
13.85697736,
24.8811352,
36.98551064,
53.76133833,
86.25393127,
121.76250602,
169.20265417
],
[
136.625,
37.416667,
18.79940139,
36.25278841,
75.53450146,
120.9118923,
179.77941153,
273.6325397,
353.72441031,
440.59270010
],
[
136.625,
37.583333,
16.50672631,
31.70953801,
66.8231193,
106.03375825,
155.55621781,
234.06458557,
301.6170747,
375.75344917
],
[
136.625,
37.75,
13.51582392,
25.90107558,
54.4038098,
87.07285421,
128.91964575,
196.49858529,
255.94431111,
322.08959861
],
[
136.625,
37.916667,
10.16182068,
19.40506043,
38.96865693,
60.49283899,
88.55318942,
136.52096855,
181.68391794,
234.88527433
],
[
136.875,
37.416667,
27.00444393,
55.51292092,
118.63028168,
182.82673253,
256.42546149,
364.19304427,
452.87576365,
547.75822132
],
[
136.875,
37.583333,
23.86908787,
51.04634086,
114.72204583,
179.85890063,
254.22088344,
362.57597497,
451.59006325,
546.75365882
],
[
136.875,
37.75,
19.03854906,
41.20168637,
101.15866357,
168.21757092,
244.77386773,
355.00330523,
444.79247544,
540.52707004
],
[
136.875,
37.916667,
14.9736206,
28.767332,
63.4714189,
104.89585089,
158.68868476,
244.89588608,
319.0959031,
400.19156942
],
[
136.375,
38.083333,
7.88540689,
10.70633914,
19.25902004,
28.67174929,
41.79455123,
68.37034411,
99.90854521,
146.64577706
],
[
136.625,
38.083333,
8.93782681,
14.67746217,
27.02194946,
40.43303582,
58.91743882,
93.52539462,
129.97867001,
177.47548265
],
[
136.625,
38.25,
7.82482372,
10.49469763,
19.03676785,
28.22046831,
40.61779871,
65.01949846,
91.98445102,
130.57089939
],
[
136.875,
38.083333,
11.03198806,
19.71463098,
37.81269635,
56.79731752,
81.08514514,
123.34155139,
164.24560269,
213.73453596
],
[
136.875,
38.25,
9.10326221,
14.58084,
25.20175689,
36.6689943,
52.33688191,
82.69422735,
116.24229393,
162.10967748
],
[
136.875,
38.416667,
7.95840862,
10.85602459,
18.51145148,
26.54382162,
37.12726678,
56.80888952,
77.48898491,
105.29529626
],
[
137.125,
33.583333,
37.81584938,
74.91707348,
175.89100927,
332.5666747,
540.96705792,
816.7935929,
1025.10706676,
1237.75511877
],
[
137.125,
33.75,
43.78669495,
79.95624239,
165.40069459,
300.24885722,
482.18669324,
718.82330923,
896.9331411,
1078.86287294
],
[
137.125,
33.916667,
44.92962541,
76.42928296,
149.78929507,
264.09476198,
417.46371024,
619.12744046,
771.52962084,
927.27731954
],
[
137.375,
33.583333,
32.43664453,
63.9795903,
149.23783395,
298.46221565,
524.34670532,
823.69427308,
1047.8255361,
1275.81755815
],
[
137.375,
33.75,
41.09124381,
81.08278937,
178.27331893,
323.36602276,
522.82456308,
787.22046327,
986.46992984,
1189.79112339
],
[
137.375,
33.916667,
45.63453824,
82.06411264,
164.99315258,
288.19095447,
457.63616263,
683.12830615,
853.3457128,
1027.29100366
],
[
137.625,
33.583333,
26.93734563,
51.44697259,
115.26151176,
214.35456432,
384.31290904,
620.66097982,
795.63767138,
972.77424335
],
[
137.625,
33.75,
36.65662805,
74.2521072,
171.79565896,
322.7190688,
540.75321261,
836.07710686,
1058.933754,
1285.98999609
],
[
137.625,
33.916667,
44.81576855,
86.24427406,
179.81513459,
308.79724991,
491.33229199,
742.73191054,
933.10563284,
1127.42009928
],
[
137.875,
33.583333,
21.96879692,
39.59247041,
89.23680413,
168.7508723,
297.02626393,
478.68633076,
614.36262653,
751.87919050
],
[
137.875,
33.75,
30.43108845,
59.69771296,
136.59848553,
244.99022317,
423.90829143,
687.82066055,
884.90287785,
1084.27978416
],
[
137.875,
33.916667,
40.03590308,
80.40906716,
183.60550814,
319.42574722,
510.94474435,
788.34770076,
1000.85076664,
1217.85473556
],
[
137.125,
34.083333,
44.1944075,
72.68585296,
138.15016158,
232.89439756,
359.96747006,
532.30216014,
663.56922603,
797.92736331
],
[
137.125,
34.25,
42.22081502,
68.44874354,
127.29264539,
206.61588891,
312.37044177,
460.51236308,
574.67118411,
691.80987198
],
[
137.125,
34.416667,
39.9926233,
63.46331639,
114.49953544,
181.31322853,
271.38540911,
400.4291812,
500.67011791,
603.86016002
],
[
137.125,
34.583333,
39.66584098,
63.11572614,
112.38008273,
171.17853194,
246.88771021,
357.61803215,
445.26910902,
536.25603590
],
[
137.375,
34.083333,
45.32546273,
77.11967931,
151.23953939,
255.873794,
394.96405029,
585.30231265,
730.64127978,
879.47355408
],
[
137.375,
34.25,
43.24945012,
71.33776777,
138.01620216,
228.20421544,
343.72543173,
504.95891338,
629.73837048,
758.06927701
],
[
137.375,
34.416667,
40.55399346,
65.63579204,
123.98412732,
201.41210065,
299.94456362,
438.89461679,
547.26609618,
659.19503599
],
[
137.375,
34.583333,
39.21553905,
61.94016215,
112.78917644,
178.31393792,
262.64764855,
383.59812373,
478.65029065,
577.20926252
],
[
137.625,
34.083333,
47.15800668,
82.81963271,
165.34311524,
277.93836854,
428.02171423,
637.78600811,
798.89430368,
964.09182430
],
[
137.625,
34.25,
46.11579569,
77.09215934,
151.54679219,
252.26361599,
377.53176149,
552.06467598,
687.95992052,
828.26037622
],
[
137.625,
34.416667,
44.01609262,
71.47269889,
137.71381769,
225.73861429,
332.63020413,
481.32012578,
597.74730588,
718.51807224
],
[
137.625,
34.583333,
42.1314699,
67.13847659,
125.37272539,
200.70952607,
292.68948445,
421.43274448,
522.74110298,
627.89404287
],
[
137.875,
34.083333,
47.41588912,
86.11524186,
176.4743366,
297.41222487,
457.71848198,
685.66545556,
862.53659084,
1044.67281901
],
[
137.875,
34.25,
50.21013141,
84.49001352,
166.5421597,
279.79462271,
417.62971368,
606.39198904,
753.19163997,
905.11215568
],
[
137.875,
34.416667,
50.84360291,
82.57985008,
158.09221484,
256.65564682,
372.75554049,
532.09280971,
656.53330028,
785.73370504
],
[
137.875,
34.583333,
50.35123439,
80.23767396,
148.77868506,
232.22303556,
329.37895682,
463.85080962,
569.45561236,
679.09389606
],
[
137.125,
34.75,
42.52319726,
71.81850654,
137.22540523,
205.44696225,
281.51835613,
389.21629447,
475.89154409,
567.82589101
],
[
137.125,
34.916667,
46.44059508,
81.73834235,
153.60973894,
220.23876633,
293.18013276,
397.93012778,
483.85854068,
576.16542237
],
[
137.125,
35.083333,
48.52154803,
84.78723449,
154.15044815,
218.07130092,
289.65500921,
395.46043757,
484.21483409,
580.90913558
],
[
137.125,
35.25,
48.87555199,
84.52461696,
151.52502213,
214.39571412,
286.34642831,
394.92214169,
487.09036678,
588.04084891
],
[
137.375,
34.75,
40.73963082,
65.91129565,
119.70518304,
179.61468775,
251.0502338,
354.42098953,
437.35087664,
524.39580977
],
[
137.375,
34.916667,
44.64788944,
76.93364882,
147.85189218,
216.3364786,
291.03622085,
397.25596697,
483.55734583,
575.66505566
],
[
137.375,
35.083333,
48.74843077,
85.63965306,
157.3927773,
222.23859219,
293.15914091,
395.76912934,
480.47964171,
571.95578075
],
[
137.375,
35.25,
50.35615026,
87.39620024,
157.38216608,
221.60734021,
293.23325548,
398.32938531,
485.81016823,
580.43225955
],
[
137.625,
34.75,
42.15905569,
66.24283546,
119.10757123,
183.22795917,
261.40787885,
372.88779714,
461.25303495,
553.44488769
],
[
137.625,
34.916667,
44.95035206,
72.82805613,
132.16990847,
192.89143603,
260.9180035,
357.64526439,
435.44779712,
517.61382660
],
[
137.625,
35.083333,
49.16995733,
84.90821877,
160.07609845,
229.62375249,
304.37381274,
410.55744158,
496.96419729,
589.35083586
],
[
137.625,
35.25,
53.13328697,
92.30410384,
168.05858564,
237.09546515,
312.63260984,
421.28369466,
510.42529094,
605.49362293
],
[
137.875,
34.75,
49.87337792,
78.44355419,
140.71011521,
213.94415545,
300.86165057,
423.91401761,
521.50445816,
623.18889519
],
[
137.875,
34.916667,
50.44994746,
78.66201355,
137.13255904,
202.49417479,
280.77062222,
394.07597935,
484.92699,
580.31396483
],
[
137.875,
35.083333,
54.24290008,
86.63665434,
151.3505823,
217.15889606,
292.77338711,
402.57644653,
492.07029241,
587.29398459
],
[
137.875,
35.25,
54.74878766,
90.62343924,
163.47877209,
235.12864322,
315.59907073,
432.15507562,
528.18100267,
631.34708416
],
[
137.125,
35.416667,
48.70277564,
83.47830277,
148.46884658,
210.68852314,
282.32244535,
389.56930846,
479.01468425,
575.57768317
],
[
137.125,
35.583333,
47.27227752,
81.20945188,
146.42099609,
209.62014227,
282.18654691,
389.83744344,
478.94318295,
574.72157267
],
[
137.125,
35.75,
44.9328055,
79.34722876,
146.22762345,
211.45368422,
286.8621617,
399.05684372,
492.12388123,
591.85836148
],
[
137.125,
35.916667,
44.35722845,
80.67882021,
153.78723947,
224.35785609,
305.86353455,
429.90139138,
536.38404418,
653.27960428
],
[
137.375,
35.416667,
51.55829154,
89.15281233,
159.35281866,
225.37882885,
300.70996019,
413.85448491,
509.67592359,
614.44610149
],
[
137.375,
35.583333,
50.97683827,
90.82636806,
163.99808854,
231.41245448,
308.17144041,
423.68019024,
521.70247816,
628.23974327
],
[
137.375,
35.75,
50.06712071,
91.38513158,
169.27281174,
242.50706879,
327.88438762,
461.39924526,
580.47165323,
715.66024108
],
[
137.375,
35.916667,
48.14055902,
85.78974069,
155.28648319,
220.17476031,
294.7158462,
407.48107196,
503.5957124,
609.01674315
],
[
137.625,
35.416667,
55.01097117,
97.16663454,
175.81591172,
248.68132462,
331.94383543,
458.35163539,
566.6614705,
685.16172186
],
[
137.625,
35.583333,
55.41866152,
100.31190225,
182.59890007,
257.93399013,
344.34023308,
476.4578945,
590.09525827,
714.69398156
],
[
137.625,
35.75,
52.32535536,
94.08159592,
172.07284982,
243.82066385,
324.74865178,
445.80492552,
548.33522786,
660.65268648
],
[
137.625,
35.916667,
50.58099585,
91.51264635,
167.05931092,
237.69143058,
317.35015335,
433.73405592,
529.36124001,
631.02189979
],
[
137.875,
35.416667,
54.25090437,
94.45153157,
174.48305918,
249.74763681,
332.8592691,
452.89249488,
551.46364104,
657.20985406
],
[
137.875,
35.583333,
50.28652998,
94.46825631,
187.19674463,
271.83255504,
366.35415627,
509.88294713,
634.49996647,
773.60578230
],
[
137.875,
35.75,
52.372431,
98.77093704,
188.27154268,
269.80044316,
361.37823248,
498.72918687,
615.84514823,
744.29278272
],
[
137.875,
35.916667,
53.39350502,
101.38407086,
192.24784321,
277.23936276,
376.25519366,
529.65563307,
661.79455962,
807.09742026
],
[
137.125,
36.083333,
43.7105549,
78.46017771,
146.8364621,
214.34401036,
293.2464492,
412.19157039,
512.08373709,
619.84211412
],
[
137.125,
36.25,
43.9979429,
80.80061045,
153.60273875,
224.28827159,
305.94729483,
429.04787178,
533.44761835,
647.02115707
],
[
137.125,
36.416667,
43.25163559,
80.25668396,
152.95721697,
224.00789353,
307.85399676,
438.65213186,
553.45129265,
682.05214809
],
[
137.125,
36.583333,
40.32326196,
73.11908339,
138.26191506,
202.98919367,
277.44010212,
387.37993268,
478.21285974,
575.74799002
],
[
137.375,
36.083333,
43.80043435,
77.74894552,
146.52404546,
213.14766862,
288.2432962,
398.24642102,
489.25585476,
587.11072870
],
[
137.375,
36.25,
43.7942458,
78.3841183,
146.83191358,
213.14086523,
288.15431788,
397.93058204,
488.43900581,
585.45213995
],
[
137.375,
36.416667,
43.50757185,
81.25092357,
158.10320095,
233.62313261,
321.95341392,
458.53847674,
577.34632213,
708.69857035
],
[
137.375,
36.583333,
41.77015364,
76.67093933,
145.63729837,
213.66100452,
292.52087178,
411.16094647,
511.56687915,
621.10377605
],
[
137.625,
36.083333,
48.32244723,
87.43097717,
162.64876797,
234.10478812,
315.44969935,
437.29755884,
540.58390635,
653.21023519
],
[
137.625,
36.25,
44.54905661,
79.51667928,
150.74276183,
219.46249368,
295.82470368,
405.49459827,
494.7932765,
589.92357342
],
[
137.625,
36.416667,
44.94502512,
81.1898815,
151.63131118,
220.12231686,
298.3845571,
413.31931451,
507.95359376,
608.90242613
],
[
137.625,
36.583333,
43.44152979,
79.91305827,
150.09763113,
219.74443406,
300.95489343,
421.81725926,
522.07063265,
629.13843670
],
[
137.875,
36.083333,
51.96517339,
95.85678949,
175.28194803,
251.28629213,
338.58841468,
467.28652422,
573.02298533,
685.25946039
],
[
137.875,
36.25,
46.25250769,
91.43046311,
182.21057257,
264.10407563,
354.42484491,
486.29360166,
595.44418767,
712.62640507
],
[
137.875,
36.416667,
44.6281478,
91.34897504,
191.83308259,
290.83942598,
406.99556795,
582.31440932,
727.74100779,
882.73413969
],
[
137.875,
36.583333,
41.09050292,
85.66870359,
181.50980468,
274.57666851,
381.58047965,
543.59943292,
680.9971,
830.33483867
],
[
137.125,
36.75,
38.12074738,
69.39341758,
133.47758698,
196.926777,
269.22089404,
375.08614021,
462.47882639,
556.35517478
],
[
137.125,
36.916667,
36.47402138,
67.39135727,
130.89011455,
193.60668735,
265.17400482,
370.6127003,
458.00157812,
552.04179391
],
[
137.125,
37.083333,
35.24463954,
66.03261909,
129.04282154,
191.31476527,
262.8065991,
368.57546383,
456.31191117,
550.64868698
],
[
137.125,
37.25,
34.31552577,
65.09486723,
127.65085852,
189.72030826,
261.35439374,
367.45462199,
455.36866262,
549.77261163
],
[
137.375,
36.75,
38.88452596,
70.82967418,
136.50992984,
202.42348352,
277.57833815,
386.79205623,
476.02833925,
571.29896578
],
[
137.375,
36.916667,
36.95542155,
68.18218143,
132.94237969,
197.40028269,
270.62217732,
377.25016002,
464.93310979,
558.89578215
],
[
137.375,
37.083333,
35.70713778,
66.74689245,
130.50524763,
193.72451651,
265.87387193,
371.78420931,
459.25489925,
553.22640775
],
[
137.375,
37.25,
34.88524404,
65.76376377,
128.67025607,
191.13166555,
262.86847348,
368.70141769,
456.27985538,
550.31984463
],
[
137.625,
36.75,
39.05874554,
72.24244416,
139.88738403,
209.00329343,
289.2095504,
407.57960963,
504.9821698,
608.79661541
],
[
137.625,
36.916667,
35.33438704,
65.68351288,
131.42999279,
198.7830252,
276.13987012,
389.21665827,
481.86621941,
580.76953190
],
[
137.625,
37.083333,
32.98071596,
62.70147015,
126.99082649,
192.09410653,
266.53410041,
375.00277631,
463.94847149,
559.03951387
],
[
137.625,
37.25,
31.78997686,
61.63965401,
125.84347875,
189.85144467,
262.80097233,
369.55686317,
457.51060765,
551.82893582
],
[
137.875,
36.75,
36.12717548,
69.19723029,
146.24878199,
231.33383749,
337.10246827,
508.37314804,
658.88230991,
823.88805672
],
[
137.875,
36.916667,
31.77014319,
56.67175981,
108.52672084,
164.89873956,
235.41141231,
347.53068151,
444.83897105,
551.54698718
],
[
137.875,
37.083333,
28.82419731,
51.35020544,
100.24426675,
153.18935283,
217.75145462,
316.4784754,
399.16600171,
488.11114784
],
[
137.875,
37.25,
26.9253785,
49.2704634,
98.44646975,
150.72486898,
213.29080485,
307.5817521,
386.55856008,
471.93953197
],
[
137.125,
37.416667,
32.34469103,
62.56771507,
124.73365551,
187.34719902,
259.68839289,
366.52499354,
454.8007554,
549.45844722
],
[
137.125,
37.583333,
29.96722321,
60.61057058,
123.53713545,
186.63403006,
259.28031517,
366.35298342,
454.77601062,
549.58011479
],
[
137.125,
37.75,
25.12605711,
54.20930834,
118.25333805,
182.72839802,
256.43529085,
364.3078141,
453.10513578,
548.14050526
],
[
137.125,
37.916667,
18.53781217,
38.06431609,
85.18615035,
139.9800494,
208.68401276,
312.94641549,
399.45156294,
492.14620934
],
[
137.375,
37.416667,
33.72025221,
64.4822778,
127.12216344,
189.37371502,
261.13328209,
367.26279225,
455.1120817,
549.40307459
],
[
137.375,
37.583333,
31.40654013,
61.76861604,
124.23818509,
187.04014428,
259.47774169,
366.33308784,
454.57838568,
549.18140381
],
[
137.375,
37.75,
27.75322119,
57.97016163,
121.45098894,
185.12933015,
258.18934691,
365.49101128,
453.91845812,
548.61164258
],
[
137.375,
37.916667,
21.01127126,
44.58676247,
101.39466767,
165.19979031,
240.18483521,
349.72210282,
439.18457025,
534.72037892
],
[
137.625,
37.416667,
30.82389642,
60.28651228,
123.22242357,
186.40229852,
258.91440218,
365.68628849,
453.89021981,
548.49395689
],
[
137.625,
37.583333,
29.55902592,
58.76705168,
121.17325968,
184.33769588,
257.08235943,
364.27214574,
452.83221834,
547.77601867
],
[
137.625,
37.75,
26.67241552,
55.74821787,
118.9623176,
183.07798676,
256.59814312,
364.34142431,
453.07682037,
548.06829361
],
[
137.625,
37.916667,
21.46557725,
47.19760823,
111.00152718,
177.03180907,
252.03545999,
360.90904581,
450.18005121,
545.52502011
],
[
137.875,
37.416667,
26.05792382,
47.97514803,
94.64029274,
143.32535202,
201.87751254,
292.0057766,
368.75150906,
452.53477822
],
[
137.875,
37.583333,
25.40602334,
47.50754432,
93.6720176,
141.46355902,
199.35941741,
289.4277982,
366.48397531,
450.73375602
],
[
137.875,
37.75,
23.56868939,
45.96354983,
94.89362817,
148.49983086,
214.60607279,
315.60476205,
400.18193483,
491.31458491
],
[
137.875,
37.916667,
20.12705273,
41.47537274,
92.19482971,
148.50453762,
216.68599771,
319.22476168,
404.46204227,
495.91980494
],
[
137.125,
38.083333,
13.79889459,
25.05051422,
48.11506297,
72.31844096,
102.5144182,
152.3691503,
198.23410775,
251.53343693
],
[
137.125,
38.25,
9.96002741,
17.31637152,
30.07636344,
44.23618789,
62.80948906,
97.28691121,
133.18568307,
179.43582722
],
[
137.125,
38.416667,
8.68949696,
13.04570316,
21.67433773,
31.13106951,
44.23853242,
68.81737848,
96.46415162,
136.46275433
],
[
137.125,
38.583333,
7.71812582,
10.09868932,
17.40021145,
24.42599861,
33.63256831,
49.73833653,
65.75555751,
85.25482954
],
[
137.375,
38.083333,
15.89009304,
29.36629562,
59.17112142,
91.3596144,
131.67962858,
196.56695826,
253.92700669,
317.98543589
],
[
137.375,
38.25,
11.8230483,
19.96217269,
36.23611265,
52.81561567,
74.44332285,
112.70945082,
150.7121925,
197.79488156
],
[
137.375,
38.416667,
9.48546317,
15.41219325,
26.02117862,
37.41971223,
53.07289676,
83.09541235,
116.17899413,
161.63420369
],
[
137.375,
38.583333,
8.5085732,
12.49778326,
20.60144792,
29.53832712,
41.43237497,
63.00003128,
85.27150979,
114.69384916
],
[
137.625,
38.083333,
17.04878708,
32.85605043,
71.36136893,
116.64536455,
174.71368631,
266.88887961,
345.70956287,
431.42840913
],
[
137.625,
38.25,
13.49510634,
23.62750494,
43.90337428,
64.84594963,
91.17374194,
135.9476887,
178.28449396,
228.64446171
],
[
137.625,
38.416667,
10.64583446,
18.30183977,
32.68156177,
48.09940356,
68.53453058,
105.6044647,
143.19293871,
190.53861018
],
[
137.625,
38.583333,
9.40272224,
15.61459469,
27.4316226,
40.3298804,
57.93498925,
89.86920693,
123.44619415,
167.43549005
],
[
137.875,
38.083333,
17.48253167,
33.76127062,
73.1974483,
120.79281179,
183.11084591,
280.96735526,
363.40594482,
452.19804131
],
[
137.875,
38.25,
15.45761646,
28.20796633,
57.91335249,
91.38576881,
135.54997762,
211.67687659,
281.12410572,
359.03150528
],
[
137.875,
38.416667,
13.26764699,
23.77504705,
49.184584,
81.04700682,
125.01093353,
202.74172111,
274.37906022,
354.28717956
],
[
137.875,
38.583333,
11.59676384,
20.87439982,
44.71892919,
74.38458569,
114.486992,
183.92085294,
248.30386272,
321.05648883
],
[
137.625,
38.75,
8.81707529,
13.85525831,
24.43361527,
35.73456194,
50.10638677,
75.29086103,
99.16991168,
127.82166310
],
[
137.875,
38.75,
10.33066585,
19.33146668,
41.24324313,
68.14668524,
103.56493835,
163.62573662,
219.19242938,
282.77319850
],
[
137.875,
38.916667,
9.44556042,
17.15727537,
35.43979822,
58.85187897,
92.92228415,
153.80458892,
210.07680268,
273.50463871
],
[
138.875,
33.25,
10.56652909,
18.32377366,
31.94276222,
45.32023879,
61.24841459,
86.90401133,
109.701804,
135.59068788
],
[
138.125,
33.583333,
19.09456387,
32.03131196,
68.04958812,
134.24286236,
236.44233163,
378.94720366,
486.55537838,
596.12045914
],
[
138.125,
33.75,
25.49544072,
45.00806063,
101.28074928,
192.11561552,
326.96126631,
523.20309179,
672.98906607,
825.53642255
],
[
138.125,
33.916667,
33.88028568,
63.18087986,
147.07015236,
270.74871528,
455.63912354,
738.33515526,
956.40446322,
1178.48223055
],
[
138.375,
33.583333,
18.92906294,
30.63198728,
61.428582,
116.775548,
197.92415699,
309.96299371,
395.8513755,
484.03316815
],
[
138.375,
33.75,
24.1931575,
39.39373604,
80.07285819,
152.60005374,
259.2225496,
407.05110691,
520.48996539,
636.87307379
],
[
138.375,
33.916667,
30.77821964,
51.64854708,
109.48203315,
206.53240528,
337.10816825,
515.92203937,
653.39722019,
794.87888457
],
[
138.625,
33.416667,
16.83282512,
29.10651729,
61.82332143,
101.79823426,
149.20929931,
216.87521595,
270.86974414,
327.38547893
],
[
138.625,
33.583333,
22.19703008,
40.90104233,
89.61217923,
142.3963451,
201.12033621,
284.02042489,
350.44718571,
420.28636446
],
[
138.625,
33.75,
29.0290489,
52.19419123,
106.56108279,
165.49160997,
232.88444767,
328.92547582,
405.908093,
486.73646668
],
[
138.625,
33.916667,
34.61101613,
59.75046479,
118.68163792,
187.07755103,
269.75283457,
389.32432912,
484.94918929,
585.06255389
],
[
138.875,
33.416667,
19.70794649,
38.98454552,
81.94581816,
122.5377889,
166.82435019,
230.58621699,
283.05200618,
339.68994327
],
[
138.875,
33.583333,
31.79147699,
67.41391788,
147.65974968,
219.43997029,
296.74499839,
407.26555253,
497.5097397,
593.91606279
],
[
138.875,
33.75,
42.81719292,
86.38950848,
169.07316594,
240.04375146,
316.16227295,
424.87649609,
513.88068029,
608.76057787
],
[
138.875,
33.916667,
47.53905438,
91.07951418,
175.76554662,
248.98114271,
326.91156958,
437.29637214,
527.1381674,
622.53902174
],
[
138.125,
34.083333,
44.84657752,
80.53551682,
169.18341465,
300.04646345,
474.40515162,
715.09347626,
900.83635788,
1092.29306232
],
[
138.125,
34.25,
55.39905427,
95.9699634,
189.19271173,
316.15589617,
471.39061924,
681.46795481,
843.416177,
1010.37428590
],
[
138.125,
34.416667,
62.84171027,
103.77300974,
194.96537233,
309.54874957,
446.83151634,
636.7875076,
785.02320568,
938.47281640
],
[
138.125,
34.583333,
65.56992758,
105.09238857,
191.08533016,
293.83580992,
416.65428116,
589.76002758,
726.17291017,
867.90615048
],
[
138.375,
34.083333,
39.61808192,
69.55127524,
148.36818121,
270.48568584,
448.11927422,
697.56579311,
887.79543899,
1082.30578610
],
[
138.375,
34.25,
52.48554016,
97.88089232,
219.62503147,
386.23339358,
593.00055289,
879.10122916,
1100.93217742,
1329.84493882
],
[
138.375,
34.416667,
68.03202209,
126.38716493,
256.77444114,
408.53557739,
592.41362265,
852.2813896,
1056.34894668,
1267.37731525
],
[
138.375,
34.583333,
81.28741853,
138.99080766,
255.9430657,
392.58987526,
560.98943708,
799.54890951,
986.76707882,
1180.67390797
],
[
138.625,
34.083333,
39.81432626,
67.81588594,
132.35843104,
211.24014838,
311.37431285,
458.83251437,
576.66686592,
699.24214903
],
[
138.625,
34.25,
46.66668644,
77.13216064,
143.6254547,
227.65271245,
341.92325905,
513.13821214,
648.56146901,
788.85496647
],
[
138.625,
34.416667,
56.94325264,
93.44448541,
167.11677231,
258.76979284,
389.20526813,
586.94366395,
742.55769446,
903.04791611
],
[
138.625,
34.583333,
67.08665386,
110.13478871,
196.27270269,
302.92270288,
454.77187071,
683.18069258,
862.22420639,
1046.89388117
],
[
138.875,
34.083333,
50.13984523,
93.87018895,
180.23903861,
255.72358415,
335.89239071,
448.90765833,
540.31702973,
637.17009186
],
[
138.875,
34.25,
53.11089929,
96.71205043,
184.32526464,
262.32137289,
345.40102407,
462.13847744,
556.15973995,
655.42276878
],
[
138.875,
34.416667,
59.24167606,
104.7280926,
192.29359751,
272.09466057,
358.49321817,
480.70411192,
579.23992712,
683.00656723
],
[
138.875,
34.583333,
63.16385953,
110.83317432,
202.32345102,
285.60980409,
376.75056582,
506.76024816,
611.76238133,
722.61554680
],
[
138.125,
34.75,
67.40465109,
105.74415578,
184.53872846,
275.29761046,
385.91610709,
545.01056138,
671.41362779,
802.97976002
],
[
138.125,
34.916667,
66.05108083,
102.00745707,
173.95905118,
254.85487649,
355.27955406,
502.6750972,
620.60701621,
743.52576484
],
[
138.125,
35.083333,
62.88363009,
96.78952446,
163.62116651,
237.00800316,
328.56935169,
465.09565751,
575.24857569,
690.30252666
],
[
138.125,
35.25,
56.91657312,
88.20260652,
151.43591189,
220.81891097,
306.39309375,
433.5524166,
536.40385744,
644.06811345
],
[
138.375,
34.75,
84.87670764,
137.86923621,
242.87961154,
366.86665814,
521.35056099,
740.71584808,
912.94093448,
1091.32352833
],
[
138.375,
34.916667,
82.93015129,
131.22827142,
226.34044825,
337.13970558,
477.42969935,
679.62658664,
838.76763131,
1003.64191049
],
[
138.375,
35.083333,
76.94307791,
120.39756658,
206.95327087,
306.95431969,
434.18774685,
620.02729461,
767.09402896,
919.68241391
],
[
138.375,
35.25,
65.07972926,
101.55941414,
178.42133731,
269.5441706,
385.30405236,
555.72600725,
691.42170513,
832.54335905
],
[
138.625,
34.75,
76.0115023,
127.30078337,
233.99768805,
366.31410159,
545.42216272,
807.81133274,
1013.68280953,
1226.25072488
],
[
138.625,
34.916667,
82.99242799,
142.11404062,
270.90260465,
423.83005942,
616.13672379,
892.08716619,
1109.39834855,
1334.63879101
],
[
138.625,
35.083333,
85.02844548,
143.92322142,
268.89788322,
407.77330957,
579.61569405,
831.05454756,
1031.35035296,
1239.34673095
],
[
138.625,
35.25,
79.81104254,
125.30801582,
225.85166322,
346.88282844,
494.12410874,
703.83645594,
869.8902473,
1042.89185940
],
[
138.875,
34.75,
67.4669507,
117.64876776,
217.65891438,
307.84864972,
406.11554312,
546.68274204,
660.75653231,
781.47712795
],
[
138.875,
34.916667,
75.58909127,
130.43901621,
244.02037717,
347.92177852,
461.06763984,
622.75414302,
753.46918451,
891.79439555
],
[
138.875,
35.083333,
87.18937883,
144.1790463,
267.59794971,
388.49115709,
520.32743868,
705.36351757,
853.47371648,
1009.22937491
],
[
138.875,
35.25,
113.39758874,
175.91126243,
299.13462117,
426.76047071,
574.70899861,
787.45496588,
958.16672399,
1137.32248038
],
[
138.125,
35.416667,
50.14414919,
78.88527304,
139.29618709,
205.36824055,
284.31292207,
399.82588126,
493.07344113,
591.07928934
],
[
138.125,
35.583333,
45.90662977,
73.60792006,
134.81404773,
199.038442,
271.98223116,
376.31525499,
460.46148098,
549.27702725
],
[
138.125,
35.75,
46.34212829,
78.74907709,
145.85632577,
213.10503672,
291.25728489,
408.72350889,
507.27634778,
613.53464250
],
[
138.125,
35.916667,
47.67960852,
91.38193488,
176.80130815,
256.12902125,
347.61960084,
486.69865405,
604.64969524,
732.63771029
],
[
138.375,
35.416667,
52.98560279,
80.45967041,
143.50600777,
220.66220325,
314.54717569,
449.4017813,
557.06289639,
669.64514079
],
[
138.375,
35.583333,
46.42673648,
70.33621631,
126.29079921,
192.19883819,
270.78864793,
386.12636167,
481.59455778,
585.12562341
],
[
138.375,
35.75,
42.88996277,
67.34652902,
122.72539868,
183.68762741,
259.38273658,
387.96253017,
509.88242139,
649.02805496
],
[
138.375,
35.916667,
39.33715524,
64.58498996,
118.24217566,
171.51236881,
236.02743526,
348.06993789,
460.49302829,
595.02047495
],
[
138.625,
35.416667,
75.36116679,
112.68709064,
189.10642923,
272.14979805,
368.72165543,
506.70399097,
617.0167912,
732.53489374
],
[
138.625,
35.583333,
65.1482444,
96.25093923,
157.44523303,
220.6150474,
293.05050939,
396.50665888,
479.39735773,
566.48167472
],
[
138.625,
35.75,
51.44827691,
76.13858399,
125.22449049,
176.95709558,
237.69544074,
326.73757311,
399.65880067,
477.57537109
],
[
138.625,
35.916667,
40.67660799,
60.46795692,
100.52826122,
143.74785469,
195.86926713,
275.43947364,
343.49702214,
418.82611364
],
[
138.875,
35.416667,
134.90803897,
197.40735644,
298.84741311,
390.96849949,
495.19746233,
649.01608377,
776.17071182,
911.67028527
],
[
138.875,
35.583333,
101.8265076,
146.58489315,
223.49721699,
295.28670403,
376.92717706,
497.17602435,
596.26571854,
701.82134051
],
[
138.875,
35.75,
68.51351136,
100.2332811,
159.52117835,
218.19166501,
286.03950704,
385.82737623,
467.62309104,
554.55053606
],
[
138.875,
35.916667,
48.76026444,
71.95451072,
117.30354744,
164.89182607,
221.65761606,
305.60298638,
373.98968379,
446.24730242
],
[
138.125,
36.083333,
43.06270882,
83.1042152,
169.95412587,
257.49628331,
363.2876739,
529.69880253,
672.80885875,
828.85107945
],
[
138.125,
36.25,
36.63664948,
63.71408412,
116.44040623,
169.52622092,
238.51991131,
370.6613751,
515.90888579,
692.85248649
],
[
138.125,
36.416667,
34.01643645,
58.1878399,
107.33476918,
163.17028521,
239.50480947,
373.90280893,
498.32421245,
638.40008603
],
[
138.125,
36.583333,
33.05353883,
58.30377228,
113.65322551,
179.7883418,
271.34008289,
425.90916895,
560.33458602,
705.00066460
],
[
138.375,
36.083333,
35.34258055,
55.88369119,
96.51813733,
137.42969322,
187.85347467,
277.17228232,
370.75777733,
487.10933612
],
[
138.375,
36.25,
29.07540628,
44.15255506,
73.45997522,
105.72846612,
148.3419508,
227.26815964,
311.16245374,
414.96843523
],
[
138.375,
36.416667,
25.98917754,
39.70887477,
67.9566619,
100.67236566,
148.02678988,
237.15260284,
320.46768774,
412.11188264
],
[
138.375,
36.583333,
26.01535753,
43.40148756,
83.82124415,
133.71335777,
204.48707686,
319.40768534,
413.73140438,
512.51320220
],
[
138.625,
36.083333,
33.69074459,
50.04343226,
84.14099278,
120.62465565,
164.84976137,
233.32398778,
293.09194697,
360.30895910
],
[
138.625,
36.25,
27.51166365,
39.80436297,
64.31668782,
91.73163286,
128.49277158,
189.92396567,
245.8036721,
309.39354550
],
[
138.625,
36.416667,
25.60337149,
37.62182217,
61.01752561,
86.79522042,
120.41506935,
177.69849174,
230.35809848,
289.79793753
],
[
138.625,
36.583333,
22.9977728,
35.0907198,
58.33646318,
84.7878884,
122.3716536,
189.4566854,
248.34822817,
311.30232199
],
[
138.875,
36.083333,
36.93763885,
53.49823935,
84.90389664,
119.56933547,
165.49691243,
237.38461801,
296.39573217,
358.50774440
],
[
138.875,
36.25,
30.09114912,
44.62857528,
71.61979418,
100.95084645,
139.15254913,
201.43524982,
256.6482132,
319.55265675
],
[
138.875,
36.416667,
26.66504879,
38.91779291,
62.37356207,
87.306925,
119.0437625,
170.65747666,
217.19369555,
271.60347243
],
[
138.875,
36.583333,
23.10691194,
33.85588494,
52.7472441,
71.85651939,
96.86260402,
140.54149213,
180.91248145,
226.15584104
],
[
138.125,
36.75,
31.39336386,
56.459375,
109.77928646,
169.8776118,
250.29121809,
383.86871459,
498.87387044,
622.19790376
],
[
138.125,
36.916667,
27.80779416,
48.87584783,
94.45489273,
148.56180994,
221.40505152,
336.55786004,
431.73159509,
532.33349415
],
[
138.125,
37.083333,
25.68072592,
44.36166014,
86.9230132,
138.26676951,
204.7042677,
305.7333316,
388.62789869,
476.61071610
],
[
138.125,
37.25,
24.26528211,
41.89998642,
83.04935551,
131.57745145,
192.69041672,
286.03567692,
364.05892368,
448.30127484
],
[
138.375,
36.75,
26.32778764,
47.73042783,
110.03797336,
188.7304399,
285.63340715,
431.65030869,
552.72965449,
682.13723255
],
[
138.375,
36.916667,
25.94167999,
47.39150998,
109.0984815,
188.01366481,
287.38143086,
447.76841426,
591.33548195,
751.37148357
],
[
138.375,
37.083333,
23.59456373,
43.06845164,
90.99583509,
148.14423182,
220.15124927,
332.96169827,
429.72855351,
535.69302290
],
[
138.375,
37.25,
22.514266,
39.70517062,
81.50058425,
132.58549879,
196.52985715,
292.84129466,
372.70992168,
458.48102843
],
[
138.625,
36.75,
23.29285975,
37.46331103,
68.81230108,
110.24200704,
171.13705335,
267.99286245,
347.41377013,
431.58979919
],
[
138.625,
36.916667,
23.39244197,
40.03702277,
82.97499992,
137.78676343,
210.02645653,
321.99265778,
415.07790457,
514.22800111
],
[
138.625,
37.083333,
21.82199489,
39.91972824,
87.5885798,
146.37036109,
220.6026601,
335.82242589,
433.79101535,
540.41314640
],
[
138.625,
37.25,
22.29197097,
40.78801479,
85.3855125,
137.9507014,
205.29143343,
309.23571296,
395.78265716,
488.24067630
],
[
138.875,
36.75,
22.6291547,
33.95016854,
54.97034369,
77.61074838,
108.199716,
160.33110084,
206.14243028,
255.87750172
],
[
138.875,
36.916667,
22.09059236,
35.14568712,
61.73556544,
93.97535208,
139.69366297,
217.05175461,
284.0662843,
357.03510486
],
[
138.875,
37.083333,
20.62690777,
35.8808309,
71.95748174,
119.32345929,
182.85626758,
282.71627374,
366.89237379,
457.49450652
],
[
138.875,
37.25,
21.36534401,
38.37412674,
79.67536558,
131.31971807,
200.0236323,
311.11350308,
407.11068136,
512.03839605
],
[
138.125,
37.416667,
22.94938285,
40.17136159,
80.28793033,
126.39475879,
184.17826114,
274.73434256,
352.20544151,
436.73041721
],
[
138.125,
37.583333,
22.15320231,
40.27866519,
80.07515969,
124.03566063,
179.99905581,
270.31255186,
348.4489544,
433.85198064
],
[
138.125,
37.75,
20.85325933,
39.08425918,
77.7485545,
120.52749005,
176.68115343,
268.25301768,
347.24188197,
433.17997447
],
[
138.125,
37.916667,
19.98883205,
38.6575119,
78.02757343,
120.80329845,
176.60052928,
267.92645239,
346.88177456,
432.80416942
],
[
138.375,
37.416667,
22.21910815,
39.45533572,
80.20601797,
127.45758736,
186.21662022,
277.10540476,
354.42926135,
438.69051732
],
[
138.375,
37.583333,
20.72220051,
37.85865002,
77.01789366,
121.49784872,
178.50633233,
269.86073871,
348.43118811,
434.06955404
],
[
138.375,
37.75,
20.99002899,
38.79989713,
78.94591683,
122.4895651,
178.00344726,
268.46774715,
347.02957792,
432.84885537
],
[
138.375,
37.916667,
20.22919661,
38.002882,
79.09201223,
123.73768971,
179.33864867,
269.15035833,
347.28341404,
432.83291560
],
[
138.625,
37.416667,
21.72854162,
40.00513294,
84.67483493,
135.01024599,
197.69719054,
295.80472165,
379.25363894,
469.76090085
],
[
138.625,
37.583333,
20.35559149,
38.22527523,
80.26178611,
127.74220561,
187.84181101,
284.39369922,
367.603447,
457.94218553
],
[
138.625,
37.75,
21.029721,
39.19497049,
81.94829067,
128.38434091,
185.66981629,
276.08450689,
353.83820814,
438.67429031
],
[
138.625,
37.916667,
20.81133788,
38.7819144,
83.05774753,
131.81992621,
189.65938074,
278.50822624,
354.73252078,
438.32139507
],
[
138.875,
37.416667,
21.60132919,
39.39338197,
83.46256553,
134.99553211,
200.198595,
303.14421511,
391.26213547,
487.13827081
],
[
138.875,
37.583333,
21.74833738,
40.34106911,
84.42270201,
132.85442283,
193.78671904,
291.82361635,
377.03451253,
470.40805576
],
[
138.875,
37.75,
22.11917517,
40.46892383,
84.81737793,
134.42454392,
194.74430207,
286.68310176,
364.04466324,
447.96612545
],
[
138.875,
37.916667,
22.746849,
41.2035331,
87.72863196,
141.9469033,
206.42843932,
301.54885156,
380.11722408,
464.48799899
],
[
138.125,
38.083333,
18.63962505,
36.08901408,
75.85117337,
119.49469509,
175.64874621,
266.99648417,
346.03037268,
432.11713078
],
[
138.125,
38.25,
17.26083966,
33.1707716,
73.12986949,
118.14596292,
175.12338017,
266.6469084,
345.62668958,
431.70086232
],
[
138.125,
38.416667,
16.0002293,
30.54733604,
70.70928971,
117.06352272,
175.00277142,
266.819382,
345.66686417,
431.54552382
],
[
138.125,
38.583333,
15.05039139,
29.08341704,
68.51385145,
115.02784394,
173.38653341,
265.61275096,
344.65107183,
430.67460141
],
[
138.375,
38.083333,
18.89547638,
36.78259825,
79.76958245,
126.49532606,
183.07002069,
272.31363943,
349.62618565,
434.49399998
],
[
138.375,
38.25,
18.59959517,
36.4101726,
80.23339316,
129.21865641,
188.00564075,
278.13075029,
354.99834934,
439.00047510
],
[
138.375,
38.416667,
18.22956098,
35.86864328,
80.11971923,
131.01854048,
192.34386787,
284.60355349,
361.82720187,
445.56755343
],
[
138.375,
38.583333,
17.87175563,
35.39864007,
79.6120404,
130.61048386,
192.28267905,
284.93388262,
362.32278941,
446.13899959
],
[
138.625,
38.083333,
21.10351135,
39.22671559,
85.31097839,
137.47336704,
197.95459774,
287.71487838,
363.20358755,
445.68005101
],
[
138.625,
38.25,
21.46501779,
39.77633165,
87.06017323,
143.19599331,
209.47218889,
305.66727394,
384.37797818,
468.61295325
],
[
138.625,
38.416667,
20.97561707,
40.12780341,
88.45689894,
147.63855524,
222.09117464,
333.09525471,
422.90346065,
517.42711147
],
[
138.625,
38.583333,
20.75284064,
40.19221409,
88.50520683,
147.45056385,
222.47812017,
335.26311467,
426.57839342,
522.53750235
],
[
138.875,
38.083333,
23.9260502,
43.47131048,
92.56226056,
152.21840407,
222.01329798,
321.36321357,
401.54887656,
486.71347713
],
[
138.875,
38.25,
25.26510257,
45.95921539,
97.2134984,
162.38303349,
240.68773059,
350.82550313,
438.08510116,
529.64972674
],
[
138.875,
38.416667,
26.52798569,
49.26925772,
105.71201062,
176.8103688,
273.76937954,
435.92561725,
575.06219667,
722.17882643
],
[
138.875,
38.583333,
26.81639561,
50.80203136,
110.90799216,
184.98804426,
286.96921799,
468.44612966,
628.60766067,
797.31586215
],
[
138.125,
38.75,
14.23915446,
28.00117674,
66.66558835,
112.64057151,
170.93974447,
263.76162279,
343.34021349,
429.82088327
],
[
138.125,
38.916667,
13.47909419,
26.97496368,
64.69079354,
109.71730001,
168.03445636,
261.8023789,
342.05050867,
428.93742591
],
[
138.375,
38.75,
17.40859157,
34.74252667,
78.44263034,
127.72521297,
187.28325871,
278.26983048,
355.46392592,
439.58679074
],
[
138.375,
38.916667,
16.50797134,
33.70421208,
76.53721656,
123.46964933,
180.91376071,
271.33116075,
349.16092154,
434.28780598
],
[
138.375,
39.083333,
15.95957375,
32.77249213,
74.22631501,
119.37514259,
176.22310839,
267.54485395,
346.39473511,
432.34512231
],
[
138.625,
38.75,
19.86437084,
39.03217721,
86.33893597,
141.7602259,
208.61998175,
306.88091184,
387.21933952,
472.82151996
],
[
138.625,
38.916667,
19.18936587,
37.76564772,
83.42965384,
134.8118052,
195.5862511,
286.68202386,
363.1794267,
446.39334762
],
[
138.625,
39.083333,
18.47324452,
36.56139536,
80.17171203,
128.07386474,
185.68740064,
275.14448978,
352.03462501,
436.27268438
],
[
138.625,
39.25,
18.24081123,
36.44419875,
78.1400008,
123.10884577,
179.21027573,
269.37256516,
347.54080215,
433.06012592
],
[
138.875,
38.75,
25.57464485,
47.80860829,
100.94352743,
166.47374753,
250.09290179,
376.7092588,
480.33791795,
589.68850809
],
[
138.875,
38.916667,
23.96341026,
43.79038972,
92.82738449,
152.12592546,
223.2696162,
326.17761841,
409.35920778,
497.35916201
],
[
138.875,
39.083333,
22.29141088,
40.766972,
87.00668103,
140.02110836,
202.75063611,
295.33883108,
372.19893922,
455.18481132
],
[
138.875,
39.25,
21.51202597,
39.84158644,
83.66987942,
132.15102,
190.80078051,
280.7261466,
357.26069074,
440.83176185
],
[
138.875,
39.416667,
20.58961318,
38.92782626,
81.65877215,
128.99433393,
187.06677623,
277.10120146,
354.05006673,
438.12138625
],
[
138.625,
41.916667,
7.59160653,
9.87690781,
21.11797323,
37.43715446,
66.26798031,
133.42688393,
200.54370293,
272.50391211
],
[
138.875,
41.75,
8.69821971,
14.98699201,
34.61345,
65.24148059,
115.57378344,
215.51971035,
315.32265875,
429.89672023
],
[
138.875,
41.916667,
8.39791368,
13.65427151,
32.20764029,
62.47933736,
115.49962706,
235.50139111,
354.98425307,
483.88431086
],
[
138.625,
42.083333,
7.42822727,
9.66434649,
20.08787065,
36.00245321,
63.76606175,
139.09162107,
215.12807619,
292.41491441
],
[
138.625,
42.25,
7.31928893,
9.52261444,
19.60557433,
34.78741401,
61.49720754,
144.29644398,
225.51592073,
305.54710634
],
[
138.625,
42.416667,
6.87417033,
8.9435018,
17.2568725,
30.03353988,
56.5040149,
145.62158599,
228.86756127,
309.83658565
],
[
138.625,
42.583333,
7.11399575,
9.25552186,
19.18805411,
35.44028258,
64.48765871,
145.40707406,
225.40346449,
305.56657069
],
[
138.875,
42.083333,
8.19925284,
12.77278966,
30.89202014,
60.49371552,
116.86733114,
259.3890071,
392.30578659,
529.14769402
],
[
138.875,
42.25,
8.07388332,
12.17411816,
29.95738019,
58.99570341,
118.34577077,
278.02721306,
419.01650329,
561.00576159
],
[
138.875,
42.416667,
7.82287505,
10.85935855,
29.44492161,
58.86579299,
119.4256955,
283.91828065,
426.97672626,
570.44646786
],
[
138.875,
42.583333,
7.85546389,
11.06007332,
29.96551715,
60.70902625,
120.12601605,
275.49572038,
415.37240022,
557.04223472
],
[
138.875,
42.75,
7.86464231,
11.11665049,
30.35956443,
62.6998655,
120.36662114,
256.53253779,
386.88152135,
523.32451975
],
[
139.625,
32.583333,
7.74080436,
10.20424026,
19.06299242,
28.51319748,
40.4795195,
59.7434557,
76.2918889,
94.17820472
],
[
139.875,
32.583333,
9.13825727,
14.62044168,
25.20005735,
36.53327084,
50.70512023,
73.34624217,
92.66229451,
113.66785839
],
[
139.125,
32.916667,
7.21878532,
9.39185624,
15.23042713,
20.34760106,
27.33542648,
37.99495555,
47.41404102,
57.86055764
],
[
139.125,
33.083333,
8.81016852,
13.35188917,
21.87045003,
30.07573736,
40.18049652,
56.33238786,
70.35078959,
86.16325210
],
[
139.125,
33.25,
15.7286339,
24.82749295,
40.42847933,
55.18762017,
72.20540035,
98.66669013,
121.81088667,
147.71214337
],
[
139.375,
32.75,
6.10617398,
7.9443155,
10.90307039,
15.33904755,
19.77502472,
27.69303051,
34.45254881,
41.85758830
],
[
139.375,
32.916667,
7.24007627,
9.41955639,
15.30932456,
20.47190321,
27.4740076,
38.1839739,
47.64294778,
58.12281130
],
[
139.375,
33.083333,
11.86339694,
18.21922684,
29.09671321,
39.55203171,
51.83374598,
70.34956126,
86.09292458,
103.12324868
],
[
139.375,
33.25,
16.46357103,
25.95071594,
42.18108508,
57.30137037,
74.80462383,
101.65356892,
124.95345667,
150.79482049
],
[
139.625,
32.75,
8.80252787,
13.31196397,
21.94947812,
31.28392973,
43.24422044,
62.29034916,
78.79658696,
96.85336432
],
[
139.625,
32.916667,
12.61448101,
18.89438443,
30.48284324,
41.92050201,
55.19067323,
75.12562029,
91.84942596,
109.92505462
],
[
139.625,
33.083333,
14.99182531,
22.28506091,
35.63849612,
48.11802551,
62.54356802,
84.08003028,
102.0229562,
121.35934192
],
[
139.625,
33.25,
19.42708927,
29.53641206,
46.80549849,
62.44732125,
80.30831557,
107.45239942,
130.57875497,
156.15896124
],
[
139.875,
32.75,
10.00427725,
16.32991265,
27.03437942,
38.39852278,
52.8218407,
75.71235085,
95.36393292,
116.74128948
],
[
139.875,
32.916667,
15.65165808,
22.92221973,
36.38661568,
49.20491386,
64.37173179,
87.24291121,
106.58285131,
127.56151093
],
[
139.875,
33.083333,
17.52343058,
25.84230398,
40.3112739,
54.31571299,
70.19989685,
94.17591514,
114.19426023,
135.80361619
],
[
139.875,
33.25,
20.01646392,
29.9741371,
47.21266036,
62.97013912,
80.94016402,
107.91571286,
130.55958185,
155.20728091
],
[
139.125,
33.416667,
22.64071311,
39.68952129,
72.70577317,
105.48353739,
144.57168536,
205.08533686,
257.03591157,
314.30667107
],
[
139.125,
33.583333,
39.28834986,
76.1599979,
148.85290329,
217.29115901,
293.65063914,
404.32761918,
494.97747377,
591.74325151
],
[
139.125,
33.75,
51.17847444,
93.59431222,
168.33210984,
235.38307041,
309.59855735,
417.60160836,
506.68885436,
601.93021278
],
[
139.125,
33.916667,
55.0834787,
97.13659203,
172.03599042,
239.08746055,
313.14992626,
420.73607218,
509.56754458,
604.56132730
],
[
139.375,
33.416667,
23.86199067,
41.18908825,
74.19075894,
106.63233355,
145.28973097,
205.27998908,
256.92356373,
313.95871115
],
[
139.375,
33.583333,
36.22177327,
68.23059813,
138.85813134,
209.83933853,
288.64964285,
401.34010181,
492.8708196,
590.17217419
],
[
139.375,
33.75,
47.16952082,
85.51631029,
158.36569377,
226.79467811,
302.8430946,
412.93056391,
503.03803981,
599.11067859
],
[
139.375,
33.916667,
54.03201484,
93.5243988,
165.24043156,
231.68847559,
306.1084306,
414.86647587,
504.49497914,
600.28785843
],
[
139.625,
33.416667,
25.64513032,
42.00260272,
73.69392039,
105.3524283,
143.50141903,
203.31271238,
255.16475625,
312.49906259
],
[
139.625,
33.583333,
35.17702489,
64.76349893,
135.01204674,
207.14810835,
286.86027229,
400.25325641,
492.14745484,
589.74254380
],
[
139.625,
33.75,
44.0573942,
80.90090581,
154.53074672,
223.93951824,
300.76588406,
411.53960737,
501.98179137,
598.36754955
],
[
139.625,
33.916667,
47.7697962,
84.64102889,
156.78152734,
225.22621792,
301.49893426,
411.99283221,
502.42662772,
598.87913837
],
[
139.875,
33.416667,
24.39186111,
37.4756199,
61.25891288,
84.37112859,
111.85224681,
155.58091278,
194.63069095,
239.13438005
],
[
139.875,
33.583333,
29.85321975,
48.01786791,
84.42835695,
124.52104856,
176.41526556,
259.89131259,
331.65013774,
409.58976110
],
[
139.875,
33.75,
34.55377383,
55.65779899,
96.78224403,
139.43085315,
192.04109616,
274.56207916,
345.14448263,
422.07611270
],
[
139.875,
33.916667,
37.06513252,
58.86858131,
100.59479046,
143.12319049,
194.99839477,
276.43239018,
346.43990225,
422.97539849
],
[
139.125,
34.083333,
57.06535934,
99.15836426,
174.61827744,
242.05878644,
316.26553187,
423.8369758,
512.52148557,
607.32081537
],
[
139.125,
34.25,
60.52369698,
103.71981817,
179.18107634,
246.63769325,
320.76911149,
428.21638312,
516.65122507,
611.08538908
],
[
139.125,
34.416667,
62.15972273,
106.12397671,
183.87515573,
252.42416523,
327.21334947,
435.01968474,
523.61138486,
618.09526417
],
[
139.125,
34.583333,
65.48630189,
111.31504954,
193.19463271,
263.51832036,
339.19195594,
447.55427565,
536.24433574,
630.82339984
],
[
139.375,
34.083333,
55.87488271,
95.6166308,
167.38970616,
233.53691895,
307.56950187,
415.87124101,
505.28258331,
600.91640390
],
[
139.375,
34.25,
60.45844598,
101.12759404,
172.9019337,
238.08086921,
311.08002856,
418.12658873,
506.82670932,
601.82387280
],
[
139.375,
34.416667,
62.8329325,
104.93821925,
178.98830628,
244.75442121,
317.35628774,
423.44470649,
511.41201371,
605.73620899
],
[
139.375,
34.583333,
65.86872985,
109.77645254,
188.35495359,
256.54167346,
330.33414656,
436.48202,
523.94269782,
617.46555455
],
[
139.625,
34.083333,
50.40456422,
88.70690792,
160.45128758,
227.71561954,
303.03685285,
412.82101438,
503.00090643,
599.29933010
],
[
139.625,
34.25,
53.82077271,
91.95099138,
164.84228366,
232.11199173,
306.84171935,
415.55181688,
505.02980874,
600.62870033
],
[
139.625,
34.416667,
56.72899044,
95.93421981,
171.96217459,
241.15175834,
316.78109612,
425.60624403,
514.89476838,
610.10817590
],
[
139.625,
34.583333,
63.3871086,
105.61332932,
186.67950071,
260.16642727,
339.86027475,
453.3936241,
545.6083399,
643.59461458
],
[
139.875,
34.083333,
41.2480857,
64.45257816,
108.1284073,
151.20023405,
202.50945095,
282.14225031,
350.82951017,
426.26883563
],
[
139.875,
34.25,
43.28606731,
67.03260626,
113.33828283,
159.53395218,
213.58157321,
294.92347846,
363.62098974,
438.45959054
],
[
139.875,
34.416667,
46.7120148,
71.41996828,
121.43023151,
174.04647551,
235.84040127,
326.85244173,
401.75508773,
481.94535029
],
[
139.875,
34.583333,
52.62472862,
79.51192386,
135.40360014,
200.28706065,
281.88429636,
404.36149163,
505.66855078,
614.41042321
],
[
139.125,
34.75,
69.4430107,
118.07335642,
208.23028865,
284.05700805,
363.73222989,
475.5200577,
565.85345651,
661.41452518
],
[
139.125,
34.916667,
77.18579581,
129.0503233,
231.84253447,
321.50764535,
415.26061945,
544.93212613,
647.99038596,
756.05362582
],
[
139.125,
35.083333,
93.62612539,
151.65096737,
269.27950519,
383.87652051,
511.62221908,
693.52634858,
839.86455379,
993.68481435
],
[
139.125,
35.25,
124.14571509,
193.63357563,
326.20644742,
457.70922327,
610.4476175,
834.22548229,
1016.12461393,
1207.53834948
],
[
139.375,
34.75,
70.1315934,
116.41531497,
202.25673772,
276.98775973,
356.6837092,
469.2348955,
560.29492511,
656.68238935
],
[
139.375,
34.916667,
79.1191366,
128.6699662,
225.02959628,
314.84934072,
414.50861756,
558.28567153,
675.28357211,
799.06616544
],
[
139.375,
35.083333,
99.22808012,
161.23219706,
284.7006891,
412.47543078,
567.63964317,
799.9386146,
989.22022749,
1188.03046125
],
[
139.375,
35.25,
115.87453831,
177.42152615,
287.93039214,
396.32874844,
525.12724445,
717.97036161,
876.68870943,
1045.00508470
],
[
139.625,
34.75,
68.82170398,
110.82923676,
197.12278801,
281.11943804,
373.6478515,
504.34971618,
609.07738328,
719.12077742
],
[
139.625,
34.916667,
81.13464662,
124.19999597,
209.44300358,
303.52046913,
425.16234929,
612.99324965,
766.09907408,
926.42074016
],
[
139.625,
35.083333,
108.50417942,
168.03363986,
279.91881833,
397.05537816,
542.40821685,
763.46374085,
944.18966271,
1134.37650938
],
[
139.625,
35.25,
117.14150553,
172.07631245,
269.55867089,
368.19909029,
488.18837817,
669.69937136,
818.50544651,
975.63706712
],
[
139.875,
34.75,
64.74160106,
98.11125462,
171.99159004,
274.04580214,
414.02411655,
619.66280031,
785.07884224,
960.04351930
],
[
139.875,
34.916667,
89.1868773,
134.83209329,
226.19273864,
340.65001571,
509.13471439,
770.46513704,
976.5092851,
1188.53343292
],
[
139.875,
35.083333,
115.45232452,
173.5513538,
277.67671732,
383.94359906,
514.6534786,
713.55318891,
877.26864728,
1050.33876088
],
[
139.875,
35.25,
112.20274109,
159.64081436,
242.61751547,
324.60951984,
423.05711049,
573.32191405,
698.00544854,
831.08824550
],
[
139.125,
35.416667,
135.98579773,
195.80526982,
297.75740925,
397.77197984,
518.94861479,
703.88976754,
857.72894771,
1021.24656949
],
[
139.125,
35.583333,
107.08948416,
152.23966948,
232.20465801,
311.35549986,
406.19812573,
549.7944858,
668.61940707,
794.40794593
],
[
139.125,
35.75,
77.3218007,
111.68815256,
176.04388987,
242.04106349,
321.73531947,
442.17110228,
541.52062471,
646.63014039
],
[
139.125,
35.916667,
58.34955718,
85.63426193,
139.59476823,
197.58470956,
267.96593684,
373.30411452,
460.02522885,
552.56764931
],
[
139.375,
35.416667,
106.29229963,
152.88463699,
236.84634203,
321.87008068,
425.07535238,
581.82957489,
710.99208723,
847.81571328
],
[
139.375,
35.583333,
89.85317599,
127.33432225,
195.76548346,
266.66392115,
353.42316968,
485.21413478,
593.75647886,
708.51109152
],
[
139.375,
35.75,
74.67089223,
106.48762722,
166.33244994,
230.04536284,
309.50325571,
433.2110845,
538.39546423,
653.06107685
],
[
139.375,
35.916667,
60.74543601,
86.89132133,
136.37975234,
189.64681452,
255.94581175,
356.14715462,
438.52417715,
526.21565615
],
[
139.625,
35.416667,
100.82497803,
141.97453162,
213.26085149,
283.95500267,
371.17785843,
507.96899153,
623.23116099,
746.11581340
],
[
139.625,
35.583333,
84.8471854,
117.16366382,
172.54585419,
228.1472448,
298.20310614,
411.96588082,
509.34043886,
613.46743175
],
[
139.625,
35.75,
71.79564565,
98.35104809,
143.73773767,
189.11256153,
246.97741438,
341.16568549,
422.35250852,
509.69847079
],
[
139.625,
35.916667,
63.55991884,
87.7107451,
129.29023271,
170.25135615,
220.62603846,
301.16910486,
371.86182421,
450.73680147
],
[
139.875,
35.416667,
99.12209629,
137.52247393,
202.95971191,
266.87623244,
344.40186441,
465.43613778,
568.0397674,
677.98690371
],
[
139.875,
35.583333,
86.98525085,
118.89191963,
172.43147379,
224.37669123,
287.64677984,
387.420071,
472.57365388,
564.43556343
],
[
139.875,
35.75,
76.39063946,
103.728063,
148.54570374,
190.55646389,
240.47039151,
318.42950084,
385.61962564,
459.10079888
],
[
139.875,
35.916667,
68.08193086,
92.12818638,
130.56418748,
165.0399908,
204.15598197,
262.65790931,
311.9718109,
365.39378574
],
[
139.125,
36.083333,
45.89261672,
66.83083088,
109.88145619,
160.39242663,
224.21160389,
320.33937685,
400.16919973,
486.22850587
],
[
139.125,
36.25,
39.0078391,
57.26551122,
94.09614465,
136.79507311,
193.47191634,
289.12194685,
379.17597922,
487.25560667
],
[
139.125,
36.416667,
33.5934685,
49.06800454,
79.0077599,
110.79589392,
151.17374559,
217.84851339,
278.39002268,
347.47268139
],
[
139.125,
36.583333,
27.94419452,
40.69584474,
64.03210133,
87.93330838,
119.53365796,
176.48352049,
231.44904484,
295.10722065
],
[
139.375,
36.083333,
52.3750868,
75.26434198,
119.25743739,
167.20782094,
227.42043198,
321.07868575,
401.18407263,
489.20605975
],
[
139.375,
36.25,
45.71765024,
66.2421658,
105.89759631,
148.55694394,
202.84037828,
290.17577855,
366.40806854,
450.48438364
],
[
139.375,
36.416667,
39.00433253,
57.69667921,
93.87584199,
133.01112799,
183.93329944,
268.5782034,
343.36580071,
425.84898891
],
[
139.375,
36.583333,
32.80956042,
48.69347315,
79.81688144,
115.95516875,
167.19833422,
256.25852427,
334.26387651,
418.93443880
],
[
139.625,
36.083333,
56.56451467,
78.7896484,
117.68240746,
156.06366983,
203.27341199,
279.21852333,
346.63230258,
421.99564468
],
[
139.625,
36.25,
50.39570097,
71.17666641,
108.23813146,
145.64513098,
192.75313547,
271.4294993,
342.60922271,
422.74228235
],
[
139.625,
36.416667,
45.28244204,
64.76302032,
100.23956822,
137.09820187,
184.80595376,
266.39159225,
340.32109605,
422.72852590
],
[
139.625,
36.583333,
39.77553582,
57.20533109,
89.7656636,
126.34212667,
176.80421773,
263.8005066,
340.42583273,
424.10622283
],
[
139.875,
36.083333,
61.56967277,
83.51153562,
117.99296781,
148.06833295,
181.31426434,
229.96646743,
270.10380895,
313.20517733
],
[
139.875,
36.25,
55.32151484,
75.35304101,
106.99623506,
134.61807184,
165.20994783,
210.26185157,
247.82094856,
288.70297356
],
[
139.875,
36.416667,
48.43348214,
66.28280084,
95.19904912,
121.63638279,
152.71790988,
202.22807157,
247.30225349,
299.63760023
],
[
139.875,
36.583333,
43.62156619,
60.20680943,
89.01030651,
117.96109994,
156.15312263,
225.95312988,
293.3556862,
370.48685762
],
[
139.125,
36.75,
26.29356935,
38.57723663,
61.5940184,
86.13981826,
118.71111234,
176.28648094,
230.80773206,
293.74682854
],
[
139.125,
36.916667,
22.77388,
35.47427094,
59.92596426,
86.9711109,
122.52827153,
183.02590063,
238.28334437,
301.07177222
],
[
139.125,
37.083333,
19.89255809,
34.20776608,
62.88313349,
94.40456502,
134.89576393,
200.71040257,
258.65248478,
323.10397779
],
[
139.125,
37.25,
21.09462841,
37.19650564,
71.43353551,
109.88827769,
159.51585303,
239.04601597,
307.53834,
382.30440501
],
[
139.375,
36.75,
29.49773578,
44.89939009,
75.56783829,
112.18184353,
164.92728513,
255.39749898,
333.86955445,
418.80937952
],
[
139.375,
36.916667,
27.48859308,
42.03759543,
72.95437275,
110.74445529,
164.65915261,
255.53578373,
333.97153618,
418.81119494
],
[
139.375,
37.083333,
21.28889956,
36.35736283,
69.75523729,
110.35851388,
165.45993596,
256.16171992,
334.31621206,
418.95231567
],
[
139.375,
37.25,
21.72661351,
38.02464949,
73.87069316,
115.0472073,
169.54506208,
259.07527964,
336.57222619,
420.79382428
],
[
139.625,
36.75,
36.23521362,
52.77378013,
85.32989434,
123.2991645,
177.12307393,
268.35947796,
346.88317064,
431.63183540
],
[
139.625,
36.916667,
28.56372726,
45.2368622,
79.55326437,
120.46814596,
177.11737816,
270.14675104,
349.1517685,
434.04806839
],
[
139.625,
37.083333,
26.67914205,
42.9499173,
77.92055191,
119.66777587,
176.51001487,
268.36860239,
346.26728412,
430.21966280
],
[
139.625,
37.25,
23.31931553,
40.53956914,
78.02509831,
120.92176404,
177.93625265,
269.48932545,
347.12543211,
430.89483247
],
[
139.875,
36.75,
39.2588922,
55.79930363,
86.37350071,
121.07843343,
172.71057732,
269.46857098,
357.49534754,
454.42153275
],
[
139.875,
36.916667,
35.56818377,
52.00407165,
87.1628762,
134.03965937,
207.33919661,
338.95577033,
461.14912424,
601.00171156
],
[
139.875,
37.083333,
33.35485414,
49.48145982,
85.74312147,
133.46367887,
202.15351467,
315.95528246,
415.85633262,
527.25627793
],
[
139.875,
37.25,
22.46932543,
39.09388014,
77.04366226,
122.517889,
184.11707084,
283.72936951,
368.2556841,
459.16738701
],
[
139.125,
37.416667,
21.48852652,
38.6142032,
77.4230131,
121.84989504,
178.8971499,
269.95477619,
347.99679181,
432.94376780
],
[
139.125,
37.583333,
21.95121691,
40.43474466,
83.1953772,
130.55372985,
189.59404702,
282.69624031,
363.35542335,
452.53868776
],
[
139.125,
37.75,
23.00029094,
41.66778729,
87.0790456,
139.65352286,
204.36820056,
302.12080043,
383.81364707,
472.15837800
],
[
139.125,
37.916667,
24.26752561,
44.75561565,
94.33466512,
153.65054904,
230.60571568,
350.23373287,
449.10004119,
553.61299753
],
[
139.375,
37.416667,
22.08294515,
39.07663634,
77.19817148,
119.9397297,
174.96617921,
263.84806878,
340.7063171,
424.53420086
],
[
139.375,
37.583333,
22.33692054,
40.51193499,
81.68238174,
127.0886876,
183.69440953,
272.74626799,
349.19339106,
432.77635257
],
[
139.375,
37.75,
23.88651619,
42.76292773,
87.34198804,
139.44384757,
204.79992205,
303.61806886,
385.47935235,
473.23206373
],
[
139.375,
37.916667,
25.5888541,
45.99825462,
94.76692487,
154.57319374,
235.95191146,
366.66762254,
475.4470881,
590.54253498
],
[
139.625,
37.416667,
22.01806596,
40.01858799,
79.90575635,
124.36517307,
181.91997059,
275.06116605,
354.88835116,
441.20303251
],
[
139.625,
37.583333,
22.94016333,
41.18659042,
82.51365896,
128.37185115,
186.37346215,
278.30524136,
356.79435901,
441.68372025
],
[
139.625,
37.75,
24.82531598,
43.58753613,
85.96122999,
134.10542095,
194.39996323,
286.87124835,
364.27716579,
447.78008090
],
[
139.625,
37.916667,
25.58159764,
44.527061,
88.57141369,
140.44034996,
205.14284111,
301.84396601,
381.25708029,
465.98055769
],
[
139.875,
37.416667,
21.89522503,
39.90600059,
80.59788616,
127.67654036,
189.94792729,
291.2296984,
378.92020889,
475.26528550
],
[
139.875,
37.583333,
23.74838546,
42.0485022,
85.19819018,
135.49403142,
200.94662517,
308.16704204,
403.89810242,
512.67194816
],
[
139.875,
37.75,
24.98642898,
43.87777927,
86.20096414,
133.6761312,
194.88751144,
295.79678889,
385.95897241,
487.33179222
],
[
139.875,
37.916667,
25.58448291,
44.33341679,
86.17733053,
132.50385217,
189.81115157,
279.05767225,
355.12705418,
437.81026071
],
[
139.125,
38.083333,
26.04903014,
49.6856699,
110.23899617,
180.30976005,
268.89832303,
408.47967252,
525.97967076,
650.59649013
],
[
139.125,
38.25,
28.35633218,
55.73553001,
120.41911716,
195.94200987,
288.32097697,
423.4071346,
532.483665,
646.95261245
],
[
139.125,
38.416667,
31.00536355,
61.27437714,
127.56033687,
207.43728547,
307.61125882,
451.03961867,
563.91211833,
680.83382954
],
[
139.125,
38.583333,
32.5009217,
66.48840228,
142.79843284,
232.08109986,
346.51668233,
522.22062732,
666.59778434,
819.16715717
],
[
139.375,
38.083333,
27.2020352,
50.47874252,
109.60969017,
181.37902247,
279.60457157,
448.11391768,
592.48080358,
744.43318975
],
[
139.375,
38.25,
29.19405932,
55.94730558,
123.60934019,
206.5075092,
318.75439903,
511.19898849,
676.19708839,
849.66447674
],
[
139.375,
38.416667,
31.71342358,
60.55499769,
135.18358185,
230.8074926,
363.60097125,
590.408342,
781.28429857,
980.07621806
],
[
139.375,
38.583333,
33.98569511,
65.86690099,
145.51076692,
249.96548316,
393.17011173,
624.88707774,
817.64680074,
1019.97486462
],
[
139.625,
38.083333,
26.47884608,
46.13206927,
92.4380628,
146.72933761,
213.82344426,
314.22207791,
396.67561542,
484.50499812
],
[
139.625,
38.25,
27.56333586,
47.92946157,
96.1664841,
153.66194883,
224.72336679,
330.64995027,
417.66465883,
510.78426519
],
[
139.625,
38.416667,
28.75705137,
49.87920099,
99.8927539,
160.12427048,
234.05731193,
342.23539793,
429.79032878,
522.28895342
],
[
139.625,
38.583333,
29.9708494,
52.50921617,
105.29814955,
170.25769177,
250.22898902,
365.77396112,
458.38419786,
555.69057231
],
[
139.875,
38.083333,
25.97883904,
44.88364995,
88.18290948,
136.06922324,
194.22825171,
284.14718641,
360.83936198,
444.50792886
],
[
139.875,
38.25,
26.54035212,
45.67359403,
89.37300232,
137.71725056,
195.88385258,
284.63508724,
359.71627449,
441.44678699
],
[
139.875,
38.416667,
27.11636441,
46.39031424,
91.13780688,
140.90173473,
199.36107767,
286.93763198,
360.75880553,
441.43108422
],
[
139.875,
38.583333,
27.83155502,
47.57763016,
94.40870941,
147.53016683,
209.155068,
299.0362535,
373.66220463,
454.40062059
],
[
139.125,
38.75,
31.47990598,
62.63647815,
138.35060106,
234.63521052,
365.89707711,
584.12810901,
770.10348904,
966.68732411
],
[
139.125,
38.916667,
28.77126741,
54.01245094,
112.31109084,
184.26049811,
277.79684401,
421.24322049,
539.31112531,
663.91613606
],
[
139.125,
39.083333,
26.86270133,
48.38052785,
98.71908449,
159.08588145,
233.43604479,
342.77148959,
431.4162145,
525.06229362
],
[
139.125,
39.25,
25.04010783,
45.29065369,
92.04108419,
146.99054559,
216.07213976,
319.60918523,
404.02981438,
493.28422887
],
[
139.375,
38.75,
34.7247204,
68.31534306,
147.25659621,
245.99594604,
378.99939578,
580.74315402,
742.57361035,
911.56827783
],
[
139.375,
38.916667,
33.71431002,
65.5201659,
144.33706481,
242.66954398,
376.59592879,
601.2325994,
793.41810037,
996.43478891
],
[
139.375,
39.083333,
31.90601605,
61.77513315,
130.82738742,
209.65859954,
315.37394146,
500.04555741,
662.18028578,
833.97846344
],
[
139.375,
39.25,
29.66553213,
57.14922662,
117.43325834,
186.14605027,
281.9458202,
449.93055399,
594.79691259,
747.37209475
],
[
139.625,
38.75,
31.7260116,
55.95471011,
112.15593938,
183.05485146,
270.92766559,
396.26701835,
495.5405072,
599.05251899
],
[
139.625,
38.916667,
32.91382209,
60.21342227,
121.73137093,
194.4729449,
285.64207352,
421.23073537,
531.44430723,
647.26954442
],
[
139.625,
39.083333,
33.50803051,
64.08054189,
129.28770034,
199.83513082,
290.22853528,
435.15069265,
557.77671248,
688.12097278
],
[
139.625,
39.25,
31.73716849,
62.84668317,
129.93374584,
202.79225115,
299.61558342,
461.51032247,
599.31854558,
745.14889254
],
[
139.875,
38.75,
28.53929247,
49.2439261,
100.04860461,
158.96729198,
227.35954181,
327.06115351,
409.76773591,
499.30823154
],
[
139.875,
38.916667,
29.30860228,
51.26133376,
104.62459313,
166.35233473,
239.42724366,
348.13036608,
439.29238811,
538.94670859
],
[
139.875,
39.083333,
29.72080816,
52.1980998,
103.01145552,
161.36551681,
232.78968961,
339.62510075,
428.04126278,
523.00400317
],
[
139.875,
39.25,
29.72072419,
52.54831862,
100.99458528,
157.2401734,
228.05622755,
333.63280564,
419.32181554,
509.87133450
],
[
139.125,
39.416667,
23.5279728,
42.91781397,
87.86582203,
140.75072454,
208.0884887,
309.00959112,
391.24468919,
478.36066837
],
[
139.125,
39.583333,
22.26333663,
40.98304505,
85.54473081,
138.00745852,
203.11166938,
299.59813703,
378.70928052,
463.26132352
],
[
139.125,
39.75,
21.0236437,
39.40528732,
84.4718072,
136.71278748,
199.36067874,
292.68825071,
370.4065478,
454.42058867
],
[
139.125,
39.916667,
21.0741164,
40.97262533,
89.72779538,
144.3933969,
211.60329045,
316.86161627,
407.59227776,
507.03628061
],
[
139.375,
39.416667,
27.30806872,
50.41835417,
102.39938292,
164.41791117,
254.59412408,
410.18707535,
540.90420204,
677.51116773
],
[
139.375,
39.583333,
24.30130936,
44.55909489,
91.37697833,
149.53841399,
228.96650294,
351.80503145,
451.20712345,
555.06467262
],
[
139.375,
39.75,
22.38750682,
40.98382045,
87.48683129,
143.61290984,
211.6666545,
310.60005399,
390.97059382,
476.44771691
],
[
139.375,
39.916667,
21.98141648,
41.40117439,
90.25875556,
146.5314737,
215.17712349,
321.83751067,
413.87353782,
515.31602277
],
[
139.625,
39.416667,
28.97928988,
55.12721216,
114.788934,
186.29167426,
289.89252495,
475.70870665,
635.49898075,
802.30404965
],
[
139.625,
39.583333,
26.62585781,
47.5319457,
95.37388128,
154.79764115,
237.24533793,
367.75964341,
474.14655256,
585.39010205
],
[
139.625,
39.75,
24.42821182,
42.87506036,
88.77309619,
144.85588423,
212.33702819,
310.23022945,
389.82207595,
474.55979191
],
[
139.625,
39.916667,
23.77783361,
42.08711926,
87.82739996,
141.43589233,
205.26233477,
300.13157417,
379.25558453,
464.67060025
],
[
139.875,
39.416667,
28.59247423,
50.92179018,
99.56976603,
157.45882777,
233.30300486,
347.40926925,
439.23460044,
535.48963009
],
[
139.875,
39.583333,
26.50677715,
46.74456931,
93.48655204,
149.47435954,
220.60226751,
326.22502607,
411.61283094,
501.63651444
],
[
139.875,
39.75,
25.21998344,
44.04681061,
88.7421222,
141.39874009,
204.94203275,
298.96429618,
376.87791723,
460.77381143
],
[
139.875,
39.916667,
24.52750078,
43.15370542,
87.81083648,
138.5517098,
199.98787736,
294.56770518,
375.14215383,
462.98460178
],
[
139.125,
40.083333,
21.37205924,
43.37435907,
98.49022638,
162.89371725,
246.06076519,
379.90466373,
496.38130997,
624.15636409
],
[
139.125,
40.25,
21.54366558,
44.70880153,
102.12409659,
172.51078999,
267.51976671,
423.14029352,
556.99809724,
700.64547223
],
[
139.125,
40.416667,
20.60530302,
43.22628482,
101.72608522,
176.95908399,
281.2790569,
454.05507024,
599.79096187,
753.50408006
],
[
139.125,
40.583333,
20.05654324,
42.66968376,
101.45050642,
178.47224121,
287.92340708,
470.21985729,
622.08987114,
780.54551564
],
[
139.375,
40.083333,
22.19676635,
43.01493193,
95.3248882,
157.02022914,
237.7137938,
369.71928279,
485.09092694,
611.70218895
],
[
139.375,
40.25,
22.51359807,
44.23669388,
98.13543453,
165.73783223,
259.12111893,
414.07888748,
547.37774674,
690.49771078
],
[
139.375,
40.416667,
21.70694261,
43.07660976,
98.70120151,
172.26695139,
275.99715357,
448.70783912,
594.59674046,
748.33425616
],
[
139.375,
40.583333,
21.67379344,
43.56309643,
100.65251442,
176.74017552,
285.84280249,
468.30136411,
620.3226725,
778.86178512
],
[
139.625,
40.083333,
23.57487685,
42.23624778,
87.58827645,
141.05126784,
208.33325175,
311.30803625,
396.94501717,
488.48410972
],
[
139.625,
40.25,
23.58159946,
42.50507489,
87.6219675,
143.02365639,
216.42612135,
330.29558961,
424.28600667,
524.11522352
],
[
139.625,
40.416667,
22.75516643,
41.07009775,
86.51681044,
145.45153706,
225.6690335,
351.45828168,
455.40621744,
565.49864924
],
[
139.625,
40.583333,
22.47990082,
41.08922826,
87.88780743,
149.02770129,
234.67553081,
372.67113926,
487.55264632,
609.08435108
],
[
139.875,
40.083333,
24.15336544,
43.20058379,
89.21944935,
141.05856843,
204.95740748,
305.19828808,
391.63115616,
486.19789345
],
[
139.875,
40.25,
23.87771202,
42.69362834,
87.23744646,
138.84294584,
203.86879623,
304.1357272,
388.51252345,
479.51046061
],
[
139.875,
40.416667,
22.8203015,
40.08722922,
81.99251991,
134.06547359,
200.04541855,
298.43322273,
379.04485115,
465.08172241
],
[
139.875,
40.583333,
23.2273505,
39.90560867,
81.04392884,
133.15609386,
199.15524734,
297.25784745,
377.53011243,
463.16388607
],
[
139.125,
40.75,
19.83766692,
42.32647439,
100.39534278,
177.28640199,
287.35909629,
471.14813931,
623.93581453,
783.07501191
],
[
139.125,
40.916667,
18.86791537,
40.58138401,
98.28499141,
173.43623801,
279.14599062,
455.0524319,
602.89991761,
758.24972742
],
[
139.125,
41.083333,
17.53452566,
38.23635579,
94.96578882,
166.7044244,
264.07740785,
424.06197448,
560.99893363,
707.13956203
],
[
139.125,
41.25,
16.89299909,
34.89767603,
88.67675942,
156.5991731,
243.88033778,
382.91271223,
503.13389459,
634.32633798
],
[
139.375,
40.75,
21.82610594,
44.32795936,
102.10262167,
178.52603808,
288.21622864,
471.4218507,
623.87784387,
782.78089105
],
[
139.375,
40.916667,
22.1954523,
44.64820715,
102.66986503,
177.85957555,
283.25696826,
458.36396972,
605.78055487,
760.84063198
],
[
139.375,
41.083333,
20.98678324,
43.61131246,
101.97989773,
174.39142426,
271.54645946,
430.90681599,
567.65605498,
713.82552494
],
[
139.375,
41.25,
19.31398679,
40.52314454,
98.09584735,
166.82912267,
253.89437216,
392.35132379,
512.51684249,
643.69879876
],
[
139.625,
40.75,
23.47757741,
42.47507462,
89.8792228,
152.89703658,
243.0333426,
392.02889726,
517.69617813,
650.75096795
],
[
139.625,
40.916667,
23.22308207,
42.69542215,
91.62340125,
156.17193488,
248.09758317,
401.94423798,
533.87220895,
674.62864943
],
[
139.625,
41.083333,
22.48548232,
42.24729472,
92.65092188,
157.31713924,
245.74891775,
391.5896434,
518.00482232,
654.45291923
],
[
139.625,
41.25,
23.43392139,
41.56882942,
90.63861919,
154.05008165,
236.34561189,
367.09065175,
480.14193062,
604.20450496
],
[
139.875,
40.75,
23.41014536,
40.38502683,
81.49658837,
133.47236644,
200.83360508,
302.02551658,
384.59736148,
472.20034364
],
[
139.875,
40.916667,
25.32743088,
42.14512268,
82.36661658,
134.16258522,
202.77591019,
306.91188772,
391.8963366,
481.81509292
],
[
139.875,
41.083333,
25.11431018,
41.99350861,
82.4370236,
133.97851801,
202.26092965,
307.2523349,
393.66292119,
485.39245515
],
[
139.875,
41.25,
24.26062255,
40.30982996,
79.6461163,
130.01350395,
196.63006236,
299.88671919,
385.87770615,
477.73313836
],
[
139.125,
41.416667,
15.18804911,
29.41378344,
75.15090617,
137.47997166,
217.06139073,
338.5555932,
440.63939526,
551.20667100
],
[
139.125,
41.583333,
13.5774141,
25.47256586,
60.20089565,
111.35173297,
182.5812721,
299.15533041,
401.22776614,
514.36769434
],
[
139.125,
41.75,
9.56074547,
19.31259791,
51.00782663,
100.84676307,
176.65253735,
313.22478512,
438.43349318,
576.22345347
],
[
139.125,
41.916667,
9.06903805,
17.53357326,
47.9378803,
99.04707797,
183.71011344,
345.26684338,
488.49358961,
639.53488745
],
[
139.375,
41.416667,
17.6307524,
35.31563758,
84.87248288,
146.32817683,
223.45226143,
341.91884056,
441.98235236,
550.59365508
],
[
139.375,
41.583333,
15.96823787,
29.80188772,
68.59227552,
119.13565608,
187.78580227,
301.09409537,
401.5985373,
513.98450539
],
[
139.375,
41.75,
14.48034048,
26.59528285,
60.16008521,
109.08709009,
182.53664935,
317.28604004,
442.51840091,
580.83801139
],
[
139.375,
41.916667,
12.27268422,
23.80083351,
57.20001121,
107.88982125,
190.47024021,
350.33540469,
493.55889299,
645.05867969
],
[
139.625,
41.416667,
21.81774514,
37.97308787,
80.0946106,
136.21145561,
208.89245643,
320.64536359,
414.50460373,
515.93453534
],
[
139.625,
41.583333,
17.14634203,
30.90237647,
66.57065766,
112.95154573,
176.60003952,
280.74007918,
371.62243681,
471.92160035
],
[
139.625,
41.75,
15.86689099,
28.13391212,
59.90147912,
104.28469251,
170.20834635,
287.72034653,
394.50969225,
513.18880454
],
[
139.625,
41.916667,
14.85940779,
26.59461453,
57.72669433,
102.8706007,
175.2608576,
309.94875074,
430.34381633,
560.72178835
],
[
139.875,
41.416667,
22.99822761,
37.79280533,
71.86550784,
115.0519066,
172.965169,
264.7936564,
342.40409898,
426.16201710
],
[
139.875,
41.583333,
21.5617335,
35.05708692,
64.50442334,
102.10450761,
155.07736743,
241.34721845,
314.76078805,
393.94428604
],
[
139.875,
41.75,
20.29097764,
33.13937537,
61.05502214,
97.85313168,
151.25332403,
240.10924224,
315.97399696,
397.56315736
],
[
139.875,
41.916667,
19.48305206,
31.80422946,
59.4393514,
96.76242318,
152.74414621,
246.72915982,
325.76024635,
409.85167323
],
[
139.125,
42.083333,
8.84664318,
16.67389956,
46.49058683,
98.40516815,
193.07332592,
376.82030177,
531.35710525,
689.73358960
],
[
139.125,
42.25,
8.7102176,
16.13867507,
45.39031615,
97.97431544,
200.65942706,
400.82133936,
562.55176255,
725.66660736
],
[
139.125,
42.416667,
8.48248734,
15.34374152,
45.37361625,
98.24631468,
202.96627513,
407.16768316,
570.50960954,
734.72992101
],
[
139.125,
42.583333,
8.51532415,
15.52222796,
46.36140547,
99.24185829,
198.79735972,
393.84379792,
553.54578156,
715.34605454
],
[
139.375,
42.083333,
9.54078061,
19.95405198,
55.0881675,
107.9263968,
200.30497417,
381.84725814,
536.43628162,
695.29279397
],
[
139.375,
42.25,
9.28766704,
19.39733309,
54.14916065,
108.1464127,
208.17494035,
405.70485821,
567.49512422,
731.04990985
],
[
139.375,
42.416667,
9.03946166,
18.80633461,
53.99609342,
108.44648691,
210.39829618,
411.9223286,
575.28503011,
739.88681681
],
[
139.375,
42.583333,
9.06762828,
18.91975722,
54.92349688,
108.97309254,
206.11907164,
398.56476677,
558.2780305,
720.47674979
],
[
139.625,
42.083333,
13.20856686,
24.92678906,
56.23185855,
102.77819191,
182.22071779,
332.21933914,
462.4127567,
600.36964574
],
[
139.625,
42.25,
12.40053767,
24.16673134,
55.31522763,
103.03936983,
187.74292603,
348.7444692,
485.7812594,
629.09494196
],
[
139.625,
42.416667,
9.45047346,
20.41899171,
53.85911304,
103.27099577,
189.45141995,
353.06661536,
491.63721274,
636.11337206
],
[
139.625,
42.583333,
9.47574401,
20.55169914,
54.73127205,
104.02991454,
186.91495196,
344.06647847,
479.05540585,
620.83339227
],
[
139.875,
42.083333,
14.26819622,
25.90329503,
55.35495524,
95.60743098,
155.75584837,
254.32815858,
335.64997853,
421.40586561
],
[
139.875,
42.25,
13.11038113,
24.41251865,
53.26806289,
95.18943258,
158.70349624,
260.11260321,
342.73914016,
429.55045060
],
[
139.875,
42.416667,
12.85822224,
24.75769527,
54.49845105,
96.66064252,
160.65412647,
262.59024781,
345.40846709,
432.38288294
],
[
139.875,
42.583333,
12.53545607,
24.5107114,
54.97584567,
97.42041879,
160.28103067,
260.71815449,
342.80126705,
429.21059131
],
[
139.125,
42.75,
8.51979311,
15.53828717,
47.12634725,
100.29382611,
190.97708981,
366.36165526,
517.32090139,
673.51880694
],
[
139.125,
42.916667,
8.5125514,
15.45964591,
47.36551626,
101.14796646,
183.70940072,
335.20635551,
472.19661947,
619.21257095
],
[
139.125,
43.083333,
8.48125176,
15.26957303,
46.6043943,
100.37017089,
178.97130357,
310.42789908,
427.10985415,
556.05926309
],
[
139.375,
42.75,
9.05856047,
18.83225259,
55.63349437,
109.37998817,
197.92211325,
371.06767896,
521.88489447,
678.39733194
],
[
139.375,
42.916667,
9.03268498,
18.59494455,
55.6187764,
109.45938548,
190.04977357,
339.76052946,
476.49632784,
623.72793809
],
[
139.375,
43.083333,
9.00406622,
18.43002231,
54.90436478,
108.6183266,
185.1050254,
314.76575124,
431.0200118,
560.03308309
],
[
139.375,
43.25,
8.96868844,
18.39943226,
56.3776722,
110.96937413,
187.16822381,
312.72414327,
421.56641047,
540.19186964
],
[
139.625,
42.75,
9.4537148,
20.25439988,
55.19102659,
104.61412506,
181.78725336,
325.15276225,
451.73490635,
587.16265847
],
[
139.625,
42.916667,
9.40840217,
19.73795416,
54.07706219,
103.18433232,
175.24322476,
303.1586003,
418.40703418,
544.74221283
],
[
139.625,
43.083333,
9.35731084,
19.34928511,
51.60932166,
98.34045962,
166.06562906,
281.06087938,
382.9197573,
495.55155025
],
[
139.625,
43.25,
9.29988073,
19.08720746,
50.86112073,
98.08417712,
168.30583668,
286.98721246,
389.720219,
501.25016220
],
[
139.875,
42.75,
11.97954306,
23.70151162,
54.77318926,
97.76028009,
158.69449168,
255.67194607,
335.78108065,
420.61894521
],
[
139.875,
42.916667,
9.60802622,
19.99611627,
51.57043828,
95.30135319,
154.55229019,
247.59406134,
325.27263535,
408.32675571
],
[
139.875,
43.083333,
9.52734906,
19.31403807,
47.73966943,
87.05787021,
141.22484002,
227.17832095,
299.38632539,
377.07370492
],
[
139.875,
43.25,
9.44041974,
18.74756232,
44.723977,
80.89263667,
134.93092132,
225.15625631,
301.29083275,
382.58949331
],
[
139.625,
43.416667,
9.23948885,
18.96400115,
52.20862337,
103.97888923,
184.74961698,
325.10716358,
447.84199872,
580.84609710
],
[
139.625,
43.583333,
9.16790394,
18.9030345,
53.31292058,
106.84431055,
195.78725263,
363.01466422,
507.05123882,
657.36814989
],
[
139.875,
43.416667,
9.35095713,
18.30856721,
43.46565596,
79.46966147,
136.30811022,
234.86478051,
317.82883205,
405.59572645
],
[
139.875,
43.583333,
9.24554592,
17.92466088,
42.63795223,
78.50477775,
137.66605837,
245.07524899,
334.93295839,
428.63409456
],
[
139.875,
43.75,
9.17775162,
17.70399255,
42.07997946,
77.44977552,
138.17897083,
252.09315751,
345.52266488,
441.70974401
],
[
140.125,
32.583333,
10.44738327,
17.56508329,
30.09534297,
43.86182741,
60.629889,
87.27834429,
110.03522378,
134.88189507
],
[
140.375,
32.583333,
12.97147818,
20.95093018,
36.36947171,
52.10449178,
71.72598691,
102.81343104,
129.5876867,
158.91007755
],
[
140.125,
32.75,
15.85185395,
23.57364806,
37.84481025,
51.93144524,
68.79771459,
95.04736584,
117.54329669,
142.18539816
],
[
140.125,
32.916667,
17.28691103,
25.71292165,
40.76503754,
55.68178708,
73.07066419,
99.67991471,
122.38407641,
147.09269305
],
[
140.125,
33.083333,
18.88461443,
28.10378966,
44.45772851,
59.9141947,
78.0643979,
105.38014942,
128.34918173,
153.26541552
],
[
140.125,
33.25,
21.10282784,
31.22041677,
48.9759407,
65.72457704,
84.90395678,
113.64292731,
137.71940967,
163.73470183
],
[
140.375,
32.75,
17.54496861,
26.6541856,
43.03377807,
59.2031605,
78.8298683,
109.6613225,
136.44820781,
165.87225704
],
[
140.375,
32.916667,
19.12640265,
28.77064776,
46.13953698,
62.93304915,
82.94998969,
114.0065383,
140.68245486,
169.97901565
],
[
140.375,
33.083333,
20.87807981,
31.17499629,
49.46555238,
67.10296123,
87.64404245,
119.00022454,
145.70591618,
174.79568745
],
[
140.375,
33.25,
23.30935059,
34.40080592,
53.94445895,
72.51238717,
94.1141837,
126.75989162,
154.33009646,
184.25156599
],
[
140.125,
33.416667,
24.08086695,
35.41336242,
55.0149051,
73.28168874,
94.25994524,
125.68840631,
152.05475702,
180.58409473
],
[
140.125,
33.583333,
27.75600786,
40.32913019,
61.91677287,
81.7174458,
104.43062995,
138.50818722,
167.24615121,
198.40059297
],
[
140.125,
33.75,
29.90197029,
43.62727237,
66.29737503,
87.06898626,
110.8019161,
146.51714547,
176.54311381,
209.16397357
],
[
140.125,
33.916667,
32.0711101,
46.66736634,
71.08369256,
93.49769658,
118.82667306,
156.46744131,
187.79663221,
221.53392775
],
[
140.375,
33.416667,
25.99567913,
38.04593424,
59.25138351,
79.36473387,
102.7276513,
138.04480966,
167.92791545,
200.41205734
],
[
140.375,
33.583333,
29.29131875,
42.66908914,
65.55362124,
87.0617547,
112.11255135,
150.29110734,
182.79977791,
218.24944269
],
[
140.375,
33.75,
32.03854164,
46.56253742,
71.36646709,
94.68944051,
121.55270653,
162.24328563,
196.66976285,
234.17862105
],
[
140.375,
33.916667,
34.92325516,
49.95735662,
76.42724151,
101.17587784,
129.82585859,
172.97312499,
209.25761402,
248.38865353
],
[
140.125,
34.083333,
36.49398491,
52.28638495,
79.55976243,
104.84532905,
133.27328718,
174.93038014,
209.27320514,
245.83795102
],
[
140.125,
34.25,
38.2627878,
54.8294732,
83.96475698,
112.15674532,
145.19976991,
194.83231966,
236.24275714,
280.65210554
],
[
140.125,
34.416667,
40.85251106,
58.54021756,
90.42178289,
123.54640545,
165.3600189,
232.07554368,
288.81719759,
349.96579058
],
[
140.125,
34.583333,
47.1165249,
67.20963548,
104.20935412,
145.5027837,
203.74228732,
301.29752421,
382.9445106,
469.04398405
],
[
140.375,
34.083333,
36.2342096,
51.61201764,
78.56000875,
104.26404694,
134.2212442,
179.51328735,
217.59748547,
258.59343710
],
[
140.375,
34.25,
39.07504541,
56.22483344,
86.64260962,
115.87762145,
149.59549065,
199.80515364,
241.51496264,
286.29377197
],
[
140.375,
34.416667,
40.78071292,
58.65205078,
91.09976861,
123.57684806,
162.37855113,
221.83396754,
272.22943046,
326.99651526
],
[
140.375,
34.583333,
45.47054464,
65.00955292,
100.65216534,
137.60555588,
184.06020323,
259.59165545,
327.01521474,
402.86116623
],
[
140.625,
34.25,
42.08888817,
59.7570011,
91.23839831,
122.54115972,
160.93187883,
222.07674536,
274.94735885,
332.56840326
],
[
140.625,
34.416667,
44.11264354,
63.19531218,
97.5084917,
131.59304161,
173.70747317,
243.19814703,
306.5581913,
378.28650548
],
[
140.625,
34.583333,
46.51686727,
66.67410253,
103.11780227,
139.79292676,
186.35117266,
269.2241064,
354.94866408,
462.74157014
],
[
140.875,
34.416667,
47.02684794,
67.18754534,
103.42162282,
141.54989186,
194.08351225,
293.62351897,
389.30129781,
495.41739829
],
[
140.875,
34.583333,
50.74800884,
72.37001017,
111.68822274,
153.77780927,
213.96160056,
340.41541524,
478.90837891,
642.42177699
],
[
140.125,
34.75,
61.98734807,
90.80933296,
144.7867566,
206.43342974,
291.57752216,
428.01157077,
540.33979715,
658.65832495
],
[
140.125,
34.916667,
90.78984291,
140.8505676,
237.3735881,
339.22835428,
463.95042221,
654.69492011,
814.89769038,
987.60056920
],
[
140.125,
35.083333,
105.36952909,
152.46551938,
237.00483111,
325.27352593,
435.56413623,
605.03278609,
744.87775079,
892.96832544
],
[
140.125,
35.25,
101.5484153,
142.00110173,
213.03822543,
284.84530029,
373.81700097,
511.78703836,
626.4821564,
747.98072364
],
[
140.375,
34.75,
56.10403834,
79.30518355,
121.66790931,
165.76899859,
222.95488492,
322.87403847,
421.06804155,
540.35898380
],
[
140.375,
34.916667,
70.57865384,
101.21036894,
157.02525009,
215.85475728,
293.88970014,
438.87655326,
591.62746351,
777.92682359
],
[
140.375,
35.083333,
83.03383372,
117.25828534,
176.67543054,
235.77743447,
309.11908624,
429.86775576,
540.52710194,
667.65161650
],
[
140.375,
35.25,
87.77982913,
121.15792475,
177.65690131,
232.91414444,
300.35096498,
408.26413858,
502.15803469,
605.51255193
],
[
140.625,
34.75,
53.67366949,
76.135748,
117.5701328,
161.02763773,
219.62232769,
344.24862909,
510.65323604,
722.24594734
],
[
140.625,
34.916667,
61.19423863,
86.51786276,
132.21250164,
178.82421792,
239.4108525,
355.28348915,
484.97669533,
646.50572801
],
[
140.625,
35.083333,
68.67348571,
95.17396068,
139.95161455,
183.07019205,
236.21089308,
327.92787105,
419.63506064,
532.99015041
],
[
140.625,
35.25,
76.33426427,
103.96246374,
149.1591542,
191.08418534,
240.74060066,
320.32854782,
392.80572986,
476.46621665
],
[
140.875,
34.75,
54.94968623,
78.21298228,
122.00667116,
170.86250856,
241.94730888,
384.9229494,
533.0560908,
705.03851149
],
[
140.875,
34.916667,
59.68173944,
83.86723032,
126.42892948,
169.8961458,
227.58194659,
333.86327143,
441.70942879,
570.06153945
],
[
140.875,
35.083333,
65.15520454,
89.75745085,
131.30533252,
171.06638543,
219.94145599,
302.84121685,
382.31773358,
476.79929733
],
[
140.875,
35.25,
73.61532291,
100.12762453,
143.09806043,
181.93145952,
226.95766639,
296.99936557,
359.37842048,
430.84564128
],
[
140.125,
35.416667,
95.00094259,
130.5485508,
191.36906627,
250.94417283,
322.79206423,
434.23186287,
528.17716282,
628.52261161
],
[
140.125,
35.583333,
87.94164824,
119.63692942,
172.39826269,
222.30435868,
281.5452358,
373.88913986,
453.66756325,
542.11889086
],
[
140.125,
35.75,
80.909346,
109.06560934,
153.84119398,
193.81542292,
239.13467288,
307.12495431,
364.37139759,
426.66858006
],
[
140.125,
35.916667,
74.60440567,
100.29370598,
140.09270302,
174.35877351,
212.00645275,
266.55579635,
311.47554353,
359.47479712
],
[
140.375,
35.416667,
88.3808213,
120.34281749,
173.62996031,
224.42333651,
285.18735079,
379.95213591,
460.98122128,
548.79234824
],
[
140.375,
35.583333,
87.3290625,
117.79003975,
166.74766798,
211.23687627,
262.01413694,
338.69176649,
403.26792691,
473.06838736
],
[
140.375,
35.75,
84.87791127,
113.8308428,
158.62321222,
197.40371745,
240.20920073,
302.85863298,
354.69165934,
410.33479662
],
[
140.375,
35.916667,
81.38086313,
109.02438753,
150.98267031,
186.4406162,
224.94230489,
280.27799301,
325.72062679,
374.18519606
],
[
140.625,
35.416667,
83.558171,
112.86368658,
159.39025691,
201.15893111,
249.01672829,
321.77226156,
384.50774734,
453.93935632
],
[
140.625,
35.583333,
88.68251996,
119.10459655,
166.16524376,
207.14319124,
252.69125682,
320.08501965,
376.75419558,
438.26858246
],
[
140.625,
35.75,
90.00693721,
120.46838683,
166.75098063,
206.17462348,
249.2464741,
311.89982282,
363.6930669,
419.39563112
],
[
140.625,
35.916667,
88.36290603,
118.00683819,
162.88053711,
200.66154266,
241.60560114,
300.50957878,
348.86479661,
400.41664685
],
[
140.875,
35.416667,
83.99599316,
113.49112065,
159.34887251,
199.36829234,
244.15480502,
310.86086575,
367.33049723,
429.27696143
],
[
140.875,
35.583333,
92.22181989,
123.71478962,
171.64352919,
212.70460793,
257.66961936,
323.49538152,
378.12039653,
437.04434498
],
[
140.875,
35.75,
95.83146745,
127.96207928,
176.42920646,
217.3481201,
261.8186577,
326.23809815,
379.2050423,
436.06742270
],
[
140.875,
35.916667,
95.0991721,
126.54848657,
174.48178285,
215.1551481,
259.21045138,
322.76649045,
374.82726403,
430.39312051
],
[
140.125,
36.083333,
68.77913068,
92.76714573,
129.39105769,
160.47240402,
194.27746969,
243.00376222,
282.92529727,
325.60085752
],
[
140.125,
36.25,
62.30460029,
84.24911839,
117.89254819,
146.41085992,
177.37023198,
222.10371562,
258.87117818,
298.33333871
],
[
140.125,
36.416667,
54.33623971,
73.32909571,
103.09979595,
128.67106166,
156.65784088,
197.26838088,
230.94636652,
267.15145006
],
[
140.125,
36.583333,
48.21624674,
65.33084078,
92.51588488,
116.30531033,
142.55407965,
181.13737774,
213.66079936,
249.18875350
],
[
140.375,
36.083333,
76.59149126,
102.71521759,
142.49490518,
176.01236664,
212.33190998,
264.42060566,
307.12788588,
352.74542160
],
[
140.375,
36.25,
69.41175077,
93.2031913,
130.13493727,
161.8221842,
196.3184343,
246.17249154,
287.11397269,
331.00961078
],
[
140.375,
36.416667,
62.42694834,
83.88334414,
117.95999502,
147.75623197,
180.45899208,
227.93216494,
266.92943009,
308.82144041
],
[
140.375,
36.583333,
55.65795307,
74.85080463,
105.92533819,
133.65309096,
164.39355123,
209.02745449,
245.61827163,
284.87807717
],
[
140.625,
36.083333,
84.53963966,
112.76308159,
156.22692629,
193.24419886,
233.54193453,
291.48733399,
338.8975369,
389.64281250
],
[
140.625,
36.25,
78.90610532,
105.34470876,
147.20907718,
184.10007846,
225.00785346,
284.41765402,
333.28067277,
385.51222637
],
[
140.625,
36.416667,
72.98610821,
97.51360901,
137.36989449,
173.63215959,
214.65992227,
274.5785687,
323.70012663,
376.04679705
],
[
140.625,
36.583333,
66.05700035,
88.67678813,
126.08315054,
160.77105528,
200.53118848,
258.70239148,
306.13442759,
356.37032882
],
[
140.875,
36.083333,
91.59485551,
121.66240729,
169.00095864,
210.74977214,
256.98026362,
324.66700663,
380.4398456,
440.17467138
],
[
140.875,
36.25,
88.39384691,
117.3585935,
164.10972468,
207.25146529,
257.18152571,
332.66156378,
395.53149396,
462.84748542
],
[
140.875,
36.416667,
83.63842207,
111.26976247,
156.80137487,
200.03326303,
252.21606186,
331.99089262,
397.93319276,
467.72538128
],
[
140.875,
36.583333,
78.05652969,
104.32486131,
147.92592181,
190.09061861,
241.79931711,
321.17794665,
386.04747824,
453.97626070
],
[
140.125,
36.75,
42.22853378,
58.13323421,
84.2971281,
107.80752126,
134.58840612,
175.94899773,
213.26566686,
256.79392742
],
[
140.125,
36.916667,
38.41158401,
53.14288816,
77.80022181,
101.48167871,
131.08735238,
182.9509046,
234.29749812,
295.89580950
],
[
140.125,
37.083333,
35.65680779,
49.7785014,
75.43414681,
101.90524013,
138.11005361,
207.60469074,
277.0845477,
357.31048913
],
[
140.125,
37.25,
30.93043408,
45.07298401,
71.61216147,
101.73473157,
145.68316614,
228.86202463,
305.71030019,
390.16602027
],
[
140.375,
36.75,
48.85646655,
66.23532143,
94.64067589,
120.39790031,
149.26008082,
191.09663587,
225.45652052,
262.15066336
],
[
140.375,
36.916667,
44.04288125,
59.61483741,
85.71750956,
109.59270837,
136.6094234,
175.88510343,
208.25241648,
242.91043444
],
[
140.375,
37.083333,
39.85249539,
54.5023551,
78.67764738,
101.21797629,
126.79970939,
164.25766814,
195.35270106,
229.24166013
],
[
140.375,
37.25,
35.17125905,
48.80763616,
72.48212297,
94.72193092,
119.86320747,
156.91404304,
187.92864205,
222.05086987
],
[
140.625,
36.75,
59.43146845,
80.05660608,
114.52266296,
146.90706139,
184.32625066,
239.06404905,
283.53388607,
330.56980860
],
[
140.625,
36.916667,
53.43078236,
72.10929983,
103.47501946,
133.22223207,
167.73390706,
218.21954605,
259.10947258,
302.36332877
],
[
140.625,
37.083333,
47.71469796,
64.77284879,
93.38918077,
120.59277505,
152.24828881,
198.41746832,
235.82979528,
275.35592855
],
[
140.625,
37.25,
42.09421606,
57.78359904,
84.36349677,
109.58529267,
138.84897467,
181.34733776,
215.73165717,
252.09165481
],
[
140.875,
36.75,
72.01134853,
96.6132474,
137.76916257,
177.91486042,
227.34901788,
302.63604649,
363.68303686,
427.38527378
],
[
140.875,
36.916667,
65.66641762,
88.38563006,
126.73684439,
164.19931512,
210.16812046,
279.51966013,
335.53949232,
393.93422158
],
[
140.875,
37.083333,
58.69244811,
79.67485265,
115.18910963,
149.69321815,
191.82856617,
255.16766205,
306.12776369,
359.28651119
],
[
140.875,
37.25,
52.93747202,
72.05298925,
104.42527484,
135.94980762,
174.17761847,
231.5291321,
277.68238791,
326.00965293
],
[
140.125,
37.416667,
29.83570523,
44.31506553,
72.76883068,
107.23603854,
158.4127953,
248.10070982,
325.77712185,
409.71558156
],
[
140.125,
37.583333,
30.22208116,
46.0837386,
78.75473999,
118.60997558,
175.00656118,
268.38736068,
347.52674644,
432.39983298
],
[
140.125,
37.75,
23.90329971,
41.4240592,
80.32074021,
124.59188191,
182.91738944,
277.12683763,
357.00835523,
442.77640966
],
[
140.125,
37.916667,
24.88258863,
42.86192707,
82.28640018,
126.90190636,
184.36083934,
275.35305182,
352.45158623,
435.67437293
],
[
140.375,
37.416667,
33.54382342,
47.14272865,
70.88425648,
93.5962836,
119.59280112,
159.24276252,
194.02787479,
233.81828064
],
[
140.375,
37.583333,
32.22809326,
46.02534328,
70.87613053,
97.24264781,
133.02824068,
200.4949017,
268.07039702,
347.06134408
],
[
140.375,
37.75,
31.47302608,
46.85949356,
79.488352,
122.80748243,
190.62453452,
316.32688936,
433.80938884,
568.59400115
],
[
140.375,
37.916667,
31.43563196,
48.43747073,
85.62672885,
129.99501106,
190.01322282,
289.03373984,
375.17103971,
469.32681814
],
[
140.625,
37.416667,
38.8731454,
53.48211629,
78.12168994,
101.73836244,
129.17692555,
169.39811481,
202.31985579,
237.53810849
],
[
140.625,
37.583333,
36.52946154,
50.43860588,
74.66746078,
97.79999874,
124.96028077,
166.27322161,
202.283647,
243.49671977
],
[
140.625,
37.75,
38.91705357,
57.13297871,
88.04482437,
116.15883892,
148.8970226,
203.36152442,
256.89283215,
323.33379514
],
[
140.625,
37.916667,
38.37505878,
58.97975366,
97.82208994,
138.42948124,
195.8996315,
305.83789905,
409.916065,
526.96723334
],
[
140.875,
37.416667,
50.93920606,
69.82415057,
100.67548111,
129.51259276,
163.4384808,
214.03708546,
255.31452509,
298.98809068
],
[
140.875,
37.583333,
48.32070638,
67.14056387,
98.10746085,
126.46605773,
158.70702478,
206.86612963,
247.93539523,
294.70802829
],
[
140.875,
37.75,
46.07953509,
65.419441,
98.42288349,
128.48446223,
162.59653479,
216.50927835,
270.07646074,
348.32399300
],
[
140.875,
37.916667,
44.87152371,
65.26439825,
100.53193479,
131.76408544,
166.231327,
218.04616196,
263.75927317,
316.99875851
],
[
140.125,
38.083333,
26.12507862,
45.06751388,
86.01244351,
131.06824672,
189.13537545,
282.94560049,
363.45473449,
450.56533143
],
[
140.125,
38.25,
26.62983038,
46.33019837,
89.29135276,
135.72283483,
195.04419444,
292.38860751,
377.00248018,
468.97285135
],
[
140.125,
38.416667,
27.03599527,
47.08174658,
91.14126936,
137.83121338,
195.91674363,
289.62214592,
371.01095021,
459.67373202
],
[
140.125,
38.583333,
27.37696353,
47.22220755,
90.83727346,
138.14098687,
196.60380923,
288.67622073,
367.34000828,
452.60517972
],
[
140.375,
38.083333,
30.27865199,
52.15173705,
91.69502733,
134.07456647,
191.04693384,
285.15322728,
365.44676994,
451.79956897
],
[
140.375,
38.25,
31.83398376,
54.45823833,
95.77081272,
139.85203967,
198.8849059,
297.62185815,
384.45641551,
479.99529859
],
[
140.375,
38.416667,
27.06847609,
46.91743904,
90.27686824,
138.85363489,
201.90110311,
305.76535195,
398.18080482,
501.58673289
],
[
140.375,
38.583333,
27.21334734,
46.72172484,
88.4769522,
135.03806573,
196.94207178,
301.6363509,
395.03426527,
498.76472626
],
[
140.625,
38.083333,
37.46492493,
58.86507608,
100.17658391,
144.08867874,
203.04905186,
305.03870593,
396.09596798,
496.05428446
],
[
140.625,
38.25,
36.74480472,
58.67585076,
100.40313962,
143.64258675,
199.95194469,
294.83112395,
378.35768954,
469.72317464
],
[
140.625,
38.416667,
31.62016128,
54.5225336,
95.59902886,
136.71873611,
189.19694206,
275.70846661,
351.18595917,
433.63272245
],
[
140.625,
38.583333,
32.24251259,
54.75569757,
94.52755122,
134.16312852,
185.24682137,
271.06601422,
346.7841205,
429.76844326
],
[
140.875,
38.083333,
44.4572629,
66.93511139,
107.35523087,
144.52452594,
188.14780646,
258.69209603,
323.23346803,
397.15375940
],
[
140.875,
38.25,
44.09868601,
68.31536838,
114.64146468,
161.75633999,
224.42890164,
341.76402994,
461.63337013,
605.45753004
],
[
140.875,
38.416667,
42.70947578,
65.92400158,
108.90311031,
150.81055233,
202.27313636,
286.71901801,
362.17488634,
446.00795438
],
[
140.875,
38.583333,
41.42181463,
64.12922339,
105.52562614,
145.52345356,
194.28441553,
274.20579289,
346.02936248,
426.49177415
],
[
140.125,
38.75,
27.55309053,
47.48314038,
93.01797459,
143.11734442,
203.88953967,
297.61501284,
377.4352608,
464.20208182
],
[
140.125,
38.916667,
27.70261256,
47.67185422,
93.13093437,
142.91590461,
203.32511555,
296.32286515,
375.26566334,
460.86757300
],
[
140.125,
39.083333,
27.64506902,
47.24171512,
91.37507505,
140.76407333,
200.58790865,
291.06705217,
366.85406613,
448.84937354
],
[
140.125,
39.25,
27.77775496,
47.7613484,
91.45315619,
141.09839205,
202.07130875,
293.59851413,
369.59513968,
451.38999411
],
[
140.375,
38.75,
27.20957574,
46.21505914,
86.61411356,
130.84241001,
187.58542293,
279.45524132,
359.09802146,
445.99506997
],
[
140.375,
38.916667,
27.13526478,
45.79057409,
85.48373011,
128.85578106,
183.9472998,
272.5016894,
349.05434405,
432.56400481
],
[
140.375,
39.083333,
26.9941538,
45.6647038,
85.50278739,
129.14384883,
184.56467045,
273.77900853,
351.14398239,
435.64452980
],
[
140.375,
39.25,
26.37676312,
44.94144895,
85.2040574,
130.13942302,
187.19084548,
278.09831857,
356.45145618,
441.76902033
],
[
140.625,
38.75,
31.9558452,
53.95339268,
92.79686711,
131.66258245,
182.03067929,
267.10244741,
342.42750513,
425.20520792
],
[
140.625,
38.916667,
31.57307238,
53.06523364,
91.1752943,
129.88895081,
180.76239982,
267.2953592,
343.82088065,
427.63701815
],
[
140.625,
39.083333,
25.95892605,
44.16475813,
82.55167698,
125.4897769,
182.51989696,
277.90610294,
362.02819331,
455.00567074
],
[
140.625,
39.25,
26.28876594,
44.9693963,
85.13078385,
130.94548596,
192.36820202,
295.63861535,
388.62759465,
494.37108510
],
[
140.875,
38.75,
38.5629102,
61.31380486,
102.16903929,
141.38388533,
189.677158,
270.0592232,
342.63841194,
423.91477730
],
[
140.875,
38.916667,
37.76244625,
59.58438527,
98.8991787,
137.59745577,
186.51856016,
268.96989961,
343.01812766,
425.19412577
],
[
140.875,
39.083333,
36.31053881,
57.39178566,
95.28098119,
133.86931772,
184.74989541,
272.22682304,
350.07000109,
435.29405580
],
[
140.875,
39.25,
35.6352784,
56.2031865,
93.33523071,
132.62099982,
186.13450942,
278.12428756,
358.86161179,
446.63378675
],
[
140.125,
39.416667,
27.54756415,
48.1820072,
95.94834289,
151.89222008,
220.72998031,
325.65854529,
415.07852616,
513.64526767
],
[
140.125,
39.583333,
26.41264255,
46.47684039,
94.92699104,
152.04360158,
222.61338841,
333.10242361,
430.39161265,
540.32260508
],
[
140.125,
39.75,
25.77126942,
44.88276822,
88.42212672,
137.76301201,
198.79492036,
294.41425047,
376.7932706,
467.27396823
],
[
140.125,
39.916667,
25.28122961,
44.08410132,
86.17881004,
133.03072628,
192.09105096,
285.8907549,
366.01555393,
452.70279220
],
[
140.375,
39.416667,
26.49065199,
45.29789713,
85.722484,
131.18798618,
189.19341729,
281.00124027,
359.30619165,
444.13957926
],
[
140.375,
39.583333,
26.56957847,
45.41682252,
85.29004738,
129.89908883,
187.28948949,
278.59131359,
356.52047674,
440.81316811
],
[
140.375,
39.75,
26.09202888,
44.44307005,
83.47927428,
127.04606868,
183.00495576,
272.62233924,
349.37435096,
432.65058882
],
[
140.375,
39.916667,
25.6392065,
43.70759933,
81.89867273,
124.20653119,
178.74623179,
266.88780116,
342.83406306,
425.63799633
],
[
140.625,
39.416667,
26.39757627,
45.21506167,
86.01038429,
132.99334633,
196.04090623,
303.14203197,
401.58681881,
516.38944744
],
[
140.625,
39.583333,
26.17509294,
44.61039365,
84.20662573,
129.66571071,
191.04932778,
296.03815596,
393.0237591,
506.12784029
],
[
140.625,
39.75,
25.77939178,
43.67602332,
81.23603228,
123.35265774,
178.82663089,
270.07498708,
349.0040076,
434.80551402
],
[
140.625,
39.916667,
25.32649862,
42.78374487,
79.27029678,
120.07610829,
174.08805264,
262.81793586,
339.6371102,
423.25855044
],
[
140.875,
39.416667,
29.92963755,
47.8808114,
84.15276624,
125.8544355,
183.08629954,
278.65762416,
361.05208019,
450.11268793
],
[
140.875,
39.583333,
25.96544165,
44.15487575,
81.97292704,
125.16686491,
184.02887333,
281.45802045,
364.750883,
454.25672412
],
[
140.875,
39.75,
25.04613607,
42.24346295,
79.36504501,
123.6140722,
184.38589277,
284.29604028,
369.97346937,
462.90953821
],
[
140.875,
39.916667,
24.5370639,
41.44095907,
77.56545132,
118.98071296,
174.81883432,
266.18559158,
344.35323231,
428.79865879
],
[
140.125,
40.083333,
24.83010499,
44.00137733,
87.78487895,
136.09229002,
197.21069851,
296.47134505,
383.18890985,
478.15527329
],
[
140.125,
40.25,
23.74692721,
41.82014888,
84.64931911,
134.50709841,
198.2859575,
301.19948136,
391.33080768,
490.67652190
],
[
140.125,
40.416667,
23.34513775,
40.72346209,
81.07221618,
128.04351869,
187.83896728,
282.08928337,
362.34170328,
449.18519886
],
[
140.125,
40.583333,
23.74324272,
40.33404197,
79.60115445,
126.0846429,
184.03976621,
273.41055272,
349.16178485,
431.52756895
],
[
140.375,
40.083333,
25.30343195,
43.28143677,
80.72800071,
122.17140473,
176.43380907,
265.10395895,
341.64751037,
424.97949964
],
[
140.375,
40.25,
24.32084081,
41.51976549,
78.46561001,
120.3658764,
175.73034031,
265.51356268,
342.49268642,
426.01020470
],
[
140.375,
40.416667,
23.88092911,
40.8496155,
77.96881217,
120.27426176,
175.78977387,
265.20072943,
341.8331824,
425.08361609
],
[
140.375,
40.583333,
26.67938689,
43.16949731,
78.91099304,
120.79526563,
176.32804309,
266.64393024,
344.31147745,
428.58460359
],
[
140.625,
40.083333,
24.32833595,
40.90280484,
76.47588216,
116.83921845,
170.68817128,
259.74704314,
337.04699438,
421.10125523
],
[
140.625,
40.25,
24.43799067,
41.38116889,
77.04246626,
117.10206511,
170.69463839,
259.68374528,
336.99338005,
421.05672553
],
[
140.625,
40.416667,
24.0432274,
40.89143469,
76.68091038,
117.28502066,
171.80724262,
261.54093099,
338.85376706,
422.72560946
],
[
140.625,
40.583333,
27.49876108,
44.13813514,
78.63246669,
119.08825051,
174.97441995,
268.58486243,
349.37137702,
436.66672385
],
[
140.875,
40.083333,
24.14950456,
40.75648793,
76.28977249,
116.56193163,
170.51750514,
259.71405716,
336.96376199,
420.88361277
],
[
140.875,
40.25,
23.69651619,
40.07785515,
75.41050618,
115.5013127,
169.48607937,
259.051329,
336.55052524,
420.63607041
],
[
140.875,
40.416667,
23.05458534,
39.24391598,
74.39565301,
115.05311791,
169.94181207,
260.11534302,
337.60620099,
421.51286909
],
[
140.875,
40.583333,
27.31614815,
43.23963247,
76.43422574,
116.16000434,
171.49342219,
263.17064312,
341.60011377,
426.27479672
],
[
140.125,
40.75,
26.05100788,
42.55671062,
80.44557604,
126.20997102,
184.03956743,
273.53222484,
349.3662103,
431.78409852
],
[
140.125,
40.916667,
26.24333612,
42.88666434,
80.69356063,
126.68231665,
185.4034552,
275.96640047,
352.20130419,
434.67099128
],
[
140.125,
41.083333,
26.12071883,
42.68287148,
80.3046796,
126.286912,
185.20944467,
276.07150258,
352.43579673,
434.95748601
],
[
140.125,
41.25,
25.40002893,
41.10768951,
77.39419743,
122.11247378,
180.49152625,
271.50170107,
348.24902541,
431.29152543
],
[
140.375,
40.75,
27.05230502,
43.91554017,
80.40030362,
123.11908092,
179.48272737,
271.89443087,
351.93032097,
439.05422805
],
[
140.375,
40.916667,
27.58418208,
44.71465236,
81.37448433,
124.9166016,
183.18425462,
278.94697936,
362.57301464,
454.64415185
],
[
140.375,
41.083333,
27.55536276,
44.44690347,
79.83719829,
121.56152282,
177.61708615,
269.74067492,
349.26227257,
435.59358085
],
[
140.375,
41.25,
26.97368137,
43.15798019,
77.4204299,
117.87879905,
172.52703671,
261.95241799,
339.00196711,
422.75088876
],
[
140.625,
40.75,
28.02488292,
45.17680308,
81.24769024,
124.49955144,
184.09002294,
283.85381973,
371.66070658,
468.87186116
],
[
140.625,
40.916667,
28.47053085,
45.7766557,
81.68196607,
124.59391892,
184.61023387,
287.24202232,
378.79402132,
481.53388430
],
[
140.625,
41.083333,
28.91003649,
46.07965475,
80.11360097,
119.78736127,
175.08179219,
268.28729007,
348.86873817,
436.05103677
],
[
140.625,
41.25,
28.64198774,
45.46300324,
78.82869849,
117.48506565,
170.99280512,
260.81886867,
338.4507879,
422.60271201
],
[
140.875,
40.75,
27.99029126,
44.24403047,
77.61375502,
117.47576632,
173.20802914,
266.10056755,
345.91372513,
432.21998561
],
[
140.875,
40.916667,
28.62867831,
45.12546975,
78.22860657,
117.32034595,
171.98645667,
263.46707532,
342.05234371,
426.95067594
],
[
140.875,
41.083333,
29.07210976,
45.6735267,
78.47068381,
116.87505656,
170.58162558,
260.96059693,
338.8602889,
423.11360408
],
[
140.875,
41.25,
31.96077561,
51.18500564,
88.19128016,
127.06506512,
177.664281,
262.89992605,
338.5394616,
421.72146800
],
[
140.125,
41.416667,
24.36345342,
38.80085257,
69.92926878,
106.97996305,
156.32032342,
236.79368837,
306.84082829,
383.81024989
],
[
140.125,
41.583333,
23.18359227,
36.58824009,
64.16422309,
96.55478036,
141.11295211,
216.76667612,
284.24452713,
359.32949156
],
[
140.125,
41.75,
22.03120517,
34.92753104,
61.47056313,
93.50096746,
138.2203995,
214.6525498,
282.69239331,
358.28725155
],
[
140.125,
41.916667,
21.70629267,
34.25170896,
60.13586414,
92.38426269,
138.19025762,
216.04564301,
284.63054666,
360.32232515
],
[
140.375,
41.416667,
26.08313082,
40.95728799,
71.54962486,
106.33156197,
153.72224243,
235.32957873,
308.45158963,
389.25325331
],
[
140.375,
41.583333,
25.06200452,
38.85802616,
66.05254551,
95.65775233,
136.00080684,
208.32824286,
275.82487542,
352.15471521
],
[
140.375,
41.75,
24.64585034,
37.87124159,
63.84243295,
92.70231301,
133.2303819,
207.48512018,
276.55231188,
353.86477934
],
[
140.375,
41.916667,
25.23825795,
37.99421585,
63.1743871,
91.84779489,
132.81029355,
207.54910764,
276.58511969,
353.78167232
],
[
140.625,
41.416667,
27.99502335,
43.86892988,
74.9418918,
110.26870376,
160.66304692,
249.20378772,
327.20237809,
412.02030558
],
[
140.625,
41.583333,
27.08718154,
41.70441075,
69.12414408,
98.40150975,
138.60824596,
212.24560024,
280.84639452,
357.78707128
],
[
140.625,
41.75,
28.28592296,
42.17402053,
67.81887625,
95.82076833,
136.43039696,
217.0759454,
295.77195038,
385.06626129
],
[
140.625,
41.916667,
27.55260548,
40.96037072,
66.4017257,
94.72366112,
137.26536056,
224.70158472,
312.04488663,
413.97732567
],
[
140.875,
41.416667,
31.53223172,
50.32319104,
86.66287691,
124.75750044,
174.59503153,
259.38196011,
335.23956082,
418.68938682
],
[
140.875,
41.583333,
32.79046571,
49.86692136,
82.16199786,
115.14574941,
157.06502958,
228.27037718,
293.67423498,
367.86687704
],
[
140.875,
41.75,
29.99003351,
44.5239888,
70.1289358,
97.55070013,
135.80255275,
208.42834618,
277.44259809,
354.93338008
],
[
140.875,
41.916667,
29.27975816,
43.24760528,
68.14078713,
94.77323859,
132.52135728,
205.93887562,
276.12538489,
354.54068207
],
[
140.125,
42.083333,
19.93688465,
32.39385121,
58.5165873,
91.74496268,
139.62627005,
219.09153846,
287.89584771,
363.29560341
],
[
140.125,
42.25,
19.24508209,
30.9890551,
56.946422,
91.25915126,
141.96869846,
224.32835237,
294.12411594,
369.89132592
],
[
140.125,
42.416667,
18.56188386,
30.15256888,
57.13296772,
93.09118592,
145.65122214,
231.63142936,
305.06953315,
384.85384870
],
[
140.125,
42.583333,
14.81191055,
26.62709013,
56.69118985,
95.78544869,
149.00313836,
235.31499101,
309.74495148,
390.98039106
],
[
140.375,
42.083333,
23.78634771,
36.36034111,
61.21017439,
90.4747503,
132.586287,
207.68092612,
276.11950413,
352.65841344
],
[
140.375,
42.25,
22.80646163,
35.12345194,
59.72343302,
89.73223521,
133.71846552,
212.51731834,
283.65203464,
362.11050702
],
[
140.375,
42.416667,
22.04553487,
34.4583295,
60.39472448,
93.96116424,
143.77080842,
234.66475484,
320.48217201,
419.54712663
],
[
140.375,
42.583333,
21.29220476,
33.86413489,
61.52178799,
100.44381224,
161.32583613,
270.70590718,
371.30870156,
485.74036784
],
[
140.625,
42.083333,
25.85588694,
38.77473712,
63.57030404,
90.95746398,
130.76111971,
206.61153566,
277.44417328,
356.07280553
],
[
140.625,
42.25,
25.04457844,
37.72150666,
61.98551435,
89.35268181,
129.42456634,
205.08183399,
275.15227228,
352.91042684
],
[
140.625,
42.416667,
24.12555027,
36.64700296,
60.67505891,
88.4833003,
129.76709447,
208.89723838,
281.54876209,
361.24048672
],
[
140.625,
42.583333,
22.97285415,
35.29050142,
59.23107323,
87.52464342,
129.68225083,
209.54785756,
282.26428293,
361.87103613
],
[
140.875,
42.083333,
27.75978144,
41.14256867,
65.76768471,
92.08132823,
129.73055131,
202.67948935,
272.32544732,
350.26706618
],
[
140.875,
42.25,
27.66542844,
40.47793437,
64.37252364,
90.14270796,
127.79767507,
200.72951347,
270.5285543,
348.65189531
],
[
140.875,
42.416667,
26.62230543,
38.98184898,
62.15849737,
87.92693695,
126.14171158,
200.56442836,
270.91144038,
349.18371348
],
[
140.875,
42.583333,
25.29524106,
37.24226024,
59.60512145,
85.4705874,
124.3388943,
199.95275728,
270.67463179,
349.04482829
],
[
140.125,
42.75,
14.25705381,
25.7973949,
55.46175413,
94.11048101,
146.64985702,
232.63651564,
307.42647773,
389.37189820
],
[
140.125,
42.916667,
13.54241067,
24.38231016,
52.47099582,
90.51662875,
141.77611721,
223.31099605,
293.19834451,
369.47876346
],
[
140.125,
43.083333,
9.54882928,
19.16449177,
47.18308804,
85.03051031,
134.20941569,
211.00058004,
277.01608806,
349.98865374
],
[
140.125,
43.25,
9.44068948,
18.46407038,
44.03476619,
78.82927618,
125.22814924,
198.21814515,
261.09807133,
330.68079985
],
[
140.375,
42.75,
20.06598838,
32.32117234,
58.91670215,
93.75147953,
144.72053179,
236.67539487,
323.45551612,
423.61864620
],
[
140.375,
42.916667,
14.21816237,
25.28135863,
52.35809679,
86.23186737,
132.65592923,
212.9345408,
285.01040969,
364.37906847
],
[
140.375,
43.083333,
13.35272326,
23.7357113,
49.8683807,
83.92703459,
129.4189234,
205.96058694,
274.80964106,
351.69019918
],
[
140.375,
43.25,
9.42128165,
18.68095859,
45.97508167,
80.90539399,
126.66307105,
203.02547938,
272.13757738,
349.39050827
],
[
140.625,
42.75,
21.87150177,
34.00332646,
57.74790699,
85.89486875,
128.08348814,
207.71553559,
280.08824282,
359.35011205
],
[
140.625,
42.916667,
20.30272516,
31.96805583,
55.49182225,
83.73995112,
125.82537511,
203.58568007,
274.45610878,
352.62038328
],
[
140.625,
43.083333,
14.17657799,
24.91069148,
50.07558844,
80.80627601,
123.6681743,
200.15771612,
270.544928,
348.74750444
],
[
140.625,
43.25,
13.32045265,
23.70409912,
48.94480581,
79.83261342,
122.63232159,
199.00656653,
269.57104013,
347.99508940
],
[
140.875,
42.75,
23.70347946,
35.18782488,
57.07921486,
82.85217428,
122.59701871,
199.29852689,
270.29838852,
348.77363744
],
[
140.875,
42.916667,
21.15042943,
32.31976829,
54.07022669,
80.08481857,
120.83178561,
198.31523936,
269.57055555,
348.28585756
],
[
140.875,
43.083333,
19.56733317,
30.04953832,
51.43983547,
77.94246326,
119.2397354,
197.31928098,
268.87513737,
347.81852624
],
[
140.875,
43.25,
13.51366722,
23.62853019,
47.16586844,
76.36770906,
118.96804496,
197.15542282,
268.72725498,
347.67763347
],
[
140.125,
43.416667,
9.33566651,
17.89024167,
41.58898116,
74.67095604,
120.48060635,
194.15452105,
257.2386381,
326.42844530
],
[
140.125,
43.583333,
9.24132698,
17.44357367,
39.75568583,
71.40597383,
117.70091243,
193.95047431,
258.75883198,
329.16095465
],
[
140.125,
43.75,
9.13251632,
16.94764902,
38.23828062,
68.47944311,
115.17356333,
193.56379195,
259.50705035,
330.57051058
],
[
140.125,
43.916667,
9.04238798,
16.5436138,
37.10105891,
66.5354295,
113.68174712,
193.54222537,
260.06503793,
331.42806019
],
[
140.375,
43.416667,
9.31244088,
18.12911958,
44.06230323,
78.0396894,
123.44620421,
199.87625314,
269.25850662,
346.76240199
],
[
140.375,
43.583333,
9.21171121,
17.64773358,
42.1607969,
74.79996939,
118.90443524,
193.02774819,
260.13762409,
335.72644880
],
[
140.375,
43.75,
9.15071448,
17.17262078,
39.95593179,
71.36630942,
114.38286315,
185.7739884,
250.04263179,
322.41205404
],
[
140.375,
43.916667,
9.05975991,
16.72448224,
38.45396428,
68.22906589,
109.65164919,
178.33801446,
239.89772796,
309.70006784
],
[
140.625,
43.416667,
9.41489459,
18.85057465,
45.87153775,
78.19638403,
121.76243959,
198.73217936,
269.49337594,
348.03050353
],
[
140.625,
43.583333,
9.3255892,
18.44450373,
44.81245357,
77.15635417,
121.08116407,
198.54838941,
269.48217259,
348.11360486
],
[
140.625,
43.75,
9.21314153,
17.90481155,
43.26926909,
75.4911999,
119.70617491,
197.72530551,
268.93234207,
347.71514192
],
[
140.625,
43.916667,
8.97425253,
16.71915268,
40.31764223,
72.70560538,
117.56811223,
196.33398154,
268.01172254,
347.17097993
],
[
140.875,
43.416667,
9.29881249,
18.43210047,
43.83702197,
74.89350866,
118.51280976,
197.08352568,
268.72253281,
347.72171715
],
[
140.875,
43.583333,
9.1939273,
18.00969155,
43.20442571,
74.47806019,
118.33950816,
197.05462175,
268.72647646,
347.75096476
],
[
140.875,
43.75,
9.11641082,
17.71929221,
42.9012637,
74.25473526,
118.15205702,
196.95592122,
268.67366874,
347.68043854
],
[
140.875,
43.916667,
9.02756852,
17.36292047,
42.4175025,
73.83396065,
117.84521687,
196.84685113,
268.65647898,
347.71291937
],
[
140.125,
44.083333,
8.79365011,
15.40418357,
34.58128299,
63.53112258,
111.93039146,
193.08137995,
259.97864779,
331.53103548
],
[
140.125,
44.25,
8.67612657,
14.9241565,
33.75515962,
62.42545372,
110.57844844,
191.64211575,
258.6494851,
330.33238788
],
[
140.125,
44.416667,
8.52201289,
14.27447135,
32.71423804,
60.91527169,
107.97111579,
187.63191817,
254.24050279,
325.79932201
],
[
140.125,
44.583333,
8.33504138,
13.43485253,
31.36970827,
58.98456674,
103.71989337,
180.12528264,
245.48446985,
316.57093817
],
[
140.375,
44.083333,
8.82594042,
15.60574828,
35.76238333,
64.3828053,
104.78891302,
171.28574557,
231.25025194,
299.59111388
],
[
140.375,
44.25,
8.71914626,
15.1244305,
34.47452522,
61.83267673,
101.30396077,
167.43962394,
227.48851631,
296.18820693
],
[
140.375,
44.416667,
8.58823472,
14.54717596,
33.17537343,
59.57696148,
98.38586516,
164.43535029,
224.8322787,
294.12943084
],
[
140.375,
44.583333,
8.43247677,
13.85587254,
31.84315949,
57.64657206,
95.50593818,
161.07985225,
221.86166049,
291.93034066
],
[
140.625,
44.083333,
8.87315565,
16.2317954,
38.99803967,
70.18412619,
113.78587322,
191.13853616,
262.57290028,
341.92962273
],
[
140.625,
44.25,
8.76925076,
15.73893623,
37.67321253,
67.43270066,
108.92571342,
183.43223303,
253.48299262,
332.12797043
],
[
140.625,
44.416667,
8.6493027,
15.17045012,
36.26501062,
64.56610191,
103.70042555,
173.07229263,
238.61097658,
313.23706534
],
[
140.625,
44.583333,
8.51068072,
14.51365685,
34.73750959,
61.42779909,
98.42734193,
164.32425984,
227.30600191,
299.57333316
],
[
140.875,
44.083333,
8.92923806,
16.9381907,
41.70553916,
73.18819617,
117.40495809,
196.69289281,
268.63466276,
347.78625457
],
[
140.875,
44.25,
8.81246339,
16.39403106,
40.61565223,
72.13864731,
116.64156958,
196.32473936,
268.45387729,
347.68233951
],
[
140.875,
44.416667,
8.68447477,
15.76955541,
39.33289379,
70.51315509,
115.20151535,
195.39118856,
267.85754008,
347.31326110
],
[
140.875,
44.583333,
8.55094662,
15.10812582,
37.99795589,
68.2883369,
112.37666164,
192.82888387,
265.76939662,
345.69136015
],
[
140.125,
44.75,
8.12067214,
12.40448746,
29.81548206,
56.62922643,
98.04991293,
169.6730242,
233.12734606,
303.64651943
],
[
140.125,
44.916667,
7.87317133,
11.10445038,
28.47135678,
53.91261318,
92.06247826,
159.20200028,
221.30240207,
292.28388502
],
[
140.125,
45.083333,
7.57511414,
9.85545071,
26.7393442,
50.82641637,
86.5866426,
151.4420481,
214.08717025,
286.51419426
],
[
140.125,
45.25,
7.20866089,
9.37868404,
23.50363206,
46.53635119,
80.66966095,
145.7115044,
210.00166538,
283.96765046
],
[
140.375,
44.75,
8.25003181,
13.02084655,
30.40000894,
55.45683413,
91.82705066,
156.49778713,
217.76896126,
288.83399423
],
[
140.375,
44.916667,
8.02877973,
11.93543187,
29.06159358,
53.02031899,
87.86125007,
151.63352271,
213.80608433,
286.06487292
],
[
140.375,
45.083333,
7.74320743,
10.34750326,
27.39331082,
50.1893881,
83.95605821,
147.70874724,
211.11061665,
284.51002438
],
[
140.375,
45.25,
7.37276077,
9.59218291,
24.29414831,
46.2220552,
79.11463833,
144.03099643,
208.92749038,
283.32353779
],
[
140.625,
44.75,
8.3466666,
13.72114737,
33.09226772,
58.28974242,
93.16440236,
156.27886785,
217.83291535,
289.51463996
],
[
140.625,
44.916667,
8.13998717,
12.67115491,
31.22623507,
55.19820482,
88.5245536,
151.07603938,
213.40652679,
285.95828788
],
[
140.625,
45.083333,
7.86053023,
11.09473103,
29.08378387,
51.89821063,
84.51146894,
147.59839451,
211.05536807,
284.50210208
],
[
140.625,
45.25,
7.29409297,
9.48983374,
23.40409251,
44.23120218,
77.16924917,
143.40330843,
208.79238834,
283.29959462
],
[
140.875,
44.75,
8.39233046,
14.29126368,
36.34126163,
65.30213898,
108.01206676,
187.64358308,
260.44347065,
340.40380269
],
[
140.875,
44.916667,
8.00412649,
12.01917172,
31.69878738,
58.86803035,
100.35680799,
177.4383513,
247.99780291,
325.74077571
],
[
140.875,
45.083333,
7.73278121,
10.31639445,
29.41652121,
55.44252817,
94.65840589,
167.77398415,
235.50285968,
310.84970494
],
[
140.875,
45.25,
7.35747284,
9.57229286,
25.91231879,
50.30091688,
87.51199326,
156.29656871,
220.87359381,
293.89083339
],
[
140.125,
45.416667,
6.7885974,
8.83216885,
18.44592582,
36.88863917,
66.94230676,
131.44226152,
198.4676566,
274.98227513
],
[
140.125,
45.583333,
6.10197082,
7.93884707,
11.87886766,
21.99144993,
38.72225923,
74.84607842,
113.82169226,
162.01109514
],
[
140.125,
45.75,
5.59866348,
7.28402913,
9.51196132,
15.34226503,
24.09288198,
40.38202123,
56.86326478,
76.87186745
],
[
140.125,
45.916667,
5.0574597,
6.57990677,
8.59247232,
10.44742344,
16.37486952,
26.04654143,
35.81293813,
47.97147686
],
[
140.375,
45.416667,
6.72769908,
8.75293831,
17.21595517,
32.92832083,
62.29909266,
129.80755914,
198.14922824,
275.01158435
],
[
140.375,
45.583333,
6.24893956,
8.13005781,
12.93658913,
22.98115854,
39.45305868,
75.66521503,
115.10476055,
164.16309145
],
[
140.375,
45.75,
5.72162322,
7.44400343,
9.72086622,
16.08525669,
24.84704248,
41.10500673,
57.4784203,
77.46455583
],
[
140.375,
45.916667,
5.16268484,
6.71680784,
8.77124669,
11.2097721,
16.98822872,
26.66665954,
36.37253943,
48.38763178
],
[
140.625,
45.416667,
6.8487198,
8.91038989,
18.33109939,
35.14235092,
64.61840007,
131.18624488,
198.96120169,
275.60389533
],
[
140.625,
45.583333,
6.34740384,
8.25816279,
13.73018316,
24.32468353,
41.14749168,
77.56962038,
117.36698623,
167.19017445
],
[
140.625,
45.75,
5.79736001,
7.54253926,
9.84954076,
16.68090904,
25.71784945,
42.25976676,
58.63501148,
78.65129034
],
[
140.625,
45.916667,
5.21757196,
6.78821762,
8.86449825,
11.60407911,
17.39397945,
27.21280424,
36.96469627,
48.91735875
],
[
140.875,
45.416667,
6.90391259,
8.98219736,
19.43911822,
39.19187465,
72.46600588,
140.09758339,
206.1517408,
280.85112923
],
[
140.875,
45.583333,
6.39707455,
8.32278588,
14.33270976,
26.01395346,
44.68101663,
82.99865673,
123.65405484,
173.95766511
],
[
140.875,
45.75,
5.83993535,
7.59793106,
9.92187498,
17.20005527,
26.70652216,
43.92735021,
60.61181627,
80.93637614
],
[
140.875,
45.916667,
5.24838769,
6.82830981,
8.91685325,
11.83840922,
17.68520347,
27.65924969,
37.47988652,
49.40135036
],
[
141.125,
34.75,
56.45347927,
80.69293873,
125.72808465,
176.46564217,
252.49934345,
399.0920606,
532.05950574,
674.33876162
],
[
141.125,
34.916667,
59.18304626,
83.05976604,
125.40527578,
171.29876482,
236.88354255,
356.27072391,
462.33650024,
576.16309985
],
[
141.125,
35.083333,
65.923068,
91.04511994,
134.08028891,
176.94294266,
231.89588716,
323.94619587,
405.87964894,
495.54801983
],
[
141.125,
35.25,
76.08659865,
104.59698755,
151.37079886,
194.68214428,
245.17021422,
322.37421589,
388.22679523,
459.84694523
],
[
141.375,
34.916667,
59.07550971,
85.25209945,
132.3153902,
184.67382094,
261.34746576,
400.1008956,
519.03370754,
643.40349802
],
[
141.375,
35.083333,
64.01639241,
90.16195358,
136.48646213,
185.38836539,
252.55633519,
370.39093264,
473.9303429,
584.67295668
],
[
141.375,
35.25,
75.22273693,
105.32024829,
156.26608807,
206.05655307,
266.87597593,
363.60391992,
447.06924492,
537.82620576
],
[
141.625,
35.25,
64.97889401,
93.13385577,
142.60931342,
194.08952207,
263.84673176,
388.22237617,
500.42796803,
622.02307996
],
[
141.125,
35.416667,
89.40758031,
121.89396879,
172.97049631,
217.84543981,
267.84271541,
341.14538717,
401.92511581,
467.15189324
],
[
141.125,
35.583333,
98.34018345,
132.69163423,
185.28094666,
230.2941359,
279.37689956,
350.67589968,
409.21952499,
471.78411141
],
[
141.125,
35.75,
101.125548,
135.58843005,
188.04756572,
232.55299438,
280.74553725,
350.37695214,
407.40347408,
468.30586536
],
[
141.125,
35.916667,
101.83922145,
135.64126745,
187.92061508,
232.94712134,
282.06765806,
353.22569361,
411.59248254,
473.92746639
],
[
141.375,
35.416667,
89.07946504,
123.92783459,
180.12618338,
231.17380593,
289.08482841,
375.40341917,
447.42382261,
525.04251278
],
[
141.375,
35.583333,
98.35648716,
134.86627874,
191.86206489,
241.46690964,
296.357673,
376.54274967,
442.78622719,
513.97239743
],
[
141.375,
35.75,
104.33232768,
141.05703709,
198.04670751,
247.04951503,
300.56235291,
378.29715376,
442.28988781,
510.98905848
],
[
141.375,
35.916667,
110.13541969,
147.15388068,
205.26327609,
256.04822646,
312.34004135,
394.41112521,
462.05091643,
534.70031558
],
[
141.625,
35.416667,
72.99985618,
102.98802141,
153.5194013,
202.85685673,
265.22619533,
371.29707459,
467.77548514,
574.77903346
],
[
141.625,
35.583333,
82.01091966,
113.45917263,
164.9761447,
212.67510297,
268.95344304,
358.23032267,
437.18792829,
525.27777875
],
[
141.625,
35.75,
98.94303665,
134.70113801,
191.55670132,
242.09103257,
298.81985418,
383.06965553,
453.58562494,
530.04078998
],
[
141.625,
35.916667,
120.78017443,
162.58924078,
228.08499709,
285.56048163,
349.56624301,
443.24247318,
520.88476254,
603.62948311
],
[
141.875,
35.416667,
59.96353348,
89.18557479,
142.83098967,
199.12655812,
276.27050257,
415.30391618,
540.38427405,
674.63101139
],
[
141.875,
35.583333,
70.42647263,
100.46333711,
152.53973139,
203.82263829,
269.41144971,
383.84240145,
489.80460651,
607.28879521
],
[
141.875,
35.75,
97.41245559,
138.64096131,
204.95849699,
264.30013602,
332.40958225,
436.61852837,
526.48694937,
624.79884000
],
[
141.875,
35.916667,
132.67086614,
184.35979836,
262.16168052,
328.23263201,
400.4755995,
505.94961357,
593.17732566,
687.01666635
],
[
141.125,
36.083333,
100.90601858,
133.72519311,
185.85504435,
232.87308952,
286.30926814,
366.10613975,
432.64640338,
504.18782334
],
[
141.125,
36.25,
97.85325553,
129.38697806,
180.64971126,
229.31365688,
288.33382122,
381.92130542,
461.33866588,
546.17735078
],
[
141.125,
36.416667,
93.43745004,
123.83626298,
173.79539784,
222.4170116,
285.06860885,
389.98645167,
478.26107726,
570.30396107
],
[
141.125,
36.583333,
88.84192241,
118.14003049,
166.57486292,
214.33627715,
277.60732102,
388.04725323,
479.74040465,
573.46448624
],
[
141.375,
36.083333,
111.29157893,
147.38870191,
205.3466375,
258.36901776,
320.20921029,
414.52018902,
493.86274428,
579.50664427
],
[
141.375,
36.25,
107.73897746,
142.28833697,
198.46555753,
252.40205216,
319.53289083,
429.60637337,
523.45755421,
622.68024698
],
[
141.375,
36.416667,
103.29760258,
136.45158171,
190.62228852,
243.69312566,
314.01900572,
437.72949194,
541.98352026,
648.73730304
],
[
141.375,
36.583333,
98.7959478,
130.71205259,
183.11652972,
234.78614286,
305.69913859,
438.89979643,
549.2080533,
659.16120837
],
[
141.625,
36.083333,
124.75632882,
165.73002859,
231.37668337,
291.58379188,
361.79901686,
468.95951858,
559.13635853,
655.98993895
],
[
141.625,
36.25,
120.03757242,
158.74603333,
221.44869597,
281.53331852,
357.29440543,
482.06718237,
588.28438665,
700.08045459
],
[
141.625,
36.416667,
114.50433306,
151.08238557,
210.8777076,
269.17162103,
347.61389457,
489.33717646,
608.46063145,
729.43131002
],
[
141.625,
36.583333,
109.26797886,
144.2446611,
201.26086483,
257.44525134,
335.81970312,
488.02737302,
613.55976634,
737.39583340
],
[
141.875,
36.083333,
140.26108618,
189.17742239,
264.45073918,
329.64387688,
401.35894765,
505.55812579,
591.07116267,
682.40265511
],
[
141.875,
36.25,
135.69527386,
180.67538799,
252.08466225,
317.10408837,
392.20227058,
504.08348388,
596.22535143,
694.18266238
],
[
141.875,
36.416667,
128.63754451,
170.27995983,
237.40345756,
301.56317422,
382.07504441,
511.69601417,
619.41198708,
732.18174522
],
[
141.875,
36.583333,
122.05080501,
161.15770759,
224.69732074,
286.75937122,
370.29664957,
519.34165864,
643.01591638,
768.61521538
],
[
141.125,
36.75,
83.87500065,
111.87343673,
158.44858789,
204.63421835,
266.46443361,
374.47258577,
463.23153602,
553.33041410
],
[
141.125,
36.916667,
78.31870768,
104.93941267,
149.27979194,
193.33449762,
252.23402093,
352.4273104,
434.13831464,
517.38399828
],
[
141.125,
37.083333,
72.10445328,
97.13138231,
138.98776623,
180.5439142,
235.47008853,
326.26366156,
399.97650883,
475.45385673
],
[
141.125,
37.25,
65.89233679,
88.99245745,
127.99335702,
166.68944434,
216.93700223,
298.0824056,
363.94270582,
431.79860544
],
[
141.375,
36.75,
94.1546298,
124.91189643,
175.55204828,
225.69046758,
295.56795815,
431.6267714,
542.80422177,
652.02609605
],
[
141.375,
36.916667,
89.29888242,
118.96742762,
167.92681267,
216.42885746,
284.35074954,
417.46933533,
525.77604073,
631.93760494
],
[
141.375,
37.083333,
84.37706117,
112.71007917,
159.66138289,
206.49827314,
271.61609887,
396.95946134,
499.54791933,
600.67731905
],
[
141.375,
37.25,
79.06573753,
105.93585076,
150.59397166,
195.1094794,
256.47005207,
369.84402553,
463.42698972,
557.18676130
],
[
141.625,
36.75,
104.43711956,
137.91603597,
192.72333335,
246.95707353,
323.31619203,
477.88547184,
603.8552854,
726.23677539
],
[
141.625,
36.916667,
99.5435031,
131.83461149,
184.74091139,
236.98049627,
311.06519725,
462.15223191,
585.13766423,
704.29719541
],
[
141.625,
37.083333,
95.02960012,
126.09521232,
177.15263415,
227.75237536,
298.62981113,
442.07089704,
559.67846045,
674.28282117
],
[
141.625,
37.25,
92.85977565,
122.94541386,
171.93264849,
220.00022013,
287.01079083,
416.61140287,
525.21891161,
633.07770906
],
[
141.875,
36.75,
115.90217463,
152.91602385,
213.3308738,
272.6990171,
355.66348549,
517.2777512,
650.11145257,
780.99516263
],
[
141.875,
36.916667,
110.22505409,
145.5663218,
203.2464043,
259.94588776,
340.44340583,
504.25146784,
638.49035982,
769.07939078
],
[
141.875,
37.083333,
105.23870616,
139.02009669,
194.37363163,
249.09051095,
325.79233934,
480.85893884,
609.59279994,
735.47619394
],
[
141.875,
37.25,
103.11432847,
135.86167188,
188.86199161,
240.71835275,
312.10322453,
448.56839135,
564.92489402,
681.69373494
],
[
141.125,
37.416667,
63.79950376,
86.45317385,
123.42051404,
158.76127937,
202.74042475,
271.91201618,
328.81351944,
388.36856282
],
[
141.125,
37.583333,
59.51782358,
82.24544767,
119.37497975,
153.66733232,
193.39484491,
252.64955221,
301.18162713,
352.77197291
],
[
141.125,
37.75,
56.00010709,
79.15572506,
118.52109375,
153.51089001,
191.5303078,
245.44431063,
288.90473308,
334.91792146
],
[
141.125,
37.916667,
53.0600967,
76.92230065,
119.13707781,
156.05757864,
195.21334304,
250.10477979,
294.16010406,
340.66340087
],
[
141.375,
37.416667,
77.35131973,
103.97238468,
147.14810723,
188.83403827,
243.63092259,
338.27882854,
418.11466388,
500.51569077
],
[
141.375,
37.583333,
73.40179468,
100.41912522,
144.4876822,
185.33581345,
234.35529897,
310.68163516,
374.72625761,
442.84492051
],
[
141.375,
37.75,
69.4347124,
97.85514516,
145.52359001,
187.823096,
234.12419795,
299.98014422,
353.27098121,
409.58809053
],
[
141.375,
37.916667,
66.04633529,
95.70720078,
148.30898031,
194.03924909,
242.39024927,
309.85960946,
363.772722,
420.45075932
],
[
141.625,
37.416667,
89.81606878,
119.86837124,
168.27421795,
214.89630724,
276.14795626,
386.20463294,
480.86267308,
578.40061884
],
[
141.625,
37.583333,
87.15018885,
118.38347469,
168.76288375,
215.35164683,
271.16083094,
359.75198577,
435.72195865,
517.39137830
],
[
141.625,
37.75,
85.4743121,
119.15105026,
175.00322127,
224.05426442,
277.44988423,
353.69766864,
415.44095169,
480.84311502
],
[
141.625,
37.916667,
83.23438111,
119.58768967,
182.94825133,
237.70459922,
295.78268992,
376.98886283,
441.94596172,
510.31925589
],
[
141.875,
37.416667,
101.33836992,
134.27786911,
186.80012545,
236.7509776,
300.85911651,
413.20415704,
511.48294458,
614.62935364
],
[
141.875,
37.583333,
100.13210332,
135.10505783,
190.62972036,
240.73833583,
298.85227897,
388.19368,
464.1472022,
546.51807759
],
[
141.875,
37.75,
99.53234232,
138.33270474,
201.62962779,
256.03796623,
314.36113664,
396.66358489,
462.88690419,
532.90378371
],
[
141.875,
37.916667,
99.56877966,
142.56007669,
216.7299521,
281.29411889,
350.49129696,
447.83304912,
526.09182635,
608.11698144
],
[
141.125,
38.083333,
51.16005015,
75.5940684,
119.52762571,
158.32069382,
199.99053841,
259.1067458,
306.97476621,
357.61403926
],
[
141.125,
38.25,
50.09596512,
75.23560705,
119.89804668,
159.93553092,
204.13448161,
268.68151511,
322.52031502,
381.25540939
],
[
141.125,
38.416667,
48.63306594,
73.84690287,
121.07480645,
165.4552681,
216.24763775,
293.79923,
361.05731682,
436.27235901
],
[
141.125,
38.583333,
47.47726981,
73.03125262,
120.57422965,
164.81781195,
215.63259761,
293.91713531,
362.36809233,
439.09073529
],
[
141.375,
38.083333,
63.24297279,
93.26298788,
148.54565106,
197.48444063,
249.81083509,
323.22923626,
382.11002481,
444.06997907
],
[
141.375,
38.25,
60.72221227,
89.74175335,
142.95444342,
190.73065091,
242.30898196,
314.97509205,
373.26403097,
434.56815815
],
[
141.375,
38.416667,
58.76411984,
87.02269221,
138.082855,
184.06825375,
233.80291385,
303.95710504,
360.33467442,
419.76949113
],
[
141.375,
38.583333,
56.07396033,
83.71865893,
134.52342161,
180.05240573,
229.27024044,
298.91171798,
355.36772274,
415.30714580
],
[
141.625,
38.083333,
81.20343576,
118.63164599,
186.07068781,
245.88465838,
309.88307749,
399.5507993,
471.28345662,
546.54113951
],
[
141.625,
38.25,
78.76345397,
114.94591949,
179.71818595,
237.78640948,
300.17183765,
387.7763137,
457.7685079,
531.40851379
],
[
141.625,
38.416667,
76.02654781,
110.86848968,
173.48218256,
229.52010434,
289.67650736,
374.10541669,
441.6171623,
512.65304106
],
[
141.625,
38.583333,
71.60212685,
105.6609507,
166.81749785,
221.12022888,
279.22620418,
360.65919606,
425.80845662,
494.18607251
],
[
141.875,
38.083333,
99.74864853,
144.44014398,
224.06450928,
295.15547114,
371.60242733,
478.8550664,
564.7324134,
654.58265037
],
[
141.875,
38.25,
98.70569086,
142.51073337,
219.67860939,
288.34512424,
362.05915769,
465.63443834,
548.47073803,
635.52553334
],
[
141.875,
38.416667,
96.5015077,
139.75044456,
215.44704043,
281.84197149,
352.98831441,
452.80184931,
532.80981278,
616.65005591
],
[
141.875,
38.583333,
92.04895912,
134.68113098,
208.84721967,
273.26598411,
341.92046344,
438.12897736,
515.22360592,
595.89415757
],
[
141.125,
38.75,
45.63836375,
70.49772217,
116.58529591,
159.3799188,
209.28209663,
287.26090349,
356.27348749,
433.94296137
],
[
141.125,
38.916667,
42.0156289,
66.29015126,
109.96594063,
151.01620419,
199.79631961,
278.41779099,
349.0632438,
428.54789914
],
[
141.125,
39.083333,
39.40083833,
62.12428745,
102.62475679,
141.74464056,
190.48309824,
272.75368702,
347.52524319,
431.10296168
],
[
141.125,
39.25,
37.15477455,
57.93026663,
95.12910259,
132.58466343,
182.06097193,
269.19222459,
348.34544178,
435.67440428
],
[
141.375,
38.75,
52.96409203,
79.5365317,
127.9715062,
171.00917137,
217.53386077,
283.74739683,
337.62418871,
395.16382922
],
[
141.375,
38.916667,
48.10821366,
73.04637819,
116.58910095,
154.63898682,
195.85141885,
255.20638099,
304.1623875,
357.15609282
],
[
141.375,
39.083333,
44.10743568,
66.52841474,
104.36656787,
137.2140569,
173.23404017,
226.3474131,
271.37750162,
321.36318114
],
[
141.375,
39.25,
39.88670842,
59.79230917,
92.34077692,
120.57626219,
152.14284061,
200.03577096,
242.28723034,
290.82646018
],
[
141.625,
38.75,
66.85738936,
98.7015887,
155.10039109,
204.68888193,
257.69712744,
332.17718361,
391.82726385,
454.52657282
],
[
141.625,
38.916667,
60.81969716,
89.23015673,
136.98088467,
178.00125342,
221.88978343,
283.77722681,
333.56640557,
386.04709665
],
[
141.625,
39.083333,
52.02654656,
76.38165038,
116.27137488,
150.04152946,
186.08943151,
236.98485371,
278.04079625,
321.50055406
],
[
141.625,
39.25,
46.55704402,
67.04727177,
99.78285179,
127.52439729,
157.28693749,
199.72576288,
234.42575448,
271.43087400
],
[
141.875,
38.75,
85.63206019,
124.58254888,
189.93522785,
245.87171734,
305.33414203,
388.81540587,
455.70631455,
526.23715873
],
[
141.875,
38.916667,
77.26258717,
110.81560004,
164.53305106,
209.61739894,
257.4850597,
325.00841379,
379.31634459,
436.65108054
],
[
141.875,
39.083333,
67.20469063,
95.75706024,
139.99270107,
176.85099348,
216.19501217,
272.04435424,
317.34055296,
365.54994412
],
[
141.875,
39.25,
57.85105763,
81.52996806,
118.07702335,
148.65044162,
181.56444171,
228.90121868,
267.70314469,
309.38195031
],
[
141.125,
39.416667,
30.25440627,
46.5354596,
78.9885332,
118.0071928,
174.41014049,
272.1015455,
357.6572366,
451.20239494
],
[
141.125,
39.583333,
30.88956933,
46.58311418,
78.22415184,
117.40521158,
175.35525099,
275.06860308,
361.76301972,
456.81829935
],
[
141.125,
39.75,
30.24126119,
45.75984402,
76.71555925,
114.19507577,
168.71625375,
262.63331938,
343.80679428,
431.40712264
],
[
141.125,
39.916667,
28.34739281,
43.72009332,
74.7162362,
111.50078155,
164.74074824,
256.02211702,
334.68446233,
419.44530353
],
[
141.375,
39.416667,
37.86817344,
55.11839136,
82.6422947,
106.61742798,
133.47648116,
174.34367458,
210.36659027,
251.38444678
],
[
141.375,
39.583333,
32.18912763,
45.82423442,
68.62758409,
90.0737527,
115.7191371,
156.63787667,
193.7146422,
236.67789359
],
[
141.375,
39.75,
31.51000672,
44.96959103,
67.50955113,
88.77405858,
114.24575118,
155.0641742,
192.04085678,
234.88226871
],
[
141.375,
39.916667,
31.57204483,
45.114396,
67.85095465,
89.27081326,
114.86569321,
155.80184469,
193.10805829,
236.80301540
],
[
141.625,
39.416667,
41.39011504,
58.95951189,
86.4233215,
109.58796705,
134.7524293,
171.04447628,
201.0852186,
233.65251983
],
[
141.625,
39.583333,
34.86188991,
48.32046067,
70.09754959,
89.5804986,
111.59464046,
144.62947225,
172.70862865,
203.74487381
],
[
141.625,
39.75,
34.31565672,
47.64542184,
69.24481948,
88.65483009,
110.64333308,
143.88937473,
172.26862706,
203.75348049
],
[
141.625,
39.916667,
35.19100667,
48.87250065,
71.38133164,
91.69203857,
114.88638659,
150.03233211,
180.40633082,
214.50935295
],
[
141.875,
39.416667,
49.81111922,
69.6264913,
99.94747782,
125.49975133,
153.16060664,
193.25488166,
226.57328246,
262.53208989
],
[
141.875,
39.583333,
42.09143167,
57.90397595,
83.05729576,
105.09184519,
129.55975577,
165.85520549,
196.36893637,
229.88331384
],
[
141.875,
39.75,
42.39657877,
58.86433632,
85.99293245,
110.11877931,
137.20100304,
177.04144356,
210.33287425,
246.25421712
],
[
141.875,
39.916667,
45.05955231,
62.96694485,
93.03940074,
120.18351278,
150.64620597,
195.37237042,
232.47106042,
272.30919664
],
[
141.125,
40.083333,
28.80150623,
44.23677735,
74.86234755,
110.62844287,
162.38973616,
252.84717668,
331.76021305,
417.08151295
],
[
141.125,
40.25,
29.06222821,
44.55673204,
75.04963055,
110.46798807,
162.0463982,
253.15586923,
332.7885537,
418.74708918
],
[
141.125,
40.416667,
31.67712814,
46.88202806,
76.34263664,
110.9434178,
162.23785173,
253.77657593,
333.95116775,
420.52269103
],
[
141.125,
40.583333,
32.03582976,
47.00469365,
75.47446615,
108.49196785,
157.83206751,
247.58958844,
326.70479347,
412.24075476
],
[
141.375,
40.083333,
30.57957427,
44.64883362,
68.40520004,
90.84670502,
117.69723835,
161.51074209,
203.47763885,
256.35404376
],
[
141.375,
40.25,
31.45601742,
45.68554704,
69.87573384,
93.19871979,
121.58203435,
170.63420536,
222.12801956,
295.10951756
],
[
141.375,
40.416667,
36.32375346,
52.27622303,
79.52204042,
104.71146856,
133.76744778,
179.40648777,
221.65355649,
274.04526736
],
[
141.375,
40.583333,
37.01637367,
53.21201552,
80.75921111,
106.14589768,
135.04940847,
178.83122794,
216.81644587,
259.57569823
],
[
141.625,
40.083333,
37.36348118,
53.88443887,
81.5724131,
106.36099168,
133.92011575,
174.6162972,
209.16023096,
247.49340998
],
[
141.625,
40.25,
39.2160512,
56.6461383,
85.87522611,
112.06866884,
141.24376104,
184.17217827,
220.12607724,
259.64304549
],
[
141.625,
40.416667,
42.15897154,
59.75385034,
89.71232812,
116.94797965,
147.42479224,
192.2147049,
229.52190838,
269.78603360
],
[
141.625,
40.583333,
43.43623545,
61.37640721,
92.23280856,
120.65476119,
152.86994425,
200.25185215,
239.45649273,
281.50668963
],
[
141.875,
40.083333,
47.60936382,
67.50265938,
101.13583022,
131.48202636,
165.24706069,
214.47433701,
254.95501945,
298.27715405
],
[
141.875,
40.25,
50.87321674,
72.28633858,
108.5175133,
141.18013122,
177.46207718,
230.19276172,
273.3646185,
319.38284626
],
[
141.875,
40.416667,
53.51504531,
75.81355463,
113.98142641,
148.72458571,
187.51311017,
243.90735937,
290.09331286,
339.19776177
],
[
141.875,
40.583333,
54.65345711,
77.43953919,
117.15693788,
154.06157004,
195.72157757,
256.68080993,
306.70709161,
359.91140349
],
[
141.125,
40.75,
32.3855008,
47.20812831,
74.72178785,
105.56567158,
150.88033112,
236.43418836,
314.32059342,
399.36888531
],
[
141.125,
40.916667,
34.99290919,
52.11639454,
84.52557766,
118.52157401,
163.58245032,
243.28097972,
317.41179151,
400.45799063
],
[
141.125,
41.083333,
35.75159781,
53.31630041,
86.74286795,
121.90433764,
167.73160409,
246.9879513,
319.96625941,
402.11235214
],
[
141.125,
41.25,
35.83378383,
53.78923118,
88.30962409,
124.86758355,
171.79693523,
251.19351191,
323.41975388,
404.67052453
],
[
141.375,
40.75,
37.8236462,
54.21847372,
82.2198385,
108.22553224,
137.97961718,
182.62496176,
220.40203246,
261.92868377
],
[
141.375,
40.916667,
38.11689142,
54.67641201,
83.03459886,
109.5305181,
140.01092137,
185.59014469,
223.70428178,
264.87378999
],
[
141.375,
41.083333,
38.27177786,
55.09828899,
84.40513239,
112.50290458,
145.42836512,
195.06043174,
236.56045246,
281.12566815
],
[
141.375,
41.25,
38.52433801,
55.56601341,
85.90192058,
115.97834021,
152.0440203,
207.15597344,
253.10965385,
302.28986026
],
[
141.625,
40.75,
43.96054686,
62.18761358,
93.9218774,
123.82184091,
158.20964172,
209.42734518,
251.79253435,
297.13094294
],
[
141.625,
40.916667,
44.07630273,
62.51820674,
95.20944144,
127.03389892,
164.67390417,
221.54358931,
268.93661732,
319.53029410
],
[
141.625,
41.083333,
44.1364339,
62.70455052,
96.47946722,
130.89963264,
173.19978459,
238.05641351,
291.95678376,
349.25529939
],
[
141.625,
41.25,
45.47545614,
64.05576563,
98.36631154,
135.42474849,
183.01938453,
257.18658608,
318.35945293,
382.96046913
],
[
141.875,
40.75,
54.85494204,
77.76257534,
118.52570091,
157.69936936,
202.97838524,
270.05850702,
325.31119769,
384.19598345
],
[
141.875,
40.916667,
54.50174799,
77.27868751,
118.84086033,
160.78967095,
211.17504453,
286.90072053,
349.44212115,
415.86961394
],
[
141.875,
41.083333,
54.45024139,
76.90508208,
119.12725494,
164.75036852,
222.0991392,
309.46068836,
380.86609033,
456.12546135
],
[
141.875,
41.25,
54.28793454,
76.45998065,
119.19109396,
168.81098933,
234.76262899,
334.92518294,
415.49129509,
499.49633219
],
[
141.125,
41.416667,
37.29298915,
55.13414601,
89.31328333,
126.0662352,
173.44309252,
253.09708484,
325.15391739,
406.03164376
],
[
141.125,
41.583333,
35.36670878,
52.7751224,
86.41663045,
122.33401669,
169.04440005,
248.49026763,
320.75502989,
402.03301172
],
[
141.125,
41.75,
35.08230815,
51.71568386,
82.75946419,
114.8856821,
156.37272715,
228.75840834,
297.27105018,
376.40671409
],
[
141.125,
41.916667,
34.61867133,
50.73699345,
80.10156894,
109.74773805,
147.57440315,
213.43770331,
276.42785259,
350.09703562
],
[
141.375,
41.416667,
40.25903117,
57.3541262,
87.65176019,
118.28390006,
155.91860807,
214.21852114,
263.01138681,
315.25486284
],
[
141.375,
41.583333,
40.02415884,
57.0181121,
86.87890433,
116.84644709,
153.56391938,
210.66702302,
258.56482263,
310.00653315
],
[
141.375,
41.75,
39.52721059,
56.19941587,
84.9869737,
113.04727159,
146.73476883,
198.6436339,
242.48254839,
289.71525977
],
[
141.375,
41.916667,
37.58402042,
54.1463209,
82.82070582,
110.35391456,
143.25427455,
194.60115053,
239.44492737,
289.96164547
],
[
141.625,
41.416667,
45.6136242,
64.14566061,
98.64656955,
137.27348493,
188.98350767,
270.84119463,
338.01326609,
408.63369904
],
[
141.625,
41.583333,
45.23490804,
63.50021707,
97.13087002,
134.11244252,
183.59907201,
262.76187517,
328.25088743,
397.14151466
],
[
141.625,
41.75,
44.64889936,
62.47564978,
94.36345278,
127.38984769,
169.60352688,
236.91292011,
293.43482762,
353.51563852
],
[
141.625,
41.916667,
43.96364036,
61.34437498,
91.24780949,
120.13535431,
154.90604839,
208.74099074,
254.19393448,
303.13955632
],
[
141.875,
41.416667,
53.48071637,
75.27945038,
117.66922861,
169.50500904,
242.44126848,
353.51186681,
441.68158523,
533.16555645
],
[
141.875,
41.583333,
52.53792156,
73.74751004,
114.17452989,
162.50373522,
231.27543604,
338.51504326,
424.40057562,
513.57642186
],
[
141.875,
41.75,
51.78584777,
72.39959222,
109.9300273,
151.04180186,
205.7326125,
292.44089567,
363.9441141,
439.06620891
],
[
141.875,
41.916667,
51.23682068,
71.33111413,
106.205981,
140.56906701,
182.58995881,
247.91262529,
302.7674544,
361.48828431
],
[
141.125,
42.083333,
31.68231913,
45.84316923,
70.40950161,
96.09273743,
131.47865294,
200.76352953,
269.51633373,
347.55385872
],
[
141.125,
42.25,
30.45042235,
44.45456533,
68.79540112,
94.43856187,
130.20629596,
200.59141783,
269.79178627,
347.93541449
],
[
141.125,
42.416667,
29.21823588,
42.66122573,
66.53241108,
91.87239746,
128.192997,
199.75936509,
269.53471322,
347.91647000
],
[
141.125,
42.583333,
27.67977073,
40.25841739,
63.59674043,
88.81442258,
125.88124353,
198.9297154,
269.2516538,
347.79157478
],
[
141.375,
42.083333,
36.96544773,
53.55981154,
82.54512442,
110.94943096,
146.53570446,
207.79686269,
266.88666418,
337.28566397
],
[
141.375,
42.25,
34.03388058,
48.53584692,
73.66691709,
98.96173312,
133.58906411,
201.00347212,
268.99587482,
346.86964203
],
[
141.375,
42.416667,
32.68247852,
46.98340795,
71.81469162,
97.49836127,
133.02640895,
202.20147437,
270.62745589,
348.41077704
],
[
141.375,
42.583333,
30.5866837,
44.4245207,
68.52881288,
94.18284988,
130.43993208,
201.69281995,
270.9363406,
348.86500645
],
[
141.625,
42.083333,
42.35759543,
59.67099559,
88.70428665,
115.44643751,
146.20663588,
192.77183586,
232.38328172,
275.62357325
],
[
141.625,
42.25,
40.57093888,
58.03512853,
87.15584904,
114.37868845,
146.91027089,
200.35965774,
251.16476241,
312.14625017
],
[
141.625,
42.416667,
37.27800796,
52.71980786,
78.92657318,
105.26048475,
140.18485128,
206.42586772,
272.22964715,
348.47920892
],
[
141.625,
42.583333,
34.7995462,
49.55800756,
75.60728839,
102.30656622,
139.11459812,
209.70229133,
278.10905208,
355.64370102
],
[
141.875,
42.083333,
49.89396319,
69.68462591,
102.42733802,
132.46720018,
166.93983352,
218.57872616,
261.72224083,
308.17391530
],
[
141.875,
42.25,
49.13259994,
68.59759156,
99.78532355,
127.5978986,
158.77242382,
205.06770462,
243.71178615,
285.63338162
],
[
141.875,
42.416667,
45.06698977,
62.55097096,
90.72613715,
116.88476541,
148.15943345,
199.38289394,
246.96313875,
302.34229486
],
[
141.875,
42.583333,
40.29975835,
57.15472908,
85.38649586,
113.42248658,
150.34970872,
219.26047571,
288.60438054,
370.52640884
],
[
141.125,
42.75,
25.89320097,
37.90469791,
60.27584877,
85.80925844,
123.77552262,
198.43902289,
269.19852906,
347.82917167
],
[
141.125,
42.916667,
23.9148564,
35.37485808,
57.18981828,
82.7636147,
121.9930542,
198.2155934,
269.29764115,
348.01288368
],
[
141.125,
43.083333,
21.84964474,
32.75197769,
54.09705551,
79.88206491,
120.59374878,
198.26283892,
269.58576794,
348.28188791
],
[
141.125,
43.25,
13.52944341,
23.31440343,
45.94631918,
75.0210032,
118.84671417,
198.27190364,
269.85891624,
348.54754568
],
[
141.375,
42.75,
28.30640278,
41.14570295,
64.62577547,
90.00523408,
127.65306752,
201.55394614,
271.9110505,
350.17636933
],
[
141.375,
42.916667,
25.89647874,
37.87210438,
60.24068566,
86.10434815,
125.22242065,
201.80930777,
273.03330719,
351.61057884
],
[
141.375,
43.083333,
23.46837299,
34.77358924,
56.49660536,
82.49237332,
123.53891209,
202.74731502,
274.81132665,
353.73467790
],
[
141.375,
43.25,
19.1216393,
29.49692549,
51.2775599,
78.95517189,
122.83184659,
204.75930045,
278.31953289,
358.70488931
],
[
141.625,
42.75,
31.29456302,
45.28141965,
69.86072291,
96.51445407,
134.62278706,
210.03408144,
283.14729045,
365.16491519
],
[
141.625,
42.916667,
27.87743363,
40.3159033,
63.60829465,
89.4782198,
129.09718174,
209.00044919,
285.04665742,
370.10770737
],
[
141.625,
43.083333,
24.81458364,
36.22953409,
57.69609081,
82.96938425,
123.32760298,
204.94211557,
279.993444,
361.82159838
],
[
141.625,
43.25,
19.20717898,
29.46647372,
50.46633141,
77.47543074,
122.9734498,
214.94348218,
300.65134414,
397.59930338
],
[
141.875,
42.75,
35.15822608,
49.83794893,
75.65573487,
101.97351082,
138.36175405,
211.04932041,
287.94715007,
382.89644083
],
[
141.875,
42.916667,
29.90435677,
42.97448334,
65.44411584,
88.49007008,
120.38085063,
183.80165873,
249.85019587,
328.09316473
],
[
141.875,
43.083333,
26.05053814,
37.31454792,
57.24652821,
78.20434394,
108.34483759,
170.13758475,
232.77621165,
304.10101520
],
[
141.875,
43.25,
20.00177799,
30.12283083,
48.86001017,
69.1467306,
99.0488784,
161.33307701,
224.63791846,
296.84599872
],
[
141.125,
43.416667,
10.68167635,
20.14838786,
43.34274019,
73.32812682,
118.17628152,
198.19364161,
269.90872683,
348.66176994
],
[
141.125,
43.583333,
8.96670574,
16.91895582,
40.22828353,
71.71499055,
117.41648101,
197.70230053,
269.50901161,
348.35606800
],
[
141.125,
43.75,
8.87204112,
16.49485606,
39.59863272,
71.00137587,
116.58775018,
196.77756954,
268.69554085,
347.67300513
],
[
141.125,
43.916667,
8.77852685,
16.10787903,
39.16475708,
70.41566013,
115.87931715,
196.17360159,
268.28692022,
347.43426607
],
[
141.375,
43.416667,
10.73155194,
19.95451057,
43.43879869,
74.48744873,
121.30070356,
204.99752255,
279.13678244,
359.90688019
],
[
141.375,
43.583333,
8.80584557,
16.04549652,
38.64477861,
70.35746428,
117.8816403,
201.4306406,
274.97968175,
354.86059142
],
[
141.375,
43.75,
8.7312771,
15.60240934,
37.17223002,
67.73992033,
114.39088817,
196.59852629,
269.14748605,
348.25321958
],
[
141.375,
43.916667,
8.63312726,
15.10597632,
36.04658923,
65.63504642,
110.81971335,
192.3221472,
265.19896692,
344.87156760
],
[
141.625,
43.416667,
10.23538978,
19.15149685,
40.28054364,
70.22184843,
120.41799239,
218.68117881,
309.97846226,
412.54906776
],
[
141.625,
43.583333,
9.72497968,
18.11728245,
37.87450587,
64.47024214,
106.17964364,
188.07791158,
265.57687844,
351.14812774
],
[
141.625,
43.75,
8.45739331,
14.05895394,
32.42663201,
57.58625206,
96.22835478,
170.07930321,
239.02849965,
315.30904388
],
[
141.625,
43.916667,
8.36195416,
13.52844398,
30.76167676,
54.55346664,
90.15446083,
156.31824279,
217.73564892,
286.74781727
],
[
141.875,
43.416667,
14.06367978,
21.84649186,
38.94971783,
60.07884926,
94.03544315,
165.70194595,
238.81127665,
324.38543948
],
[
141.875,
43.583333,
9.55079997,
17.08004676,
33.61659472,
54.99770508,
89.67329512,
166.23854758,
248.41526945,
351.26155582
],
[
141.875,
43.75,
8.01306165,
11.74161979,
27.32171416,
47.99399339,
81.13989537,
150.9596804,
224.41214028,
314.28305723
],
[
141.875,
43.916667,
7.89846994,
11.1266448,
25.99891449,
45.21491495,
75.40534026,
137.15869885,
199.80067862,
272.32297311
],
[
141.125,
44.083333,
8.67862204,
15.69128789,
38.7434051,
69.8880686,
115.39051416,
195.92412992,
268.1772119,
347.42514883
],
[
141.125,
44.25,
8.57593966,
15.23006634,
38.1894444,
69.31241134,
114.96029289,
195.76345615,
268.10030619,
347.34703925
],
[
141.125,
44.416667,
8.45840591,
14.65221959,
37.38867892,
68.57137546,
114.4747567,
195.57598838,
268.01014513,
347.29357027
],
[
141.125,
44.583333,
8.32402644,
13.94870352,
36.50252557,
67.89583258,
114.11091145,
195.50153229,
268.03000145,
347.38677852
],
[
141.375,
44.083333,
8.53127353,
14.62763037,
35.27722047,
64.84601582,
110.26829967,
192.35653885,
265.59615238,
345.51630322
],
[
141.375,
44.25,
8.44148943,
14.21918603,
34.60234429,
63.74614368,
109.01148226,
191.46291656,
264.98998246,
345.05779226
],
[
141.375,
44.416667,
8.34021406,
13.75211012,
33.76026253,
61.54171945,
104.48809093,
184.63203112,
257.8075987,
338.01086275
],
[
141.375,
44.583333,
8.2214585,
13.16358018,
32.92589303,
60.47767978,
103.64913958,
184.58310814,
258.24305571,
338.78057592
],
[
141.625,
44.083333,
8.27146258,
13.08084062,
29.84283838,
52.98199364,
87.54279502,
152.41555659,
213.9914079,
283.80185043
],
[
141.625,
44.25,
8.17534032,
12.61405133,
29.18644417,
51.83211492,
86.07235481,
150.71133551,
212.53567439,
282.66695391
],
[
141.625,
44.416667,
8.08234695,
12.16228707,
28.57299884,
50.17305649,
82.80059659,
145.14581983,
206.00284055,
275.86011843
],
[
141.625,
44.583333,
7.99054407,
11.70544475,
28.07964985,
49.12816685,
80.27774101,
139.77323792,
198.62975927,
267.34848929
],
[
141.875,
44.083333,
7.79537688,
10.58598526,
25.13145855,
43.67604054,
72.77859151,
132.13762072,
192.29853145,
262.29931620
],
[
141.875,
44.25,
7.80757931,
10.63427953,
24.78243691,
42.86898141,
71.32036107,
129.79658163,
189.76492359,
259.99742557
],
[
141.875,
44.416667,
7.71891146,
10.17448885,
24.24907579,
42.11993776,
70.30554695,
128.80409297,
189.03907683,
259.55748941
],
[
141.875,
44.583333,
7.63844386,
9.93784458,
23.80949811,
41.51047328,
69.58371523,
128.18988863,
188.64670488,
259.32806122
],
[
141.125,
44.75,
8.17612182,
13.13504941,
35.44384648,
67.0071443,
113.53806907,
195.30177458,
267.96890805,
347.37470967
],
[
141.125,
44.916667,
7.98542843,
12.00621755,
33.77393757,
65.19519671,
112.09334788,
194.52144035,
267.51050139,
347.09281194
],
[
141.125,
45.083333,
7.71292124,
10.19213363,
31.28361618,
62.46520369,
109.76248602,
193.12270947,
266.62287983,
346.57902361
],
[
141.125,
45.25,
7.336599,
9.54513536,
27.1731639,
57.57972999,
105.33088834,
190.06026372,
264.50909863,
345.14035046
],
[
141.375,
44.75,
8.08500223,
12.44694565,
32.20393218,
60.4937683,
105.18075244,
187.87122407,
262.06661495,
342.76705884
],
[
141.375,
44.916667,
7.90356142,
11.40985845,
30.9695717,
58.86477818,
102.55476079,
184.60572046,
258.84201378,
339.68366504
],
[
141.375,
45.083333,
7.64138086,
9.94166571,
29.14722655,
56.21595526,
96.79984372,
171.62725062,
240.82486056,
317.84051725
],
[
141.375,
45.25,
7.27495729,
9.46493766,
25.47210623,
52.17319042,
94.51685647,
173.49806343,
245.8524539,
325.40457643
],
[
141.625,
44.75,
7.86177235,
11.01818941,
27.39840288,
48.49002482,
80.12550505,
140.82552101,
200.37692594,
269.48356603
],
[
141.625,
44.916667,
7.69966969,
10.08225574,
26.61588148,
47.7198317,
79.44985029,
140.30668866,
199.98141509,
269.19970202
],
[
141.625,
45.083333,
7.4596188,
9.70518782,
25.20609226,
45.92780639,
76.76698693,
136.41707027,
195.86326604,
265.23490173
],
[
141.625,
45.25,
7.11528269,
9.25719621,
22.03704578,
42.34961545,
73.05637767,
132.98786247,
192.97487687,
262.85423242
],
[
141.875,
44.75,
7.52834336,
9.79460053,
23.16980107,
40.74543033,
68.95384775,
127.77321626,
188.39077738,
259.17633144
],
[
141.875,
44.916667,
7.38936026,
9.61377935,
22.49575438,
40.20317172,
68.6620067,
127.65098354,
188.32866296,
259.14756887
],
[
141.875,
45.083333,
7.17662716,
9.3370072,
21.20766252,
39.25820055,
68.00651563,
127.40062915,
188.23482775,
259.11168001
],
[
141.875,
45.25,
6.86629125,
8.93325088,
18.81906082,
36.57328549,
65.58467833,
126.01463154,
187.50455501,
258.74308456
],
[
141.125,
45.416667,
6.88805834,
8.96157051,
19.73457468,
43.30420963,
86.8899345,
172.94310489,
249.41290613,
331.61271905
],
[
141.125,
45.583333,
6.39052328,
8.31426248,
14.45004678,
26.93641056,
48.03872093,
93.0905542,
139.56212262,
194.25970986
],
[
141.125,
45.75,
5.84014331,
7.59820162,
9.9222283,
17.37864645,
27.2269281,
45.06507553,
62.19120505,
82.76070020
],
[
141.125,
45.916667,
5.24769358,
6.82740675,
8.91567398,
11.84499739,
17.7284093,
27.73240625,
37.51537114,
49.30261505
],
[
141.375,
45.416667,
6.83247035,
8.88924887,
18.94957495,
39.73410681,
79.52989649,
163.58143146,
240.47876082,
323.28904427
],
[
141.375,
45.583333,
6.34028052,
8.24889513,
13.94140525,
25.76116535,
45.36075054,
85.89619704,
127.35276472,
176.59314718
],
[
141.375,
45.75,
5.79883563,
7.5444591,
9.8520478,
16.91942049,
26.30019653,
43.09191592,
59.1704994,
78.43626150
],
[
141.375,
45.916667,
5.21457444,
6.78431777,
8.85940557,
11.57826499,
17.35125194,
26.9947142,
36.37619739,
47.65550986
],
[
141.625,
45.416667,
6.68891516,
8.70247926,
17.35337595,
33.64779923,
61.14257456,
120.29501207,
182.08850359,
254.11997026
],
[
141.625,
45.583333,
6.20875346,
8.07777449,
12.72858047,
23.07029563,
39.22590484,
72.07808685,
106.67674981,
150.07729189
],
[
141.625,
45.75,
5.67987804,
7.38969171,
9.64994242,
15.81003923,
24.38121374,
39.78529577,
54.98387139,
72.93624724
],
[
141.625,
45.916667,
5.11550589,
6.65542661,
8.69109107,
10.85068164,
16.5213112,
25.64425609,
34.50141676,
45.19124359
],
[
141.875,
45.416667,
6.47524932,
8.4244936,
15.29959377,
28.95483632,
54.61288294,
114.91531596,
178.91657412,
252.47266930
],
[
141.875,
45.583333,
6.02778826,
7.84233333,
11.1916633,
20.25348439,
35.62052183,
68.49561854,
105.80630495,
153.58496773
],
[
141.875,
45.75,
5.53127499,
7.19635468,
9.39747029,
14.59591768,
22.5852841,
37.78340148,
52.67692542,
70.54909025
],
[
141.875,
45.916667,
5.00161023,
6.50724494,
8.49758576,
10.01203136,
15.63694626,
24.32534971,
32.79474973,
43.11603254
],
[
142.125,
37.916667,
113.75674271,
161.26521834,
242.69126417,
314.6357969,
392.69179792,
503.55043245,
592.92333625,
687.10961676
],
[
142.125,
38.083333,
116.40964212,
166.33538904,
253.66541577,
331.60355857,
416.05294187,
535.59604886,
631.50685922,
732.34297161
],
[
142.125,
38.25,
117.59548463,
168.05626584,
255.01318464,
331.69021415,
414.44858286,
531.51766076,
625.43915527,
724.22243916
],
[
142.125,
38.416667,
116.69459541,
167.78831485,
254.60772284,
330.04854992,
411.0295991,
525.3792196,
617.05929715,
713.51399301
],
[
142.125,
38.583333,
112.49261481,
162.79923944,
247.16685955,
319.52003645,
396.87762985,
505.78553188,
593.16216411,
685.13120278
],
[
142.375,
38.416667,
133.93958413,
189.56333457,
280.03998452,
357.69999031,
441.42625216,
560.71834,
657.17444054,
759.29363128
],
[
142.375,
38.583333,
130.64309084,
185.22735767,
272.19829409,
345.53015984,
423.91956079,
534.94203713,
624.3833983,
718.76363686
],
[
142.125,
38.75,
104.92248174,
149.74280611,
221.07136521,
280.67957925,
343.98914931,
433.02123994,
504.58922511,
580.04837505
],
[
142.125,
38.916667,
94.39059707,
132.43026727,
190.6745569,
238.75831862,
289.78831328,
361.64256923,
419.57474588,
480.76000550
],
[
142.125,
39.083333,
81.02941764,
113.14633865,
161.9157123,
202.44641106,
245.83271845,
307.64208231,
357.93682781,
411.56041462
],
[
142.125,
39.25,
67.45221589,
93.79496468,
134.35229081,
168.59489369,
205.8206508,
259.3948161,
303.56261857,
350.91727799
],
[
142.375,
38.75,
122.9025532,
171.32201456,
245.11288636,
305.89131704,
370.28735251,
460.85469471,
533.89143067,
610.59547511
],
[
142.375,
38.916667,
111.02293815,
152.57473952,
214.97854742,
266.53462481,
321.51354204,
399.57907021,
462.85547497,
530.11905661
],
[
142.375,
39.083333,
95.08475648,
130.62358954,
184.67174366,
230.23659353,
279.48570118,
350.59663405,
408.82162267,
470.97969132
],
[
142.375,
39.25,
77.82664398,
107.39988781,
153.11678559,
192.31878829,
235.44308847,
298.18761399,
350.09472267,
405.69117981
],
[
142.625,
38.916667,
125.35764626,
170.65836018,
240.42733346,
300.11147418,
365.46720294,
460.02769644,
537.87380691,
620.75113612
],
[
142.625,
39.083333,
107.56121149,
147.33171307,
210.10335437,
265.04191127,
326.24344293,
416.00866761,
490.23302422,
569.82782993
],
[
142.625,
39.25,
87.77104652,
121.18553653,
175.03423524,
222.92426653,
276.61206322,
355.86552818,
421.66421167,
492.35831720
],
[
142.125,
39.416667,
56.43532477,
77.95850081,
111.22351867,
139.61870471,
170.74482842,
216.21525725,
253.9428211,
294.68120081
],
[
142.125,
39.583333,
49.76860286,
69.1474012,
99.9678913,
126.74056083,
156.07616179,
198.72522706,
234.11532373,
272.24426528
],
[
142.125,
39.75,
50.69293846,
70.54191024,
102.77602531,
131.18477274,
162.79726639,
209.23471087,
247.70632838,
289.20319874
],
[
142.125,
39.916667,
54.670091,
76.23009836,
112.59536036,
145.7302577,
182.92411095,
237.49424721,
282.4984099,
330.70561234
],
[
142.375,
39.416667,
60.78848818,
84.06754761,
121.5417893,
154.65026554,
191.37704286,
245.23951752,
289.77723016,
337.53597377
],
[
142.375,
39.583333,
56.5467861,
78.24900974,
113.19453445,
143.65084305,
177.12280196,
225.77845219,
265.81355479,
308.77970512
],
[
142.375,
39.75,
58.69267109,
81.35398873,
118.26901138,
150.97601581,
187.38700198,
240.67254771,
284.77847784,
332.03866654
],
[
142.375,
39.916667,
66.71654826,
92.53060445,
135.60111227,
174.69788009,
218.72294062,
283.45981851,
336.85385694,
393.91011446
],
[
142.625,
39.416667,
73.79073118,
102.96396258,
150.08259219,
191.29394765,
236.69721881,
302.67036625,
357.0713729,
415.36811193
],
[
142.625,
39.583333,
69.49259563,
97.21302676,
141.19441995,
178.84935989,
219.66055914,
278.28655008,
326.26629544,
377.45656244
],
[
142.625,
39.75,
71.96326645,
100.22724007,
145.44833522,
184.40177122,
226.95150457,
288.24581533,
338.42762944,
392.08770355
],
[
142.625,
39.916667,
81.66611544,
113.21959788,
164.42399356,
209.94927878,
260.49949394,
334.7850227,
396.10701928,
461.74189868
],
[
142.875,
39.416667,
97.09660652,
135.75437407,
197.51085229,
251.17455222,
309.82609526,
394.59863937,
464.16121615,
538.67179784
],
[
142.875,
39.583333,
92.54345361,
129.02126129,
186.46514928,
235.91514341,
290.01375042,
368.54473694,
433.41547344,
503.21633113
],
[
142.875,
39.75,
92.69346169,
128.69316655,
185.48438808,
234.37099428,
287.70542743,
364.84856862,
428.33696576,
496.35321548
],
[
142.875,
39.916667,
100.27525157,
138.54951185,
199.51398347,
252.62602732,
310.78977601,
394.89587179,
463.81276473,
537.46507169
],
[
142.125,
40.083333,
60.6192226,
85.46659357,
127.22798024,
164.94440195,
206.97778978,
268.013743,
318.04149598,
371.44697184
],
[
142.125,
40.25,
66.21120437,
93.24481385,
138.93919316,
180.1174055,
225.90866544,
292.19733532,
346.41192352,
404.07276837
],
[
142.125,
40.416667,
69.70399296,
98.21794714,
147.02343049,
191.45288426,
241.01436107,
313.00702432,
371.84397199,
434.37637983
],
[
142.125,
40.583333,
70.83203424,
100.05910942,
151.34972414,
199.09765794,
253.06556881,
331.80530216,
396.326712,
464.96908509
],
[
142.375,
40.083333,
75.29311164,
105.1024768,
155.47351216,
201.29984432,
252.69587212,
327.62772827,
389.14253535,
454.64181364
],
[
142.375,
40.25,
82.87794837,
115.91017732,
171.77327782,
222.52739841,
279.17295799,
361.72922977,
429.42322881,
501.41243305
],
[
142.375,
40.416667,
87.21993057,
122.35511104,
182.7250203,
238.0679374,
300.09815349,
390.68010207,
464.89108378,
543.93974175
],
[
142.375,
40.583333,
88.65628892,
125.00392792,
188.68887991,
248.43596812,
316.04183178,
415.16260644,
496.45063089,
583.02990499
],
[
142.625,
40.083333,
92.66539725,
128.41509298,
187.6726248,
241.45967658,
302.23987986,
392.02483615,
466.32110783,
545.85851054
],
[
142.625,
40.25,
100.94042374,
140.12080988,
206.16556532,
266.61829362,
335.11940005,
436.08100649,
519.53679643,
608.22074997
],
[
142.625,
40.416667,
105.28518361,
146.77446549,
217.95970254,
284.07694129,
359.08010862,
469.31036837,
559.86021585,
655.96062960
],
[
142.625,
40.583333,
106.68308162,
149.38791224,
224.49957918,
295.55329022,
376.81336598,
496.14507912,
593.85047366,
697.29444408
],
[
142.875,
40.083333,
110.57605426,
152.6345519,
220.94276573,
281.83686839,
349.81558081,
449.25649817,
531.40095263,
618.89200974
],
[
142.875,
40.25,
117.78514433,
163.07262299,
239.15916752,
309.2932008,
388.91810341,
506.59931725,
603.61347445,
707.15518484
],
[
142.875,
40.416667,
121.3647298,
168.89981617,
251.23494933,
328.63529586,
417.14243181,
547.35405795,
654.01171521,
767.19488907
],
[
142.875,
40.583333,
122.55954824,
171.34727216,
258.29018742,
342.40123274,
439.42069204,
581.86683879,
697.62648126,
820.09629004
],
[
142.125,
40.75,
70.53221166,
99.83728951,
152.71292584,
203.92597864,
263.05878467,
350.50393014,
422.30149546,
498.63058547
],
[
142.125,
40.916667,
69.27499064,
98.14299669,
151.85800675,
207.10115651,
273.15673137,
371.80666743,
452.52378653,
537.93099385
],
[
142.125,
41.083333,
68.17081178,
96.11491754,
150.10206264,
210.19624344,
285.04512896,
396.56424099,
486.44541876,
580.59326153
],
[
142.125,
41.25,
66.21765577,
93.31718164,
147.46232032,
212.65020278,
297.46279079,
421.79647719,
520.15592026,
622.02298653
],
[
142.375,
40.75,
88.22973385,
124.66266261,
190.35736627,
254.27936702,
328.03143997,
436.67284358,
525.77976925,
619.96309529
],
[
142.375,
40.916667,
86.55267019,
122.03686481,
188.70130839,
257.22326271,
338.55553596,
458.53714987,
555.9516298,
658.39354228
],
[
142.375,
41.083333,
83.47125165,
117.75180469,
185.12658217,
259.55822854,
350.69208799,
483.52976073,
589.76312806,
700.42723282
],
[
142.375,
41.25,
79.47149352,
112.43959629,
179.70629407,
261.07848394,
363.76500508,
510.44892663,
625.59599901,
744.67859626
],
[
142.625,
40.75,
105.83856061,
148.67522073,
226.40281467,
302.43264243,
390.81309773,
520.74009965,
626.40334389,
737.89070466
],
[
142.125,
41.416667,
63.97984199,
89.92313521,
142.69775148,
210.68145813,
303.85839281,
438.98551002,
544.3095484,
652.82643343
],
[
142.125,
41.583333,
62.05405861,
87.12790133,
136.5947159,
199.77782325,
290.93765953,
427.10979147,
533.86902333,
643.86862238
],
[
142.125,
41.75,
61.40202628,
85.8587033,
131.36428004,
183.19817366,
253.42801259,
363.22191991,
452.44214439,
545.62534474
],
[
142.125,
41.916667,
61.47947978,
85.59806746,
127.67861032,
169.83186704,
221.50967986,
301.21726649,
367.78271766,
438.60081735
],
[
142.375,
41.416667,
75.58766192,
106.71994131,
171.61011968,
257.59000364,
371.41514235,
531.0659866,
654.53791745,
781.71697485
],
[
142.375,
41.583333,
76.1966412,
108.41765127,
172.44844627,
252.97946624,
365.18889004,
530.73032869,
660.0344938,
793.30801828
],
[
142.375,
41.75,
75.53170028,
106.97818874,
166.22162399,
232.37458959,
320.27523369,
458.45285075,
571.173517,
688.81956658
],
[
142.375,
41.916667,
75.48185303,
106.31337675,
160.27006101,
212.87283422,
275.18205669,
370.45867411,
450.28243523,
535.88219611
],
[
142.625,
41.583333,
87.22794024,
125.89187416,
205.81921842,
308.79194727,
448.64117587,
648.217908,
802.84324747,
961.93918872
],
[
142.625,
41.75,
84.8763021,
121.3804464,
194.14133716,
280.66132582,
400.38894874,
585.85078982,
734.110673,
887.77075066
],
[
142.625,
41.916667,
83.19238241,
117.92045255,
182.12531815,
247.41021284,
326.35721149,
447.45414107,
548.5156215,
656.30643475
],
[
142.875,
41.583333,
95.97838301,
143.70564273,
247.58926489,
375.83200867,
539.89772246,
772.76963795,
954.41765265,
1142.15310268
],
[
142.875,
41.75,
91.77096046,
135.8588337,
231.69009329,
345.71928031,
497.48029456,
730.26852645,
917.35991857,
1111.97345131
],
[
142.875,
41.916667,
87.90250202,
126.3638115,
203.53100965,
285.73899466,
384.75039276,
534.04437404,
657.2947528,
788.49974044
],
[
142.125,
42.083333,
61.05819982,
84.72900604,
123.80870198,
159.84238946,
201.27208445,
263.07826982,
314.46618844,
369.49475016
],
[
142.125,
42.25,
59.67863131,
82.82650689,
119.64098614,
152.40879008,
189.07912717,
243.23211583,
288.23112849,
336.57963163
],
[
142.125,
42.416667,
56.61189507,
78.61595752,
113.3652313,
144.06932808,
178.63902633,
230.48537817,
274.20701036,
321.94230944
],
[
142.125,
42.583333,
47.75094016,
66.74774681,
97.25993449,
125.48438614,
159.12024674,
213.89694025,
263.98167782,
322.44526585
],
[
142.375,
42.083333,
74.84029122,
104.44246204,
153.15353765,
196.80200523,
245.58939697,
316.8957572,
375.70469998,
438.51760184
],
[
142.375,
42.25,
72.21706589,
100.28447788,
144.773699,
183.18583141,
225.21643873,
285.74625322,
335.23881905,
387.97004979
],
[
142.375,
42.416667,
67.76247681,
93.9563987,
134.6803186,
169.62858377,
207.99330231,
263.44868527,
309.2144274,
358.23027649
],
[
142.375,
42.583333,
55.22329587,
75.83596899,
108.49492884,
137.97288511,
171.92478867,
224.09709645,
269.0981891,
318.79533362
],
[
142.625,
42.083333,
80.74856582,
113.79817059,
170.23187356,
222.11485982,
280.29582908,
365.38410709,
435.24654688,
509.84075011
],
[
142.625,
42.25,
77.56044712,
108.21042934,
157.97930075,
201.53875986,
249.2032381,
317.50417001,
373.08517136,
431.95807330
],
[
142.625,
42.416667,
72.53710677,
100.74415235,
145.31847669,
183.61112375,
225.31432962,
285.12655617,
333.91219385,
385.78568043
],
[
142.625,
42.583333,
64.66913793,
90.13062654,
130.15229034,
164.63348583,
202.36547982,
257.11591238,
302.27943579,
350.86444292
],
[
142.875,
42.083333,
84.69575105,
120.58180281,
186.4784916,
249.53369911,
320.28868328,
422.40873926,
505.24455975,
592.74558047
],
[
142.875,
42.25,
80.64336886,
113.66407001,
169.52272659,
219.81729022,
275.2199313,
354.54498329,
418.74636588,
486.58807462
],
[
142.875,
42.416667,
75.37554106,
105.48680074,
154.45947174,
197.31099503,
244.15877544,
311.3057032,
365.8390436,
423.61747472
],
[
142.875,
42.583333,
67.73506737,
95.04623186,
138.81710229,
177.03757913,
218.92922268,
279.43519671,
329.03823943,
381.82713801
],
[
142.125,
42.75,
39.81608747,
56.03290668,
82.41108156,
107.44658813,
138.36444903,
191.62734962,
243.71692208,
306.54528218
],
[
142.125,
42.916667,
33.01220266,
46.47197246,
68.77217998,
90.24693681,
117.59701777,
167.03392643,
218.01260077,
280.97017669
],
[
142.125,
43.083333,
25.67007998,
37.15677332,
57.15483744,
77.08961188,
103.5108137,
154.92338724,
210.38374026,
277.99792424
],
[
142.125,
43.25,
21.81234898,
32.10444775,
50.28755274,
69.28241027,
95.90370579,
150.90764183,
210.69474441,
281.50196176
],
[
142.375,
42.75,
45.0303709,
62.65909353,
91.3142432,
118.01384669,
149.99804912,
202.56186146,
251.40070188,
308.80075676
],
[
142.375,
42.916667,
35.32597789,
49.85550974,
74.31948509,
97.28405551,
125.56159356,
174.3605809,
222.90851404,
282.76435780
],
[
142.375,
43.083333,
28.7265408,
41.34084946,
62.9194189,
83.85912226,
110.61400189,
161.13928589,
216.57580344,
287.88262523
],
[
142.375,
43.25,
22.81296919,
33.37650287,
52.24045031,
72.16885823,
101.02323733,
167.28305907,
248.24197709,
354.29408429
],
[
142.625,
42.75,
49.13215004,
67.97715911,
98.35480269,
126.35886596,
159.41423014,
212.64908879,
260.82900276,
317.06443642
],
[
142.625,
42.916667,
37.41192044,
53.10470458,
79.02408926,
103.46403993,
133.04231022,
182.69643667,
230.65212734,
288.65076096
],
[
142.625,
43.083333,
30.24185667,
43.62864127,
65.96591746,
87.43764302,
114.54081005,
163.37303633,
214.21185785,
277.56790998
],
[
142.625,
43.25,
25.60179365,
37.07010465,
57.13498593,
77.11736056,
103.36886678,
153.84296998,
208.70896114,
276.68487408
],
[
142.875,
42.75,
54.54807965,
77.78408824,
116.47393955,
151.45637875,
190.95027505,
249.96294352,
299.80140908,
354.93899165
],
[
142.875,
42.916667,
43.89317167,
63.3967848,
97.11917302,
128.53818698,
164.82997177,
220.56657115,
269.69284421,
325.62854091
],
[
142.875,
43.083333,
31.54094138,
45.3431122,
68.5736205,
91.1510521,
119.53784155,
169.65746481,
219.87988065,
281.53758425
],
[
142.875,
43.25,
26.42180181,
38.10909333,
58.657266,
79.21427406,
106.20704584,
156.33649109,
208.64127187,
272.85860091
],
[
142.125,
43.416667,
18.28756366,
27.19751207,
43.49910131,
61.0507986,
87.53074114,
146.6430441,
210.24646188,
283.04736984
],
[
142.125,
43.583333,
9.32035491,
16.06118688,
30.45664959,
49.1672686,
78.74003525,
142.89082194,
208.19738374,
281.77550734
],
[
142.125,
43.75,
7.64805729,
9.95035195,
23.65745896,
42.29634616,
73.36432778,
137.9476177,
202.50155233,
276.10275664
],
[
142.125,
43.916667,
7.52406051,
9.78902842,
22.39416948,
40.20829337,
70.26931787,
132.59215905,
194.82728286,
266.13607554
],
[
142.375,
43.416667,
18.56239938,
27.50146615,
43.86819965,
61.70535587,
89.27599477,
155.32750813,
231.86580541,
327.93364674
],
[
142.375,
43.583333,
9.06132347,
15.12233233,
28.60468279,
46.15862288,
73.93210187,
135.37295604,
199.72153765,
273.97500021
],
[
142.375,
43.75,
8.64132868,
13.66766166,
26.0475092,
41.74258352,
68.20768524,
128.63830297,
190.85663253,
261.90135591
],
[
142.375,
43.916667,
7.15491322,
9.30875671,
19.08161094,
34.96905241,
62.84728618,
124.19385943,
186.31956505,
257.81902846
],
[
142.625,
43.416667,
19.60393606,
29.02999492,
46.02108172,
63.69934678,
88.65391727,
141.9093187,
201.7211974,
274.17062592
],
[
142.625,
43.583333,
12.12418017,
18.53663228,
31.1095367,
45.89570344,
67.83396369,
116.13298263,
169.32107405,
233.42643765
],
[
142.625,
43.75,
8.37280203,
12.64253329,
23.88603209,
37.37396379,
57.75714808,
100.98268161,
147.98681897,
205.64450936
],
[
142.625,
43.916667,
6.85691364,
8.92105033,
16.99784418,
29.30285809,
50.37436676,
95.17728388,
142.52807656,
200.71634294
],
[
142.875,
43.416667,
22.5059873,
32.80277122,
51.10196075,
70.048108,
96.02208239,
146.4912115,
200.36700359,
266.70161125
],
[
142.875,
43.583333,
17.35141436,
25.24934904,
39.25279867,
54.2427771,
74.82016757,
116.86255496,
163.69517121,
222.94497297
],
[
142.875,
43.75,
8.47816698,
12.75304999,
22.71609995,
34.2893877,
50.72264577,
85.65286633,
125.80152286,
179.17750421
],
[
142.875,
43.916667,
6.87480337,
8.9443254,
16.1328647,
25.95468457,
41.61881262,
76.85655954,
117.81648378,
172.79708193
],
[
142.125,
44.083333,
7.41941051,
9.65287562,
21.4842731,
39.06927363,
68.33335713,
128.86556096,
189.93869276,
260.61004427
],
[
142.125,
44.25,
7.32692943,
9.53255497,
20.76198756,
38.1671093,
66.77537862,
126.6741987,
187.88085011,
258.97254969
],
[
142.125,
44.416667,
7.22287993,
9.39718345,
19.9499626,
37.15473594,
65.45462402,
125.55039712,
187.14524703,
258.54744998
],
[
142.125,
44.583333,
7.14080327,
9.29039925,
19.63495814,
36.71900047,
64.94016234,
125.19514513,
186.97272251,
258.46996297
],
[
142.375,
44.083333,
7.05147727,
9.17418345,
18.4835401,
33.64572447,
60.33593618,
120.43645078,
182.9680382,
255.28770223
],
[
142.375,
44.25,
6.95601273,
9.04998121,
17.93996756,
32.28325653,
57.48244696,
113.81243451,
174.5557238,
246.52408586
],
[
142.375,
44.416667,
6.87416455,
8.94349427,
17.48140502,
31.19826719,
55.47464628,
110.24827026,
170.88951949,
243.24737506
],
[
142.375,
44.583333,
6.78875747,
8.8323771,
17.02937007,
30.44647538,
54.71188838,
109.79581934,
170.70453135,
243.18404703
],
[
142.625,
44.083333,
6.71863912,
8.74115103,
16.04531253,
27.61948503,
47.30899306,
89.93362257,
136.83545631,
195.41909187
],
[
142.625,
44.25,
6.63754099,
8.63563992,
15.55629623,
26.80108998,
45.3227835,
84.24972047,
126.7372666,
181.21699525
],
[
142.625,
44.416667,
6.55809721,
8.53228118,
15.0622471,
26.01726019,
43.80473444,
81.6638559,
123.78719557,
178.27201856
],
[
142.625,
44.583333,
6.47580513,
8.42521672,
14.57298374,
25.47270616,
43.33164843,
81.77852743,
124.36231966,
179.06849173
],
[
142.875,
44.083333,
6.25065497,
8.1322896,
12.98320229,
23.1025476,
39.07805023,
74.23052613,
115.50526451,
171.31792556
],
[
142.875,
44.25,
6.16664782,
8.02299379,
12.3383163,
22.18249038,
37.91977323,
72.6695587,
114.41884903,
170.81174642
],
[
142.875,
44.416667,
6.09193804,
7.92579413,
11.7507464,
21.39713249,
37.034678,
71.91171816,
114.1229416,
170.75735061
],
[
142.875,
44.583333,
6.04424497,
7.863744,
11.38938847,
21.18372237,
37.04040686,
72.15612405,
114.39039419,
170.96712271
],
[
142.125,
44.75,
7.0332101,
9.15041731,
19.18838732,
36.20410369,
64.59202947,
125.12203841,
186.97721305,
258.48790597
],
[
142.125,
44.916667,
7.01591917,
9.12792129,
19.0831461,
36.14459127,
64.6797932,
125.27999518,
187.10443248,
258.58030213
],
[
142.125,
45.083333,
6.82669925,
8.8817405,
18.19965987,
35.28683422,
64.2414311,
125.24184436,
187.14804362,
258.62655114
],
[
142.125,
45.25,
6.54822006,
8.51943072,
16.21136045,
32.36279299,
61.87946418,
124.05711323,
186.56043953,
258.33943182
],
[
142.375,
44.75,
6.70440249,
8.72262874,
16.66878789,
30.28245675,
55.15980052,
111.54806878,
173.18262083,
245.92180815
],
[
142.375,
44.916667,
6.58662658,
8.56939876,
16.08641544,
29.93148818,
55.57035626,
113.79359694,
176.61579106,
249.95507540
],
[
142.375,
45.083333,
6.40711773,
8.33585235,
14.936455,
29.05273632,
55.08033384,
113.93716739,
176.8695267,
250.17821015
],
[
142.375,
45.25,
6.14827262,
7.9990871,
12.66668696,
26.2050847,
52.09026698,
112.30414088,
176.07948923,
249.80170342
],
[
142.625,
44.75,
6.39363224,
8.31830732,
14.12307005,
25.22496557,
43.58864207,
83.52514289,
127.67814269,
183.79209182
],
[
142.625,
44.916667,
6.27683365,
8.16634885,
13.38158445,
24.69262792,
43.52106296,
84.340636,
128.9544736,
185.26554290
],
[
142.625,
45.083333,
6.10165621,
7.93843775,
12.00989216,
23.26651201,
42.3077522,
83.67375531,
128.63370216,
185.13768455
],
[
142.625,
45.25,
5.85743698,
7.62070121,
9.95160973,
19.85511468,
38.28763592,
79.83108334,
125.74980323,
183.09037291
],
[
142.875,
44.75,
5.97107405,
7.76854645,
10.78161011,
20.73441229,
36.86385431,
72.26924147,
114.60035844,
171.15759824
],
[
142.875,
44.916667,
5.85214027,
7.61381004,
9.94261079,
19.7322965,
36.00948722,
71.6807786,
114.31557532,
171.05891038
],
[
142.875,
45.083333,
5.67533675,
7.38378334,
9.6422269,
18.01721548,
33.27704737,
69.01096987,
112.30199106,
169.82627499
],
[
142.875,
45.25,
5.44161685,
7.07970675,
9.2451438,
15.20821734,
27.54245202,
58.59567223,
100.51793922,
159.75625714
],
[
142.125,
45.416667,
6.19776076,
8.06347266,
12.91439982,
25.45295583,
50.42705741,
112.71002679,
177.9147126,
252.02418548
],
[
142.125,
45.583333,
5.79509102,
7.53958724,
9.84568581,
18.15577934,
32.18698548,
65.27396583,
103.12068785,
151.43265001
],
[
142.125,
45.75,
5.34469354,
6.95360661,
9.080474,
13.07607843,
20.3735013,
35.29993313,
49.7262087,
67.52305319
],
[
142.125,
45.916667,
4.85771353,
6.32003102,
8.25310958,
9.71542707,
14.47990605,
22.58818065,
30.55247489,
40.42483141
],
[
142.375,
45.416667,
5.8262003,
7.58006135,
9.89853955,
19.78230971,
40.45520469,
98.62234832,
165.86092392,
242.61167402
],
[
142.375,
45.583333,
5.4563937,
7.09893187,
9.27024923,
15.0035481,
26.52072179,
55.14114354,
90.57124741,
138.38838062
],
[
142.375,
45.75,
5.04073321,
6.55814511,
8.56405452,
10.38603224,
17.57635566,
30.43762832,
44.11243468,
60.63338701
],
[
142.375,
45.916667,
4.58813401,
5.96929998,
7.79510206,
9.17626803,
12.24280613,
19.58882416,
27.26764223,
36.39728391
],
[
142.625,
45.416667,
5.55529574,
7.22760639,
9.43828082,
16.26049959,
29.35407038,
63.3463722,
104.42183149,
159.17913636
],
[
142.625,
45.583333,
5.20768117,
6.77534942,
8.84769411,
12.1555029,
20.45618712,
39.61093532,
61.3196248,
89.38456056
],
[
142.625,
45.75,
4.67279989,
6.07945282,
7.93894685,
9.34559978,
13.78568053,
24.38344532,
35.22193005,
48.53349384
],
[
142.625,
45.916667,
4.26179617,
5.54472465,
7.24066386,
8.52359234,
9.80652082,
16.50454631,
22.87921562,
30.80367459
],
[
142.875,
45.416667,
5.15493692,
6.70672756,
8.75808321,
11.73235269,
20.61865412,
40.85296001,
65.9033325,
102.29343490
],
[
142.875,
45.583333,
4.82254431,
6.2742748,
8.19335812,
9.64508861,
15.55308121,
27.61339158,
40.41958614,
56.96817488
],
[
142.875,
45.75,
4.45347277,
5.79410166,
7.56631665,
8.90694554,
11.10383487,
19.00542914,
26.95699351,
36.57801422
],
[
143.125,
41.583333,
96.82564252,
147.6217036,
268.38748772,
407.350597,
573.38593945,
812.0570181,
1002.44745256,
1201.35455350
],
[
143.125,
41.75,
93.09747492,
138.24909154,
239.59523784,
347.67155407,
472.40448142,
657.09084935,
810.11652347,
973.91762161
],
[
143.125,
41.916667,
90.49887369,
131.60632274,
218.95756386,
310.29588408,
412.15647203,
556.28774478,
672.21947254,
794.44281278
],
[
143.375,
41.583333,
92.77722094,
135.79990174,
230.46856053,
326.51231964,
430.32114847,
574.79686617,
689.88052182,
810.89349956
],
[
143.375,
41.75,
91.81446301,
134.46049715,
229.72444809,
328.13747354,
433.50014232,
577.57666895,
690.66172389,
808.27452242
],
[
143.375,
41.916667,
91.79768189,
133.87985084,
223.32228605,
316.03384084,
417.90305612,
559.17101473,
670.73057867,
786.88608620
],
[
143.625,
41.583333,
94.7780097,
138.1265125,
234.09316387,
338.06088205,
453.87805815,
614.37907789,
740.79008313,
872.34795568
],
[
143.625,
41.75,
95.23707277,
139.28237704,
237.65869164,
350.3082399,
478.70511845,
655.95437056,
794.67208184,
938.42744974
],
[
143.625,
41.916667,
94.4759395,
137.7808729,
229.89006793,
331.12613411,
447.03006872,
608.72383546,
735.9516928,
868.04308627
],
[
143.875,
41.583333,
102.62545004,
150.08484499,
258.76955672,
403.34061014,
573.58897993,
800.85293743,
975.42704558,
1155.06378529
],
[
143.875,
41.75,
103.42311776,
152.36849399,
262.46022348,
397.0844173,
550.43464212,
757.68411374,
918.29120926,
1084.12737279
],
[
143.875,
41.916667,
100.63979939,
148.37702317,
253.55904586,
374.2099857,
510.05560813,
695.63535888,
840.47479837,
990.41113558
],
[
143.125,
42.083333,
87.33013216,
125.69617007,
199.82766204,
272.8383143,
353.90455557,
468.47635962,
560.03595664,
655.80379759
],
[
143.125,
42.25,
82.56025086,
117.49078085,
179.86110157,
238.33691746,
303.52411185,
397.15572448,
472.92198196,
552.85597265
],
[
143.125,
42.416667,
76.57587514,
108.49369713,
163.29952364,
213.45418848,
269.44991092,
351.22432528,
418.70952928,
491.39103088
],
[
143.125,
42.583333,
68.63521046,
97.46753615,
145.96582939,
189.96494051,
239.36654869,
312.14184462,
372.82696969,
438.82117092
],
[
143.375,
42.083333,
88.56258238,
128.17832618,
206.90588738,
286.56069392,
376.3236292,
503.52266002,
605.02836122,
711.27919595
],
[
143.375,
42.25,
82.71738243,
118.86837026,
187.65048904,
256.72113914,
336.06309318,
450.70830725,
543.18959022,
640.36497657
],
[
143.375,
42.416667,
75.53974417,
108.44490597,
169.11639884,
229.03277803,
297.98740096,
398.81730307,
480.82836347,
567.66204203
],
[
143.375,
42.583333,
66.53035689,
96.68099697,
151.83211136,
205.73846721,
267.45813971,
357.67489827,
431.56046798,
510.37960120
],
[
143.625,
42.083333,
89.94886716,
130.90687174,
215.00762513,
305.75072572,
410.42491576,
557.76081079,
674.19401344,
795.15938861
],
[
143.625,
42.25,
82.66801512,
119.86489803,
195.33551959,
277.17058799,
372.59349965,
507.76059052,
614.78208704,
726.13650552
],
[
143.625,
42.416667,
73.85679008,
108.05534735,
177.26786005,
252.31325522,
339.62115282,
463.54659107,
561.9169893,
664.35997422
],
[
143.625,
42.583333,
65.06670279,
96.41764987,
160.58659274,
229.40285075,
308.27737767,
419.8875266,
508.76663859,
601.49362340
],
[
143.875,
42.083333,
95.14808649,
140.18215492,
237.70100389,
346.04639133,
467.87756734,
635.77615858,
767.35445559,
903.77710033
],
[
143.875,
42.25,
86.89401975,
128.13743001,
216.48213909,
314.43730533,
425.38311924,
578.96949366,
699.39805545,
824.56780785
],
[
143.875,
42.416667,
78.19826437,
115.15292859,
193.59754097,
282.42654601,
384.38465273,
525.8801173,
636.84987558,
751.93866127
],
[
143.875,
42.583333,
67.30724502,
100.52932029,
174.7010097,
258.89326577,
353.75145299,
484.39520281,
586.96739375,
693.37510898
],
[
143.125,
42.75,
55.92270337,
80.5188669,
123.49093062,
163.51769667,
209.01128343,
276.29948465,
332.92935128,
395.03824200
],
[
143.125,
42.916667,
45.38007154,
66.19773931,
104.01630148,
140.52370973,
183.02533812,
248.16986144,
305.11777342,
370.19400877
],
[
143.125,
43.083333,
36.78983605,
54.37987341,
87.49691165,
120.28465576,
158.94248225,
219.19278593,
273.30270577,
336.22253941
],
[
143.125,
43.25,
26.87936782,
38.86784717,
60.23297809,
81.96625272,
110.30926784,
163.20535132,
218.19334841,
285.93840786
],
[
143.375,
42.75,
55.03515688,
80.79436173,
130.97669851,
181.732172,
240.23114486,
326.45010361,
398.22204641,
476.50870182
],
[
143.375,
42.916667,
45.82071494,
67.89928746,
111.81221173,
156.80771989,
209.11849768,
287.35271612,
354.33521511,
429.71167119
],
[
143.375,
43.083333,
37.98599466,
56.93192626,
95.16615639,
134.82313631,
181.21675921,
252.04196422,
314.60074754,
388.32583352
],
[
143.375,
43.25,
30.58293676,
47.35884067,
81.91874695,
118.05884787,
160.20325445,
225.177786,
283.70694553,
354.16087554
],
[
143.625,
42.75,
54.48084997,
81.40703835,
139.19893512,
201.58041531,
272.26932677,
371.78960518,
451.12357749,
534.46912783
],
[
143.625,
42.916667,
46.57861129,
70.12775217,
122.03987733,
177.99957567,
241.16194077,
330.53294682,
402.32953573,
478.29586877
],
[
143.625,
43.083333,
39.67554693,
60.44865869,
105.93752118,
154.89705337,
210.56304874,
290.22601614,
355.15679498,
424.73285984
],
[
143.625,
43.25,
35.45652398,
53.96188066,
93.50308869,
135.28656952,
182.84921352,
251.91322543,
309.04183665,
371.16795587
],
[
143.875,
42.75,
58.42672546,
88.38317928,
155.54332351,
231.76000365,
317.55430087,
436.12742499,
529.50495664,
626.54710294
],
[
143.875,
42.916667,
50.4547411,
77.1762885,
137.12506112,
204.71404283,
280.59282916,
385.84377166,
468.9770673,
555.80392227
],
[
143.875,
43.083333,
43.17012225,
66.72160091,
121.171693,
181.43563871,
248.41678917,
341.71365168,
416.06531853,
494.26067668
],
[
143.875,
43.25,
38.60339704,
63.07942121,
115.63885274,
167.80143119,
225.16623227,
306.61184227,
372.74775106,
443.31712151
],
[
143.125,
43.416667,
23.08904923,
33.70426896,
52.83870304,
72.85213272,
99.87756628,
151.82877732,
206.2767203,
272.74705456
],
[
143.125,
43.583333,
14.4333958,
21.21955219,
35.30021807,
50.59121258,
73.25199588,
119.30093986,
169.62374552,
232.78929722
],
[
143.125,
43.75,
8.93693044,
14.25413465,
25.61605509,
39.05727337,
58.62624977,
95.84073615,
134.905405,
185.58458996
],
[
143.125,
43.916667,
7.2326386,
9.40987977,
17.10600315,
26.30546365,
40.50812872,
74.13579264,
115.21892068,
171.09986754
],
[
143.375,
43.416667,
26.96595049,
41.48888566,
72.60614593,
104.9691704,
142.49502136,
199.86185629,
250.96608549,
310.22343384
],
[
143.375,
43.583333,
18.79490328,
28.35442442,
46.50227767,
65.64994407,
90.77033031,
136.47312443,
183.39389575,
242.80435295
],
[
143.375,
43.75,
9.77457133,
16.505765,
28.8434838,
43.32962687,
63.26520009,
100.47015781,
139.30117191,
189.32515106
],
[
143.375,
43.916667,
9.13549461,
14.6071764,
25.42029479,
37.8843296,
55.84367023,
90.69834045,
128.87017695,
179.74806723
],
[
143.625,
43.416667,
27.7165653,
45.32882076,
83.00486477,
120.86948665,
163.27109028,
225.38707666,
277.74399629,
335.93279822
],
[
143.625,
43.583333,
23.84352259,
39.21607631,
72.1908274,
104.19207817,
139.51286777,
190.93253268,
234.27109013,
282.27556171
],
[
143.625,
43.75,
17.18926849,
26.94123815,
45.28709561,
63.76729083,
86.63631626,
124.69067041,
161.01719956,
206.27472222
],
[
143.625,
43.916667,
10.27217805,
17.23291755,
29.48245909,
43.45100238,
62.16952278,
97.27855529,
134.48294733,
183.64648677
],
[
143.875,
43.416667,
36.54863182,
63.57631592,
121.9986301,
176.27662534,
235.98028833,
323.55431923,
397.09474939,
477.36963054
],
[
143.875,
43.583333,
29.05495342,
53.38077364,
102.12211632,
146.6270213,
196.23013425,
270.651051,
334.34697093,
404.93362446
],
[
143.875,
43.75,
20.96238162,
34.41810083,
58.3311776,
81.30658922,
108.65032272,
152.39250772,
192.33117591,
239.35829399
],
[
143.875,
43.916667,
17.48224421,
27.21158502,
45.13333703,
62.99156836,
85.0688729,
121.80009862,
157.2634664,
201.80960636
],
[
143.125,
44.083333,
6.83892091,
8.89764124,
15.44244736,
23.93806494,
37.82702012,
71.02686172,
112.86299615,
169.69769672
],
[
143.125,
44.25,
5.95403465,
7.74637768,
10.57118452,
19.41756404,
34.24897615,
68.80368621,
111.68393123,
169.22083045
],
[
143.125,
44.416667,
5.9036602,
7.680839,
10.15287003,
19.16624151,
33.99459418,
68.74404905,
111.6910147,
169.23419108
],
[
143.125,
44.583333,
5.84390748,
7.60309892,
9.92862351,
18.85870627,
33.69955828,
68.66952447,
111.68993196,
169.24528755
],
[
143.375,
44.083333,
7.30266255,
9.50098303,
17.08739063,
25.81884029,
39.16155381,
71.44676584,
112.94349294,
169.82170505
],
[
143.375,
44.25,
6.79644267,
8.84237578,
15.06879676,
22.98292739,
36.2294714,
68.94311478,
111.61797023,
169.28622875
],
[
143.375,
44.416667,
5.7497665,
7.48061868,
9.76868081,
18.12472599,
32.65753835,
68.03259929,
111.43771413,
169.26792948
],
[
143.375,
44.583333,
5.67389255,
7.3819044,
9.63977325,
17.61589015,
32.09181457,
67.78265259,
111.34277486,
169.24350523
],
[
143.625,
44.083333,
7.96044829,
10.95425591,
19.42686267,
29.07751073,
43.30700232,
74.45768127,
114.08063357,
169.86015708
],
[
143.625,
44.25,
7.20470707,
9.37354001,
16.70326162,
25.19073463,
38.23409356,
69.84910169,
111.66088907,
168.99641055
],
[
143.625,
44.416667,
6.71231841,
8.73292759,
14.66470491,
22.33504543,
35.46839107,
68.3128214,
111.1784571,
168.91210320
],
[
143.625,
44.583333,
5.52731893,
7.19120773,
9.39074907,
16.46748705,
30.75663373,
67.02698157,
110.81349055,
168.81675520
],
[
143.875,
44.083333,
10.37987966,
17.19462898,
29.15568195,
42.58079687,
60.53550447,
94.66102113,
131.3594191,
180.83384369
],
[
143.875,
44.25,
7.81402602,
10.45387605,
18.94145552,
28.352226,
42.04164187,
72.78699897,
112.76187286,
169.16610361
],
[
143.875,
44.416667,
6.97031465,
9.06858844,
15.85995131,
24.13473461,
37.21192763,
69.06654301,
111.24787706,
168.79488880
],
[
143.875,
44.583333,
6.3996243,
8.32610317,
13.15989971,
20.23330714,
33.41622004,
66.82240065,
110.3007196,
168.46996822
],
[
143.125,
44.75,
5.75259513,
7.48429882,
9.77348658,
18.27432096,
33.02114594,
68.31541636,
111.52690866,
169.19022969
],
[
143.125,
44.916667,
5.61274004,
7.30234314,
9.53587696,
17.05216629,
31.16478476,
66.93931133,
110.61736153,
168.75086645
],
[
143.125,
45.083333,
5.42259331,
7.05495656,
9.21282339,
14.90491017,
27.23080579,
60.77816572,
105.3042846,
164.95036568
],
[
143.125,
45.25,
5.18616895,
6.74736137,
8.81114549,
12.08505538,
21.3430697,
45.04180091,
77.20069869,
126.67362866
],
[
143.375,
44.75,
5.55787618,
7.23096362,
9.44266491,
16.63038881,
30.75760906,
66.94619044,
110.87017895,
169.04602964
],
[
143.375,
44.916667,
5.39464707,
7.01859766,
9.16534356,
14.80780283,
27.86288289,
63.59661406,
108.41382673,
167.53910930
],
[
143.375,
45.083333,
5.18980341,
6.75208991,
8.81732032,
12.24829216,
22.53536118,
51.04392702,
92.20978458,
151.77802526
],
[
143.375,
45.25,
4.94646158,
6.43549488,
8.40388985,
9.89292315,
17.601215,
34.8611502,
56.91777151,
89.00338990
],
[
143.625,
44.75,
5.3879761,
7.00991852,
9.15400978,
14.95923291,
28.71065983,
65.21775022,
109.63782576,
168.20924003
],
[
143.625,
44.916667,
5.20485949,
6.77167832,
8.84290015,
12.59214153,
24.2498663,
57.51505285,
102.61801864,
163.03100326
],
[
143.625,
45.083333,
4.98428199,
6.48470038,
8.4681456,
9.96856399,
18.73188356,
40.38764316,
70.6971414,
116.70038383
],
[
143.625,
45.25,
4.72833166,
6.15170132,
8.03329366,
9.45666332,
14.68689447,
27.26601989,
41.92166051,
61.49998739
],
[
143.875,
44.75,
5.08816394,
6.61985391,
8.64463792,
11.40050351,
25.44820793,
61.5929814,
106.85527719,
166.26606130
],
[
143.875,
44.916667,
4.89133059,
6.36376782,
8.31022396,
9.78266119,
19.41177146,
47.13309723,
85.64028186,
142.66817842
],
[
143.875,
45.083333,
4.65315077,
6.05388872,
7.90556358,
9.30630153,
14.74365639,
30.8905438,
51.0092282,
78.91466622
],
[
143.875,
45.25,
4.37570966,
5.69292952,
7.43419946,
8.75141932,
10.39230069,
20.47859136,
31.15608058,
44.65146512
],
[
143.125,
45.416667,
4.90545156,
6.38213962,
8.33421506,
9.81090312,
16.66766182,
30.46426632,
46.88230253,
68.37667002
],
[
143.125,
45.583333,
4.58454808,
5.96463457,
7.78900968,
9.16909616,
12.52972632,
21.32757383,
30.45929923,
42.01004808
],
[
143.375,
45.416667,
4.66522888,
6.06960271,
7.92608393,
9.33045776,
13.59822176,
23.97988068,
35.26613201,
49.62917039
],
[
143.625,
45.416667,
4.43876574,
5.77496738,
7.54132985,
8.87753149,
10.9823749,
19.10105193,
27.4950968,
37.85187365
],
[
144.125,
41.75,
115.59698984,
175.45747447,
311.64012094,
469.21997775,
643.19413199,
878.55433998,
1061.77506733,
1251.14027391
],
[
144.125,
41.916667,
110.61954283,
166.98064447,
294.53733812,
436.61795221,
591.76485805,
802.5919493,
967.2912569,
1138.14031826
],
[
144.375,
41.916667,
121.24262858,
189.35966634,
342.35971919,
505.70919399,
682.21350184,
922.60676637,
1110.73629145,
1305.80877524
],
[
144.125,
42.083333,
104.86867016,
157.12885836,
274.11105451,
401.32474256,
540.34843977,
730.31997488,
879.12836601,
1033.77232876
],
[
144.125,
42.25,
95.28044227,
143.11779509,
249.28179912,
363.84396109,
489.71293333,
662.44884514,
797.88574951,
938.61330250
],
[
144.125,
42.416667,
85.55377391,
128.17729147,
222.01988359,
325.64697615,
441.00490167,
599.61404128,
724.04290514,
853.00058719
],
[
144.125,
42.583333,
75.07441756,
113.12289098,
197.07204395,
291.95485938,
398.56195362,
545.04748545,
659.69706792,
778.57180671
],
[
144.375,
42.083333,
114.83695823,
176.28278283,
313.86324808,
461.29328201,
620.79955633,
838.08237847,
1008.22170782,
1184.78862084
],
[
144.375,
42.25,
106.33736992,
161.77750917,
284.44650666,
416.48210938,
560.42370538,
757.06541895,
911.12937914,
1071.20606642
],
[
144.375,
42.416667,
95.90924016,
145.32044037,
253.36934145,
371.78436454,
502.84889657,
682.4278565,
822.98503504,
968.74037081
],
[
144.375,
42.583333,
83.8576919,
127.04906229,
221.49531293,
328.79732234,
449.58785124,
615.00503517,
744.0776725,
877.80725610
],
[
144.625,
42.083333,
124.38273406,
196.36426337,
354.92493312,
522.9506966,
704.77714281,
953.02267992,
1147.66338611,
1349.43567244
],
[
144.625,
42.25,
116.75271507,
180.20981117,
318.74513465,
470.50035329,
636.72548714,
863.1666671,
1040.30559234,
1223.65072635
],
[
144.625,
42.416667,
105.1061321,
160.71049345,
281.36683777,
417.05589595,
568.25972896,
774.36199714,
935.09804243,
1101.44924582
],
[
144.625,
42.583333,
90.12099882,
138.19485418,
243.48750953,
366.04751242,
504.85208053,
693.65132786,
840.41276439,
992.04812798
],
[
144.875,
42.083333,
120.49594873,
194.37967101,
372.66330538,
563.22119232,
765.2155465,
1039.83509117,
1255.23459003,
1479.18803088
],
[
144.875,
42.25,
122.66390915,
197.34088396,
356.3072913,
525.7905525,
712.87381323,
969.87867647,
1171.37016427,
1380.21049601
],
[
144.875,
42.416667,
110.13671116,
173.17741784,
307.95884188,
462.19587419,
637.16048962,
875.35901858,
1060.63352329,
1251.89756023
],
[
144.875,
42.583333,
91.99395888,
142.77553898,
257.04137112,
396.07465198,
555.95759533,
771.80306588,
938.54346023,
1110.40818102
],
[
144.125,
42.75,
64.65271229,
98.83474681,
176.70956245,
265.65909132,
364.80373202,
500.2968252,
606.26374171,
716.14631576
],
[
144.125,
42.916667,
55.22120118,
85.40646258,
155.17004312,
236.51301279,
327.57563401,
451.99294206,
549.27690245,
650.22374314
],
[
144.125,
43.083333,
48.24806354,
76.1071069,
138.59550995,
209.38762813,
288.73076468,
398.1994257,
484.36626196,
574.24587744
],
[
144.125,
43.25,
46.02987097,
77.69978117,
144.62725548,
207.35841396,
274.60104471,
369.14902345,
445.37111618,
526.41697931
],
[
144.375,
42.75,
70.77941372,
109.49281321,
196.19911809,
296.30147716,
408.48214625,
561.14226942,
680.02336443,
802.92084199
],
[
144.375,
42.916667,
59.69117243,
93.797195,
171.73610233,
263.82498758,
366.92427348,
506.60931761,
615.23232348,
727.55397261
],
[
144.375,
43.083333,
53.37601536,
83.98590334,
151.3823151,
227.24865337,
312.38795303,
429.502389,
521.45476685,
616.86871929
],
[
144.375,
43.25,
54.05618843,
90.58280863,
163.56785412,
230.44514432,
301.85409553,
402.13259109,
482.8890382,
568.60443406
],
[
144.625,
42.75,
75.5911286,
116.77355215,
209.02188127,
319.18045494,
445.73639174,
617.48803881,
750.52561434,
887.91387694
],
[
144.625,
42.916667,
63.62652004,
99.65716877,
180.02597963,
270.51272109,
372.01069477,
511.02639575,
619.56507339,
731.93564718
],
[
144.625,
43.083333,
57.25033641,
89.31276942,
156.6981875,
227.07803174,
305.50197438,
414.74884924,
501.12112331,
591.28321942
],
[
144.625,
43.25,
58.20875743,
94.71629489,
165.86342904,
231.09681087,
301.43639307,
401.35912271,
482.63066383,
569.54601851
],
[
144.875,
42.75,
77.7222887,
119.39512926,
211.07111628,
314.30871305,
432.98641031,
597.00193535,
725.24361867,
857.85067481
],
[
144.875,
42.916667,
67.60263834,
104.38522555,
180.75557238,
258.44359003,
344.84431654,
465.83871002,
561.85451041,
661.93804684
],
[
144.875,
43.083333,
60.49907153,
93.34841489,
157.43545771,
218.69503609,
286.03150391,
381.23454226,
457.73209378,
538.48054627
],
[
144.875,
43.25,
58.33230299,
90.17586693,
147.13999701,
198.25965168,
254.28621003,
334.94719845,
401.19816713,
472.46850874
],
[
144.125,
43.416667,
46.93732716,
89.65118354,
170.59943706,
239.50263631,
313.71488333,
420.50703959,
508.57240981,
602.86581132
],
[
144.125,
43.583333,
41.87977441,
78.6531916,
149.40444209,
213.80988476,
286.04334229,
392.69278023,
481.22187567,
576.57559067
],
[
144.125,
43.75,
30.73516813,
54.65801239,
97.36723046,
134.91238483,
176.36247031,
238.12711756,
291.0732198,
349.95166803
],
[
144.125,
43.916667,
20.8035037,
33.30392627,
55.09139969,
75.96405141,
100.93131494,
141.42359508,
178.98869295,
224.25398948
],
[
144.375,
43.416667,
55.72934885,
101.06552261,
180.76261913,
248.67615336,
321.95140145,
427.77050849,
515.14366069,
608.77356944
],
[
144.375,
43.583333,
52.69997919,
95.73771629,
170.45316271,
236.22842292,
309.10486039,
415.87738575,
504.42712888,
599.46703025
],
[
144.375,
43.75,
39.39875893,
71.5082574,
130.7347758,
187.14385658,
253.58697233,
354.9204097,
440.28426342,
532.64234473
],
[
144.375,
43.916667,
26.48266929,
42.84084352,
71.85827967,
99.22405702,
131.44442951,
182.17500367,
227.53799335,
279.21004643
],
[
144.625,
43.416667,
62.12234269,
105.29661888,
181.26504051,
247.6894824,
320.24043657,
425.84044003,
513.326307,
607.20099080
],
[
144.625,
43.583333,
59.58104208,
101.95920134,
174.6811726,
239.66159163,
312.52303139,
419.87018716,
509.29032321,
605.27837313
],
[
144.625,
43.75,
46.2826814,
80.21627399,
149.84819467,
218.24277749,
295.1434556,
406.34490337,
497.13398607,
593.89623328
],
[
144.625,
43.916667,
34.61239994,
57.545555,
101.02291156,
145.18172733,
199.14105484,
284.2206375,
357.48051868,
437.70724533
],
[
144.875,
43.416667,
60.47328912,
98.19104424,
165.48999285,
227.14549444,
296.8421861,
400.71424647,
487.76286054,
581.96789727
],
[
144.875,
43.583333,
62.54881565,
103.14368906,
173.39578762,
237.87045388,
311.20815809,
420.15889451,
511.24875199,
609.19456908
],
[
144.875,
43.75,
52.64277237,
89.969367,
161.77277691,
230.24018144,
307.59096043,
421.4577042,
516.42118592,
618.90593584
],
[
144.875,
43.916667,
44.05880251,
75.53672083,
141.75347743,
209.40526527,
286.57771837,
398.62961073,
490.1382537,
587.57881228
],
[
144.125,
44.083333,
12.81628848,
20.26725393,
34.88698287,
49.60952096,
69.07740306,
104.01256187,
140.01657977,
187.56039203
],
[
144.125,
44.25,
9.76579347,
16.18519879,
27.57431713,
40.02901314,
57.55240934,
90.76901561,
127.7619548,
178.20225302
],
[
144.125,
44.416667,
7.51016637,
9.77095172,
17.98232201,
27.15159171,
40.54799977,
71.74706248,
112.34308261,
169.14955653
],
[
144.125,
44.583333,
6.70413004,
8.72227427,
14.53935488,
21.9084319,
34.49612402,
66.28340746,
109.36973411,
167.89584723
],
[
144.375,
44.083333,
20.12148015,
31.51972347,
51.31606987,
70.39491119,
93.55453627,
131.34967164,
167.20038156,
211.51991329
],
[
144.375,
44.25,
13.00995525,
20.24434631,
34.68510616,
49.25076286,
68.39307352,
102.6194345,
138.25407804,
185.72730204
],
[
144.375,
44.416667,
9.16161177,
14.6522543,
25.28881838,
37.20555309,
53.92537601,
86.81001232,
124.18950704,
175.78478610
],
[
144.375,
44.583333,
7.07671567,
9.20701935,
16.05981659,
23.97142428,
36.26818126,
65.91983806,
107.17531847,
165.72924949
],
[
144.625,
44.083333,
26.71875067,
41.61023928,
67.33937909,
91.26394821,
119.47031372,
164.38875819,
205.18972555,
252.73531289
],
[
144.625,
44.25,
21.01324122,
32.28348034,
51.77196494,
70.41815772,
92.9584697,
129.70448122,
164.81572668,
208.60625908
],
[
144.625,
44.416667,
11.59369198,
18.70639569,
32.13641554,
46.46672922,
65.24400953,
99.23733872,
135.19402127,
183.25441015
],
[
144.625,
44.583333,
7.45484715,
9.69897976,
17.5858114,
26.08772095,
38.12945436,
64.76922924,
100.39514763,
156.25883788
],
[
144.875,
44.083333,
31.74380403,
53.59833094,
94.74389055,
136.01786103,
185.96656324,
264.04593054,
331.17894894,
404.70152323
],
[
144.875,
44.25,
24.46334348,
38.82683042,
64.26508864,
88.11084237,
116.388353,
161.50196917,
202.67732149,
250.85765442
],
[
144.875,
44.416667,
19.18666815,
29.69678934,
48.56280668,
66.71993632,
88.57933564,
124.79175391,
159.52404501,
203.42580767
],
[
144.875,
44.583333,
9.79884557,
16.37339181,
27.88321178,
40.08325483,
56.33840783,
84.42529586,
112.58001461,
149.57296450
],
[
144.125,
44.75,
4.96914592,
6.4650079,
8.44242987,
9.93829185,
21.81263209,
54.31688597,
98.63289262,
159.48917717
],
[
144.125,
44.916667,
4.75823463,
6.19060598,
8.08409791,
9.51646927,
16.69655548,
37.02915731,
63.89890428,
104.03236980
],
[
144.125,
45.083333,
4.50463563,
5.86066607,
7.65324081,
9.00927125,
12.23021146,
24.54063265,
37.9512382,
55.42249250
],
[
144.375,
44.75,
6.26254326,
8.14775663,
12.07647621,
18.19425244,
27.2171465,
48.40433404,
80.24411742,
132.03389111
],
[
144.375,
44.916667,
4.59680257,
5.98057803,
7.80982968,
9.19360514,
13.81627308,
28.70297119,
46.61198704,
70.54873353
],
[
144.625,
44.75,
6.44870341,
8.38995658,
12.87614429,
18.71550293,
27.11557301,
43.68717898,
63.82180974,
94.88356347
],
[
144.625,
44.916667,
5.69482988,
7.40914449,
9.67534514,
14.28514218,
19.57138711,
29.85909224,
40.45800273,
54.25787380
],
[
144.875,
44.75,
6.59184199,
8.57618416,
13.50553361,
19.30552998,
27.51417098,
41.75187584,
56.15567761,
74.05865525
],
[
144.875,
44.916667,
5.71825529,
7.43962165,
9.71514421,
14.18856883,
19.20771842,
28.31173751,
36.87490915,
47.02896709
],
[
144.875,
45.083333,
5.06032823,
6.58363881,
8.59734587,
10.3476568,
14.73688955,
20.75263723,
26.87999239,
33.78169261
],
[
145.125,
42.083333,
108.73035489,
163.21140704,
272.55525684,
387.96748688,
524.6156403,
723.27919667,
883.18072059,
1051.05370251
],
[
145.125,
42.25,
111.98695178,
181.336808,
343.91290563,
523.57437863,
725.04522137,
1004.080418,
1223.66126054,
1451.81406425
],
[
145.125,
42.416667,
104.40389458,
167.48574628,
315.0102062,
485.64665435,
680.29048555,
946.3384261,
1153.41423216,
1367.10107481
],
[
145.125,
42.583333,
91.68456812,
140.82544663,
250.94320436,
371.4312179,
506.81677319,
694.06916627,
841.05530861,
993.50143200
],
[
145.375,
42.083333,
109.16588704,
163.89797562,
266.82051944,
361.40966979,
463.66326853,
607.33454316,
722.27068912,
842.79056060
],
[
145.375,
42.25,
104.85318124,
161.33433964,
286.88457313,
410.15662334,
541.58068581,
723.23990731,
867.30569203,
1018.17883563
],
[
145.375,
42.416667,
100.44901406,
155.14050923,
280.41921794,
404.9847145,
537.15780871,
719.40908637,
863.8771338,
1015.13583751
],
[
145.375,
42.583333,
94.99984775,
146.43420409,
249.79920321,
344.41531799,
444.61017395,
583.42376118,
693.49009145,
808.68219602
],
[
145.625,
42.083333,
118.01286829,
176.21963275,
277.46307155,
370.99550836,
477.5672716,
637.42568544,
771.61504963,
916.64918043
],
[
145.625,
42.25,
113.00680974,
170.4680421,
281.62676004,
385.99639798,
499.80719249,
661.02045746,
790.6342357,
927.28632474
],
[
145.625,
42.416667,
107.2114398,
163.68448796,
273.82916917,
373.77181067,
479.93788704,
627.71425397,
745.20872127,
868.48220409
],
[
145.625,
42.583333,
100.03974905,
153.21404593,
251.48030018,
337.33190388,
428.23858749,
555.0983778,
656.46804171,
762.99126856
],
[
145.875,
42.25,
122.76818753,
182.17872913,
285.1511867,
382.80229393,
497.27504607,
670.86393995,
815.65854577,
970.62129037
],
[
145.875,
42.416667,
114.50488914,
171.13964669,
273.61005158,
370.18099413,
479.59652023,
639.32923008,
769.48159739,
907.08947404
],
[
145.875,
42.583333,
106.06629282,
159.88022121,
258.41873939,
348.64547101,
447.88715767,
589.88708525,
704.55659382,
825.69397684
],
[
145.125,
42.75,
81.79324974,
124.81594765,
211.29726132,
295.72526316,
388.86061716,
519.9824827,
624.40497315,
733.63840461
],
[
145.125,
42.916667,
73.69663245,
111.88290099,
182.09573664,
245.86050962,
314.94702961,
412.49477286,
490.75282379,
573.17808155
],
[
145.125,
43.083333,
66.62054262,
101.34793772,
162.07465031,
215.30878877,
272.82347041,
354.92074948,
421.85444325,
493.39898696
],
[
145.125,
43.25,
61.49468247,
92.97125644,
145.24938735,
190.39628061,
239.71742045,
311.7570708,
372.0013581,
437.90722984
],
[
145.375,
42.75,
87.79704122,
134.38079053,
218.23896888,
290.63872114,
367.0041374,
473.32047296,
558.15037108,
646.95426654
],
[
145.375,
42.916667,
80.17190218,
121.86606443,
192.19182432,
251.03542452,
312.80276611,
398.85563452,
467.6307674,
539.90246775
],
[
145.375,
43.083333,
72.97700525,
110.65310391,
172.49299811,
223.80657151,
277.93903241,
354.13935151,
415.66158943,
480.92947942
],
[
145.375,
43.25,
66.25003228,
100.5249596,
156.30436933,
203.14846018,
253.57098691,
326.37444438,
386.88106169,
452.76716930
],
[
145.625,
42.75,
93.16748781,
141.90874691,
226.82011835,
298.77305522,
374.869335,
481.44029354,
567.12145332,
657.12946037
],
[
145.625,
42.916667,
85.92752271,
130.03071892,
204.89283293,
267.91430351,
334.65886534,
428.48143547,
503.95847061,
583.66167953
],
[
145.625,
43.083333,
78.45732166,
118.19187497,
184.9103065,
241.71218063,
302.46400066,
388.49779121,
457.96787586,
531.66165783
],
[
145.625,
43.25,
71.07428996,
107.4940759,
168.44749013,
220.95693795,
277.82402025,
359.38474472,
426.15212585,
497.45169227
],
[
145.875,
42.75,
98.63463052,
149.31148546,
241.97370082,
325.1622193,
415.19035928,
542.56256394,
644.85794193,
752.51645285
],
[
145.875,
42.916667,
91.91072768,
139.11979949,
226.12559252,
304.45137575,
389.24075105,
509.14660466,
605.48218889,
707.04651686
],
[
145.875,
43.083333,
84.97189523,
128.18016649,
208.21244662,
281.47278502,
361.77832682,
476.14902401,
568.65473122,
666.16805962
],
[
145.875,
43.25,
73.75727292,
110.99408416,
182.01477627,
247.4670025,
318.66652146,
419.74452911,
501.27409864,
587.43000688
],
[
145.125,
43.416667,
60.52581813,
92.63644107,
144.14258654,
188.94479658,
239.25033602,
315.45254132,
381.14153439,
454.35447832
],
[
145.125,
43.583333,
54.38219264,
87.49689287,
152.51460225,
217.6119204,
292.70585821,
402.90502294,
493.48249425,
590.23698198
],
[
145.125,
43.75,
53.97992599,
90.10068514,
159.93116602,
227.35188612,
303.4413738,
414.42134792,
505.54295292,
602.70684628
],
[
145.125,
43.916667,
47.12958916,
83.71052047,
156.72372605,
225.93204036,
303.08610575,
415.04143557,
506.98795538,
605.19549225
],
[
145.375,
43.416667,
56.98975332,
85.06111877,
132.19801803,
173.90835327,
220.40251312,
289.96446007,
349.34791754,
415.34281383
],
[
145.375,
43.583333,
52.63551447,
79.06818954,
123.43699853,
163.63192335,
210.19865904,
282.36263355,
345.88798918,
417.10047138
],
[
145.375,
43.75,
49.89266804,
76.54640957,
121.39255566,
162.98110242,
211.80705326,
287.47790611,
353.02689498,
425.37087625
],
[
145.375,
43.916667,
43.60155104,
68.65795079,
117.30365329,
168.57533857,
232.32526895,
331.05088602,
414.25626898,
503.98324423
],
[
145.625,
43.416667,
59.67568591,
89.74020887,
142.96056816,
190.38291422,
242.46091097,
317.94818919,
380.41822925,
448.05567255
],
[
145.625,
43.583333,
52.85562658,
78.28528807,
121.45671262,
159.1488749,
200.02280559,
258.46951581,
306.01295075,
356.47065317
],
[
145.625,
43.75,
46.03768493,
67.03120461,
101.31335309,
130.89441856,
162.99482077,
209.07136138,
246.60400119,
286.60704066
],
[
145.625,
43.916667,
41.46434549,
60.64321136,
91.51314765,
118.05722499,
147.04780244,
189.09679715,
223.93694575,
261.38362945
],
[
145.875,
43.416667,
65.36026277,
98.05868704,
158.01074,
212.19089088,
271.03444093,
354.77831096,
422.53927394,
494.29671352
],
[
145.875,
43.583333,
56.83312725,
84.61000605,
133.60735989,
177.19198574,
224.58337685,
292.07826077,
346.72073684,
404.55278745
],
[
145.875,
43.75,
49.28606068,
73.20030343,
114.23159749,
150.37267768,
189.71548505,
246.02527225,
291.73161538,
340.15808852
],
[
145.875,
43.916667,
42.01989851,
61.46075026,
93.9737968,
122.30849824,
153.22231707,
197.69515467,
234.14038108,
272.98090863
],
[
145.125,
44.083333,
38.05359834,
67.91847069,
137.01728062,
207.44728889,
286.09776191,
398.81882709,
490.44201507,
587.88007999
],
[
145.125,
44.25,
26.48549666,
45.74718814,
87.01984074,
131.02964822,
185.05345705,
268.98661829,
340.29828069,
417.91046159
],
[
145.125,
44.416667,
20.5151933,
33.05694376,
55.85409409,
77.92208511,
104.38187955,
147.04604053,
186.53584739,
233.68234545
],
[
145.125,
44.583333,
15.24345081,
23.44223981,
38.83867658,
54.09570711,
72.11010582,
100.18868846,
124.78126487,
152.34393727
],
[
145.375,
44.083333,
36.37315859,
59.34732376,
109.27629575,
163.4995466,
229.70105386,
330.23682288,
414.13325742,
504.29451393
],
[
145.375,
44.25,
25.90848326,
43.68305301,
83.97421002,
133.78387866,
201.34471178,
306.68475701,
393.49892631,
485.72563062
],
[
145.375,
44.416667,
20.91661555,
33.54130283,
57.14172676,
80.93538323,
110.44901767,
159.31912952,
204.609944,
257.13810246
],
[
145.375,
44.583333,
15.13650591,
23.38698676,
39.11032719,
54.81376779,
73.26386491,
101.59529409,
125.80776475,
152.26387786
],
[
145.625,
44.083333,
33.27806216,
48.12220005,
73.25171283,
96.30197786,
122.73495249,
162.76189302,
196.79457801,
234.08774873
],
[
145.625,
44.25,
28.15587452,
41.4918699,
64.72883995,
86.2486066,
111.04639693,
148.79595941,
181.00039128,
216.41688810
],
[
145.625,
44.416667,
18.75156914,
29.32009826,
49.05922885,
68.10530544,
90.25657012,
124.01951915,
152.61087368,
183.81340525
],
[
145.625,
44.583333,
15.78003975,
24.23106404,
40.26936466,
56.61750679,
75.88530852,
105.40623933,
130.39700695,
157.59167635
],
[
145.875,
44.083333,
34.57581543,
49.19383351,
73.72788633,
95.75433629,
120.64645451,
158.05883958,
189.70130887,
224.37663914
],
[
145.875,
44.25,
27.10731951,
38.91533695,
59.7303367,
79.53797056,
102.73749237,
138.19411587,
168.4773843,
201.62364982
],
[
145.875,
44.416667,
23.47376553,
33.97612088,
52.60708092,
70.62986836,
92.12110275,
125.28337848,
153.66603883,
184.71324968
],
[
145.875,
44.583333,
16.41166478,
25.21975967,
42.29107557,
59.66982725,
80.55125132,
112.5365705,
139.53532026,
168.82111854
],
[
145.125,
44.75,
8.20151272,
11.70616244,
20.01785489,
29.28687354,
41.05096928,
60.7134068,
78.54138638,
98.63697809
],
[
145.125,
44.916667,
5.66548258,
7.37096277,
9.62548496,
13.79681522,
18.66200131,
27.12624815,
34.88290626,
43.91102364
],
[
145.125,
45.083333,
4.98885672,
6.49065224,
8.47591793,
9.97771344,
14.20503933,
19.84753322,
25.68629009,
31.94965685
],
[
145.375,
44.75,
8.32547012,
12.10418561,
20.72379679,
30.2083045,
42.75690506,
63.64915481,
82.59705864,
103.98065483
],
[
145.375,
44.916667,
7.55571139,
9.83020716,
17.53513573,
25.49395609,
36.18887673,
54.9226908,
72.24662502,
91.93082995
],
[
145.375,
45.083333,
4.86381838,
6.3279736,
8.26348153,
9.72763675,
13.39231244,
18.90153531,
24.21831905,
29.94642021
],
[
145.375,
45.25,
3.26095191,
4.24259624,
5.54025947,
6.52190381,
7.50354815,
8.80121138,
9.78285572,
13.31523807
],
[
145.625,
44.75,
13.87401693,
20.96418506,
35.61411016,
50.08316146,
67.75584048,
94.7961173,
117.69276697,
142.54611979
],
[
145.625,
44.916667,
7.68662658,
10.00142416,
18.19380963,
26.85240492,
38.53255143,
59.29643109,
78.54088285,
100.20302394
],
[
145.625,
45.083333,
4.6798732,
6.08865541,
7.95096419,
9.3597464,
12.20149587,
17.53619002,
22.14882196,
27.66609003
],
[
145.625,
45.25,
3.08243035,
4.01033435,
5.23695671,
6.1648607,
7.0927647,
8.31938706,
9.24729106,
10.75209723
],
[
145.875,
44.75,
14.8099429,
22.60041344,
38.30981659,
54.41417407,
73.66093633,
103.16862023,
128.09164451,
155.08490587
],
[
145.875,
44.916667,
13.24539149,
20.05134758,
34.75978352,
49.34748948,
67.11521286,
94.2339576,
117.11302275,
141.84902458
],
[
145.875,
45.083333,
7.34120738,
9.551131,
17.10442656,
25.47551598,
37.2415671,
58.27002198,
77.68057583,
99.39432427
],
[
146.125,
42.416667,
120.58022183,
178.6300762,
280.56115683,
378.71666225,
494.41724603,
669.47917536,
814.87682861,
969.97179701
],
[
146.125,
42.583333,
112.62301175,
168.06104627,
273.13204884,
374.25320586,
487.32820192,
648.99604977,
779.33679137,
916.38890621
],
[
146.375,
42.583333,
121.02419436,
180.71321035,
295.48528387,
405.77605553,
528.64578885,
704.41606839,
846.91083601,
997.68116567
],
[
146.625,
42.583333,
129.10762043,
192.15447192,
312.40026407,
430.07391089,
563.54050418,
756.48482121,
913.32862939,
1079.41848607
],
[
146.125,
42.75,
105.39037702,
158.83018773,
267.50335904,
371.70207485,
483.92578049,
640.00465383,
763.96151208,
893.58713260
],
[
146.125,
42.916667,
99.36968638,
150.80589031,
258.70782405,
363.8450247,
477.88246769,
638.31931767,
767.19146967,
903.11820488
],
[
146.125,
43.083333,
89.6698448,
136.67643978,
237.3733442,
336.313415,
444.44420493,
597.20624217,
720.1740715,
849.65814857
],
[
146.125,
43.25,
81.82305565,
123.74433469,
208.23188734,
289.55574786,
379.2246227,
506.74608017,
609.34618936,
717.45188738
],
[
146.375,
42.75,
112.12990384,
170.29309024,
299.6195952,
426.66173008,
561.15037139,
745.76719606,
891.60552739,
1044.05451605
],
[
146.375,
42.916667,
107.50015251,
164.72104765,
294.22648878,
424.27536339,
565.92447836,
765.75910819,
926.97648972,
1097.49325145
],
[
146.375,
43.083333,
101.01533201,
153.93605734,
267.74380803,
382.85590612,
511.49114904,
695.20277428,
843.97973398,
1001.41064277
],
[
146.375,
43.25,
91.77312722,
138.43167914,
234.63456715,
331.92616095,
441.22185131,
596.49626123,
720.9222008,
851.33501141
],
[
146.625,
42.75,
125.72801465,
191.49452859,
326.82597138,
458.64262098,
602.15735486,
802.67392505,
962.26656995,
1129.45145619
],
[
146.625,
42.916667,
120.15790754,
183.34429684,
316.16560513,
448.73732697,
594.15292129,
797.48834759,
959.22418088,
1128.56381925
],
[
146.625,
43.083333,
113.01573889,
170.92504558,
293.74229503,
422.15528947,
567.4263669,
773.63505313,
939.21907213,
1113.76828098
],
[
146.625,
43.25,
102.793127,
154.07667786,
262.04806415,
377.1447318,
507.39006875,
690.81289527,
837.12938349,
990.60115482
],
[
146.875,
42.75,
138.65190352,
210.8085445,
351.13,
490.62109685,
648.83238312,
875.54391061,
1057.66357161,
1248.37306689
],
[
146.875,
42.916667,
130.56952309,
197.92330596,
337.19131407,
478.82004921,
634.12703478,
848.83704169,
1018.27153512,
1194.25846789
],
[
146.875,
43.083333,
122.30762888,
184.27222261,
318.57800413,
460.44516765,
615.09684925,
827.49043542,
994.61205438,
1168.92217062
],
[
146.875,
43.25,
112.81145218,
168.89080383,
292.14942363,
425.58080453,
573.72261339,
780.0099992,
944.15917485,
1116.67988483
],
[
146.125,
43.416667,
72.78031442,
109.09073859,
177.81472454,
241.89014323,
312.48269727,
413.24125715,
494.67628243,
580.82168100
],
[
146.125,
43.583333,
63.3831286,
94.48887229,
150.71390315,
201.97769074,
258.19595924,
338.60063641,
403.75216315,
472.65560100
],
[
146.125,
43.75,
54.73247838,
81.21107702,
128.02997509,
170.02220454,
216.06481881,
281.87516519,
335.30356708,
391.86420513
],
[
146.125,
43.916667,
45.86368596,
67.19320956,
103.59479083,
135.8789851,
171.25711589,
222.21519596,
263.7746348,
307.96864076
],
[
146.375,
43.416667,
81.58014261,
121.99323358,
201.2371438,
279.67558959,
368.1437022,
494.40630004,
595.78500305,
702.14900191
],
[
146.375,
43.583333,
71.19363716,
105.92200016,
170.80085105,
232.85867052,
302.1350068,
401.53791203,
481.76071768,
566.41477978
],
[
146.375,
43.75,
61.28248468,
90.91205481,
144.75454989,
194.70268051,
250.10858453,
329.42730179,
393.57277701,
461.25441287
],
[
146.375,
43.916667,
52.57244748,
77.95663864,
123.21253801,
164.52020941,
210.06149398,
275.14397293,
327.85611,
383.52580887
],
[
146.625,
43.416667,
91.17909116,
135.81020716,
227.84247287,
324.80388776,
434.46993541,
588.38646607,
710.3724279,
837.71244304
],
[
146.625,
43.583333,
79.70091839,
118.24466229,
194.60917622,
272.32551669,
360.08364528,
484.61932625,
584.10039949,
688.07754029
],
[
146.625,
43.75,
68.75492884,
101.81659996,
164.85302728,
226.23229349,
294.87288595,
392.78823474,
471.45425693,
554.14040837
],
[
146.625,
43.916667,
61.78747772,
93.16845917,
148.17072277,
197.31378202,
251.00059927,
327.58539074,
389.59479164,
455.13083516
],
[
146.875,
43.416667,
101.04432484,
150.43769624,
257.4601083,
373.34100178,
502.33242298,
681.56704068,
823.46290329,
971.78812026
],
[
146.875,
43.583333,
92.33981935,
137.16742313,
227.53173195,
321.65595591,
428.20196439,
577.86870946,
696.35858098,
820.10363396
],
[
146.875,
43.75,
80.42547447,
120.85937031,
197.82981905,
272.73263122,
356.73420547,
476.66435919,
573.03760721,
674.00493475
],
[
146.875,
43.916667,
68.4154746,
104.85095999,
171.72759298,
232.2478515,
298.02862897,
391.62563959,
467.11789793,
546.77244029
],
[
146.125,
44.083333,
39.68758124,
58.40078162,
89.89765349,
117.89175908,
148.63945176,
193.1576869,
229.75149444,
268.78700357
],
[
146.125,
44.25,
28.87239424,
41.6531698,
64.12117951,
85.4380158,
110.36084078,
148.65410374,
181.30795863,
217.04155478
],
[
146.125,
44.416667,
25.68311219,
37.06470935,
57.40513973,
77.06322854,
100.25209341,
136.11209869,
166.70516698,
200.09826341
],
[
146.125,
44.583333,
17.26757093,
26.7784474,
45.4682977,
64.50378322,
87.24309362,
121.94218618,
151.17451594,
182.78742831
],
[
146.375,
44.083333,
41.42083998,
61.20570141,
96.91013757,
129.52645941,
165.51876396,
217.13764557,
259.02893121,
303.48949755
],
[
146.375,
44.25,
35.3713302,
52.70727588,
84.08162748,
112.60389817,
144.00714952,
189.16659742,
226.10347189,
265.37261450
],
[
146.375,
44.416667,
28.35297901,
40.96194352,
63.45742004,
84.85096895,
109.86193128,
148.23821871,
180.85600313,
216.48228864
],
[
146.375,
44.583333,
25.09807298,
36.36993543,
56.5970531,
76.21838037,
99.39235861,
135.15094156,
165.56826753,
198.68180860
],
[
146.625,
44.083333,
51.40287288,
79.43651536,
128.65267372,
170.95476786,
216.07106392,
279.55819804,
330.74438254,
384.69935018
],
[
146.625,
44.25,
43.04831657,
66.48235916,
107.58416687,
142.77843024,
180.0911968,
232.55089499,
274.64739781,
319.02196320
],
[
146.625,
44.416667,
34.44005931,
51.50827312,
82.63170723,
110.927339,
142.07466075,
186.82623472,
223.33503617,
262.14661367
],
[
146.625,
44.583333,
27.57222239,
39.82993455,
61.99102992,
83.12041145,
107.87843032,
145.76072362,
177.92973936,
213.04007582
],
[
146.875,
44.083333,
58.66007346,
91.10546227,
149.75449801,
200.57886076,
254.59945244,
330.35231004,
391.13008029,
455.12265831
],
[
146.875,
44.25,
50.11017805,
78.93814676,
130.64433828,
174.63536504,
220.8273506,
285.17550701,
336.53496589,
390.50040262
],
[
146.875,
44.416667,
41.90551856,
65.66757914,
108.62596245,
145.66236063,
184.75521824,
239.33142115,
283.01744431,
328.94821848
],
[
146.875,
44.583333,
36.4333081,
57.23611776,
95.22310136,
127.96131382,
162.60190033,
211.13383347,
250.00715672,
290.95371127
],
[
146.125,
44.75,
15.8085937,
24.3900984,
41.41646956,
58.99819389,
79.97884699,
112.02853183,
138.95187959,
168.03987964
],
[
146.125,
44.916667,
14.30128922,
21.90833414,
37.65493616,
53.71824911,
72.93465358,
102.26651202,
126.95670417,
153.59750624
],
[
146.125,
45.083333,
7.33117865,
9.53808333,
17.59536662,
26.92323151,
39.86055181,
63.11574405,
84.17265651,
107.62954446
],
[
146.125,
45.25,
6.97847104,
9.07920015,
15.97477684,
24.25358901,
36.10537014,
57.00339727,
76.13095401,
97.47227582
],
[
146.375,
44.75,
16.84018829,
26.22013535,
44.83334448,
63.83114788,
86.46971391,
120.81579427,
149.66279292,
180.77722729
],
[
146.375,
44.916667,
15.19542228,
23.61935666,
40.48556829,
57.98769361,
78.70386874,
110.19171764,
136.66681961,
165.17645394
],
[
146.375,
45.083333,
13.65565568,
21.05744887,
36.6732678,
52.37884535,
71.20281648,
99.89448259,
124.0535312,
150.03460292
],
[
146.375,
45.25,
7.21567565,
9.38781045,
17.10037026,
26.13085856,
38.76205013,
61.25310499,
81.76005688,
104.62856436
],
[
146.625,
44.75,
24.23789035,
35.27040329,
55.07885424,
74.3382594,
97.16705743,
132.28224987,
162.16362547,
194.67354066
],
[
146.625,
44.916667,
16.25501582,
25.40234583,
43.59655451,
62.16314587,
84.31165777,
117.85823693,
146.02056227,
176.36640128
],
[
146.625,
45.083333,
14.67995775,
22.76509464,
39.16545431,
56.10965266,
76.19222849,
106.75421517,
132.42939803,
160.11038333
],
[
146.625,
45.25,
13.05235019,
20.05497297,
35.20481844,
50.20036076,
68.41853181,
96.13498146,
119.41381752,
144.60841858
],
[
146.875,
44.75,
26.51697122,
38.38830902,
59.66358199,
80.20118358,
104.43184479,
141.40957373,
172.88780903,
207.21317144
],
[
146.875,
44.916667,
23.1048872,
33.70612167,
52.75432751,
71.34775629,
93.53811119,
127.65759957,
156.73403678,
188.35753168
],
[
146.875,
45.083333,
15.58917053,
24.28509261,
41.63177847,
59.45925664,
80.74904504,
113.14267984,
140.31942763,
169.68548940
],
[
146.875,
45.25,
13.91360012,
21.48406509,
37.27737639,
53.28161519,
72.44599449,
101.72598315,
126.4168426,
153.07692805
],
[
146.625,
45.416667,
7.06266549,
9.18873966,
16.37854349,
24.91993486,
37.03773013,
58.46449303,
78.12050963,
100.05826900
],
[
146.875,
45.416667,
7.24121092,
9.42103261,
17.21771761,
26.31465609,
39.00322679,
61.69170334,
82.43052373,
105.63952849
],
[
146.875,
45.583333,
6.85908852,
8.92387991,
15.38328169,
23.2602262,
34.68776791,
54.84607815,
73.38695165,
94.23105044
],
[
147.125,
42.916667,
138.00673066,
210.03717829,
361.73873746,
517.46508769,
687.99895157,
924.65955314,
1111.65474939,
1306.36186224
],
[
147.125,
43.083333,
129.29494844,
195.74741454,
342.34079845,
494.03933756,
655.69058774,
875.43626091,
1047.60476174,
1225.98459050
],
[
147.125,
43.25,
120.47336871,
181.47766777,
319.42695374,
466.0370526,
623.48230855,
838.60752105,
1007.9447352,
1184.47058658
],
[
147.375,
43.083333,
137.95333305,
209.71647715,
364.43209284,
523.54189252,
695.71894601,
932.98534426,
1119.98082125,
1314.43769312
],
[
147.375,
43.25,
130.48635375,
197.594608,
344.82869746,
497.45728246,
660.14054807,
881.01028523,
1053.94692455,
1233.09710008
],
[
147.125,
43.416667,
113.81633555,
170.12301025,
292.19016867,
423.57526361,
569.38924907,
772.15683509,
933.28318875,
1102.17386382
],
[
147.125,
43.583333,
101.40751129,
152.88800505,
259.36216305,
370.70530317,
494.92601838,
668.30569385,
805.51511221,
948.79586982
],
[
147.125,
43.75,
89.45432941,
136.30265945,
229.48754768,
321.39347304,
423.75454717,
568.07962366,
682.89133008,
802.80199633
],
[
147.125,
43.916667,
77.67592164,
119.79340426,
201.15776253,
276.22933948,
357.85272415,
473.31863484,
566.15927564,
663.66030692
],
[
147.375,
43.416667,
121.78790557,
184.84106824,
321.47910216,
465.59423886,
622.6498997,
838.79654193,
1009.46114209,
1187.56755917
],
[
147.375,
43.583333,
111.60534681,
169.92563489,
292.84865155,
419.94746425,
561.1408288,
758.46466968,
915.47177044,
1080.11040980
],
[
147.375,
43.75,
99.68918962,
153.3035383,
263.11782427,
371.06230834,
489.44265455,
655.22982805,
787.11691749,
925.03759553
],
[
147.375,
43.916667,
87.20407769,
135.64789276,
233.91438556,
325.55073141,
424.12181045,
562.05988517,
672.06204751,
787.29602020
],
[
147.125,
44.083333,
66.56314357,
104.03892152,
175.04096443,
237.49981091,
303.67095003,
396.10108109,
470.0463344,
547.75931190
],
[
147.125,
44.25,
56.76289358,
89.55006969,
151.24081773,
204.28708965,
259.78172729,
336.76833608,
398.03473652,
462.25248935
],
[
147.125,
44.416667,
47.01418367,
73.7239643,
123.88072977,
167.69712086,
213.97466239,
278.31915472,
329.68866515,
383.51815489
],
[
147.125,
44.583333,
40.08910277,
63.54984984,
106.88786152,
144.62647699,
184.4932291,
240.08060702,
284.5443728,
331.22524380
],
[
147.375,
44.083333,
74.91380299,
117.74607484,
203.44008592,
280.01560611,
360.8361931,
473.17233735,
562.82962361,
656.75602897
],
[
147.375,
44.25,
63.7360555,
100.90468875,
173.8772554,
237.61737663,
304.27495785,
396.44922355,
469.7305718,
546.48375998
],
[
147.375,
44.416667,
54.06616172,
85.97466216,
146.98872812,
199.72808812,
254.89975188,
331.22596638,
391.90631329,
455.44457512
],
[
147.375,
44.583333,
44.6794784,
70.12494804,
119.02096573,
162.1428203,
207.81364044,
271.3849713,
322.06947093,
375.28364914
],
[
147.625,
44.083333,
83.14417651,
130.72724764,
229.19731291,
318.04548729,
411.44586705,
540.79554921,
643.6539837,
751.47322190
],
[
147.625,
44.25,
70.89429416,
112.02967776,
194.20991002,
267.16913255,
343.70342177,
449.75885598,
534.30086904,
622.84982238
],
[
147.625,
44.416667,
59.93505784,
95.01879516,
162.5481189,
221.76302222,
283.92580164,
370.0640399,
438.54871697,
510.43207407
],
[
147.625,
44.583333,
49.25081995,
77.24617907,
131.07028393,
179.49540244,
231.08978139,
302.99691008,
360.3706355,
420.57063778
],
[
147.875,
44.25,
77.96951131,
121.43795978,
206.80051558,
282.65612413,
362.49043052,
473.01192989,
560.88621883,
652.68177989
],
[
147.875,
44.416667,
66.42448107,
103.56143142,
174.72271212,
237.94627628,
304.91323959,
398.10155907,
472.40156219,
550.24392445
],
[
147.875,
44.583333,
54.54894103,
84.44825583,
142.39621672,
195.71842469,
253.23601939,
333.96167251,
398.54652995,
466.43036033
],
[
147.125,
44.75,
34.83552831,
54.96026904,
92.33488587,
124.89968517,
159.37342607,
207.68989613,
246.35679405,
287.07309547
],
[
147.125,
44.916667,
25.06870735,
36.38545955,
56.67459407,
76.3249056,
99.50955677,
135.2958633,
165.76212898,
198.96000859
],
[
147.125,
45.083333,
16.36526614,
25.58242184,
43.87126874,
62.55087521,
84.89208632,
118.87781012,
147.53862449,
178.49777579
],
[
147.125,
45.25,
14.64679882,
22.70732136,
39.04594886,
55.9374805,
76.04022005,
106.79485812,
132.75804693,
160.84440596
],
[
147.375,
44.75,
38.04297397,
59.91952244,
101.46810996,
138.01409228,
176.82426331,
231.14383419,
274.56785139,
320.19164921
],
[
147.375,
44.916667,
32.60786408,
51.48147794,
87.08547748,
118.50112305,
152.04183768,
199.15453184,
237.02393625,
276.90417611
],
[
147.375,
45.083333,
23.18845094,
33.76482668,
52.72700152,
71.19241267,
93.23655193,
127.24535818,
156.36374328,
188.16992729
],
[
147.375,
45.25,
15.22538168,
23.67880292,
40.52353264,
58.05801379,
78.95479689,
111.0424049,
138.20589722,
167.64679487
],
[
147.625,
44.75,
41.54036242,
65.35067818,
110.6174207,
151.39885301,
195.04965294,
256.29294776,
305.34215342,
356.89449509
],
[
147.625,
44.916667,
35.33850692,
55.51441053,
94.09220344,
128.95887533,
166.52572168,
219.44629283,
261.98449539,
306.80725711
],
[
147.625,
45.083333,
27.9335942,
42.90764533,
73.64561978,
104.08514855,
137.70526748,
185.13055658,
223.07574443,
262.88973925
],
[
147.625,
45.25,
20.82374524,
30.45897382,
48.02321795,
65.13449464,
85.56690554,
117.39027922,
144.80418664,
174.85166462
],
[
147.875,
44.75,
45.50794104,
70.6394374,
119.62081006,
165.01079043,
214.37447045,
284.0740658,
340.03031439,
398.94805244
],
[
147.875,
44.916667,
37.95108176,
59.2775989,
100.96481435,
139.90464445,
182.52908053,
242.95655302,
291.56087285,
342.67418848
],
[
147.875,
45.083333,
29.6016092,
45.84777969,
79.3561038,
113.82537379,
152.14825654,
206.11996707,
249.11765485,
294.12783256
],
[
147.875,
45.25,
25.36006738,
38.86624517,
68.31621689,
98.56067093,
132.13094217,
179.23088044,
216.77410151,
256.06339062
],
[
147.125,
45.416667,
12.87889946,
19.84565284,
34.75647672,
49.59561159,
67.69062369,
95.36924769,
118.75602264,
144.14498907
],
[
147.125,
45.583333,
6.98888051,
9.09274318,
16.02269347,
24.31740203,
36.16785788,
57.1736855,
76.57338306,
98.39043564
],
[
147.375,
45.416667,
13.40901041,
20.6504308,
36.02928633,
51.45253891,
70.14768046,
99.01063843,
123.49837336,
150.02683044
],
[
147.375,
45.583333,
11.56746297,
18.41903015,
31.6322321,
45.49906746,
62.11408415,
87.90446697,
109.82238681,
133.72491133
],
[
147.375,
45.75,
6.68814528,
8.70147762,
14.51864892,
21.83759235,
32.69731201,
51.92263699,
69.79425726,
90.11045046
],
[
147.625,
45.416667,
13.75524532,
21.24183817,
36.88089282,
52.75740581,
72.00444775,
101.81358051,
127.21896322,
154.86366054
],
[
147.625,
45.583333,
11.86901992,
18.75521703,
32.37245648,
46.51981227,
63.64150155,
90.2344548,
113.05055812,
137.87564751
],
[
147.625,
45.75,
6.7280471,
8.75339109,
14.73208917,
22.2032626,
33.22455672,
52.84639058,
71.19908575,
92.18042718
],
[
147.625,
45.916667,
6.35281638,
8.26520467,
12.72723506,
19.30217201,
28.97446346,
46.40194984,
62.66123007,
81.27509731
],
[
147.875,
45.416667,
13.8770425,
21.47502025,
37.2260741,
53.33847177,
72.94810062,
103.50709662,
129.63633919,
158.21672182
],
[
147.875,
45.583333,
11.96156935,
18.87174203,
32.65335829,
46.95846968,
64.40693049,
91.67359328,
115.1457812,
140.76217280
],
[
147.875,
45.75,
10.05618801,
16.79543298,
28.57331307,
41.13435451,
56.68038633,
80.91335247,
101.85155057,
124.78860291
],
[
147.875,
45.916667,
6.34428185,
8.25410099,
12.6861697,
19.27382184,
28.95581771,
46.49539877,
62.97823489,
81.95367791
],
[
148.125,
44.416667,
71.27418474,
108.35794069,
179.54478228,
246.19150349,
318.7779658,
421.22528491,
503.3178329,
589.54893364
],
[
148.125,
44.583333,
59.70016761,
91.40636066,
152.73514662,
211.09297959,
275.31627447,
366.43350925,
439.51539535,
516.48535872
],
[
148.375,
44.583333,
68.04601314,
103.23784307,
169.04569694,
232.65778265,
304.19797525,
406.7376117,
489.12683507,
575.72090118
],
[
148.625,
44.583333,
72.64094051,
109.96155857,
182.86938861,
255.83627784,
338.26653832,
455.35610967,
548.74427494,
646.39628036
],
[
148.125,
44.75,
49.3135276,
76.11981474,
128.50431748,
179.34328598,
235.99143249,
316.53869294,
381.18953849,
449.13082231
],
[
148.125,
44.916667,
40.49376883,
63.09057221,
107.83411629,
151.90410532,
201.26412897,
271.55499043,
327.89525253,
387.02313688
],
[
148.125,
45.083333,
31.5173759,
48.51503082,
85.46252007,
124.91271573,
169.30006089,
231.54732973,
280.86380107,
332.43331926
],
[
148.125,
45.25,
26.4860914,
40.61448512,
72.76646718,
107.2754454,
145.92036956,
199.8598609,
242.6303381,
287.28619902
],
[
148.375,
44.75,
56.63022574,
87.69293888,
147.09639571,
204.14928457,
267.85368252,
358.72353651,
431.76000311,
508.49482154
],
[
148.375,
44.916667,
44.22906881,
69.80649955,
124.30512121,
177.1832484,
234.73697972,
315.30188057,
379.52489127,
446.87749593
],
[
148.375,
45.083333,
36.42286959,
58.83829992,
108.94564089,
156.83350485,
207.70313208,
278.03925842,
333.91374212,
392.36809419
],
[
148.375,
45.25,
29.93905266,
49.80910475,
95.94204495,
139.22334791,
184.34744065,
246.23368011,
295.14908895,
346.26374794
],
[
148.625,
44.75,
57.72499575,
89.85883431,
157.69764379,
225.11786884,
299.08194584,
402.65556902,
484.99211366,
571.19006087
],
[
148.625,
44.916667,
46.83712617,
75.07349406,
138.40118648,
200.79285876,
267.52521091,
359.69353905,
432.73517751,
509.09671922
],
[
148.625,
45.083333,
37.96934328,
62.44339533,
121.44034712,
178.90300659,
238.82663446,
320.67732722,
385.25315105,
452.60410272
],
[
148.625,
45.25,
31.04557668,
52.32394732,
106.57832343,
158.74091332,
212.13282478,
284.4878927,
341.37705207,
400.67147046
],
[
148.875,
44.75,
59.97538809,
95.44909797,
174.1693318,
252.93882283,
337.69739855,
454.85857242,
547.49105592,
644.13777059
],
[
148.875,
44.916667,
48.32405367,
78.92202615,
153.53084747,
227.28734528,
304.06897078,
408.5510915,
490.71334864,
576.41413579
],
[
148.875,
45.083333,
38.83295116,
65.21242034,
135.46607433,
204.68095681,
274.8533057,
369.27624391,
443.21872516,
520.27728044
],
[
148.875,
45.25,
31.68115675,
54.19888672,
118.90718964,
182.21718874,
245.29478937,
329.73938052,
395.78308845,
464.45705451
],
[
148.125,
45.416667,
22.16988545,
34.62886685,
62.35293514,
92.61897023,
126.36888405,
173.33611192,
210.56082611,
249.37583507
],
[
148.125,
45.583333,
11.81148367,
18.73132124,
32.39687211,
46.7083261,
64.2404814,
91.84240287,
115.72701006,
141.89904047
],
[
148.125,
45.75,
9.95698068,
16.64645915,
28.35809445,
40.85517257,
56.47023868,
80.93315212,
102.18554618,
125.53372393
],
[
148.125,
45.916667,
9.17588374,
14.61515516,
24.93511221,
35.92707647,
49.46997265,
71.17314947,
89.95534429,
110.66674824
],
[
148.375,
45.416667,
25.66733654,
42.74465431,
84.64562092,
123.67646287,
163.83293246,
218.594526,
261.81639187,
306.96631783
],
[
148.375,
45.583333,
19.00593198,
29.66281744,
55.92792958,
86.35638781,
120.52169963,
167.50824416,
204.44081506,
242.82175248
],
[
148.375,
45.75,
9.78174751,
16.22505161,
27.6792332,
39.83212836,
55.26880722,
79.50471592,
100.66633862,
124.02360207
],
[
148.375,
45.916667,
9.03092327,
14.21906341,
24.29921224,
35.08613953,
48.45766941,
69.86558344,
88.59440847,
109.21390618
],
[
148.625,
45.416667,
26.24176748,
44.41143033,
93.4990016,
140.28802046,
187.57758214,
251.46530285,
301.62129913,
353.93274016
],
[
148.625,
45.583333,
22.04367949,
37.92606836,
81.94232843,
123.52653823,
165.2445964,
221.49503794,
265.72046789,
311.80437415
],
[
148.625,
45.75,
16.46522354,
29.68512188,
71.0482016,
108.25929236,
145.06240505,
194.54766228,
233.45471483,
273.98587010
],
[
148.625,
45.916667,
6.047972,
7.86859299,
10.98515644,
17.49967334,
26.09395724,
41.88776686,
57.31463211,
75.30774125
],
[
148.875,
45.416667,
26.56737359,
45.63446585,
103.76883907,
160.17540868,
215.85414458,
290.29101446,
348.52323816,
409.09327806
],
[
148.875,
45.583333,
22.3050188,
38.66755822,
90.07639626,
139.45813343,
188.00472949,
252.9304705,
303.74558734,
356.64210077
],
[
148.875,
45.75,
16.75148907,
30.38473232,
77.40124815,
120.48227885,
162.49920122,
218.66849463,
262.69780147,
308.57441577
],
[
148.875,
45.916667,
8.44841441,
13.51528911,
31.75299273,
66.90497648,
105.93968037,
156.23260513,
194.89025712,
234.88802785
],
[
149.125,
44.916667,
48.5361146,
81.18645875,
170.07977572,
257.88283624,
346.35834042,
464.97091352,
557.7542949,
654.06695244
],
[
149.125,
45.083333,
39.03434559,
66.87146525,
150.87602554,
233.26697085,
314.0756545,
421.39056057,
505.06529041,
591.87309858
],
[
149.125,
45.25,
31.9342191,
55.50672135,
132.81031561,
208.42826114,
281.61310259,
378.52915672,
454.05589833,
532.56475417
],
[
149.375,
45.083333,
38.87756514,
67.94754716,
167.41175508,
263.04464491,
354.42467325,
474.96268789,
568.78978932,
665.96885818
],
[
149.375,
45.25,
32.01073999,
56.4964792,
146.07915566,
231.8778194,
313.09896469,
420.03756131,
503.22804192,
589.53487246
],
[
149.125,
45.416667,
26.75060715,
46.57080505,
115.05700648,
181.82115301,
246.13545129,
331.39182504,
397.86507126,
466.94664613
],
[
149.125,
45.583333,
22.49979943,
39.28421701,
98.60355745,
155.84023151,
211.05681501,
284.40345873,
341.68722127,
401.26872509
],
[
149.125,
45.75,
13.74177569,
26.2534696,
81.12818345,
131.89906364,
179.59509104,
242.72161829,
292.06332555,
343.38495291
],
[
149.125,
45.916667,
9.80728961,
19.65525424,
67.98892656,
112.15102989,
153.30854015,
207.82658188,
250.48137707,
294.92367131
],
[
149.375,
45.416667,
26.94872495,
47.51296766,
125.5632218,
200.42981543,
271.2984376,
364.85189116,
437.71701914,
513.51599683
],
[
149.375,
45.583333,
19.87483209,
36.58224243,
104.96540238,
170.1360018,
231.34155497,
312.27142336,
375.44829752,
441.16730035
],
[
149.375,
45.75,
13.71835567,
26.59303319,
87.64855022,
143.82992462,
196.46177037,
266.29000752,
320.95876833,
378.00502580
],
[
149.375,
45.916667,
11.25890151,
22.51025502,
74.22484694,
122.1264362,
167.39521161,
227.81599813,
275.30547278,
324.96421658
]
]
|> Enum.sort_by(fn [mesh_longitude, mesh_latitude | _] ->
:math.pow(longitude - mesh_longitude, 2) + :math.pow(latitude - mesh_latitude, 2) * 0.444
end)
|> Stream.take(4)
|> Enum.map_reduce(0, fn [x, y | accelerations], acc ->
effectiveness =
:math.pow(:math.pow(longitude - x, 2) + :math.pow(latitude - y, 2) * 0.444, -0.5)
{[effectiveness | accelerations], acc + effectiveness}
end)
{base_period, dt} =
cond do
recurrence_period >= 1000 -> {1000, :math.log(2000 / 1000)}
recurrence_period >= 500 -> {500, :math.log(1000 / 500)}
recurrence_period >= 200 -> {200, :math.log(500 / 200)}
recurrence_period >= 100 -> {100, :math.log(200 / 100)}
recurrence_period >= 50 -> {50, :math.log(100 / 50)}
recurrence_period >= 20 -> {20, :math.log(50 / 20)}
recurrence_period > 0 -> {10, :math.log(20 / 10)}
end
[base_acceleration, da] =
values
|> Stream.map(fn [effectiveness | accelerations] ->
cond do
recurrence_period >= 1000 -> Enum.slice(accelerations, 6, 2)
recurrence_period >= 500 -> Enum.slice(accelerations, 5, 2)
recurrence_period >= 200 -> Enum.slice(accelerations, 4, 2)
recurrence_period >= 100 -> Enum.slice(accelerations, 3, 2)
recurrence_period >= 50 -> Enum.slice(accelerations, 2, 2)
recurrence_period >= 20 -> Enum.slice(accelerations, 1, 2)
recurrence_period > 0 -> Enum.slice(accelerations, 0, 2)
end
|> Stream.map(&(0.01 * effectiveness * &1))
end)
|> Enum.reduce(fn value1, value2 ->
Stream.zip(value1, value2) |> Stream.map(fn {a1, a2} -> a1 + a2 end)
end)
|> Stream.map(&(&1 / sum_of_effectiveness))
|> Enum.scan(&(&1 - &2))
base_acceleration + da / dt * :math.log(recurrence_period / base_period)
end
end | lib/structex/load/seismic.ex | 0.947113 | 0.77053 | seismic.ex | starcoder |
defmodule Aecore.Tx.Transaction do
@moduledoc """
Behaviour that states all the necessary functions that every custom transaction,
child tx of DataTx should implement to work correctly on the blockchain
"""
alias Aecore.Tx.DataTx
@typedoc "Arbitrary map holding all the specific elements required
by the specified transaction type"
@type payload :: map()
@typedoc "Structure of a custom transaction"
@type tx_types ::
Aecore.Account.Tx.SpendTx.t()
| Aecore.Oracle.Tx.OracleExtendTx.t()
| Aecore.Oracle.Tx.OracleRegistrationTx.t()
| Aecore.Oracle.Tx.OracleResponseTx.t()
| Aecore.Oracle.Tx.OracleResponseTx.t()
| Aecore.Naming.Tx.NamePreClaimTx.t()
| Aecore.Naming.Tx.NameClaimTx.t()
| Aecore.Naming.Tx.NameUpdateTx.t()
| Aecore.Naming.Tx.NameTransferTx.t()
| Aecore.Naming.Tx.NameRevokeTx.t()
| Aecore.Channel.Tx.ChannelCreateTx.t()
| Aecore.Channel.Tx.ChannelCloseMutalTx.t()
| Aecore.Channel.Tx.ChannelCloseSoloTx.t()
| Aecore.Channel.Tx.ChannelSlashTx.t()
| Aecore.Channel.Tx.ChannelSettleTx.t()
@typedoc "Reason for the error"
@type reason :: String.t()
@typedoc "Structure that holds specific transaction info in the chainstate"
@type tx_type_state() :: map()
# Callbacks
@doc "The name for state chain entry to be passed for processing"
@callback get_chain_state_name() :: Chainstate.chain_state_types()
@callback init(payload()) :: tx_types()
@callback validate(tx_types(), DataTx.t()) :: :ok | {:error, reason()}
@doc """
Default function for executing a given transaction type.
Make necessary changes to the account_state and tx_type_state of
the transaction (Transaction type-specific chainstate)
"""
@callback process_chainstate(
Chainstate.accounts(),
tx_type_state(),
block_height :: non_neg_integer(),
tx_types(),
DataTx.t()
) :: {:ok, {Chainstate.accounts(), tx_type_state()}} | {:error, reason()}
@doc """
Default preprocess_check implementation for deduction of the fee.
You may add as many as you need additional checks
depending on your transaction specifications.
# Example
def preprocess_check(tx, account_state, fee, nonce, %{} = tx_type_state) do
cond do
account_state.balance - (tx.amount + fee) < 0 ->
{:error, "Negative balance"}
account_state.nonce >= nonce ->
{:error, "Nonce too small"}
1-st_additional_check_required_by_your_tx_functionality ->
{:error, reason}
. . .
n-th_additional_checks_required_by_your_tx_functionality ->
{:error, reason}
true ->
:ok
end
"""
@callback preprocess_check(
Chainstate.accounts(),
tx_type_state(),
block_height :: non_neg_integer(),
tx_types(),
DataTx.t()
) :: :ok | {:error, reason}
@callback deduct_fee(
Chainstate.accounts(),
non_neg_integer(),
tx_types(),
DataTx.t(),
non_neg_integer()
) :: Chainstate.accounts()
end | apps/aecore/lib/aecore/tx/transaction.ex | 0.860325 | 0.432123 | transaction.ex | starcoder |
defmodule PlugCheckup.Options do
@moduledoc """
Defines the options which can be given to initialize PlugCheckup.
"""
defstruct json_encoder: nil,
timeout: :timer.seconds(1),
checks: [],
error_code: 500,
pretty: true,
time_unit: :microsecond
@type t :: %__MODULE__{
json_encoder: module(),
timeout: pos_integer(),
checks: list(PlugCheckup.Check.t()),
error_code: pos_integer(),
pretty: boolean(),
time_unit: :second | :millisecond | :microsecond
}
@spec new(keyword()) :: __MODULE__.t()
def new(opts \\ []) do
default = %__MODULE__{}
Map.merge(default, fields_to_change(opts))
end
defp fields_to_change(opts) do
opts
|> Keyword.take([:json_encoder, :timeout, :checks, :error_code, :pretty, :time_unit])
|> Enum.into(Map.new())
|> validate!()
end
defp validate!(fields) do
validate_optional(fields, :timeout, &validate_timeout!/1)
validate_optional(fields, :checks, &validate_checks!/1)
validate_optional(fields, :error_code, &validate_error_code!/1)
validate_optional(fields, :pretty, &validate_pretty!/1)
validate_optional(fields, :time_unit, &validate_time_unit!/1)
validate_required(fields, :json_encoder, &validate_json_encoder!/1)
fields
end
defp validate_optional(fields, key, validator) do
if Map.has_key?(fields, key) do
value = fields[key]
validator.(value)
end
end
defp validate_required(fields, key, validator) do
if Map.has_key?(fields, key) do
value = fields[key]
validator.(value)
else
raise ArgumentError, message: "PlugCheckup expects a #{inspect(key)} configuration"
end
end
defp validate_error_code!(error_code) do
if !is_integer(error_code) || error_code <= 0 do
raise ArgumentError, message: "error_code should be a positive integer"
end
end
defp validate_timeout!(timeout) do
if !is_integer(timeout) || timeout <= 0 do
raise ArgumentError, message: "timeout should be a positive integer"
end
end
defp validate_checks!(checks) do
not_a_check? = &(!match?(%{__struct__: PlugCheckup.Check}, &1))
if Enum.any?(checks, not_a_check?) do
raise ArgumentError, message: "checks should be a list of PlugCheckup.Check"
end
end
defp validate_pretty!(pretty) do
if pretty not in [true, false] do
raise ArgumentError, message: "pretty should be a boolean"
end
end
defp validate_time_unit!(time_unit) do
possible_values = ~w(second millisecond microsecond)a
if time_unit not in possible_values do
raise ArgumentError, message: "time_unit should be one of #{inspect(possible_values)}"
end
end
defp validate_json_encoder!(encoder) do
unless Code.ensure_compiled?(encoder) do
raise ArgumentError,
"invalid :json_encoder option. The module #{inspect(encoder)} is not " <>
"loaded and could not be found"
end
unless function_exported?(encoder, :encode!, 2) do
raise ArgumentError,
"invalid :json_encoder option. The module #{inspect(encoder)} must " <>
"implement encode!/2"
end
end
end | lib/plug_checkup/options.ex | 0.847463 | 0.407805 | options.ex | starcoder |
defmodule ChangesetHelpers do
@moduledoc ~S"""
Provides a set of helpers to work with Changesets.
"""
@doc ~S"""
Validates the result of the comparison of
* two fields (where at least one is a change) or
* a change and a value, where the value is an integer, a `Date`, a `Time`,
a `DateTime` or a `NaiveDateTime`.
## Options
* `:error_on_field` - specifies on which field to add the error, defaults to the first field
* `:message` - a customized message on failure
"""
def validate_comparison(changeset, field1, operator, field2_or_value, opts \\ [])
def validate_comparison(%Ecto.Changeset{} = changeset, field1, operator, field2, opts) when is_atom(field2) do
error_on_field = Keyword.get(opts, :error_on_field, field1)
operator = operator_abbr(operator)
validate_changes changeset, [field1, field2], :comparison, fn [{_, value1}, {_, value2}] ->
if value1 == nil || value2 == nil do
[]
else
valid? =
case compare(value1, value2) do
:eq ->
operator in [:eq, :ge, :le]
:lt ->
operator in [:ne, :lt, :le]
:gt ->
operator in [:ne, :gt, :ge]
end
message =
if error_on_field == field1 do
Keyword.get(opts, :message, comparison_error_message(operator, value2))
else
reverse_operator =
case operator do
:lt -> :gt
:gt -> :lt
:le -> :ge
:ge -> :le
_ -> operator
end
Keyword.get(opts, :message, comparison_error_message(reverse_operator, value1))
end
if valid?,
do: [],
else: [{error_on_field, {message, [validation: :comparison]}}]
end
end
end
def validate_comparison(%Ecto.Changeset{} = changeset, field, operator, value, opts) do
operator = operator_abbr(operator)
Ecto.Changeset.validate_change changeset, field, :comparison, fn _, field_value ->
valid? =
case compare(field_value, value) do
:eq ->
operator in [:eq, :ge, :le]
:lt ->
operator in [:ne, :lt, :le]
:gt ->
operator in [:ne, :gt, :ge]
end
message = Keyword.get(opts, :message, comparison_error_message(operator, value))
if valid?,
do: [],
else: [{field, {message, [validation: :comparison]}}]
end
end
defp operator_abbr(:eq), do: :eq
defp operator_abbr(:ne), do: :ne
defp operator_abbr(:gt), do: :gt
defp operator_abbr(:ge), do: :ge
defp operator_abbr(:lt), do: :lt
defp operator_abbr(:le), do: :le
defp operator_abbr(:equal_to), do: :eq
defp operator_abbr(:not_equal_to), do: :ne
defp operator_abbr(:greater_than), do: :gt
defp operator_abbr(:greater_than_or_equal_to), do: :ge
defp operator_abbr(:less_than), do: :lt
defp operator_abbr(:less_than_or_equal_to), do: :le
defp comparison_error_message(:eq, value), do: "must be equal to #{to_string value}"
defp comparison_error_message(:ne, value), do: "must be not equal to #{to_string value}"
defp comparison_error_message(:gt, value), do: "must be greater than #{to_string value}"
defp comparison_error_message(:ge, value), do: "must be greater than or equal to #{to_string value}"
defp comparison_error_message(:lt, value), do: "must be less than #{to_string value}"
defp comparison_error_message(:le, value), do: "must be less than or equal to #{to_string value}"
defp compare(%Time{} = time1, %Time{} = time2), do: Time.compare(time1, time2)
defp compare(%Date{} = date1, %Date{} = date2), do: Date.compare(date1, date2)
defp compare(%DateTime{} = dt1, %DateTime{} = dt2), do: DateTime.compare(dt1, dt2)
defp compare(%NaiveDateTime{} = dt1, %NaiveDateTime{} = dt2), do: NaiveDateTime.compare(dt1, dt2)
defp compare(number1, number2) when is_number(number1) and is_number(number2) do
cond do
number1 == number2 -> :eq
number1 < number2 -> :lt
true -> :gt
end
end
@doc ~S"""
Validates a list of values using the given validator.
```elixir
changeset =
%Appointment{}
|> Appointment.changeset(%{days_of_week: [1, 3, 8]})
|> validate_list(:days_of_week, &Ecto.Changeset.validate_inclusion/3, [1..7])
assert [days_of_week: {"is invalid", [validation: :list, index: 2, validator: :validate_inclusion]}] = changeset.errors
assert [days_of_week: {:list, [validator: :validate_inclusion]}] = changeset.validations
```
"""
def validate_list(changeset, field, validation_fun, validation_fun_args) do
{validation_fun, validation_fun_name} =
if is_atom(validation_fun) do
{capture_function(validation_fun, length(validation_fun_args) + 2), validation_fun}
# + 2 because we must pass the changeset and the field name
else
{:name, validation_fun_name} = Function.info(validation_fun, :name)
{validation_fun, validation_fun_name}
end
values = Ecto.Changeset.get_change(changeset, field)
changeset =
if values == nil || values == [] do
changeset
else
ecto_type = type(hd(values))
{errors, index} =
Enum.reduce_while(values, {[], -1}, fn value, {_errors, index} ->
data = %{}
types = %{field => ecto_type}
params = %{field => value}
changeset = Ecto.Changeset.cast({data, types}, params, Map.keys(types))
changeset = apply(validation_fun, [changeset, field | validation_fun_args])
if match?(%Ecto.Changeset{valid?: false}, changeset) do
{:halt, {changeset.errors, index + 1}}
else
{:cont, {[], index + 1}}
end
end)
case errors do
[] ->
changeset
[{_field, {message, _meta}}] ->
Ecto.Changeset.add_error(changeset, field, message, validation: :list, index: index, validator: validation_fun_name)
end
end
%{changeset | validations: [{field, {:list, validator: validation_fun_name}} | changeset.validations]}
end
defp capture_function(fun_name, args_count), do: Function.capture(Ecto.Changeset, fun_name, args_count)
defp type(%Time{}), do: :time
defp type(%Date{}), do: :date
defp type(%DateTime{}), do: :utc_datetime
defp type(%NaiveDateTime{}), do: :naive_datetime
defp type(integer) when is_integer(integer), do: :integer
defp type(float) when is_float(float), do: :float
defp type(string) when is_binary(string), do: :string
@doc ~S"""
Works like `Ecto.Changeset.validate_change/3` but may receive multiple fields.
The `validator` function receives as argument a keyword list, where the keys are the field
names and the values are the change for this field, or the data.any()
If one of the fields is `nil`, the `validator` function is not invoked.
"""
def validate_changes(changeset, fields, meta, validator) when is_list(fields) do
fields_values = Enum.map(fields, &{&1, Ecto.Changeset.fetch_field!(changeset, &1)})
changeset =
cond do
# none of the values are nil
Enum.all?(fields_values, fn {_, value} -> value != nil end) ->
errors = validator.(fields_values)
if errors do
Enum.reduce(errors, changeset, fn
{field, {msg, meta}}, changeset ->
Ecto.Changeset.add_error(changeset, field, msg, meta)
{field, msg}, changeset ->
Ecto.Changeset.add_error(changeset, field, msg)
end)
else
changeset
end
true ->
changeset
end
validations = Enum.map(fields, &{&1, meta})
%{changeset | validations: validations ++ changeset.validations}
end
@doc ~S"""
Raises if one of the given field has an invalid value.
"""
def raise_if_invalid_fields(changeset, keys_validations) do
unless Keyword.keyword?(keys_validations) do
raise ArgumentError, message: "`raise_if_invalid_fields/2` expects a keyword list as its second argument"
end
ensure_fields_exist!(changeset, keys_validations)
ensure_validations_exist!(changeset, keys_validations)
# `keys_validations` may be passed in different formats:
# * email: [:required, :length]
# * email: :required, email: :length
keys_validations =
keys_validations
# flatten to: email: :required, email: :length
|> Enum.map(fn {key, validations} ->
Enum.map(List.wrap(validations), &({key, &1}))
end)
|> List.flatten()
# filter out duplicates
|> Enum.uniq()
# regroup to: email: [:required, :length]
|> Enum.group_by(fn {field, _} -> field end)
|> Enum.map(fn {field, validations} -> {field, Keyword.values(validations)} end)
do_raise_if_invalid_fields(changeset, keys_validations)
end
def do_raise_if_invalid_fields(%Ecto.Changeset{valid?: false, errors: errors} = changeset, keys_validations) do
errors
|> Enum.reverse()
|> Enum.find_value(fn {key, {_message, meta}} ->
if validations = keys_validations[key] do
if validation = Enum.find(List.wrap(validations), &(&1 == meta[:validation])) do
{key, validation, meta[:raise]}
end
end
end)
|> case do
{key, validation, nil} ->
value = Ecto.Changeset.fetch_field!(changeset, key)
raise "Field `#{inspect key}` was provided an invalid value `#{inspect value}`. " <>
"The changeset validator is `#{inspect validation}`."
{_, _, error_message} ->
raise error_message
_ ->
changeset
end
end
def do_raise_if_invalid_fields(changeset, _), do: changeset
defp ensure_fields_exist!(%Ecto.Changeset{} = changeset, keys_validations) do
Keyword.keys(keys_validations)
|> Enum.each(&ensure_field_exists!(changeset, &1))
end
defp ensure_field_exists!(%Ecto.Changeset{types: types}, key) do
unless Map.has_key?(types, key) do
raise ArgumentError, "unknown field `#{inspect key}`"
end
end
defp ensure_validations_exist!(%Ecto.Changeset{} = changeset, keys_validations) do
required =
changeset.required
|> Enum.map(fn field -> {field, :required} end)
validations =
Ecto.Changeset.validations(changeset)
|> Enum.map(fn
{field, validation_tuple} when is_tuple(validation_tuple) ->
{field, elem(validation_tuple, 0)}
{field, validation} when is_atom(validation) ->
{field, validation}
end)
validations = required ++ validations
keys_validations =
keys_validations
|> Enum.map(fn {key, validations} ->
Enum.map(List.wrap(validations), &({key, &1}))
end)
|> List.flatten()
|> Enum.uniq()
unknown_validations = keys_validations -- validations
if unknown_validations != [] do
[{field, validation} | _] = unknown_validations
raise ArgumentError, "unknown validation `#{inspect validation}` for field `#{inspect field}`"
end
end
def change_assoc(struct_or_changeset, keys) do
change_assoc(struct_or_changeset, keys, %{})
end
@doc ~S"""
Returns the nested association in a changeset. This function will first look into the changes and then fails back on
data wrapped in a changeset.
Changes may be added to the given changeset through the third argument.
A tuple is returned containing the root changeset, and the changeset of the association.
```elixir
{account_changeset, address_changeset} =
change_assoc(account_changeset, [:user, :config, :address], %{street: "Foo street"})
```
"""
def change_assoc(struct_or_changeset, keys, changes) when is_map(changes) do
keys = List.wrap(keys)
changed_assoc = do_change_assoc(struct_or_changeset, keys, changes)
{
put_assoc(struct_or_changeset |> Ecto.Changeset.change(), keys, changed_assoc),
changed_assoc
}
end
def change_assoc(struct_or_changeset, keys, index) when is_integer(index) do
change_assoc(struct_or_changeset, keys, index, %{})
end
@doc ~S"""
Returns the nested association in a changeset at the given index.
A tuple is returned containing the root changeset, the changesets of the association and the changeset at the
specified index.
See `change_assoc(struct_or_changeset, keys, changes)`.
```
"""
def change_assoc(struct_or_changeset, keys, index, changes) when is_integer(index) and is_map(changes) do
keys = List.wrap(keys)
changed_assoc = do_change_assoc(struct_or_changeset, keys, index, changes)
{
put_assoc(struct_or_changeset |> Ecto.Changeset.change(), keys, changed_assoc),
changed_assoc,
Enum.at(changed_assoc, index)
}
end
defp do_change_assoc(changeset, keys, index \\ nil, changes)
defp do_change_assoc(%Ecto.Changeset{} = changeset, [key | []], nil, changes) do
Map.get(changeset.changes, key, Map.fetch!(changeset.data, key) |> load!(changeset.data))
|> do_change_assoc(changes)
end
defp do_change_assoc(%Ecto.Changeset{} = changeset, [key | []], index, changes) do
Map.get(changeset.changes, key, Map.fetch!(changeset.data, key) |> load!(changeset.data))
|> List.update_at(index, &(do_change_assoc(&1, changes)))
end
defp do_change_assoc(%{__meta__: _} = schema, [key | []], nil, changes) do
Map.fetch!(schema, key)
|> load!(schema)
|> do_change_assoc(changes)
end
defp do_change_assoc(%{__meta__: _} = schema, [key | []], index, changes) do
Map.fetch!(schema, key)
|> load!(schema)
|> List.update_at(index, &(do_change_assoc(&1, changes)))
end
defp do_change_assoc(%Ecto.Changeset{} = changeset, [key | tail_keys], index, changes) do
Map.get(changeset.changes, key, Map.fetch!(changeset.data, key) |> load!(changeset.data))
|> do_change_assoc(tail_keys, index, changes)
end
defp do_change_assoc(%{__meta__: _} = schema, [key | tail_keys], index, changes) do
Map.fetch!(schema, key)
|> load!(schema)
|> do_change_assoc(tail_keys, index, changes)
end
defp do_change_assoc([], _changes), do: []
defp do_change_assoc([%{__meta__: _} = schema | tail], changes) do
[Ecto.Changeset.change(schema, changes) | do_change_assoc(tail, changes)]
end
defp do_change_assoc([%Ecto.Changeset{} = changeset | tail], changes) do
[Ecto.Changeset.change(changeset, changes) | do_change_assoc(tail, changes)]
end
defp do_change_assoc(%{__meta__: _} = schema, changes) do
Ecto.Changeset.change(schema, changes)
end
defp do_change_assoc(%Ecto.Changeset{} = changeset, changes) do
Ecto.Changeset.change(changeset, changes)
end
@doc ~S"""
Puts the given nested association in the changeset through a given list of field names.
```elixir
ChangesetHelpers.put_assoc(account_changeset, [:user, :config, :address], address_changeset)
```
Instead of giving a Changeset or a schema as the third argument, a function may also be given receiving the nested
Changeset(s) to be updated as argument.
```elixir
ChangesetHelpers.put_assoc(account_changeset, [:user, :articles],
&(Enum.concat(&1, [%Article{} |> Ecto.Changeset.change()])))
```
In the code above, we add a new empty Article to the articles association (typically done when we want to add a new
article to a form).
"""
def put_assoc(changeset, keys, value) do
do_put_assoc(changeset, List.wrap(keys), value)
end
@doc ~S"""
Puts the given nested association in the changeset at the given index.
See `put_assoc(changeset, keys, value)`.
"""
def put_assoc(changeset, keys, index, value) do
do_put_assoc(changeset, List.wrap(keys), index, value)
end
defp do_put_assoc(changeset, keys, index \\ nil, value_or_fun)
defp do_put_assoc(changeset, [key | []], nil, fun) when is_function(fun) do
Ecto.Changeset.put_assoc(changeset, key, fun.(do_change_assoc(changeset, [key], %{})))
end
defp do_put_assoc(changeset, [key | []], nil, value) do
Ecto.Changeset.put_assoc(changeset, key, value)
end
defp do_put_assoc(changeset, [key | []], index, fun) when is_function(fun) do
nested_changesets = do_change_assoc(changeset, [key], %{})
nested_changesets = List.update_at(nested_changesets, index, &(fun.(&1)))
Ecto.Changeset.put_assoc(changeset, key, nested_changesets)
end
defp do_put_assoc(changeset, [key | []], index, value) do
nested_changesets =
do_change_assoc(changeset, [key], %{})
|> List.replace_at(index, value)
Ecto.Changeset.put_assoc(changeset, key, nested_changesets)
end
defp do_put_assoc(changeset, [key | tail_keys], index, value_or_fun) do
Ecto.Changeset.put_assoc(
changeset,
key,
do_put_assoc(do_change_assoc(changeset, [key], %{}), tail_keys, index, value_or_fun)
)
end
@doc ~S"""
Fetches the given nested field from changes or from the data.
While `fetch_change/2` only looks at the current changes to retrieve a value, this function looks at the changes and
then falls back on the data, finally returning `:error` if no value is available.
For relations, these functions will return the changeset original data with changes applied. To retrieve raw
changesets, please use `fetch_change/2`.
```elixir
{:changes, street} =
ChangesetHelpers.fetch_field(account_changeset, [:user, :config, :address, :street])
```
"""
def fetch_field(%Ecto.Changeset{} = changeset, [key | []]) do
Ecto.Changeset.fetch_field(changeset, key)
end
def fetch_field(%Ecto.Changeset{} = changeset, [key | tail_keys]) do
Map.get(changeset.changes, key, Map.fetch!(changeset.data, key) |> load!(changeset.data))
|> Ecto.Changeset.change()
|> fetch_field(tail_keys)
end
@doc ~S"""
Same as `fetch_field/2` but returns the value or raises if the given nested key was not found.
```elixir
street = ChangesetHelpers.fetch_field!(account_changeset, [:user, :config, :address, :street])
```
"""
def fetch_field!(%Ecto.Changeset{} = changeset, keys) do
case fetch_field(changeset, keys) do
{_, value} ->
value
:error ->
raise KeyError, key: keys, term: changeset.data
end
end
@doc ~S"""
Fetches a nested change from the given changeset.
This function only looks at the `:changes` field of the given `changeset` and returns `{:ok, value}` if the change is
present or `:error` if it's not.
```elixir
{:ok, street} =
ChangesetHelpers.fetch_change(account_changeset, [:user, :config, :address, :street])
```
"""
def fetch_change(%Ecto.Changeset{} = changeset, [key | []]) do
Ecto.Changeset.fetch_change(changeset, key)
end
def fetch_change(%Ecto.Changeset{} = changeset, [key | tail_keys]) do
case Map.get(changeset.changes, key) do
nil ->
nil
changeset ->
fetch_change(changeset, tail_keys)
end
end
@doc ~S"""
Same as `fetch_change/2` but returns the value or raises if the given nested key was not found.
```elixir
street = ChangesetHelpers.fetch_change!(account_changeset, [:user, :config, :address, :street])
```
"""
def fetch_change!(%Ecto.Changeset{} = changeset, keys) do
case fetch_change(changeset, keys) do
{:ok, value} ->
value
:error ->
raise KeyError, key: keys, term: changeset.changes
end
end
@doc ~S"""
This function allows checking if a given field is different between two changesets.
```elixir
{street_changed, street1, street2} =
diff_field(account_changeset, new_account_changeset, [:user, :config, :address, :street])
```
"""
def diff_field(%Ecto.Changeset{} = changeset1, %Ecto.Changeset{} = changeset2, keys) do
field1 = fetch_field!(changeset1, keys)
field2 = fetch_field!(changeset2, keys)
{field1 != field2, field1, field2}
end
@doc ~S"""
Adds an error to the nested changeset.
```elixir
account_changeset =
ChangesetHelpers.add_error(account_changeset, [:user, :articles, :error_key], "Some error")
```
"""
def add_error(%Ecto.Changeset{} = changeset, keys, message, extra \\ []) do
reversed_keys = keys |> Enum.reverse()
last_key = hd(reversed_keys)
keys_without_last = reversed_keys |> tl() |> Enum.reverse()
{_, nested_changes} = change_assoc(changeset, keys_without_last)
nested_changes = do_add_error(nested_changes, last_key, message, extra)
ChangesetHelpers.put_assoc(changeset, keys_without_last, nested_changes)
end
defp do_add_error(nested_changes, key, message, extra) when is_list(nested_changes) do
Enum.map(nested_changes, &(Ecto.Changeset.add_error(&1, key, message, extra)))
end
defp do_add_error(nested_changes, key, message, extra) do
Ecto.Changeset.add_error(nested_changes, key, message, extra)
end
defp load!(%Ecto.Association.NotLoaded{} = not_loaded, %{__meta__: %{state: :built}}) do
case cardinality_to_empty(not_loaded.__cardinality__) do
nil ->
Ecto.build_assoc(struct(not_loaded.__owner__), not_loaded.__field__)
[] ->
[]
end
end
defp load!(%Ecto.Association.NotLoaded{__field__: field}, struct) do
raise "attempting to change association `#{field}` " <>
"from `#{inspect struct.__struct__}` that was not loaded. Please preload your " <>
"associations before manipulating them through changesets"
end
defp load!(loaded, _struct) do
loaded
end
defp cardinality_to_empty(:one), do: nil
defp cardinality_to_empty(:many), do: []
end | lib/changeset_helpers.ex | 0.872171 | 0.809389 | changeset_helpers.ex | starcoder |
defmodule Trunk.State do
@moduledoc """
This module defines a `Trunk.State` struct and provides some helper functions for working with that state.
## Fields
The following fields are available in the state object. Some values are filled in during processing.
- `filename` - The base filename of the file being processed. (e.g. `"photo.jpg"`)
- `rootname` - The root of the filen being processed. (e.g. `"photo"`)
- `extname` - The file extension of the file being processed. (e.g. `".jpg"`)
- `lower_extname` - The file extension of the file being processed forced to lower case (e.g. `"*.jpg"`, even if the file is `"PHOTO.JPG"`)
- `path` - The full path to the file being processed. If the file was passed in as a binary, it is a path to the temporary file created with that binary.
- `versions` - A map of the versions and their respective `Trunk.VersionState` (e.g. `%{original: %Trunk.VersionState{}, thumbnail: %Trunk.VersionState{}}`)
- `scope` - A user struct/map passed in useful for determining storage locations and file naming.
- `async` - A boolean indicator of whether processing will be done in parallel.
- `timeout` - The timeout after which each processing process will be terminated. (Only applies with `async: true`)
- `storage` - The module to use for storage processing. (e.g. `Trunk.Storage.Filesystem` or `Trunk.Storage.S3`)
- `storage_opts` - A keyword list of options for the `storage` module
- `errors` - a place to record errors encountered during processing. (`nli` if no errors, otherwise a map of errors)
- `opts` - All the options merged together (see Options in `Trunk` module documentation).
- `assigns` - shared user data as a map (Same as assigns in `Plug.Conn`)
"""
alias Trunk.VersionState
defstruct module: nil,
path: nil,
filename: nil,
rootname: nil,
extname: nil,
lower_extname: nil,
versions: %{},
scope: %{},
async: true,
timeout: 5_000,
storage: nil,
storage_opts: [],
errors: nil,
opts: [],
assigns: %{}
@type opts :: Keyword.t()
@type t :: %__MODULE__{
module: atom,
opts: opts,
filename: String.t(),
rootname: String.t(),
extname: String.t(),
lower_extname: String.t(),
path: String.t(),
versions: map,
async: boolean,
timeout: integer,
scope: map | struct,
storage: atom,
storage_opts: Keyword.t(),
errors: Keyword.t(),
assigns: map
}
def init(%{} = info, scope, opts) do
state = restore(info, opts)
rootname = Path.rootname(state.filename)
extname = Path.extname(state.filename)
%{
state
| extname: extname,
lower_extname: String.downcase(extname),
rootname: rootname,
timeout: Keyword.fetch!(opts, :timeout),
async: Keyword.fetch!(opts, :async),
storage: Keyword.fetch!(opts, :storage),
storage_opts: Keyword.fetch!(opts, :storage_opts),
scope: scope,
opts: opts
}
end
@doc ~S"""
Puts an error into the error map.
## Example:
```
iex> state.errors
nil
iex> state = Trunk.State.put_error(state, :thumb, :transform, "Error with convert blah blah")
iex> state.errors
%{thumb: [transform: "Error with convert blah blah"]}
```
"""
def put_error(%__MODULE__{errors: errors} = state, version, stage, error),
do: %{
state
| errors: Map.update(errors || %{}, version, [{stage, error}], &[{stage, error} | &1])
}
@doc ~S"""
Assigns a value to a key on the state.
## Example:
```
iex> state.assigns[:hello]
nil
iex> state = Trunk.State.assign(state, :hello, :world)
iex> state.assigns[:hello]
:world
```
"""
@spec assign(state :: Trunk.State.t(), key :: any, value :: any) :: map
def assign(%{assigns: assigns} = state, key, value),
do: %{state | assigns: Map.put(assigns, key, value)}
@doc ~S"""
Retrieves an assign value for a specific version.
## Example:
```
iex> state = %Trunk.State{versions: %{thumbnail: %Trunk.VersionState{assigns: %{hello: :world}}}}
iex> %Trunk.State.get_version_assign(state, :thumbnail, :hello)
:world
iex> %Trunk.State.get_version_assign(state, :thumbnail, :unknown)
nil
```
"""
@type version :: atom
@spec get_version_assign(state :: Trunk.State.t(), version, assign :: atom) :: any | nil
def get_version_assign(%{versions: versions}, version, assign) do
case versions[version] do
%{assigns: %{^assign => value}} -> value
_ -> nil
end
end
@doc ~S"""
Extracts the data needed from the state in order to reconstruct the file paths in future.
Options:
- `:as` - How to save the state.
- `:string` - Default, will just save the file name. An error will be raised if there are any assigns unless `:ignore_assigns` is set to tru
- `:map` - will save a map with keys `:filename`, `:assigns`, and `:version_assigns`
- `:json` - will save a map encoded as JSON (Requires Poison library to be included in deps)
- `:ignore_assigns` boolean, default false. Use this to save as string and ignore any assigns (Make sure you’re not using assigns for `c:Trunk.storage_dir/2` or `c:Trunk.filename/2`)
- `:assigns` - a list of keys to save from the assigns hashes
## Example:
```
iex> Trunk.State.save(%Trunk.State{filename: "photo.jpg"})
"photo.jpg"
iex> Trunk.State.save(%Trunk.State{filename: "photo.jpg", assigns: %{hash: "abcdef"}}, as: :map)
%{filename: "photo.jpg", assigns: %{hash: "abcdef"}}
iex> Trunk.State.save(%Trunk.State{filename: "photo.jpg", assigns: %{hash: "abcdef", file_size: 12345}}, as: :map, assigns: [:hash])
%{filename: "photo.jpg", assigns: %{hash: "abcdef"}}
iex> Trunk.State.save(%Trunk.State{filename: "photo.jpg", assigns: %{hash: "abcdef"}}, as: :json)
"{\"filename\": \"photo.jpg\", \"assigns\": {\"hash\": \"abcdef\"}}"
```
"""
@type assign_keys :: [atom]
@type save_opts :: [assigns: :all | assign_keys]
@spec save(Trunk.State.t()) :: String.t()
@spec save(Trunk.State.t(), [{:as, :string} | save_opts]) :: String.t()
@spec save(Trunk.State.t(), [{:as, :json} | save_opts]) :: String.t()
@spec save(Trunk.State.t(), [{:as, :map} | save_opts]) :: map
def save(state, opts \\ []) do
save_as = Keyword.get(opts, :as, :string)
save_as(state, save_as, opts)
end
defp save_as(%{filename: filename} = state, :string, opts) do
unless Keyword.get(opts, :ignore_assigns, false), do: assert_no_assigns(state)
filename
end
defp(save_as(state, :json, opts), do: state |> save_as(:map, opts) |> json_parser().encode!())
defp save_as(%{filename: filename, assigns: assigns, versions: versions}, :map, opts) do
assigns_to_save = Keyword.get(opts, :assigns, :all)
%{filename: filename}
|> save_assigns(assigns, assigns_to_save)
|> save_version_assigns(versions, assigns_to_save)
end
defp assert_no_assigns(%{assigns: assigns}) when assigns != %{},
do: raise(ArgumentError, message: "Cannot save state as string with non-empty assigns hash")
defp assert_no_assigns(%{versions: versions}),
do: Enum.each(versions, fn {_version, state} -> assert_no_assigns(state) end)
defp assert_no_assigns(%{}), do: nil
defp save_assigns(map, assigns, _keys) when assigns == %{}, do: map
defp save_assigns(map, assigns, :all), do: Map.put(map, :assigns, assigns)
defp save_assigns(map, assigns, keys), do: Map.put(map, :assigns, Map.take(assigns, keys))
defp save_version_assigns(map, versions, keys) do
version_assigns =
versions
|> Enum.map(fn
{version, %{assigns: assigns}} when assigns == %{} ->
{version, nil}
{version, %{assigns: assigns}} ->
{version, if(keys == :all, do: assigns, else: Map.take(assigns, keys))}
end)
|> Enum.filter(fn {_version, value} -> value end)
|> Map.new()
if Enum.empty?(version_assigns),
do: map,
else: Map.put(map, :version_assigns, version_assigns)
end
@doc ~S"""
Restore a saved state from a filename, JSON, or a map
## Example:
```
iex> Trunk.State.restore("photo.jpg")
%Trunk.State{filename: "photo.jpg"}
iex> Trunk.State.restore(%{filename: "photo.jpg", assigns: %{hash: "abcdef"}}
%Trunk.State{filename: "photo.jpg", assigns: %{hash: "abcdef"}}
iex> Trunk.State.restore(%{"filename" => "photo.jpg", "assigns" => %{"hash" => "abcdef"}}
%Trunk.State{filename: "photo.jpg", assigns: %{hash: "abcdef"}}
iex> Trunk.State.restore("{\"filename\": \"photo.jpg\", \"assigns\": {\"hash\": \"abcdef\"}}")
%Trunk.State{filename: "photo.jpg", assigns: %{hash: "abcdef"}}
```
"""
@type file_info :: String.t() | map
@spec restore(file_info, opts) :: Trunk.State.t()
def restore(file_info, opts \\ [])
def restore(<<"{", _rest::binary>> = json, opts) do
{:ok, map} = json_parser().decode(json)
map
|> keys_to_atom
|> restore(opts)
end
def restore(<<filename::binary>>, opts), do: restore(%{filename: filename}, opts)
def restore(%{} = info, opts) do
info = keys_to_atom(info)
state = struct(__MODULE__, info)
version_assigns = info[:version_assigns] || %{}
versions =
opts
|> Keyword.fetch!(:versions)
|> Enum.map(fn version ->
assigns = version_assigns[version] || %{}
{version, %VersionState{assigns: assigns}}
end)
|> Map.new()
%{state | versions: versions}
end
defp keys_to_atom(%{} = map) do
map
|> Enum.map(fn {key, value} ->
try do
{String.to_existing_atom(key), keys_to_atom(value)}
rescue
ArgumentError ->
{key, keys_to_atom(value)}
end
end)
|> Map.new()
end
defp keys_to_atom(arg), do: arg
defp json_parser do
cond do
Code.ensure_loaded?(Jason) ->
Jason
Code.ensure_loaded?(Poison) ->
Poison
raise RuntimeError,
"You must have a JSON parser loaded (Jason and Poison are supported)"
end
end
end | lib/trunk/state.ex | 0.917159 | 0.908618 | state.ex | starcoder |
defmodule Rollbax.Client do
@moduledoc false
# This GenServer keeps a pre-built bare-bones version of an exception (a
# "draft") to be reported to Rollbar, which is then filled with the data
# related to each specific exception when such exception is being
# reported. This GenServer is also responsible for actually sending data to
# the Rollbar API and receiving responses from said API.
use GenServer
require Logger
alias Rollbax.Item
@name __MODULE__
@hackney_pool __MODULE__
@headers [{"content-type", "application/json"}]
## GenServer state
defstruct [:draft, :url, :enabled, hackney_responses: %{}]
## Public API
def start_link(config) do
state = %__MODULE__{
draft: Item.draft(config[:access_token], config[:environment], config[:custom]),
url: config[:api_endpoint],
enabled: config[:enabled]
}
GenServer.start_link(__MODULE__, state, name: @name)
end
def emit(level, timestamp, body, custom, occurrence_data)
when is_atom(level) and is_integer(timestamp) and timestamp > 0 and is_map(body) and
is_map(custom) and is_map(occurrence_data) do
if pid = Process.whereis(@name) do
event = {Atom.to_string(level), timestamp, body, custom, occurrence_data}
GenServer.cast(pid, {:emit, event})
else
Logger.warn(
"(Rollbax) Trying to report an exception but the :rollbax application has not been started",
rollbax: false
)
end
end
## GenServer callbacks
def init(state) do
Logger.metadata(rollbax: false)
:ok = :hackney_pool.start_pool(@hackney_pool, max_connections: 20)
{:ok, state}
end
def terminate(_reason, _state) do
:ok = :hackney_pool.stop_pool(@hackney_pool)
end
def handle_cast({:emit, _event}, %{enabled: false} = state) do
{:noreply, state}
end
def handle_cast({:emit, event}, %{enabled: :log} = state) do
Logger.info(["(Rollbax) registered report.\n", event_to_chardata(event)])
{:noreply, state}
end
def handle_cast({:emit, event}, %{enabled: true} = state) do
case compose_json(state.draft, event) do
{:ok, payload} ->
opts = [:async, pool: @hackney_pool]
case :hackney.post(state.url, @headers, payload, opts) do
{:ok, _ref} ->
:ok
{:error, reason} ->
Logger.error("(Rollbax) connection error: #{inspect(reason)}")
end
{:error, exception} ->
Logger.error([
"(Rollbax) failed to encode report below ",
"for reason: ",
Exception.message(exception),
?\n,
event_to_chardata(event)
])
end
{:noreply, state}
end
def handle_info({:hackney_response, ref, response}, state) do
new_state = handle_hackney_response(ref, response, state)
{:noreply, new_state}
end
def handle_info(message, state) do
Logger.info("(Rollbax) unexpected message: #{inspect(message)}")
{:noreply, state}
end
## Helper functions
defp compose_json(draft, event) do
draft
|> Item.compose(event)
|> Jason.encode_to_iodata()
end
defp event_to_chardata({level, timestamp, body, custom, occurrence_data}) do
[
inspect(body),
"\nLevel: ",
level,
"\nTimestamp: ",
Integer.to_string(timestamp),
"\nCustom data: ",
inspect(custom),
"\nOccurrence data: ",
inspect(occurrence_data)
]
end
defp handle_hackney_response(ref, :done, %{hackney_responses: responses} = state) do
body = responses |> Map.fetch!(ref) |> IO.iodata_to_binary()
case Jason.decode(body) do
{:ok, %{"err" => 1, "message" => message}} when is_binary(message) ->
Logger.error("(Rollbax) API returned an error: #{inspect(message)}")
{:ok, response} ->
Logger.debug("(Rollbax) API response: #{inspect(response)}")
{:error, _} ->
Logger.error("(Rollbax) API returned malformed JSON: #{inspect(body)}")
end
%{state | hackney_responses: Map.delete(responses, ref)}
end
defp handle_hackney_response(
ref,
{:status, code, description},
%{hackney_responses: responses} = state
) do
if code != 200 do
Logger.error("(Rollbax) unexpected API status: #{code}/#{description}")
end
%{state | hackney_responses: Map.put(responses, ref, [])}
end
defp handle_hackney_response(_ref, {:headers, headers}, state) do
Logger.debug("(Rollbax) API headers: #{inspect(headers)}")
state
end
defp handle_hackney_response(ref, body_chunk, %{hackney_responses: responses} = state)
when is_binary(body_chunk) do
%{state | hackney_responses: Map.update!(responses, ref, &[&1 | body_chunk])}
end
defp handle_hackney_response(ref, {:error, reason}, %{hackney_responses: responses} = state) do
Logger.error("(Rollbax) connection error: #{inspect(reason)}")
%{state | hackney_responses: Map.delete(responses, ref)}
end
end | lib/rollbax/client.ex | 0.641984 | 0.410786 | client.ex | starcoder |
defmodule LangTags.Tag do
@moduledoc """
Tags registered according to the rules in [RFC3066](https://tools.ietf.org/html/rfc3066)
Please note that this *tags* appears in records whose *type* is either 'grandfathered'
or 'redundant' and contains a tag registered under [RFC3066](https://tools.ietf.org/html/rfc3066).
For more information, see [section 2.2.8](https://tools.ietf.org/html/bcp47#section-2.2.8)
"""
alias LangTags.{SubTag,Registry}
@doc """
Creates a new tag as a map
## Examples
iex> LangTags.Tag.new("en-gb-oed")
%{"Record" => %{"Added" => "2003-07-09", "Deprecated" => "2015-04-17",
"Description" => ["English, Oxford English Dictionary spelling"],
"Preferred-Value" => "en-GB-oxendict", "Tag" => "en-gb-oed",
"Type" => "grandfathered"}, "Tag" => "en-gb-oed"}
"""
@spec new(String.t) :: map
def new(tag) do
# Lowercase for consistency (case is only a formatting
# convention, not a standard requirement)
tag = tag |> String.trim() |> String.downcase()
try do
%{"Tag" => tag, "Record" => Registry.tag(tag)}
rescue
ArgumentError -> %{"Tag" => tag}
end
end
@doc """
If the tag is listed as *deprecated* or *redundant* it might have a preferred value. This method returns a tag as a map if so.
## Examples
iex> LangTags.Tag.preferred("i-klingon")
%{"Tag" => "tlh"}
iex> "zh-cmn-Hant" |> LangTags.Tag.new() |> LangTags.Tag.preferred()
%{"Tag" => "cmn-hant"}
"""
@spec preferred(map | String.t) :: map | nil
def preferred(tag) when is_binary(tag), do: tag |> new() |> preferred()
def preferred(tag) when is_map(tag) do
preferred = tag["Record"]["Preferred-Value"]
if preferred, do: new(preferred), else: nil
end
@doc """
Returns a list of subtags making up the tag, as `Subtag` maps.
Note that if the tag is *grandfathered* the result will be an empty list
## Examples
iex> LangTags.Tag.subtags("en-gb-oed")
[]
iex> LangTags.Tag.subtags("az-arab")
LangTags.Tag.subtags("az-arab")
"""
@spec subtags(map | String.t) :: [map] | []
def subtags(tag) when is_map(tag), do: process_subtags(tag, tag["Record"]["Type"])
def subtags(tag) when is_binary(tag), do: tag |> new() |> subtags()
@doc """
Shortcut for `find/2` with a `language` filter
## Examples
iex> LangTags.Tag.language("az-arab")
%{"Record" => %{"Added" => "2005-10-16", "Description" => ["Azerbaijani"],
"Scope" => "macrolanguage", "Subtag" => "az", "Type" => "language"},
"Subtag" => "az"}
"""
@spec language(map | String.t) :: map
def language(tag) when is_map(tag), do: find(tag, "language")
def language(tag) when is_binary(tag), do: tag |> new() |> language()
@doc """
Shortcut for `find/2` with a `region` filter
## Examples
iex> LangTags.Tag.region("en-gb-oeb")["Record"]["Description"] == ["United Kingdom"]
true
"""
@spec region(map | String.t) :: map
def region(tag) when is_map(tag), do: find(tag, "region")
def region(tag) when is_binary(tag), do: tag |> new() |> region()
@doc """
Shortcut for `find/2` with a `script` filter
## Examples
iex> LangTags.Tag.script("az-arab")
%{"Record" => %{"Added" => "2005-10-16", "Description" => ["Arabic"],
"Subtag" => "arab", "Type" => "script"}, "Subtag" => "arab"}
"""
@spec script(map | String.t) :: map
def script(tag) when is_map(tag), do: find(tag, "script")
def script(tag) when is_binary(tag), do: tag |> new() |> script()
@doc """
Find a subtag of the given type from those making up the tag.
## Examples
iex> LangTags.Tag.find("az-arab", "script")
%{"Record" => %{"Added" => "2005-10-16", "Description" => ["Arabic"],
"Subtag" => "arab", "Type" => "script"}, "Subtag" => "arab"}
"""
@spec find(map | String.t, String.t) :: map
def find(tag, filter) when is_map(tag), do: Enum.find(subtags(tag), &(type(&1) == filter))
def find(tag, filter) when is_binary(tag), do: tag |> new() |> find(filter)
@doc """
Returns `true` if the tag is valid, `false` otherwise.
"""
@spec valid?(map | String.t) :: boolean
def valid?(tag) when is_map(tag), do: errors(tag) == []
def valid?(tag) when is_binary(tag), do: tag |> new |> valid?()
# FIXME: This is horrible!
def errors(tag) do
# Check if the tag is grandfathered and if the grandfathered tag is deprecated (e.g. no-nyn).
if tag["Record"]["Deprecated"] do
["ERR_DEPRECATED"]
else
codes = tag["Tag"] |> String.split("-")
# Check that all subtag codes are meaningful.
errors =
codes
|> Enum.with_index()
|> Enum.reduce_while([], fn({code, index}, acc) ->
# Ignore anything after a singleton
if String.length(code) < 2 do
# Check that each private-use subtag is within the maximum allowed length.
acc =
codes
|> Enum.slice(index, Enum.count(codes))
|> Enum.reduce_while(acc, fn(c, result) ->
if String.length(c) > 8 do
{:halt, ["ERR_TOO_LONG" | result]}
else
{:cont, result}
end
end)
{:halt, acc}
else
if Registry.types(code) == [] do
{:halt, ["ERR_UNKNOWN" | acc]}
else
{:cont, acc}
end
end
end)
# Check that first tag is a language tag.
subtags = subtags(tag)
if subtags |> List.first() |> SubTag.type() == "language" do
["ERR_NO_LANGUAGE" | errors]
else
# TODO: Check for more than one of some types and for deprecation.
# TODO: Check for correct order.
errors
end
end
end
@doc """
Returns "grandfathered" if the tag is grandfathered, "redundant" if the tag is redundant, and "tag" if neither.
For a definition of grandfathered and redundant tags, see [RFC 5646 section 2.2.8](http://tools.ietf.org/html/rfc5646#section-2.2.8).
## Examples
iex> LangTags.Tag.type("art-lojban")
"grandfathered"
iex> LangTags.Tag.type("az-Arab")
"redundant"
"""
@spec type(map | String.t) :: String.t
def type(tag) when is_map(tag), do: tag["Record"]["Type"] || "tag"
def type(tag) when is_binary(tag), do: tag |> new() |> type()
@doc """
Returns `true` if the tag is grandfathered, otherwise returns `false`
## Examples
iex> LangTags.Tag.grandfathered?("zh-xiang")
true
iex> LangTags.Tag.grandfathered?("az-Arab")
false
"""
@spec grandfathered?(String.t) :: boolean
def grandfathered?(tag), do: Registry.grandfathered?(tag)
@doc """
Returns `true` if the tag is redundant, otherwise returns `false`
## Examples
iex> LangTags.Tag.redundant?("az-Arab")
true
iex> LangTags.Tag.redundant?("zh-xiang")
false
"""
@spec redundant?(String.t) :: boolean
def redundant?(tag), do: Registry.redundant?(tag)
@doc """
For grandfathered or redundant tags, returns a date string reflecting the date the tag was added to the registry.
## Examples
iex> LangTags.Tag.added("cel-gaulish")
"2001-05-25"
"""
@spec added(map | String.t) :: String.t | nil
def added(tag) when is_map(tag), do: tag["Record"]["Added"]
def added(tag) when is_binary(tag), do: tag |> new() |> added()
@doc """
For grandfathered or redundant tags, returns a date string reflecting the deprecation date if the tag is deprecated.
## Examples
iex> LangTags.Tag.deprecated("art-lojban")
"2003-09-02"
iex> "zh-cmn-Hant" |> LangTags.Tag.new() |> LangTags.Tag.deprecated()
"2009-07-29"
"""
@spec deprecated(map | String.t) :: String.t | nil
def deprecated(tag) when is_map(tag), do: tag["Record"]["Deprecated"]
def deprecated(tag) when is_binary(tag), do: tag |> new() |> deprecated()
@doc """
Returns a list of tag descriptions for grandfathered or redundant tags, otherwise returns an empty list.
## Examples
iex> LangTags.Tag.descriptions("art-lojban")
["Lojban"]
"""
@spec descriptions(map | String.t) :: String.t | []
def descriptions(tag) when is_map(tag), do: tag["Record"]["Description"] || []
def descriptions(tag) when is_binary(tag), do: tag |> new() |> descriptions()
@doc """
Format a tag according to the case conventions defined in [RFC 5646 section 2.1.1](http://tools.ietf.org/html/rfc5646#section-2.1.1).
## Examples
iex> LangTags.Tag.format("en-gb-oed")
"en-GB-oed"
iex> "en-gb" |> LangTags.Tag.new() |> LangTags.Tag.format()
"en-GB"
"""
@spec format(map | String.t) :: String.t
def format(tag) when is_binary(tag), do: tag |> new() |> format()
def format(tag) when is_map(tag) do
tag["Tag"]
|> String.split("-")
|> Enum.with_index()
|> Enum.reduce([], fn({value, index}, acc) ->
format_by_index(index, value, acc)
end)
|> Enum.reverse()
|> Enum.join("-")
end
## Helpers
defp process_subtags(_tag, "grandfathered"), do: []
defp process_subtags(tag, _) do
codes = tag["Tag"] |> String.split("-") |> Enum.with_index()
subtags =
Enum.reduce_while(codes, [], fn({code, index}, subtags) ->
# Singletons and anything after are unhandled.
if String.length(code) < 2 do
{:halt, subtags} # Stop the loop (stop processing after a singleton).
else
subtags = process_subtag_by_index(index, code, subtags)
{:cont, subtags}
end
end)
Enum.reverse(subtags)
end
defp format_by_index(0, value, _acc), do: [value]
defp format_by_index(_index, value, acc) do
if acc |> hd() |> String.length() == 1 do
[value | acc]
else
format_by_string_length(acc, value)
end
end
defp format_by_string_length(acc, value) do
case String.length(value) do
2 ->
[String.upcase(value) | acc]
4 ->
{char, rest} = String.Casing.titlecase_once(value)
[char <> rest | acc]
_ ->
[value | acc]
end
end
## Process subtags
defp process_subtag_by_index(0, code, subtags) do
# Language subtags may only appear at the beginning of the tag, otherwise the subtag type is indeterminate.
if subtag = SubTag.find(code, "language"), do: [subtag | subtags], else: subtags
end
defp process_subtag_by_index(_, code, subtags) do
code |> String.length() |> process_subtag_by_string_length(code, subtags)
end
defp process_subtag_by_string_length(2, code, subtags) do
# Should be a region, but, in case of error we can assume
# a language type in the wrong place
types = ["region", "language"]
find_subtag(code, subtags, types)
end
defp process_subtag_by_string_length(3, code, subtags) do
# Could be a numeric region code e.g. '001' for 'World'
# As a second case we try with "extlang"
# Error case: language subtag in the wrong place.
types = ["region", "extlang", "language"]
find_subtag(code, subtags, types)
end
defp process_subtag_by_string_length(4, code, subtags) do
# Could be a numeric variant.
types = ["variant", "script"]
find_subtag(code, subtags, types)
end
defp process_subtag_by_string_length(_, code, subtags) do
# Should be a variant
find_subtag(code, subtags, ["variant"])
end
defp find_subtag(code, subtags, types) do
Enum.reduce_while(types, subtags, fn(type, acc) ->
if subtag = SubTag.find(code, type) do
{:halt, [subtag | acc]}
else
{:cont, acc}
end
end)
end
end | lib/lang_tags/tag.ex | 0.738292 | 0.484014 | tag.ex | starcoder |
defmodule Cleanser do
@moduledoc """
Documentation for Cleanser.
"""
@doc """
Email Validation
## Examples
iex> Cleanser.validate_email("<EMAIL>")
:ok
iex> Cleanser.validate_email("<EMAIL>")
{:error, "spambox.me is an invalid domain"}
iex> Cleanser.validate_email("blocked.com")
{:error, "Unable to get the domain from blocked.com"}
iex> Cleanser.validate_email("<EMAIL>", ["example.com"])
{:error, "example.com is an invalid domain"}
iex> Cleanser.validate_email("<EMAIL>", ["abc.com"])
:ok
"""
def validate_email(email, invalid_domains \\ []) when is_binary(email) and is_list(invalid_domains) do
case parse_email_domain(email) do
{:ok, domain} ->
is_valid_domain?(domain, invalid_domains)
{:error, error_message } ->
{:error, error_message}
end
end
@doc false
def parse_email_domain(email) when is_binary(email) do
email_parts = String.split(email, "@")
case email_parts do
[_, domain] ->
{:ok, domain}
_ ->
{:error, "Unable to get the domain from #{email}"}
end
end
@doc """
Domain Validation
Validates a given `domain` against a list of disposable emails.
## Examples
iex> Cleanser.is_valid_domain?("example.com")
:ok
iex> Cleanser.is_valid_domain?("spambox.me")
{:error, "spambox.me is an invalid domain"}
It also validates a given `domain` against a list of custom domains.
## Example
iex> Cleanser.is_valid_domain?("example.com", ["example.com"])
{:error, "example.com is an invalid domain"}
"""
def is_valid_domain?(domain, invalid_domains \\ []) when is_list(invalid_domains) do
is_valid = invalid_domains ++ disposable_domains()
|> MapSet.new
|> MapSet.member?(domain)
|> Kernel.not
case is_valid do
true ->
:ok
false ->
{:error, "#{domain} is an invalid domain"}
end
end
@doc false
defp disposable_domains do
Path.join(:code.priv_dir(:cleanser), "disposable_emails.txt")
|> File.read!
|> String.split
end
@doc """
Bad Words Filter
Validates a string against a list of bad words in the language chosen.
## Examples
iex> Cleanser.contains_bad_words?("Hello I am normal", "English")
:ok
iex> Cleanser.contains_bad_words?("What the butt", "english")
{:error, "This string contains bad words"}
iex> Cleanser.contains_bad_words?("ok ok 挿入 ok ok", "japanese")
{:error, "This string contains bad words"}
"""
def contains_bad_words?(string, language) do
case is_valid_language?(language) do
:ok ->
words = String.downcase(string)
|>String.split
|>MapSet.new
is_valid = bad_words(language)
|> MapSet.new
|> MapSet.disjoint?(words)
case is_valid do
true ->
:ok
false ->
{:error, "This string contains bad words"}
end
{:error, message} ->
{:error, message}
end
end
defp bad_words(language) do
language = String.downcase(language)
Path.join(:code.priv_dir(:cleanser), "bad_words/#{language}.txt")
|> File.read!
|> String.downcase()
|> String.split
end
@doc """
Language Validation
Validates a language against a list of available languages.
## Examples
iex> Cleanser.is_valid_language?("dutch")
:ok
iex> Cleanser.is_valid_language?("Gibberish")
{:error, "gibberish is either not a valid language or not available in this package"}
"""
def is_valid_language?(language) do
language = String.downcase(language)
valid_language = ["arabic", "chinese", "czech", "danish", "dutch", "english", "esperanto", "finnish", "french",
"german", "hindi", "hungarian", "italian", "japanese", "korean", "norwegian", "persian", "polish",
"portuguese", "russian", "spanish", "swedish", "thai", "turkish"]
|> MapSet.new
|> MapSet.member?(language)
case valid_language do
true ->
:ok
false ->
{:error, "#{language} is either not a valid language or not available in this package"}
end
end
@doc """
Credit Card Validation
Validates a given credit card number using the Luhn Check Sum.
## Examples
iex> Cleanser.is_valid_credit_card?(4024007157761171)
:ok
iex> Cleanser.is_valid_credit_card?(4111111111111113)
{:error, "4111111111111113 is an invalid credit card number"}
"""
# Using the Luhn Sum Algorithm this:
# 1) Starting from the right most number, doubles the value of every second number
# If the value of the number doubled is 10 or more, subtract 9
# 2) Takes the sum of all the numbers
# 3) If the sum is evenly divisible by 10, then the credit card number is valid
def is_valid_credit_card?(card_number) when is_integer(card_number) do
[head | tail] = Enum.reverse(Integer.digits(card_number))
doubled = Enum.map_every(tail, 2, fn x -> if x >= 5, do: x * 2 - 9, else: x * 2 end)
non_check_sum = Enum.sum(doubled)
remainder = rem(non_check_sum + head, 10)
case remainder do
0 ->
:ok
_ ->
{:error, "#{card_number} is an invalid credit card number"}
end
end
end | lib/cleanser.ex | 0.842313 | 0.438184 | cleanser.ex | starcoder |
defmodule Mimic.Module do
alias Mimic.{Cover, Server}
@moduledoc false
def original(module), do: "#{module}.Mimic.Original.Module" |> String.to_atom()
def clear!(module) do
:code.purge(module)
:code.delete(module)
:code.purge(original(module))
:code.delete(original(module))
:ok
end
def replace!(module) do
backup_module = original(module)
case :cover.is_compiled(module) do
{:file, beam_file} ->
coverdata_path = Cover.export_coverdata!(module)
Server.store_beam_and_coverdata(module, beam_file, coverdata_path)
false ->
:ok
end
rename_module(module, backup_module)
Code.compiler_options(ignore_module_conflict: true)
create_mock(module)
Code.compiler_options(ignore_module_conflict: false)
:ok
end
defp rename_module(module, new_module) do
beam_code = beam_code(module)
{:ok, {_, [{:abstract_code, {:raw_abstract_v1, forms}}]}} =
:beam_lib.chunks(beam_code, [:abstract_code])
forms = rename_attribute(forms, new_module)
case :compile.forms(forms, compiler_options(module)) do
{:ok, module_name, binary} ->
load_binary(module_name, binary)
binary
{:ok, module_name, binary, _warnings} ->
load_binary(module_name, binary)
Binary
end
end
defp beam_code(module) do
case :code.get_object_code(module) do
{_, binary, _filename} -> binary
_error -> throw({:object_code_not_found, module})
end
end
defp compiler_options(module) do
options =
module.module_info(:compile)
|> Keyword.get(:options)
|> Enum.filter(&(&1 != :from_core))
[:return_errors | [:debug_info | options]]
end
defp load_binary(module, binary) do
case :code.load_binary(module, '', binary) do
{:module, ^module} -> :ok
{:error, reason} -> exit({:error_loading_module, module, reason})
end
apply(:cover, :compile_beams, [[{module, binary}]])
end
defp rename_attribute([{:attribute, line, :module, {_, vars}} | t], new_name) do
[{:attribute, line, :module, {new_name, vars}} | t]
end
defp rename_attribute([{:attribute, line, :module, _} | t], new_name) do
[{:attribute, line, :module, new_name} | t]
end
defp rename_attribute([h | t], new_name), do: [h | rename_attribute(t, new_name)]
defp create_mock(module) do
mimic_info = module_mimic_info()
mimic_functions = generate_mimic_functions(module)
Module.create(module, [mimic_info | mimic_functions], Macro.Env.location(__ENV__))
module
end
defp module_mimic_info do
quote do: def(__mimic_info__, do: :ok)
end
defp generate_mimic_functions(module) do
internal_functions = [__info__: 1, module_info: 0, module_info: 1]
for {fn_name, arity} <- module.module_info(:exports),
{fn_name, arity} not in internal_functions do
args =
0..arity
|> Enum.to_list()
|> tl()
|> Enum.map(&Macro.var(String.to_atom("arg_#{&1}"), Elixir))
quote do
def unquote(fn_name)(unquote_splicing(args)) do
Server.apply(__MODULE__, unquote(fn_name), unquote(args))
end
end
end
end
end | lib/mimic/module.ex | 0.588889 | 0.447158 | module.ex | starcoder |
defmodule SurfaceBulma.Form.Utils do
def input_classes(assigns, other_classes \\ [])
def input_classes(assigns, other_classes) when is_binary(other_classes) do
input_classes(assigns, [other_classes])
end
def input_classes(assigns, other_classes) do
["input"] ++
other_classes ++
[
"is-danger": has_error?(assigns),
"is-success": has_change?(assigns) && !has_error?(assigns),
"is-#{assigns[:size]}": assigns[:size] != "normal",
"is-static": assigns[:static]
] ++ (assigns[:class] || [])
end
def display_right_icon?(%{disable_right_icon: true}), do: false
def display_right_icon?(assigns) do
(!Map.get(assigns, :disable_icons) &&
(has_error?(assigns) || has_change?(assigns))) ||
Map.get(assigns, :icon_right)
end
def display_left_icon?(assigns) do
Map.get(assigns, :icon_left)
end
def display_error_icon?(assigns) do
!Map.get(assigns, :disable_icons) && !Map.get(assigns, :icon_right) && has_error?(assigns) &&
display_right_icon?(assigns)
end
def display_valid_icon?(assigns) do
!Map.get(assigns, :disable_icons) &&
!Map.get(assigns, :icon_right) &&
has_change?(assigns) &&
!has_error?(assigns) && display_right_icon?(assigns)
end
def has_error?(assigns) do
get_form(assigns)
|> field_has_error?(assigns.field)
end
def has_change?(assigns) do
get_form(assigns)
|> field_has_change?(assigns.field)
end
@doc "Helper function used by the form controls"
def field_has_error?(%{source: %{errors: errors}}, field) do
Enum.any?(errors, fn {field_name, _} ->
field_name == field
end)
end
def field_has_error?(_not_form, _field), do: false
@doc "Helper function used by the form controls"
def field_has_change?(%{source: source}, field) when is_map(source) do
Ecto.Changeset.get_change(source, field, false)
end
def field_has_change?(_not_form, _field), do: false
@doc "Gets the form from the context. Works with a `Surface.Components.Form` and `SurfaceBulma.Form`."
def get_form(%{__context__: context}) do
case context do
%{{Surface.Components.Form, :form} => form} -> form
%{{SurfaceBulma.Form, :form} => form} -> form
_ -> nil
end
end
def text_size(size) do
size =
case size do
"small" -> 7
"normal" -> 5
"medium" -> 4
"large" -> 3
end
"is-size-#{size}"
end
end | lib/surface_bulma/form/utils.ex | 0.506836 | 0.430985 | utils.ex | starcoder |
defmodule Plug.AMQP.Conn do
@moduledoc """
Adapter for AMQP to Plug.Conn
This adapter partially implements the Plug.Conn.Adapter behaviour, with the
following caveats:
* `c:Plug.Conn.Adapter.send_file/6`, `c:Plug.Conn.Adapter.send_chunked/3` and
`c:Plug.Conn.Adapter.chunk/2` raise, because there is no such functionality
in *AMQP*. Also `c:Plug.Conn.Adapter.push/3` and
`c:Plug.Conn.Adapter.inform/3` are not supported.
* `c:Plug.Conn.Adapter.read_req_body/2` ignores the options and always returns
the whole message body.
* `request_path` is taken from the *routing_key*, by replacing dots with
slashes and prepending a slash. This will play nice with existing plugs
that expect url-like paths.
* `method` is `"POST"` by default. You can override this behaviour setting a
custom method in the `x-method-override` header.
"""
@behaviour Plug.Conn.Adapter
@routing_key_header "amqp-routing-key"
@method_override_header "x-method-override"
alias Plug.AMQP.{ConsumerProducer, UnsupportedError}
@spec conn(GenServer.server(), ConsumerProducer.payload(), ConsumerProducer.headers()) ::
Plug.Conn.t()
def conn(consumer_producer, payload, headers) do
headers = Enum.map(headers, fn {k, v} -> {normalize_header_name(k), to_string(v)} end)
{_, routing_key} = Enum.find(headers, {nil, ""}, &match?({@routing_key_header, _}, &1))
{_, method} = Enum.find(headers, {nil, "POST"}, &match?({@method_override_header, _}, &1))
# Renormalize some common headers that are used by usual plugs.
common_headers =
Enum.flat_map(headers, fn
{"amqp-content-encoding", v} -> [{"content-encoding", v}]
# Compatibility with Plug.Parsers
{"amqp-content-type", v} -> [{"content-type", v}]
# Compatibility with Plug.RequestId
{"amqp-message-id", v} -> [{"x-request-id", v}]
_ -> []
end)
%Plug.Conn{
adapter: {__MODULE__, {consumer_producer, payload}},
method: String.upcase(method),
owner: self(),
path_info: :binary.split(routing_key, ".", [:global, :trim_all]),
remote_ip: {0, 0, 0, 0},
req_headers: common_headers ++ headers,
request_path: "/" <> :binary.replace(routing_key, ".", "/", [:global])
}
end
defp normalize_header_name(name) do
name |> to_string() |> String.downcase() |> String.replace(~r|[^a-zA-Z0-9]+|, "-")
end
@impl true
def send_resp(req = {consumer_producer, _req_payload}, _status, headers, body) do
ConsumerProducer.send_resp(consumer_producer, body, headers)
{:ok, body, req}
end
@impl true
def send_file(_req, _status, _headers, _path, _offset, _length) do
raise UnsupportedError
end
@impl true
def send_chunked(_req, _status, _headers) do
raise UnsupportedError
end
@impl true
def chunk(_req, _body) do
raise UnsupportedError
end
@impl true
def read_req_body(req = {_endpoint, payload}, _opts) do
{:ok, payload, req}
end
@impl true
def inform(_req, _status, _headers) do
{:error, :not_supported}
end
@impl true
def push(_req, _path, _headers) do
{:error, :not_supported}
end
@impl true
def get_peer_data(_conn) do
%{address: {0, 0, 0, 0}, port: 0, ssl_cert: nil}
end
@impl true
def get_http_protocol(_req) do
:"AMQP-0-9-1"
end
end | lib/plug/amqp/conn.ex | 0.781372 | 0.444625 | conn.ex | starcoder |
defmodule XQLite3.Query do
defstruct [
:name,
:statement,
:ref,
:column_names,
:column_types
]
alias XQLite3.Result
alias __MODULE__, as: Query
defimpl DBConnection.Query do
def parse(query, _opts) do
query
end
def describe(query, _opts) do
query
end
@spec encode(any, [any], Keyword.t()) :: any
def encode(_query, params, _opts) do
Enum.map(params, fn
nil -> :undefined
true -> 1
false -> 0
date = %Date{} -> Date.to_string(date)
time = %Time{} -> Time.to_string(time)
datetime = %DateTime{} -> DateTime.to_string(datetime)
ndatetime = %NaiveDateTime{} -> NaiveDateTime.to_string(ndatetime)
other -> other
end)
end
def decode(
%Query{column_names: columns, column_types: types, statement: statement},
%{rows: rows, num_updated_rows: num_updated_rows, last_insert_id: last_insert_id},
_opts
) do
rows =
Enum.map(rows, fn row ->
row
|> Enum.zip(types)
|> Enum.map(&decode_col(&1))
end)
num_rows = if is_update?(statement), do: num_updated_rows, else: length(rows)
rows = if is_update?(statement), do: nil, else: rows
%Result{rows: rows, num_rows: num_rows, columns: columns, last_insert_id: last_insert_id}
end
def decode_col({:undefined, _}), do: nil
def decode_col({{:blob, blob}, _}), do: blob
def decode_col({val, type}) when type in ["bool", "boolean"], do: val == 1
def decode_col({val, type}) when type in ["time"], do: Time.from_iso8601!(val)
def decode_col({val, type}) when type in ["date"], do: Date.from_iso8601!(val)
@doc """
For e.g., CURRENT_TIMESTAMP SQLite returns the UTC datetime but with
no timezone specified. Here we make a best-effort of translating datetime columns
by first trying to parse it as a DateTime, and otherwise falling back to
parsing it as Naive and translating that to DateTime with the UTC zone.
Unfortunately, this means that any naive datetimes stored in the database will not be
returned as such. The application developer is responsible for shifting things as needed.
"""
def decode_col({val, type}) when type in ["datetime"] do
case DateTime.from_iso8601(val) do
{:ok, dt, _} ->
dt
{:error, _} ->
NaiveDateTime.from_iso8601!(val)
|> DateTime.from_naive!("Etc/UTC")
end
end
def decode_col({val, _type}), do: val
def is_update?(statement) do
String.match?(to_string(statement), ~r/(insert|update|delete)\s/i)
end
end
defimpl String.Chars do
def to_string(%XQLite3.Query{statement: statement}) do
IO.iodata_to_binary(statement)
end
end
end | lib/xqlite3/query.ex | 0.771499 | 0.442938 | query.ex | starcoder |
defmodule Adventofcode.IntcodeComputer do
alias __MODULE__.{Computer, Parameter, Program}
defmodule Parameter do
@enforce_keys [:value, :mode]
defstruct [:value, :mode]
def new(value, 0), do: new(value, :positional)
def new(value, 1), do: new(value, :immediate)
def new(value, 2), do: new(value, :relative)
def new(value, :positional = mode), do: do_new(value, mode)
def new(value, :immediate = mode), do: do_new(value, mode)
def new(value, :relative = mode), do: do_new(value, mode)
defp do_new(value, mode), do: %__MODULE__{value: value, mode: mode}
end
defmodule Program do
@enforce_keys [:addresses]
defstruct addresses: %{},
position: 0,
status: :idle,
outputs: [],
inputs: [],
fallback_input: 0,
relative_base: 0
def new(addresses) do
%__MODULE__{addresses: addresses}
end
def get(program, position) when position >= 0 do
Map.get(program.addresses, position, 0)
end
def put(program, %Parameter{mode: :relative, value: position}, val) do
put(program, position + program.relative_base, val)
end
def put(program, %Parameter{value: position}, value), do: put(program, position, value)
def put(program, position, value) do
%{program | addresses: Map.put(program.addresses, position, value)}
end
def shift_input_and_put_into(program, parameter) do
{input, program} = shift_input(program)
put(program, parameter, input)
end
def shift_input(%Program{inputs: [], fallback_input: nil} = program) do
{program.fallback_input, %{program | status: :waiting}}
end
def shift_input(%Program{inputs: []} = program), do: {program.fallback_input, program}
def shift_input(%Program{inputs: [input | inputs]} = program) do
{input, %{program | inputs: inputs}}
end
def jump(program, position) do
%{program | position: position}
end
def raw_instruction(program, position, amount) do
position..(position + amount)
|> Enum.to_list()
|> Enum.map(&get(program, &1))
end
def parse_instruction(%{position: position} = program) do
[opcode | args] = raw_instruction(program, position, 3)
modes = parse_modes(opcode)
params = build_params(args, modes)
opcode
|> rem(100)
|> prepare_instruction(params)
end
defp build_params(args, modes) do
[args, modes]
|> List.zip()
|> Enum.map(fn {arg, mode} -> Parameter.new(arg, mode) end)
end
defp parse_modes(opcode) do
opcode
|> div(100)
|> to_string
|> String.pad_leading(3, "0")
|> String.reverse()
|> String.graphemes()
|> Enum.map(&String.to_integer/1)
end
defp prepare_instruction(1, [param1, param2, param3]) do
{:add, [param1, param2, param3]}
end
defp prepare_instruction(2, [param1, param2, param3]) do
{:multiply, [param1, param2, param3]}
end
defp prepare_instruction(3, [param1 | _]) do
{:store, [param1]}
end
defp prepare_instruction(4, [param1 | _]) do
{:output, [param1]}
end
defp prepare_instruction(5, [param1, param2 | _]) do
{:jump_if_true, [param1, param2]}
end
defp prepare_instruction(6, [param1, param2 | _]) do
{:jump_if_false, [param1, param2]}
end
defp prepare_instruction(7, [param1, param2, param3]) do
{:less_than, [param1, param2, param3]}
end
defp prepare_instruction(8, [param1, param2, param3]) do
{:equals, [param1, param2, param3]}
end
defp prepare_instruction(9, [param1 | _]) do
{:adjust_relative_base, [param1]}
end
defp prepare_instruction(99, _args) do
{:halt, []}
end
def input(program, nil) do
program
end
def input(program, value) when is_number(value) do
inputs(program, [value])
end
def inputs(program, values) when is_list(values) do
%{program | inputs: program.inputs ++ values}
end
def fallback_input(program, value) do
%{program | fallback_input: value}
end
def output(program, value) do
%{program | outputs: [value | program.outputs]}
end
def value(program, %Parameter{value: position, mode: :positional}) do
get(program, position)
end
def value(_program, %Parameter{value: value, mode: :immediate}) do
value
end
def value(program, %Parameter{value: position, mode: :relative}) do
get(program, position + program.relative_base)
end
end
defmodule Computer do
alias Adventofcode.IntcodeComputer.Program
import Program, only: [value: 2]
def halt(program, []), do: %{program | status: :halted}
def add(program, [param1, param2, param3]) do
result = value(program, param1) + value(program, param2)
program
|> Program.put(param3, result)
|> Program.jump(program.position + 4)
end
def multiply(program, [param1, param2, param3]) do
result = value(program, param1) * value(program, param2)
program
|> Program.put(param3, result)
|> Program.jump(program.position + 4)
end
# Opcode 3 takes a single integer as input and saves it to the address given
# by its only parameter. For example, the instruction 3,50 would take an
# input value and store it at address 50.
def store(%{inputs: [], fallback_input: nil} = program, [_param1]) do
%{program | status: :waiting}
end
def store(program, [param1]) do
program
|> Program.shift_input_and_put_into(param1)
|> Program.jump(program.position + 2)
end
# Opcode 4 outputs the value of its only parameter. For example, the
# instruction 4,50 would output the value at address 50.
def output(program, [param1]) do
program
|> Program.output(value(program, param1))
|> Program.jump(program.position + 2)
end
# Opcode 5 is jump-if-true: if the first parameter is non-zero, it sets the
# instruction pointer to the value from the second parameter. Otherwise, it
# does nothing.
def jump_if_true(program, [param1, param2]) do
position =
if value(program, param1) == 0 do
program.position + 3
else
value(program, param2)
end
program
|> Program.jump(position)
end
# Opcode 6 is jump-if-false: if the first parameter is zero, it sets the
# instruction pointer to the value from the second parameter. Otherwise, it
# does nothing.
def jump_if_false(program, [param1, param2]) do
position =
if value(program, param1) == 0 do
value(program, param2)
else
program.position + 3
end
program
|> Program.jump(position)
end
# Opcode 7 is less than: if the first parameter is less than the second
# parameter, it stores 1 in the position given by the third parameter.
# Otherwise, it stores 0.
def less_than(program, [param1, param2, param3]) do
result =
if value(program, param1) < value(program, param2) do
1
else
0
end
program
|> Program.put(param3, result)
|> Program.jump(program.position + 4)
end
# Opcode 8 is equals: if the first parameter is equal to the second
# parameter, it stores 1 in the position given by the third parameter.
# Otherwise, it stores 0.
def equals(program, [param1, param2, param3]) do
result =
if value(program, param1) == value(program, param2) do
1
else
0
end
program
|> Program.put(param3, result)
|> Program.jump(program.position + 4)
end
# Opcode 9 adjusts the relative base by the value of its only parameter. The
# relative base increases (or decreases, if the value is negative) by the
# value of the parameter.
def adjust_relative_base(program, [param1]) do
relative_base = program.relative_base + value(program, param1)
program
|> Map.put(:relative_base, relative_base)
|> Program.jump(program.position + 2)
end
end
def run(%Program{status: :halted} = program), do: program
def run(%Program{status: :waiting} = program) do
%{program | status: :idle}
end
def run(%Program{status: :idle} = program) do
run(%{program | status: :running})
end
def run(program) do
{instruction, args} = Program.parse_instruction(program)
apply(Computer, instruction, [program, args])
|> run()
end
def parse(input) when is_binary(input) do
input
|> String.split(",")
|> Enum.map(&String.to_integer/1)
|> parse()
end
def parse(input) when is_list(input) do
input
|> Enum.with_index()
|> Enum.map(fn {val, pos} -> {pos, val} end)
|> Enum.into(%{})
|> Program.new()
end
def input(program, value) when is_number(value) do
Program.input(program, value)
end
def inputs(program, values) when is_list(values) do
Program.inputs(program, values)
end
def fallback_input(program, input) do
Program.fallback_input(program, input)
end
def output(%{outputs: []}), do: nil
def output(%{outputs: [output | _]}), do: output
def outputs(program), do: Enum.reverse(program.outputs)
def pop_outputs(program) do
{outputs(program), %{program | outputs: []}}
end
def put(program, key, value) do
Program.put(program, key, value)
end
end
defimpl Inspect, for: Adventofcode.IntcodeComputer.Program do
import Inspect.Algebra
def inspect(program, opts) do
opts = %Inspect.Opts{opts | charlists: :as_lists}
concat([
"#Program<",
to_string(program.status),
" (",
to_string(program.relative_base),
") ",
container_doc("[", inputs(program.inputs, program.fallback_input), "]", opts, &to_doc/2),
" => ",
to_doc(program.outputs, opts),
">"
])
end
defp inputs(inputs, nil), do: inputs
defp inputs(inputs, fallback_input), do: inputs ++ ["(#{fallback_input})"]
end | lib/intcode_computer.ex | 0.69451 | 0.562357 | intcode_computer.ex | starcoder |
defmodule Brex.Result.Mappers do
@moduledoc """
Tools for combining `Enum` and result tuples.
"""
import Brex.Result.Base
alias Brex.Result.Base
@type s(x) :: Base.s(x)
@type t(x) :: Base.t(x)
@type p() :: Base.p()
@type s() :: Base.s()
@type t() :: Base.t()
@typedoc """
The type `t:Enum.t/0` does not accept any arguments. This is a workaround to express the type of
an enumerable with elements restricted to a particular type.
"""
@type enumerable(x) :: [x] | Enum.t()
@doc """
Binds the function to each tuple in the enum.
## Example:
iex> [{:ok, 1}, {:ok, 2}, {:error, 3}, {:ok, 4}]
...> |> map_with_bind(fn x -> if x == 2, do: {:error, x*6}, else: {:ok, x*6} end)
[{:ok, 6}, {:error, 12}, {:error, 3}, {:ok, 24}]
"""
@doc since: "0.1.0"
@spec map_with_bind(enumerable(s(a)), (a -> s(b))) :: enumerable(s(b)) when a: var, b: var
def map_with_bind(l, f), do: Enum.map(l, &bind(&1, f))
@doc """
Given an enumerable of plain values,
it returns `{:ok, processed enum}` or the first `error`.
Equivalent to traverse or mapM in Haskell.
## Examples:
iex> [1, 2, 3, 4]
...> |> map_while_success(fn x -> if x == 3 || x == 1, do: {:error, x}, else: {:ok, x} end)
{:error, 1}
iex> map_while_success([1, 2, 3, 4], fn x -> {:ok, x + 2} end)
{:ok, [3, 4, 5, 6]}
"""
@doc since: "0.1.0"
@spec map_while_success(enumerable(a), (a -> t(b))) :: s(enumerable(b)) when a: var, b: var
def map_while_success(l, f) do
l
|> Enum.reduce_while({:ok, []}, fn x, acc ->
case f.(x) do
:ok -> {:cont, acc}
{:ok, val} -> {:cont, fmap(acc, &[val | &1])}
{:error, r} -> {:halt, {:error, r}}
end
end)
|> fmap(&Enum.reverse/1)
end
@doc """
Given an enum of plain values, an initial value, and a reducing function,
it returns the first `error` or reduced result.
## Examples:
iex> [1, 2, 3, 4]
...> |> reduce_while_success(100, &{:ok, &1 + &2})
{:ok, 110}
iex> [1, 2, 3, 4]
...> |> reduce_while_success(100, fn x, acc ->
...> if x > 2 do
...> {:error, x}
...> else
...> {:ok, x + acc}
...> end
...> end)
{:error, 3}
"""
@doc since: "0.3.0"
@spec reduce_while_success(enumerable(a), b, (a, b -> t(b))) :: t(b) when a: var, b: var
def reduce_while_success(ms, b, f) do
Enum.reduce_while(ms, {:ok, b}, fn a, acc ->
case bind(acc, &f.(a, &1)) do
{:ok, val} -> {:cont, {:ok, val}}
{:error, r} -> {:halt, {:error, r}}
end
end)
end
@doc """
Applies the function to each element of the enumerable until an error occurs.
No guarentee on the order of evaluation. (But usually backwards for lists.)
Only takes a function that returns `:ok | {:error, value}`.
## Examples:
iex> [1, 2, 3, 4]
...> |> each_while_success(fn x -> if x < 3, do: :ok, else: {:error, :too_big} end)
{:error, :too_big}
iex> [1, 2, 3, 4]
...> |> each_while_success(fn x -> if x < 5, do: :ok, else: {:error, :too_big} end)
:ok
"""
@doc since: "0.2.0"
@spec each_while_success(enumerable(a), (a -> p())) :: p() when a: var
def each_while_success(ms, f) do
Enum.reduce_while(ms, :ok, fn x, _acc ->
case f.(x) do
:ok -> {:cont, :ok}
{:error, r} -> {:halt, {:error, r}}
end
end)
end
end | lib/result/mappers.ex | 0.850391 | 0.500549 | mappers.ex | starcoder |
defmodule Bencoder.Decode do
@doc """
Decodes a binary and translates it into elixir objects.
Returns the decoded element.
`number` -> `Integer`
`string` -> `String`
`list` -> `List`
`dict` -> `Map`
"""
@spec decode(binary) :: term
def decode(data) do
{:ok, decoded, _} = data |> :binary.bin_to_list |> decode_element
decoded
end
@doc """
Decodes each element and returns a list with the non-consumed input
Returns `{ :ok, element, non_consumed }`
"""
@spec decode_element(List.binary) :: { :ok, List.t | Map.t | Integer | binary, List.binary }
defp decode_element(chars) do
case hd(chars) do
?i ->
decode_integer(chars)
?l ->
decode_list(chars)
?d ->
decode_dictionary(chars)
_ ->
decode_string(chars)
end
end
defp decode_integer(chars) do
digits = Enum.take_while(tl(chars), fn (x) -> x != ?e end)
{number, _} = ('0' ++ digits) |> to_string |> Integer.parse
{:ok, number, Enum.drop(chars, 2 + length(digits))}
end
defp decode_list(chars) do
decode_list_elements(tl(chars), [])
end
defp decode_list_elements(chars, z) do
case hd(chars) do
?e ->
{:ok, z, tl(chars)}
_ ->
{:ok, decoded, remaining} = decode_element(chars)
decode_list_elements(remaining, z ++ [decoded])
end
end
defp decode_dictionary(chars) do
decode_dictionary_elements(tl(chars), %{})
end
defp decode_dictionary_elements(chars, map) do
case hd(chars) do
?e ->
{:ok, map, tl(chars)}
_ ->
{:ok, decoded_key, remaining} = decode_element(chars)
{:ok, decoded_value, remaining} = decode_element(remaining)
decode_dictionary_elements(remaining, Map.put(map, decoded_key, decoded_value))
end
end
defp decode_string(binary) do
digits = Enum.take_while(binary, fn (x) -> x != ?: end)
{s, _} = digits |> to_string |> Integer.parse
word = Enum.drop(binary, length(digits) + 1)
{:ok, :binary.list_to_bin(Enum.take(word, s)), Enum.drop(word, s)}
end
end | lib/bencoder/decoder.ex | 0.880707 | 0.678177 | decoder.ex | starcoder |
defmodule Geohash do
@moduledoc ~S"""
Drop in replacement fot the Elixir native [Geohash encode/decode library](https://hexdocs.pm/geohash/) implemented as a NIF
## Basic Usage
```elixir
iex(1)> Geohash.encode(42.6, -5.6, 5)
"ezs42"
iex(1)> Geohash.encode(42.6, -5.6, 11)
"ezs42e44yx9"
iex(1)> Geohash.decode("ezs42")
{42.605, -5.603}
iex(1)> Geohash.neighbors("ezs42")
%{
"e" => "ezs43",
"n" => "ezs48",
"ne" => "ezs49",
"nw" => "ezefx",
"s" => "ezs40",
"se" => "ezs41",
"sw" => "ezefp",
"w" => "ezefr"
}
iex(1)> Geohash.adjacent("ezs42","n")
"ezs48"
iex(1)> Geohash.bounds("u4pruydqqv")
%{
max_lat: 57.649115324020386,
max_lon: 10.407443046569824,
min_lat: 57.649109959602356,
min_lon: 10.407432317733765
}
```
"""
alias Geohash.Nif
@doc ~S"""
Encodes given coordinates to a geohash of length `precision`
## Examples
```
iex> Geohash.encode(42.6, -5.6, 5)
"ezs42"
```
"""
defdelegate encode(latitude, longitude, precision \\ 11), to: Nif
@doc ~S"""
Decodes given geohash to a coordinate pair
## Examples
```
iex> {_lat, _lng} = Geohash.decode("ezs42")
{42.605, -5.603}
```
"""
defdelegate decode(hash), to: Nif
@doc ~S"""
Decodes given geohash to a bitstring
## Examples
```
iex> Geohash.decode_to_bits("ezs42")
<<0b0110111111110000010000010::25>>
```
"""
def decode_to_bits(hash) do
bits = Nif.decode_to_bits(hash)
bit_size = round(:math.log2(bits) + 1)
<<bits::size(bit_size)>>
end
@doc ~S"""
Calculates bounds for a given geohash
## Examples
```
iex> Geohash.bounds("u4pruydqqv")
%{
min_lon: 10.407432317733765,
min_lat: 57.649109959602356,
max_lon: 10.407443046569824,
max_lat: 57.649115324020386
}
```
"""
defdelegate bounds(hash), to: Nif
@doc ~S"""
Calculate adjacent hashes for the 8 touching `neighbors/2`
## Options
These options are specific to this function
* `:keys` -- controls how keys in objects are decoded. Possible values are:
* `:strings` (default) - decodes keys as binary strings (compatible mode)
* `:atoms` - decodes keys as atoms (fast mode)
## Examples
```
iex> Geohash.neighbors("6gkzwgjz")
%{
"n" => "6gkzwgmb",
"s" => "6gkzwgjy",
"e" => "6gkzwgnp",
"w" => "6gkzwgjx",
"ne" => "6gkzwgq0",
"se" => "6gkzwgnn",
"nw" => "6gkzwgm8",
"sw" => "6gkzwgjw"
}
iex> Geohash.neighbors("6gkzwgjz", keys: :atoms)
%{
n: "6gkzwgmb",
s: "6gkzwgjy",
e: "6gkzwgnp",
w: "6gkzwgjx",
ne: "6gkzwgq0",
se: "6gkzwgnn",
nw: "6gkzwgm8",
sw: "6gkzwgjw"
}
```
"""
def neighbors(hash, opts \\ [keys: :strings])
def neighbors(hash, keys: :strings) do
Nif.neighbors(hash)
end
def neighbors(hash, keys: :atoms) do
Nif.neighbors2(hash)
end
@doc ~S"""
Calculate `adjacent/2` geohash in ordinal direction `["n","s","e","w"]`.
## Examples
```
iex> Geohash.adjacent("ezs42","n")
"ezs48"
```
"""
defdelegate adjacent(hash, direction), to: Nif
end | lib/geohash.ex | 0.796609 | 0.825062 | geohash.ex | starcoder |
defmodule Randex do
@moduledoc """
Randex is a regex based random string generator.
## Example
```elixir
iex(1)> Randex.stream(~r/(1[0-2]|0[1-9])(:[0-5]\d){2} (A|P)M/) |> Enum.take(10)
["10:53:29 AM", "02:54:11 AM", "09:23:04 AM", "10:41:57 AM", "11:42:13 AM",
"10:27:37 AM", "06:15:18 AM", "03:09:58 AM", "09:15:06 AM", "04:25:28 AM"]
```
## Unsupported Features
* [Atomic Grouping and Possessive
Quantifiers](http://erlang.org/doc/man/re.html#sect15)
* [Recursive Patterns](http://erlang.org/doc/man/re.html#sect20)
* [Conditional Subpatterns](http://erlang.org/doc/man/re.html#sect18)
* [Subpatterns as
Subroutines](http://erlang.org/doc/man/re.html#sect21)
* [Backtracking Control](http://erlang.org/doc/man/re.html#sect23)
"""
alias Randex.Generator.Config
@doc ~S"""
Generates random strings that match the given regex
### Options
* max_repetition: (integer) There is no upper limit for some of the
quantifiers like `+`, `*` etc. This config specifies how the upper
limit should be calculated in these cases. The range is calculated
as `min..(min + max_repetition)`. Defaults to `100`.
* mod: (module) The library comes with 3 different types of
generators. Defaults to `Randex.Generator.Random`
`Randex.Generator.Random` - Generates the string in a random manner.
`Randex.Generator.DFS` - This does a depth first traversal. This could be used to generate all possible strings in a systematic manner.
`Randex.Generator.StreamData` - This is built on top of the `StreamData` generators. It could be used as a generator in property testing. Note: this generator might not work well with complicated lookahead or lookbehind expressions.
"""
@spec stream(Regex.t() | String.t()) :: Enumerable.t()
def stream(regex, options \\ []) do
regex =
cond do
is_binary(regex) -> Regex.compile!(regex)
Regex.regex?(regex) -> regex
true -> raise ArgumentError, "Invalid regex: #{inspect(regex)}"
end
source = Regex.source(regex)
source =
case Regex.opts(regex) do
"" -> source
opts -> "(?#{opts})#{source}"
end
config = Map.merge(%Config{}, Enum.into(options, %{}))
Randex.Parser.parse(source)
|> Randex.Generator.gen(config)
end
end | lib/randex.ex | 0.797281 | 0.803983 | randex.ex | starcoder |
defmodule Bolt.Sips.ResponseEncoder do
@moduledoc """
This module provides functions to encode a query result or data containing Bolt.Sips.Types
into various format.
For now, only JSON is supported.
Encoding is handled by protocols to allow override if a specific implemention is required.
See targeted protocol documentation for more information
"""
@doc """
Encode the data in json format.
This is done is 2 steps:
- first, the data is converted into a jsonable format
- the result is encoded in json via Jason
Both of these steps are overridable, see:
- for step 1: `Bolt.Sips.ResponseEncoder.Json`
- for step 2 (depending of your preferred library):
- `Bolt.Sips.ResponseEncoder.Json.Jason`
- `Bolt.Sips.ResponseEncoder.Json.Poison`
## Example
iex> data = %{"t1" => %Bolt.Sips.Types.Node{
...> id: 69,
...> labels: ["Test"],
...> properties: %{
...> "created" => %Bolt.Sips.Types.DateTimeWithTZOffset{
...> naive_datetime: ~N[2016-05-24 13:26:08.543],
...> timezone_offset: 7200
...> },
...> "uuid" => 12345
...> }
...> }
...> }
iex> Bolt.Sips.ResponseEncoder.encode(data, :json)
{:ok, ~S|{"t1":{"id":69,"labels":["Test"],"properties":{"created":"2016-05-24T13:26:08.543+02:00","uuid":12345}}}|}
iex> Bolt.Sips.ResponseEncoder.encode("\\xFF", :json)
{:error, %Jason.EncodeError{message: "invalid byte 0xFF in <<255>>"}}
"""
@spec encode(any(), :json) ::
{:ok, String.t()} | {:error, Jason.EncodeError.t() | Exception.t()}
def encode(response, :json) do
response
|> jsonable_response()
|> Jason.encode()
end
@doc """
Encode the data in json format.
Similar to `encode/1` except it will unwrap the error tuple and raise in case of errors.
## Example
iex> data = %{"t1" => %Bolt.Sips.Types.Node{
...> id: 69,
...> labels: ["Test"],
...> properties: %{
...> "created" => %Bolt.Sips.Types.DateTimeWithTZOffset{
...> naive_datetime: ~N[2016-05-24 13:26:08.543],
...> timezone_offset: 7200
...> },
...> "uuid" => 12345
...> }
...> }
...> }
iex> Bolt.Sips.ResponseEncoder.encode!(data, :json)
~S|{"t1":{"id":69,"labels":["Test"],"properties":{"created":"2016-05-24T13:26:08.543+02:00","uuid":12345}}}|
iex> Bolt.Sips.ResponseEncoder.encode!("\\xFF", :json)
** (Jason.EncodeError) invalid byte 0xFF in <<255>>
"""
@spec encode!(any(), :json) :: String.t() | no_return()
def encode!(response, :json) do
response
|> jsonable_response()
|> Jason.encode!()
end
defp jsonable_response(response) do
response
|> Bolt.Sips.ResponseEncoder.Json.encode()
end
end | lib/bolt_sips/response_encoder.ex | 0.888879 | 0.55917 | response_encoder.ex | starcoder |
defmodule Geocoder.Providers.OpenCageData do
use Tesla
plug(Tesla.Middleware.BaseUrl, "https://maps.googleapis.com")
plug(Tesla.Middleware.Query,
key: Application.fetch_env!(:geocoder, Geocoder.Providers.OpenCageData)[:key],
pretty: 1
)
plug(Tesla.Middleware.JSON)
@path_geocode "/geocode/v1/json"
@field_mapping %{
"house_number" => :street_number,
"road" => :street,
"city" => :city,
"state" => :state,
"county" => :county,
"postcode" => :postal_code,
"country" => :country,
"country_code" => :country_code
}
def geocode(opts) do
with {:ok, %Tesla.Env{status: 200, body: body}} <-
get(@path_geocode, query: build_request_params(opts)) do
body |> transform_response()
else
_ -> :error
end
end
defdelegate reverse_geocode(opts), to: __MODULE__, as: :geocode
defp build_request_params(opts) do
opts
|> Keyword.take([
:bounds,
:language,
:add_request,
:countrycode,
:jsonp,
:limit,
:min_confidence,
:no_annotations,
:no_dedupe
])
|> Keyword.put(
:q,
case opts |> Keyword.take([:address, :latlng]) |> Keyword.values() do
[{lat, lon}] -> "#{lat},#{lon}"
[query] -> query
_ -> nil
end
)
end
def transform_response(%{"results" => [result | _]}) do
coords = retrieve_coords(result)
bounds = retrieve_bounds(result)
location = retrieve_location(result)
{:ok, %{coords | bounds: bounds, location: location}}
end
defp retrieve_coords(%{
"geometry" => %{
"lat" => lat,
"lng" => lon
}
}) do
%Geocoder.Coords{lat: lat, lon: lon}
end
defp retrieve_location(%{"components" => components, "formatted" => formatted_address}) do
components
|> Enum.reduce(
%Geocoder.Location{formatted_address: formatted_address},
fn {type, value}, acc ->
struct(acc, [{@field_mapping[type], value}])
end
)
end
defp retrieve_bounds(%{
"bounds" => %{
"northeast" => %{
"lat" => north,
"lng" => east
},
"southwest" => %{
"lat" => south,
"lng" => west
}
}
}) do
%Geocoder.Bounds{top: north, right: east, bottom: south, left: west}
end
defp retrieve_bounds(_), do: %Geocoder.Bounds{}
end | lib/geocoder/providers/open_cage_data.ex | 0.657209 | 0.432842 | open_cage_data.ex | starcoder |
defmodule Calypte.Engine.NaiveFirst do
@moduledoc """
Implements naive algorithm for finding applicable rules.
It uses basic tree search first match algorithm for finding applicable node using type optimization.
"""
alias Calypte.{Binding, Graph, Rule, Utils}
alias Calypte.Ast.{Relation, Var}
import Utils
@behaviour Calypte.Engine
defstruct executed: %{}, rules: []
@impl true
def init(_graph), do: %__MODULE__{}
@impl true
def add_rules(%{rules: rules} = state, new_rules), do: %{state | rules: new_rules ++ rules}
@impl true
def delete_rules(%{rules: rules} = state, rule_ids) do
%{state | rules: Enum.filter(rules, &(not (Rule.id(&1) in rule_ids)))}
end
@impl true
def add_exec_change(%{executed: executed} = state, {rule_id, hash}, _) do
%{state | executed: deep_put(executed, [rule_id, hash], true)}
end
@impl true
def del_exec_change(%{executed: executed} = state, {rule_id, hash}, _) do
%{^hash => true} = rule_execs = executed[rule_id]
cond do
map_size(rule_execs) == 1 -> %{state | executed: Map.delete(executed, rule_id)}
true -> %{state | executed: executed |> pop_in([rule_id, hash]) |> elem(1)}
end
end
@impl true
def add_change(state, _), do: state
@impl true
def eval(%{rules: rules} = state, graph) do
{search(rules, graph, state), state}
end
def search([], _graph, _state), do: []
def search([%Rule{if: if_ast} = rule | rules], graph, state) do
with [] <- find_binding(if_ast, graph, Binding.init(graph, rule), state) do
search(rules, graph, state)
end
end
@doc """
Simple find of binding using sequential unfolding of matches
"""
def find_binding([], _graph, %Binding{} = binding, state) do
binding = Binding.calc_hash(binding)
if executed?(state, binding), do: [], else: [binding]
end
def find_binding([%Var{name: name, type: type} | matches], graph, binding, state)
when is_binary(type) do
candidates = Graph.get_typed(graph, type)
%{types: types} = binding
binding = %{binding | types: Map.put(types, name, type)}
check_branches(name, candidates, matches, graph, binding, state)
end
def find_binding([%Relation{} = relation | matches], graph, binding, state) do
%Relation{from: %Var{name: from_var}, to: %Var{name: to_var, type: type}, edge: edge} =
relation
%{nodes: nodes, types: types} = binding
binding = %{binding | types: Map.put(types, to_var, type)}
edges = Graph.related(graph, nodes[from_var], edge)
candidates = Graph.get_typed(graph, type, edges)
check_branches(to_var, candidates, matches, graph, binding, state)
end
def find_binding([expr | matches], graph, binding, state) do
check_bindings(matches, graph, Rule.match(expr, binding), state)
end
def check_branches(_, [], _matches, _graph, _binding, _state), do: []
def check_branches(name, [candidate | candidates], matches, graph, binding, state) do
%Binding{nodes: nodes} = binding
node = Graph.get_node(graph, candidate)
new_binding = %Binding{binding | nodes: Map.put(nodes, name, node)}
with [] <- find_binding(matches, graph, new_binding, state),
do: check_branches(name, candidates, matches, graph, binding, state)
end
def check_bindings(_matches, _graph, [], _state), do: []
def check_bindings(matches, graph, [binding | next_bindings], state) do
with [] <- find_binding(matches, graph, binding, state),
do: check_bindings(matches, graph, next_bindings, state)
end
def executed?(%{executed: executed} = _state, %Binding{rule: rule, hash: hash}) do
executed[Rule.id(rule)][hash]
end
end | lib/calypte/engine/naive_first.ex | 0.77768 | 0.481881 | naive_first.ex | starcoder |
defmodule Genex.Tools.Benchmarks.SymbolicRegression do
@moduledoc """
Provides benchmark functions for Symbolic Regression programs with Genetic Programming.
These functions haven't been tested. More documentation/testing is coming later.
"""
@doc """
Kotanchek benchmark.
Returns ```math```.
# Parameters
- `x`: `number`.
- `y`: `number`.
"""
def kotanchek(x, y) do
(1 - x)
|> :math.pow(2)
|> :math.exp()
|> Kernel./(
3.2
|> Kernel.+(:math.pow(y - 2.5, 2))
)
end
@doc """
Salustowicz 1-D benchmark function.
Returns ```math```.
# Parameters
- `x`: `number`.
"""
def salustowicz_1d(x) do
-x
|> :math.exp()
|> Kernel.*(:math.pow(x, 3))
|> Kernel.*(:math.cos(x))
|> Kernel.*(:math.sin(x))
|> Kernel.*(
x
|> :math.cos()
|> Kernel.*(:math.pow(:math.sin(x), 2))
|> Kernel.-(1)
)
end
@doc """
Salustowicz 2-D benchmark function.
Returns ```math```.
# Parameters
- `x`: `number`.
- `y`: `number`.
"""
def salustowicz_2d(x, y) do
-x
|> :math.exp()
|> Kernel.*(:math.pow(x, 3))
|> Kernel.*(:math.cos(x))
|> Kernel.*(:math.sin(x))
|> Kernel.*(
x
|> :math.cos()
|> Kernel.*(:math.pow(:math.sin(x), 2))
|> Kernel.-(1)
)
|> Kernel.*(y - 5)
end
@doc """
Unwrapped Ball benchmark function.
Returns ```math```.
# Parameters
- `xs`: `Enum` of `number`.
"""
def unwrapped_ball(xs) do
10
|> Kernel./(
5
|> Kernel.+(
xs
|> Enum.map(&:math.pow(&1 - 3, 2))
|> Enum.sum()
)
)
end
@doc """
Rational polynomial benchmark functon.
Returns ```math```.
# Parameters
- `x`: `number`.
- `y`: `number`.
- `z`: `number`.
"""
def rational_polynomial(x, y, z) do
30
|> Kernel.*(x - 1)
|> Kernel.*(z - 1)
|> Kernel./(
y
|> :math.pow(2)
|> Kernel.*(x - 10)
)
end
@doc """
Rational polynomial in 2 dimensions benchmark function.
Returns ```math```.
# Parameters
- `x`: `number`.
- `y`: `number`.
"""
def rational_polynomial2(x, y) do
x
|> Kernel.-(3)
|> :math.pow(4)
|> Kernel.+(:math.pow(y - 3, 3))
|> Kernel.-(y - 3)
|> Kernel./(
(y - 2)
|> :math.pow(4)
|> Kernel.+(10)
)
end
@doc """
Sine-Cosine benchmark function.
Returns ```math```.
# Parameters
- `x`: `number`.
- `y`: `number`.
"""
def sin_cos(x, y) do
6
|> Kernel.*(:math.sin(x))
|> Kernel.*(:math.cos(y))
end
@doc """
Ripple benchmark function.
Returns ```math```.
# Parameters
- `x`: `number`
- `y`: `number`
"""
def ripple(x, y) do
(x - 3)
|> Kernel.*(y - 3)
|> Kernel.+(
2
|> Kernel.*(
(x - 4)
|> Kernel.*(y - 4)
|> :math.sin()
)
)
end
end | lib/genex/tools/benchmarks/symbolic_regression.ex | 0.911323 | 0.968768 | symbolic_regression.ex | starcoder |
defmodule Kalevala.Output.Tables.Tag do
@moduledoc false
defstruct [:name, attributes: %{}, children: []]
def append(tag, child) do
%{tag | children: tag.children ++ [child]}
end
end
defmodule Kalevala.Output.Tables do
@moduledoc """
Process table tags into ANSI tables
Processes 3 tags, `{table}`, `{row}`, and `{cell}`.
Tables are automatically balanced and text in cells are centered.
Example table:
```
{table}
{row}
{cell}Player Name{/cell}
{/row}
{row}
{cell}HP{/cell}
{cell}{color foreground="red"}50/50{/color}{/cell}
{/row}
{/table}
```
# `{table}` Tag
This tag starts a new table. It can _only_ contain `{row}` tags as children. Any
whitespace is trimmed and ignored inside the table.
# `{row}` Tag
This tag starts a new row. It can _only_ contain `{cell}` tags as children. Any
whitespace is trimmed and ignored inside the row.
# `{cell}` Tag
This tag is a cell. It can contain strings and other tags that don't increase
the width of the cell, e.g. color tags. Anything other than a string is not
used to calculate the width of the cell, which is used for balacing the table.
"""
use Kalevala.Output
import Kalevala.Character.View.Macro, only: [sigil_i: 2]
alias Kalevala.Character.View
alias Kalevala.Output.Tables.Tag
@impl true
def init(opts) do
%Context{
data: [],
opts: opts,
meta: %{
current_tag: :empty,
tag_stack: []
}
}
end
@impl true
def parse({:open, "table", attributes}, context) do
parse_open(context, :table, attributes)
end
def parse({:open, "row", attributes}, context) do
parse_open(context, :row, attributes)
end
def parse({:open, "cell", attributes}, context) do
parse_open(context, :cell, attributes)
end
def parse({:close, "table"}, context) do
parse_close(context)
end
def parse({:close, "row"}, context) do
parse_close(context)
end
def parse({:close, "cell"}, context) do
parse_close(context)
end
def parse(datum, context) do
case context.meta.current_tag == :empty do
true ->
Map.put(context, :data, context.data ++ [datum])
false ->
current_tag = Tag.append(context.meta.current_tag, datum)
meta = Map.put(context.meta, :current_tag, current_tag)
Map.put(context, :meta, meta)
end
end
defp parse_open(context, tag, attributes) do
tag_stack = [context.meta.current_tag | context.meta.tag_stack]
meta =
context.meta
|> Map.put(:current_tag, %Tag{name: tag, attributes: attributes})
|> Map.put(:tag_stack, tag_stack)
Map.put(context, :meta, meta)
end
defp parse_close(context) do
[new_current | tag_stack] = context.meta.tag_stack
current_tag = context.meta.current_tag
current_tag = %{current_tag | children: current_tag.children}
case new_current do
:empty ->
meta =
context.meta
|> Map.put(:current_tag, :empty)
|> Map.put(:tag_stack, tag_stack)
context
|> Map.put(:data, context.data ++ [current_tag])
|> Map.put(:meta, meta)
new_current ->
meta =
context.meta
|> Map.put(:current_tag, Tag.append(new_current, current_tag))
|> Map.put(:tag_stack, tag_stack)
Map.put(context, :meta, meta)
end
end
@impl true
def post_parse(context) do
data =
context.data
|> table_breathing_room()
|> Enum.map(&parse_data/1)
case Enum.any?(data, &match?(:error, &1)) do
true ->
:error
false ->
Map.put(context, :data, data)
end
end
@doc """
Give table tags some "breathing" room
- If there is text before the table and no newline, then make a new line
- If there is text after the table and no newline, then make a new line
"""
def table_breathing_room([]), do: []
def table_breathing_room([datum, table = %Tag{name: :table} | data]) do
case String.ends_with?(datum, "\n") || datum == "" do
true ->
[datum | table_breathing_room([table | data])]
false ->
[datum, "\n" | table_breathing_room([table | data])]
end
end
def table_breathing_room([table = %Tag{name: :table}, datum | data]) do
case String.starts_with?(datum, "\n") || datum == "" do
true ->
[table | table_breathing_room([datum | data])]
false ->
[table, "\n" | table_breathing_room([datum | data])]
end
end
def table_breathing_room([datum | data]) do
[datum | table_breathing_room(data)]
end
defp parse_data(%Tag{name: :table, children: children}) do
parse_table(children)
end
defp parse_data(datum), do: datum
defp parse_table(rows) do
rows =
rows
|> trim_children()
|> Enum.map(fn row ->
cells = trim_children(row.children)
%{row | children: cells}
end)
case valid_rows?(rows) do
true ->
display_rows(rows)
false ->
:error
end
end
defp trim_children([]), do: []
defp trim_children([child | children]) when is_binary(child) do
child = String.trim(child)
case child == "" do
true ->
trim_children(children)
false ->
[child | trim_children(children)]
end
end
defp trim_children([child = %Tag{} | children]) do
[child | trim_children(children)]
end
@doc """
Validate rows in a table (are all row tags and have valid cells)
"""
def valid_rows?(rows) do
Enum.all?(rows, fn row ->
match?(%Tag{name: :row}, row) && valid_cells?(row.children)
end)
end
@doc """
Validate cells in a row (are all cell tags)
"""
def valid_cells?(cells) do
Enum.all?(cells, fn cell ->
match?(%Tag{name: :cell}, cell)
end)
end
@doc """
Display a table
"""
def display_rows(rows) do
width = max_width(rows)
split_row = Enum.join(Enum.map(0..(width - 1), fn _i -> "-" end), "")
rows = Enum.map(rows, &display_row(&1, width, split_row))
[
~i(+#{split_row}+\n),
View.join(rows, "\n")
]
end
@doc """
Display a row's cells
"""
def display_row(row, max_width, split_row) do
width_difference = max_width - row_width(row)
cell_padding = Float.floor(width_difference / Enum.count(row.children))
[
"| ",
View.join(display_cells(row.children, cell_padding), " | "),
" |\n",
["+", split_row, "+"]
]
end
@doc """
Display a cell's contents
Pads the left and right, "pulls" left when centering (if an odd number)
"""
def display_cells(cells, cell_padding) do
left_padding = cell_padding(Float.floor(cell_padding / 2))
right_padding = cell_padding(Float.ceil(cell_padding / 2))
Enum.map(cells, fn cell ->
[left_padding, cell.children, right_padding]
end)
end
@doc """
Build a list of padding spaces for a side of a cell
"""
def cell_padding(0.0), do: []
def cell_padding(cell_padding) do
Enum.map(1..trunc(cell_padding), fn _i ->
" "
end)
end
@doc """
Find the max width of rows in a table
"""
def max_width(rows) do
rows
|> Enum.max_by(&row_width/1)
|> row_width()
end
@doc """
Get the total width of a row
Each cell tracks it's string width, plus 3 for built in padding
"""
def row_width(row) do
# - 1 for not tracking the final "|" of the row
Enum.reduce(row.children, 0, fn cell, width ->
children = Enum.filter(cell.children, &is_binary/1)
# + 1 for cell barrier
# + 2 for cell padding
Enum.reduce(children, width, fn elem, width ->
String.length(elem) + width
end) + 3
end) - 1
end
end | lib/kalevala/output/tables.ex | 0.862511 | 0.844409 | tables.ex | starcoder |
defmodule Absinthe.Utils do
@doc """
Camelize a word, respecting underscore prefixes.
## Examples
With an uppercase first letter:
```
iex> camelize("foo_bar")
"FooBar"
iex> camelize("foo")
"Foo"
iex> camelize("__foo_bar")
"__FooBar"
iex> camelize("__foo")
"__Foo"
iex> camelize("_foo")
"_Foo"
```
With a lowercase first letter:
```
iex> camelize("foo_bar", lower: true)
"fooBar"
iex> camelize("foo", lower: true)
"foo"
iex> camelize("__foo_bar", lower: true)
"__fooBar"
iex> camelize("__foo", lower: true)
"__foo"
iex> camelize("_foo", lower: true)
"_foo"
```
"""
@spec camelize(binary, Keyword.t) :: binary
def camelize(word, opts \\ [])
def camelize("_" <> word, opts) do
"_" <> camelize(word, opts)
end
def camelize(word, opts) do
case opts |> Enum.into(%{}) do
%{lower: true} ->
{first, rest} = String.split_at(Macro.camelize(word), 1)
String.downcase(first) <> rest
_ ->
Macro.camelize(word)
end
end
@doc false
def placement_docs([{_, placement} | _]) do
placement
|> do_placement_docs
end
defp do_placement_docs([toplevel: true]) do
"""
Top level in module.
"""
end
defp do_placement_docs([toplevel: false]) do
"""
Allowed under any block. Not allowed to be top level
"""
end
defp do_placement_docs([under: under]) when is_list(under) do
under = under
|> Enum.sort_by(&(&1))
|> Enum.map(&"`#{&1}`")
|> Enum.join(" ")
"""
Allowed under: #{under}
"""
end
defp do_placement_docs([under: under]) do
do_placement_docs([under: [under]])
end
@doc false
def describe_builtin_module(module) do
title = module
|> Module.split
|> List.last
types = module.__absinthe_types__
|> Map.keys
|> Enum.sort_by(&(&1))
|> Enum.map(fn identifier ->
type = module.__absinthe_type__(identifier)
"""
## #{type.name}
Identifier: `#{inspect identifier}`
#{type.description}
"""
end)
directives = module.__absinthe_directives__
|> Map.keys
|> Enum.sort_by(&(&1))
|> Enum.map(fn identifier ->
directive = module.__absinthe_directive__(identifier)
"""
## #{directive.name}
Identifier: `#{inspect identifier}`
#{directive.description}
"""
end)
"""
# #{title}
#{types ++ directives}
"""
end
end | lib/absinthe/utils.ex | 0.881863 | 0.690076 | utils.ex | starcoder |
defmodule System do
@moduledoc """
The `System` module provides functions that interact directly
with the VM or the host system.
## Time
The `System` module also provides functions that work with time,
returning different times kept by the system with support for
different time units.
One of the complexities in relying on system times is that they
may be adjusted. For example, when you enter and leave daylight
saving time, the system clock will be adjusted, often adding
or removing one hour. We call such changes "time warps". In
order to understand how such changes may be harmful, imagine
the following code:
## DO NOT DO THIS
prev = System.os_time()
# ... execute some code ...
next = System.os_time()
diff = next - prev
If, while the code is executing, the system clock changes,
some code that executed in 1 second may be reported as taking
over 1 hour! To address such concerns, the VM provides a
monotonic time via `System.monotonic_time/0` which never
decreases and does not leap:
## DO THIS
prev = System.monotonic_time()
# ... execute some code ...
next = System.monotonic_time()
diff = next - prev
Generally speaking, the VM provides three time measurements:
* `os_time/0` - the time reported by the operating system (OS). This time may be
adjusted forwards or backwards in time with no limitation;
* `system_time/0` - the VM view of the `os_time/0`. The system time and operating
system time may not match in case of time warps although the VM works towards
aligning them. This time is not monotonic (i.e., it may decrease)
as its behaviour is configured [by the VM time warp
mode](http://www.erlang.org/doc/apps/erts/time_correction.html#Time_Warp_Modes);
* `monotonic_time/0` - a monotonically increasing time provided
by the Erlang VM.
The time functions in this module work in the `:native` unit
(unless specified otherwise), which is operating system dependent. Most of
the time, all calculations are done in the `:native` unit, to
avoid loss of precision, with `convert_time_unit/3` being
invoked at the end to convert to a specific time unit like
`:millisecond` or `:microsecond`. See the `t:time_unit/0` type for
more information.
For a more complete rundown on the VM support for different
times, see the [chapter on time and time
correction](http://www.erlang.org/doc/apps/erts/time_correction.html)
in the Erlang docs.
"""
@typedoc """
The time unit to be passed to functions like `monotonic_time/1` and others.
The `:second`, `:millisecond`, `:microsecond` and `:nanosecond` time
units controls the return value of the functions that accept a time unit.
A time unit can also be a strictly positive integer. In this case, it
represents the "parts per second": the time will be returned in `1 /
parts_per_second` seconds. For example, using the `:millisecond` time unit
is equivalent to using `1000` as the time unit (as the time will be returned
in 1/1000 seconds - milliseconds).
"""
@type time_unit ::
:second
| :millisecond
| :microsecond
| :nanosecond
| pos_integer
@base_dir :filename.join(__DIR__, "../../..")
@version_file :filename.join(@base_dir, "VERSION")
defp strip(iodata) do
:re.replace(iodata, "^[\s\r\n\t]+|[\s\r\n\t]+$", "", [:global, return: :binary])
end
defp read_stripped(path) do
case :file.read_file(path) do
{:ok, binary} ->
strip(binary)
_ ->
""
end
end
# Read and strip the version from the VERSION file.
defmacrop get_version do
case read_stripped(@version_file) do
"" -> raise "could not read the version number from VERSION"
data -> data
end
end
# Returns OTP version that Elixir was compiled with.
defmacrop get_otp_release do
:erlang.list_to_binary(:erlang.system_info(:otp_release))
end
# Tries to run "git rev-parse --short=7 HEAD". In the case of success returns
# the short revision hash. If that fails, returns an empty string.
defmacrop get_revision do
null =
case :os.type() do
{:win32, _} -> 'NUL'
_ -> '/dev/null'
end
'git rev-parse --short=7 HEAD 2> '
|> Kernel.++(null)
|> :os.cmd()
|> strip
end
defp revision, do: get_revision()
# Get the date at compilation time.
# Follows https://reproducible-builds.org/specs/source-date-epoch/
defmacrop get_date do
unix_epoch =
if source_date_epoch = :os.getenv('SOURCE_DATE_EPOCH') do
try do
List.to_integer(source_date_epoch)
rescue
_ -> nil
end
end
unix_epoch = unix_epoch || :os.system_time(:second)
{{year, month, day}, {hour, minute, second}} =
:calendar.gregorian_seconds_to_datetime(unix_epoch + 62_167_219_200)
"~4..0b-~2..0b-~2..0bT~2..0b:~2..0b:~2..0bZ"
|> :io_lib.format([year, month, day, hour, minute, second])
|> :erlang.iolist_to_binary()
end
@doc """
Returns the endianness.
"""
@spec endianness() :: :little | :big
def endianness do
:erlang.system_info(:endian)
end
@doc """
Returns the endianness the system was compiled with.
"""
@endianness :erlang.system_info(:endian)
@spec compiled_endianness() :: :little | :big
def compiled_endianness do
@endianness
end
@doc """
Elixir version information.
Returns Elixir's version as binary.
"""
@spec version() :: String.t()
def version, do: get_version()
@doc """
Elixir build information.
Returns a map with the Elixir version, the Erlang/OTP release it was compiled
with, a short Git revision hash and the date and time it was built.
Every value in the map is a string, and these are:
* `:build` - the Elixir version, short Git revision hash and
Erlang/OTP release it was compiled with
* `:date` - a string representation of the ISO8601 date and time it was built
* `:otp_release` - OTP release it was compiled with
* `:revision` - short Git revision hash. If Git was not available at building
time, it is set to `""`
* `:version` - the Elixir version
One should not rely on the specific formats returned by each of those fields.
Instead one should use specialized functions, such as `version/0` to retrieve
the Elixir version and `otp_release/0` to retrieve the Erlang/OTP release.
## Examples
iex> System.build_info()
%{
build: "1.9.0-dev (772a00a0c) (compiled with Erlang/OTP 21)",
date: "2018-12-24T01:09:21Z",
otp_release: "21",
revision: "772a00a0c",
version: "1.9.0-dev"
}
"""
@spec build_info() :: %{
build: String.t(),
date: String.t(),
revision: String.t(),
version: String.t(),
otp_release: String.t()
}
def build_info do
%{
build: build(),
date: get_date(),
revision: revision(),
version: version(),
otp_release: get_otp_release()
}
end
# Returns a string of the build info
defp build do
{:ok, v} = Version.parse(version())
revision_string = if v.pre != [] and revision() != "", do: " (#{revision()})", else: ""
otp_version_string = " (compiled with Erlang/OTP #{get_otp_release()})"
version() <> revision_string <> otp_version_string
end
@doc """
Lists command line arguments.
Returns the list of command line arguments passed to the program.
"""
@spec argv() :: [String.t()]
def argv do
:elixir_config.get(:argv)
end
@doc """
Modifies command line arguments.
Changes the list of command line arguments. Use it with caution,
as it destroys any previous argv information.
"""
@spec argv([String.t()]) :: :ok
def argv(args) do
:elixir_config.put(:argv, args)
end
@doc """
Marks if the system should halt or not at the end of ARGV processing.
"""
@doc since: "1.9.0"
@spec no_halt(boolean) :: :ok
def no_halt(boolean) when is_boolean(boolean) do
:elixir_config.put(:no_halt, boolean)
end
@doc """
Checks if the system will halt or not at the end of ARGV processing.
"""
@doc since: "1.9.0"
@spec no_halt() :: boolean
def no_halt() do
:elixir_config.get(:no_halt)
end
@doc """
Current working directory.
Returns the current working directory or `nil` if one
is not available.
"""
@deprecated "Use File.cwd/0 instead"
@spec cwd() :: String.t() | nil
def cwd do
case File.cwd() do
{:ok, cwd} -> cwd
_ -> nil
end
end
@doc """
Current working directory, exception on error.
Returns the current working directory or raises `RuntimeError`.
"""
@deprecated "Use File.cwd!/0 instead"
@spec cwd!() :: String.t()
def cwd! do
case File.cwd() do
{:ok, cwd} ->
cwd
_ ->
raise "could not get a current working directory, the current location is not accessible"
end
end
@doc """
User home directory.
Returns the user home directory (platform independent).
"""
@spec user_home() :: String.t() | nil
def user_home do
:elixir_config.get(:home)
end
@doc """
User home directory, exception on error.
Same as `user_home/0` but raises `RuntimeError`
instead of returning `nil` if no user home is set.
"""
@spec user_home!() :: String.t()
def user_home! do
user_home() || raise "could not find the user home, please set the HOME environment variable"
end
@doc ~S"""
Writable temporary directory.
Returns a writable temporary directory.
Searches for directories in the following order:
1. the directory named by the TMPDIR environment variable
2. the directory named by the TEMP environment variable
3. the directory named by the TMP environment variable
4. `C:\TMP` on Windows or `/tmp` on Unix
5. as a last resort, the current working directory
Returns `nil` if none of the above are writable.
"""
@spec tmp_dir() :: String.t() | nil
def tmp_dir do
write_env_tmp_dir('TMPDIR') || write_env_tmp_dir('TEMP') || write_env_tmp_dir('TMP') ||
write_tmp_dir('/tmp') || write_cwd_tmp_dir()
end
defp write_cwd_tmp_dir do
case File.cwd() do
{:ok, cwd} -> write_tmp_dir(cwd)
_ -> nil
end
end
@doc """
Writable temporary directory, exception on error.
Same as `tmp_dir/0` but raises `RuntimeError`
instead of returning `nil` if no temp dir is set.
"""
@spec tmp_dir!() :: String.t()
def tmp_dir! do
tmp_dir() ||
raise "could not get a writable temporary directory, please set the TMPDIR environment variable"
end
defp write_env_tmp_dir(env) do
case :os.getenv(env) do
false -> nil
tmp -> write_tmp_dir(tmp)
end
end
defp write_tmp_dir(dir) do
case File.stat(dir) do
{:ok, stat} ->
case {stat.type, stat.access} do
{:directory, access} when access in [:read_write, :write] ->
IO.chardata_to_string(dir)
_ ->
nil
end
{:error, _} ->
nil
end
end
@doc """
Registers a program exit handler function.
Registers a function that will be invoked at the end of program execution.
Useful for invoking a hook in "script" mode.
The handler always executes in a different process from the one it was
registered in. As a consequence, any resources managed by the calling process
(ETS tables, open files, etc.) won't be available by the time the handler
function is invoked.
The function must receive the exit status code as an argument.
"""
@spec at_exit((non_neg_integer -> any)) :: :ok
def at_exit(fun) when is_function(fun, 1) do
:elixir_config.update(:at_exit, &[fun | &1])
:ok
end
@doc """
Locates an executable on the system.
This function looks up an executable program given
its name using the environment variable PATH on Unix
and Windows. It also considers the proper executable
extension for each operating system, so for Windows it will try to
lookup files with `.com`, `.cmd` or similar extensions.
"""
@spec find_executable(binary) :: binary | nil
def find_executable(program) when is_binary(program) do
assert_no_null_byte!(program, "System.find_executable/1")
case :os.find_executable(String.to_charlist(program)) do
false -> nil
other -> List.to_string(other)
end
end
@doc """
Returns all system environment variables.
The returned value is a map containing name-value pairs.
Variable names and their values are strings.
"""
@spec get_env() :: %{optional(String.t()) => String.t()}
def get_env do
Enum.into(:os.getenv(), %{}, fn var ->
var = IO.chardata_to_string(var)
[k, v] = String.split(var, "=", parts: 2)
{k, v}
end)
end
@doc """
Returns the value of the given environment variable.
The returned value of the environment variable
`varname` is a string. If the environment variable
is not set, returns the string specified in `default` or
`nil` if none is specified.
## Examples
iex> System.get_env("PORT")
"4000"
iex> System.get_env("NOT_SET")
nil
iex> System.get_env("NOT_SET", "4001")
"4001"
"""
@doc since: "1.9.0"
@spec get_env(String.t(), String.t() | nil) :: String.t() | nil
def get_env(varname, default \\ nil)
when is_binary(varname) and
(is_binary(default) or is_nil(default)) do
case :os.getenv(String.to_charlist(varname)) do
false -> default
other -> List.to_string(other)
end
end
@doc """
Returns the value of the given environment variable or `:error` if not found.
If the environment variable `varname` is set, then `{:ok, value}` is returned
where `value` is a string. If `varname` is not set, `:error` is returned.
## Examples
iex> System.fetch_env("PORT")
{:ok, "4000"}
iex> System.fetch_env("NOT_SET")
:error
"""
@doc since: "1.9.0"
@spec fetch_env(String.t()) :: {:ok, String.t()} | :error
def fetch_env(varname) when is_binary(varname) do
case :os.getenv(String.to_charlist(varname)) do
false -> :error
other -> {:ok, List.to_string(other)}
end
end
@doc """
Returns the value of the given environment variable or raises if not found.
Same as `get_env/1` but raises instead of returning `nil` when the variable is
not set.
## Examples
iex> System.fetch_env!("PORT")
"4000"
iex> System.fetch_env!("NOT_SET")
** (ArgumentError) could not fetch environment variable "NOT_SET" because it is not set
"""
@doc since: "1.9.0"
@spec fetch_env!(String.t()) :: String.t()
def fetch_env!(varname) when is_binary(varname) do
get_env(varname) ||
raise ArgumentError,
"could not fetch environment variable #{inspect(varname)} because it is not set"
end
@doc """
Erlang VM process identifier.
Returns the process identifier of the current Erlang emulator
in the format most commonly used by the operating system environment.
For more information, see `:os.getpid/0`.
"""
@spec get_pid() :: binary
def get_pid, do: IO.iodata_to_binary(:os.getpid())
@doc """
Sets an environment variable value.
Sets a new `value` for the environment variable `varname`.
"""
@spec put_env(binary, binary) :: :ok
def put_env(varname, value) when is_binary(varname) and is_binary(value) do
case :binary.match(varname, "=") do
{_, _} ->
raise ArgumentError,
"cannot execute System.put_env/2 for key with \"=\", got: #{inspect(varname)}"
:nomatch ->
:os.putenv(String.to_charlist(varname), String.to_charlist(value))
:ok
end
end
@doc """
Sets multiple environment variables.
Sets a new value for each environment variable corresponding
to each `{key, value}` pair in `enum`.
"""
@spec put_env(Enumerable.t()) :: :ok
def put_env(enum) do
Enum.each(enum, fn {key, val} -> put_env(key, val) end)
end
@doc """
Deletes an environment variable.
Removes the variable `varname` from the environment.
"""
@spec delete_env(String.t()) :: :ok
def delete_env(varname) do
:os.unsetenv(String.to_charlist(varname))
:ok
end
@doc """
Deprecated mechanism to retrieve the last exception stacktrace.
Accessing the stacktrace outside of a rescue/catch is deprecated.
If you want to support only Elixir v1.7+, you must access
`__STACKTRACE__/0` inside a rescue/catch. If you want to support
earlier Elixir versions, move `System.stacktrace/0` inside a rescue/catch.
Note that the Erlang VM (and therefore this function) does not
return the current stacktrace but rather the stacktrace of the
latest exception. To retrieve the stacktrace of the current process,
use `Process.info(self(), :current_stacktrace)` instead.
"""
# TODO: Fully deprecate it on Elixir v1.11 via @deprecated
# It is currently partially deprecated in elixir_dispatch.erl
def stacktrace do
apply(:erlang, :get_stacktrace, [])
end
@doc """
Immediately halts the Erlang runtime system.
Terminates the Erlang runtime system without properly shutting down
applications and ports. Please see `stop/1` for a careful shutdown of the
system.
`status` must be a non-negative integer, the atom `:abort` or a binary.
* If an integer, the runtime system exits with the integer value which
is returned to the operating system.
* If `:abort`, the runtime system aborts producing a core dump, if that is
enabled in the operating system.
* If a string, an Erlang crash dump is produced with status as slogan,
and then the runtime system exits with status code 1.
Note that on many platforms, only the status codes 0-255 are supported
by the operating system.
For more information, see `:erlang.halt/1`.
## Examples
System.halt(0)
System.halt(1)
System.halt(:abort)
"""
@spec halt(non_neg_integer | binary | :abort) :: no_return
def halt(status \\ 0)
def halt(status) when is_integer(status) or status == :abort do
:erlang.halt(status)
end
def halt(status) when is_binary(status) do
:erlang.halt(String.to_charlist(status))
end
@doc """
Returns the operating system PID for the current Erlang runtime system instance.
Returns a string containing the (usually) numerical identifier for a process.
On UNIX, this is typically the return value of the `getpid()` system call.
On Windows, the process ID as returned by the `GetCurrentProcessId()` system
call is used.
## Examples
System.pid()
"""
@doc since: "1.9.0"
@spec pid :: String.t()
def pid do
List.to_string(:os.getpid())
end
@doc """
Restarts all applications in the Erlang runtime system.
All applications are taken down smoothly, all code is unloaded, and all ports
are closed before the system starts all applications once again.
## Examples
System.restart()
"""
@doc since: "1.9.0"
@spec restart :: :ok
defdelegate restart(), to: :init
@doc """
Carefully stops the Erlang runtime system.
All applications are taken down smoothly, all code is unloaded, and all ports
are closed before the system terminates by calling `halt/1`.
`status` must be a non-negative integer value which is returned by the
runtime system to the operating system.
Note that on many platforms, only the status codes 0-255 are supported
by the operating system.
## Examples
System.stop(0)
System.stop(1)
"""
@doc since: "1.5.0"
@spec stop(non_neg_integer | binary) :: no_return
def stop(status \\ 0)
def stop(status) when is_integer(status) do
:init.stop(status)
end
def stop(status) when is_binary(status) do
:init.stop(String.to_charlist(status))
end
@doc ~S"""
Executes the given `command` with `args`.
`command` is expected to be an executable available in PATH
unless an absolute path is given.
`args` must be a list of binaries which the executable will receive
as its arguments as is. This means that:
* environment variables will not be interpolated
* wildcard expansion will not happen (unless `Path.wildcard/2` is used
explicitly)
* arguments do not need to be escaped or quoted for shell safety
This function returns a tuple containing the collected result
and the command exit status.
Internally, this function uses a `Port` for interacting with the
outside world. However, if you plan to run a long-running program,
ports guarantee stdin/stdout devices will be closed but it does not
automatically terminate the program. The documentation for the
`Port` module describes this problem and possible solutions under
the "Zombie processes" section.
## Examples
iex> System.cmd("echo", ["hello"])
{"hello\n", 0}
iex> System.cmd("echo", ["hello"], env: [{"MIX_ENV", "test"}])
{"hello\n", 0}
iex> System.cmd("echo", ["hello"], into: IO.stream(:stdio, :line))
hello
{%IO.Stream{}, 0}
## Options
* `:into` - injects the result into the given collectable, defaults to `""`
* `:cd` - the directory to run the command in
* `:env` - an enumerable of tuples containing environment key-value as binary
* `:arg0` - sets the command arg0
* `:stderr_to_stdout` - redirects stderr to stdout when `true`
* `:parallelism` - when `true`, the VM will schedule port tasks to improve
parallelism in the system. If set to `false`, the VM will try to perform
commands immediately, improving latency at the expense of parallelism.
The default can be set on system startup by passing the "+spp" argument
to `--erl`.
## Error reasons
If invalid arguments are given, `ArgumentError` is raised by
`System.cmd/3`. `System.cmd/3` also expects a strict set of
options and will raise if unknown or invalid options are given.
Furthermore, `System.cmd/3` may fail with one of the POSIX reasons
detailed below:
* `:system_limit` - all available ports in the Erlang emulator are in use
* `:enomem` - there was not enough memory to create the port
* `:eagain` - there are no more available operating system processes
* `:enametoolong` - the external command given was too long
* `:emfile` - there are no more available file descriptors
(for the operating system process that the Erlang emulator runs in)
* `:enfile` - the file table is full (for the entire operating system)
* `:eacces` - the command does not point to an executable file
* `:enoent` - the command does not point to an existing file
## Shell commands
If you desire to execute a trusted command inside a shell, with pipes,
redirecting and so on, please check `:os.cmd/1`.
"""
@spec cmd(binary, [binary], keyword) :: {Collectable.t(), exit_status :: non_neg_integer}
def cmd(command, args, opts \\ []) when is_binary(command) and is_list(args) do
assert_no_null_byte!(command, "System.cmd/3")
unless Enum.all?(args, &is_binary/1) do
raise ArgumentError, "all arguments for System.cmd/3 must be binaries"
end
cmd = String.to_charlist(command)
cmd =
if Path.type(cmd) == :absolute do
cmd
else
:os.find_executable(cmd) || :erlang.error(:enoent, [command, args, opts])
end
{into, opts} = cmd_opts(opts, [:use_stdio, :exit_status, :binary, :hide, args: args], "")
{initial, fun} = Collectable.into(into)
try do
do_cmd(Port.open({:spawn_executable, cmd}, opts), initial, fun)
catch
kind, reason ->
fun.(initial, :halt)
:erlang.raise(kind, reason, __STACKTRACE__)
else
{acc, status} -> {fun.(acc, :done), status}
end
end
defp do_cmd(port, acc, fun) do
receive do
{^port, {:data, data}} ->
do_cmd(port, fun.(acc, {:cont, data}), fun)
{^port, {:exit_status, status}} ->
{acc, status}
end
end
defp cmd_opts([{:into, any} | t], opts, _into), do: cmd_opts(t, opts, any)
defp cmd_opts([{:cd, bin} | t], opts, into) when is_binary(bin),
do: cmd_opts(t, [{:cd, bin} | opts], into)
defp cmd_opts([{:arg0, bin} | t], opts, into) when is_binary(bin),
do: cmd_opts(t, [{:arg0, bin} | opts], into)
defp cmd_opts([{:stderr_to_stdout, true} | t], opts, into),
do: cmd_opts(t, [:stderr_to_stdout | opts], into)
defp cmd_opts([{:stderr_to_stdout, false} | t], opts, into), do: cmd_opts(t, opts, into)
defp cmd_opts([{:parallelism, bool} | t], opts, into) when is_boolean(bool),
do: cmd_opts(t, [{:parallelism, bool} | opts], into)
defp cmd_opts([{:env, enum} | t], opts, into),
do: cmd_opts(t, [{:env, validate_env(enum)} | opts], into)
defp cmd_opts([{key, val} | _], _opts, _into),
do: raise(ArgumentError, "invalid option #{inspect(key)} with value #{inspect(val)}")
defp cmd_opts([], opts, into), do: {into, opts}
defp validate_env(enum) do
Enum.map(enum, fn
{k, nil} ->
{String.to_charlist(k), false}
{k, v} ->
{String.to_charlist(k), String.to_charlist(v)}
other ->
raise ArgumentError, "invalid environment key-value #{inspect(other)}"
end)
end
@doc """
Returns the current monotonic time in the `:native` time unit.
This time is monotonically increasing and starts in an unspecified
point in time.
Inlined by the compiler.
"""
@spec monotonic_time() :: integer
def monotonic_time do
:erlang.monotonic_time()
end
@doc """
Returns the current monotonic time in the given time unit.
This time is monotonically increasing and starts in an unspecified
point in time.
"""
@spec monotonic_time(time_unit) :: integer
def monotonic_time(unit) do
:erlang.monotonic_time(normalize_time_unit(unit))
end
@doc """
Returns the current system time in the `:native` time unit.
It is the VM view of the `os_time/0`. They may not match in
case of time warps although the VM works towards aligning
them. This time is not monotonic.
Inlined by the compiler.
"""
@spec system_time() :: integer
def system_time do
:erlang.system_time()
end
@doc """
Returns the current system time in the given time unit.
It is the VM view of the `os_time/0`. They may not match in
case of time warps although the VM works towards aligning
them. This time is not monotonic.
"""
@spec system_time(time_unit) :: integer
def system_time(unit) do
:erlang.system_time(normalize_time_unit(unit))
end
@doc """
Converts `time` from time unit `from_unit` to time unit `to_unit`.
The result is rounded via the floor function.
`convert_time_unit/3` accepts an additional time unit (other than the
ones in the `t:time_unit/0` type) called `:native`. `:native` is the time
unit used by the Erlang runtime system. It's determined when the runtime
starts and stays the same until the runtime is stopped, but could differ
the next time the runtime is started on the same machine. For this reason,
you should use this function to convert `:native` time units to a predictable
unit before you display them to humans.
To determine how many seconds the `:native` unit represents in your current
runtime, you can can call this function to convert 1 second to the `:native`
time unit: `System.convert_time_unit(1, :second, :native)`.
"""
@spec convert_time_unit(integer, time_unit | :native, time_unit | :native) :: integer
def convert_time_unit(time, from_unit, to_unit) do
:erlang.convert_time_unit(time, normalize_time_unit(from_unit), normalize_time_unit(to_unit))
end
@doc """
Returns the current time offset between the Erlang VM monotonic
time and the Erlang VM system time.
The result is returned in the `:native` time unit.
See `time_offset/1` for more information.
Inlined by the compiler.
"""
@spec time_offset() :: integer
def time_offset do
:erlang.time_offset()
end
@doc """
Returns the current time offset between the Erlang VM monotonic
time and the Erlang VM system time.
The result is returned in the given time unit `unit`. The returned
offset, added to an Erlang monotonic time (e.g., obtained with
`monotonic_time/1`), gives the Erlang system time that corresponds
to that monotonic time.
"""
@spec time_offset(time_unit) :: integer
def time_offset(unit) do
:erlang.time_offset(normalize_time_unit(unit))
end
@doc """
Returns the current operating system (OS) time.
The result is returned in the `:native` time unit.
This time may be adjusted forwards or backwards in time
with no limitation and is not monotonic.
Inlined by the compiler.
"""
@spec os_time() :: integer
def os_time do
:os.system_time()
end
@doc """
Returns the current operating system (OS) time in the given time `unit`.
This time may be adjusted forwards or backwards in time
with no limitation and is not monotonic.
"""
@spec os_time(time_unit) :: integer
def os_time(unit) do
:os.system_time(normalize_time_unit(unit))
end
@doc """
Returns the Erlang/OTP release number.
"""
@spec otp_release :: String.t()
def otp_release do
:erlang.list_to_binary(:erlang.system_info(:otp_release))
end
@doc """
Returns the number of schedulers in the VM.
"""
@spec schedulers :: pos_integer
def schedulers do
:erlang.system_info(:schedulers)
end
@doc """
Returns the number of schedulers online in the VM.
"""
@spec schedulers_online :: pos_integer
def schedulers_online do
:erlang.system_info(:schedulers_online)
end
@doc """
Generates and returns an integer that is unique in the current runtime
instance.
"Unique" means that this function, called with the same list of `modifiers`,
will never return the same integer more than once on the current runtime
instance.
If `modifiers` is `[]`, then a unique integer (that can be positive or negative) is returned.
Other modifiers can be passed to change the properties of the returned integer:
* `:positive` - the returned integer is guaranteed to be positive.
* `:monotonic` - the returned integer is monotonically increasing. This
means that, on the same runtime instance (but even on different
processes), integers returned using the `:monotonic` modifier will always
be strictly less than integers returned by successive calls with the
`:monotonic` modifier.
All modifiers listed above can be combined; repeated modifiers in `modifiers`
will be ignored.
Inlined by the compiler.
"""
@spec unique_integer([:positive | :monotonic]) :: integer
def unique_integer(modifiers \\ []) do
:erlang.unique_integer(modifiers)
end
defp assert_no_null_byte!(binary, operation) do
case :binary.match(binary, "\0") do
{_, _} ->
raise ArgumentError,
"cannot execute #{operation} for program with null byte, got: #{inspect(binary)}"
:nomatch ->
binary
end
end
defp normalize_time_unit(:native), do: :native
defp normalize_time_unit(:second), do: :second
defp normalize_time_unit(:millisecond), do: :millisecond
defp normalize_time_unit(:microsecond), do: :microsecond
defp normalize_time_unit(:nanosecond), do: :nanosecond
defp normalize_time_unit(:seconds), do: warn(:seconds, :second)
defp normalize_time_unit(:milliseconds), do: warn(:milliseconds, :millisecond)
defp normalize_time_unit(:microseconds), do: warn(:microseconds, :microsecond)
defp normalize_time_unit(:nanoseconds), do: warn(:nanoseconds, :nanosecond)
defp normalize_time_unit(:milli_seconds), do: warn(:milli_seconds, :millisecond)
defp normalize_time_unit(:micro_seconds), do: warn(:micro_seconds, :microsecond)
defp normalize_time_unit(:nano_seconds), do: warn(:nano_seconds, :nanosecond)
defp normalize_time_unit(unit) when is_integer(unit) and unit > 0, do: unit
defp normalize_time_unit(other) do
raise ArgumentError,
"unsupported time unit. Expected :second, :millisecond, " <>
":microsecond, :nanosecond, or a positive integer, " <> "got #{inspect(other)}"
end
defp warn(unit, replacement_unit) do
{:current_stacktrace, stacktrace} = Process.info(self(), :current_stacktrace)
stacktrace = Enum.drop(stacktrace, 3)
:elixir_config.warn({System, unit}, stacktrace) &&
IO.warn(
"deprecated time unit: #{inspect(unit)}. A time unit should be " <>
":second, :millisecond, :microsecond, :nanosecond, or a positive integer",
stacktrace
)
replacement_unit
end
end | lib/elixir/lib/system.ex | 0.929248 | 0.619183 | system.ex | starcoder |
defmodule MailgunEx.Opts do
@moduledoc """
Generate API options based on overwritten values, as well as
any configured defaults.
Please refer to `MailgunEx` for more details on configuring this library,
the know what can be configured.
"""
@doc """
Merge the `provided_opts` with the configured options from the
`:mailgun_ex` application env, available from `MailgunEx.Opts.env/0`
## Example
MailgunEx.Opts.merge([resource: "messages"])
"""
def merge(provided_opts), do: merge(provided_opts, env(), nil)
@doc """
Merge the `provided_opts` with an env `configured_key`. Or, merge those
`provided_opts` with the default application envs in `MailgunEx.Opts.env/0`,
but only provide values for the `expected_keys`.
## Example
# Merge the provided keyword list with the Application env for `:mailgun_ex`
# but only take the `expected_keys` of `[:base, :domain, :resource]`
MailgunEx.Opts.merge([resource: "messages"], [:base, :domain, :resource])
# Merge the provided keyword list with the `:http_opts` from the
# Application env for `:mailgun_ex`
MailgunEx.Opts.merge([resource: "messages"], :http_opts)
"""
def merge(provided_opts, configured_key_or_expected_keys)
when is_atom(configured_key_or_expected_keys) do
merge(provided_opts, env(configured_key_or_expected_keys), nil)
end
def merge(provided_opts, expected_keys) when is_list(expected_keys) do
merge(provided_opts, env(), expected_keys)
end
@doc """
Merge the `provided_opts` with the `configured_opts`. Only provide
values for the `expected_keys` (if `nil` then merge all keys from
`configured_opts`).
## Example
iex> MailgunEx.Opts.merge(
...> [resource: "messages"],
...> [base: "https://api.mailgun.net/v4", resource: "log", timeout: 5000],
...> [:resource, :base])
[base: "https://api.mailgun.net/v4", resource: "messages"]
iex> MailgunEx.Opts.merge(
...> [resource: "messages"],
...> [base: "https://api.mailgun.net/v4", resource: "log", timeout: 5000],
...> nil)
[base: "https://api.mailgun.net/v4", timeout: 5000, resource: "messages"]
"""
def merge(provided_opts, nil, _), do: provided_opts
def merge(provided_opts, configured_opts, expected_keys) do
case expected_keys do
nil -> configured_opts
k -> configured_opts |> Keyword.take(k)
end
|> Keyword.merge(provided_opts)
end
@doc """
Lookup all application env values for `:mailgun_ex`
## Example
# Return all environment variables for :mailgun_ex
MailgunEx.Opts.env()
"""
def env, do: Application.get_all_env(:mailgun_ex)
@doc """
Lookup the `key` within the `:mailgun_ex` application.
## Example
# Return the `:mailgun_ex` value for the `:domain` key
MailgunEx.Opts.env(:domain)
"""
def env(key), do: Application.get_env(:mailgun_ex, key)
end | lib/mailgun_ex/opts.ex | 0.843622 | 0.464355 | opts.ex | starcoder |
defmodule Interp.Functions do
alias Interp.Globals
defmacro is_iterable(value) do
quote do: is_map(unquote(value)) or is_list(unquote(value))
end
@doc """
Checks whether the given value is 'single', which means that it is
either an integer/float/string. Since the only types allowed by 05AB1E are the following:
- integer
- float
- string
- iterable (enum/stream)
We only need to check whether the given value is not iterable.
"""
defmacro is_single?(value) do
quote do: not (is_map(unquote(value)) or is_list(unquote(value)))
end
# ----------------
# Value conversion
# ----------------
def to_number(true), do: 1
def to_number(false), do: 0
def to_number(value) when is_iterable(value), do: value |> Stream.map(&to_number/1)
def to_number(value) when is_number(value), do: value
def to_number(value) do
value = cond do
Regex.match?(~r/^\.\d+/, to_string(value)) -> "0" <> to_string(value)
true -> value
end
if is_bitstring(value) and String.starts_with?(value, "-") do
try do
new_val = String.slice(value, 1..-1)
-to_number(new_val)
rescue
_ -> value
end
else
try do
{int_part, remaining} = Integer.parse(value)
case remaining do
"" -> int_part
_ ->
{float_part, remaining} = Float.parse("0" <> remaining)
cond do
remaining != "" -> value
float_part == 0.0 -> int_part
remaining == "" -> int_part + float_part
true -> value
end
end
rescue
_ -> value
end
end
end
def to_number!(value) do
cond do
is_iterable(value) -> value |> Stream.map(&to_number!/1)
true -> case to_number(value) do
x when is_number(x) -> x
_ -> raise("Could not convert #{value} to number.")
end
end
end
def to_integer(value) do
cond do
value == true -> 1
value == false -> 0
is_integer(value) -> value
is_float(value) -> round(Float.floor(value))
is_iterable(value) -> value |> Stream.map(&to_integer/1)
true ->
case Integer.parse(to_string(value)) do
:error -> value
{int, string} ->
cond do
string == "" -> int
Regex.match?(~r/^\.\d+$/, string) -> int
true -> value
end
end
end
end
def to_integer!(value) do
cond do
is_iterable(value) -> value |> Stream.map(&to_integer!/1)
true ->
case to_integer(value) do
x when is_integer(x) -> x
_ -> raise("Could not convert #{value} to integer.")
end
end
end
def is_integer?(value), do: is_integer(to_number(value))
def is_number?(value), do: is_number(to_number(value))
def to_non_number(value) do
case value do
_ when is_integer(value) ->
Integer.to_string(value)
_ when is_float(value) ->
Float.to_string(value)
_ when is_iterable(value) ->
value |> Stream.map(&to_non_number/1)
_ ->
value
end
end
def to_str(value) do
case value do
true -> "1"
false -> "0"
_ when is_number(value) -> to_string(value)
_ when is_iterable(value) -> Enum.map(value, &to_str/1)
_ -> value
end
end
def flat_string(value) do
case value do
true -> "1"
false -> "0"
_ when is_number(value) -> to_string(value)
_ when is_iterable(value) -> "[" <> (value |> Enum.to_list |> Enum.map(&flat_string/1) |> Enum.join(", ")) <> "]"
_ -> value
end
end
def to_list(value) do
cond do
is_iterable(value) -> value
true -> String.graphemes(to_string(value))
end
end
def stream(value) do
cond do
is_list(value) -> value |> Stream.map(fn x -> x end)
is_map(value) -> value
is_integer(value) -> stream(to_string(value))
true -> String.graphemes(value)
end
end
def as_stream(stream) do
stream |> Stream.map(fn x -> x end)
end
def normalize_to(value, initial) when is_iterable(value) and not is_iterable(initial), do: value |> Enum.to_list |> Enum.join("")
def normalize_to(value, _), do: value
def normalize_inner(value, initial) when is_iterable(value) and not is_iterable(initial), do: value |> Stream.map(fn x -> x |> Stream.map(fn y -> Enum.join(y, "") end) end)
def normalize_inner(value, _), do: value
# --------------------------------
# Force evaluation on lazy objects
# --------------------------------
def eval(value) when is_iterable(value), do: Enum.map(Enum.to_list(value), &eval/1)
def eval(value), do: value
# --------------------
# Unary method calling
# --------------------
def call_unary(func, a), do: call_unary(func, a, false)
def call_unary(func, a, false) when is_iterable(a), do: a |> Stream.map(fn x -> call_unary(func, x, false) end)
def call_unary(func, a, _) do
try_default(fn -> func.(a) end, fn exception -> throw_test_or_return(exception, a) end)
end
# ---------------------
# Binary method calling
# ---------------------
def call_binary(func, a, b), do: call_binary(func, a, b, false, false)
def call_binary(func, a, b, false, false) when is_iterable(a) and is_iterable(b), do: Stream.zip([a, b]) |> Stream.map(fn {x, y} -> call_binary(func, x, y, false, false) end)
def call_binary(func, a, b, _, false) when is_iterable(b), do: b |> Stream.map(fn x -> call_binary(func, a, x, true, false) end)
def call_binary(func, a, b, false, _) when is_iterable(a), do: a |> Stream.map(fn x -> call_binary(func, x, b, false, true) end)
def call_binary(func, a, b, _, _) do
try_default([
fn -> func.(a, b) end,
fn -> func.(b, a) end
], fn exception -> throw_test_or_return(exception, a) end)
end
def try_default([function], exception_function), do: try_default(function, exception_function)
def try_default([function | remaining], exception_function), do: (try do function.() rescue _ -> try_default(remaining, exception_function) end)
def try_default(function, exception_function), do: (try do function.() rescue x -> exception_function.(x) end)
defp throw_test_or_return(exception, value) do
case Globals.get().debug.test do
true -> throw(exception)
false -> value
end
end
end | lib/interp/functions.ex | 0.534855 | 0.655708 | functions.ex | starcoder |
defmodule Phoenix.LiveView.Router do
@moduledoc """
Provides LiveView routing for Phoenix routers.
"""
@cookie_key "__phoenix_flash__"
@doc """
Defines a LiveView route.
A LiveView can be routed to by using the `live` macro with a path and
the name of the LiveView:
live "/thermostat", ThermostatLive
By default, you can generate a route to this LiveView by using the `live_path` helper:
live_path(@socket, ThermostatLive)
## Actions and live navigation
It is common for a LiveView to have multiple states and multiple URLs.
For example, you can have a single LiveView that lists all articles on
your web app. For each article there is an "Edit" button which, when
pressed, opens up a modal on the same page to edit the article. It is a
best practice to use live navigation in those cases, so when you click
edit, the URL changes to "/articles/1/edit", even though you are still
within the same LiveView. Similarly, you may also want to show a "New"
button, which opens up the modal to create new entries, and you want
this to be reflected in the URL as "/articles/new".
In order to make it easier to recognize the current "action" your
LiveView is on, you can pass the action option when defining LiveViews
too:
live "/articles", ArticleLive.Index, :index
live "/articles/new", ArticleLive.Index, :new
live "/articles/:id/edit", ArticleLive.Index, :edit
When an action is given, the generated route helpers are named after
the LiveView itself (in the same way as for a controller). For the example
above, we will have:
article_index_path(@socket, :index)
article_index_path(@socket, :new)
article_index_path(@socket, :edit, 123)
The current action will always be available inside the LiveView as
the `@live_action` assign, that can be used to render a LiveComponent:
<%= if @live_action == :new do %>
<%= live_component MyAppWeb.ArticleLive.FormComponent %>
<% end %>
Or can be used to show or hide parts of the template:
<%= if @live_action == :edit do %>
<%= render("form.html", user: @user) %>
<% end %>
Note that `@live_action` will be `nil` if no action is given on the route definition.
## Options
* `:container` - an optional tuple for the HTML tag and DOM attributes to
be used for the LiveView container. For example: `{:li, style: "color: blue;"}`.
See `Phoenix.LiveView.Helpers.live_render/3` for more information and examples.
* `:as` - optionally configures the named helper. Defaults to `:live` when
using a LiveView without actions or defaults to the LiveView name when using
actions.
* `:metadata` - a map to optional feed metadata used on telemetry events and route info,
for example: `%{route_name: :foo, access: :user}`.
* `:private` - an optional map of private data to put in the plug connection.
for example: `%{route_name: :foo, access: :user}`.
## Examples
defmodule MyApp.Router
use Phoenix.Router
import Phoenix.LiveView.Router
scope "/", MyApp do
pipe_through [:browser]
live "/thermostat", ThermostatLive
live "/clock", ClockLive
live "/dashboard", DashboardLive, container: {:main, class: "row"}
end
end
iex> MyApp.Router.Helpers.live_path(MyApp.Endpoint, MyApp.ThermostatLive)
"/thermostat"
"""
defmacro live(path, live_view, action \\ nil, opts \\ []) do
quote bind_quoted: binding() do
{action, router_options} =
Phoenix.LiveView.Router.__live__(__MODULE__, live_view, action, opts)
Phoenix.Router.get(path, Phoenix.LiveView.Plug, action, router_options)
end
end
@doc """
Defines a live session for live redirects within a group of live routes.
`live_session/3` allow routes defined with `live/4` to support
`live_redirect` from the client with navigation purely over the existing
websocket connection. This allows live routes defined in the router to
mount a new root LiveView without additional HTTP requests to the server.
## Security Considerations
A `live_redirect` from the client will *not go through the plug pipeline*
as a hard-refresh or initial HTTP render would. This means authentication,
authorization, etc that may be done in the `Plug.Conn` pipeline must always
be performed within the LiveView mount lifecycle. Live sessions allow you
to support a shared security model by allowing `live_redirect`s to only be
issued between routes defined under the same live session name. If a client
attempts to live redirect to a different live session, it will be refused
and a graceful client-side redirect will trigger a regular HTTP request to
the attempted URL.
*Note*: the live_session is tied to the LiveView and not the browser/cookie
session. Logging out does not expire the live_session, therefore, one should
avoid storing credential/authentication values, such as `current_user_id`, in
the live_session and use the browser/cookie session instead.
## Options
* `:session` - The optional extra session map or MFA tuple to be merged with
the LiveView session. For example, `%{"admin" => true}`, `{MyMod, :session, []}`.
For MFA, the function is invoked, passing the `%Plug.Conn{}` prepended to
the arguments list.
* `:root_layout` - The optional root layout tuple for the intial HTTP render to
override any existing root layout set in the router.
## Examples
scope "/", MyAppWeb do
pipe_through :browser
live_session :default do
live "/feed", FeedLive, :index
live "/status", StatusLive, :index
live "/status/:id", StatusLive, :show
end
live_session :admin, session: %{"admin" => true} do
live "/admin", AdminDashboardLive, :index
live "/admin/posts", AdminPostLive, :index
end
end
To avoid a false security of plug pipeline enforcement, avoid defining
live session routes under different scopes and pipelines. For example, the following
routes would share a live session, but go through different authenticate pipelines
on first mount. This would work and be secure only if you were also enforcing
the admin authentication in your mount, but could be confusing and error prone
later if you are using only pipelines to gauge security. Instead of the following
routes:
live_session :default do
scope "/" do
pipe_through [:authenticate_user]
live ...
end
scope "/admin" do
pipe_through [:authenticate_user, :require_admin]
live ...
end
end
Prefer different live sessions to enforce a separation and guarantee
live redirects may only happen between admin to admin routes, and
default to default routes:
live_session :default do
scope "/" do
pipe_through [:authenticate_user]
live ...
end
end
live_session :admin do
scope "/admin" do
pipe_through [:authenticate_user, :require_admin]
live ...
end
end
"""
defmacro live_session(name, do: block) do
quote do
live_session(unquote(name), [], do: unquote(block))
end
end
defmacro live_session(name, opts, do: block) do
quote do
unquote(__MODULE__).__live_session__(__MODULE__, unquote(opts), unquote(name))
unquote(block)
Module.delete_attribute(__MODULE__, :phoenix_live_session_current)
end
end
@doc false
def __live_session__(module, opts, name) do
Module.register_attribute(module, :phoenix_live_sessions, accumulate: true)
vsn = session_vsn(module)
unless is_atom(name) do
raise ArgumentError, """
expected live_session name to be an atom, got: #{inspect(name)}
"""
end
extra = validate_live_session_opts(opts, name)
if nested = Module.get_attribute(module, :phoenix_live_session_current) do
raise """
attempting to define live_session #{inspect(name)} inside #{inspect(elem(nested, 0))}.
live_session definitions cannot be nested.
"""
end
live_sessions = Module.get_attribute(module, :phoenix_live_sessions)
existing = Enum.find(live_sessions, fn {existing_name, _, _} -> name == existing_name end)
if existing do
raise """
attempting to redefine live_session #{inspect(name)}.
live_session routes must be declared in a single named block.
"""
end
Module.put_attribute(module, :phoenix_live_session_current, {name, extra, vsn})
Module.put_attribute(module, :phoenix_live_sessions, {name, extra, vsn})
end
@live_session_opts [:root_layout, :session]
defp validate_live_session_opts(opts, _name) when is_list(opts) do
opts
|> Keyword.put_new(:session, %{})
|> Enum.reduce(%{}, fn
{:session, val}, acc when is_map(val) or (is_tuple(val) and tuple_size(val) == 3) ->
Map.put(acc, :session, val)
{:session, bad_session}, _acc ->
raise ArgumentError, """
invalid live_session :session
expected a map with string keys or an MFA tuple, got #{inspect(bad_session)}
"""
{:root_layout, {mod, template}}, acc when is_atom(mod) and is_binary(template) ->
Map.put(acc, :root_layout, {mod, template})
{:root_layout, {mod, template}}, acc when is_atom(mod) and is_atom(template) ->
Map.put(acc, :root_layout, {mod, "#{template}.html"})
{:root_layout, false}, acc ->
Map.put(acc, :root_layout, false)
{:root_layout, bad_layout}, _acc ->
raise ArgumentError, """
invalid live_session :root_layout
expected a tuple with the view module and template string or atom name, got #{inspect(bad_layout)}
"""
{key, _val}, _acc ->
raise ArgumentError, """
unknown live_session option "#{inspect(key)}"
Supported options include: #{inspect(@live_session_opts)}
"""
end)
end
defp validate_live_session_opts(invalid, name) do
raise ArgumentError, """
expected second argument to live_session to be a list of options, got:
live_session #{inspect(name)}, #{inspect(invalid)}
"""
end
@doc """
Fetches the LiveView and merges with the controller flash.
Replaces the default `:fetch_flash` plug used by `Phoenix.Router`.
## Examples
defmodule AppWeb.Router do
use LiveGenWeb, :router
import Phoenix.LiveView.Router
pipeline :browser do
...
plug :fetch_live_flash
end
...
end
"""
def fetch_live_flash(%Plug.Conn{} = conn, _) do
case cookie_flash(conn) do
{conn, nil} ->
Phoenix.Controller.fetch_flash(conn, [])
{conn, flash} ->
conn
|> Phoenix.Controller.fetch_flash([])
|> Phoenix.Controller.merge_flash(flash)
end
end
@doc false
def __live__(router, live_view, action, opts)
when is_list(action) and is_list(opts) do
__live__(router, live_view, nil, Keyword.merge(action, opts))
end
def __live__(router, live_view, action, opts)
when is_atom(action) and is_list(opts) do
live_session =
Module.get_attribute(router, :phoenix_live_session_current) ||
{:default, %{session: %{}}, session_vsn(router)}
live_view = Phoenix.Router.scoped_alias(router, live_view)
{private, metadata, opts} = validate_live_opts!(opts)
opts =
opts
|> Keyword.put(:router, router)
|> Keyword.put(:action, action)
{as_helper, as_action} = inferred_as(live_view, opts[:as], action)
{as_action,
alias: false,
as: as_helper,
private: Map.put(private, :phoenix_live_view, {live_view, opts, live_session}),
metadata: Map.put(metadata, :phoenix_live_view, {live_view, action, opts, live_session})}
end
defp validate_live_opts!(opts) do
{private, opts} = Keyword.pop(opts, :private, %{})
{metadata, opts} = Keyword.pop(opts, :metadata, %{})
Enum.each(opts, fn
{:container, {tag, attrs}} when is_atom(tag) and is_list(attrs) ->
:ok
{:container, val} ->
raise ArgumentError, """
expected live :container to be a tuple matching {atom, attrs :: list}, got: #{inspect(val)}
"""
{:as, as} when is_atom(as) ->
:ok
{:as, bad_val} ->
raise ArgumentError, """
expected live :as to be an atom, got: #{inspect(bad_val)}
"""
{key, %{} = meta} when key in [:metadata, :private] and is_map(meta) ->
:ok
{key, bad_val} when key in [:metadata, :private] ->
raise ArgumentError, """
expected live :#{key} to be a map, got: #{inspect(bad_val)}
"""
{key, val} ->
raise ArgumentError, """
unkown live option :#{key}.
Supported options include: :container, :as, :metadata, :private.
Got: #{inspect([{key, val}])}
"""
end)
{private, metadata, opts}
end
defp inferred_as(live_view, as, nil), do: {as || :live, live_view}
defp inferred_as(live_view, nil, action) do
live_view
|> Module.split()
|> Enum.drop_while(&(not String.ends_with?(&1, "Live")))
|> Enum.map(&(&1 |> String.replace_suffix("Live", "") |> Macro.underscore()))
|> Enum.reject(&(&1 == ""))
|> Enum.join("_")
|> case do
"" ->
raise ArgumentError,
"could not infer :as option because a live action was given and the LiveView " <>
"does not have a \"Live\" suffix. Please pass :as explicitly or make sure your " <>
"LiveView is named like \"FooLive\" or \"FooLive.Index\""
as ->
{String.to_atom(as), action}
end
end
defp inferred_as(_live_view, as, action), do: {as, action}
defp cookie_flash(%Plug.Conn{cookies: %{@cookie_key => token}} = conn) do
endpoint = Phoenix.Controller.endpoint_module(conn)
flash =
case Phoenix.LiveView.Utils.verify_flash(endpoint, token) do
%{} = flash when flash != %{} -> flash
%{} -> nil
end
{Plug.Conn.delete_resp_cookie(conn, @cookie_key), flash}
end
defp cookie_flash(%Plug.Conn{} = conn), do: {conn, nil}
defp session_vsn(module) do
if vsn = Module.get_attribute(module, :phoenix_session_vsn) do
vsn
else
vsn = System.system_time()
Module.put_attribute(module, :phoenix_session_vsn, vsn)
vsn
end
end
end | lib/phoenix_live_view/router.ex | 0.88912 | 0.626038 | router.ex | starcoder |
defmodule Membrane.Core.Child.PadController do
@moduledoc false
alias Membrane.Core.Child.{PadModel, PadSpecHandler}
alias Membrane.{LinkError, Pad}
require Membrane.Core.Child.PadModel
require Membrane.Logger
@type state_t :: Membrane.Core.Bin.State.t() | Membrane.Core.Element.State.t()
@spec validate_pad_being_linked!(
Pad.ref_t(),
Pad.direction_t(),
PadModel.pad_info_t(),
state_t()
) :: :ok
def validate_pad_being_linked!(pad_ref, direction, info, state) do
cond do
:ok == PadModel.assert_data(state, pad_ref, linked?: true) ->
raise LinkError, "Pad #{inspect(pad_ref)} has already been linked"
info.direction != direction ->
raise LinkError, """
Invalid pad direction:
expected: #{inspect(info.direction)},
actual: #{inspect(direction)}
"""
true ->
:ok
end
end
@spec validate_pad_mode!(
{Pad.ref_t(), info :: PadModel.pad_info_t() | PadModel.pad_data_t()},
{Pad.ref_t(), other_info :: PadModel.pad_info_t() | PadModel.pad_data_t()}
) :: :ok
def validate_pad_mode!(this, that) do
:ok = do_validate_pad_mode!(this, that)
:ok = do_validate_pad_mode!(that, this)
:ok
end
defp do_validate_pad_mode!(
{from, %{direction: :output, mode: :pull}},
{to, %{direction: :input, mode: :push}}
) do
raise LinkError,
"Cannot connect pull output #{inspect(from)} to push input #{inspect(to)}"
end
defp do_validate_pad_mode!(_pad, _other_pad) do
:ok
end
@spec parse_pad_options!(Pad.name_t(), Membrane.ParentSpec.pad_options_t(), state_t()) ::
map | no_return
def parse_pad_options!(pad_name, options, state) do
{_pad_name, pad_spec} =
PadSpecHandler.get_pads(state) |> Enum.find(fn {k, _} -> k == pad_name end)
bunch_field_specs =
Bunch.KVList.map_values(pad_spec.options || [], &Keyword.take(&1, [:default]))
case options |> List.wrap() |> Bunch.Config.parse(bunch_field_specs) do
{:ok, options} ->
options
{:error, {:config_field, {:key_not_found, key}}} ->
raise LinkError, "Missing option #{inspect(key)} for pad #{inspect(pad_name)}"
{:error, {:config_invalid_keys, keys}} ->
raise LinkError,
"Invalid keys in options of pad #{inspect(pad_name)} - #{inspect(keys)}"
end
end
@spec assert_all_static_pads_linked!(state_t) :: :ok
def assert_all_static_pads_linked!(state) do
linked_pads_names = state.pads_data |> Map.values() |> MapSet.new(& &1.name)
static_unlinked_pads =
state.pads_info
|> Map.values()
|> Enum.filter(
&(Pad.availability_mode(&1.availability) == :static and &1.name not in linked_pads_names)
)
unless Enum.empty?(static_unlinked_pads) do
raise LinkError, """
Some static pads remained unlinked: #{inspect(Enum.map(static_unlinked_pads, & &1.name))}
State: #{inspect(state, pretty: true)}
"""
end
:ok
end
end | lib/membrane/core/child/pad_controller.ex | 0.852522 | 0.408808 | pad_controller.ex | starcoder |
defmodule Exoml do
@moduledoc """
A module to decode/encode xml into a tree structure.
The aim of this parser is to be able to represent any xml document as a tree-like structure,
but be able to put it back together in a sane way.
In comparison to other xml parsers, this one preserves broken stuff.
The goal is to be able to decode the typical broken html document, modify it, and encode it again,
without loosing too much of its original content.
Currently the parser preserves whitespace between <xml> nodes, so <pre> or <textarea> tags should be unaffected,
by a `decode/1` into `encode/1`.
The only part where the parser tidies up, is the `attr="part"` of a <xml attr="part"> node.
With well-formed XML, the parser does work really well.
"""
@type attr() :: binary() | {binary(), binary()}
@type attr_list() :: [] | [attr()]
@type xmlnode_list() :: [] | [xmlnode()]
@type xmlnode() ::
binary() |
{binary(), attr_list(), xmlnode_list()} |
{binary(), attr_list(), nil} |
{atom(), attr_list(), nil} |
{atom(), attr_list(), xmlnode_list()}
@type opts() :: [{atom(), any()}]
@type xmlroot() :: {:root, opts(), xmlnode_list()}
@doc """
Returns a tree representation from the given xml string.
## Examples
iex> Exoml.decode("<tag foo=bar>some text<self closing /></tag>")
{:root, [],
[{"tag", [{"foo", "bar"}],
["some text", {"self", [{"closing", "closing"}], nil}]}]}
iex> Exoml.decode("what, this is not xml")
{:root, [], ["what, this is not xml"]}
iex> Exoml.decode("Well, it renders <b>in the browser</b>")
{:root, [], ["Well, it renders ", {"b", [], ["in the browser"]}]}
iex> Exoml.decode("")
{:root, [], []}
"""
@spec decode(binary()) :: xmlroot()
def decode(bin) when is_binary(bin) do
Exoml.Decoder.decode(bin)
end
@doc """
Returns a string representation from the given xml tree
> Note when encoding a previously decoded xml document:
> Exoml does not perfectly preserve everything from a decoded xml document.
> In general, it preserves just well enough, but don't expect a 1-1 conversion.
## Examples
iex> xml = ~s'<tag foo="bar">some text</tag>'
iex> ^xml = Exoml.encode(Exoml.decode(xml))
"<tag foo=\"bar\">some text</tag>"
"""
@spec encode(xmlroot()) :: binary()
def encode(tree) when is_tuple(tree) do
Exoml.Encoder.encode(tree)
end
end | lib/exoml.ex | 0.858941 | 0.433862 | exoml.ex | starcoder |
defmodule Saxy.Handler do
@moduledoc ~S"""
This module provides callbacks to implement SAX events handler.
"""
@doc ~S"""
Callback for event handling.
This callback takes an event type, an event data and `user_state` as the input.
The initial `user_state` is the third argument in `Saxy.parse_string/3` and `Saxy.parse_stream/3`.
It can be accumulated and passed around during the parsing time by returning it as the result of
the callback implementation, which can be used to keep track of data when parsing is happening.
Returning `{:ok, new_state}` continues the parsing process with the new state.
Returning `{:stop, anything}` stops the prosing process immediately, and `anything` will be returned.
This is usually handy when we want to get the desired return without parsing the whole file.
Returning `{:halt, anything}` stops the prosing process immediately, `anything` will be returned, together
with the rest of buffer being parsed. This is usually handy when we want to get the desired return
without parsing the whole file.
## SAX Events
There are a couple of events that need to be handled in the handler.
* `:start_document`.
* `:start_element`.
* `:characters` – the binary that matches [`CharData*`](https://www.w3.org/TR/xml/#d0e1106) and [Reference](https://www.w3.org/TR/xml/#NT-Reference).
Note that it is **not trimmed** and includes **ALL** whitespace characters that match `CharData`.
* `:cdata` – the binary that matches [`CData*`](https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-CData).
* `:end_document`.
* `:end_element`.
Check out `event_data()` type for more information of what are emitted for each event type.
## Examples
defmodule MyEventHandler do
@behaviour Saxy.Handler
def handle_event(:start_document, prolog, state) do
{:ok, [{:start_document, prolog} | state]}
end
def handle_event(:end_document, _data, state) do
{:ok, [{:end_document} | state]}
end
def handle_event(:start_element, {name, attributes}, state) do
{:ok, [{:start_element, name, attributes} | state]}
end
def handle_event(:end_element, name, state) do
{:ok, [{:end_element, name} | state]}
end
def handle_event(:characters, chars, state) do
{:ok, [{:chacters, chars} | state]}
end
end
"""
@type event_name() :: :start_document | :end_document | :start_element | :characters | :cdata | :end_element
@type start_document_data() :: Keyword.t()
@type end_document_data() :: any()
@type start_element_data() :: {name :: String.t(), attributes :: [{name :: String.t(), value :: String.t()}]}
@type end_element_data() :: name :: String.t()
@type characters_data() :: String.t()
@type cdata_data() :: String.t()
@type event_data() ::
start_document_data()
| end_document_data()
| start_element_data()
| end_element_data()
| characters_data()
| cdata_data()
@callback handle_event(event_type :: event_name(), data :: event_data(), user_state :: any()) ::
{:ok, user_state :: any()} | {:stop, returning :: any()} | {:halt, returning :: any()}
end | lib/saxy/handler.ex | 0.89388 | 0.751032 | handler.ex | starcoder |
defmodule AWS.AuditManager do
@moduledoc """
Welcome to the Audit Manager API reference.
This guide is for developers who need detailed information about the Audit
Manager API operations, data types, and errors.
Audit Manager is a service that provides automated evidence collection so that
you can continually audit your Amazon Web Services usage. You can use it to
assess the effectiveness of your controls, manage risk, and simplify compliance.
Audit Manager provides prebuilt frameworks that structure and automate
assessments for a given compliance standard. Frameworks include a prebuilt
collection of controls with descriptions and testing procedures. These controls
are grouped according to the requirements of the specified compliance standard
or regulation. You can also customize frameworks and controls to support
internal audits with specific requirements.
Use the following links to get started with the Audit Manager API:
*
[Actions](https://docs.aws.amazon.com/audit-manager/latest/APIReference/API_Operations.html): An alphabetical list of all Audit Manager API operations.
* [Data
types](https://docs.aws.amazon.com/audit-manager/latest/APIReference/API_Types.html):
An alphabetical list of all Audit Manager data types.
* [Common parameters](https://docs.aws.amazon.com/audit-manager/latest/APIReference/CommonParameters.html):
Parameters that all Query operations can use.
* [Common errors](https://docs.aws.amazon.com/audit-manager/latest/APIReference/CommonErrors.html):
Client and server errors that all operations can return.
If you're new to Audit Manager, we recommend that you review the [ Audit Manager User
Guide](https://docs.aws.amazon.com/audit-manager/latest/userguide/what-is.html).
"""
alias AWS.Client
alias AWS.Request
def metadata do
%AWS.ServiceMetadata{
abbreviation: nil,
api_version: "2017-07-25",
content_type: "application/x-amz-json-1.1",
credential_scope: nil,
endpoint_prefix: "auditmanager",
global?: false,
protocol: "rest-json",
service_id: "AuditManager",
signature_version: "v4",
signing_name: "auditmanager",
target_prefix: nil
}
end
@doc """
Associates an evidence folder to an assessment report in a Audit Manager
assessment.
"""
def associate_assessment_report_evidence_folder(
%Client{} = client,
assessment_id,
input,
options \\ []
) do
url_path = "/assessments/#{AWS.Util.encode_uri(assessment_id)}/associateToAssessmentReport"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:put,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Associates a list of evidence to an assessment report in an Audit Manager
assessment.
"""
def batch_associate_assessment_report_evidence(
%Client{} = client,
assessment_id,
input,
options \\ []
) do
url_path =
"/assessments/#{AWS.Util.encode_uri(assessment_id)}/batchAssociateToAssessmentReport"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:put,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Creates a batch of delegations for an assessment in Audit Manager.
"""
def batch_create_delegation_by_assessment(
%Client{} = client,
assessment_id,
input,
options \\ []
) do
url_path = "/assessments/#{AWS.Util.encode_uri(assessment_id)}/delegations"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:post,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Deletes a batch of delegations for an assessment in Audit Manager.
"""
def batch_delete_delegation_by_assessment(
%Client{} = client,
assessment_id,
input,
options \\ []
) do
url_path = "/assessments/#{AWS.Util.encode_uri(assessment_id)}/delegations"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:put,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Disassociates a list of evidence from an assessment report in Audit Manager.
"""
def batch_disassociate_assessment_report_evidence(
%Client{} = client,
assessment_id,
input,
options \\ []
) do
url_path =
"/assessments/#{AWS.Util.encode_uri(assessment_id)}/batchDisassociateFromAssessmentReport"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:put,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Uploads one or more pieces of evidence to a control in an Audit Manager
assessment.
"""
def batch_import_evidence_to_assessment_control(
%Client{} = client,
assessment_id,
control_id,
control_set_id,
input,
options \\ []
) do
url_path =
"/assessments/#{AWS.Util.encode_uri(assessment_id)}/controlSets/#{AWS.Util.encode_uri(control_set_id)}/controls/#{AWS.Util.encode_uri(control_id)}/evidence"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:post,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Creates an assessment in Audit Manager.
"""
def create_assessment(%Client{} = client, input, options \\ []) do
url_path = "/assessments"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:post,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Creates a custom framework in Audit Manager.
"""
def create_assessment_framework(%Client{} = client, input, options \\ []) do
url_path = "/assessmentFrameworks"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:post,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Creates an assessment report for the specified assessment.
"""
def create_assessment_report(%Client{} = client, assessment_id, input, options \\ []) do
url_path = "/assessments/#{AWS.Util.encode_uri(assessment_id)}/reports"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:post,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Creates a new custom control in Audit Manager.
"""
def create_control(%Client{} = client, input, options \\ []) do
url_path = "/controls"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:post,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Deletes an assessment in Audit Manager.
"""
def delete_assessment(%Client{} = client, assessment_id, input, options \\ []) do
url_path = "/assessments/#{AWS.Util.encode_uri(assessment_id)}"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:delete,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Deletes a custom framework in Audit Manager.
"""
def delete_assessment_framework(%Client{} = client, framework_id, input, options \\ []) do
url_path = "/assessmentFrameworks/#{AWS.Util.encode_uri(framework_id)}"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:delete,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Deletes a share request for a custom framework in Audit Manager.
"""
def delete_assessment_framework_share(%Client{} = client, request_id, input, options \\ []) do
url_path = "/assessmentFrameworkShareRequests/#{AWS.Util.encode_uri(request_id)}"
headers = []
{query_params, input} =
[
{"requestType", "requestType"}
]
|> Request.build_params(input)
Request.request_rest(
client,
metadata(),
:delete,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Deletes an assessment report in Audit Manager.
When you run the `DeleteAssessmentReport` operation, Audit Manager attempts to
delete the following data:
1. The specified assessment report that’s stored in your S3 bucket
2. The associated metadata that’s stored in Audit Manager
If Audit Manager can’t access the assessment report in your S3 bucket, the
report isn’t deleted. In this event, the `DeleteAssessmentReport` operation
doesn’t fail. Instead, it proceeds to delete the associated metadata only. You
must then delete the assessment report from the S3 bucket yourself.
This scenario happens when Audit Manager receives a `403 (Forbidden)` or `404
(Not Found)` error from Amazon S3. To avoid this, make sure that your S3 bucket
is available, and that you configured the correct permissions for Audit Manager
to delete resources in your S3 bucket. For an example permissions policy that
you can use, see [Assessment report destination permissions](https://docs.aws.amazon.com/audit-manager/latest/userguide/security_iam_id-based-policy-examples.html#full-administrator-access-assessment-report-destination)
in the *Audit Manager User Guide*. For information about the issues that could
cause a `403 (Forbidden)` or `404 (Not Found`) error from Amazon S3, see [List of Error
Codes](https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html#ErrorCodeList)
in the *Amazon Simple Storage Service API Reference*.
"""
def delete_assessment_report(
%Client{} = client,
assessment_id,
assessment_report_id,
input,
options \\ []
) do
url_path =
"/assessments/#{AWS.Util.encode_uri(assessment_id)}/reports/#{AWS.Util.encode_uri(assessment_report_id)}"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:delete,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Deletes a custom control in Audit Manager.
"""
def delete_control(%Client{} = client, control_id, input, options \\ []) do
url_path = "/controls/#{AWS.Util.encode_uri(control_id)}"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:delete,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Deregisters an account in Audit Manager.
When you deregister your account from Audit Manager, your data isn’t deleted. If
you want to delete your resource data, you must perform that task separately
before you deregister your account. Either, you can do this in the Audit Manager
console. Or, you can use one of the delete API operations that are provided by
Audit Manager.
To delete your Audit Manager resource data, see the following instructions:
[DeleteAssessment](https://docs.aws.amazon.com/audit-manager/latest/APIReference/API_DeleteAssessment.html) (see also: [Deleting an
assessment](https://docs.aws.amazon.com/audit-manager/latest/userguide/delete-assessment.html)
in the *Audit Manager User Guide*)
[DeleteAssessmentFramework](https://docs.aws.amazon.com/audit-manager/latest/APIReference/API_DeleteAssessmentFramework.html) (see also: [Deleting a custom
framework](https://docs.aws.amazon.com/audit-manager/latest/userguide/delete-custom-framework.html)
in the *Audit Manager User Guide*)
[DeleteAssessmentFrameworkShare](https://docs.aws.amazon.com/audit-manager/latest/APIReference/API_DeleteAssessmentFrameworkShare.html) (see also: [Deleting a share
request](https://docs.aws.amazon.com/audit-manager/latest/userguide/deleting-shared-framework-requests.html)
in the *Audit Manager User Guide*)
[DeleteAssessmentReport](https://docs.aws.amazon.com/audit-manager/latest/APIReference/API_DeleteAssessmentReport.html) (see also: [Deleting an assessment
report](https://docs.aws.amazon.com/audit-manager/latest/userguide/generate-assessment-report.html#delete-assessment-report-steps)
in the *Audit Manager User Guide*)
[DeleteControl](https://docs.aws.amazon.com/audit-manager/latest/APIReference/API_DeleteControl.html) (see also: [Deleting a custom
control](https://docs.aws.amazon.com/audit-manager/latest/userguide/delete-controls.html)
in the *Audit Manager User Guide*)
At this time, Audit Manager doesn't provide an option to delete evidence. All
available delete operations are listed above.
"""
def deregister_account(%Client{} = client, input, options \\ []) do
url_path = "/account/deregisterAccount"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:post,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Removes the specified Amazon Web Services account as a delegated administrator
for Audit Manager.
When you remove a delegated administrator from your Audit Manager settings, you
continue to have access to the evidence that you previously collected under that
account. This is also the case when you deregister a delegated administrator
from Organizations. However, Audit Manager will stop collecting and attaching
evidence to that delegated administrator account moving forward.
When you deregister a delegated administrator account for Audit Manager, the
data for that account isn’t deleted. If you want to delete resource data for a
delegated administrator account, you must perform that task separately before
you deregister the account. Either, you can do this in the Audit Manager
console. Or, you can use one of the delete API operations that are provided by
Audit Manager.
To delete your Audit Manager resource data, see the following instructions:
[DeleteAssessment](https://docs.aws.amazon.com/audit-manager/latest/APIReference/API_DeleteAssessment.html) (see also: [Deleting an
assessment](https://docs.aws.amazon.com/audit-manager/latest/userguide/delete-assessment.html)
in the *Audit Manager User Guide*)
[DeleteAssessmentFramework](https://docs.aws.amazon.com/audit-manager/latest/APIReference/API_DeleteAssessmentFramework.html) (see also: [Deleting a custom
framework](https://docs.aws.amazon.com/audit-manager/latest/userguide/delete-custom-framework.html)
in the *Audit Manager User Guide*)
[DeleteAssessmentFrameworkShare](https://docs.aws.amazon.com/audit-manager/latest/APIReference/API_DeleteAssessmentFrameworkShare.html) (see also: [Deleting a share
request](https://docs.aws.amazon.com/audit-manager/latest/userguide/deleting-shared-framework-requests.html)
in the *Audit Manager User Guide*)
[DeleteAssessmentReport](https://docs.aws.amazon.com/audit-manager/latest/APIReference/API_DeleteAssessmentReport.html) (see also: [Deleting an assessment
report](https://docs.aws.amazon.com/audit-manager/latest/userguide/generate-assessment-report.html#delete-assessment-report-steps)
in the *Audit Manager User Guide*)
[DeleteControl](https://docs.aws.amazon.com/audit-manager/latest/APIReference/API_DeleteControl.html) (see also: [Deleting a custom
control](https://docs.aws.amazon.com/audit-manager/latest/userguide/delete-controls.html)
in the *Audit Manager User Guide*)
At this time, Audit Manager doesn't provide an option to delete evidence. All
available delete operations are listed above.
"""
def deregister_organization_admin_account(%Client{} = client, input, options \\ []) do
url_path = "/account/deregisterOrganizationAdminAccount"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:post,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Disassociates an evidence folder from the specified assessment report in Audit
Manager.
"""
def disassociate_assessment_report_evidence_folder(
%Client{} = client,
assessment_id,
input,
options \\ []
) do
url_path =
"/assessments/#{AWS.Util.encode_uri(assessment_id)}/disassociateFromAssessmentReport"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:put,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Returns the registration status of an account in Audit Manager.
"""
def get_account_status(%Client{} = client, options \\ []) do
url_path = "/account/status"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Returns an assessment from Audit Manager.
"""
def get_assessment(%Client{} = client, assessment_id, options \\ []) do
url_path = "/assessments/#{AWS.Util.encode_uri(assessment_id)}"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Returns a framework from Audit Manager.
"""
def get_assessment_framework(%Client{} = client, framework_id, options \\ []) do
url_path = "/assessmentFrameworks/#{AWS.Util.encode_uri(framework_id)}"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Returns the URL of an assessment report in Audit Manager.
"""
def get_assessment_report_url(
%Client{} = client,
assessment_id,
assessment_report_id,
options \\ []
) do
url_path =
"/assessments/#{AWS.Util.encode_uri(assessment_id)}/reports/#{AWS.Util.encode_uri(assessment_report_id)}/url"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Returns a list of changelogs from Audit Manager.
"""
def get_change_logs(
%Client{} = client,
assessment_id,
control_id \\ nil,
control_set_id \\ nil,
max_results \\ nil,
next_token \\ nil,
options \\ []
) do
url_path = "/assessments/#{AWS.Util.encode_uri(assessment_id)}/changelogs"
headers = []
query_params = []
query_params =
if !is_nil(next_token) do
[{"nextToken", next_token} | query_params]
else
query_params
end
query_params =
if !is_nil(max_results) do
[{"maxResults", max_results} | query_params]
else
query_params
end
query_params =
if !is_nil(control_set_id) do
[{"controlSetId", control_set_id} | query_params]
else
query_params
end
query_params =
if !is_nil(control_id) do
[{"controlId", control_id} | query_params]
else
query_params
end
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Returns a control from Audit Manager.
"""
def get_control(%Client{} = client, control_id, options \\ []) do
url_path = "/controls/#{AWS.Util.encode_uri(control_id)}"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Returns a list of delegations from an audit owner to a delegate.
"""
def get_delegations(%Client{} = client, max_results \\ nil, next_token \\ nil, options \\ []) do
url_path = "/delegations"
headers = []
query_params = []
query_params =
if !is_nil(next_token) do
[{"nextToken", next_token} | query_params]
else
query_params
end
query_params =
if !is_nil(max_results) do
[{"maxResults", max_results} | query_params]
else
query_params
end
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Returns evidence from Audit Manager.
"""
def get_evidence(
%Client{} = client,
assessment_id,
control_set_id,
evidence_folder_id,
evidence_id,
options \\ []
) do
url_path =
"/assessments/#{AWS.Util.encode_uri(assessment_id)}/controlSets/#{AWS.Util.encode_uri(control_set_id)}/evidenceFolders/#{AWS.Util.encode_uri(evidence_folder_id)}/evidence/#{AWS.Util.encode_uri(evidence_id)}"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Returns all evidence from a specified evidence folder in Audit Manager.
"""
def get_evidence_by_evidence_folder(
%Client{} = client,
assessment_id,
control_set_id,
evidence_folder_id,
max_results \\ nil,
next_token \\ nil,
options \\ []
) do
url_path =
"/assessments/#{AWS.Util.encode_uri(assessment_id)}/controlSets/#{AWS.Util.encode_uri(control_set_id)}/evidenceFolders/#{AWS.Util.encode_uri(evidence_folder_id)}/evidence"
headers = []
query_params = []
query_params =
if !is_nil(next_token) do
[{"nextToken", next_token} | query_params]
else
query_params
end
query_params =
if !is_nil(max_results) do
[{"maxResults", max_results} | query_params]
else
query_params
end
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Returns an evidence folder from the specified assessment in Audit Manager.
"""
def get_evidence_folder(
%Client{} = client,
assessment_id,
control_set_id,
evidence_folder_id,
options \\ []
) do
url_path =
"/assessments/#{AWS.Util.encode_uri(assessment_id)}/controlSets/#{AWS.Util.encode_uri(control_set_id)}/evidenceFolders/#{AWS.Util.encode_uri(evidence_folder_id)}"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Returns the evidence folders from a specified assessment in Audit Manager.
"""
def get_evidence_folders_by_assessment(
%Client{} = client,
assessment_id,
max_results \\ nil,
next_token \\ nil,
options \\ []
) do
url_path = "/assessments/#{AWS.Util.encode_uri(assessment_id)}/evidenceFolders"
headers = []
query_params = []
query_params =
if !is_nil(next_token) do
[{"nextToken", next_token} | query_params]
else
query_params
end
query_params =
if !is_nil(max_results) do
[{"maxResults", max_results} | query_params]
else
query_params
end
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Returns a list of evidence folders that are associated with a specified control
of an assessment in Audit Manager.
"""
def get_evidence_folders_by_assessment_control(
%Client{} = client,
assessment_id,
control_id,
control_set_id,
max_results \\ nil,
next_token \\ nil,
options \\ []
) do
url_path =
"/assessments/#{AWS.Util.encode_uri(assessment_id)}/evidenceFolders-by-assessment-control/#{AWS.Util.encode_uri(control_set_id)}/#{AWS.Util.encode_uri(control_id)}"
headers = []
query_params = []
query_params =
if !is_nil(next_token) do
[{"nextToken", next_token} | query_params]
else
query_params
end
query_params =
if !is_nil(max_results) do
[{"maxResults", max_results} | query_params]
else
query_params
end
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Gets the latest analytics data for all your current active assessments.
"""
def get_insights(%Client{} = client, options \\ []) do
url_path = "/insights"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Gets the latest analytics data for a specific active assessment.
"""
def get_insights_by_assessment(%Client{} = client, assessment_id, options \\ []) do
url_path = "/insights/assessments/#{AWS.Util.encode_uri(assessment_id)}"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Returns the name of the delegated Amazon Web Services administrator account for
the organization.
"""
def get_organization_admin_account(%Client{} = client, options \\ []) do
url_path = "/account/organizationAdminAccount"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Returns a list of the in-scope Amazon Web Services services for the specified
assessment.
"""
def get_services_in_scope(%Client{} = client, options \\ []) do
url_path = "/services"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Returns the settings for the specified Amazon Web Services account.
"""
def get_settings(%Client{} = client, attribute, options \\ []) do
url_path = "/settings/#{AWS.Util.encode_uri(attribute)}"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Lists the latest analytics data for controls within a specific control domain
and a specific active assessment.
Control insights are listed only if the control belongs to the control domain
and assessment that was specified. Moreover, the control must have collected
evidence on the `lastUpdated` date of `controlInsightsByAssessment`. If neither
of these conditions are met, no data is listed for that control.
"""
def list_assessment_control_insights_by_control_domain(
%Client{} = client,
assessment_id,
control_domain_id,
max_results \\ nil,
next_token \\ nil,
options \\ []
) do
url_path = "/insights/controls-by-assessment"
headers = []
query_params = []
query_params =
if !is_nil(next_token) do
[{"nextToken", next_token} | query_params]
else
query_params
end
query_params =
if !is_nil(max_results) do
[{"maxResults", max_results} | query_params]
else
query_params
end
query_params =
if !is_nil(control_domain_id) do
[{"controlDomainId", control_domain_id} | query_params]
else
query_params
end
query_params =
if !is_nil(assessment_id) do
[{"assessmentId", assessment_id} | query_params]
else
query_params
end
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Returns a list of sent or received share requests for custom frameworks in Audit
Manager.
"""
def list_assessment_framework_share_requests(
%Client{} = client,
max_results \\ nil,
next_token \\ nil,
request_type,
options \\ []
) do
url_path = "/assessmentFrameworkShareRequests"
headers = []
query_params = []
query_params =
if !is_nil(request_type) do
[{"requestType", request_type} | query_params]
else
query_params
end
query_params =
if !is_nil(next_token) do
[{"nextToken", next_token} | query_params]
else
query_params
end
query_params =
if !is_nil(max_results) do
[{"maxResults", max_results} | query_params]
else
query_params
end
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Returns a list of the frameworks that are available in the Audit Manager
framework library.
"""
def list_assessment_frameworks(
%Client{} = client,
framework_type,
max_results \\ nil,
next_token \\ nil,
options \\ []
) do
url_path = "/assessmentFrameworks"
headers = []
query_params = []
query_params =
if !is_nil(next_token) do
[{"nextToken", next_token} | query_params]
else
query_params
end
query_params =
if !is_nil(max_results) do
[{"maxResults", max_results} | query_params]
else
query_params
end
query_params =
if !is_nil(framework_type) do
[{"frameworkType", framework_type} | query_params]
else
query_params
end
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Returns a list of assessment reports created in Audit Manager.
"""
def list_assessment_reports(
%Client{} = client,
max_results \\ nil,
next_token \\ nil,
options \\ []
) do
url_path = "/assessmentReports"
headers = []
query_params = []
query_params =
if !is_nil(next_token) do
[{"nextToken", next_token} | query_params]
else
query_params
end
query_params =
if !is_nil(max_results) do
[{"maxResults", max_results} | query_params]
else
query_params
end
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Returns a list of current and past assessments from Audit Manager.
"""
def list_assessments(
%Client{} = client,
max_results \\ nil,
next_token \\ nil,
status \\ nil,
options \\ []
) do
url_path = "/assessments"
headers = []
query_params = []
query_params =
if !is_nil(status) do
[{"status", status} | query_params]
else
query_params
end
query_params =
if !is_nil(next_token) do
[{"nextToken", next_token} | query_params]
else
query_params
end
query_params =
if !is_nil(max_results) do
[{"maxResults", max_results} | query_params]
else
query_params
end
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Lists the latest analytics data for control domains across all of your active
assessments.
A control domain is listed only if at least one of the controls within that
domain collected evidence on the `lastUpdated` date of `controlDomainInsights`.
If this condition isn’t met, no data is listed for that control domain.
"""
def list_control_domain_insights(
%Client{} = client,
max_results \\ nil,
next_token \\ nil,
options \\ []
) do
url_path = "/insights/control-domains"
headers = []
query_params = []
query_params =
if !is_nil(next_token) do
[{"nextToken", next_token} | query_params]
else
query_params
end
query_params =
if !is_nil(max_results) do
[{"maxResults", max_results} | query_params]
else
query_params
end
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Lists analytics data for control domains within a specified active assessment.
A control domain is listed only if at least one of the controls within that
domain collected evidence on the `lastUpdated` date of `controlDomainInsights`.
If this condition isn’t met, no data is listed for that domain.
"""
def list_control_domain_insights_by_assessment(
%Client{} = client,
assessment_id,
max_results \\ nil,
next_token \\ nil,
options \\ []
) do
url_path = "/insights/control-domains-by-assessment"
headers = []
query_params = []
query_params =
if !is_nil(next_token) do
[{"nextToken", next_token} | query_params]
else
query_params
end
query_params =
if !is_nil(max_results) do
[{"maxResults", max_results} | query_params]
else
query_params
end
query_params =
if !is_nil(assessment_id) do
[{"assessmentId", assessment_id} | query_params]
else
query_params
end
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Lists the latest analytics data for controls within a specific control domain
across all active assessments.
Control insights are listed only if the control belongs to the control domain
that was specified and the control collected evidence on the `lastUpdated` date
of `controlInsightsMetadata`. If neither of these conditions are met, no data is
listed for that control.
"""
def list_control_insights_by_control_domain(
%Client{} = client,
control_domain_id,
max_results \\ nil,
next_token \\ nil,
options \\ []
) do
url_path = "/insights/controls"
headers = []
query_params = []
query_params =
if !is_nil(next_token) do
[{"nextToken", next_token} | query_params]
else
query_params
end
query_params =
if !is_nil(max_results) do
[{"maxResults", max_results} | query_params]
else
query_params
end
query_params =
if !is_nil(control_domain_id) do
[{"controlDomainId", control_domain_id} | query_params]
else
query_params
end
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Returns a list of controls from Audit Manager.
"""
def list_controls(
%Client{} = client,
control_type,
max_results \\ nil,
next_token \\ nil,
options \\ []
) do
url_path = "/controls"
headers = []
query_params = []
query_params =
if !is_nil(next_token) do
[{"nextToken", next_token} | query_params]
else
query_params
end
query_params =
if !is_nil(max_results) do
[{"maxResults", max_results} | query_params]
else
query_params
end
query_params =
if !is_nil(control_type) do
[{"controlType", control_type} | query_params]
else
query_params
end
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Returns a list of keywords that are pre-mapped to the specified control data
source.
"""
def list_keywords_for_data_source(
%Client{} = client,
max_results \\ nil,
next_token \\ nil,
source,
options \\ []
) do
url_path = "/dataSourceKeywords"
headers = []
query_params = []
query_params =
if !is_nil(source) do
[{"source", source} | query_params]
else
query_params
end
query_params =
if !is_nil(next_token) do
[{"nextToken", next_token} | query_params]
else
query_params
end
query_params =
if !is_nil(max_results) do
[{"maxResults", max_results} | query_params]
else
query_params
end
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Returns a list of all Audit Manager notifications.
"""
def list_notifications(%Client{} = client, max_results \\ nil, next_token \\ nil, options \\ []) do
url_path = "/notifications"
headers = []
query_params = []
query_params =
if !is_nil(next_token) do
[{"nextToken", next_token} | query_params]
else
query_params
end
query_params =
if !is_nil(max_results) do
[{"maxResults", max_results} | query_params]
else
query_params
end
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Returns a list of tags for the specified resource in Audit Manager.
"""
def list_tags_for_resource(%Client{} = client, resource_arn, options \\ []) do
url_path = "/tags/#{AWS.Util.encode_uri(resource_arn)}"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:get,
url_path,
query_params,
headers,
nil,
options,
nil
)
end
@doc """
Enables Audit Manager for the specified Amazon Web Services account.
"""
def register_account(%Client{} = client, input, options \\ []) do
url_path = "/account/registerAccount"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:post,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Enables an Amazon Web Services account within the organization as the delegated
administrator for Audit Manager.
"""
def register_organization_admin_account(%Client{} = client, input, options \\ []) do
url_path = "/account/registerOrganizationAdminAccount"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:post,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Creates a share request for a custom framework in Audit Manager.
The share request specifies a recipient and notifies them that a custom
framework is available. Recipients have 120 days to accept or decline the
request. If no action is taken, the share request expires.
When you invoke the `StartAssessmentFrameworkShare` API, you are about to share
a custom framework with another Amazon Web Services account. You may not share a
custom framework that is derived from a standard framework if the standard
framework is designated as not eligible for sharing by Amazon Web Services,
unless you have obtained permission to do so from the owner of the standard
framework. To learn more about which standard frameworks are eligible for
sharing, see [Framework sharing eligibility](https://docs.aws.amazon.com/audit-manager/latest/userguide/share-custom-framework-concepts-and-terminology.html#eligibility)
in the *Audit Manager User Guide*.
"""
def start_assessment_framework_share(%Client{} = client, framework_id, input, options \\ []) do
url_path = "/assessmentFrameworks/#{AWS.Util.encode_uri(framework_id)}/shareRequests"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:post,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Tags the specified resource in Audit Manager.
"""
def tag_resource(%Client{} = client, resource_arn, input, options \\ []) do
url_path = "/tags/#{AWS.Util.encode_uri(resource_arn)}"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:post,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Removes a tag from a resource in Audit Manager.
"""
def untag_resource(%Client{} = client, resource_arn, input, options \\ []) do
url_path = "/tags/#{AWS.Util.encode_uri(resource_arn)}"
headers = []
{query_params, input} =
[
{"tagKeys", "tagKeys"}
]
|> Request.build_params(input)
Request.request_rest(
client,
metadata(),
:delete,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Edits an Audit Manager assessment.
"""
def update_assessment(%Client{} = client, assessment_id, input, options \\ []) do
url_path = "/assessments/#{AWS.Util.encode_uri(assessment_id)}"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:put,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Updates a control within an assessment in Audit Manager.
"""
def update_assessment_control(
%Client{} = client,
assessment_id,
control_id,
control_set_id,
input,
options \\ []
) do
url_path =
"/assessments/#{AWS.Util.encode_uri(assessment_id)}/controlSets/#{AWS.Util.encode_uri(control_set_id)}/controls/#{AWS.Util.encode_uri(control_id)}"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:put,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Updates the status of a control set in an Audit Manager assessment.
"""
def update_assessment_control_set_status(
%Client{} = client,
assessment_id,
control_set_id,
input,
options \\ []
) do
url_path =
"/assessments/#{AWS.Util.encode_uri(assessment_id)}/controlSets/#{AWS.Util.encode_uri(control_set_id)}/status"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:put,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Updates a custom framework in Audit Manager.
"""
def update_assessment_framework(%Client{} = client, framework_id, input, options \\ []) do
url_path = "/assessmentFrameworks/#{AWS.Util.encode_uri(framework_id)}"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:put,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Updates a share request for a custom framework in Audit Manager.
"""
def update_assessment_framework_share(%Client{} = client, request_id, input, options \\ []) do
url_path = "/assessmentFrameworkShareRequests/#{AWS.Util.encode_uri(request_id)}"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:put,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Updates the status of an assessment in Audit Manager.
"""
def update_assessment_status(%Client{} = client, assessment_id, input, options \\ []) do
url_path = "/assessments/#{AWS.Util.encode_uri(assessment_id)}/status"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:put,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Updates a custom control in Audit Manager.
"""
def update_control(%Client{} = client, control_id, input, options \\ []) do
url_path = "/controls/#{AWS.Util.encode_uri(control_id)}"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:put,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Updates Audit Manager settings for the current user account.
"""
def update_settings(%Client{} = client, input, options \\ []) do
url_path = "/settings"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:put,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Validates the integrity of an assessment report in Audit Manager.
"""
def validate_assessment_report_integrity(%Client{} = client, input, options \\ []) do
url_path = "/assessmentReports/integrity"
headers = []
query_params = []
Request.request_rest(
client,
metadata(),
:post,
url_path,
query_params,
headers,
input,
options,
nil
)
end
end | lib/aws/generated/audit_manager.ex | 0.766818 | 0.562237 | audit_manager.ex | starcoder |
defmodule ExPng.Image.Drawing do
@moduledoc """
Utility module to hold functions related to drawing on images.
"""
@type coordinate_pair :: {pos_integer, pos_integer}
alias ExPng.{Color, Image}
@doc """
Colors the pixel at the given `{x, y}` coordinates in the image the provided
color.
"""
@spec draw(Image.t(), coordinate_pair, ExPng.maybe(Color.t())) :: Image.t()
def draw(%Image{} = image, {_, _} = coordinates, color \\ Color.black()) do
update_in(image, [coordinates], fn _ -> color end)
end
@doc """
Returns the pixel at the given `{x, y}` coordinates in the image.
"""
@spec at(Image.t(), coordinate_pair) :: Color.t()
def at(%Image{} = image, {_, _} = coordinates) do
get_in(image, [coordinates])
end
@doc """
Clears the pixel at the given `{x, y}` coordinates in the image, coloring it
opaque white.
"""
@spec clear(Image.t(), coordinate_pair) :: Image.t()
def clear(%Image{} = image, {_, _} = coordinates) do
{nil, image} = pop_in(image, [coordinates])
image
end
@doc """
Erases all content in the image, setting every pixel to opaque white
"""
@spec erase(Image.t()) :: Image.t()
def erase(%Image{} = image) do
%{image | pixels: build_pixels(image.width, image.height)}
end
defp build_pixels(width, height) do
for _ <- 1..height do
Stream.cycle([Color.white()]) |> Enum.take(width)
end
end
@doc """
Draws a line between the given coordinates in the image.
Shortcut functions are provided for horizontal lines, vertical lines, and
lines with a slope of 1 or -1. For other angles, [Xiaolin Wu's algorithm for
drawing anti-aliased lines](https://en.wikipedia.org/wiki/Xiaolin_Wu%27s_line_algorithm) is used.
"""
@spec line(Image.t(), coordinate_pair, coordinate_pair, ExPng.maybe(Color.t())) :: Image.t()
def line(
%Image{} = image,
{x0, y0} = _coordinates0,
{x1, y1} = _coordinates1,
color \\ Color.black()
) do
dx = x1 - x0
dy = y1 - y0
drawing_func =
case {abs(dx), abs(dy)} do
{_, 0} -> &draw_horizontal_line/6
{0, _} -> &draw_vertical_line/6
{d, d} -> &draw_diagonal_line/6
_ -> &draw_line/6
end
drawing_func.(image, x0, y0, x1, y1, color)
end
defp draw_horizontal_line(%Image{} = image, x0, y, x1, y, color) do
Enum.reduce(x0..x1, image, fn x, image ->
draw(image, {x, y}, color)
end)
end
defp draw_vertical_line(%Image{} = image, x, y0, x, y1, color) do
Enum.reduce(y0..y1, image, fn y, image ->
draw(image, {x, y}, color)
end)
end
defp draw_diagonal_line(%Image{} = image, x0, y0, x1, y1, color) do
dy = if y1 < y0, do: -1, else: 1
{_, image} =
Enum.reduce(x0..x1, {y0, image}, fn x, {y, image} ->
{y + dy, draw(image, {x, y}, color)}
end)
image
end
defp draw_line(%Image{} = image, x0, y0, x1, y1, color) do
steep = abs(y1 - y0) > abs(x1 - x0)
[x0, y0, x1, y1] =
case steep do
true -> [y0, x0, y1, x1]
false -> [x0, y0, x1, y1]
end
[x0, y0, x1, y1] =
case x0 > x1 do
true -> [x1, y1, x0, y0]
false -> [x0, y0, x1, y1]
end
dx = x1 - x0
dy = abs(y1 - y0)
gradient = 1.0 * dy / dx
{image, xpxl1, yend} = draw_end_point(image, x0, y0, gradient, steep, color)
itery = yend + gradient
{image, xpxl2, _} = draw_end_point(image, x1, y1, gradient, steep, color)
{_, image} =
Enum.reduce((xpxl1 + 1)..(xpxl2 - 1), {itery, image}, fn x, {itery, image} ->
image =
image
|> put_color(x, ipart(itery), color, steep, rfpart(itery))
|> put_color(x, ipart(itery) + 1, color, steep, fpart(itery))
{itery + gradient, image}
end)
image
end
defp draw_end_point(image, x, y, gradient, steep, color) do
xend = round(x)
yend = y + gradient * (xend - x)
xgap = rfpart(x + 0.5)
xpxl = xend
ypxl = ipart(yend)
image =
image
|> put_color(xpxl, ypxl, color, steep, rfpart(yend) * xgap)
|> put_color(xpxl, ypxl + 1, color, steep, fpart(yend) * xgap)
{image, xpxl, yend}
end
defp put_color(image, x, y, color, steep, c) do
[x, y] = if steep, do: [y, x], else: [x, y]
draw(image, {round(x), round(y)}, anti_alias(color, at(image, {round(x), round(y)}), c))
end
defp anti_alias(color, old, ratio) do
<<r, g, b, _>> = color
<<old_r, old_g, old_b, _>> = old
[r, g, b] =
[r, g, b]
|> Enum.zip([old_r, old_g, old_b])
|> Enum.map(fn {n, o} -> round(n * ratio + o * (1.0 - ratio)) end)
Color.rgb(r, g, b)
end
defp ipart(x), do: Float.floor(x)
defp fpart(x), do: x - ipart(x)
defp rfpart(x), do: 1.0 - fpart(x)
end | lib/ex_png/image/drawing.ex | 0.896146 | 0.810704 | drawing.ex | starcoder |
defmodule Set do
@moduledoc ~S"""
Generic API for sets.
This module is deprecated, use the `MapSet` module instead.
"""
@moduledoc deprecated: "Use MapSet instead"
@type value :: any
@type values :: [value]
@type t :: map
# TODO: Remove by 2.0
message = "Use the MapSet module for working with sets"
defmacrop target(set) do
quote do
case unquote(set) do
%module{} -> module
set -> unsupported_set(set)
end
end
end
@deprecated message
def delete(set, value) do
target(set).delete(set, value)
end
@deprecated message
def difference(set1, set2) do
target1 = target(set1)
target2 = target(set2)
if target1 == target2 do
target1.difference(set1, set2)
else
Enumerable.reduce(set2, {:cont, set1}, fn v, acc ->
{:cont, target1.delete(acc, v)}
end)
|> elem(1)
end
end
@deprecated message
def disjoint?(set1, set2) do
target1 = target(set1)
target2 = target(set2)
if target1 == target2 do
target1.disjoint?(set1, set2)
else
Enumerable.reduce(set2, {:cont, true}, fn member, acc ->
case target1.member?(set1, member) do
false -> {:cont, acc}
_ -> {:halt, false}
end
end)
|> elem(1)
end
end
@deprecated message
def empty(set) do
target(set).empty(set)
end
@deprecated message
def equal?(set1, set2) do
target1 = target(set1)
target2 = target(set2)
cond do
target1 == target2 ->
target1.equal?(set1, set2)
target1.size(set1) == target2.size(set2) ->
do_subset?(target1, target2, set1, set2)
true ->
false
end
end
@deprecated message
def intersection(set1, set2) do
target1 = target(set1)
target2 = target(set2)
if target1 == target2 do
target1.intersection(set1, set2)
else
Enumerable.reduce(set1, {:cont, target1.new}, fn v, acc ->
{:cont, if(target2.member?(set2, v), do: target1.put(acc, v), else: acc)}
end)
|> elem(1)
end
end
@deprecated message
def member?(set, value) do
target(set).member?(set, value)
end
@deprecated message
def put(set, value) do
target(set).put(set, value)
end
@deprecated message
def size(set) do
target(set).size(set)
end
@deprecated message
def subset?(set1, set2) do
target1 = target(set1)
target2 = target(set2)
if target1 == target2 do
target1.subset?(set1, set2)
else
do_subset?(target1, target2, set1, set2)
end
end
@deprecated message
def to_list(set) do
target(set).to_list(set)
end
@deprecated message
def union(set1, set2) do
target1 = target(set1)
target2 = target(set2)
if target1 == target2 do
target1.union(set1, set2)
else
Enumerable.reduce(set2, {:cont, set1}, fn v, acc ->
{:cont, target1.put(acc, v)}
end)
|> elem(1)
end
end
defp do_subset?(_target1, target2, set1, set2) do
Enumerable.reduce(set1, {:cont, true}, fn member, acc ->
case target2.member?(set2, member) do
true -> {:cont, acc}
_ -> {:halt, false}
end
end)
|> elem(1)
end
defp unsupported_set(set) do
raise ArgumentError, "unsupported set: #{inspect(set)}"
end
end | lib/elixir/lib/set.ex | 0.51562 | 0.425187 | set.ex | starcoder |
defmodule AWS.ElasticLoadBalancing do
@moduledoc """
Elastic Load Balancing
A load balancer can distribute incoming traffic across your EC2 instances.
This enables you to increase the availability of your application. The load
balancer also monitors the health of its registered instances and ensures that
it routes traffic only to healthy instances. You configure your load balancer to
accept incoming traffic by specifying one or more listeners, which are
configured with a protocol and port number for connections from clients to the
load balancer and a protocol and port number for connections from the load
balancer to the instances.
Elastic Load Balancing supports three types of load balancers: Application Load
Balancers, Network Load Balancers, and Classic Load Balancers. You can select a
load balancer based on your application needs. For more information, see the
[Elastic Load Balancing User Guide](https://docs.aws.amazon.com/elasticloadbalancing/latest/userguide/).
This reference covers the 2012-06-01 API, which supports Classic Load Balancers.
The 2015-12-01 API supports Application Load Balancers and Network Load
Balancers.
To get started, create a load balancer with one or more listeners using
`CreateLoadBalancer`. Register your instances with the load balancer using
`RegisterInstancesWithLoadBalancer`.
All Elastic Load Balancing operations are *idempotent*, which means that they
complete at most one time. If you repeat an operation, it succeeds with a 200 OK
response code.
"""
@doc """
Adds the specified tags to the specified load balancer.
Each load balancer can have a maximum of 10 tags.
Each tag consists of a key and an optional value. If a tag with the same key is
already associated with the load balancer, `AddTags` updates its value.
For more information, see [Tag Your Classic Load Balancer](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/add-remove-tags.html)
in the *Classic Load Balancers Guide*.
"""
def add_tags(client, input, options \\ []) do
request(client, "AddTags", input, options)
end
@doc """
Associates one or more security groups with your load balancer in a virtual
private cloud (VPC).
The specified security groups override the previously associated security
groups.
For more information, see [Security Groups for Load Balancers in a VPC](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-security-groups.html#elb-vpc-security-groups)
in the *Classic Load Balancers Guide*.
"""
def apply_security_groups_to_load_balancer(client, input, options \\ []) do
request(client, "ApplySecurityGroupsToLoadBalancer", input, options)
end
@doc """
Adds one or more subnets to the set of configured subnets for the specified load
balancer.
The load balancer evenly distributes requests across all registered subnets. For
more information, see [Add or Remove Subnets for Your Load Balancer in a VPC](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-manage-subnets.html)
in the *Classic Load Balancers Guide*.
"""
def attach_load_balancer_to_subnets(client, input, options \\ []) do
request(client, "AttachLoadBalancerToSubnets", input, options)
end
@doc """
Specifies the health check settings to use when evaluating the health state of
your EC2 instances.
For more information, see [Configure Health Checks for Your Load Balancer](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-healthchecks.html)
in the *Classic Load Balancers Guide*.
"""
def configure_health_check(client, input, options \\ []) do
request(client, "ConfigureHealthCheck", input, options)
end
@doc """
Generates a stickiness policy with sticky session lifetimes that follow that of
an application-generated cookie.
This policy can be associated only with HTTP/HTTPS listeners.
This policy is similar to the policy created by
`CreateLBCookieStickinessPolicy`, except that the lifetime of the special
Elastic Load Balancing cookie, `AWSELB`, follows the lifetime of the
application-generated cookie specified in the policy configuration. The load
balancer only inserts a new stickiness cookie when the application response
includes a new application cookie.
If the application cookie is explicitly removed or expires, the session stops
being sticky until a new application cookie is issued.
For more information, see [Application-Controlled Session Stickiness](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-sticky-sessions.html#enable-sticky-sessions-application)
in the *Classic Load Balancers Guide*.
"""
def create_app_cookie_stickiness_policy(client, input, options \\ []) do
request(client, "CreateAppCookieStickinessPolicy", input, options)
end
@doc """
Generates a stickiness policy with sticky session lifetimes controlled by the
lifetime of the browser (user-agent) or a specified expiration period.
This policy can be associated only with HTTP/HTTPS listeners.
When a load balancer implements this policy, the load balancer uses a special
cookie to track the instance for each request. When the load balancer receives a
request, it first checks to see if this cookie is present in the request. If so,
the load balancer sends the request to the application server specified in the
cookie. If not, the load balancer sends the request to a server that is chosen
based on the existing load-balancing algorithm.
A cookie is inserted into the response for binding subsequent requests from the
same user to that server. The validity of the cookie is based on the cookie
expiration time, which is specified in the policy configuration.
For more information, see [Duration-Based Session Stickiness](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-sticky-sessions.html#enable-sticky-sessions-duration)
in the *Classic Load Balancers Guide*.
"""
def create_l_b_cookie_stickiness_policy(client, input, options \\ []) do
request(client, "CreateLBCookieStickinessPolicy", input, options)
end
@doc """
Creates a Classic Load Balancer.
You can add listeners, security groups, subnets, and tags when you create your
load balancer, or you can add them later using `CreateLoadBalancerListeners`,
`ApplySecurityGroupsToLoadBalancer`, `AttachLoadBalancerToSubnets`, and
`AddTags`.
To describe your current load balancers, see `DescribeLoadBalancers`. When you
are finished with a load balancer, you can delete it using `DeleteLoadBalancer`.
You can create up to 20 load balancers per region per account. You can request
an increase for the number of load balancers for your account. For more
information, see [Limits for Your Classic Load Balancer](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-limits.html)
in the *Classic Load Balancers Guide*.
"""
def create_load_balancer(client, input, options \\ []) do
request(client, "CreateLoadBalancer", input, options)
end
@doc """
Creates one or more listeners for the specified load balancer.
If a listener with the specified port does not already exist, it is created;
otherwise, the properties of the new listener must match the properties of the
existing listener.
For more information, see [Listeners for Your Classic Load Balancer](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-listener-config.html)
in the *Classic Load Balancers Guide*.
"""
def create_load_balancer_listeners(client, input, options \\ []) do
request(client, "CreateLoadBalancerListeners", input, options)
end
@doc """
Creates a policy with the specified attributes for the specified load balancer.
Policies are settings that are saved for your load balancer and that can be
applied to the listener or the application server, depending on the policy type.
"""
def create_load_balancer_policy(client, input, options \\ []) do
request(client, "CreateLoadBalancerPolicy", input, options)
end
@doc """
Deletes the specified load balancer.
If you are attempting to recreate a load balancer, you must reconfigure all
settings. The DNS name associated with a deleted load balancer are no longer
usable. The name and associated DNS record of the deleted load balancer no
longer exist and traffic sent to any of its IP addresses is no longer delivered
to your instances.
If the load balancer does not exist or has already been deleted, the call to
`DeleteLoadBalancer` still succeeds.
"""
def delete_load_balancer(client, input, options \\ []) do
request(client, "DeleteLoadBalancer", input, options)
end
@doc """
Deletes the specified listeners from the specified load balancer.
"""
def delete_load_balancer_listeners(client, input, options \\ []) do
request(client, "DeleteLoadBalancerListeners", input, options)
end
@doc """
Deletes the specified policy from the specified load balancer.
This policy must not be enabled for any listeners.
"""
def delete_load_balancer_policy(client, input, options \\ []) do
request(client, "DeleteLoadBalancerPolicy", input, options)
end
@doc """
Deregisters the specified instances from the specified load balancer.
After the instance is deregistered, it no longer receives traffic from the load
balancer.
You can use `DescribeLoadBalancers` to verify that the instance is deregistered
from the load balancer.
For more information, see [Register or De-Register EC2 Instances](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-deregister-register-instances.html)
in the *Classic Load Balancers Guide*.
"""
def deregister_instances_from_load_balancer(client, input, options \\ []) do
request(client, "DeregisterInstancesFromLoadBalancer", input, options)
end
@doc """
Describes the current Elastic Load Balancing resource limits for your AWS
account.
For more information, see [Limits for Your Classic Load Balancer](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-limits.html)
in the *Classic Load Balancers Guide*.
"""
def describe_account_limits(client, input, options \\ []) do
request(client, "DescribeAccountLimits", input, options)
end
@doc """
Describes the state of the specified instances with respect to the specified
load balancer.
If no instances are specified, the call describes the state of all instances
that are currently registered with the load balancer. If instances are
specified, their state is returned even if they are no longer registered with
the load balancer. The state of terminated instances is not returned.
"""
def describe_instance_health(client, input, options \\ []) do
request(client, "DescribeInstanceHealth", input, options)
end
@doc """
Describes the attributes for the specified load balancer.
"""
def describe_load_balancer_attributes(client, input, options \\ []) do
request(client, "DescribeLoadBalancerAttributes", input, options)
end
@doc """
Describes the specified policies.
If you specify a load balancer name, the action returns the descriptions of all
policies created for the load balancer. If you specify a policy name associated
with your load balancer, the action returns the description of that policy. If
you don't specify a load balancer name, the action returns descriptions of the
specified sample policies, or descriptions of all sample policies. The names of
the sample policies have the `ELBSample-` prefix.
"""
def describe_load_balancer_policies(client, input, options \\ []) do
request(client, "DescribeLoadBalancerPolicies", input, options)
end
@doc """
Describes the specified load balancer policy types or all load balancer policy
types.
The description of each type indicates how it can be used. For example, some
policies can be used only with layer 7 listeners, some policies can be used only
with layer 4 listeners, and some policies can be used only with your EC2
instances.
You can use `CreateLoadBalancerPolicy` to create a policy configuration for any
of these policy types. Then, depending on the policy type, use either
`SetLoadBalancerPoliciesOfListener` or `SetLoadBalancerPoliciesForBackendServer`
to set the policy.
"""
def describe_load_balancer_policy_types(client, input, options \\ []) do
request(client, "DescribeLoadBalancerPolicyTypes", input, options)
end
@doc """
Describes the specified the load balancers.
If no load balancers are specified, the call describes all of your load
balancers.
"""
def describe_load_balancers(client, input, options \\ []) do
request(client, "DescribeLoadBalancers", input, options)
end
@doc """
Describes the tags associated with the specified load balancers.
"""
def describe_tags(client, input, options \\ []) do
request(client, "DescribeTags", input, options)
end
@doc """
Removes the specified subnets from the set of configured subnets for the load
balancer.
After a subnet is removed, all EC2 instances registered with the load balancer
in the removed subnet go into the `OutOfService` state. Then, the load balancer
balances the traffic among the remaining routable subnets.
"""
def detach_load_balancer_from_subnets(client, input, options \\ []) do
request(client, "DetachLoadBalancerFromSubnets", input, options)
end
@doc """
Removes the specified Availability Zones from the set of Availability Zones for
the specified load balancer in EC2-Classic or a default VPC.
For load balancers in a non-default VPC, use `DetachLoadBalancerFromSubnets`.
There must be at least one Availability Zone registered with a load balancer at
all times. After an Availability Zone is removed, all instances registered with
the load balancer that are in the removed Availability Zone go into the
`OutOfService` state. Then, the load balancer attempts to equally balance the
traffic among its remaining Availability Zones.
For more information, see [Add or Remove Availability Zones](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-disable-az.html)
in the *Classic Load Balancers Guide*.
"""
def disable_availability_zones_for_load_balancer(client, input, options \\ []) do
request(client, "DisableAvailabilityZonesForLoadBalancer", input, options)
end
@doc """
Adds the specified Availability Zones to the set of Availability Zones for the
specified load balancer in EC2-Classic or a default VPC.
For load balancers in a non-default VPC, use `AttachLoadBalancerToSubnets`.
The load balancer evenly distributes requests across all its registered
Availability Zones that contain instances. For more information, see [Add or Remove Availability
Zones](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-disable-az.html)
in the *Classic Load Balancers Guide*.
"""
def enable_availability_zones_for_load_balancer(client, input, options \\ []) do
request(client, "EnableAvailabilityZonesForLoadBalancer", input, options)
end
@doc """
Modifies the attributes of the specified load balancer.
You can modify the load balancer attributes, such as `AccessLogs`,
`ConnectionDraining`, and `CrossZoneLoadBalancing` by either enabling or
disabling them. Or, you can modify the load balancer attribute
`ConnectionSettings` by specifying an idle connection timeout value for your
load balancer.
For more information, see the following in the *Classic Load Balancers Guide*:
* [Cross-Zone Load Balancing](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-disable-crosszone-lb.html)
* [Connection Draining](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/config-conn-drain.html)
* [Access Logs](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/access-log-collection.html)
* [Idle Connection Timeout](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/config-idle-timeout.html)
"""
def modify_load_balancer_attributes(client, input, options \\ []) do
request(client, "ModifyLoadBalancerAttributes", input, options)
end
@doc """
Adds the specified instances to the specified load balancer.
The instance must be a running instance in the same network as the load balancer
(EC2-Classic or the same VPC). If you have EC2-Classic instances and a load
balancer in a VPC with ClassicLink enabled, you can link the EC2-Classic
instances to that VPC and then register the linked EC2-Classic instances with
the load balancer in the VPC.
Note that `RegisterInstanceWithLoadBalancer` completes when the request has been
registered. Instance registration takes a little time to complete. To check the
state of the registered instances, use `DescribeLoadBalancers` or
`DescribeInstanceHealth`.
After the instance is registered, it starts receiving traffic and requests from
the load balancer. Any instance that is not in one of the Availability Zones
registered for the load balancer is moved to the `OutOfService` state. If an
Availability Zone is added to the load balancer later, any instances registered
with the load balancer move to the `InService` state.
To deregister instances from a load balancer, use
`DeregisterInstancesFromLoadBalancer`.
For more information, see [Register or De-Register EC2 Instances](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-deregister-register-instances.html)
in the *Classic Load Balancers Guide*.
"""
def register_instances_with_load_balancer(client, input, options \\ []) do
request(client, "RegisterInstancesWithLoadBalancer", input, options)
end
@doc """
Removes one or more tags from the specified load balancer.
"""
def remove_tags(client, input, options \\ []) do
request(client, "RemoveTags", input, options)
end
@doc """
Sets the certificate that terminates the specified listener's SSL connections.
The specified certificate replaces any prior certificate that was used on the
same load balancer and port.
For more information about updating your SSL certificate, see [Replace the SSL Certificate for Your Load
Balancer](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-update-ssl-cert.html)
in the *Classic Load Balancers Guide*.
"""
def set_load_balancer_listener_s_s_l_certificate(client, input, options \\ []) do
request(client, "SetLoadBalancerListenerSSLCertificate", input, options)
end
@doc """
Replaces the set of policies associated with the specified port on which the EC2
instance is listening with a new set of policies.
At this time, only the back-end server authentication policy type can be applied
to the instance ports; this policy type is composed of multiple public key
policies.
Each time you use `SetLoadBalancerPoliciesForBackendServer` to enable the
policies, use the `PolicyNames` parameter to list the policies that you want to
enable.
You can use `DescribeLoadBalancers` or `DescribeLoadBalancerPolicies` to verify
that the policy is associated with the EC2 instance.
For more information about enabling back-end instance authentication, see
[Configure Back-end Instance Authentication](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-create-https-ssl-load-balancer.html#configure_backendauth_clt)
in the *Classic Load Balancers Guide*. For more information about Proxy
Protocol, see [Configure Proxy Protocol Support](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-proxy-protocol.html)
in the *Classic Load Balancers Guide*.
"""
def set_load_balancer_policies_for_backend_server(client, input, options \\ []) do
request(client, "SetLoadBalancerPoliciesForBackendServer", input, options)
end
@doc """
Replaces the current set of policies for the specified load balancer port with
the specified set of policies.
To enable back-end server authentication, use
`SetLoadBalancerPoliciesForBackendServer`.
For more information about setting policies, see [Update the SSL Negotiation Configuration](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/ssl-config-update.html),
[Duration-Based Session Stickiness](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-sticky-sessions.html#enable-sticky-sessions-duration),
and [Application-Controlled Session Stickiness](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-sticky-sessions.html#enable-sticky-sessions-application)
in the *Classic Load Balancers Guide*.
"""
def set_load_balancer_policies_of_listener(client, input, options \\ []) do
request(client, "SetLoadBalancerPoliciesOfListener", input, options)
end
@spec request(AWS.Client.t(), binary(), map(), list()) ::
{:ok, map() | nil, map()}
| {:error, term()}
defp request(client, action, input, options) do
client = %{client | service: "elasticloadbalancing"}
host = build_host("elasticloadbalancing", client)
url = build_url(host, client)
headers = [
{"Host", host},
{"Content-Type", "application/x-www-form-urlencoded"}
]
input = Map.merge(input, %{"Action" => action, "Version" => "2012-06-01"})
payload = encode!(client, input)
headers = AWS.Request.sign_v4(client, "POST", url, headers, payload)
post(client, url, payload, headers, options)
end
defp post(client, url, payload, headers, options) do
case AWS.Client.request(client, :post, url, payload, headers, options) do
{:ok, %{status_code: 200, body: body} = response} ->
body = if body != "", do: decode!(client, body)
{:ok, body, response}
{:ok, response} ->
{:error, {:unexpected_response, response}}
error = {:error, _reason} -> error
end
end
defp build_host(_endpoint_prefix, %{region: "local", endpoint: endpoint}) do
endpoint
end
defp build_host(_endpoint_prefix, %{region: "local"}) do
"localhost"
end
defp build_host(endpoint_prefix, %{region: region, endpoint: endpoint}) do
"#{endpoint_prefix}.#{region}.#{endpoint}"
end
defp build_url(host, %{:proto => proto, :port => port}) do
"#{proto}://#{host}:#{port}/"
end
defp encode!(client, payload) do
AWS.Client.encode!(client, payload, :query)
end
defp decode!(client, payload) do
AWS.Client.decode!(client, payload, :xml)
end
end | lib/aws/generated/elastic_load_balancing.ex | 0.922408 | 0.613902 | elastic_load_balancing.ex | starcoder |
defmodule Holobot.Holofans.Channels do
@moduledoc """
Holofans channels caching server and client API module.
"""
use GenServer, shutdown: 10_000
require Logger
require Memento
alias Holobot.Holofans.{Channel, Client}
require Logger
@cache_update_interval 3_600_000
def start_link(init_args \\ []) do
Logger.info("Starting Channels cache server")
GenServer.start_link(__MODULE__, [init_args], name: __MODULE__)
end
@impl true
def init(_args) do
# Setup Mnesia table
setup_table()
{:ok, %{}, {:continue, :update}}
end
@impl true
def handle_continue(:update, state) do
Logger.info("Performing initial channels cache")
send(self(), :update)
:timer.send_interval(@cache_update_interval, :update)
{:noreply, state}
end
@impl true
def handle_info(:update, _state) do
Logger.info("Updating Channels cache")
# Fetch and cache
:ok = cache_channels!()
{:noreply, :state}
end
# Client
@doc """
Get a list of all channels.
"""
@spec get_channels :: list(Channel.t())
def get_channels() do
Memento.transaction!(fn ->
Memento.Query.all(Channel)
end)
end
@doc """
Get a channel by its Youtube channel ID.
"""
@spec get_channel(binary()) :: Channel.t() | nil
def get_channel(yt_channel_id) do
Memento.transaction!(fn ->
Memento.Query.read(Channel, yt_channel_id)
end)
end
@spec get_channels_top_subs(integer) :: [Channel.t()]
def get_channels_top_subs(limit \\ 10) do
get_channels() |> Enum.sort_by(& &1.subscriber_count, :desc) |> Enum.take(limit)
end
@spec get_channels_top_views(integer) :: [Channel.t()]
def get_channels_top_views(limit \\ 10) do
get_channels() |> Enum.sort_by(& &1.view_count, :desc) |> Enum.take(limit)
end
@spec search(any, any) :: Stream.t()
def search(channels, query \\ "") do
Stream.filter(channels, fn channel ->
String.contains?(channel.name |> String.downcase(), query)
end)
end
# Helpers
defp cache_channels!(step \\ 50) do
filter = %{
sort: "name",
limit: step
}
try do
{:ok, results} = fetch_channels(filter)
total = results[:total]
if total > 0 do
0..total
|> Stream.filter(&(rem(&1, step) == 0))
|> Enum.each(fn offset ->
Logger.debug("Current offset: #{offset}")
with {:ok, results} <- fetch_channels(Map.merge(filter, %{offset: offset})),
{:ok, channels} <- Access.fetch(results, :channels),
channels_chunk <- Stream.map(channels, &Channel.build_record/1) do
Memento.transaction!(fn ->
Enum.each(channels_chunk, &Memento.Query.write/1)
end)
end
Logger.info("Cached total of #{total} channels")
end)
end
rescue
RuntimeError -> "Error when caching channels!"
end
end
defp setup_table() do
if !Holobot.Helpers.table_exists?(Channel) do
Logger.info("Setting up Mnesia table Channel")
Memento.Table.create!(Channel)
end
end
defp fetch_channels(params) do
query = URI.encode_query(params)
url = URI.parse("/channels") |> Map.put(:query, query) |> URI.to_string()
case Client.get(url) do
{:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
{:ok, body}
{:ok, %HTTPoison.Response{status_code: 404}} ->
Logger.warning("Resource not found")
{:error, "Not found"}
{:error, %HTTPoison.Error{reason: reason}} ->
Logger.error(reason)
{:error, reason}
end
end
end | lib/holobot/holofans/channels.ex | 0.835936 | 0.408188 | channels.ex | starcoder |
defmodule Blockchain.Transaction do
@moduledoc """
This module encodes the transaction object,
defined in Section 4.2 of the Yellow Paper.
We are focused on implementing 𝛶, as defined in Eq.(1).
"""
alias Block.Header
alias Blockchain.Account.Repo
alias Blockchain.{Chain, Contract, MathHelper, Transaction}
alias Blockchain.Transaction.{AccountCleaner, Receipt, Validity}
alias EVM.{Configuration, Gas, SubState}
alias MerklePatriciaTree.Trie
# nonce: T_n
# gas_price: T_p
# gas_limit: T_g
# to: T_t
# value: T_v
# v: T_w
# r: T_r
# s: T_s
# init: T_i
# data: T_d
defstruct nonce: 0,
gas_price: 0,
gas_limit: 0,
to: <<>>,
value: 0,
v: nil,
r: nil,
s: nil,
init: <<>>,
data: <<>>
@type t :: %__MODULE__{
nonce: EVM.val(),
gas_price: EVM.val(),
gas_limit: EVM.val(),
to: EVM.address() | <<_::0>>,
value: EVM.val(),
v: Transaction.Signature.hash_v(),
r: Transaction.Signature.hash_r(),
s: Transaction.Signature.hash_s(),
init: EVM.MachineCode.t(),
data: binary()
}
@type status :: 0 | 1
@success_status 1
@failure_status 0
@doc """
Encodes a transaction such that it can be RLP-encoded.
This is defined at L_T Eq.(15) in the Yellow Paper.
## Examples
iex> Blockchain.Transaction.serialize(%Blockchain.Transaction{nonce: 5, gas_price: 6, gas_limit: 7, to: <<1::160>>, value: 8, v: 27, r: 9, s: 10, data: "hi"})
[<<5>>, <<6>>, <<7>>, <<1::160>>, <<8>>, "hi", <<27>>, <<9>>, <<10>>]
iex> Blockchain.Transaction.serialize(%Blockchain.Transaction{nonce: 5, gas_price: 6, gas_limit: 7, to: <<>>, value: 8, v: 27, r: 9, s: 10, init: <<1, 2, 3>>})
[<<5>>, <<6>>, <<7>>, <<>>, <<8>>, <<1, 2, 3>>, <<27>>, <<9>>, <<10>>]
iex> Blockchain.Transaction.serialize(%Blockchain.Transaction{nonce: 5, gas_price: 6, gas_limit: 7, to: <<>>, value: 8, v: 27, r: 9, s: 10, init: <<1, 2, 3>>}, false)
[<<5>>, <<6>>, <<7>>, <<>>, <<8>>, <<1, 2, 3>>]
iex> Blockchain.Transaction.serialize(%Blockchain.Transaction{ data: "", gas_limit: 21000, gas_price: 20000000000, init: "", nonce: 9, r: 0, s: 0, to: "55555555555555555555", v: 1, value: 1000000000000000000 })
["\t", <<4, 168, 23, 200, 0>>, "R\b", "55555555555555555555", <<13, 224, 182, 179, 167, 100, 0, 0>>, "", <<1>>, "", ""]
"""
@spec serialize(t) :: ExRLP.t()
def serialize(tx, include_vrs \\ true) do
base = [
tx.nonce |> BitHelper.encode_unsigned(),
tx.gas_price |> BitHelper.encode_unsigned(),
tx.gas_limit |> BitHelper.encode_unsigned(),
tx.to,
tx.value |> BitHelper.encode_unsigned(),
input_data(tx)
]
if include_vrs do
base ++
[
BitHelper.encode_unsigned(tx.v),
BitHelper.encode_unsigned(tx.r),
BitHelper.encode_unsigned(tx.s)
]
else
base
end
end
@doc """
Returns the input data for the transaction. If the transaction is a contract
creation, then it will return the data in the `init` field. If the transaction
is a message call transaction, then it will return the data in the `data`
field.
"""
@spec input_data(t) :: binary()
def input_data(tx) do
if contract_creation?(tx) do
tx.init
else
tx.data
end
end
@doc """
Decodes a transaction that was previously encoded
using `Transaction.serialize/1`. Note, this is the
inverse of L_T Eq.(15) defined in the Yellow Paper.
## Examples
iex> Blockchain.Transaction.deserialize([<<5>>, <<6>>, <<7>>, <<1::160>>, <<8>>, "hi", <<27>>, <<9>>, <<10>>])
%Blockchain.Transaction{nonce: 5, gas_price: 6, gas_limit: 7, to: <<1::160>>, value: 8, v: 27, r: 9, s: 10, data: "hi"}
iex> Blockchain.Transaction.deserialize([<<5>>, <<6>>, <<7>>, <<>>, <<8>>, <<1, 2, 3>>, <<27>>, <<9>>, <<10>>])
%Blockchain.Transaction{nonce: 5, gas_price: 6, gas_limit: 7, to: <<>>, value: 8, v: 27, r: 9, s: 10, init: <<1, 2, 3>>}
iex> Blockchain.Transaction.deserialize(["\t", <<4, 168, 23, 200, 0>>, "R\b", "55555555555555555555", <<13, 224, 182, 179, 167, 100, 0, 0>>, "", <<1>>, "", ""])
%Blockchain.Transaction{
data: "",
gas_limit: 21000,
gas_price: 20000000000,
init: "",
nonce: 9,
r: 0,
s: 0,
to: "55555555555555555555",
v: 1,
value: 1000000000000000000
}
"""
@spec deserialize(ExRLP.t()) :: t
def deserialize(rlp) do
[
nonce,
gas_price,
gas_limit,
to,
value,
init_or_data,
v,
r,
s
] = rlp
{init, data} = if to == <<>>, do: {init_or_data, <<>>}, else: {<<>>, init_or_data}
%__MODULE__{
nonce: :binary.decode_unsigned(nonce),
gas_price: :binary.decode_unsigned(gas_price),
gas_limit: :binary.decode_unsigned(gas_limit),
to: to,
value: :binary.decode_unsigned(value),
init: init,
data: data,
v: :binary.decode_unsigned(v),
r: :binary.decode_unsigned(r),
s: :binary.decode_unsigned(s)
}
end
@doc """
Validates the validity of a transaction and then executes it if transaction is valid.
"""
@spec execute_with_validation(Trie.t(), t, Header.t(), Chain.t()) ::
{Repo.t(), Gas.t(), Receipt.t()}
def execute_with_validation(
state,
tx,
block_header,
chain
) do
validation_result = Validity.validate(state, tx, block_header, chain)
case validation_result do
:valid -> execute(state, tx, block_header, chain)
{:invalid, _} -> {Repo.new(state), 0, %Receipt{}}
end
end
@doc """
Performs transaction execution, as defined in Section 6
of the Yellow Paper, defined there as 𝛶, Eq.(1) and Eq.(59),
Eq.(70), Eq.(79) and Eq.(80).
From the Yellow Paper, T_o is the original transactor, which can differ from the
sender in the case of a message call or contract creation
not directly triggered by a transaction but coming from
the execution of EVM-code.
This function returns the final state, the total gas used, the logs created,
and the status code of this transaction. These are referred to as {σ', Υ^g,
Υ^l, Y^z} in the Transaction Execution section of the Yellow Paper.
"""
@spec execute(Trie.t(), t, Header.t(), Chain.t()) :: {Repo.t(), Gas.t(), Receipt.t()}
def execute(state, tx, block_header, chain) do
{:ok, sender} = Transaction.Signature.sender(tx, chain.params.network_id)
evm_config = Chain.evm_config(chain, block_header.number)
initial_account_repo = Repo.new(state)
{updated_account_repo, remaining_gas, sub_state, status} =
initial_account_repo
|> begin_transaction(sender, tx)
|> apply_transaction(tx, block_header, sender, evm_config)
{expended_gas, refund} = calculate_gas_usage(tx, remaining_gas, sub_state)
{account_repo_after_receipt, receipt} =
if empty_contract_creation?(tx) && evm_config.clean_touched_accounts do
account_repo_after_execution = Repo.commit(updated_account_repo)
receipt =
create_receipt(
account_repo_after_execution.state.root_hash,
expended_gas,
sub_state.logs,
status,
evm_config
)
account_repo =
refund_gas_and_clean_accounts(
account_repo_after_execution,
sender,
tx,
refund,
block_header,
sub_state,
evm_config
)
{account_repo, receipt}
else
account_repo_after_execution =
updated_account_repo
|> refund_gas_and_clean_accounts(
sender,
tx,
refund,
block_header,
sub_state,
evm_config
)
|> Repo.commit()
receipt =
create_receipt(
account_repo_after_execution.state.root_hash,
expended_gas,
sub_state.logs,
status,
evm_config
)
{account_repo_after_execution, receipt}
end
final_account_repo =
account_repo_after_receipt
|> maybe_reset_coinbase(sub_state, block_header)
|> Repo.commit()
{final_account_repo, expended_gas, receipt}
end
@doc """
Performs the actual creation of a contract or message call. It returns a
four-tuple response {σ_P, g', A, z} designated as Λ_4 and Θ_4 in the Yellow
Paper
Note: the originator is always the same as the sender for transactions that
originate outside of the EVM.
"""
@spec apply_transaction(
Repo.t(),
t,
Header.t(),
EVM.address(),
EVM.Configuration.t()
) :: {Repo.t(), Gas.t(), EVM.SubState.t(), status()}
def apply_transaction(account_repo, tx, block_header, sender, config) do
# sender and originator are the same for transaction execution
originator = sender
# stack depth starts at zero for transaction execution
stack_depth = 0
# apparent value is the full value for transaction execution
apparent_value = tx.value
# gas is equal to what was just subtracted from sender account less intrinsic gas cost
gas = tx.gas_limit - intrinsic_gas_cost(tx, config)
if contract_creation?(tx) do
%Contract.CreateContract{
account_repo: account_repo,
sender: sender,
originator: originator,
available_gas: gas,
gas_price: tx.gas_price,
endowment: tx.value,
init_code: tx.init,
stack_depth: stack_depth,
block_header: block_header,
config: config
}
|> Contract.create()
|> transaction_response()
else
%Contract.MessageCall{
account_repo: account_repo,
sender: sender,
originator: originator,
recipient: tx.to,
contract: tx.to,
available_gas: gas,
gas_price: tx.gas_price,
value: tx.value,
apparent_value: apparent_value,
data: tx.data,
stack_depth: stack_depth,
block_header: block_header,
config: config
}
|> Contract.message_call()
|> transaction_response()
|> touch_beneficiary_account(block_header.beneficiary)
end
end
defp refund_gas_and_clean_accounts(
account_repo,
sender,
tx,
refund,
block_header,
sub_state,
config
) do
account_repo
|> pay_and_refund_gas(sender, tx, refund, block_header)
|> clean_up_accounts_marked_for_destruction(sub_state)
|> clean_touched_accounts(sub_state, config)
end
defp empty_contract_creation?(tx) do
contract_creation?(tx) && tx.init == <<>> && tx.value == 0 && tx.gas_price == 0
end
defp touch_beneficiary_account({state, gas, sub_state, status}, beneficiary) do
new_sub_state = SubState.add_touched_account(sub_state, beneficiary)
{state, gas, new_sub_state, status}
end
defp transaction_response({:ok, {account_repo, remaining_gas, sub_state, _output}}) do
{account_repo, remaining_gas, sub_state, @success_status}
end
defp transaction_response({:error, {account_repo, remaining_gas, sub_state, _output}}) do
{account_repo, remaining_gas, sub_state, @failure_status}
end
@spec calculate_gas_usage(t, Gas.t(), EVM.SubState.t()) :: {Gas.t(), Gas.t()}
defp calculate_gas_usage(tx, remaining_gas, sub_state) do
refund = MathHelper.calculate_total_refund(tx, remaining_gas, sub_state.refund)
expended_gas = tx.gas_limit - refund
{expended_gas, refund}
end
@doc """
Performs first step of transaction, which adjusts the sender's
balance and nonce, as defined in Eq.(67), Eq.(68) and Eq.(69)
of the Yellow Paper.
Note: we pass in sender here so we do not need to compute it
several times (since we'll use it elsewhere).
TODO: we execute this as two separate updates; we may want to
combine a series of updates before we update our state.
## Examples
iex> MerklePatriciaTree.Trie.new(MerklePatriciaTree.Test.random_ets_db())
...> |> Blockchain.Account.Repo.new()
...> |> Blockchain.Account.Repo.put_account(<<0x01::160>>, %Blockchain.Account{balance: 1000, nonce: 7})
...> |> Blockchain.Transaction.begin_transaction(<<0x01::160>>, %Blockchain.Transaction{gas_price: 3, gas_limit: 100})
...> |> Blockchain.Account.Repo.account(<<0x01::160>>)
%Blockchain.Account{balance: 700, nonce: 8}
"""
@spec begin_transaction(Repo.t(), EVM.address(), t) :: Repo.t()
def begin_transaction(account_repo, sender, trx) do
account_repo
|> Repo.dec_wei(sender, trx.gas_limit * trx.gas_price)
|> Repo.increment_account_nonce(sender)
end
@doc """
Finalizes the gas payout, repaying the sender for excess or refunded gas
and paying the miner his due. This is defined according to Eq.(73), Eq.(74),
Eq.(75) and Eq.(76) of the Yellow Paper.
Again, we take a sender so that we don't have to re-compute the sender
address several times.
## Examples
iex> trx = %Blockchain.Transaction{gas_price: 10, gas_limit: 30}
iex> account_repo = MerklePatriciaTree.Trie.new(MerklePatriciaTree.Test.random_ets_db())
...> |> Blockchain.Account.put_account(<<0x01::160>>, %Blockchain.Account{balance: 11})
...> |> Blockchain.Account.put_account(<<0x02::160>>, %Blockchain.Account{balance: 22})
...> |> Blockchain.Account.Repo.new()
...> |> Blockchain.Transaction.pay_and_refund_gas(<<0x01::160>>, trx, 5, %Block.Header{beneficiary: <<0x02::160>>})
...> Blockchain.Account.Repo.account(account_repo, <<0x01::160>>)
%Blockchain.Account{balance: 61}
...> Blockchain.Account.Repo.account(account_repo, <<0x02::160>>)
%Blockchain.Account{balance: 272}
"""
@spec pay_and_refund_gas(Repo.t(), EVM.address(), t, Gas.t(), Block.Header.t()) :: Repo.t()
def pay_and_refund_gas(account_repo, sender, trx, total_refund, block_header) do
# Eq.(74)
# Eq.(75)
account_repo
|> Repo.add_wei(sender, total_refund * trx.gas_price)
|> Repo.add_wei(
block_header.beneficiary,
(trx.gas_limit - total_refund) * trx.gas_price
)
end
@spec clean_up_accounts_marked_for_destruction(Repo.t(), EVM.SubState.t()) :: Repo.t()
defp clean_up_accounts_marked_for_destruction(account_repo, sub_state) do
Enum.reduce(sub_state.selfdestruct_list, account_repo, fn address, new_account_repo ->
Repo.del_account(new_account_repo, address)
end)
end
@spec maybe_reset_coinbase(Repo.t(), EVM.SubState.t(), Header.t()) :: Repo.t()
defp maybe_reset_coinbase(account_repo, sub_state, header) do
suicided_coinbase =
Enum.find(sub_state.selfdestruct_list, fn address -> Header.mined_by?(header, address) end)
if suicided_coinbase do
Repo.reset_account(account_repo, suicided_coinbase)
else
account_repo
end
end
defp clean_touched_accounts(account_repo, sub_state, config) do
accounts = sub_state.touched_accounts
AccountCleaner.clean_touched_accounts(account_repo, accounts, config)
end
@doc """
Defines the "intrinsic gas cost," that is the amount of gas
this transaction requires to be paid prior to execution. This
is defined as g_0 in Eq.(54), Eq.(55) and Eq.(56) of the
Yellow Paper.
## Examples
iex> Blockchain.Transaction.intrinsic_gas_cost(%Blockchain.Transaction{to: <<1::160>>, init: <<>>, data: <<1, 2, 0, 3>>}, EVM.Configuration.Frontier.new())
3 * 68 + 4 + 21000
iex> Blockchain.Transaction.intrinsic_gas_cost(%Blockchain.Transaction{to: <<1::160>>, init: <<>>, data: <<1, 2, 0, 3>>}, EVM.Configuration.Frontier.new())
3 * 68 + 4 + 21000
iex> Blockchain.Transaction.intrinsic_gas_cost(%Blockchain.Transaction{to: <<1::160>>, init: <<>>, data: <<>>}, EVM.Configuration.Frontier.new())
21000
iex> Blockchain.Transaction.intrinsic_gas_cost(%Blockchain.Transaction{to: <<>>, init: <<1, 2, 0, 3>>, data: <<>>}, EVM.Configuration.Frontier.new())
3 * 68 + 4 + 21000
iex> Blockchain.Transaction.intrinsic_gas_cost(%Blockchain.Transaction{to: <<>>, init: <<1, 2, 0, 3>>, data: <<>>}, EVM.Configuration.Frontier.new())
3 * 68 + 4 + 21000
"""
@spec intrinsic_gas_cost(t, Configuration.t()) :: Gas.t()
def intrinsic_gas_cost(tx, config) do
data_cost = input_data_cost(tx)
data_cost + transaction_cost(tx, config)
end
defp input_data_cost(tx) do
tx
|> input_data()
|> Gas.g_txdata()
end
defp transaction_cost(tx, config) do
if contract_creation?(tx) do
config.contract_creation_cost
else
Gas.g_transaction()
end
end
defp create_receipt(state_root_hash, gas_used, logs, status_code, evm_config) do
if evm_config.status_in_receipt do
Receipt.new(status_code, gas_used, logs)
else
Receipt.new(state_root_hash, gas_used, logs)
end
end
def contract_creation?(%Blockchain.Transaction{to: <<>>}), do: true
def contract_creation?(%Blockchain.Transaction{to: _recipient}), do: false
end | apps/blockchain/lib/blockchain/transaction.ex | 0.863103 | 0.465995 | transaction.ex | starcoder |
defmodule Regulator do
@moduledoc """
Adaptive concurrency limits.
"""
alias Regulator.Regulators
alias Regulator.LimiterSup
alias Regulator.Limits
alias Regulator.Buffer
alias Regulator.Telemetry
alias Regulator.Monitor
@type token :: map()
@type result :: {:ok, term()}
| {:error, term()}
| {:ignore, term()}
@doc """
Creates a new regulator.
"""
@spec install(name :: term(), {module(), Keyword.t()}) :: DynamicSupervisor.on_start_child()
def install(name, {mod, opts}) do
opts = %{name: name, limit: {mod, mod.new(opts)}}
DynamicSupervisor.start_child(Regulators, {LimiterSup, opts})
end
@doc """
Removes a regulator.
"""
@spec uninstall(name :: term()) :: :ok | {:error, :not_found}
def uninstall(name) do
# Find the limit supervisor and terminate it. This will also clean up the
# ets tables that we've created since they are created by the supervisor
# process. If the process is not found then we assume its already been
# killed.
case Process.whereis(name) do
nil ->
:ok
pid ->
DynamicSupervisor.terminate_child(Regulators, pid)
end
end
@doc """
Ask for access to a protected service. If we've reached the concurrency limit
then `ask` will return a `:dropped` atom without executing the callback. Otherwise
the callback will be applied. The callback must return tuple with the result
as the first element and the desired return value as the second. The available
result atoms are:
* `:ok` - The call succeeded.
* `:error` - The call failed or timed out. This is used as a signal to backoff or otherwise adjust the limit.
* `:ignore` - The call should not be counted in the concurrency limit. This is typically used to filter out status checks and other low latency RPCs.
"""
@spec ask(term(), (-> result())) :: term()
def ask(name, f) do
with {:ok, ctx} <- ask(name) do
case safe_execute(ctx, f) do
{:ok, result} ->
ok(ctx)
result
{:error, result} ->
error(ctx)
result
{:ignore, result} ->
ignore(ctx)
result
end
end
end
@doc """
Ask for access to a protected service. Instead of executing a callback this
function returns a `dropped` atom or a context. It is the callers responsibility
to check the context map back in to the regulator using one of the corresponding
functions. Care must be taken to avoid leaking these contexts. Otherwise the
regulator will not be able to adjust the inflight count which will eventually
deadlock the regulator.
"""
@spec ask(name :: term()) :: {:ok, token()} | :dropped
def ask(name) do
:ok = Monitor.monitor_me(name)
inflight = Limits.add(name)
start = Telemetry.start(:ask, %{regulator: name}, %{inflight: inflight})
if inflight <= Limits.limit(name) do
{:ok, %{start: start, name: name, inflight: inflight}}
else
Limits.sub(name)
Monitor.demonitor_me(name)
Telemetry.stop(:ask, start, %{regulator: name, result: :dropped})
:dropped
end
end
@doc """
Checks in a context and marks it as "ok".
"""
@spec ok(token()) :: :ok
def ok(ctx) do
rtt = System.monotonic_time() - ctx.start
Telemetry.stop(:ask, ctx.start, %{regulator: ctx.name, result: :ok})
Buffer.add_sample(ctx.name, {rtt, ctx.inflight, false})
Limits.sub(ctx.name)
Monitor.demonitor_me(ctx.name)
:ok
end
@doc """
Checks in a context and marks it as an error.
"""
@spec error(token()) :: :ok
def error(ctx) do
rtt = System.monotonic_time() - ctx.start
Telemetry.stop(:ask, ctx.start, %{regulator: ctx.name, result: :error})
Buffer.add_sample(ctx.name, {rtt, ctx.inflight, true})
Limits.sub(ctx.name)
Monitor.demonitor_me(ctx.name)
:ok
end
@doc """
Checks in a context and ignores the result.
"""
@spec ignore(token()) :: :ok
def ignore(ctx) do
Telemetry.stop(:ask, ctx.start, %{regulator: ctx.name, result: :ignore})
Limits.sub(ctx.name)
Monitor.demonitor_me(ctx.name)
:ok
end
defp safe_execute(ctx, f) do
f.()
rescue
error ->
Limits.sub(ctx.name)
Monitor.demonitor_me(ctx.name)
Telemetry.exception(:ask, ctx.start, :error, error, __STACKTRACE__, %{regulator: ctx.name})
reraise error, __STACKTRACE__
catch
kind, reason ->
Limits.sub(ctx.name)
Monitor.demonitor_me(ctx.name)
Telemetry.exception(:ask, ctx.start, kind, reason, __STACKTRACE__, %{regulator: ctx.name})
:erlang.raise(kind, reason, __STACKTRACE__)
end
end | lib/regulator.ex | 0.79649 | 0.422892 | regulator.ex | starcoder |
defmodule Nookal do
@moduledoc """
This module provides function to work with [Nookal API](https://nookal.com).
`Nookal` uses [`mint`](https://hex.pm/packages/mint) as the HTTP client.
Please be noted that the functions in this module are very coupled to Nookal
API itself which can be changed at any time. Please always check Nookal API
documentation at: [https://api.nookal.com/developers](https://api.nookal.com/developers).
## Configuration
In order for `:nookal` application to work, some configurations need to be set up:
use Mix.Config
config :nookal, api_key: "not-2-long-but-not-2-short"
After configuration is set, you are good to go:
iex> Nookal.verify()
:ok
"""
@client Application.get_env(:nookal, :http_client, Nookal.Client)
@doc """
Verify if the configured API key is valid.
### Examples
iex> Nookal.verify()
:ok
"""
@spec verify() :: :ok | {:error, term()}
def verify() do
with {:ok, _payload} <- @client.dispatch("/verify"), do: :ok
end
@doc """
Get all locations.
## Example
iex> Nookal.get_locations()
{:ok,
%Nookal.Page{
current: 1,
items: [
%Nookal.Location{
address: %Nookal.Address{
city: nil,
country: "Singapore",
line1: "",
line2: nil,
line3: nil,
postcode: "0",
state: nil
},
id: "4",
name: "Location #1",
timezone: "Asia/Singapore"
}
],
next: nil
}}
"""
@spec get_locations() :: {:ok, Nookal.Page.t(Nookal.Location.t())} | {:error, term()}
def get_locations() do
with {:ok, payload} <- @client.dispatch("/getLocations"),
{:ok, raw_locations} <- fetch_results(payload, "locations"),
{:ok, page} <- Nookal.Page.new(payload),
{:ok, locations} <- Nookal.Location.new(raw_locations) do
{:ok, Nookal.Page.put_items(page, locations)}
end
end
@doc """
Get all practitioners.
## Example
iex> Nookal.get_practitioners()
{:ok,
%Nookal.Page{
current: 1,
items: [
%Nookal.Practitioner{
email: "<EMAIL>",
first_name: "Erik",
id: "9",
last_name: "Johanson",
location_ids: [1],
speciality: "Doctor",
title: "Dr"
},
],
next: nil
}}
"""
@spec get_practitioners() :: {:ok, Nookal.Page.t(Nookal.Practitioner.t())} | {:error, term()}
def get_practitioners() do
with {:ok, payload} <- @client.dispatch("/getPractitioners"),
{:ok, raw_practitioners} <- fetch_results(payload, "practitioners"),
{:ok, page} <- Nookal.Page.new(payload),
{:ok, practitioners} <- Nookal.Practitioner.new(raw_practitioners) do
{:ok, Nookal.Page.put_items(page, practitioners)}
end
end
@doc """
Get patients in a page.
Please check [API specs](https://api.nookal.com/dev/reference/patient) for more information.
## Examples
iex> Nookal.get_patients(%{"page_length" => 1})
{:ok,
%Nookal.Page{
current: 1,
items: [
%Nookal.Patient{
address: %Nookal.Address{
city: "Berlin Wedding",
country: "Germany",
line1: "Genslerstraße 84",
line2: "",
line3: "",
postcode: "13339",
state: "Berlin"
},
alerts: "",
category: "",
date_created: nil,
date_modified: nil,
dob: ~D[1989-01-01],
email: "<EMAIL>",
employer: "Berlin Solutions",
first_name: "Patrick",
gender: "F",
id: 1,
last_name: "Propst",
location_id: 1,
middle_name: "Kahn",
mobile: "98989899",
nickname: "",
notes: "",
occupation: "",
online_code: "ABC123",
postal_address: %Nookal.Address{
city: "Berlin Wedding",
country: "Germany",
line1: "Genslerstraße 84",
line2: "",
line3: "",
postcode: "13339",
state: "Berlin"
},
title: "Mr"
}
],
next: 2
}}
"""
@spec get_patients(map()) :: {:ok, Nookal.Page.t(Nookal.Patient.t())} | {:error, term()}
def get_patients(params \\ %{}) do
with {:ok, payload} <- @client.dispatch("/getPatients", params),
{:ok, raw_patients} <- fetch_results(payload, "patients"),
{:ok, page} <- Nookal.Page.new(payload),
{:ok, patients} <- Nookal.Patient.new(raw_patients) do
{:ok, Nookal.Page.put_items(page, patients)}
end
end
@doc """
Get patients in a page.
Please check [API specs](https://api.nookal.com/dev/objects/appointment) for more information.
## Examples
iex> Nookal.get_appointments(%{"page_length" => 1})
%Nookal.Page{
current: 1,
items: [
%Nookal.Appointment{
arrived?: 0,
cancellation_date: nil,
cancelled?: 0,
date: ~D[2019-09-05],
date_created: ~N[2019-09-03 05:47:48],
date_modified: ~N[2019-09-04 09:28:33],
email_reminder_sent?: 0,
end_time: nil,
id: 1,
invoice_generated?: 0,
location_id: 1,
notes: nil,
patient_id: 1,
practitioner_id: 1,
start_time: nil,
type: "Consultation",
type_id: 1
}
],
next: 2
}
"""
@spec get_appointments(map()) :: {:ok, Nookal.Page.t(Nookal.Appointment.t())} | {:error, term()}
def get_appointments(params \\ %{}) do
with {:ok, payload} <- @client.dispatch("/getAppointments", params),
{:ok, raw_appointments} <- fetch_results(payload, "appointments"),
{:ok, page} <- Nookal.Page.new(payload),
{:ok, appointments} <- Nookal.Appointment.new(raw_appointments) do
{:ok, Nookal.Page.put_items(page, appointments)}
end
end
@doc """
Stream pages with the request function.
## Examples
iex> request_fun = fn current_page ->
...> Nookal.get_patients(%{
...> "page" => current_page,
...> "page_length" => 15
...> })
...> end
...>
...> request_fun
...> |> Nookal.stream_pages()
...> |> Stream.flat_map(fn page -> page.items end)
...> |> Enum.to_list()
[
%Nookal.Patient{
id: 1,
first_name: "Patrick",
last_name: "Propst",
...
},
%Nookal.Patient{
id: 2,
first_name: "Johan",
last_name: "Kesling",
...
}
]
"""
@spec stream_pages((integer() -> {:ok, Nookal.Page.t(any())} | {:error, term()}), integer()) ::
Enumerable.t()
def stream_pages(request_fun, starting_page \\ 1) do
Stream.unfold(starting_page, fn current_page ->
if current_page do
case request_fun.(current_page) do
{:ok, %Nookal.Page{} = page} ->
{page, page.next}
{:error, _reason} ->
nil
end
end
end)
end
@doc """
Upload file for a patient.
### Examples
file_content = File.read!("/path/to/file")
params = %{
"patient_id" => 1,
"case_id" => 1,
"name" => "<NAME>",
"extension" => "png",
"file_type" => "image/png",
"file_path" => "/path/to/file"
}
Nookal.upload(file_content, params)
"""
@spec upload(binary(), map()) :: {:ok, String.t()} | {:error, term()}
def upload(file_content, params) do
patient_id = Map.fetch!(params, "patient_id")
with {:ok, payload} <- @client.dispatch("/uploadFile", params),
{:ok, file_id} <- fetch_results(payload, "file_id"),
{:ok, file_uploading_url} <- fetch_results(payload, "url"),
:ok <- @client.upload(file_uploading_url, file_content),
activate_params = %{"file_id" => file_id, "patient_id" => patient_id},
{:ok, _payload} <- @client.dispatch("/setFileActive", activate_params) do
{:ok, file_id}
end
end
defp fetch_results(payload, key) do
case payload do
%{"data" => %{"results" => %{^key => data}}} ->
{:ok, data}
_other ->
{:error, {:malformed_payload, "could not fetch #{inspect(key)} from payload"}}
end
end
end | lib/nookal.ex | 0.842118 | 0.535038 | nookal.ex | starcoder |
defmodule Artemis.CacheInstance do
use GenServer, restart: :transient
require Logger
alias Artemis.CacheEvent
defmodule CacheEntry do
defstruct [:data, :inserted_at, :key]
end
@moduledoc """
A thin wrapper around a cache instance. Supports multiple cache drivers.
Encapsulates all the application specific logic like subscribing to events,
reseting cache values automatically.
## GenServer Configuration
By default the `restart` value of a GenServer child is `:permanent`. This is
perfect for the common scenario where child processes should always be
restarted.
In the case of a cache instance, each is created dynamically only when
needed. There may be cases where a cache instance is no longer needed, and
should be shut down. To enable this, the CacheInstance uses the `:transient`
value. This ensures the cache is only restarted if it was shutdown abnormally.
For more information on see the [Supervisor Documentation](https://hexdocs.pm/elixir/1.8.2/Supervisor.html#module-restart-values-restart).
## Preventing Cache Stampeding
When the cache is empty, the first call to `fetch()` will execute the
`getter` function and insert the result into the cache.
While the initial `getter` function is being evaluated but not yet completed,
any additional calls to `fetch` will also see an empty cache and start
executing the `getter` function. While inefficient, this duplication is
especially problematic if the getter function is expensive or takes a long time
to execute.
The GenServer can be used as a simple queuing mechanism to prevent this
"thundering herd" scenario and ensure the `getter` function is only executed
once.
Since all GenServer callbacks are blocking, any additional calls to the
cache that are received while the `getter` function is being executed will be
queued until after the initial call completes.
With the `getter` execution completed and the value stored in the cached, all
subsequent calls in the queue can read directly from the cache.
Since the cache can support many different values under different keys, it's
important to note the `fetch` function will never queue requests for keys
that are already present in the cache. Only requests for keys that are
currently empty will be queued.
"""
@default_cache_options [
expiration: :timer.minutes(5),
limit: 100
]
@fetch_timeout :timer.minutes(5)
# Server Callbacks
def start_link(options) do
module = Keyword.fetch!(options, :module)
initial_state = %{
cache_instance_name: get_cache_instance_name(module),
cache_driver: select_cache_driver(Keyword.get(options, :cache_driver)),
cache_options: Keyword.get(options, :cache_options, @default_cache_options),
cache_server_name: get_cache_server_name(module),
cache_reset_on_cloudant_changes: Keyword.get(options, :cache_reset_on_cloudant_changes, []),
cache_reset_on_events: Keyword.get(options, :cache_reset_on_events, []),
module: module
}
GenServer.start_link(__MODULE__, initial_state, name: initial_state.cache_server_name)
end
# Server Functions
@doc """
Detect if the cache instance GenServer has been started
"""
def started?(module) do
name = get_cache_server_name(module)
cond do
Process.whereis(name) -> true
:global.whereis_name(name) != :undefined -> true
true -> false
end
end
@doc """
Fetch the key from the cache instance. If it exists, return the value.
If it does not, evaluate the `getter` function and cache the result.
If the `getter` function returns a `{:error, _}` tuple, it will not
be stored in the cache.
"""
def fetch(module, key, getter) do
cache_instance_name = get_cache_instance_name(module)
cache_driver = get_cache_driver(module)
case get_from_cache(cache_driver, cache_instance_name, key) do
nil ->
Logger.debug("#{cache_instance_name}: cache miss")
GenServer.call(get_cache_server_name(module), {:fetch, key, getter}, @fetch_timeout)
value ->
Logger.debug("#{cache_instance_name}: cache hit")
value
end
end
@doc """
Gets the key from the cache instance. If it does not exist, returns `nil`.
"""
def get(module, key) do
cache_instance_name = get_cache_instance_name(module)
cache_driver = get_cache_driver(module)
get_from_cache(cache_driver, cache_instance_name, key)
end
@doc """
Puts value into the cache, unless it is an error tuple. If it is a function, evaluate it
"""
def put(module, key, value), do: put_in_cache(module, key, value, get_cache_driver(module), get_cache_options(module))
@doc """
Puts many values into the cache
"""
def put_many(module, entries),
do: put_many_in_cache(module, entries, get_cache_driver(module), get_cache_options(module))
def get_cache_server_name(module), do: String.to_atom("#{module}.CacheServer")
def get_cache_instance_name(module), do: String.to_atom("#{module}.CacheInstance")
def get_cache_driver(module), do: GenServer.call(get_cache_server_name(module), :cache_driver, @fetch_timeout)
def get_cache_options(module), do: GenServer.call(get_cache_server_name(module), :cache_options, @fetch_timeout)
def get_name(module), do: get_cache_server_name(module)
def default_cache_options, do: @default_cache_options
@doc """
Determines if a cache server has been created for the given module
"""
def exists?(module), do: Enum.member?(Process.registered(), get_cache_server_name(module))
@doc """
Clear all cache data
"""
def reset(module) do
GenServer.call(get_cache_server_name(module), :reset)
end
@doc """
Stop the cache GenServer and the linked Cache Instance process
"""
def stop(module) do
GenServer.stop(get_cache_server_name(module))
:ok = CacheEvent.broadcast("cache:stopped", module)
end
@doc """
Return the cache driver based on the instance or app config
"""
def select_cache_driver(cache_instance_cache_driver_config) do
cache_instance_cache_driver_config
|> get_cache_driver_config()
|> get_cache_driver_from_config()
end
defp get_cache_driver_config(cache_instance_cache_driver_config) do
cache_instance_cache_driver_config
|> get_cache_driver_config_value()
|> Artemis.Helpers.to_string()
|> String.downcase()
end
defp get_cache_driver_config_value(cache_instance_cache_driver_config) do
case Artemis.Helpers.present?(cache_instance_cache_driver_config) do
true -> cache_instance_cache_driver_config
false -> get_global_cache_driver_config()
end
end
defp get_global_cache_driver_config() do
:artemis
|> Artemis.Helpers.AppConfig.fetch!(:cache, :driver)
|> Kernel.||("")
|> String.downcase()
end
defp get_cache_driver_from_config(config) do
case Artemis.Helpers.to_string(config) do
"postgres" -> Artemis.Drivers.Cache.Postgres
"redis" -> Artemis.Drivers.Cache.Redis
_ -> Artemis.Drivers.Cache.Cachex
end
end
# Instance Callbacks
@impl true
def init(initial_state) do
cache_options = initial_state.cache_driver.get_cache_instance_options(initial_state.cache_options)
{:ok, cache_instance_pid} =
initial_state.cache_driver.create_cache_instance(initial_state.cache_instance_name, cache_options)
state =
initial_state
|> Map.put(:cache_instance_pid, cache_instance_pid)
|> Map.put(:cache_options, cache_options)
subscribe_to_cloudant_changes(initial_state)
subscribe_to_events(initial_state)
:ok = CacheEvent.broadcast("cache:started", initial_state.module)
{:ok, state}
end
@impl true
def handle_call(:cache_driver, _from, state) do
{:reply, state.cache_driver, state}
end
def handle_call(:cache_options, _from, state) do
{:reply, state.cache_options, state}
end
def handle_call({:fetch, key, getter}, _from, state) do
entry = fetch_from_cache(state.module, key, getter, state.cache_driver, state.cache_options)
{:reply, entry, state}
end
def handle_call(:reset, _from, state) do
{:reply, :ok, reset_cache(state)}
end
@impl true
def handle_info(%{event: _event, payload: %{type: "cloudant-change"} = payload}, state) do
process_cloudant_event(payload, state)
end
def handle_info(%{event: event, payload: payload}, state), do: process_event(event, payload, state)
# Cache Instance Helpers
defp get_from_cache(cache_driver, cache_instance_name, key) do
cache_driver.get(cache_instance_name, key)
end
defp put_in_cache(_module, _key, {:error, message}, _cache_driver, _cache_options),
do: %CacheEntry{data: {:error, message}}
defp put_in_cache(module, key, value, cache_driver, cache_options) do
cache_instance_name = get_cache_instance_name(module)
inserted_at = DateTime.utc_now() |> DateTime.to_unix()
entry = %CacheEntry{
data: value,
inserted_at: inserted_at,
key: key
}
cache_driver.put(cache_instance_name, key, entry, cache_options)
entry
end
defp put_many_in_cache(module, entries, cache_driver, cache_options) do
cache_instance_name = get_cache_instance_name(module)
inserted_at = DateTime.utc_now() |> DateTime.to_unix()
cache_entries =
Enum.map(entries, fn {key, value} ->
entry = %CacheEntry{
data: value,
inserted_at: inserted_at,
key: key
}
{key, entry}
end)
cache_driver.put_many(cache_instance_name, cache_entries, cache_options)
cache_entries
end
defp fetch_from_cache(module, key, getter, cache_driver, cache_options) do
cache_instance_name = get_cache_instance_name(module)
case get_from_cache(cache_driver, cache_instance_name, key) do
nil ->
Logger.debug("#{cache_instance_name}: fetch - updating cache")
put_in_cache(module, key, getter.(), cache_driver, cache_options)
value ->
Logger.debug("#{cache_instance_name}: fetch - cache hit")
value
end
end
# Helpers - Events
defp subscribe_to_cloudant_changes(%{cache_reset_on_cloudant_changes: changes}) when length(changes) > 0 do
Enum.map(changes, fn change ->
schema = Map.get(change, :schema)
topic = Artemis.CloudantChange.topic(schema)
:ok = ArtemisPubSub.subscribe(topic)
end)
end
defp subscribe_to_cloudant_changes(_), do: :skipped
defp subscribe_to_events(%{cache_reset_on_events: events}) when length(events) > 0 do
topic = Artemis.Event.get_broadcast_topic()
:ok = ArtemisPubSub.subscribe(topic)
end
defp subscribe_to_events(_state), do: :skipped
defp process_cloudant_event(payload, state) do
case matches_any?(state.cache_reset_on_cloudant_changes, payload) do
true -> {:noreply, reset_cache(state, payload)}
false -> {:noreply, state}
end
end
defp matches_any?(items, target) do
Enum.any?(items, &Artemis.Helpers.subset?(&1, target))
end
defp process_event(event, payload, state) do
case Enum.member?(state.cache_reset_on_events, event) do
true -> {:noreply, reset_cache(state, payload)}
false -> {:noreply, state}
end
end
# Helpers
defp reset_cache(state, event \\ %{}) do
cache_instance_name = get_cache_instance_name(state.module)
state.cache_driver.reset(cache_instance_name)
:ok = CacheEvent.broadcast("cache:reset", state.module, event)
Logger.debug("#{state.cache_instance_name}: Cache reset by event #{event}")
state
end
end | apps/artemis/lib/artemis/cache/cache_instance.ex | 0.824497 | 0.546073 | cache_instance.ex | starcoder |
defmodule Plymio.Codi.Pattern.Other do
@moduledoc ~S"""
This module collects the *other*, simple patterns.
See `Plymio.Codi` for an overview and documentation terms.
## Pattern: *form*
The *form* pattern is a convenience to embed arbitrary code.
Valid keys in the *cpo* are:
| Key | Aliases |
| :--- | :--- |
| `:form` | *:forms, :ast, :asts* |
## Examples
A simple example with four functions:
iex> {:ok, {forms, _}} = [
...> form: quote(do: def(add_1(x), do: x + 1)),
...> ast: quote(do: def(sqr_x(x), do: x * x)),
...> forms: [
...> quote(do: def(sub_1(x), do: x - 1)),
...> quote(do: def(sub_2(x), do: x - 2)),
...> ]
...> ] |> produce_codi
...> forms |> harnais_helper_show_forms!
["def(add_1(x)) do\n x + 1\n end",
"def(sqr_x(x)) do\n x * x\n end",
"def(sub_1(x)) do\n x - 1\n end",
"def(sub_2(x)) do\n x - 2\n end"]
Here the subtraction functions are renamed:
iex> {:ok, {forms, _}} = [
...> form: quote(do: def(add_1(x), do: x + 1)),
...> ast: quote(do: def(sqr_x(x), do: x * x)),
...> forms: [
...> forms: [quote(do: def(sub_1(x), do: x - 1)),
...> quote(do: def(sub_2(x), do: x - 2))],
...> forms_edit: [rename_funs: [sub_1: :decr_1, sub_2: :take_away_2]]]
...> ] |> produce_codi
...> forms |> harnais_helper_show_forms!
["def(add_1(x)) do\n x + 1\n end",
"def(sqr_x(x)) do\n x * x\n end",
"def(decr_1(x)) do\n x - 1\n end",
"def(take_away_2(x)) do\n x - 2\n end"]
In this example the edits are "global" and applied to *all* produced forms:
iex> forms_edit = [rename_funs: [
...> sub_1: :decr_1,
...> sub_2: :take_away_2,
...> add_1: :incr_1,
...> sqr_x: :power_2]
...> ]
...> {:ok, {forms, _}} = [
...> form: quote(do: def(add_1(x), do: x + 1)),
...> ast: quote(do: def(sqr_x(x), do: x * x)),
...> forms: [quote(do: def(sub_1(x), do: x - 1)),
...> quote(do: def(sub_2(x), do: x - 2))],
...> ] |> produce_codi(forms_edit: forms_edit)
...> forms |> harnais_helper_show_forms!
["def(incr_1(x)) do\n x + 1\n end",
"def(power_2(x)) do\n x * x\n end",
"def(decr_1(x)) do\n x - 1\n end",
"def(take_away_2(x)) do\n x - 2\n end"]
## Pattern: *since*
The *since* pattern builds a `@since` module attribute form.
Valid keys in the *cpo* are:
| Key | Aliases |
| :--- | :--- |
| `:since` | |
## Examples
The value must be a string and is validated by `Version.parse/1`:
iex> {:ok, {forms, _}} = [
...> since: "1.7.9"
...> ] |> produce_codi
...> forms |> harnais_helper_show_forms!
["@since(\"1.7.9\")"]
iex> {:error, error} = [
...> since: "1.2.3.4.5"
...> ] |> produce_codi
...> error |> Exception.message
"since invalid, got: 1.2.3.4.5"
## Pattern: *deprecated*
The *deprecated* pattern builds a `@deprecated` module attribute form.
Valid keys in the *cpo* are:
| Key | Aliases |
| :--- | :--- |
| `:deprecated` | |
## Examples
The value must be a string.
iex> {:ok, {forms, _}} = [
...> deprecated: "This function has been deprecated since 1.7.9"
...> ] |> produce_codi
...> forms |> harnais_helper_show_forms!
["@deprecated(\"This function has been deprecated since 1.7.9\")"]
"""
alias Plymio.Codi, as: CODI
use Plymio.Fontais.Attribute
use Plymio.Codi.Attribute
import Plymio.Fontais.Guard,
only: [
is_value_unset: 1
]
import Plymio.Codi.Error,
only: [
new_error_result: 1
]
import Plymio.Fontais.Option,
only: [
opts_take_canonical_keys: 2,
opts_create_aliases_dict: 1
]
import Plymio.Codi.Utility,
only: [
validate_since: 1,
validate_deprecated: 1
]
import Plymio.Codi.CPO,
only: [
cpo_fetch_form: 1,
cpo_get_since: 1,
cpo_get_deprecated: 1,
cpo_done_with_edited_form: 2
]
@pattern_form_kvs_alias [
@plymio_codi_key_alias_pattern,
@plymio_codi_key_alias_status,
@plymio_codi_key_alias_form,
@plymio_codi_key_alias_forms_edit
]
@pattern_form_dict_alias @pattern_form_kvs_alias
|> opts_create_aliases_dict
@doc false
def cpo_pattern_form_normalise(opts, dict \\ nil) do
opts |> opts_take_canonical_keys(dict || @pattern_form_dict_alias)
end
@pattern_since_kvs_alias [
@plymio_codi_key_alias_pattern,
@plymio_codi_key_alias_status,
@plymio_codi_key_alias_since,
@plymio_codi_key_alias_forms_edit
]
@pattern_since_dict_alias @pattern_since_kvs_alias
|> opts_create_aliases_dict
@doc false
def cpo_pattern_since_normalise(opts, dict \\ nil) do
opts |> opts_take_canonical_keys(dict || @pattern_since_dict_alias)
end
@pattern_deprecated_kvs_alias [
@plymio_codi_key_alias_pattern,
@plymio_codi_key_alias_status,
@plymio_codi_key_alias_deprecated,
@plymio_codi_key_alias_forms_edit
]
@pattern_deprecated_dict_alias @pattern_deprecated_kvs_alias
|> opts_create_aliases_dict
@doc false
def cpo_pattern_deprecated_normalise(opts, dict \\ nil) do
opts |> opts_take_canonical_keys(dict || @pattern_deprecated_dict_alias)
end
@doc false
def express_pattern(codi, pattern, opts)
def express_pattern(%CODI{} = state, pattern, cpo)
when pattern == @plymio_codi_pattern_form do
with {:ok, cpo} <- cpo |> cpo_pattern_form_normalise,
{:ok, form} <- cpo |> cpo_fetch_form,
{:ok, cpo} <- cpo |> cpo_done_with_edited_form(form) do
{:ok, {cpo, state}}
else
{:error, %{__exception__: true}} = result -> result
end
end
def express_pattern(%CODI{} = state, pattern, cpo)
when pattern == @plymio_codi_pattern_since do
with {:ok, since} <- cpo |> cpo_get_since do
since
|> is_value_unset
|> case do
true ->
# drop the pattern
{:ok, {[], state}}
_ ->
with {:ok, since} <- since |> validate_since do
pattern_form =
quote do
@since unquote(since)
end
with {:ok, cpo} <- cpo |> cpo_done_with_edited_form(pattern_form) do
{:ok, {cpo, state}}
else
{:error, %{__exception__: true}} = result -> result
end
else
{:error, %{__exception__: true}} = result -> result
end
end
else
{:error, %{__exception__: true}} = result -> result
end
end
def express_pattern(%CODI{} = state, pattern, cpo)
when pattern == @plymio_codi_pattern_deprecated do
with {:ok, deprecated} <- cpo |> cpo_get_deprecated do
deprecated
|> is_value_unset
|> case do
true ->
# drop the pattern
{:ok, {[], state}}
_ ->
with {:ok, deprecated} <- deprecated |> validate_deprecated do
pattern_form =
quote do
@deprecated unquote(deprecated)
end
with {:ok, cpo} <- cpo |> cpo_done_with_edited_form(pattern_form) do
{:ok, {cpo, state}}
else
{:error, %{__exception__: true}} = result -> result
end
else
{:error, %{__exception__: true}} = result -> result
end
end
else
{:error, %{__exception__: true}} = result -> result
end
end
def express_pattern(_codi, pattern, opts) do
new_error_result(m: "proxy pattern #{inspect(pattern)} invalid", v: opts)
end
end | lib/codi/pattern/other/other.ex | 0.849738 | 0.602939 | other.ex | starcoder |
defmodule ElixirSense.Plugins.Ecto.Schema do
@moduledoc false
alias ElixirSense.Core.Introspection
alias ElixirSense.Plugins.Option
alias ElixirSense.Plugins.Util
alias ElixirSense.Providers.Suggestion.Matcher
# We'll keep these values hard-coded until Ecto provides the same information
# using docs' metadata.
@on_replace_values [
raise: """
(default) - do not allow removing association or embedded
data via parent changesets
""",
mark_as_invalid: """
If attempting to remove the association or
embedded data via parent changeset - an error will be added to the parent
changeset, and it will be marked as invalid
""",
nilify: """
Sets owner reference column to `nil` (available only for
associations). Use this on a `belongs_to` column to allow the association
to be cleared out so that it can be set to a new value. Will set `action`
on associated changesets to `:replace`
""",
update: """
Updates the association, available only for `has_one` and `belongs_to`.
This option will update all the fields given to the changeset including the id
for the association
""",
delete: """
Removes the association or related data from the database.
This option has to be used carefully (see below). Will set `action` on associated
changesets to `:replace`
"""
]
@on_delete_values [
nothing: "(default) - do nothing to the associated records when the parent record is deleted",
nilify_all: "Sets the key in the associated table to `nil`",
delete_all: "Deletes the associated records when the parent record is deleted"
]
@options %{
field: [
%{
name: :default,
doc: """
Sets the default value on the schema and the struct.
The default value is calculated at compilation time, so don't use
expressions like `DateTime.utc_now` or `Ecto.UUID.generate` as
they would then be the same for all records.
"""
},
%{
name: :source,
doc: """
Defines the name that is to be used in database for this field.
This is useful when attaching to an existing database. The value should be
an atom.
"""
},
%{
name: :autogenerate,
doc: """
a `{module, function, args}` tuple for a function
to call to generate the field value before insertion if value is not set.
A shorthand value of `true` is equivalent to `{type, :autogenerate, []}`.
"""
},
%{
name: :read_after_writes,
doc: """
When true, the field is always read back
from the database after insert and updates.
For relational databases, this means the RETURNING option of those
statements is used. For this reason, MySQL does not support this
option and will raise an error if a schema is inserted/updated with
read after writes fields.
"""
},
%{
name: :virtual,
doc: """
When true, the field is not persisted to the database.
Notice virtual fields do not support `:autogenerate` nor
`:read_after_writes`.
"""
},
%{
name: :primary_key,
doc: """
When true, the field is used as part of the
composite primary key.
"""
},
%{
name: :load_in_query,
doc: """
When false, the field will not be loaded when
selecting the whole struct in a query, such as `from p in Post, select: p`.
Defaults to `true`.
"""
}
],
belongs_to: [
%{
name: :foreign_key,
doc: """
Sets the foreign key field name, defaults to the name
of the association suffixed by `_id`. For example, `belongs_to :company`
will define foreign key of `:company_id`. The associated `has_one` or `has_many`
field in the other schema should also have its `:foreign_key` option set
with the same value.
"""
},
%{
name: :references,
doc: """
Sets the key on the other schema to be used for the
association, defaults to: `:id`
"""
},
%{
name: :define_field,
doc: """
When false, does not automatically define a `:foreign_key`
field, implying the user is defining the field manually elsewhere
"""
},
%{
name: :type,
doc: """
Sets the type of automatically defined `:foreign_key`.
Defaults to: `:integer` and can be set per schema via `@foreign_key_type`
"""
},
%{
name: :on_replace,
doc: """
The action taken on associations when the record is
replaced when casting or manipulating parent changeset. May be
`:raise` (default), `:mark_as_invalid`, `:nilify`, `:update`, or `:delete`.
See `Ecto.Changeset`'s section on related data for more info.
""",
values: @on_replace_values
},
%{
name: :defaults,
doc: """
Default values to use when building the association.
It may be a keyword list of options that override the association schema
or a `{module, function, args}` that receive the struct and the owner as
arguments. For example, if you set `Post.has_many :comments, defaults: [public: true]`,
then when using `Ecto.build_assoc(post, :comments)` that comment will have
`comment.public == true`. Alternatively, you can set it to
`Post.has_many :comments, defaults: {__MODULE__, :update_comment, []}`
and `Post.update_comment(comment, post)` will be invoked.
"""
},
%{
name: :primary_key,
doc: """
If the underlying belongs_to field is a primary key
"""
},
%{
name: :source,
doc: """
Defines the name that is to be used in database for this field
"""
},
%{
name: :where,
doc: """
A filter for the association. See "Filtering associations"
in `has_many/3`.
"""
}
],
has_one: [
%{
name: :foreign_key,
doc: """
Sets the foreign key, this should map to a field on the
other schema, defaults to the underscored name of the current module
suffixed by `_id`
"""
},
%{
name: :references,
doc: """
Sets the key on the current schema to be used for the
association, defaults to the primary key on the schema
"""
},
%{
name: :through,
doc: """
If this association must be defined in terms of existing
associations. Read the section in `has_many/3` for more information
"""
},
%{
name: :on_delete,
doc: """
The action taken on associations when parent record
is deleted. May be `:nothing` (default), `:nilify_all` and `:delete_all`.
Using this option is DISCOURAGED for most relational databases. Instead,
in your migration, set `references(:parent_id, on_delete: :delete_all)`.
Opposite to the migration option, this option cannot guarantee integrity
and it is only triggered for `c:Ecto.Repo.delete/2` (and not on
`c:Ecto.Repo.delete_all/2`) and it never cascades. If posts has many comments,
which has many tags, and you delete a post, only comments will be deleted.
If your database does not support references, cascading can be manually
implemented by using `Ecto.Multi` or `Ecto.Changeset.prepare_changes/2`
""",
values: @on_delete_values
},
%{
name: :on_replace,
doc: """
The action taken on associations when the record is
replaced when casting or manipulating parent changeset. May be
`:raise` (default), `:mark_as_invalid`, `:nilify`, `:update`, or
`:delete`. See `Ecto.Changeset`'s section on related data for more info.
""",
values: @on_replace_values
},
%{
name: :defaults,
doc: """
Default values to use when building the association.
It may be a keyword list of options that override the association schema
or a `{module, function, args}` that receive the struct and the owner as
arguments. For example, if you set `Post.has_many :comments, defaults: [public: true]`,
then when using `Ecto.build_assoc(post, :comments)` that comment will have
`comment.public == true`. Alternatively, you can set it to
`Post.has_many :comments, defaults: {__MODULE__, :update_comment, []}`
and `Post.update_comment(comment, post)` will be invoked.
"""
},
%{
name: :where,
doc: """
A filter for the association. See "Filtering associations"
in `has_many/3`. It does not apply to `:through` associations.
"""
}
],
has_many: [
%{
name: :foreign_key,
doc: """
Sets the foreign key, this should map to a field on the
other schema, defaults to the underscored name of the current module
suffixed by `_id`.
"""
},
%{
name: :references,
doc: """
Sets the key on the current schema to be used for the
association, defaults to the primary key on the schema.
"""
},
%{
name: :through,
doc: """
If this association must be defined in terms of existing
associations. Read the section in `has_many/3` for more information.
"""
},
%{
name: :on_delete,
doc: """
The action taken on associations when parent record
is deleted. May be `:nothing` (default), `:nilify_all` and `:delete_all`.
Using this option is DISCOURAGED for most relational databases. Instead,
in your migration, set `references(:parent_id, on_delete: :delete_all)`.
Opposite to the migration option, this option cannot guarantee integrity
and it is only triggered for `c:Ecto.Repo.delete/2` (and not on
`c:Ecto.Repo.delete_all/2`) and it never cascades. If posts has many comments,
which has many tags, and you delete a post, only comments will be deleted.
If your database does not support references, cascading can be manually
implemented by using `Ecto.Multi` or `Ecto.Changeset.prepare_changes/2`.
""",
values: @on_delete_values
},
%{
name: :on_replace,
doc: """
The action taken on associations when the record is
replaced when casting or manipulating parent changeset. May be
`:raise` (default), `:mark_as_invalid`, `:nilify`, `:update`, or
`:delete`. See `Ecto.Changeset`'s section on related data for more info.
""",
values: @on_replace_values
},
%{
name: :defaults,
doc: """
Default values to use when building the association.
It may be a keyword list of options that override the association schema
or a `{module, function, args}` that receive the struct and the owner as
arguments. For example, if you set `Post.has_many :comments, defaults: [public: true]`,
then when using `Ecto.build_assoc(post, :comments)` that comment will have
`comment.public == true`. Alternatively, you can set it to
`Post.has_many :comments, defaults: {__MODULE__, :update_comment, []}`
and `Post.update_comment(comment, post)` will be invoked.
"""
},
%{
name: :where,
doc: """
A filter for the association. See "Filtering associations"
in `has_many/3`. It does not apply to `:through` associations.
"""
}
],
many_to_many: [
%{
name: :join_through,
doc: """
Specifies the source of the associated data.
It may be a string, like "posts_tags", representing the
underlying storage table or an atom, like `MyApp.PostTag`,
representing a schema. This option is required.
"""
},
%{
name: :join_keys,
doc: """
Specifies how the schemas are associated. It
expects a keyword list with two entries, the first being how
the join table should reach the current schema and the second
how the join table should reach the associated schema. In the
example above, it defaults to: `[post_id: :id, tag_id: :id]`.
The keys are inflected from the schema names.
"""
},
%{
name: :on_delete,
doc: """
The action taken on associations when the parent record
is deleted. May be `:nothing` (default) or `:delete_all`.
Using this option is DISCOURAGED for most relational databases. Instead,
in your migration, set `references(:parent_id, on_delete: :delete_all)`.
Opposite to the migration option, this option cannot guarantee integrity
and it is only triggered for `c:Ecto.Repo.delete/2` (and not on
`c:Ecto.Repo.delete_all/2`). This option can only remove data from the
join source, never the associated records, and it never cascades.
""",
values: Keyword.take(@on_delete_values, [:nothing, :delete_all])
},
%{
name: :on_replace,
doc: """
The action taken on associations when the record is
replaced when casting or manipulating parent changeset. May be
`:raise` (default), `:mark_as_invalid`, or `:delete`.
`:delete` will only remove data from the join source, never the
associated records. See `Ecto.Changeset`'s section on related data
for more info.
""",
values: Keyword.take(@on_replace_values, [:raise, :mark_as_invalid, :delete])
},
%{
name: :defaults,
doc: """
Default values to use when building the association.
It may be a keyword list of options that override the association schema
or a `{module, function, args}` that receive the struct and the owner as
arguments. For example, if you set `Post.has_many :comments, defaults: [public: true]`,
then when using `Ecto.build_assoc(post, :comments)` that comment will have
`comment.public == true`. Alternatively, you can set it to
`Post.has_many :comments, defaults: {__MODULE__, :update_comment, []}`
and `Post.update_comment(comment, post)` will be invoked.
"""
},
%{
name: :join_defaults,
doc: """
The same as `:defaults` but it applies to the join schema
instead. This option will raise if it is given and the `:join_through` value
is not a schema.
"""
},
%{
name: :unique,
doc: """
When true, checks if the associated entries are unique
whenever the association is cast or changed via the parent record.
For instance, it would verify that a given tag cannot be attached to
the same post more than once. This exists mostly as a quick check
for user feedback, as it does not guarantee uniqueness at the database
level. Therefore, you should also set a unique index in the database
join table, such as: `create unique_index(:posts_tags, [:post_id, :tag_id])`
"""
},
%{
name: :where,
doc: """
A filter for the association. See "Filtering associations"
in `has_many/3`
"""
},
%{
name: :join_where,
doc: """
A filter for the join table. See "Filtering associations"
in `has_many/3`
"""
}
]
}
def find_options(hint, fun) do
@options[fun] |> Option.find(hint, fun)
end
def find_option_values(hint, option, fun) do
for {value, doc} <- Enum.find(@options[fun], &(&1.name == option))[:values] || [],
value_str = inspect(value),
Matcher.match?(value_str, hint) do
%{
type: :generic,
kind: :enum_member,
label: value_str,
insert_text: Util.trim_leading_for_insertion(hint, value_str),
detail: "#{inspect(option)} value",
documentation: doc
}
end
end
def find_schemas(hint) do
for {module, _} <- :code.all_loaded(),
function_exported?(module, :__schema__, 1),
mod_str = inspect(module),
Util.match_module?(mod_str, hint) do
{doc, _} = Introspection.get_module_docs_summary(module)
%{
type: :generic,
kind: :class,
label: mod_str,
insert_text: Util.trim_leading_for_insertion(hint, mod_str),
detail: "Ecto schema",
documentation: doc
}
end
|> Enum.sort_by(& &1.label)
end
end | lib/elixir_sense/plugins/ecto/schema.ex | 0.850701 | 0.558568 | schema.ex | starcoder |
defmodule Exmoji.EmojiChar do
@moduledoc """
EmojiChar is a struct represents a single Emoji character and its associated
metadata.
## Fields
* `name` - The standardized name used in the Unicode specification to
represent this emoji character.
* `unified` - The primary unified codepoint ID for the emoji.
* `variations` - A list of all variant codepoints that may also represent this
emoji.
* `short_name` - The canonical "short name" or keyword used in many systems to
refer to this emoji. Often surrounded by `:colons:` in systems like GitHub
& Campfire.
* `short_names` - A full list of possible keywords for the emoji.
* `text` - An alternate textual representation of the emoji, for example a
smiley face emoji may be represented with an ASCII alternative. Most emoji
do not have a text alternative. This is typically used when building an
automatic translation from typed emoticons.
It also contains a few helper functions to deal with this data type.
"""
defstruct [
name: nil,
unified: nil,
variations: [],
short_name: nil,
short_names: [],
text: nil
]
alias Exmoji.EmojiChar
@doc """
Renders an `EmojiChar` to its bitstring glyph representation, suitable for
printing to screen.
By passing options field `variant_encoding` you can manually specify whether
the variant encoding selector should be used to hint to rendering devices
that "graphic" representation should be used. By default, we use this for all
Emoji characters that contain a possible variant.
"""
def render(ec, options \\ [variant_encoding: true])
def render(ec, variant_encoding: false) do
Exmoji.unified_to_char(ec.unified)
end
def render(ec, variant_encoding: true) do
case variant?(ec) do
true -> Exmoji.unified_to_char( variant(ec) )
false -> Exmoji.unified_to_char( ec.unified )
end
end
defimpl String.Chars do
def to_string(ec), do: EmojiChar.render(ec)
end
@doc """
Returns a list of all possible bitstring renderings of an `EmojiChar`.
E.g., normal, with variant selectors, etc. This is useful if you want to have
all possible values to match against when searching for the emoji in a string
representation.
"""
def chars(%EmojiChar{}=emojichar) do
codepoint_ids(emojichar)
|> Enum.map(&Exmoji.unified_to_char/1)
end
@doc """
Returns a list of all possible codepoint string IDs of an `EmojiChar`.
E.g., normal, with variant selectors, etc. This is useful if you want to have
all possible values to match against.
## Example
iex> Exmoji.from_short_name("cloud") |> Exmoji.EmojiChar.codepoint_ids
["2601","2601-FE0F"]
"""
def codepoint_ids(%EmojiChar{unified: uid, variations: variations}) do
[uid] ++ variations
end
@doc """
Is the `EmojiChar` represented by a doublebyte codepoint in Unicode?
"""
def doublebyte?(%EmojiChar{unified: id}) do
id |> String.contains?("-")
end
@doc """
Does the `EmojiChar` have an alternate Unicode variant encoding?
"""
def variant?(%EmojiChar{variations: variations}) do
length(variations) > 0
end
@doc """
Returns the most likely variant-encoding codepoint ID for an `EmojiChar`.
For now we only know of one possible variant encoding for certain characters,
but there could be others in the future.
This is typically used to force Emoji rendering for characters that could be
represented in standard font glyphs on certain operating systems.
The resulting encoded string will be two codepoints, or three codepoints for
doublebyte Emoji characters.
If there is no variant-encoding for a character, returns nil.
"""
def variant(%EmojiChar{variations: variations}) do
List.first variations
end
end | lib/exmoji/emoji_char.ex | 0.903628 | 0.433921 | emoji_char.ex | starcoder |
defmodule Geocoder.Providers.GoogleMaps do
use HTTPoison.Base
use Towel
@endpoint "https://maps.googleapis.com/"
def geocode(opts) do
request("maps/api/geocode/json", extract_opts(opts))
|> fmap(&parse_geocode/1)
end
def geocode_list(opts) do
request_all("maps/api/geocode/json", extract_opts(opts))
|> fmap(fn(r) -> Enum.map(r, &parse_geocode/1) end)
end
def reverse_geocode(opts) do
request("maps/api/geocode/json", extract_opts(opts))
|> fmap(&parse_reverse_geocode/1)
end
def reverse_geocode_list(opts) do
request_all("maps/api/geocode/json", extract_opts(opts))
|> fmap(fn(r) -> Enum.map(r, &parse_reverse_geocode/1) end)
end
defp extract_opts(opts) do
opts
|> Keyword.take([:key, :address, :components, :bounds, :language, :region,
:latlng, :placeid, :result_type, :location_type])
|> Keyword.update(:latlng, nil, fn
{lat, lng} -> "#{lat},#{lng}"
q -> q
end)
|> Keyword.delete(:latlng, nil)
end
defp parse_geocode(response) do
coords = geocode_coords(response)
bounds = geocode_bounds(response)
location = geocode_location(response)
%{coords | bounds: bounds, location: location}
end
defp parse_reverse_geocode(response) do
coords = geocode_coords(response)
location = geocode_location(response)
%{coords | location: location}
end
defp geocode_coords(%{"geometry" => %{"location" => coords}}) do
%{"lat" => lat, "lng" => lon} = coords
%Geocoder.Coords{lat: lat, lon: lon}
end
defp geocode_bounds(%{"geometry" => %{"bounds" => bounds}}) do
%{"northeast" => %{"lat" => north, "lng" => east},
"southwest" => %{"lat" => south, "lng" => west}} = bounds
%Geocoder.Bounds{top: north, right: east, bottom: south, left: west}
end
defp geocode_bounds(_), do: %Geocoder.Bounds{}
@components ["locality", "administrative_area_level_1", "administrative_area_level_2", "country", "postal_code", "street", "street_number", "route"]
@map %{
"street_number" => :street_number,
"route" => :street,
"street_address" => :street,
"locality" => :city,
"administrative_area_level_1" => :state,
"administrative_area_level_2" => :county,
"postal_code" => :postal_code,
"country" => :country
}
defp geocode_location(%{"address_components" => components, "formatted_address" => formatted_address}) do
name = &Map.get(&1, "long_name")
type = fn component ->
component |> Map.get("types") |> Enum.find(&Enum.member?(@components, &1))
end
map = &({type.(&1), name.(&1)})
reduce = fn {type, name}, location ->
Map.put(location, Map.get(@map, type), name)
end
country = Enum.find(components, fn(component) ->
component |> Map.get("types") |> Enum.member?("country")
end)
country_code = case country do
nil ->
nil
%{"short_name" => name} ->
name
end
location = %Geocoder.Location{country_code: country_code, formatted_address: formatted_address}
components
|> Enum.filter_map(type, map)
|> Enum.reduce(location, reduce)
end
defp request_all(path, params) do
httpoison_options = Application.get_env(:geocoder, Geocoder.Worker)[:httpoison_options] || []
get(path, [], Keyword.merge(httpoison_options, params: Enum.into(params, %{})))
|> fmap(&Map.get(&1, :body))
|> fmap(&Map.get(&1, "results"))
end
defp request(path, params) do
request_all(path, params)
|> fmap(&List.first/1)
end
defp process_url(url) do
@endpoint <> url
end
defp process_response_body(body) do
body |> Poison.decode!
end
end | lib/geocoder/providers/google_maps.ex | 0.582491 | 0.51312 | google_maps.ex | starcoder |
defmodule Cldr.Currency.Backend do
@moduledoc false
def define_currency_module(config) do
require Cldr
require Cldr.Currency
module = inspect(__MODULE__)
backend = config.backend
config = Macro.escape(config)
quote location: :keep, bind_quoted: [module: module, backend: backend, config: config] do
defmodule Currency do
unless Cldr.Config.include_module_docs?(config.generate_docs) do
@moduledoc false
end
@doc """
Returns a `Currency` struct created from the arguments.
## Arguments
* `currency` is a private use currency code in a format defined by
[ISO4217](https://en.wikipedia.org/wiki/ISO_4217)
which is `X` followed by two alphanumeric characters.
* `options` is a map of options representing the optional elements of
the `Cldr.Currency.t` struct.
## Options
* `:name` is the name of the currency. Required.
* `:digits` is the precision of the currency. Required.
* `:symbol` is the currency symbol. Optional.
* `:narrow_symbol` is an alternative narrow symbol. Optional.
* `:round_nearest` is the rounding precision such as `0.05`. Optional.
* `:alt_code` is an alternative currency code for application use.
* `:cash_digits` is the precision of the currency when used as cash. Optional.
* `:cash_rounding_nearest` is the rounding precision when used as cash
such as `0.05`. Optional.
## Returns
* `{:ok, Cldr.Currency.t}` or
* `{:error, {exception, message}}`
## Example
iex> #{inspect(__MODULE__)}.new(:XAA, name: "Custom Name", digits: 0)
{:ok,
%Cldr.Currency{
alt_code: :XAA,
cash_digits: 0,
cash_rounding: nil,
code: :XAA,
count: %{other: "Custom Name"},
digits: 0,
from: nil,
iso_digits: 0,
name: "Custom Name",
narrow_symbol: nil,
rounding: 0,
symbol: "XAA",
tender: false,
to: nil
}}
iex> MyApp.Cldr.Currency.new(:XAA, name: "Custom Name")
{:error, "Required options are missing. Required options are [:name, :digits]"}
iex> #{inspect(__MODULE__)}.new(:XBC)
{:error, {Cldr.CurrencyAlreadyDefined, "Currency :XBC is already defined."}}
"""
@spec new(Cldr.Currency.code(), map() | Keyword.t) ::
{:ok, Cldr.Currency.t} | {:error, {module(), String.t}}
def new(currency, options \\ [])
def new(currency, options) do
Cldr.Currency.new(currency, options)
end
@doc """
Returns the appropriate currency display name for the `currency`, based
on the plural rules in effect for the `locale`.
## Arguments
* `number` is an integer, float or `Decimal`
* `currency` is any currency returned by `Cldr.Currency.known_currencies/0`
* `options` is a keyword list of options
## Options
* `locale` is any valid locale name returned by `MyApp.Cldr.known_locale_names/0`
or a `Cldr.LanguageTag` struct returned by `MyApp.Cldr.Locale.new!/1`. The
default is `#{inspect backend}.get_locale/0`
## Returns
* `{:ok, plural_string}` or
* `{:error, {exception, message}}`
## Examples
iex> #{inspect(__MODULE__)}.pluralize 1, :USD
{:ok, "US dollar"}
iex> #{inspect(__MODULE__)}.pluralize 3, :USD
{:ok, "US dollars"}
iex> #{inspect(__MODULE__)}.pluralize 12, :USD, locale: "zh"
{:ok, "美元"}
iex> #{inspect(__MODULE__)}.pluralize 12, :USD, locale: "fr"
{:ok, "dollars des États-Unis"}
iex> #{inspect(__MODULE__)}.pluralize 1, :USD, locale: "fr"
{:ok, "dollar des États-Unis"}
"""
@spec pluralize(pos_integer, atom, Keyword.t()) ::
{:ok, String.t()} | {:error, {module(), String.t()}}
def pluralize(number, currency, options \\ []) do
Cldr.Currency.pluralize(number, currency, unquote(backend), options)
end
@doc """
Returns a list of all known currency codes.
## Example
iex> #{inspect(__MODULE__)}.known_currency_codes |> Enum.count
303
"""
@spec known_currency_codes() :: list(atom)
def known_currency_codes do
Cldr.Currency.known_currency_codes()
end
@deprecate "Use #{inspect(__MODULE__)}.known_currency_codes/0"
defdelegate known_currencies, to: __MODULE__, as: :known_currency_codes
@doc """
Returns a boolean indicating if the supplied currency code is known.
## Arguments
* `currency_code` is a `binary` or `atom` representing an ISO4217
currency code
## Returns
* `true` or `false`
## Examples
iex> #{inspect(__MODULE__)}.known_currency_code? "AUD"
true
iex> #{inspect(__MODULE__)}.known_currency_code? "GGG"
false
iex> #{inspect(__MODULE__)}.known_currency_code? :XCV
false
"""
@spec known_currency_code?(Cldr.Currency.code()) :: boolean
def known_currency_code?(currency_code) do
Cldr.Currency.known_currency_code?(currency_code)
end
@doc """
Returns a 2-tuple indicating if the supplied currency code is known.
## Arguments
* `currency_code` is a `binary` or `atom` representing an ISO4217
currency code
## Returns
* `{:ok, currency_code}` or
* `{:error, {exception, reason}}`
## Examples
iex> #{inspect(__MODULE__)}.known_currency_code "AUD"
{:ok, :AUD}
iex> #{inspect(__MODULE__)}.known_currency_code "GGG"
{:error, {Cldr.UnknownCurrencyError, "The currency \\"GGG\\" is invalid"}}
"""
@spec known_currency_code(Cldr.Currency.code()) ::
{:ok, Cldr.Currency.code} | {:error, {module, String.t}}
def known_currency_code(currency_code) do
Cldr.Currency.known_currency_code(currency_code)
end
@deprecate "Use #{inspect(__MODULE__)}.known_currency_code?/0"
defdelegate known_currency?(code), to: __MODULE__, as: :known_currency_code?
@doc """
Returns the effective currency for a given locale
## Arguments
* `locale` is a `Cldr.LanguageTag` struct returned by
`Cldr.Locale.new!/2`
## Returns
* A ISO 4217 currency code as an upcased atom
## Examples
iex> {:ok, locale} = #{inspect backend}.validate_locale "en"
iex> #{inspect __MODULE__}.currency_from_locale locale
:USD
iex> {:ok, locale} = #{inspect backend}.validate_locale "en-AU"
iex> #{inspect __MODULE__}.currency_from_locale locale
:AUD
iex> #{inspect __MODULE__}.currency_from_locale "en-GB"
:GBP
"""
def currency_from_locale(%LanguageTag{} = locale) do
Cldr.Currency.currency_from_locale(locale)
end
def currency_from_locale(locale) when is_binary(locale) do
Cldr.Currency.currency_from_locale(locale, unquote(backend))
end
@doc """
Returns the currency metadata for the requested currency code.
## Arguments
* `currency_code` is a `binary` or `atom` representation of an
ISO 4217 currency code.
## Examples
iex> #{inspect(__MODULE__)}.currency_for_code("AUD")
{:ok,
%Cldr.Currency{
cash_digits: 2,
cash_rounding: 0,
code: "AUD",
count: %{one: "Australian dollar", other: "Australian dollars"},
digits: 2,
iso_digits: 2,
name: "Australian Dollar",
narrow_symbol: "$",
rounding: 0,
symbol: "A$",
tender: true
}}
iex> #{inspect(__MODULE__)}.currency_for_code("THB")
{:ok,
%Cldr.Currency{
cash_digits: 2,
cash_rounding: 0,
code: "THB",
count: %{one: "Thai baht", other: "Thai baht"},
digits: 2,
iso_digits: 2,
name: "<NAME>",
narrow_symbol: "฿",
rounding: 0,
symbol: "THB",
tender: true
}}
"""
@spec currency_for_code(Cldr.Currency.code, Keyword.t()) ::
{:ok, Cldr.Currency.t} | {:error, {module(), String.t()}}
def currency_for_code(
currency_code,
options \\ [locale: unquote(backend).default_locale()]
) do
Cldr.Currency.currency_for_code(currency_code, unquote(backend), options)
end
defp get_currency_metadata(code, nil) do
string_code = to_string(code)
{:ok, meta} =
new(code,
name: string_code,
symbol: string_code,
narrow_symbol: string_code,
count: %{other: string_code}
)
meta
end
defp get_currency_metadata(_code, meta) do
meta
end
@doc """
Returns a map of the metadata for all currencies for
a given locale.
## Arguments
* `locale` is any valid locale name returned by `MyApp.Cldr.known_locale_names/0`
or a `Cldr.LanguageTag` struct returned by `MyApp.Cldr.Locale.new!/1`
* `currency_status` is `:all`, `:current`, `:historic`,
`unannotated` or `:tender`; or a list of one or more status.
The default is `:all`. See `Cldr.Currency.currency_filter/2`.
## Returns
* `{:ok, currency_map}` or
* `{:error, {exception, reason}}`
## Example
MyApp.Cldr.Currency.currencies_for_locale "en"
=> {:ok,
%{
FJD: %Cldr.Currency{
cash_digits: 2,
cash_rounding: 0,
code: "FJD",
count: %{one: "Fijian dollar", other: "Fijian dollars"},
digits: 2,
from: nil,
iso_digits: 2,
name: "Fijian Dollar",
narrow_symbol: "$",
rounding: 0,
symbol: "FJD",
tender: true,
to: nil
},
SUR: %Cldr.Currency{
cash_digits: 2,
cash_rounding: 0,
code: "SUR",
count: %{one: "Soviet rouble", other: "Soviet roubles"},
digits: 2,
from: nil,
iso_digits: nil,
name: "Soviet Rouble",
narrow_symbol: nil,
rounding: 0,
symbol: "SUR",
tender: true,
to: nil
},
...
}}
"""
@spec currencies_for_locale(
Cldr.Locale.locale_name() | LanguageTag.t(),
only :: Cldr.Currency.filter(),
except :: Cldr.Currency.filter()
) ::
{:ok, map()} | {:error, {module(), String.t()}}
@dialyzer {:nowarn_function, currencies_for_locale: 3}
def currencies_for_locale(locale, only \\ :all, except \\ nil)
@doc """
Returns a map that matches a currency string to a
currency code.
A currency string is a localised name or symbol
representing a currency in a locale-specific manner.
## Arguments
* `locale` is any valid locale name returned by `MyApp.Cldr.known_locale_names/0`
or a `Cldr.LanguageTag` struct returned by `MyApp.Cldr.Locale.new!/1`
* `currency_status` is `:all`, `:current`, `:historic`,
`unannotated` or `:tender`; or a list of one or more status.
The default is `:all`. See `Cldr.Currency.currency_filter/2`.
## Returns
* `{:ok, currency_string_map}` or
* `{:error, {exception, reason}}`
## Example
MyApp.Cldr.Currency.currency_strings "en"
=> {:ok,
%{
"mexican silver pesos" => :MXP,
"sudanese dinar" => :SDD,
"bad" => :BAD,
"rsd" => :RSD,
"swazi lilangeni" => :SZL,
"zairean new zaire" => :ZRN,
"guyanaese dollars" => :GYD,
"equatorial guinean ekwele" => :GQE,
...
}}
"""
@spec currency_strings(Cldr.LanguageTag.t() | Cldr.Locale.locale_name(),
only :: Cldr.Currency.filter(),
except :: Cldr.Currency.filter()) ::
{:ok, map()} | {:error, {module(), String.t()}}
@dialyzer {:nowarn_function, currency_strings: 3}
def currency_strings(locale, only \\ :all, except \\ nil)
for locale_name <- Cldr.Config.known_locale_names(config) do
currencies =
locale_name
|> Cldr.Config.currencies_for!(config)
|> Enum.map(fn {k, v} -> {k, struct(Cldr.Currency, v)} end)
|> Map.new()
currency_strings =
for {currency_code, currency} <- Cldr.Config.currencies_for!(locale_name, config) do
strings =
([currency.name, currency.symbol, currency.code] ++ Map.values(currency.count))
|> Enum.reject(&is_nil/1)
|> Enum.map(&String.downcase/1)
|> Enum.map(&String.trim_trailing(&1, "."))
|> Enum.uniq()
{currency_code, strings}
end
inverted_currency_strings =
Cldr.Currency.invert_currency_strings(currency_strings)
|> Cldr.Currency.remove_duplicate_strings(currencies)
|> Map.new
def currencies_for_locale(
%LanguageTag{cldr_locale_name: unquote(locale_name)},
only, except
) do
filtered_currencies =
unquote(Macro.escape(currencies))
|> Cldr.Currency.currency_filter(only, except)
{:ok, filtered_currencies}
end
def currency_strings(%LanguageTag{cldr_locale_name: unquote(locale_name)}, :all, nil) do
{:ok, unquote(Macro.escape(inverted_currency_strings))}
end
end
def currencies_for_locale(locale_name, only, except) when is_binary(locale_name) do
with {:ok, locale} <- Cldr.validate_locale(locale_name, unquote(backend)) do
currencies_for_locale(locale, only, except)
end
end
def currencies_for_locale(locale, _only, _except) do
{:error, Cldr.Locale.locale_error(locale)}
end
def currency_strings(locale_name, only, except) when is_binary(locale_name) do
with {:ok, locale} <- Cldr.validate_locale(locale_name, unquote(backend)) do
currency_strings(locale, only, except)
end
end
def currency_strings(%LanguageTag{} = locale, only, except) do
with {:ok, currencies} <- currencies_for_locale(locale) do
filtered_currencies =
currencies
|> Cldr.Currency.currency_filter(only, except)
currency_codes =
filtered_currencies
|> Map.keys()
strings =
locale
|> currency_strings!
|> Enum.filter(fn {_k, v} -> v in currency_codes end)
|> Cldr.Currency.remove_duplicate_strings(filtered_currencies)
|> Map.new()
{:ok, strings}
end
end
def currency_strings(locale, _only, _except) do
{:error, Cldr.Locale.locale_error(locale)}
end
@doc """
Returns a map of the metadata for all currencies for
a given locale and raises on error.
## Arguments
* `locale` is any valid locale name returned by `MyApp.Cldr.known_locale_names/0`
or a `Cldr.LanguageTag` struct returned by `MyApp.Cldr.Locale.new!/1`
* `currency_status` is `:all`, `:current`, `:historic`,
`unannotated` or `:tender`; or a list of one or more status.
The default is `:all`. See `Cldr.Currency.currency_filter/2`.
## Returns
* `{:ok, currency_map}` or
* raises an exception
## Example
MyApp.Cldr.Currency.currencies_for_locale! "en"
=> %{
FJD: %Cldr.Currency{
cash_digits: 2,
cash_rounding: 0,
code: "FJD",
count: %{one: "Fijian dollar", other: "Fijian dollars"},
digits: 2,
from: nil,
iso_digits: 2,
name: "Fijian Dollar",
narrow_symbol: "$",
rounding: 0,
symbol: "FJD",
tender: true,
to: nil
},
SUR: %Cldr.Currency{
cash_digits: 2,
cash_rounding: 0,
code: "SUR",
count: %{one: "Soviet rouble", other: "Soviet roubles"},
digits: 2,
from: nil,
iso_digits: nil,
name: "Soviet Rouble",
narrow_symbol: nil,
rounding: 0,
symbol: "SUR",
tender: true,
to: nil
},
...
}
"""
@spec currencies_for_locale(Cldr.Locale.locale_name() | LanguageTag.t(),
only :: Cldr.Currency.filter(), except :: Cldr.Currency.filter()) ::
map() | no_return()
def currencies_for_locale!(locale, only \\ :all, except \\ nil) do
case currencies_for_locale(locale, only, except) do
{:ok, currencies} -> currencies
{:error, {exception, reason}} -> raise exception, reason
end
end
@doc """
Returns a map that matches a currency string to a
currency code or raises an exception.
A currency string is a localised name or symbol
representing a currency in a locale-specific manner.
## Arguments
* `locale` is any valid locale name returned by `MyApp.Cldr.known_locale_names/0`
or a `Cldr.LanguageTag` struct returned by `MyApp.Cldr.Locale.new!/1`
* `currency_status` is `:all`, `:current`, `:historic`,
`unannotated` or `:tender`; or a list of one or more status.
The default is `:all`. See `Cldr.Currency.currency_filter/2`.
## Returns
* `{:ok, currency_string_map}` or
* raises an exception
## Example
MyApp.Cldr.Currency.currency_strings! "en"
=> %{
"mexican silver pesos" => :MXP,
"sudanese dinar" => :SDD,
"bad" => :BAD,
"rsd" => :RSD,
"swazi lilangeni" => :SZL,
"zairean new zaire" => :ZRN,
"guyanaese dollars" => :GYD,
"equatorial guinean ekwele" => :GQE,
...
}
"""
@spec currency_strings!(Cldr.LanguageTag.t() | Cldr.Locale.locale_name(),
only :: Cldr.Currency.filter(), except :: Cldr.Currency.filter()) ::
map() | no_return()
def currency_strings!(locale_name, only \\ :all, except \\ nil) do
case currency_strings(locale_name, only, except) do
{:ok, currency_strings} -> currency_strings
{:error, {exception, reason}} -> raise exception, reason
end
end
@doc """
Returns the strings associated with a currency
in a given locale.
## Arguments
* `currency` is an ISO4217 currency code
* `locale` is any valid locale name returned by `MyApp.Cldr.known_locale_names/0`
or a `Cldr.LanguageTag` struct returned by `MyApp.Cldr.Locale.new!/1`
## Returns
* A list of strings or
* `{:error, {exception, reason}}`
## Example
iex> MyApp.Cldr.Currency.strings_for_currency :AUD, "en"
["a$", "australian dollars", "aud", "australian dollar"]
"""
def strings_for_currency(currency, locale) do
Cldr.Currency.strings_for_currency(currency, locale, unquote(backend))
end
@doc """
Returns a list of historic and the current
currency for a given locale.
## Arguments
* `locale` is any valid locale name returned by `MyApp.Cldr.known_locale_names/0`
or a `Cldr.LanguageTag` struct returned by `MyApp.Cldr.Locale.new!/1`
## Example
iex> MyApp.Cldr.Currency.currency_history_for_locale "en"
{:ok,
%{
USD: %{from: ~D[1792-01-01], to: nil},
USN: %{tender: false},
USS: %{from: nil, tender: false, to: ~D[2014-03-01]}
}
}
"""
@spec currency_history_for_locale(LanguageTag.t | Cldr.Locale.locale_name) ::
map() | {:error, {module(), String.t}}
def currency_history_for_locale(%LanguageTag{} = language_tag) do
Cldr.Currency.currency_history_for_locale(language_tag)
end
def currency_history_for_locale(locale_name) when is_binary(locale_name) do
Cldr.Currency.currency_history_for_locale(locale_name, unquote(backend))
end
@doc """
Returns the current currency for a given locale.
This function does not consider the `U` extenion
parameters `cu` or `rg`. It is recommended to us
`Cldr.Currency.currency_from_locale/1` in most
circumstances.
## Arguments
* `locale` is any valid locale name returned by `MyApp.Cldr.known_locale_names/0`
or a `Cldr.LanguageTag` struct returned by `MyApp.Cldr.Locale.new!/1`
## Example
iex> MyApp.Cldr.Currency.current_currency_from_locale "en"
:USD
iex> MyApp.Cldr.Currency.current_currency_from_locale "en-AU"
:AUD
"""
def current_currency_from_locale(%LanguageTag{} = locale) do
Cldr.Currency.current_currency_from_locale(locale)
end
def current_currency_from_locale(locale_name) when is_binary(locale_name) do
Cldr.Currency.current_currency_from_locale(locale_name, unquote(backend))
end
end
end
end
end | lib/cldr/backend.ex | 0.927252 | 0.583174 | backend.ex | starcoder |
defmodule ExRajaOngkir.Cost do
alias ExRajaOngkir.Request
defstruct [
:weight_unit,
:courier_code,
:courier_name,
:description,
:service_name,
:estimates,
:params
]
def calculate!(from, to, weight, courier, opts \\ []) do
{:ok, result} = calculate(from, to, weight, courier, opts)
result
end
def calculate(from, to, weight, courier, opts \\ [])
def calculate(from, to, weight, courier, opts) when is_list(courier) do
calculate(from, to, weight, Enum.join(courier, ":"), opts)
end
def calculate(from, to, weight, courier, opts)
when is_integer(weight) and is_binary(courier) do
struct = make_struct(from, to, weight, courier, opts)
response =
struct
|> make_params()
|> request()
|> Request.take_result()
response
|> case do
{:ok, results} -> {:ok, response_into(results, struct)}
{:error, reason} -> {:error, reason}
end
end
defp make_struct(from, to, weight, courier, opts) do
%__MODULE__{
params: %{
origin: from,
destination: to,
weight: weight,
courier: courier,
opts: opts
}
}
end
defp make_params(%__MODULE__{params: params}) do
make_params_by_plan(
ExRajaOngkir.plan(),
params
)
end
defp make_params_by_plan(:starter, %{
origin: %{id: origin_id},
destination: %{id: destination_id},
weight: weight,
courier: courier
}) do
%{origin: origin_id, destination: destination_id, weight: weight, courier: courier}
end
defp make_params_by_plan(:basic, params) do
make_params_by_plan(:starter, params)
end
@defult_origin_type 'city'
@defult_destination_type 'city'
defp make_params_by_plan(:pro, %{opts: opts} = params) do
Map.merge(make_params_by_plan(:basic, params), %{
originType: opts[:origin_type] || @defult_origin_type,
destinationType: opts[:destination_type] || @defult_destination_type
})
end
defp request(params) do
Request.post(
"cost",
headers: ["Content-Type": "application/x-www-form-urlencoded"],
body:
params
|> Enum.map(fn {key, value} -> "#{key}=#{value}" end)
|> Enum.join("&")
)
end
defp response_into(response, %__MODULE__{} = struct) do
response
|> Enum.map(fn row ->
base_struct = %{
struct
| weight_unit: 'g',
courier_code: row["code"],
courier_name: row["name"]
}
{
base_struct.courier_code |> String.to_atom(),
Enum.map(row["costs"], fn cost ->
%{
base_struct
| description: cost["description"],
service_name: cost["service"],
estimates: ExRajaOngkir.Estimate.cast_from_response(cost["cost"])
}
end)
}
end)
|> Enum.into(%{})
end
end | lib/ex_raja_ongkir/cost.ex | 0.668988 | 0.501343 | cost.ex | starcoder |
defmodule Cldr.Calendar.Duration do
@moduledoc """
Functions to create and format a difference between
two dates, times or datetimes.
The difference between two dates (or times or datetimes) is
usually defined in terms of days or seconds.
A duration is calculated as the difference in time in calendar
units: years, months, days, hours, minutes, seconds and microseconds.
This is useful to support formatting a string for users in
easy-to-understand terms. For example `11 months, 3 days and 4 minutes`
is a lot easier to understand than `28771440` seconds.
The package [ex_cldr_units](https://hex.pm/packages/ex_cldr_units) can
be optionally configured to provide localized formatting of durations.
If configured, the following providers should be configured in the
appropriate CLDR backend module. For example:
```elixir
defmodule MyApp.Cldr do
use Cldr,
locales: ["en", "ja"],
providers: [Cldr.Calendar, Cldr.Number, Cldr.Unit, Cldr.List]
end
```
"""
@struct_list [year: 0, month: 0, day: 0, hour: 0, minute: 0, second: 0, microsecond: 0]
@keys Keyword.keys(@struct_list)
defstruct @struct_list
@typedoc "Measure a duration in calendar units"
@type t :: %__MODULE__{
year: non_neg_integer(),
month: non_neg_integer(),
day: non_neg_integer(),
hour: non_neg_integer(),
minute: non_neg_integer(),
second: non_neg_integer(),
microsecond: non_neg_integer()
}
@typedoc "A date, time or datetime"
@type date_or_datetime ::
Calendar.date() | Calendar.time() | Calendar.datetime() | Calendar.naive_datetime()
@microseconds_in_second 1_000_000
@microseconds_in_day 86_400_000_000
defimpl String.Chars do
def to_string(duration) do
Cldr.Calendar.Duration.to_string!(duration)
end
end
if Code.ensure_loaded?(Cldr.Unit) do
@doc """
Returns a string formatted representation of
a duration.
Note that time units that are zero are ommitted
from the output.
Formatting is
## Arguments
* `duration` is a duration of type `t()` returned
by `Cldr.Calendar.Duration.new/2`
* `options` is a Keyword list of options
## Options
* `:except` is a list of time units to be omitted from
the formatted output. It may be useful to use
`except: [:microsecond]` for example. The default is
`[]`.
* `locale` is any valid locale name returned by `Cldr.known_locale_names/1`
or a `Cldr.LanguageTag` struct returned by `Cldr.Locale.new!/2`
The default is `Cldr.get_locale/0`
* `backend` is any module that includes `use Cldr` and therefore
is a `Cldr` backend module. The default is `Cldr.default_backend/0`
* `:list_options` is a list of options passed to `Cldr.List.to_string/3` to
control the final list output.
Any other options are passed to `Cldr.Number.to_string/3` and
`Cldr.Unit.to_string/3` during the formatting process.
## Example
iex> {:ok, duration} = Cldr.Calendar.Duration.new(~D[2019-01-01], ~D[2019-12-31])
iex> Cldr.Calendar.Duration.to_string(duration)
{:ok, "11 months and 30 days"}
"""
def to_string(%__MODULE__{} = duration, options \\ []) do
{except, options} = Keyword.pop(options, :except, [])
for key <- @keys, value = Map.get(duration, key), value != 0 && key not in except do
Cldr.Unit.new!(key, value)
end
|> Cldr.Unit.to_string(options)
end
else
@doc """
Returns a string formatted representation of
a duration.
Note that time units that are zero are ommitted
from the output.
## Localized formatting
If localized formatting of a duration is desired,
add `{:ex_cldr_units, "~> 2.0"}` to your `mix.exs`
and ensure you have configured your providers in
your backend configuration to include: `providers:
[Cldr.Calendar, Cldr.Number, Cldr.Unit, Cldr.List]`
## Arguments
* `duration` is a duration of type `t()` returned
by `Cldr.Calendar.Duration.new/2`
* `options` is a Keyword list of options
## Options
* `:except` is a list of time units to be omitted from
the formatted output. It may be useful to use
`except: [:microsecond]` for example. The default is
`[]`.
## Example
iex> {:ok, duration} = Cldr.Calendar.Duration.new(~D[2019-01-01], ~D[2019-12-31])
iex> Cldr.Calendar.Duration.to_string(duration)
{:ok, "11 months, 30 days"}
"""
def to_string(%__MODULE__{} = duration, options \\ []) do
except = Keyword.get(options, :except, [])
formatted =
for key <- @keys, value = Map.get(duration, key), value != 0 && key not in except do
if value > 1, do: "#{value} #{key}s", else: "#{value} #{key}"
end
|> Enum.join(", ")
{:ok, formatted}
end
end
@doc """
Formats a duration as a string or raises
an exception on error.
## Arguments
* `duration` is a duration of type `t()` returned
by `Cldr.Calendar.Duration.new/2`
* `options` is a Keyword list of options
## Options
See `Cldr.Calendar.Duration.to_string/2`
## Returns
* A formatted string or
* raises an exception
"""
@spec to_string!(t(), Keyword.t()) :: String.t() | no_return
def to_string!(%__MODULE__{} = duration, options \\ []) do
case to_string(duration, options) do
{:ok, string} -> string
{:error, {exception, reason}} -> raise exception, reason
end
end
@doc """
Calculates the calendar difference between two dates
returning a `Duration` struct.
The difference calculated is in terms of years, months,
days, hours, minutes, seconds and microseconds.
## Arguments
* `from` is a date, time or datetime representing the
start of the duration
* `to` is a date, time or datetime representing the
end of the duration
Note that `from` must be before or at the same time
as `to`. In addition, both `from` and `to` must
be in the same calendar.
## Returns
* A `{:ok, duration struct}` tuple or a
* `{:error, {exception, reason}}` tuple
## Example
iex> Cldr.Calendar.Duration.new(~D[2019-01-01], ~D[2019-12-31])
{:ok,
%Cldr.Calendar.Duration{
year: 0,
month: 11,
day: 30,
hour: 0,
microsecond: 0,
minute: 0,
second: 0
}}
"""
@spec new(from :: date_or_datetime(), to :: date_or_datetime()) ::
{:ok, t()} | {:error, {module(), String.t()}}
def new(%{calendar: calendar} = from, %{calendar: calendar} = to) do
time_diff = time_duration(from, to)
date_diff = date_duration(from, to)
duration =
if time_diff < 0 do
back_one_day(date_diff, calendar) |> merge(@microseconds_in_day + time_diff)
else
date_diff |> merge(time_diff)
end
{:ok, duration}
end
def new(%{calendar: _calendar1} = from, %{calendar: _calendar2} = to) do
{:error,
{Cldr.IncompatibleCalendarError,
"The two dates must be in the same calendar. Found #{inspect(from)} and #{inspect(to)}"}}
end
@doc """
Calculates the calendar difference between two dates
returning a `Duration` struct.
The difference calculated is in terms of years, months,
days, hours, minutes, seconds and microseconds.
## Arguments
* `from` is a date, time or datetime representing the
start of the duration
* `to` is a date, time or datetime representing the
end of the duration
Note that `from` must be before or at the same time
as `to`. In addition, both `from` and `to` must
be in the same calendar.
## Returns
* A `duration` struct or
* raises an exception
## Example
iex> Cldr.Calendar.Duration.new!(~D[2019-01-01], ~D[2019-12-31])
%Cldr.Calendar.Duration{
year: 0,
month: 11,
day: 30,
hour: 0,
microsecond: 0,
minute: 0,
second: 0
}
"""
@spec new!(from :: date_or_datetime(), to :: date_or_datetime()) ::
t() | no_return()
def new!(from, to) do
case new(from, to) do
{:ok, duration} -> duration
{:error, {exception, reason}} -> raise exception, reason
end
end
defp time_duration(
%{hour: _, minute: _, second: _, microsecond: _, calendar: calendar} = from,
%{hour: _, minute: _, second: _, microsecond: _, calendar: calendar} = to
) do
Time.diff(to, from, :microsecond)
end
defp time_duration(_to, _from) do
0
end
defp date_duration(
%{year: year, month: month, day: day, calendar: calendar},
%{year: year, month: month, day: day, calendar: calendar}
) do
%__MODULE__{}
end
defp date_duration(%{calendar: calendar} = from, %{calendar: calendar} = to) do
if Date.compare(from, to) in [:gt] do
raise ArgumentError, "`from` date must be before or equal to `to` date"
end
%{year: year1, month: month1, day: day1} = from
%{year: year2, month: month2, day: day2} = to
# Doesnt account for era in calendars like Japanese
year_diff = year2 - year1 - possible_adjustment(month2, month1, day2, day1)
month_diff =
if month2 > month1 do
month2 - month1 - possible_adjustment(day2, day1)
else
calendar.months_in_year(year1) - month1 + month2 - possible_adjustment(day2, day1)
end
day_diff =
if day2 > day1 do
day2 - day1
else
calendar.days_in_month(year1, month1) - day1 + day2
end
%__MODULE__{year: year_diff, month: month_diff, day: day_diff}
end
defp back_one_day(date_diff, calendar) do
back_one_day(date_diff, :day, calendar)
end
defp back_one_day(%{day: day} = date_diff, :day, calendar) do
%{date_diff | day: day - 1}
|> back_one_day(:month, calendar)
end
defp back_one_day(%{month: month, day: day} = date_diff, :month, calendar) when day < 1 do
%{date_diff | month: month - 1}
|> back_one_day(:year, calendar)
end
defp back_one_day(%{year: _, month: _, day: _} = date_diff, :month, _calendar) do
date_diff
end
defp back_one_day(%{year: year, month: month} = date_diff, :year, calendar) when month < 1 do
diff = %{date_diff | year: year - 1}
diff = if diff.month < 1, do: %{diff | month: calendar.months_in_year(year)}, else: diff
diff =
if diff.day < 1, do: %{diff | day: calendar.days_in_month(year, diff.month)}, else: diff
diff
end
defp back_one_day(%{year: _, month: _, day: _} = date_diff, :year, _calendar) do
date_diff
end
defp merge(duration, microseconds) do
{seconds, microseconds} = Cldr.Math.div_mod(microseconds, @microseconds_in_second)
{hours, minutes, seconds} = :calendar.seconds_to_time(seconds)
duration
|> Map.put(:hour, hours)
|> Map.put(:minute, minutes)
|> Map.put(:second, seconds)
|> Map.put(:microsecond, microseconds)
end
# The difference in years is adjusted if the
# month of the `to` year is less than the
# month of the `from` year
defp possible_adjustment(m2, m1, _d2, _d1) when m2 < m1, do: 1
defp possible_adjustment(m2, m2, d2, d1) when d2 < d1, do: 1
defp possible_adjustment(_m2, _m1, _d2, _d1), do: 0
defp possible_adjustment(m2, m1) when m2 < m1, do: 1
defp possible_adjustment(_m2, _m1), do: 0
end | lib/cldr/calendar/duration.ex | 0.958943 | 0.910704 | duration.ex | starcoder |
defmodule SMPPEX.ESME do
@moduledoc """
This is a module for launching an `SMPPEX.Session` implementation as an ESME.
To start an ESME one generally should do the following.
1. Implement an `SMPPEX.Session` behaviour.
```elixir
defmodule MyESMESession do
use SMPPEX.Session
# ...Callback implementation
end
```
2. Launch it.
```elixir
{:ok, esme_session} = SMPPEX.ESME.start_link("127.0.0.1",
2775,
{MyESMESession, some_args})
```
"""
alias SMPPEX.Compat
alias SMPPEX.Session.Defaults
alias SMPPEX.Session
alias SMPPEX.TransportSession
@default_transport :ranch_tcp
@default_timeout 5000
@spec start_link(
host :: term,
port :: non_neg_integer,
{module, args :: term},
opts :: Keyword.t()
) :: GenServer.on_start()
@doc """
Starts an `SMPPEX.Session` implementation as an ESME entitiy, i.e. makes a transport connection to `host`:`port` and starts an `SMPPEX.Session` to handle the connection with the passed module.
The function does not return until ESME successfully connects to the specified
`host` and `port` and initializes or fails.
`module` is the callback module which should implement `SMPPEX.ESME` behaviour.
`args` is the argument passed to the `init` callback.
`opts` is a keyword list of different options:
* `:transport` is Ranch transport used for TCP connection: either `:ranch_tcp` (the default) or
`:ranch_ssl`;
* `:timeout` is timeout for transport connect. The default is #{@default_timeout} ms;
* `:esme_opts` is a keyword list of ESME options:
- `:timer_resolution` is interval of internal `ticks` on which time related events happen, like checking timeouts
for pdus, checking SMPP timers, etc. The default is #{inspect(Defaults.timer_resolution())} ms;
- `:enquire_link_limit` is value for enquire_link SMPP timer, i.e. the interval of SMPP session inactivity after which
enquire_link PDU is send to "ping" the connetion. The default value is #{
inspect(Defaults.enquire_link_limit())
} ms;
- `:enquire_link_resp_limit` is the maximum time for which ESME waits for enquire_link PDU response. If the
response is not received within this interval of time and no activity from the peer occurs, the session is then considered
dead and the ESME stops. The default value is #{inspect(Defaults.enquire_link_resp_limit())} ms;
- `:inactivity_limit` is the maximum time for which the peer is allowed not to send PDUs (which are not response PDUs).
If no such PDUs are received within this interval of time, ESME stops. The default is #{
inspect(Defaults.inactivity_limit())
} ms;
- `:response_limit` is the maximum time to wait for a response for a previously sent PDU. If the response is
not received within this interval, `handle_resp_timeout` callback is triggered for the original pdu. If the response
is received later, it is discarded. The default value is #{
inspect(Defaults.response_limit())
} ms.
- `:session_init_limit` is the maximum time for the session to be unbound.
If no bind request succeed within this interval of time, the session stops.
The default value is #{inspect(Defaults.session_init_limit())} ms;
* `:socket_opts` is a keyword list of ranch socket options, see ranch's options for more information
If `:esme_opts` list of options is ommited, all options take their default values.
The whole `opts` argument may also be ommited in order to start ESME with the defaults.
The returned value is either `{:ok, pid}` or `{:error, reason}`.
"""
def start_link(host, port, {_module, _args} = mod_with_args, opts \\ []) do
transport = Keyword.get(opts, :transport, @default_transport)
timeout = Keyword.get(opts, :timeout, @default_timeout)
sock_opts = [
:binary,
{:packet, 0},
{:active, :once}
| Keyword.get(opts, :socket_opts, [])
]
esme_opts = Keyword.get(opts, :esme_opts, [])
case transport.connect(convert_host(host), port, sock_opts, timeout) do
{:ok, socket} ->
session_opts = {Session, [mod_with_args, esme_opts], :esme}
case TransportSession.start_link(socket, transport, session_opts) do
{:ok, pid} ->
{:ok, pid}
{:error, _} = error ->
transport.close(socket)
error
end
{:error, _} = error ->
error
end
end
defp convert_host(host) when is_binary(host), do: Compat.to_charlist(host)
defp convert_host(host), do: host
end | lib/smppex/esme.ex | 0.843782 | 0.840783 | esme.ex | starcoder |
defmodule Pcal do
defstruct month: 1, year: 2018, output: "output.pdf"
@moduledoc """
Documentation for Pcal.
"""
@pcal_command "pcal"
@pdf_converter_command "ps2pdf"
@script "bin/generate_pdf"
@doc """
Check if pcal command exists.
## Examples
iex> {:ok, path} = Pcal.command_exists?
iex> String.ends_with?(path, "/pcal")
true
"""
def command_exists? do
case System.find_executable(@pcal_command) do
path when is_binary(path) -> {:ok, path}
_ -> {:error, "can not find executable #{@pcal_command}."}
end
end
@doc """
Check if pcal command exists.
## Examples
iex> {:ok, path} = Pcal.converter_exists?
iex> String.ends_with?(path, "/ps2pdf")
true
"""
def converter_exists? do
case System.find_executable(@pdf_converter_command) do
path when is_binary(path) -> {:ok, path}
_ -> {:error, "can not find executable #{@pdf_converter_command}."}
end
end
@doc """
Check prerequisites
## Examples
iex> Pcal.prerequisites?
iex> {:ok, %{command_path: command_path, converter_path: converter_path}} = {:ok, %{command_path: "/usr/bin/pcal", converter_path: "/usr/bin/ps2pdf"}}
iex> String.ends_with?(command_path, "/pcal")
true
iex> String.ends_with?(converter_path, "/ps2pdf")
true
"""
def prerequisites? do
case command_exists?() do
{:ok, command_path} ->
case converter_exists?() do
{:ok, converter_path} ->
{:ok, %{command_path: command_path, converter_path: converter_path}}
{:error, message} ->
{:error, message}
end
{:error, message} ->
{:error, message}
end
end
@doc """
Executes the shells script.
## Examples
iex> Pcal.execute_shell(%Pcal{month: "1", year: "2019", output: "./support/output.pdf"})
{:ok, "./support/output.pdf"}
"""
def execute_shell(%Pcal{month: month, year: year, output: output}) do
shell = System.find_executable("sh")
case System.cmd(shell, [script(), month, year, output]) do
{"", 0} ->
{:ok, output}
{_, error_code} ->
{:error, "Error executing shell command #{error_code}"}
end
end
@doc """
Generates a pdf
## Examples
iex> Pcal.generate_pdf(%Pcal{month: "1", year: "2019", output: "./support/output2.pdf"})
{:ok, "./support/output2.pdf"}
"""
def generate_pdf(%Pcal{} = pcal) do
case Pcal.prerequisites?() do
{:ok, _commands} ->
execute_shell(pcal)
_ ->
{:error,
"Please check prerequisites #{@pcal_command}, #{@pdf_converter_command}, and #{script()}"}
end
end
defp script do
case File.exists?(@script) do
true -> @script
false -> Path.join([Mix.Project.config()[:deps_path], "pcal", @script])
end
end
end | lib/pcal.ex | 0.770076 | 0.443781 | pcal.ex | starcoder |
defmodule Webapp.Regions do
@moduledoc """
The Regions context.
"""
import Ecto.Query, warn: false
alias Webapp.Repo
alias Webapp.{
Regions.Region,
Hypervisors.Hypervisor
}
@doc """
Returns the list of regions.
## Examples
iex> list_regions()
[%Region{}, ...]
"""
def list_regions do
Repo.all(Region)
end
@doc """
Returns the list of regions with at least one hypervisor.
## Examples
iex> list_usable_regions()
[%Region{}, ...]
"""
def list_usable_regions do
query = from(r in Region, [
join: h in Hypervisor, on: r.id == h.region_id,
group_by: r.id,
where: h.is_inactive == false
])
Repo.all(query)
end
@doc """
Returns the list hypervisors associated with region.
## Examples
iex> list_region_hypervisors()
[%Hypervisor{}, ...]
"""
def list_region_hypervisors(region, preloads \\ []) do
from(h in Hypervisor,
[where: h.is_inactive == false and h.region_id == ^region.id])
|> Repo.all()
|> Repo.preload(preloads)
end
@doc """
Gets a single region.
Raises `Ecto.NoResultsError` if the Region does not exist.
## Examples
iex> get_region!(123)
%Region{}
iex> get_region!(456)
** (Ecto.NoResultsError)
"""
def get_region!(id, preloads \\ []) do
Repo.get!(Region, id)
|> Repo.preload(preloads)
end
@doc """
Creates a region.
## Examples
iex> create_region(%{field: value})
{:ok, %Region{}}
iex> create_region(%{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def create_region(attrs \\ %{}) do
%Region{}
|> Region.changeset(attrs)
|> Repo.insert()
end
@doc """
Updates a region.
## Examples
iex> update_region(region, %{field: new_value})
{:ok, %Region{}}
iex> update_region(region, %{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def update_region(%Region{} = region, attrs) do
region
|> Region.changeset(attrs)
|> Repo.update()
end
@doc """
Deletes a Region.
## Examples
iex> delete_region(region)
{:ok, %Region{}}
iex> delete_region(region)
{:error, %Ecto.Changeset{}}
"""
def delete_region(%Region{} = region) do
Repo.delete(region)
end
@doc """
Returns an `%Ecto.Changeset{}` for tracking region changes.
## Examples
iex> change_region(region)
%Ecto.Changeset{source: %Region{}}
"""
def change_region(%Region{} = region) do
Region.changeset(region, %{})
end
end | lib/webapp/regions/regions.ex | 0.84955 | 0.408306 | regions.ex | starcoder |
defmodule AWS.WorkDocs do
@moduledoc """
The WorkDocs API is designed for the following use cases:
<ul> <li> File Migration: File migration applications are supported for
users who want to migrate their files from an on-premises or off-premises
file system or service. Users can insert files into a user directory
structure, as well as allow for basic metadata changes, such as
modifications to the permissions of files.
</li> <li> Security: Support security applications are supported for users
who have additional security needs, such as antivirus or data loss
prevention. The API actions, along with AWS CloudTrail, allow these
applications to detect when changes occur in Amazon WorkDocs. Then, the
application can take the necessary actions and replace the target file. If
the target file violates the policy, the application can also choose to
email the user.
</li> <li> eDiscovery/Analytics: General administrative applications are
supported, such as eDiscovery and analytics. These applications can choose
to mimic or record the actions in an Amazon WorkDocs site, along with AWS
CloudTrail, to replicate data for eDiscovery, backup, or analytical
applications.
</li> </ul> All Amazon WorkDocs API actions are Amazon authenticated and
certificate-signed. They not only require the use of the AWS SDK, but also
allow for the exclusive use of IAM users and roles to help facilitate
access, trust, and permission policies. By creating a role and allowing an
IAM user to access the Amazon WorkDocs site, the IAM user gains full
administrative visibility into the entire Amazon WorkDocs site (or as set
in the IAM policy). This includes, but is not limited to, the ability to
modify file permissions and upload any file to any user. This allows
developers to perform the three use cases above, as well as give users the
ability to grant access on a selective basis using the IAM model.
"""
@doc """
Aborts the upload of the specified document version that was previously
initiated by `InitiateDocumentVersionUpload`. The client should make this
call only when it no longer intends to upload the document version, or
fails to do so.
"""
def abort_document_version_upload(client, document_id, version_id, input, options \\ []) do
path_ = "/api/v1/documents/#{URI.encode(document_id)}/versions/#{URI.encode(version_id)}"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
query_ = []
request(client, :delete, path_, query_, headers, input, options, 204)
end
@doc """
Activates the specified user. Only active users can access Amazon WorkDocs.
"""
def activate_user(client, user_id, input, options \\ []) do
path_ = "/api/v1/users/#{URI.encode(user_id)}/activation"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
query_ = []
request(client, :post, path_, query_, headers, input, options, 200)
end
@doc """
Creates a set of permissions for the specified folder or document. The
resource permissions are overwritten if the principals already have
different permissions.
"""
def add_resource_permissions(client, resource_id, input, options \\ []) do
path_ = "/api/v1/resources/#{URI.encode(resource_id)}/permissions"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
query_ = []
request(client, :post, path_, query_, headers, input, options, 201)
end
@doc """
Adds a new comment to the specified document version.
"""
def create_comment(client, document_id, version_id, input, options \\ []) do
path_ = "/api/v1/documents/#{URI.encode(document_id)}/versions/#{URI.encode(version_id)}/comment"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
query_ = []
request(client, :post, path_, query_, headers, input, options, 201)
end
@doc """
Adds one or more custom properties to the specified resource (a folder,
document, or version).
"""
def create_custom_metadata(client, resource_id, input, options \\ []) do
path_ = "/api/v1/resources/#{URI.encode(resource_id)}/customMetadata"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
{query_, input} =
[
{"VersionId", "versionid"},
]
|> AWS.Request.build_params(input)
request(client, :put, path_, query_, headers, input, options, 200)
end
@doc """
Creates a folder with the specified name and parent folder.
"""
def create_folder(client, input, options \\ []) do
path_ = "/api/v1/folders"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
query_ = []
request(client, :post, path_, query_, headers, input, options, 201)
end
@doc """
Adds the specified list of labels to the given resource (a document or
folder)
"""
def create_labels(client, resource_id, input, options \\ []) do
path_ = "/api/v1/resources/#{URI.encode(resource_id)}/labels"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
query_ = []
request(client, :put, path_, query_, headers, input, options, 200)
end
@doc """
Configure Amazon WorkDocs to use Amazon SNS notifications. The endpoint
receives a confirmation message, and must confirm the subscription.
For more information, see [Subscribe to
Notifications](https://docs.aws.amazon.com/workdocs/latest/developerguide/subscribe-notifications.html)
in the *Amazon WorkDocs Developer Guide*.
"""
def create_notification_subscription(client, organization_id, input, options \\ []) do
path_ = "/api/v1/organizations/#{URI.encode(organization_id)}/subscriptions"
headers = []
query_ = []
request(client, :post, path_, query_, headers, input, options, 200)
end
@doc """
Creates a user in a Simple AD or Microsoft AD directory. The status of a
newly created user is "ACTIVE". New users can access Amazon WorkDocs.
"""
def create_user(client, input, options \\ []) do
path_ = "/api/v1/users"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
query_ = []
request(client, :post, path_, query_, headers, input, options, 201)
end
@doc """
Deactivates the specified user, which revokes the user's access to Amazon
WorkDocs.
"""
def deactivate_user(client, user_id, input, options \\ []) do
path_ = "/api/v1/users/#{URI.encode(user_id)}/activation"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
query_ = []
request(client, :delete, path_, query_, headers, input, options, 204)
end
@doc """
Deletes the specified comment from the document version.
"""
def delete_comment(client, comment_id, document_id, version_id, input, options \\ []) do
path_ = "/api/v1/documents/#{URI.encode(document_id)}/versions/#{URI.encode(version_id)}/comment/#{URI.encode(comment_id)}"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
query_ = []
request(client, :delete, path_, query_, headers, input, options, 204)
end
@doc """
Deletes custom metadata from the specified resource.
"""
def delete_custom_metadata(client, resource_id, input, options \\ []) do
path_ = "/api/v1/resources/#{URI.encode(resource_id)}/customMetadata"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
{query_, input} =
[
{"DeleteAll", "deleteAll"},
{"Keys", "keys"},
{"VersionId", "versionId"},
]
|> AWS.Request.build_params(input)
request(client, :delete, path_, query_, headers, input, options, 200)
end
@doc """
Permanently deletes the specified document and its associated metadata.
"""
def delete_document(client, document_id, input, options \\ []) do
path_ = "/api/v1/documents/#{URI.encode(document_id)}"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
query_ = []
request(client, :delete, path_, query_, headers, input, options, 204)
end
@doc """
Permanently deletes the specified folder and its contents.
"""
def delete_folder(client, folder_id, input, options \\ []) do
path_ = "/api/v1/folders/#{URI.encode(folder_id)}"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
query_ = []
request(client, :delete, path_, query_, headers, input, options, 204)
end
@doc """
Deletes the contents of the specified folder.
"""
def delete_folder_contents(client, folder_id, input, options \\ []) do
path_ = "/api/v1/folders/#{URI.encode(folder_id)}/contents"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
query_ = []
request(client, :delete, path_, query_, headers, input, options, 204)
end
@doc """
Deletes the specified list of labels from a resource.
"""
def delete_labels(client, resource_id, input, options \\ []) do
path_ = "/api/v1/resources/#{URI.encode(resource_id)}/labels"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
{query_, input} =
[
{"DeleteAll", "deleteAll"},
{"Labels", "labels"},
]
|> AWS.Request.build_params(input)
request(client, :delete, path_, query_, headers, input, options, 200)
end
@doc """
Deletes the specified subscription from the specified organization.
"""
def delete_notification_subscription(client, organization_id, subscription_id, input, options \\ []) do
path_ = "/api/v1/organizations/#{URI.encode(organization_id)}/subscriptions/#{URI.encode(subscription_id)}"
headers = []
query_ = []
request(client, :delete, path_, query_, headers, input, options, 200)
end
@doc """
Deletes the specified user from a Simple AD or Microsoft AD directory.
"""
def delete_user(client, user_id, input, options \\ []) do
path_ = "/api/v1/users/#{URI.encode(user_id)}"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
query_ = []
request(client, :delete, path_, query_, headers, input, options, 204)
end
@doc """
Describes the user activities in a specified time period.
"""
def describe_activities(client, activity_types \\ nil, end_time \\ nil, include_indirect_activities \\ nil, limit \\ nil, marker \\ nil, organization_id \\ nil, resource_id \\ nil, start_time \\ nil, user_id \\ nil, authentication_token \\ nil, options \\ []) do
path_ = "/api/v1/activities"
headers = []
headers = if !is_nil(authentication_token) do
[{"Authentication", authentication_token} | headers]
else
headers
end
query_ = []
query_ = if !is_nil(user_id) do
[{"userId", user_id} | query_]
else
query_
end
query_ = if !is_nil(start_time) do
[{"startTime", start_time} | query_]
else
query_
end
query_ = if !is_nil(resource_id) do
[{"resourceId", resource_id} | query_]
else
query_
end
query_ = if !is_nil(organization_id) do
[{"organizationId", organization_id} | query_]
else
query_
end
query_ = if !is_nil(marker) do
[{"marker", marker} | query_]
else
query_
end
query_ = if !is_nil(limit) do
[{"limit", limit} | query_]
else
query_
end
query_ = if !is_nil(include_indirect_activities) do
[{"includeIndirectActivities", include_indirect_activities} | query_]
else
query_
end
query_ = if !is_nil(end_time) do
[{"endTime", end_time} | query_]
else
query_
end
query_ = if !is_nil(activity_types) do
[{"activityTypes", activity_types} | query_]
else
query_
end
request(client, :get, path_, query_, headers, nil, options, 200)
end
@doc """
List all the comments for the specified document version.
"""
def describe_comments(client, document_id, version_id, limit \\ nil, marker \\ nil, authentication_token \\ nil, options \\ []) do
path_ = "/api/v1/documents/#{URI.encode(document_id)}/versions/#{URI.encode(version_id)}/comments"
headers = []
headers = if !is_nil(authentication_token) do
[{"Authentication", authentication_token} | headers]
else
headers
end
query_ = []
query_ = if !is_nil(marker) do
[{"marker", marker} | query_]
else
query_
end
query_ = if !is_nil(limit) do
[{"limit", limit} | query_]
else
query_
end
request(client, :get, path_, query_, headers, nil, options, 200)
end
@doc """
Retrieves the document versions for the specified document.
By default, only active versions are returned.
"""
def describe_document_versions(client, document_id, fields \\ nil, include \\ nil, limit \\ nil, marker \\ nil, authentication_token \\ nil, options \\ []) do
path_ = "/api/v1/documents/#{URI.encode(document_id)}/versions"
headers = []
headers = if !is_nil(authentication_token) do
[{"Authentication", authentication_token} | headers]
else
headers
end
query_ = []
query_ = if !is_nil(marker) do
[{"marker", marker} | query_]
else
query_
end
query_ = if !is_nil(limit) do
[{"limit", limit} | query_]
else
query_
end
query_ = if !is_nil(include) do
[{"include", include} | query_]
else
query_
end
query_ = if !is_nil(fields) do
[{"fields", fields} | query_]
else
query_
end
request(client, :get, path_, query_, headers, nil, options, 200)
end
@doc """
Describes the contents of the specified folder, including its documents and
subfolders.
By default, Amazon WorkDocs returns the first 100 active document and
folder metadata items. If there are more results, the response includes a
marker that you can use to request the next set of results. You can also
request initialized documents.
"""
def describe_folder_contents(client, folder_id, include \\ nil, limit \\ nil, marker \\ nil, order \\ nil, sort \\ nil, type \\ nil, authentication_token \\ nil, options \\ []) do
path_ = "/api/v1/folders/#{URI.encode(folder_id)}/contents"
headers = []
headers = if !is_nil(authentication_token) do
[{"Authentication", authentication_token} | headers]
else
headers
end
query_ = []
query_ = if !is_nil(type) do
[{"type", type} | query_]
else
query_
end
query_ = if !is_nil(sort) do
[{"sort", sort} | query_]
else
query_
end
query_ = if !is_nil(order) do
[{"order", order} | query_]
else
query_
end
query_ = if !is_nil(marker) do
[{"marker", marker} | query_]
else
query_
end
query_ = if !is_nil(limit) do
[{"limit", limit} | query_]
else
query_
end
query_ = if !is_nil(include) do
[{"include", include} | query_]
else
query_
end
request(client, :get, path_, query_, headers, nil, options, 200)
end
@doc """
Describes the groups specified by the query. Groups are defined by the
underlying Active Directory.
"""
def describe_groups(client, limit \\ nil, marker \\ nil, organization_id \\ nil, search_query, authentication_token \\ nil, options \\ []) do
path_ = "/api/v1/groups"
headers = []
headers = if !is_nil(authentication_token) do
[{"Authentication", authentication_token} | headers]
else
headers
end
query_ = []
query_ = if !is_nil(search_query) do
[{"searchQuery", search_query} | query_]
else
query_
end
query_ = if !is_nil(organization_id) do
[{"organizationId", organization_id} | query_]
else
query_
end
query_ = if !is_nil(marker) do
[{"marker", marker} | query_]
else
query_
end
query_ = if !is_nil(limit) do
[{"limit", limit} | query_]
else
query_
end
request(client, :get, path_, query_, headers, nil, options, 200)
end
@doc """
Lists the specified notification subscriptions.
"""
def describe_notification_subscriptions(client, organization_id, limit \\ nil, marker \\ nil, options \\ []) do
path_ = "/api/v1/organizations/#{URI.encode(organization_id)}/subscriptions"
headers = []
query_ = []
query_ = if !is_nil(marker) do
[{"marker", marker} | query_]
else
query_
end
query_ = if !is_nil(limit) do
[{"limit", limit} | query_]
else
query_
end
request(client, :get, path_, query_, headers, nil, options, 200)
end
@doc """
Describes the permissions of a specified resource.
"""
def describe_resource_permissions(client, resource_id, limit \\ nil, marker \\ nil, principal_id \\ nil, authentication_token \\ nil, options \\ []) do
path_ = "/api/v1/resources/#{URI.encode(resource_id)}/permissions"
headers = []
headers = if !is_nil(authentication_token) do
[{"Authentication", authentication_token} | headers]
else
headers
end
query_ = []
query_ = if !is_nil(principal_id) do
[{"principalId", principal_id} | query_]
else
query_
end
query_ = if !is_nil(marker) do
[{"marker", marker} | query_]
else
query_
end
query_ = if !is_nil(limit) do
[{"limit", limit} | query_]
else
query_
end
request(client, :get, path_, query_, headers, nil, options, 200)
end
@doc """
Describes the current user's special folders; the `RootFolder` and the
`RecycleBin`. `RootFolder` is the root of user's files and folders and
`RecycleBin` is the root of recycled items. This is not a valid action for
SigV4 (administrative API) clients.
This action requires an authentication token. To get an authentication
token, register an application with Amazon WorkDocs. For more information,
see [Authentication and Access Control for User
Applications](https://docs.aws.amazon.com/workdocs/latest/developerguide/wd-auth-user.html)
in the *Amazon WorkDocs Developer Guide*.
"""
def describe_root_folders(client, limit \\ nil, marker \\ nil, authentication_token, options \\ []) do
path_ = "/api/v1/me/root"
headers = []
headers = if !is_nil(authentication_token) do
[{"Authentication", authentication_token} | headers]
else
headers
end
query_ = []
query_ = if !is_nil(marker) do
[{"marker", marker} | query_]
else
query_
end
query_ = if !is_nil(limit) do
[{"limit", limit} | query_]
else
query_
end
request(client, :get, path_, query_, headers, nil, options, 200)
end
@doc """
Describes the specified users. You can describe all users or filter the
results (for example, by status or organization).
By default, Amazon WorkDocs returns the first 24 active or pending users.
If there are more results, the response includes a marker that you can use
to request the next set of results.
"""
def describe_users(client, fields \\ nil, include \\ nil, limit \\ nil, marker \\ nil, order \\ nil, organization_id \\ nil, query \\ nil, sort \\ nil, user_ids \\ nil, authentication_token \\ nil, options \\ []) do
path_ = "/api/v1/users"
headers = []
headers = if !is_nil(authentication_token) do
[{"Authentication", authentication_token} | headers]
else
headers
end
query_ = []
query_ = if !is_nil(user_ids) do
[{"userIds", user_ids} | query_]
else
query_
end
query_ = if !is_nil(sort) do
[{"sort", sort} | query_]
else
query_
end
query_ = if !is_nil(query) do
[{"query", query} | query_]
else
query_
end
query_ = if !is_nil(organization_id) do
[{"organizationId", organization_id} | query_]
else
query_
end
query_ = if !is_nil(order) do
[{"order", order} | query_]
else
query_
end
query_ = if !is_nil(marker) do
[{"marker", marker} | query_]
else
query_
end
query_ = if !is_nil(limit) do
[{"limit", limit} | query_]
else
query_
end
query_ = if !is_nil(include) do
[{"include", include} | query_]
else
query_
end
query_ = if !is_nil(fields) do
[{"fields", fields} | query_]
else
query_
end
request(client, :get, path_, query_, headers, nil, options, 200)
end
@doc """
Retrieves details of the current user for whom the authentication token was
generated. This is not a valid action for SigV4 (administrative API)
clients.
This action requires an authentication token. To get an authentication
token, register an application with Amazon WorkDocs. For more information,
see [Authentication and Access Control for User
Applications](https://docs.aws.amazon.com/workdocs/latest/developerguide/wd-auth-user.html)
in the *Amazon WorkDocs Developer Guide*.
"""
def get_current_user(client, authentication_token, options \\ []) do
path_ = "/api/v1/me"
headers = []
headers = if !is_nil(authentication_token) do
[{"Authentication", authentication_token} | headers]
else
headers
end
query_ = []
request(client, :get, path_, query_, headers, nil, options, 200)
end
@doc """
Retrieves details of a document.
"""
def get_document(client, document_id, include_custom_metadata \\ nil, authentication_token \\ nil, options \\ []) do
path_ = "/api/v1/documents/#{URI.encode(document_id)}"
headers = []
headers = if !is_nil(authentication_token) do
[{"Authentication", authentication_token} | headers]
else
headers
end
query_ = []
query_ = if !is_nil(include_custom_metadata) do
[{"includeCustomMetadata", include_custom_metadata} | query_]
else
query_
end
request(client, :get, path_, query_, headers, nil, options, 200)
end
@doc """
Retrieves the path information (the hierarchy from the root folder) for the
requested document.
By default, Amazon WorkDocs returns a maximum of 100 levels upwards from
the requested document and only includes the IDs of the parent folders in
the path. You can limit the maximum number of levels. You can also request
the names of the parent folders.
"""
def get_document_path(client, document_id, fields \\ nil, limit \\ nil, marker \\ nil, authentication_token \\ nil, options \\ []) do
path_ = "/api/v1/documents/#{URI.encode(document_id)}/path"
headers = []
headers = if !is_nil(authentication_token) do
[{"Authentication", authentication_token} | headers]
else
headers
end
query_ = []
query_ = if !is_nil(marker) do
[{"marker", marker} | query_]
else
query_
end
query_ = if !is_nil(limit) do
[{"limit", limit} | query_]
else
query_
end
query_ = if !is_nil(fields) do
[{"fields", fields} | query_]
else
query_
end
request(client, :get, path_, query_, headers, nil, options, 200)
end
@doc """
Retrieves version metadata for the specified document.
"""
def get_document_version(client, document_id, version_id, fields \\ nil, include_custom_metadata \\ nil, authentication_token \\ nil, options \\ []) do
path_ = "/api/v1/documents/#{URI.encode(document_id)}/versions/#{URI.encode(version_id)}"
headers = []
headers = if !is_nil(authentication_token) do
[{"Authentication", authentication_token} | headers]
else
headers
end
query_ = []
query_ = if !is_nil(include_custom_metadata) do
[{"includeCustomMetadata", include_custom_metadata} | query_]
else
query_
end
query_ = if !is_nil(fields) do
[{"fields", fields} | query_]
else
query_
end
request(client, :get, path_, query_, headers, nil, options, 200)
end
@doc """
Retrieves the metadata of the specified folder.
"""
def get_folder(client, folder_id, include_custom_metadata \\ nil, authentication_token \\ nil, options \\ []) do
path_ = "/api/v1/folders/#{URI.encode(folder_id)}"
headers = []
headers = if !is_nil(authentication_token) do
[{"Authentication", authentication_token} | headers]
else
headers
end
query_ = []
query_ = if !is_nil(include_custom_metadata) do
[{"includeCustomMetadata", include_custom_metadata} | query_]
else
query_
end
request(client, :get, path_, query_, headers, nil, options, 200)
end
@doc """
Retrieves the path information (the hierarchy from the root folder) for the
specified folder.
By default, Amazon WorkDocs returns a maximum of 100 levels upwards from
the requested folder and only includes the IDs of the parent folders in the
path. You can limit the maximum number of levels. You can also request the
parent folder names.
"""
def get_folder_path(client, folder_id, fields \\ nil, limit \\ nil, marker \\ nil, authentication_token \\ nil, options \\ []) do
path_ = "/api/v1/folders/#{URI.encode(folder_id)}/path"
headers = []
headers = if !is_nil(authentication_token) do
[{"Authentication", authentication_token} | headers]
else
headers
end
query_ = []
query_ = if !is_nil(marker) do
[{"marker", marker} | query_]
else
query_
end
query_ = if !is_nil(limit) do
[{"limit", limit} | query_]
else
query_
end
query_ = if !is_nil(fields) do
[{"fields", fields} | query_]
else
query_
end
request(client, :get, path_, query_, headers, nil, options, 200)
end
@doc """
Retrieves a collection of resources, including folders and documents. The
only `CollectionType` supported is `SHARED_WITH_ME`.
"""
def get_resources(client, collection_type \\ nil, limit \\ nil, marker \\ nil, user_id \\ nil, authentication_token \\ nil, options \\ []) do
path_ = "/api/v1/resources"
headers = []
headers = if !is_nil(authentication_token) do
[{"Authentication", authentication_token} | headers]
else
headers
end
query_ = []
query_ = if !is_nil(user_id) do
[{"userId", user_id} | query_]
else
query_
end
query_ = if !is_nil(marker) do
[{"marker", marker} | query_]
else
query_
end
query_ = if !is_nil(limit) do
[{"limit", limit} | query_]
else
query_
end
query_ = if !is_nil(collection_type) do
[{"collectionType", collection_type} | query_]
else
query_
end
request(client, :get, path_, query_, headers, nil, options, 200)
end
@doc """
Creates a new document object and version object.
The client specifies the parent folder ID and name of the document to
upload. The ID is optionally specified when creating a new version of an
existing document. This is the first step to upload a document. Next,
upload the document to the URL returned from the call, and then call
`UpdateDocumentVersion`.
To cancel the document upload, call `AbortDocumentVersionUpload`.
"""
def initiate_document_version_upload(client, input, options \\ []) do
path_ = "/api/v1/documents"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
query_ = []
request(client, :post, path_, query_, headers, input, options, 201)
end
@doc """
Removes all the permissions from the specified resource.
"""
def remove_all_resource_permissions(client, resource_id, input, options \\ []) do
path_ = "/api/v1/resources/#{URI.encode(resource_id)}/permissions"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
query_ = []
request(client, :delete, path_, query_, headers, input, options, 204)
end
@doc """
Removes the permission for the specified principal from the specified
resource.
"""
def remove_resource_permission(client, principal_id, resource_id, input, options \\ []) do
path_ = "/api/v1/resources/#{URI.encode(resource_id)}/permissions/#{URI.encode(principal_id)}"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
{query_, input} =
[
{"PrincipalType", "type"},
]
|> AWS.Request.build_params(input)
request(client, :delete, path_, query_, headers, input, options, 204)
end
@doc """
Updates the specified attributes of a document. The user must have access
to both the document and its parent folder, if applicable.
"""
def update_document(client, document_id, input, options \\ []) do
path_ = "/api/v1/documents/#{URI.encode(document_id)}"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
query_ = []
request(client, :patch, path_, query_, headers, input, options, 200)
end
@doc """
Changes the status of the document version to ACTIVE.
Amazon WorkDocs also sets its document container to ACTIVE. This is the
last step in a document upload, after the client uploads the document to an
S3-presigned URL returned by `InitiateDocumentVersionUpload`.
"""
def update_document_version(client, document_id, version_id, input, options \\ []) do
path_ = "/api/v1/documents/#{URI.encode(document_id)}/versions/#{URI.encode(version_id)}"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
query_ = []
request(client, :patch, path_, query_, headers, input, options, 200)
end
@doc """
Updates the specified attributes of the specified folder. The user must
have access to both the folder and its parent folder, if applicable.
"""
def update_folder(client, folder_id, input, options \\ []) do
path_ = "/api/v1/folders/#{URI.encode(folder_id)}"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
query_ = []
request(client, :patch, path_, query_, headers, input, options, 200)
end
@doc """
Updates the specified attributes of the specified user, and grants or
revokes administrative privileges to the Amazon WorkDocs site.
"""
def update_user(client, user_id, input, options \\ []) do
path_ = "/api/v1/users/#{URI.encode(user_id)}"
{headers, input} =
[
{"AuthenticationToken", "Authentication"},
]
|> AWS.Request.build_params(input)
query_ = []
request(client, :patch, path_, query_, headers, input, options, 200)
end
@spec request(AWS.Client.t(), binary(), binary(), list(), list(), map(), list(), pos_integer()) ::
{:ok, map() | nil, map()}
| {:error, term()}
defp request(client, method, path, query, headers, input, options, success_status_code) do
client = %{client | service: "workdocs"}
host = build_host("workdocs", client)
url = host
|> build_url(path, client)
|> add_query(query, client)
additional_headers = [{"Host", host}, {"Content-Type", "application/x-amz-json-1.1"}]
headers = AWS.Request.add_headers(additional_headers, headers)
payload = encode!(client, input)
headers = AWS.Request.sign_v4(client, method, url, headers, payload)
perform_request(client, method, url, payload, headers, options, success_status_code)
end
defp perform_request(client, method, url, payload, headers, options, success_status_code) do
case AWS.Client.request(client, method, url, payload, headers, options) do
{:ok, %{status_code: status_code, body: body} = response}
when is_nil(success_status_code) and status_code in [200, 202, 204]
when status_code == success_status_code ->
body = if(body != "", do: decode!(client, body))
{:ok, body, response}
{:ok, response} ->
{:error, {:unexpected_response, response}}
error = {:error, _reason} -> error
end
end
defp build_host(_endpoint_prefix, %{region: "local", endpoint: endpoint}) do
endpoint
end
defp build_host(_endpoint_prefix, %{region: "local"}) do
"localhost"
end
defp build_host(endpoint_prefix, %{region: region, endpoint: endpoint}) do
"#{endpoint_prefix}.#{region}.#{endpoint}"
end
defp build_url(host, path, %{:proto => proto, :port => port}) do
"#{proto}://#{host}:#{port}#{path}"
end
defp add_query(url, [], _client) do
url
end
defp add_query(url, query, client) do
querystring = encode!(client, query, :query)
"#{url}?#{querystring}"
end
defp encode!(client, payload, format \\ :json) do
AWS.Client.encode!(client, payload, format)
end
defp decode!(client, payload) do
AWS.Client.decode!(client, payload, :json)
end
end | lib/aws/generated/work_docs.ex | 0.773473 | 0.454593 | work_docs.ex | starcoder |
defmodule Grizzly.ZWave.Commands.ConfigurationPropertiesReport do
@moduledoc """
This command is used to advertise the properties of a configuration parameter.
Params:
* `:param_number` - This field is used to specify which configuration parameter (required)
* `read_only` - This field is used to indicate if the parameter is read-only. (optional - v4+)
* `:altering_capabilities`: - This field is used to indicate if the advertised parameter triggers a change in the node’s capabilities. (optional - v4+)
* `:format` - This field is used to advertise the format of the parameter, one of :signed_integer, :unsigned_integer, :enumerated, :bit_field (required)
* `:size` - This field is used to advertise the size of the actual parameter, one of 0, 1, 2, 4
The advertised size MUST also apply to the fields “Min Value”, “Max Value”, “Default Value” carried in
this command. (required)
* `:min_value` - This field advertises the minimum value that the actual parameter can assume.
If the parameter is “Bit field”, this field MUST be set to 0. (required if size > 0 else omitted)
* `:max_value` - This field advertises the maximum value that the actual parameter can assume.
If the parameter is “Bit field”, each individual supported bit MUST be set to ‘1’, while each un-
supported bit of MUST be set to ‘0’. (required if size > 0 else omitted)
* `:default_value` - This field MUST advertise the default value of the actual parameter (required if size > 0 else omitted)
* `:next_param_number` - This field advertises the next available (possibly non-sequential) configuration parameter, else 0 (required)
* `:advanced` - This field is used to indicate if the advertised parameter is to be presented in the “Advanced”
parameter section in the controller GUI. (optional - v4+)
* `:no_bulk_support` - This field is used to advertise if the sending node supports Bulk Commands. (optional - v4+)
"""
@behaviour Grizzly.ZWave.Command
alias Grizzly.ZWave.{Command, DecodeError}
alias Grizzly.ZWave.CommandClasses.Configuration
@type param ::
{:param_number, non_neg_integer()}
| {:read_only, boolean | nil}
| {:altering_capabilities, boolean | nil}
| {:format, Configuration.format()}
| {:size, 0 | 1 | 2 | 4}
| {:min_value, integer | nil}
| {:max_value, integer | nil}
| {:default_value, integer | nil}
| {:next_param_number, non_neg_integer()}
| {:advanced, boolean | nil}
| {:no_bulk_support, boolean | nil}
@impl true
@spec new([param()]) :: {:ok, Command.t()}
def new(params) do
command = %Command{
name: :configuration_properties_report,
command_byte: 0x0F,
command_class: Configuration,
params: params,
impl: __MODULE__
}
{:ok, command}
end
@impl true
@spec encode_params(Command.t()) :: binary()
def encode_params(command) do
param_number = Command.param!(command, :param_number)
next_param_number = Command.param!(command, :next_param_number)
format = Command.param!(command, :format)
format_byte = Configuration.format_to_byte(format)
size = Command.param!(command, :size) |> Configuration.validate_size()
read_only_bit = Command.param(command, :read_only, false) |> Configuration.boolean_to_bit()
altering_capabilities_bit =
Command.param(command, :altering_capabilities, false) |> Configuration.boolean_to_bit()
<<param_number::size(16), altering_capabilities_bit::size(1), read_only_bit::size(1),
format_byte::size(3),
size::size(3)>> <>
maybe_value_specs(command, format, size) <>
<<next_param_number::size(16)>> <> maybe_v4_end_byte(command)
end
@impl true
@spec decode_params(binary()) :: {:ok, [param()]} | {:error, DecodeError.t()}
def decode_params(
<<param_number::size(16), altering_capabilities_bit::size(1), read_only_bit::size(1),
format_byte::size(3), 0x00::size(3), next_param_number::size(16), maybe_more::binary>>
) do
with {:ok, format} <- Configuration.format_from_byte(format_byte) do
case maybe_more do
# < v4
<<>> ->
{:ok,
[
param_number: param_number,
format: format,
size: 0,
next_param_number: next_param_number
]}
<<_reserved::size(6), no_bulk_support_bit::size(1), advanced_bit::size(1)>> ->
{:ok,
[
param_number: param_number,
read_only: Configuration.boolean_from_bit(read_only_bit),
advanced: Configuration.boolean_from_bit(advanced_bit),
no_bulk_support: Configuration.boolean_from_bit(no_bulk_support_bit),
altering_capabilities: Configuration.boolean_from_bit(altering_capabilities_bit),
format: format,
size: 0,
next_param_number: next_param_number
]}
end
else
{:error, %DecodeError{} = decode_error} ->
{:error, %DecodeError{decode_error | command: :configuration_properties_report}}
end
end
def decode_params(
<<param_number::size(16), altering_capabilities_bit::size(1), read_only_bit::size(1),
format_byte::size(3), size::size(3), min_value_bin::binary-size(size),
max_value_bin::binary-size(size), default_value_bin::binary-size(size),
next_param_number::size(16), maybe_more::binary>>
) do
with {:ok, format} <- Configuration.format_from_byte(format_byte) do
value_specs = [
min_value: value_spec(size, format, min_value_bin),
max_value: value_spec(size, format, max_value_bin),
default_value: value_spec(size, format, default_value_bin)
]
case maybe_more do
# < v4
<<>> ->
{:ok,
[
param_number: param_number,
format: format,
size: size,
next_param_number: next_param_number
]
|> Keyword.merge(value_specs)}
<<_reserved::size(6), no_bulk_support_bit::size(1), advanced_bit::size(1)>> ->
{:ok,
[
param_number: param_number,
read_only: Configuration.boolean_from_bit(read_only_bit),
advanced: Configuration.boolean_from_bit(advanced_bit),
no_bulk_support: Configuration.boolean_from_bit(no_bulk_support_bit),
altering_capabilities: Configuration.boolean_from_bit(altering_capabilities_bit),
format: format,
size: size,
next_param_number: next_param_number
]
|> Keyword.merge(value_specs)}
end
else
{:error, %DecodeError{} = decode_error} ->
{:error, %DecodeError{decode_error | command: :configuration_properties_report}}
end
end
defp maybe_value_specs(_command, _format, 0), do: <<>>
defp maybe_value_specs(command, format, size) do
min_value = Command.param!(command, :min_value)
max_value = Command.param!(command, :max_value)
default_value = Command.param!(command, :default_value)
case format do
:signed_integer ->
<<min_value::integer-signed-unit(8)-size(size),
max_value::integer-signed-unit(8)-size(size),
default_value::integer-signed-unit(8)-size(size)>>
_other ->
<<min_value::integer-unsigned-unit(8)-size(size),
max_value::integer-unsigned-unit(8)-size(size),
default_value::integer-unsigned-unit(8)-size(size)>>
end
end
defp maybe_v4_end_byte(command) do
v4? =
Command.param(command, :read_only) != nil or
Command.param(command, :altering_capabilities) != nil or
Command.param(command, :advanced) != nil or
Command.param(command, :no_bulk_support) != nil
if v4? do
no_bulk_support_bit =
Command.param!(command, :no_bulk_support) |> Configuration.boolean_to_bit()
advanced_bit = Command.param!(command, :advanced) |> Configuration.boolean_to_bit()
<<0x00::size(6), no_bulk_support_bit::size(1), advanced_bit::size(1)>>
else
<<>>
end
end
defp value_spec(size, format, value_bin) do
case format do
:signed_integer ->
<<value::integer-signed-unit(8)-size(size)>> = value_bin
value
_other ->
<<value::integer-unsigned-unit(8)-size(size)>> = value_bin
value
end
end
end | lib/grizzly/zwave/commands/configuration_properties_report.ex | 0.885767 | 0.60542 | configuration_properties_report.ex | starcoder |
defmodule Nerves.Hub do
@moduledoc """
Implements a hierarchical key-value store with
publish/watch semantics at each node of the hierarchy.
A specific location on a hub is called a __point__, a
term borrowed from SCADA and DCS industrial control
systems. Points are defined by a __path__, which is a
list of atoms.
Processes can publish state at any point on a hub
(update), and subscribe to observe state changes at that
point (watch). By doing so they will get notified
whenever the point or anything below it changes.
Processes can also register as handlers for a
__requests__ for a point. A process that handles requests
for a point is called a __manager__.
Hub keeps a sequence ID for each change to state, and
this is stored as part of the state graph, so that the
hub can answer the question: "show me all state that has
changed since sequence XXX"
** Limitations and areas for improvement**
Right now the store is only in memory, so a restart
removes all data from the store. All persistence must be
implemented separately
There is currently no change history or playback history
feature.
*Examples*
Basic Usage:
# Start the Hub GenServer
iex> Nerves.Hub.start
{:ok, #PID<0.127.0>}
# Put [status: :online] at path [:some, :point]
iex> Nerves.Hub.put [:some, :point], [status: :online]
{:changes, {"05142ef7fe86a86D2471CA6869E19648", 1},
[some: [point: [status: :online]]]}
# Fetch all values at path [:some, :point]
iex> Nerves.Hub.fetch [:some, :point]
{{"05142ef7fe86a86D2471CA6869E19648", 1},
[status: :online]}
# Get particular value :status at [:some, :point]
iex> Nerves.Hub.get [:some, :point], :status
:online
"""
import Nerves.Hub.Helpers
alias Nerves.Hub.Server
@proc_path_key {:agent, :path}
def start() do
start([],[])
end
def start_link() do
start_link([], [])
end
@doc "Start the Hub GenServer"
def start(_,_) do
case GenServer.start(Server, [], name: Server) do
{:error, {:already_started, pid}} ->
{:ok, pid}
ret ->
ret
end
end
@doc "Start the Hub GenServer with link to calling process"
def start_link(_,_) do
case GenServer.start_link(Server, [], name: Server) do
{:error, {:already_started, pid}} ->
{:ok, pid}
ret ->
ret
end
end
@doc """
Request a change to the path in the hub. The Manager is
forwarded the request and is responsible for handling it.
If no manager is found a timeout will occur.
## Examples
iex> Nerves.Hub.request [:some, :point], [useful: :info]
{:changes, {"0513b7725c5436E67975FB3A13EB3BAA", 2},
[some: [point: [useful: :info]]]}
"""
def request(path, request, context \\ []) do
atomic_path = atomify(path)
{:ok, {manager_pid, _opts}} = manager(atomic_path)
GenServer.call(manager_pid, {:request, atomic_path, request, context})
end
@doc """
Updates the path with the changes provided.
## Examples
iex> Nerves.Hub.update [:some, :point], [some: :data]
{:changes, {"05142ef7fe86a86D2471CA6869E19648", 1},
[some: [point: [some: :data]]]}
"""
def update(path, changes, context \\ []) do
GenServer.call(Server, {:update, atomify(path), changes, context})
end
@doc """
Puts the given changes at the path and returns immediately
## Examples
iex> Nerves.Hub.put [:some, :point], [some: :data]
:ok
"""
def put(path, changes) do
GenServer.cast(Server, {:put, atomify(path), changes})
end
@doc """
Associate the current process as the primary agent for
the given path. This binds/configures this process to
the hub, and also sets the path as the "agent path" in
the process dictionary.
*Note:* The path provided must exist and have values
stored before trying to master it.
## Examples
iex> Nerves.Hub.master [:some, :point]
:ok
"""
def master(path, options \\ []) do
Process.put @proc_path_key, path
update(path, [])
manage(path, options)
watch(path, [])
end
@doc """
Similar to `master/2` but does not `watch` the path.
## Examples
iex> Nerves.Hub.manage [:some, :point], []
:ok
"""
def manage(path, options \\ []) do
GenServer.call(Server, {:manage, atomify(path), options})
end
@doc """
Retrieves the manager with options for the provided path.
## Examples
iex> Nerves.Hub.manager [:some, :point]
{:ok, {#PID<0.125.0>, []}}
"""
def manager(path) do
GenServer.call(Server, {:manager, atomify(path)})
end
@doc """
Returns the controlling agent for this path, or `nil` if
none
## Examples
iex> Nerves.Hub.agent [:some, :point]
#PID<0.125.0>
"""
def agent(path) do
case manager(path) do
{:ok, {pid, _opts} } -> pid
_ -> nil
end
end
@doc """
Adds the calling process to the @wch list of process to
get notified of changes to the path specified.
## Examples
```
iex> Hub.watch [:some, :point]
{:ok,
{{"d94ccc37-4f4c-4568-b53b-40aa05c298c0", 1},
[test_data: [5, 16, "Some String"]]}}
```
"""
def watch(path, options \\ []) do
GenServer.call(Server, {:watch, atomify(path), options})
end
@doc """
Removes the calling process from the @wch list of process
to stop getting notified of changes to the path
specified.
## Examples
iex> Nerves.Hub.unwatch [:some, :point]
:ok
"""
def unwatch(path) do
GenServer.call(Server, {:unwatch, atomify(path)})
end
@doc """
Dumps the entire contents of the hub graph, including
"non human" information.
## Examples
iex> Nerves.Hub.dump
{{"05142ef7fe86a86D2471CA6869E19648", 1},
[some: {1,
[point: {1,
[mgr@: {#PID<0.125.0>, []}, some: {1, :data}]}]}]}
"""
def dump(path \\ []) do
GenServer.call(Server, {:dump, atomify(path)})
end
@doc """
Gets the value at the specified path with the specified
key.
## Examples
iex> Nerves.Hub.get [:some, :point]
[status: :online]
#DEPRECATED USAGE
iex> Nerves.Hub.get [:some, :point], :status
:online
"""
def get(path) do
{_vers, dict} = fetch(path)
dict
end
#DEPRECATED - 04/2016
def get(path, key) do
{_vers, dict} = fetch(path)
Dict.get dict, key
end
@doc """
Gets all the "human readable" key values pairs at the
specified path.
## Examples
iex> Nerves.Hub.fetch [:some, :point]
{{"05142ef7fe86a86D2471CA6869E19648", 1},
[some: :data, status: :online]}
"""
def fetch(path \\ []), do: deltas({:unknown, 0}, path)
@doc """
Gets the changes from the provided sequence counter on
the path to its current state.
The sequence counter is returned on calls to `get/1`, `put/2`, `update/3`,
`dump/1`, `fetch/1`
## Examples
iex> Nerves.Hub.deltas {"05142f977e209de63a768684291be964", 1}, [:some, :path]
{{"05142f977e209de63a768684291be964", 2}, [some: :new_data]}
iex> Nerves.Hub.deltas {:undefined, 0}, [:some, :path]
#Returns all changes
"""
def deltas(seq, path \\ []) do
GenServer.call(Server, {:deltas, seq, atomify(path)})
end
end | lib/hub.ex | 0.853821 | 0.849784 | hub.ex | starcoder |
defmodule LevelWeb.Schema.Mutations do
@moduledoc false
use Absinthe.Schema.Notation
@desc "Interface for payloads containing validation data."
interface :validatable do
field :success, non_null(:boolean)
field :errors, list_of(:error)
resolve_type fn _, _ -> nil end
end
@desc "A validation error."
object :error do
@desc "The name of the invalid attribute."
field :attribute, non_null(:string)
@desc "A human-friendly error message."
field :message, non_null(:string)
end
@desc "The response to updating a user."
object :update_user_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
@desc """
The mutated object. If the mutation was not successful,
this field may be null.
"""
field :user, :user
interface :validatable
end
@desc "The response to creating a space."
object :create_space_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
@desc """
The mutated object. If the mutation was not successful,
this field may be null.
"""
field :space, :space
interface :validatable
end
@desc "The response to updating a space."
object :update_space_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
@desc """
The mutated object. If the mutation was not successful,
this field may be null.
"""
field :space, :space
interface :validatable
end
@desc "The response to completing a setup step."
object :complete_setup_step_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc """
The next state.
"""
field :state, :space_setup_state
end
@desc "The response to creating a group."
object :create_group_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
@desc """
The mutated object. If the mutation was not successful,
this field may be null.
"""
field :group, :group
interface :validatable
end
@desc "The response to updating a group."
object :update_group_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
@desc """
The mutated object. If the mutation was not successful,
this field may be null.
"""
field :group, :group
interface :validatable
end
@desc "The response to bulk creating groups."
object :bulk_create_groups_payload do
@desc "A list of result payloads for each group."
field :payloads, non_null(list_of(:bulk_create_group_payload))
end
@desc "The payload for an individual group in a bulk create payload."
object :bulk_create_group_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
@desc """
The mutated object. If the mutation was not successful,
this field may be null.
"""
field :group, :group
@desc "The original arguments for this particular object."
field :args, non_null(:bulk_create_group_args)
interface :validatable
end
@desc "The arguments for an individual bulk-created group."
object :bulk_create_group_args do
@desc "The name of the group."
field :name, non_null(:string)
end
@desc "The response to subscribing to a group."
object :subscribe_to_group_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
@desc """
The group.
"""
field :group, :group
interface :validatable
end
@desc "The response to unsubscribing from a group."
object :unsubscribe_from_group_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
@desc """
The group.
"""
field :group, :group
interface :validatable
end
@desc "The response to granting group access."
object :grant_group_access_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
interface :validatable
end
@desc "The response to revoking group access."
object :revoke_group_access_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
interface :validatable
end
@desc "The payload for an updating group bookmark state."
object :bookmark_group_payload do
@desc "The current bookmark status."
field :is_bookmarked, non_null(:boolean)
@desc "The group."
field :group, non_null(:group)
end
@desc "The response to posting a message to a group."
object :create_post_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
@desc """
The mutated object. If the mutation was not successful,
this field may be null.
"""
field :post, :post
interface :validatable
end
@desc "The response to updating a post."
object :update_post_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
@desc """
The mutated object. If the mutation was not successful,
this field may be null.
"""
field :post, :post
interface :validatable
end
@desc "The response to replying to a post."
object :create_reply_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
@desc """
The mutated object. If the mutation was not successful,
this field may be null.
"""
field :reply, :reply
interface :validatable
end
@desc "The response to updating a reply."
object :update_reply_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
@desc """
The mutated object. If the mutation was not successful,
this field may be null.
"""
field :reply, :reply
interface :validatable
end
@desc "The response to recording a post view."
object :record_post_view_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
interface :validatable
end
@desc "The response to dismissing a mention."
object :dismiss_mentions_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
@desc """
The post for which mentions were dismissed. If the mutation was not successful,
this field may be null.
"""
field :posts, list_of(:post)
interface :validatable
end
@desc "The response to dismissing posts."
object :dismiss_posts_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
@desc """
The posts that were dismissed. If the mutation was not successful,
this field may be null.
"""
field :posts, list_of(:post)
interface :validatable
end
@desc "The response to marking posts as unread."
object :mark_as_unread_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
@desc """
The posts that were marked. If the mutation was not successful,
this field may be null.
"""
field :posts, list_of(:post)
interface :validatable
end
@desc "The response to registering a push subscription."
object :register_push_subscription_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
interface :validatable
end
@desc "The response to recording reply views."
object :record_reply_views_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
@desc "The replies marked as viewed."
field :replies, list_of(:reply)
interface :validatable
end
@desc "The response to closing a post."
object :close_post_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
@desc "The closed post."
field :post, non_null(:post)
interface :validatable
end
@desc "The response to reopening a post."
object :reopen_post_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
@desc "The reopened post."
field :post, non_null(:post)
interface :validatable
end
@desc "The response to creating group invitations."
object :create_group_invitations_payload do
@desc """
A boolean indicating if the mutation was successful. If true, the errors
list will be empty. Otherwise, errors may contain objects describing why
the mutation failed.
"""
field :success, non_null(:boolean)
@desc "A list of validation errors."
field :errors, list_of(:error)
@desc "The reopened post."
field :invitees, list_of(non_null(:space_user))
interface :validatable
end
end | lib/level_web/schema/mutations.ex | 0.869936 | 0.423518 | mutations.ex | starcoder |
defmodule Bokken.Gamification do
@moduledoc """
The Gamification context.
"""
import Ecto.Query, warn: false
alias Bokken.Repo
alias Bokken.Accounts
alias Bokken.Gamification.Badge
alias Bokken.Gamification.BadgeNinja
alias Bokken.Uploaders.Emblem
@doc """
Returns the list of badges.
Takes a map with the following optional arguments:
* `:ninja_id` - A ninja id to filter the results by.
## Examples
iex> list_badges()
[%Badge{}, ...]
"""
@spec list_badges(map()) :: list(%Badge{})
def list_badges(args \\ %{})
def list_badges(%{"ninja_id" => ninja_id}) do
ninja_id
|> Accounts.get_ninja!([:badges])
|> Map.fetch!(:badges)
end
def list_badges(_args) do
Badge
|> Repo.all()
end
@doc """
Gets a single badge.
Raises `Ecto.NoResultsError` if the Badge does not exist.
## Examples
iex> get_badge!(123)
%Badge{}
iex> get_badge!(456)
** (Ecto.NoResultsError)
"""
def get_badge!(id, preloads \\ []) do
Repo.get!(Badge, id) |> Repo.preload(preloads)
end
@doc """
Creates a badge.
## Examples
iex> create_badge(%{field: value})
{:ok, %Badge{}}
iex> create_badge(%{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def create_badge(attrs \\ %{}) do
transaction =
Ecto.Multi.new()
|> Ecto.Multi.insert(:badge, Badge.changeset(%Badge{}, attrs))
|> Ecto.Multi.update(:badge_with_image, &Badge.image_changeset(&1.badge, attrs))
|> Repo.transaction()
case transaction do
{:ok, %{badge: badge, badge_with_image: badge_with_image}} ->
{:ok, %{badge | image: badge_with_image.image}}
{:error, _transation, errors, _changes_so_far} ->
{:error, errors}
end
end
@doc """
Updates a badge.
## Examples
iex> update_badge(badge, %{field: new_value})
{:ok, %Badge{}}
iex> update_badge(badge, %{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def update_badge(%Badge{} = badge, attrs) do
badge
|> change_badge(attrs)
|> Repo.update()
end
@doc """
Deletes a badge.
## Examples
iex> delete_badge(badge)
{:ok, %Badge{}}
iex> delete_badge(badge)
{:error, %Ecto.Changeset{}}
"""
def delete_badge(%Badge{} = badge) do
Emblem.delete({badge.image, badge})
Repo.delete(badge)
end
@doc """
Returns an `%Ecto.Changeset{}` for tracking badge changes.
## Examples
iex> change_badge(badge)
%Ecto.Changeset{data: %Badge{}}
"""
def change_badge(%Badge{} = badge, attrs \\ %{}) do
badge
|> Badge.changeset(attrs)
|> Badge.image_changeset(attrs)
end
alias Bokken.Gamification.BadgeNinja
def give_badge(badge_id, ninja_id) do
%BadgeNinja{}
|> BadgeNinja.changeset(%{badge_id: badge_id, ninja_id: ninja_id})
|> Repo.insert()
end
def remove_badge(badge_id, ninja_id) do
query =
from(bn in BadgeNinja,
where: bn.badge_id == ^badge_id,
where: bn.ninja_id == ^ninja_id
)
Repo.delete_all(query)
end
end | lib/bokken/gamification.ex | 0.842976 | 0.4831 | gamification.ex | starcoder |
defmodule Imgex do
@moduledoc """
Provides functions to generate secure Imgix URLs.
"""
@doc """
Provides configured source information when it's not passed explicitly to
`url/3` or `proxy_url/3`.
"""
def configured_source,
do: %{
token: Application.get_env(:imgex, :secure_token),
domain: Application.get_env(:imgex, :imgix_domain)
}
@doc """
Generates a secure Imgix URL from a Web Proxy source given:
* `path` - The full public image URL.
* `params` - (optional) A map containing Imgix API parameters used to manipulate the image.
* `source` - (optional) A map containing Imgix source information:
* `:token` - The secure token used to sign API requests.
* `:domain` - The Imgix source domain.
## Examples
iex> Imgex.proxy_url "http://avatars.com/john-smith.png"
"https://my-social-network.imgix.net/http%3A%2F%2Favatars.com%2Fjohn-smith.png?s=493a52f008c91416351f8b33d4883135"
iex> Imgex.proxy_url "http://avatars.com/john-smith.png", %{w: 400, h: 300}
"https://my-social-network.imgix.net/http%3A%2F%2Favatars.com%2Fjohn-smith.png?h=300&w=400&s=a201fe1a3caef4944dcb40f6ce99e746"
"""
def proxy_url(path, params \\ %{}, source \\ configured_source()) when is_map(params) do
# URI-encode the public URL.
path = "/" <> URI.encode(path, &URI.char_unreserved?/1)
# Return the generated URL.
url(path, params, source)
end
@doc """
Generates custom `srcset` attributes for Imgix URLs, pre-signed with the
source's secure token (if configured). These are useful for responsive
images at a variety of screen sizes or pixel densities.
By default, the `srcset` generated will allow for responsive size switching
by building a list of image-width mappings. This default list of image
width mappings covers a wide range of 31 different widths from 100px to
8192px. This default results in quite a long `srcset` attribute, though, so
it is preferable to instead give more specific size guidance by specifying
either:
* a width, _OR_
* a height + aspect ratio
When these params are provided, the returned `srcset` will cover 5
different pixel densities (1x-5x).
## Arguments
* `path` - The URL path to the image.
* `params` - (optional) A map containing Imgix API parameters used to manipulate the image.
* `source` - (optional) A map containing Imgix source information:
* `:token` - The secure token used to sign API requests.
* `:domain` - The Imgix source domain.
## Examples
iex> Imgex.srcset("/images/lulu.jpg", %{w: 100})
"https://my-social-network.imgix.net/images/lulu.jpg?dpr=1&w=100&s=9bd210f344a0f65032951a9cf171c40e 1x,
https://my-social-network.imgix.net/images/lulu.jpg?dpr=2&w=100&s=33520b8f84fa72afa28539d66fb2734f 2x,
https://my-social-network.imgix.net/images/lulu.jpg?dpr=3&w=100&s=97d0f1731b4c8d8dd609424dfca2eab5 3x,
https://my-social-network.imgix.net/images/lulu.jpg?dpr=4&w=100&s=b96a02e08eeb50df5a75223c998e46f5 4x,
https://my-social-network.imgix.net/images/lulu.jpg?dpr=5&w=100&s=9ba1ab37db9f09283d9194223fbafb2f 5x"
iex> Imgex.srcset("/images/lulu.jpg", %{ar: "3:4", h: 500})
"https://my-social-network.imgix.net/images/lulu.jpg?ar=3%3A4&dpr=1&h=500&s=fa2016a84454271a30c00c93a6d236a2 1x,
https://my-social-network.imgix.net/images/lulu.jpg?ar=3%3A4&dpr=2&h=500&s=43303719ce9a76e618c6d16ef7b5f30f 2x,
https://my-social-network.imgix.net/images/lulu.jpg?ar=3%3A4&dpr=3&h=500&s=b1f39589cf13b10a7480c4b90f4dcea4 3x,
https://my-social-network.imgix.net/images/lulu.jpg?ar=3%3A4&dpr=4&h=500&s=1be6ccb379a227b8e4cfa8ebcbca2b76 4x,
https://my-social-network.imgix.net/images/lulu.jpg?ar=3%3A4&dpr=5&h=500&s=455776036fb49c420f20d93fb59af96e 5x"
"""
def srcset(
path,
params \\ %{},
source \\ configured_source()
)
when is_map(params) do
width = params[:w]
height = params[:h]
aspect_ratio = params[:ar]
if width || (height && aspect_ratio) do
build_dpr_srcset(path, params, source)
else
build_srcset_pairs(path, params, source)
end
end
@doc """
Generates a secure Imgix URL given:
* `path` - The URL path to the image.
* `params` - (optional) A map containing Imgix API parameters used to manipulate the image.
* `source` - (optional) A map containing Imgix source information:
* `:token` - The secure token used to sign API requests.
* `:domain` - The Imgix source domain.
## Examples
iex> Imgex.url "/images/jets.png"
"https://my-social-network.imgix.net/images/jets.png?s=7c6a3ef8679f4965f5aaecb66547fa61"
iex> Imgex.url "/images/jets.png", %{con: 10}, %{domain: "https://cannonball.imgix.net", token: "<PASSWORD>"}
"https://cannonball.imgix.net/images/jets.png?con=10&s=d982f04bbca4d819971496524aa5f95a"
"""
def url(path, params \\ %{}, source \\ configured_source()) when is_map(params) do
# Add query parameters to the path.
path = path_with_params(path, params)
# Use a md5 hash of the path and secret token as a signature.
signature = Base.encode16(:erlang.md5(source.token <> path), case: :lower)
# Append the signature to verify the request is valid and return the URL.
if params == %{} do
source.domain <> path <> "?s=" <> signature
else
source.domain <> path <> "&s=" <> signature
end
end
defp path_with_params(path, params) when params == %{}, do: path
defp path_with_params(path, params) when is_map(params) do
path <> "?" <> URI.encode_query(params)
end
# Default set of target widths, borrowed from JS and Ruby Imgix libraries.
@default_srcset_target_widths [
100,
116,
134,
156,
182,
210,
244,
282,
328,
380,
442,
512,
594,
688,
798,
926,
1074,
1246,
1446,
1678,
1946,
2258,
2618,
3038,
3524,
4088,
4742,
5500,
6380,
7400,
8192
]
@default_srcset_target_ratios [1, 2, 3, 4, 5]
defp build_srcset_pairs(path, params, source) when is_map(params) do
@default_srcset_target_widths
|> Enum.map(fn width ->
updated_params = Map.put(params, :w, width)
url(path, updated_params, source) <> " #{width}w"
end)
|> Enum.join(",\n")
end
defp build_dpr_srcset(path, params, source) when is_map(params) do
Enum.map(@default_srcset_target_ratios, fn ratio ->
updated_params = Map.put(params, :dpr, ratio)
url(path, updated_params, source) <> " #{ratio}x"
end)
|> Enum.join(",\n")
end
end | lib/imgex.ex | 0.918439 | 0.451387 | imgex.ex | starcoder |
defmodule GameApp.Game do
@moduledoc """
`GameApp.Game` defines a struct that encapsulates game state as well as many
functions that advance the game state based on actions that players can take.
"""
alias __MODULE__, as: Game
alias GameApp.{Player, Round}
alias GameApp.Config, as: GameConfig
require Logger
@enforce_keys [:shortcode, :creator]
defstruct shortcode: nil,
round_number: 1,
rounds: [],
players: %{},
scores: %{},
phase: :lobby,
winners: [],
creator: nil,
funmaster: nil,
funmaster_order: [],
config: %GameConfig{}
@type game_state ::
:lobby
| :game_start
| :round_start
| :prompt_selection
| :reaction_selection
| :winner_selection
| :round_end
| :game_end
@type t() :: %Game{
shortcode: String.t(),
round_number: integer() | nil,
rounds: list(Round.t()),
players: %{optional(String.t()) => Player.t()},
scores: %{optional(String.t()) => integer()},
phase: game_state,
winners: list(Player.t()),
creator: Player.t(),
funmaster: Player.t() | nil,
funmaster_order: list(String.t()),
config: GameConfig.t()
}
@doc """
Creates a game.
## Examples
iex> Game.create(shortcode: "ABCD", creator: Player.create(id: "1", name: "Gamer"))
%Game{
shortcode: "ABCD",
creator: %Player{id: "1", name: "Gamer"},
players: %{"1" => %Player{id: "1", name: "Gamer"}},
scores: %{"1" => 0},
funmaster: %Player{id: "1", name: "Gamer"},
funmaster_order: ["1"]
}
"""
@spec create(keyword()) :: Game.t()
def create(attrs \\ []) do
struct(Game, Enum.into(attrs, %{config: %GameConfig{}}))
|> player_join(Keyword.get(attrs, :creator))
end
@doc """
Returns a summary of the game state.
## Examples
iex> g = Game.create(shortcode: "ABCD", creator: Player.create(id: "1", name: "Gamer"))
iex> Game.summary(g)
%{
creator: %Player{id: "1", name: "Gamer"},
funmaster: %Player{id: "1", name: "Gamer"},
phase: :lobby,
players: %{"1" => %Player{id: "1", name: "Gamer"}},
player_count: 1,
prompt: nil,
reactions: %{},
reaction_count: 0,
ready_to_start: false,
round_winner: nil,
round_number: 1,
scores: %{"1" => 0},
shortcode: "ABCD",
winners: [],
final_round: true,
config: %GameConfig{}
}
"""
@spec summary(Game.t()) :: map()
def summary(%Game{rounds: []} = game), do: summarize(game, %{})
def summary(%Game{rounds: [round | _]} = game), do: summarize(game, round)
@doc """
Adds a player to a game.
## Examples
iex> :rand.seed(:exsplus, {1, 2, 3})
iex> g = Game.create(shortcode: "ABCD", creator: Player.create(id: "1", name: "Gamer"))
iex> Game.player_join(g, Player.create(id: "2", name: "Gamer2"))
%Game{
shortcode: "ABCD",
creator: %Player{id: "1", name: "Gamer"},
players: %{
"1" => %Player{id: "1", name: "Gamer"},
"2" => %Player{id: "2", name: "Gamer2"}
},
scores: %{"1" => 0, "2" => 0},
funmaster: %Player{id: "1", name: "Gamer"},
funmaster_order: ["1", "2"]
}
"""
@spec player_join(Game.t(), Player.t()) :: Game.t()
def player_join(
%Game{players: players, scores: scores, phase: phase} = game,
%Player{id: id} = player
)
when phase not in [:lobby, :game_start] do
game
|> Map.put(:players, Map.put(players, id, player))
|> set_player_score(player, Map.get(scores, id))
end
def player_join(%Game{players: players, scores: scores} = game, %Player{id: id} = player) do
game
|> Map.put(:players, Map.put(players, id, player))
|> set_player_score(player, Map.get(scores, id))
|> set_funmaster_and_order()
end
@doc """
Removes a player from a game. Removing a player doesn't remove their score
which allows for a player to possibly leave and rejoin a game in progress
without losing their prior points.
## Examples
iex> :rand.seed(:exsplus, {1, 2, 3})
iex> p1 = Player.create(id: "1", name: "Gamer")
iex> p2 = Player.create(id: "2", name: "Gamer2")
iex> g = Game.create(shortcode: "ABCD", creator: p1)
iex> g = Game.player_join(g, p2)
iex> Game.player_leave(g, p2)
%Game{
shortcode: "ABCD",
creator: %Player{id: "1", name: "Gamer"},
players: %{"1" => %Player{id: "1", name: "Gamer"}},
scores: %{"1" => 0, "2" => 0},
funmaster: %Player{id: "1", name: "Gamer"},
funmaster_order: ["1", "2"]
}
"""
@spec player_leave(Game.t(), Player.t()) :: Game.t()
def player_leave(%Game{phase: :game_end} = game, _player), do: game
def player_leave(game, player) do
game |> remove_player(player)
end
@doc """
Starts a game. Requires at least 3 players including the creator.
## Examples
iex> :rand.seed(:exsplus, {1, 2, 3})
iex> p1 = Player.create(id: "1", name: "Gamer1")
iex> p2 = Player.create(id: "2", name: "Gamer2")
iex> p3 = Player.create(id: "3", name: "Gamer3")
iex> g = Game.create(shortcode: "ABCD", creator: p1)
...> |> Game.player_join(p2)
...> |> Game.player_join(p3)
iex> Game.start_game(g)
%Game{
shortcode: "ABCD",
phase: :game_start,
creator: %Player{id: "1", name: "Gamer1"},
players: %{
"1" => %Player{id: "1", name: "Gamer1"},
"2" => %Player{id: "2", name: "Gamer2"},
"3" => %Player{id: "3", name: "Gamer3"}
},
scores: %{
"1" => 0,
"2" => 0,
"3" => 0
},
funmaster: %Player{id: "2", name: "Gamer2"},
funmaster_order: ["2", "3", "1"]
}
"""
@spec start_game(Game.t()) :: Game.t()
def start_game(
%Game{phase: :lobby, players: players, config: %{min_players: min_players}} = game
)
when map_size(players) < min_players,
do: game
def start_game(%Game{phase: :lobby} = game) do
game |> set_phase(:game_start)
end
@doc """
Starts a round.
## Examples
iex> :rand.seed(:exsplus, {1, 2, 3})
iex> p1 = Player.create(id: "1", name: "Gamer1")
iex> p2 = Player.create(id: "2", name: "Gamer2")
iex> p3 = Player.create(id: "3", name: "Gamer3")
iex> g = Game.create(shortcode: "ABCD", creator: p1)
...> |> Game.player_join(p2)
...> |> Game.player_join(p3)
iex> g = Game.start_game(g)
iex> Game.start_round(g)
%Game{
shortcode: "ABCD",
phase: :round_start,
round_number: 1,
creator: %Player{id: "1", name: "Gamer1"},
players: %{
"1" => %Player{id: "1", name: "Gamer1"},
"2" => %Player{id: "2", name: "Gamer2"},
"3" => %Player{id: "3", name: "Gamer3"}
},
scores: %{
"1" => 0,
"2" => 0,
"3" => 0
},
funmaster: %Player{id: "3", name: "Gamer3"},
funmaster_order: ["3", "1", "2"],
rounds: [
%Round{number: 1, prompt: nil, reactions: %{}, winner: nil}
]
}
"""
@spec start_round(Game.t()) :: Game.t()
def start_round(%Game{phase: :game_start} = game) do
game
|> set_phase(:round_start)
|> set_round(1)
|> set_funmaster_and_order()
end
def start_round(%Game{phase: :round_end, round_number: round_number} = game) do
game
|> set_phase(:round_start)
|> set_round(round_number + 1)
|> set_funmaster()
end
@doc """
Starts prompt selection for the current round.
"""
@spec start_prompt_selection(Game.t()) :: Game.t()
def start_prompt_selection(%Game{phase: :round_start} = game) do
game |> set_phase(:prompt_selection)
end
@doc """
Assigns a prompt to the current round.
"""
@spec select_prompt(Game.t(), String.t()) :: Game.t()
def select_prompt(%Game{phase: :prompt_selection, rounds: [round | _]} = game, prompt) do
game
|> set_phase(:reaction_selection)
|> update_round(Round.set_prompt(round, prompt))
end
@doc """
Adds a reaction in the current round for the given player.
"""
@spec select_reaction(Game.t(), Player.t(), String.t()) :: Game.t()
def select_reaction(
%Game{phase: :reaction_selection, rounds: [round | _]} = game,
player,
reaction
) do
game
|> update_round(Round.set_reaction(round, player, reaction))
end
def start_winner_selection(%Game{phase: :reaction_selection} = game) do
game |> set_phase(:winner_selection)
end
@doc """
Starts prompt selection for the current round.
"""
@spec select_winner(Game.t(), Player.t() | nil) :: Game.t()
def select_winner(%Game{phase: :winner_selection, rounds: [round | _]} = game, player) do
game
|> update_round(Round.set_winner(round, player))
|> award_points(player)
|> set_phase(:round_end)
end
def finalize(game) do
game
|> set_winners(game_winners(game))
|> set_phase(:game_end)
end
def is_empty?(%Game{players: players}) when players == %{}, do: true
def is_empty?(_), do: false
def all_players_reacted?(%Game{} = game), do: reactions_count(game) == players_count(game) - 1
def final_round?(%Game{
round_number: round_number,
players: players,
config: %GameConfig{rounds_per_player: rounds_per_player}
})
when round_number >= map_size(players) * rounds_per_player,
do: true
def final_round?(_), do: false
# private
@spec summarize(Game.t(), map()) :: map()
defp summarize(game, round) when is_map(round) do
%{
config: game.config,
shortcode: game.shortcode,
round_number: game.round_number,
players: game.players,
ready_to_start: can_start?(game),
player_count: players_count(game),
scores: scores_for_players(game.players, game.scores),
final_round: final_round?(game),
phase: game.phase,
winners: game.winners,
creator: game.creator,
funmaster: game.funmaster,
prompt: Map.get(round, :prompt),
round_winner: Map.get(round, :winner),
reaction_count: reactions_count(game),
reactions: Map.get(round, :reactions, %{})
}
end
@spec set_round(Game.t(), integer()) :: Game.t()
defp set_round(%Game{rounds: rounds} = game, round_number) do
Map.merge(game, %{
round_number: round_number,
rounds: [Round.create(number: round_number)] ++ rounds
})
end
@spec set_phase(Game.t(), game_state()) :: Game.t()
defp set_phase(game, phase) do
Map.put(game, :phase, phase)
end
@spec set_winners(Game.t(), list()) :: Game.t()
defp set_winners(game, winners) do
Map.put(game, :winners, winners)
end
@spec set_player_score(Game.t(), map(), integer() | nil) :: Game.t()
defp set_player_score(%Game{scores: scores} = game, player, nil) do
Map.put(game, :scores, Map.put(scores, player.id, 0))
end
defp set_player_score(%Game{scores: scores} = game, player, score) do
Map.put(game, :scores, Map.put(scores, player.id, score))
end
@spec set_funmaster_and_order(Game.t()) :: Game.t()
defp set_funmaster_and_order(%Game{players: players} = game) when players == %{} do
game
|> Map.put(:funmaster, nil)
|> Map.put(:funmaster_order, [])
end
defp set_funmaster_and_order(%Game{players: players} = game) do
game
|> Map.put(:funmaster_order, generate_funmaster_order(players))
|> set_funmaster()
end
@spec set_funmaster(Game.t()) :: Game.t()
defp set_funmaster(
%Game{players: players, funmaster_order: order, round_number: round_number} = game
) do
Map.put(game, :funmaster, funmaster_for_round(order, players, round_number))
end
defp award_points(%Game{scores: scores} = game, %Player{id: id}) do
Map.put(game, :scores, Map.put(scores, id, Map.get(scores, id) + 1))
end
defp award_points(game, nil), do: game
@spec remove_player(Game.t(), Player.t()) :: Game.t()
defp remove_player(%Game{players: players} = game, %Player{id: id}) do
game
|> Map.put(:players, Map.delete(players, id))
end
@spec update_round(Game.t(), Round.t()) :: Game.t()
defp update_round(%Game{rounds: [_round | rounds]} = game, new_round) do
Map.put(game, :rounds, [new_round] ++ rounds)
end
defp players_count(%Game{players: players}), do: Kernel.map_size(players)
defp reactions_count(%Game{rounds: []}), do: 0
defp reactions_count(%Game{rounds: [round | _]}), do: Kernel.map_size(round.reactions)
defp can_start?(%Game{config: %GameConfig{min_players: min_players}} = game) do
players_count(game) >= min_players
end
defp can_start?(_), do: false
defp scores_for_players(players, scores) do
Map.take(scores, Map.keys(players))
end
@spec funmaster_for_round([String.t()], map(), integer()) :: Player.t()
defp funmaster_for_round(funmaster_order, players, round_number) do
funmaster_order
|> Stream.cycle()
|> Enum.take(round_number)
|> List.last()
|> (&Map.get(players, &1)).()
end
@spec generate_funmaster_order(map()) :: [String.t()] | []
defp generate_funmaster_order(players) do
_ = :random.seed(:os.timestamp())
players
|> Map.values()
|> Enum.shuffle()
|> Enum.map(& &1.id)
end
defp game_winners(%Game{scores: scores, players: players}) do
scores
|> Map.to_list()
|> Enum.filter(fn {_, score} -> score > 0 end)
|> max_score()
|> Enum.map(fn {id, _} -> Map.get(players, id) end)
end
defp max_score(list, acc \\ [])
defp max_score([head | tail], []), do: max_score(tail, [head])
defp max_score([{id, score} | tail], [{_, high_score} | _] = acc) do
cond do
score == high_score -> max_score(tail, [{id, score} | acc])
score > high_score -> max_score(tail, [{id, score}])
score < high_score -> max_score(tail, acc)
end
end
defp max_score([], acc), do: Enum.reverse(acc)
end | apps/game/lib/game/state/game.ex | 0.871352 | 0.520618 | game.ex | starcoder |
defmodule Membrane.RTP do
@moduledoc """
This module provides caps struct for RTP packet.
"""
@typedoc """
RTP payload type that is statically mapped to encoding and clock rate.
"""
@type static_payload_type_t :: 0..95
@typedoc """
RTP payload type that can be dynamically mapped to encoding and clock rate.
"""
@type dynamic_payload_type_t :: 96..127
@typedoc """
RTP payload type.
"""
@type payload_type_t() :: static_payload_type_t() | dynamic_payload_type_t()
@typedoc """
Predefined names of encoding for static payload types (< 96).
"""
@type static_encoding_name_t() ::
:PCMU
| :GSM
| :G732
| :DVI4
| :LPC
| :PCMA
| :G722
| :L16
| :QCELP
| :CN
| :MPA
| :G728
| :G729
| :CELB
| :JPEG
| :NV
| :H261
| :MPV
| :MP2T
| :H263
@typedoc """
Dynamically assigned encoding names for payload types >= 96
They should be atoms matching the encoding name in SDP's attribute `rtpmap`. This is usually defined by
RFC for that payload format (e.g. for H264 there's RFC 6184 defining it must be "H264", so the atom `:H264` should be used
https://tools.ietf.org/html/rfc6184#section-8.2.1)
"""
@type dynamic_encoding_name_t() :: atom()
@typedoc """
Encoding name of RTP payload.
"""
@type encoding_name_t() :: static_encoding_name_t | dynamic_encoding_name_t()
@typedoc """
Rate of the clock used for RTP timestamps in Hz
"""
@type clock_rate_t() :: non_neg_integer()
@typedoc """
The source of a stream of RTP packets, identified by a 32-bit numeric identifier.
"""
@type ssrc_t() :: pos_integer()
@type t() :: %__MODULE__{}
defstruct []
@doc """
Determines if payload type is `t:static_payload_type_t/0`.
"""
defguard is_payload_type_static(payload_type) when payload_type in 0..95
@doc """
Determines if payload type is `t:dynamic_payload_type_t/0`.
"""
defguard is_payload_type_dynamic(payload_type) when payload_type in 96..127
end | lib/membrane/rtp.ex | 0.796055 | 0.494385 | rtp.ex | starcoder |
defmodule IntermodalContainers.ContainerNumber.Parser do
alias IntermodalContainers.ContainerNumber
alias IntermodalContainers.ContainerNumber.Alphabet
@type result() :: {:ok, %ContainerNumber{}} | {:error, String.t()}
@spec parse(String.t()) :: result()
def parse(code) when byte_size(code) == 11 do
parse_step({code, 0, %ContainerNumber{}})
end
def parse(code) when is_binary(code) do
{:error, "code is expected to be 11 bytes, has #{byte_size(code)}"}
end
def parse(_code) do
{:error, "code must be a string"}
end
def parse_step({code, 0, _} = parse_state) when byte_size(code) == 11 do
validator = &validate_owner_code/1
consume(parse_state, 3, validator)
end
def parse_step({remaining_code, 3, _} = parse_state) when byte_size(remaining_code) == 8 do
validator = &validate_category_identifier/1
consume(parse_state, 1, validator)
end
def parse_step({remaining_code, 4, _} = parse_state) when byte_size(remaining_code) == 7 do
validator = &validate_serial_number/1
consume(parse_state, 6, validator)
end
def parse_step({check_digit, 10, _} = parse_state) when byte_size(check_digit) == 1 do
validator = &validate_check_digit/1
consume(parse_state, 1, validator)
end
def parse_step({code, position, parsed_container_number}) do
err =
"Unidentified parse step for #{code} at #{position}." <>
"State: #{inspect(parsed_container_number)}"
{:error, err}
end
defp consume({code, position, parsed_container_number}, size, validator) do
{target, rest} = String.split_at(code, size)
validator.(target)
|> advance(rest, position + size, parsed_container_number)
end
defp advance({:error, _reason} = err, _code, _position, _parsed_container_number), do: err
defp advance({:ok, :check_digit, check_digit}, "", 11, parsed_container_number) do
{:ok, %{parsed_container_number | check_digit: check_digit}}
end
defp advance({:ok, key, val}, remainder, next_position, intermediate_result) do
intermediate_result = Map.update!(intermediate_result, key, fn _old -> val end)
parse_step({remainder, next_position, intermediate_result})
end
def validate_owner_code(owner_code) do
cond do
byte_size(owner_code) != 3 ->
{:error, "Owner code must be three letter long. Got #{owner_code}"}
!Alphabet.all_letters(owner_code) ->
{:error, "Owner code must be three capital letters. Got #{owner_code}"}
true ->
{:ok, :owner_code, owner_code}
end
end
def validate_category_identifier(category_identifier) do
cond do
byte_size(category_identifier) != 1 ->
{:error, "Category Identifier must be one letter long."}
!(category_identifier in ["U", "J", "Z"]) ->
{:error, "Category Identidier must be one of U, J, Z"}
true ->
{:ok, :category_identifier, category_identifier}
end
end
def validate_serial_number(serial_number) do
cond do
byte_size(serial_number) != 6 ->
{:error, "Serial Number must be 6 digits long. Got #{serial_number}"}
!Alphabet.all_digits(serial_number) ->
{:error, "Serial Number must be comprised of digits. Got #{serial_number}"}
true ->
{:ok, :serial_number, serial_number}
end
end
def validate_check_digit(check_digit) do
cond do
byte_size(check_digit) != 1 ->
{:error, "Check digit must be 1 digit long."}
!Alphabet.is_digit(check_digit) ->
{:error, "Check digit must be a digit."}
true ->
{:ok, :check_digit, check_digit}
end
end
end | lib/intermodal_containers/container_number/parser.ex | 0.773901 | 0.487917 | parser.ex | starcoder |
defmodule ParallelEnum do
@moduledoc """
Some parallel processing function
inspired by https://gist.github.com/padde/b350dbc81f458898f08417d804e793aa
"""
@doc """
Map all element of a list and execute the given function on it in parallel.
If the function raise an error during one process still get going & return the error in the relevant result index as:
> {:error, err, element}
"""
@spec map(list|map, function, integer) :: list
def map(enum, fun, max \\ 1)
def map(list, fun, max)
when is_list(list) and is_function(fun) and is_integer(max) do
results = List.duplicate(nil, length(list))
case :erlang.fun_info(fun)[:arity] do
1 -> do_pmap1(list, fun, max(1, min(max, length(list))), 0, results)
2 -> do_pmap2(list, fun, max(1, min(max, length(list))), 0, results)
_ -> results
end
end
def map(map, fun, max) when is_map(map),
do: map(for {k, v} <- map do {k, v} end, fun, max)
@doc """
Map all element of a list and execute the given function on it in parallel.
Error are propagated to the main thread
"""
@spec map!(list|map, function, integer) :: list
def map!(enum, fun, max \\ 1)
def map!(list, fun, max)
when is_list(list) and is_function(fun) and is_integer(max) do
results = List.duplicate(nil, length(list))
case :erlang.fun_info(fun)[:arity] do
1 -> do_pmap1!(list, fun, max(1, min(max, length(list))), 0, results)
2 -> do_pmap2!(list, fun, max(1, min(max, length(list))), 0, results)
_ -> results
end
end
def map!(map, fun, max) when is_map(map),
do: map!(for {k, v} <- map do {k, v} end, fun, max)
defp do_pmap1([], _fun, _max, 0, results), do: results
defp do_pmap1([element | todo], fun, max, workers, results) when workers < max do
caller = self
index = length(results) - length(todo) - 1
spawn fn ->
result = try do
fun.(element)
rescue
error -> {:error, error, element}
end
send caller, {index, result}
end
do_pmap1(todo, fun, max, workers + 1, results)
end
defp do_pmap1(todo, fun, max, workers, results) do
results = receive do
{index, result} -> List.replace_at(results, index, result)
end
do_pmap1(todo, fun, max, workers - 1, results)
end
defp do_pmap2([], _fun, _max, 0, results), do: results
defp do_pmap2([element | todo], fun, max, workers, results) when workers < max do
caller = self
index = length(results) - length(todo) - 1
spawn fn ->
result = try do
fun.(element, index)
rescue
error -> {:error, error, element}
end
send caller, {index, result}
end
do_pmap2(todo, fun, max, workers + 1, results)
end
defp do_pmap2(todo, fun, max, workers, results) do
results = receive do
{index, result} -> List.replace_at(results, index, result)
end
do_pmap2(todo, fun, max, workers - 1, results)
end
defp do_pmap1!([], _fun, _max, 0, results), do: results
defp do_pmap1!([element | todo], fun, max, workers, results) when workers < max do
caller = self
index = length(results) - length(todo) - 1
spawn_link fn ->
send caller, {index, fun.(element)}
end
do_pmap1!(todo, fun, max, workers + 1, results)
end
defp do_pmap1!(todo, fun, max, workers, results) do
results = receive do
{index, result} -> List.replace_at(results, index, result)
end
do_pmap1!(todo, fun, max, workers - 1, results)
end
defp do_pmap2!([], _fun, _max, 0, results), do: results
defp do_pmap2!([element | todo], fun, max, workers, results) when workers < max do
caller = self
index = length(results) - length(todo) - 1
spawn_link fn ->
send caller, {index, fun.(element, index)}
end
do_pmap2!(todo, fun, max, workers + 1, results)
end
defp do_pmap2!(todo, fun, max, workers, results) do
results = receive do
{index, result} -> List.replace_at(results, index, result)
end
do_pmap2!(todo, fun, max, workers - 1, results)
end
end | lib/parallel_enum.ex | 0.654122 | 0.528838 | parallel_enum.ex | starcoder |
--
-- This example uses mockup data to send a map objects to the template parser.
--
include std/map.e
include std/filesys.e
include std/search.e
include mvc/template.e
if search:ends( "examples", current_dir() ) then
-- make sure we can find our templates
-- if we're in the 'examples' directory
set_template_path( "../templates" )
end if
--
-- Mockaroo - Random Data Generator and API Mocking Tool
-- https://www.mockaroo.com/
--
sequence data = {
{
{"id", 1},
{"first_name", "Mommy"},
{"last_name", "Mewburn"},
{"email_address", "<EMAIL>"},
{"job_title", "Business Systems Development Analyst"},
{"ip_address", "245.131.117.235"}
},
{
{"id", 2},
{"first_name", "Malinda"},
{"last_name", "Yemm"},
{"email_address", "<EMAIL>"},
{"job_title", "Social Worker"},
{"ip_address", "192.168.127.12"}
},
{
{"id", 3},
{"first_name", "Clywd"},
{"last_name", "Firpi"},
{"email_address", "<EMAIL>"},
{"job_title", "VP Quality Control"},
{"ip_address", "248.104.29.229"}
},
{
{"id", 4},
{"first_name", "Val"},
{"last_name", "Blumire"},
{"email_address", "<EMAIL>"},
{"job_title", "Assistant Media Planner"},
{"ip_address", "172.16.17.32"}
},
{
{"id", 5},
{"first_name", "Devon"},
{"last_name", "Rayburn"},
{"email_address", "<EMAIL>"},
{"job_title", "Legal Assistant"},
{"ip_address", "192.168.127.12"}
},
{
{"id", 6},
{"first_name", "Solomon"},
{"last_name", "Degnen"},
{"email_address", "<EMAIL>"},
{"job_title", "Administrative Officer"},
{"ip_address", "172.16.31.10"}
},
{
{"id", 7},
{"first_name", "Nate"},
{"last_name", "Helm"},
{"email_address", "<EMAIL>"},
{"job_title", "Nuclear Power Engineer"},
{"ip_address", "172.16.17.32"}
},
{
{"id", 8},
{"first_name", "Sayre"},
{"last_name", "Bento"},
{"email_address", "<EMAIL>"},
{"job_title", "Graphic Designer"},
{"ip_address", "172.16.17.32"}
},
{
{"id", 9},
{"first_name", "Windham"},
{"last_name", "Westpfel"},
{"email_address", "<EMAIL>"},
{"job_title", "Chemical Engineer"},
{"ip_address", "192.168.127.12"}
},
{
{"id", 10},
{"first_name", "Timmy"},
{"last_name", "Bedells"},
{"email_address", "<EMAIL>"},
{"job_title", "Senior Financial Analyst"},
{"ip_address", "172.16.31.10"}
}
}
procedure main()
sequence user_list = {}
for i = 1 to length( data ) do
user_list &= { map:new_from_kvpairs(data[i]) }
end for
object response = map:new()
map:put( response, "title", "Example 2" )
map:put( response, "user_list", user_list )
sequence content = render_template( "example2.html", response )
puts( 1, content )
end procedure
main() | examples/example2.ex | 0.585694 | 0.535341 | example2.ex | starcoder |
defmodule Credo.Check.Readability.ModuleDoc do
@moduledoc """
Every module should contain comprehensive documentation.
Many times a sentence or two in plain english, explaining why the module
exists, will suffice. Documenting your train of thought this way will help
both your co-workers and your future-self.
Other times you will want to elaborate even further and show some
examples of how the module's functions can and should be used.
In some cases however, you might not want to document things about a module,
e.g. it is part of a private API inside your project. Since Elixir prefers
explicitness over implicit behaviour, you should "tag" these modules with
@moduledoc false
to make it clear that there is no intention in documenting it.
"""
@explanation [check: @moduledoc]
@default_params [
ignore_names: [
~r/(\.\w+Controller|\.Endpoint|\.Mixfile|\.Repo|\.Router|\.\w+Socket|\w+Test|\.\w+View)$/
]
]
alias Credo.Code.Module
use Credo.Check
def run(%SourceFile{ast: ast} = source_file, params \\ []) do
issue_meta = IssueMeta.for(source_file, params)
ignore_names = params |> Params.get(:ignore_names, @default_params)
Credo.Code.prewalk(ast, &traverse(&1, &2, issue_meta, ignore_names))
end
defp traverse({:defmodule, meta, _arguments} = ast, issues, issue_meta, ignore_names) do
exception? = Module.exception?(ast)
case Module.attribute(ast, :moduledoc) do
{:error, _} when not exception? ->
mod_name = Module.name(ast)
if mod_name |> matches?(ignore_names) do
{ast, issues}
else
{ast, [issue_for(issue_meta, meta[:line], mod_name)] ++ issues}
end
_ ->
{ast, issues}
end
end
defp traverse(ast, issues, _issue_meta, _ignore_names) do
{ast, issues}
end
defp matches?(name, patterns) when is_list(patterns) do
patterns |> Enum.any?(&matches?(name, &1))
end
defp matches?(name, string) when is_binary(string) do
name |> String.contains?(string)
end
defp matches?(name, regex) do
String.match?(name, regex)
end
defp issue_for(issue_meta, line_no, trigger) do
format_issue issue_meta,
message: "Modules should have a @moduledoc tag.",
trigger: trigger,
line_no: line_no
end
end | lib/credo/check/readability/module_doc.ex | 0.656548 | 0.503723 | module_doc.ex | starcoder |
defmodule Bintreeviz.Factory do
@moduledoc false
alias Bintreeviz.Node
def build(:simple) do
Node.new("Root",
left_child:
Node.new("Node A",
left_child: Node.new("Node C"),
right_child: Node.new("Node D")
),
right_child:
Node.new("Node B",
left_child: Node.new("Node E"),
right_child: Node.new("Node F")
)
)
end
def build(:medium) do
Node.new("Node A",
left_child:
Node.new("Node B",
left_child:
Node.new("Node D",
left_child: Node.new("Node H"),
right_child: Node.new("Node I")
),
right_child: Node.new("Node E")
),
right_child:
Node.new("Node C",
left_child: Node.new("Node F"),
right_child: Node.new("Node G")
)
)
end
def build(:large) do
Node.new("Node A",
left_child:
Node.new("Node B",
left_child: Node.new("Node D"),
right_child: Node.new("Node E")
),
right_child:
Node.new("Node C",
left_child:
Node.new("Node F",
left_child: Node.new("Node H"),
right_child: Node.new("Node I")
),
right_child:
Node.new("Node G",
left_child: Node.new("Node J"),
right_child: Node.new("Node K")
)
)
)
end
def build(:weird) do
Node.new("Node A",
left_child:
Node.new("Node B",
left_child: Node.new("Node D"),
right_child: Node.new("Node E")
),
right_child:
Node.new("Node C",
left_child: Node.new("Node F"),
right_child:
Node.new("Node G",
left_child:
Node.new("Node H",
left_child: nil,
right_child:
Node.new("Node J",
left_child: nil,
right_child:
Node.new("Node K",
left_child: nil,
right_child:
Node.new("Node L",
left_child: nil,
right_child: Node.new("Node M")
)
)
)
),
right_child: Node.new("Node I")
)
)
)
end
end | test/support/factory.ex | 0.656328 | 0.409221 | factory.ex | starcoder |