struct WKB::Position
- WKB::Position
- Struct
- Value
- Object
Overview
A position is the base entity to represent coordinates in geometry objects.
Positions are a thin wrapper around a slice of double precision floats, they have a mode, and they can also be empty.
Included Modules
- Indexable(Float64)
Defined in:
wkb/geojson.crwkb/position.cr
Constructors
-
.new(coordinates : Array(Float64), mode : Mode)
Creates a position with the given coordinates (which can be empty) and coordinate mode.
-
.new(pull : JSON::PullParser)
NOTE It's necessary to require the GeoJSON extension after loading the library.
Instance Method Summary
-
#has_m?
Returns
true
if the M coordinate is supported. -
#has_z?
Returns
true
if the Z coordinate is supported. -
#has_zm?
Returns
true
if both Z and M coordinates are supported. -
#m
Returns the M coordinate or
Float64::NAN
if empty or the mode has not M. -
#mode : WKB::Mode
Returns the position's coordinate mode.
-
#size
Returns the number of coordinates.
-
#slice : Slice(Float64)
Returns the underlying slice of coordinates.
-
#to_coordinates : Array(Float64)
Returns a representation of coordinates as an array.
-
#to_json(builder : JSON::Builder)
NOTE It's necessary to require the GeoJSON extension after loading the library.
-
#x
Returns the X coordinate or
Float64::NAN
if empty. -
#y
Returns the Y coordinate or
Float64::NAN
if empty. -
#z
Returns the Z coordinate or
Float64::NAN
if empty or the mode has not Z.
Constructor Detail
Creates a position with the given coordinates (which can be empty) and coordinate mode.
NOTE It raises WKB::Error
if the number of coordinates does not agree with the mode.
NOTE It's necessary to require the GeoJSON extension after loading the library.
Instance Method Detail
NOTE It's necessary to require the GeoJSON extension after loading the library.