Documentation for MapLib/Store.swift

class MemoryStore : Object

In memory spatial data storage. After class instance destruction all data will be loose.

static let ext = ".ngmem"

Memory storage description file extension.

func createFeatureClass()

Create feature class in storage.

Parameters
  • name – Feature class name.

  • geometryType – Geometry type.

  • epsg – Spatial reference EPSG code.

  • fields – Feature class fields.

  • options – Any other create option if form of key-value dictionary.

Returns

FeatureClass class instance or nil.

class Store : Object

Spatial data storage. This is geopackage file with specific additions.

static let ext = ".ngst"

Spatial data storage file extension.

func createFeatureClass()

Create feature class in storage.

Parameters
  • name – Feature class name.

  • geometryType – Geometry type.

  • fields – Feature class fields.

  • options – Any other create option if form of key-value dictionary.

Returns

FeatureClass class instance or nil.

func createTable()

Create table in storage.

Parameters
  • name – Table name.

  • fields – Table fields.

  • options – Any other create option if form of key-value dictionary.

Returns

Table class instance or nil.

enum EditOperationType

Edit operation type. This is enumerator of edit operation types.

  • NOP: No operation.

  • CREATE_FEATURE: Create feature/row.

  • CHANGE_FEATURE: Change feature/row.

  • DELETE_FEATURE: Delete feature/row.

  • DELETE_ALL_FEATURES: Delete all features.

  • CREATE_ATTACHMENT: Create new attachment

  • CHANGE_ATTACHMENT: Change attachment name and/or description

  • DELETE_ATTACHMENT: Delete attachment

  • DELETE_ALL_ATTACHMENTS: Delete all attachmetns

struct EditOperation

Edit operation for logging properties.

class Raster : Object

Spatial referenced raster or image

func cacheArea()

Cache tiles for some area for TMS datasource.

Parameters
  • bbox – Area to cache.

  • zoomLevels – Zoom levels to cache.

  • callback – Callback function which executes periodically indicating progress.

Returns

True on success.

class Table : Object

Non spatial table.

var fields : [Field] = []

Fields array

var batchMode : Bool

Enable/disable batch mode property. The sqlite journal will be swith on/off.

var count : Int64

Feature/row count readonly property.

func createFeature() Feature?

Create new feature/row in memory.

Returns

New feature class instane or nil.

func insertFeature(_ feature:Feature, logEdits: Bool = true) Bool

Insert feature into table.

Parameters
  • feature – Feature/row to insert.

  • logEdits – Log edits in history table. This log can be received using editOperations function.

Returns

True on success.

func updateFeature(_ feature:Feature, logEdits: Bool = true) Bool

Update feature/row.

Parameters
  • feature – Feature/row to update.

  • logEdits – Log edits in history table. This log can be received using editOperations function.

Returns

True on success.

func deleteFeature(id: Int64, logEdits: Bool = true) Bool

Delete feature/row.

Parameters
  • id – Feature/row identificator.

  • logEdits – Log edits in history table. This log can be received using editOperations function.

Returns

True on success.

func deleteFeature(feature: Feature, logEdits: Bool = true) Bool

Delete feature/row.

Parameters
  • feature – Feature/row to delete.

  • logEdits – Log edits in history table. This log can be received using editOperations function.

Returns

True on success.

func deleteFeatures(logEdits: Bool = true) Bool

Delete all features/rows in table.

Parameters
  • logEdits – Log edits in history table. This log can be received using editOperations function.

Returns

True on success.

func reset()

Reset reading features/rows.

func nextFeature() Feature?

Get next feature/row.

Returns

Feature class instance or nil.

func getFeature(index: Int64) Feature?

Get feature/row by identificator.

Parameters
  • index – Feature/row

Returns

Feature class instance or nil.

func getFeature(remoteId: Int64) Feature?

Get feature/row by remote identificator.

Parameters
  • remoteId – remote identificator.

Returns

Feature class instance or nil.

func fieldIndexAndType(by name:String) (index: Int32, type: Field.FieldType)

Search field index and type by field name.

Parameters
  • name – Field name.

Returns

Tuple with index and type. If field not exists the index will be negative and field type will be UNKNOWN.Get e

func editOperations() [EditOperation]

Get edit operations log.

Returns

EditOperation class array. It may be empty.

func delete(editOperation: EditOperation)

Delete edit operation from log.

Parameters
  • editOperation – EditOperation to delete.

class FeatureClass : Table

Spatial table.

let geometryType : Geometry.GeometryType

Geometry type of feature class.

func createOverviews()

Create vector overviews to speedup drawing. This is a synchronous method.

Parameters
  • force – If true the previous overviews will be deleted.

  • zoomLevels – The list of zoom levels to generate.

  • callback – Callback function to show process and cancel creation if needed.

Returns

True on success.

func clearFilters() Bool

Clear any filters set on feature class.

Returns

True on success.

func setSpatialFilter(envelope: Envelope) Bool

Set spatial filter.

Parameters
  • envelope – Features intesect with envelope will be returned via nextFeature.

Returns

True on success.

func setSpatialFilter(geometry: Geometry) Bool

Set spatial filter.

Parameters
  • geometry – Features intesect with geometry will be returned via nextFeature.

Returns

True on success.

func setAttributeFilter(query: String) Bool

Set attribute filter.

Parameters
  • query – SQL WHERE clause.

Returns

True on success.

func setFilters(geometry: Geometry, query: String) Bool

Set spatial and attribute filtes.

Parameters
  • geometry – Features intesect with geometry will be returned via nextFeature.

  • query – SQL WHERE clause.

Returns

True on success.

class Field

FeatureClass/Table filed class.

let name : String

Field name.

let alias : String

Field alias.

let type : FieldType

Field type.

let defaultValue : String

Field default value.

init(name: String, alias: String, type: FieldType, defaultValue: String = nil)

Init field with values.

Parameters
  • name – Field name.

  • alias – Field alias.

  • type – Field type.

  • defaultValue – Default value or nil.

enum FieldType : Int32

Field type enum.

  • UNKNOWN: Unknown type.

  • INTEGER: Integer type.

  • REAL: Real type.

  • STRING: String type.

  • DATE: Date/time type.