shapeWithData static method

MLNShape? shapeWithData(
  1. NSData data, {
  2. required int encoding,
  3. required Pointer<Pointer<ObjCObject>> error,
})
override

Returns an MLNShape object initialized with the given data interpreted as a string containing a GeoJSON object.

If the GeoJSON object is a geometry, the returned value is a kind of MLNShape. If it is a feature object, the returned value is a kind of MLNShape that conforms to the MLNShape protocol. If it is a feature collection object, the returned value is an instance of MLNShapeCollectionFeature.

Example

let url = mainBundle.url(forResource: "amsterdam", withExtension: "geojson")!
let data = try! Data(contentsOf: url)
let feature = try! MLNShape(data: data, encoding: String.Encoding.utf8.rawValue) as!
MLNShapeCollectionFeature

@param data String data containing GeoJSON source code. @param encoding The encoding used by data. @param outError Upon return, if an error has occurred, a pointer to an NSError object describing the error. Pass in NULL to ignore any error. @return An MLNShape object representation of data, or nil if data could not be parsed as valid GeoJSON source code. If nil, outError contains an NSError object describing the problem.

Implementation

static MLNShape? shapeWithData(objc.NSData data, {required int encoding,required ffi.Pointer<ffi.Pointer<objc.ObjCObject>> error}) {
  final _ret = _objc_msgSend_1nomli1(_class_MLNPolygonFeature, _sel_shapeWithData_encoding_error_, data.ref.pointer, encoding, error);
  return _ret.address == 0 ? null : MLNShape.castFromPointer(_ret, retain: true, release: true);
}