ArcGIS.Portal (ArcGIS v1.0.2)

View Source

An ArcGIS Portal. This may refer to an ArcGIS Online endpoint or an ArcGIS Enterprise installation.

Summary

Types

A portal item ID

t()

The configuration of an ArcGIS portal necessary for its use, in particular the base_url

A function that transforms raw ArcGIS results into a more prefereable form. Both one- and two-arity functions are supported, with the two arity receiving a map of metadata including such things as the spatial reference if available.

Functions

Returns the default portal. The portal (if any) defined in the application configuration will be used, with ArcGIS Online used as the ultimate fallback.

Discovers the version, type (:online or :enterprise), etc. of a portal and returns a new %ArcGIS.Portal{} with this information

Performs an HTTP GET request, checking for errors.

Create a t:Portal.t/0 from its base URL.

Performs an HTTP POST request, checking for errors.

Returns information about the Portal using the self query

Types

aggregate()

@type aggregate() :: %{type: aggregate_type(), field: String.t(), name: String.t()}

aggregate_type()

@type aggregate_type() :: :avg | :count | :max | :min | :sum

form_data()

@type form_data() :: map()

get_options()

@type get_options() :: request_option()

id()

@type id() :: String.t()

A portal item ID

order_by_field()

@type order_by_field() :: :atom | String.t() | {:atom | String.t(), :asc | :desc}

portal_option()

@type portal_option() ::
  {:auth_token, String.t()}
  | {:client_id, String.t()}
  | {:headers, url_meta()}
  | {:params, url_meta()}
  | {:portal, t()}
  | {:timeout, :infinity | pos_integer()}
  | {:async, boolean()}
  | {:verify_tls, boolean() | nil}

portal_options()

@type portal_options() :: [portal_option()]

portal_type()

@type portal_type() :: :online | :enterprise | :unknown

portal_version()

@type portal_version() :: {year :: number(), release :: number()} | :unknown

post_options()

@type post_options() :: request_option()

query_option()

@type query_option() ::
  {:is_features_query?, boolean()}
  | {:aggregates, [aggregate()]}
  | {:fields, [String.t()]}
  | {:geometry?, boolean()}
  | {:limit, non_neg_integer()}
  | {:offset, non_neg_integer()}
  | {:order_by, order_by_field() | [order_by_field()]}
  | {:response_format, response_format()}
  | {:where, String.t()}

request_data()

@type request_data() :: [url: String.t(), params: url_meta(), headers: url_meta()]

request_option()

@type request_option() ::
  portal_option() | query_option() | {:transform, transform_fn()}

request_options()

@type request_options() :: [request_option()]

response_format()

@type response_format() :: :geojson | :htmnl | :json | :pbf

t()

@type t() :: %ArcGIS.Portal{
  base_url: URI.t(),
  help_url: URI.t() | :unknown,
  type: portal_type(),
  verify_tls: boolean(),
  version: portal_version()
}

The configuration of an ArcGIS portal necessary for its use, in particular the base_url

transform_fn()

@type transform_fn() ::
  (source :: map() -> transformed :: term())
  | (source :: map(), metadata :: map() -> transformed :: term())

A function that transforms raw ArcGIS results into a more prefereable form. Both one- and two-arity functions are supported, with the two arity receiving a map of metadata including such things as the spatial reference if available.

url_meta()

@type url_meta() :: %{required(String.t()) => String.t()}

Functions

default_portal()

@spec default_portal() :: t()

Returns the default portal. The portal (if any) defined in the application configuration will be used, with ArcGIS Online used as the ultimate fallback.

discover(portal, options \\ [])

@spec discover((portal_url :: String.t()) | t(), options :: [portal_option()]) ::
  {:ok, t()} | {:error, reason :: String.t()}

Discovers the version, type (:online or :enterprise), etc. of a portal and returns a new %ArcGIS.Portal{} with this information

geometry_module_for(binary, arg2, arg3)

@spec geometry_module_for(esri_type :: String.t(), z? :: boolean(), m? :: boolean()) ::
  geometry_struct :: atom()
@spec geometry_module_for(esri_type :: String.t(), z? :: boolean(), m? :: boolean()) ::
  geometry_struct :: atom()
@spec geometry_module_for(esri_type :: String.t(), z? :: boolean(), m? :: boolean()) ::
  geometry_struct :: atom()
@spec geometry_module_for(esri_type :: String.t(), z? :: boolean(), m? :: boolean()) ::
  geometry_struct :: atom()

get(portal, resource, options \\ [])

@spec get(t(), resource :: String.t() | URI.t(), [get_options()]) ::
  {:ok, ArcGIS.Portal.ResultSet.t() | map() | term()}
  | {:error, reason :: String.t()}

Performs an HTTP GET request, checking for errors.

If the results are paged, then an %ArcGIS.Portal.ResultSet{} with the next offset and results is returned.

Queries that result in a single, unpaged response are returned as a map.

Passing in a transform function with the transform option allows processing the returned data into a preferred shape (e.g. a struct) when the query is successful. In the case of responses with multiple results, the transform function will be applied to each result.

new(url)

@spec new(url :: String.t()) :: {:ok, t()} | {:error, reason :: String.t()}

Create a t:Portal.t/0 from its base URL.

post(portal, resource, form_data, options \\ [])

@spec post(t(), resource :: String.t() | URI.t(), form_data(), [post_options()]) ::
  {:ok, ArcGIS.Portal.ResultSet.t() | map() | term()}
  | {:error, reason :: String.t()}

Performs an HTTP POST request, checking for errors.

If the results are paged, then an %ArcGIS.Portal.ResultSet{} with the next offset and results is returned.

Queries that result in a single, unpaged response are returned as a map.

Passing in a transform function with the transform option allows processing the returned data into a preferred shape (e.g. a struct) when the query is successful. In the case of responses with multiple results, the transform function will be applied to each result.

self(portal, options \\ [])

@spec self(t(), options :: [portal_option()]) ::
  {:ok, map()} | {:error, reason :: String.t()}

Returns information about the Portal using the self query