struct WKB::Position

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

Defined in:

wkb/geojson.cr
wkb/position.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(coordinates : Array(Float64), mode : Mode) #

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.


[View source]
def self.new(pull : JSON::PullParser) #

NOTE It's necessary to require the GeoJSON extension after loading the library.


[View source]

Instance Method Detail

def has_m? #

Returns true if the M coordinate is supported.


[View source]
def has_z? #

Returns true if the Z coordinate is supported.


[View source]
def has_zm? #

Returns true if both Z and M coordinates are supported.


[View source]
def m #

Returns the M coordinate or Float64::NAN if empty or the mode has not M.


[View source]
def mode : WKB::Mode #

Returns the position's coordinate mode.


[View source]
def size #

Returns the number of coordinates.


[View source]
def slice : Slice(Float64) #

Returns the underlying slice of coordinates.


[View source]
def to_coordinates : Array(Float64) #

Returns a representation of coordinates as an array.


[View source]
def to_json(builder : JSON::Builder) #

NOTE It's necessary to require the GeoJSON extension after loading the library.


[View source]
def x #

Returns the X coordinate or Float64::NAN if empty.


[View source]
def y #

Returns the Y coordinate or Float64::NAN if empty.


[View source]
def z #

Returns the Z coordinate or Float64::NAN if empty or the mode has not Z.


[View source]