Geometry.GeometryCollectionZ (Geometry v0.2.0) View Source

A collection set of 3D geometries.

GeometryCollectionZ implements the protocols Enumerable and Collectable.

Examples

iex> Enum.map(
...>   GeometryCollectionZ.new([
...>     PointZ.new(11, 12, 13),
...>     LineStringZ.new([
...>       PointZ.new(21, 22, 23),
...>       PointZ.new(31, 32, 33)
...>     ])
...>   ]),
...>   fn
...>     %PointZ{} -> :point
...>     %LineStringZ{} -> :line_string
...>   end
...> ) |> Enum.sort()
[:line_string, :point]

iex> Enum.into([PointZ.new(1, 2, 3)], GeometryCollectionZ.new())
%GeometryCollectionZ{
  geometries: MapSet.new([%PointZ{coordinate: [1, 2, 3]}])
}

Link to this section Summary

Functions

Returns true if the given GeometryCollectionZ is empty.

Returns an :ok tuple with the GeometryCollectionZ from the given GeoJSON term. Otherwise returns an :error tuple.

The same as from_geo_json/1, but raises a Geometry.Error exception if it fails.

Returns an :ok tuple with the GeometryCollectionZ from the given WKB string. Otherwise returns an :error tuple.

The same as from_wkb/2, but raises a Geometry.Error exception if it fails.

Returns an :ok tuple with the GeometryCollectionZ from the given WKT string. Otherwise returns an :error tuple.

The same as from_wkt/1, but raises a Geometry.Error exception if it fails.

Checks if GeometryCollectionZ contains geometry.

Creates an empty GeometryCollectionZ.

Creates an empty GeometryCollectionZ.

Returns the number of elements in GeometryCollectionZ.

Returns the GeoJSON term of a GeometryCollectionZ.

Converts GeometryCollectionZ to a list.

Returns the WKB representation for a GeometryCollectionZ.

Returns the WKT representation for a GeometryCollectionZ. With option :srid an EWKT representation with the SRID is returned.

Link to this section Types

Specs

t() :: %Geometry.GeometryCollectionZ{geometries: MapSet.t(Geometry.t())}

Link to this section Functions

Link to this function

empty?(geometry_collection_z)

View Source

Specs

empty?(t()) :: boolean()

Returns true if the given GeometryCollectionZ is empty.

Examples

iex> GeometryCollectionZ.empty?(GeometryCollectionZ.new())
true

iex> GeometryCollectionZ.empty?(GeometryCollectionZ.new([PointZ.new(1, 2, 3)]))
false

Specs

from_geo_json(Geometry.geo_json_term()) ::
  {:ok, t()} | Geometry.geo_json_error()

Returns an :ok tuple with the GeometryCollectionZ from the given GeoJSON term. Otherwise returns an :error tuple.

Examples

iex> ~s({
...>   "type": "GeometryCollection",
...>   "geometries": [
...>     {"type": "Point", "coordinates": [1.1, 2.2, 3.3]}
...>   ]
...> })
iex> |> Jason.decode!()
iex> |> GeometryCollectionZ.from_geo_json()
{
  :ok,
  %GeometryCollectionZ{
    geometries: MapSet.new([%PointZ{coordinate: [1.1, 2.2, 3.3]}])
  }
}

Specs

from_geo_json!(Geometry.geo_json_term()) :: t()

The same as from_geo_json/1, but raises a Geometry.Error exception if it fails.

Link to this function

from_wkb(wkb, mode \\ :binary)

View Source

Specs

from_wkb(Geometry.wkb(), Geometry.mode()) ::
  {:ok, t()} | {:ok, t(), Geometry.srid()} | Geometry.wkb_error()

Returns an :ok tuple with the GeometryCollectionZ from the given WKB string. Otherwise returns an :error tuple.

If the geometry contains a SRID the id is added to the tuple.

An example of a simpler geometry can be found in the description for the Geometry.PointZ.from_wkb/2 function.

Link to this function

from_wkb!(wkb, mode \\ :binary)

View Source

Specs

from_wkb!(Geometry.wkb(), Geometry.mode()) :: t() | {t(), Geometry.srid()}

The same as from_wkb/2, but raises a Geometry.Error exception if it fails.

Specs

from_wkt(Geometry.wkt()) ::
  {:ok, t()} | {:ok, t(), Geometry.srid()} | Geometry.wkt_error()

Returns an :ok tuple with the GeometryCollectionZ from the given WKT string. Otherwise returns an :error tuple.

If the geometry contains a SRID the id is added to the tuple.

Examples

iex> GeometryCollectionZ.from_wkt(
...>   "GeometryCollection Z (Point Z (1.1 2.2 3.3))")
{
  :ok,
  %GeometryCollectionZ{
    geometries: MapSet.new([%PointZ{coordinate: [1.1, 2.2, 3.3]}])
  }
}

iex> GeometryCollectionZ.from_wkt(
...>   "SRID=123;GeometryCollection Z (Point Z (1.1 2.2 3.3))")
{
  :ok,
  %GeometryCollectionZ{
    geometries: MapSet.new([%PointZ{coordinate: [1.1, 2.2, 3.3]}])
  },
  123
}

