-
Encodes an instance of the concrete
GeoJSONObject
type.Declaration
Swift
public static func encode<T>(_ geoJSONObject: T) throws -> Data where T : GeoJSONObject
Parameters
geoJSONObject
The object that conforms to
GeoJSONObject
protocol to encode.Return Value
Data
that represents encoded GeoJSON object. -
Decodes an instance of the known expected GeoJSON type.
Declaration
Swift
public static func decodeKnown<T>(_ data: Data) throws -> T? where T : GeoJSONObject
Parameters
data
Data
object that represents encoded GeoJSON object with known expected type.Return Value
Concrete GeoJSON object that conforms to
GeoJSONObject
protocol, ornil
if the type is not a GeoJSON object. -
Decodes an instance of the unknown concrete type that is expected to conform to
GeoJSONObject
protocol.Declaration
Swift
public static func decodeUnknown(_ data: Data) throws -> GeoJSONObject?
Parameters
data
Data
object that represents encoded GeoJSON object with unknown concrete type.Return Value
GeoJSON object that conforms to
GeoJSONObject
protocol, ornil
if the type is not a GeoJSON object. -
Converts a generic object confirming to the
GeoJSONObject
protocol to a dictionary representation of that data. Use this method when creating a new GeoJSON source withStyle.addSource(_:properties)
.Declaration
Swift
public static func dictionaryFrom<T>(_ geoJSONObject: T) throws -> [String : Any]? where T : GeoJSONObject
Parameters
geoJSONObject
A generic object that conforms to the
GeoJSONObject
protocol.Return Value
A nested dictionary that represents the
data
object of a GeoJSON feature.