Documentation for MapLib/Geometry.swift

class CoordinateTransformation

Coordinate transformation class. Helps to transform from one spatial reference to another.

static func new(fromEPSG: Int32, toEPSG: Int32) CoordinateTransformation

Create new coordinate transformation.

Parameters
  • fromEPSG – Source EPSG spatial reference code.

  • toEPSG – Destination EPSG spatial reference code.

Returns

CoordinateTransformation class instance.

func transform(_ point:Point) Point

Perform transformation of point from one spatial reference to another.

Parameters
  • point – Point to transform.

Returns

Point with new coordinates.

struct Envelope : Equatable

Spatial envelope.

var minX : Double

Minimum X coordinate.

var maxX : Double

Maximum X coordinate.

var minY : Double

Minimum Y coordinate.

var maxY : Double

Maximum Y coordinate.

init(minX: Double, minY: Double, maxX: Double, maxY: Double)

Init envelope with values.

Parameters
  • minX – Minimum X coordinate.

  • minY – Minimum Y coordinate.

  • maxX – Maximum X coordinate.

  • maxY – Maximum Y coordinate.

init()

Init envelope with zeroo coordinates. Envelope will be invalid.

func isInit() Bool

Check if envelope is init.

Returns

True if envelope is init.

func merge(other: Envelope)

Merge envelope with other envelope. The result of extent of this and other envelop will be set to this envelope.

Parameters
  • other – Other envelope.

var width : Double

Envelope width.

var height : Double

Envelope height.

var center : Point

Envelope center.

func increase(by value:Double)

Increase envelope by value.

Parameters
  • value – Value to increase width and height of envelope. May be negative for decrease sizes.

func transform(fromEPSG: Int32, toEPSG: Int32)

Transform envelope from one spatial reference to another.

Parameters
  • fromEPSG – Source spatial reference EPSG code.

  • toEPSG – Destination spatial reference EPSD code.

func clone() Envelope

Create strong copy of envelope.

Returns

New envelope clas instance.

class Geometry

Geometry class.

var envelope : Envelope

Envelope of geometry.

var isEmpty : Bool

Is empty geometry.

var type : GeometryType

Geometry type.

func transform(to epsg:Int32) Bool

Transform geometry from one spatial reference to another.

Parameters
  • epsg – Destination spatial reference.

Returns

True on success.

func transform(_ transformation:CoordinateTransformation) Bool

Transform geometry from one spatial reference to another.

Parameters
  • transformation – CoordinateTransformation class instance.

Returns

True on success.

func asJson() String

Transform geometry to GeoJson string.

Returns

GeoJson string.

enum GeometryType : Int32

Geometry type.

  • NONE: No geometry.

  • POINT: Point.

  • LINESTRING: Linestring.

  • POLYGON: Polygon.

  • MULTIPOINT: Multipoint.

  • MULTILINESTRING: Multilinestring.

  • MULTIPOLYGON: Multipolygon.

class GeoPoint : Geometry

Geometry point class.

func setCoordinates(x: Double, y: Double, z: Double = 0, m: Double = 0)

Set the point location

Parameters
  • x – input X coordinate

  • y – input Y coordinate

  • z – input Z coordinate

  • m – input M coordinate

func setCoordinates(point: Point, z: Double = 0, m: Double = 0)

Set the point location

Parameters
  • point – input raw point struct

  • z – input Z coordinate

  • m – input M coordinate