Geometry.LineStringZ (Geometry v0.1.0) View Source
A line-string struct, representing a 3D line.
A none empty line-string requires at least two points.
Link to this section Summary
Functions
Returns true if the given LineStringZ is empty.
Creates a LineStringZ from the given coordinates.
Returns an :ok tuple with the LineStringZ 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 LineStringZ from the given WKB string. Otherwise
returns an :error tuple.
The same as from_wkb/1, but raises a Geometry.Error exception if it fails.
Returns an :ok tuple with the LineStringZ 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.
Creates an empty LineStringZ.
Creates a LineStringZ from the given Geometry.PointZs.
Returns the GeoJSON term of a LineStringZ.
Returns the WKB representation for a LineStringZ.
Returns the WKT representation for a LineStringZ. With option :srid an
EWKT representation with the SRID is returned.
Link to this section Types
Specs
t() :: %Geometry.LineStringZ{points: Geometry.coordinates()}
Link to this section Functions
Specs
Returns true if the given LineStringZ is empty.
Examples
iex> LineStringZ.empty?(LineStringZ.new())
true
iex> LineStringZ.empty?(
...> LineStringZ.new(
...> [PointZ.new(1, 2, 3), PointZ.new(3, 4, 5)]
...> )
...> )
false
Specs
from_coordinates([Geometry.coordinate()]) :: t()
Creates a LineStringZ from the given coordinates.
Examples
iex> LineStringZ.from_coordinates(
...> [[-1, 1, 1], [-2, 2, 2], [-3, 3, 3]]
...> )
%LineStringZ{
points: [
[-1, 1, 1],
[-2, 2, 2],
[-3, 3, 3]
]
}
Specs
from_geo_json(Geometry.geo_json_term()) :: {:ok, t()} | Geometry.geo_json_error()
Returns an :ok tuple with the LineStringZ from the given GeoJSON term.
Otherwise returns an :error tuple.
Examples
iex> ~s(
...> {
...> "type": "LineString",
...> "coordinates": [
...> [1.1, 1.2, 1.3],
...> [20.1, 20.2, 20.3]
...> ]
...> }
...> )
iex> |> Jason.decode!()
iex> |> LineStringZ.from_geo_json()
{:ok, %LineStringZ{points: [
[1.1, 1.2, 1.3],
[20.1, 20.2, 20.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.
Specs
from_wkb(Geometry.wkb()) :: {:ok, t()} | {:ok, t(), Geometry.srid()} | Geometry.wkb_error()
Returns an :ok tuple with the LineStringZ 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/1 function.
Specs
from_wkb!(Geometry.wkb()) :: t() | {t(), Geometry.srid()}
The same as from_wkb/1, 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 LineStringZ 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> LineStringZ.from_wkt(
...> "LineString Z (-5.1 7.8 1.1, 0.1 0.2 2.2)"
...> )
{:ok, %LineStringZ{
points: [
[-5.1, 7.8, 1.1],
[0.1, 0.2, 2.2]
]
}}
iex> LineStringZ.from_wkt(
...> "SRID=7219;LineString Z (-5.1 7.8 1.1, 0.1 0.2 2.2)"
...> )
{:ok, %LineStringZ{
points: [
[-5.1, 7.8, 1.1],
[0.1, 0.2, 2.2]
]
}, 7219}
iex> LineStringZ.from_wkt("LineString Z EMPTY")
{:ok, %LineStringZ{}}
Specs
from_wkt!(Geometry.wkt()) :: t() | {t(), Geometry.srid()}
The same as from_wkt/1, but raises a Geometry.Error exception if it fails.
Specs
new() :: t()
Creates an empty LineStringZ.
Examples
iex> LineStringZ.new()
%LineStringZ{points: []}
Specs
new([Geometry.PointZ.t()]) :: t()
Creates a LineStringZ from the given Geometry.PointZs.
Examples
iex> LineStringZ.new([PointZ.new(1, 2, 3), PointZ.new(3, 4, 5)])
%LineStringZ{points: [[1, 2, 3], [3, 4, 5]]}
Specs
to_geo_json(t()) :: Geometry.geo_json_term()
Returns the GeoJSON term of a LineStringZ.
Examples
iex> LineStringZ.to_geo_json(
...> LineStringZ.new([
...> PointZ.new(-1.1, -2.2, -3.3),
...> PointZ.new(1.1, 2.2, 3.3)
...> ])
...> )
%{
"type" => "LineString",
"coordinates" => [
[-1.1, -2.2, -3.3],
[1.1, 2.2, 3.3]
]
}
Specs
to_wkb(t() | Geometry.coordinates(), opts) :: Geometry.wkb() when opts: [endian: Geometry.endian(), srid: Geometry.srid()]
Returns the WKB representation for a LineStringZ.
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 :xdr.
An example of a simpler geometry can be found in the description for the
Geometry.PointZ.to_wkb/1 function.
Specs
to_wkt(t(), opts) :: Geometry.wkt() when opts: [{:srid, Geometry.srid()}]
Returns the WKT representation for a LineStringZ. With option :srid an
EWKT representation with the SRID is returned.
Examples
iex> LineStringZ.to_wkt(LineStringZ.new())
"LineString Z EMPTY"
iex> LineStringZ.to_wkt(
...> LineStringZ.new([
...> PointZ.new(7.1, 8.1, 1.1),
...> PointZ.new(9.2, 5.2, 2.2)
...> ])
...> )
"LineString Z (7.1 8.1 1.1, 9.2 5.2 2.2)"
iex> LineStringZ.to_wkt(
...> LineStringZ.new([
...> PointZ.new(7.1, 8.1, 1.1),
...> PointZ.new(9.2, 5.2, 2.2)
...> ]),
...> srid: 123
...> )
"SRID=123;LineString Z (7.1 8.1 1.1, 9.2 5.2 2.2)"