iex> GeometryCollectionZ.from_wkt("GeometryCollection Z EMPTY")
{:ok, %GeometryCollectionZ{}}

Specs

from_wkt!(Geometry.wkt()) :: t() | {t(), Geometry.srid()}

The same as from_wkt/1, but raises a Geometry.Error exception if it fails.

Link to this function

member?(geometry_collection_z, geometry)

View Source

Specs

member?(t(), Geometry.t()) :: boolean()

Checks if GeometryCollectionZ contains geometry.

Examples

iex> GeometryCollectionZ.member?(
...>   GeometryCollectionZ.new([
...>     PointZ.new(11, 12, 13),
...>     LineStringZ.new([
...>       PointZ.new(21, 22, 23),
...>       PointZ.new(31, 32, 33)
...>     ])
...>   ]),
...>   PointZ.new(11, 12, 13)
...> )
true

iex> GeometryCollectionZ.member?(
...>   GeometryCollectionZ.new([
...>     PointZ.new(11, 12, 13),
...>     LineStringZ.new([
...>       PointZ.new(21, 22, 23),
...>       PointZ.new(31, 32, 33)
...>     ])
...>   ]),
...>   PointZ.new(1, 2, 3)
...> )
false

Specs

new() :: t()

Creates an empty GeometryCollectionZ.

Examples

iex> GeometryCollectionZ.new()
%GeometryCollectionZ{geometries: MapSet.new()}

Specs

new([Geometry.t()]) :: t()

Creates an empty GeometryCollectionZ.

Examples

iex> GeometryCollectionZ.new([
...>   PointZ.new(1, 2, 3),
...>   LineStringZ.new([PointZ.new(1, 1, 1), PointZ.new(2, 2, 2)])
...> ])
%GeometryCollectionZ{geometries: MapSet.new([
  %PointZ{coordinate: [1, 2, 3]},
  %LineStringZ{points: [[1, 1, 1], [2, 2, 2]]}
])}
Link to this function

size(geometry_collection_z)

View Source

Specs

size(t()) :: non_neg_integer()

Returns the number of elements in GeometryCollectionZ.

Examples

iex> GeometryCollectionZ.size(
...>   GeometryCollectionZ.new([
...>     PointZ.new(11, 12, 13),
...>     LineStringZ.new([
...>       PointZ.new(21, 22, 23),
...>       PointZ.new(31, 32, 33)
...>     ])
...>   ])
...> )
2
Link to this function

to_geo_json(geometry_collection_z)

View Source

Specs

to_geo_json(t()) :: Geometry.geo_json_term()

Returns the GeoJSON term of a GeometryCollectionZ.

Examples

iex> GeometryCollectionZ.to_geo_json(
...> GeometryCollectionZ.new([PointZ.new(1.1, 2.2, 3.3)]))
%{
  "type" => "GeometryCollection",
  "geometries" => [
    %{
      "type" => "Point",
      "coordinates" => [1.1, 2.2, 3.3]
    }
  ]
}
Link to this function

to_list(geometry_collection_z)

View Source

Specs

to_list(t()) :: [Geometry.t()]

Converts GeometryCollectionZ to a list.

Examples

iex> GeometryCollectionZ.to_list(
...>   GeometryCollectionZ.new([
...>     PointZ.new(11, 12, 13)
...>   ])
...> )
[%PointZ{coordinate: [11, 12, 13]}]
Link to this function

to_wkb(geometry_collection_z, opts \\ [])

View Source

Specs

to_wkb(t(), opts) :: Geometry.wkb()
when opts: [endian: Geometry.endian(), srid: Geometry.srid()]

Returns the WKB representation for a GeometryCollectionZ.

With option :srid an EWKB representation with the SRID is returned.

The option endian indicates whether :xdr big endian or :ndr little endian is returned. The default is :ndr.

The :mode determines whether a hex-string or binary is returned. The default is :binary.

An example of a simpler geometry can be found in the description for the Geometry.PointZ.to_wkb/1 function.

Link to this function

to_wkt(geometry_collection_z, opts \\ [])

View Source

Specs

to_wkt(t(), opts) :: Geometry.wkt() when opts: [{:srid, Geometry.srid()}]

Returns the WKT representation for a GeometryCollectionZ. With option :srid an EWKT representation with the SRID is returned.

Examples

iex> GeometryCollectionZ.to_wkt(GeometryCollectionZ.new())
"GeometryCollection Z EMPTY"

iex> GeometryCollectionZ.to_wkt(
...>   GeometryCollectionZ.new([
...>     PointZ.new(1.1, 1.2, 1.3),
...>     PointZ.new(2.1, 2.2, 2.3)
...>   ])
...> )
"GeometryCollection Z (Point Z (1.1 1.2 1.3), Point Z (2.1 2.2 2.3))"

iex> GeometryCollectionZ.to_wkt(
...>   GeometryCollectionZ.new([PointZ.new(1.1, 2.2, 3.3)]),
...>   srid: 4711)
"SRID=4711;GeometryCollection Z (Point Z (1.1 2.2 3.3))"