Geometry.GeometryCollectionZM (Geometry v0.3.0) View Source

A collection set of 3D geometries with a measurement.

GeometryCollectionZM implements the protocols Enumerable and Collectable.

Examples

iex> Enum.map(
...>   GeometryCollectionZM.new([
...>     PointZM.new(11, 12, 13, 14),
...>     LineStringZM.new([
...>       PointZM.new(21, 22, 23, 24),
...>       PointZM.new(31, 32, 33, 34)
...>     ])
...>   ]),
...>   fn
...>     %PointZM{} -> :point
...>     %LineStringZM{} -> :line_string
...>   end
...> ) |> Enum.sort()
[:line_string, :point]

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

Link to this section Summary

Functions

Returns true if the given GeometryCollectionZM is empty.

Returns an :ok tuple with the GeometryCollectionZM 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 GeometryCollectionZM 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 GeometryCollectionZM 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 GeometryCollectionZM contains geometry.

Creates an empty GeometryCollectionZM.

Creates an empty GeometryCollectionZM.

Returns the number of elements in GeometryCollectionZM.

Returns the GeoJSON term of a GeometryCollectionZM.

Converts GeometryCollectionZM to a list.

Returns the WKB representation for a GeometryCollectionZM.

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

Link to this section Types

Specs

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

Link to this section Functions

Link to this function

empty?(geometry_collection_zm)

View Source

Specs

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

Returns true if the given GeometryCollectionZM is empty.

Examples

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

iex> GeometryCollectionZM.empty?(GeometryCollectionZM.new([PointZM.new(1, 2, 3, 4)]))
false

Specs

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

Returns an :ok tuple with the GeometryCollectionZM 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, 4.4]}
...>   ]
...> })
iex> |> Jason.decode!()
iex> |> GeometryCollectionZM.from_geo_json()
{
  :ok,
  %GeometryCollectionZM{
    geometries: MapSet.new([%PointZM{coordinate: [1.1, 2.2, 3.3, 4.4]}])
  }
}

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() | {t(), Geometry.srid()}} | Geometry.wkb_error()

Returns an :ok tuple with the GeometryCollectionZM 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.PointZM.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() | {t(), Geometry.srid()}} | Geometry.wkt_error()

Returns an :ok tuple with the GeometryCollectionZM 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> GeometryCollectionZM.from_wkt(
...>   "GeometryCollection ZM (Point ZM (1.1 2.2 3.3 4.4))")
{
  :ok,
  %GeometryCollectionZM{
    geometries: MapSet.new([%PointZM{coordinate: [1.1, 2.2, 3.3, 4.4]}])
  }
}

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

iex> GeometryCollectionZM.from_wkt("GeometryCollection ZM EMPTY")
{:ok, %GeometryCollectionZM{}}

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_zm, geometry)

View Source

Specs

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

Checks if GeometryCollectionZM contains geometry.

Examples

iex> GeometryCollectionZM.member?(
...>   GeometryCollectionZM.new([
...>     PointZM.new(11, 12, 13, 14),
...>     LineStringZM.new([
...>       PointZM.new(21, 22, 23, 24),
...>       PointZM.new(31, 32, 33, 34)
...>     ])
...>   ]),
...>   PointZM.new(11, 12, 13, 14)
...> )
true

iex> GeometryCollectionZM.member?(
...>   GeometryCollectionZM.new([
...>     PointZM.new(11, 12, 13, 14),
...>     LineStringZM.new([
...>       PointZM.new(21, 22, 23, 24),
...>       PointZM.new(31, 32, 33, 34)
...>     ])
...>   ]),
...>   PointZM.new(1, 2, 3, 4)
...> )
false

Specs

new() :: t()

Creates an empty GeometryCollectionZM.

Examples

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

Specs

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

Creates an empty GeometryCollectionZM.

Examples

iex> GeometryCollectionZM.new([
...>   PointZM.new(1, 2, 3, 4),
...>   LineStringZM.new([PointZM.new(1, 1, 1, 1), PointZM.new(2, 2, 2, 2)])
...> ])
%GeometryCollectionZM{geometries: MapSet.new([
  %PointZM{coordinate: [1, 2, 3, 4]},
  %LineStringZM{points: [[1, 1, 1, 1], [2, 2, 2, 2]]}
])}
Link to this function

size(geometry_collection_zm)

View Source

Specs

size(t()) :: non_neg_integer()

Returns the number of elements in GeometryCollectionZM.

Examples

iex> GeometryCollectionZM.size(
...>   GeometryCollectionZM.new([
...>     PointZM.new(11, 12, 13, 14),
...>     LineStringZM.new([
...>       PointZM.new(21, 22, 23, 24),
...>       PointZM.new(31, 32, 33, 34)
...>     ])
...>   ])
...> )
2
Link to this function

to_geo_json(geometry_collection_zm)

View Source

Specs

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

Returns the GeoJSON term of a GeometryCollectionZM.

Examples

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

to_list(geometry_collection_zm)

View Source

Specs

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

Converts GeometryCollectionZM to a list.

Examples

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

to_wkb(geometry_collection_zm, opts \\ [])

View Source

Specs

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

Returns the WKB representation for a GeometryCollectionZM.

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.PointZM.to_wkb/1 function.

Link to this function

to_wkt(geometry_collection_zm, opts \\ [])

View Source

Specs

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

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

Examples

iex> GeometryCollectionZM.to_wkt(GeometryCollectionZM.new())
"GeometryCollection ZM EMPTY"

iex> GeometryCollectionZM.to_wkt(
...>   GeometryCollectionZM.new([
...>     PointZM.new(1.1, 1.2, 1.3, 1.4),
...>     PointZM.new(2.1, 2.2, 2.3, 2.4)
...>   ])
...> )
"GeometryCollection ZM (Point ZM (1.1 1.2 1.3 1.4), Point ZM (2.1 2.2 2.3 2.4))"

iex> GeometryCollectionZM.to_wkt(
...>   GeometryCollectionZM.new([PointZM.new(1.1, 2.2, 3.3, 4.4)]),
...>   srid: 4711)
"SRID=4711;GeometryCollection ZM (Point ZM (1.1 2.2 3.3 4.4))"