Documentation for maplib/Geometry.kt

data class Point

Point class. Holds X and Y coordinates.

fun constructor(x: Double = 0.0, y: Double = 0.0)

Main constructor

Parameters
  • x – x X coordinate.

  • y – y Y coordinate.

var x : Double = 0.0

x X coordinate.

var y : Double = 0.0

y Y coordinate.

class CoordinateTransformation

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

fun constructor(handle: Long)

Main constructor

static fun new(fromEPSG: Int, toEPSG: Int) : CoordinateTransformation

Create new coordinate transformation.

Parameters
  • fromEPSG – Source EPSG spatial reference code.

  • toEPSG – Destination EPSG spatial reference code.

Returns

CoordinateTransformation class instance.

fun transform(point: Point) : Point

Perform transformation of point from one spatial reference to another.

Parameters
  • point – Point to transform.

Returns

Point with new coordinates.

data class Envelope

Spatial envelope.

fun constructor(minX: Double = 0.0, maxX: Double = 0.0, minY: Double = 0.0, maxY: Double = 0.0)

Main constructor

Parameters
  • minX – X Minimum X value.

  • maxX – X Maximum X value.

  • minY – Y Minimum Y value.

  • maxY – Y Maximum X value.

var minX : Double = 0.0

X Minimum X value.

var maxX : Double = 0.0

X Maximum X value.

var minY : Double = 0.0

Y Minimum Y value.

var maxY : Double = 0.0

Y Maximum X value.

val width : Double

Envelope width.

val height : Double

Envelope height.

val center : Point

Envelope center.

fun isInit() : Boolean

Check if envelope is init.

Returns

True if envelope is init.

fun 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.

fun increase(byValue: Double)

Increase envelope by value.

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

fun transform(fromEPSG: Int, toEPSG: Int)

Transform envelope from one spatial reference to another.

Parameters
  • fromEPSG – Source spatial reference EPSG code.

  • toEPSG – Destination spatial reference EPSD code.

class Geometry

Geometry class.

fun constructor(handle: Long)

Main constructor

Parameters
  • handle – e C API handle

val handle : Long

e C API handle

static fun typeToName(geometryType: Type) : String

Get name from geometry type.

Parameters
  • geometryType – Geometry type.

Returns

Geometry type name string.

static fun createFromJson(json: JsonObject) : Geometry?

Create geometry from json object. The GeoJson geometry part.

Parameters
  • json – JsonObject class instance.

Returns

Geometry or null.

val envelope : Envelope

Envelope of geometry.

val isEmpty : Boolean

Is empty geometry.

val type : Type

Geometry type.

fun transform(toEPSG: Int) : Boolean

Transform geometry from one spatial reference to another.

Parameters
  • epsg – Destination spatial reference.

Returns

True on success.

fun transform(transformation: CoordinateTransformation) : Boolean

Transform geometry from one spatial reference to another.

Parameters
  • transformation – CoordinateTransformation class instance.

Returns

True on success.

fun asJson() : String

Transform geometry to GeoJson string.

Returns

GeoJson string.

enum class Type

Geometry type.

  • NONE = 0 : No geometry.

  • POINT = 1 : Point.

  • LINESTRING = 2 : Linestring.

  • POLYGON = 3 : Polygon.

  • MULTIPOINT = 4 : Multipoint.

  • MULTILINESTRING = 5 : Multilinestring.

  • MULTIPOLYGON = 6 : Multipolygon.

class GeoPoint

Geometry point class.

constructor(handle Long)

Main constructor

fun setCoordinates(x: Double, y: Double, z: Double = 0.0, m: Double = 0.0)

Set the point location

Parameters
  • x – input X coordinate

  • y – input Y coordinate

  • z – input Z coordinate

  • m – input M coordinate

fun setCoordinates(point: Point, z: Double = 0.0, m: Double = 0.0)

Set the point location.

Parameters
  • point – input raw point struct

  • z – input Z coordinate

  • m – input M coordinate