UNPKG

@nativescript-community/ui-carto

Version:
77 lines 2.71 kB
import { BaseNative } from '../BaseNative'; import { FeatureCollection } from './feature'; import { PolygonGeometry } from '.'; import { nativeProperty } from '..'; import { LineGeometry, PointGeometry } from './index.ios'; export class GeoJSONGeometryReader extends BaseNative { createNative() { return NTGeoJSONGeometryReader.alloc().init(); } readFeatureCollection(str) { return new FeatureCollection(this.getNative().readFeatureCollection(typeof str === 'string' ? str : JSON.stringify(str))); } readGeometry(value) { const result = this.getNative().readGeometry(typeof value === 'string' ? value : JSON.stringify(value)); if (result instanceof NTLineGeometry) { return new LineGeometry(null, result); } else if (result instanceof NTPointGeometry) { return new PointGeometry(null, result); } else if (result instanceof NTPolygonGeometry) { return new PolygonGeometry(null, result); } return result; } set targetProjection(value) { this.native && this.native.setTargetProjection(value.getNative()); } get targetProjection() { return this.options.targetProjection; } } export class WKBGeometryReader extends BaseNative { createNative() { return NTWKBGeometryReader.alloc().init(); } readGeometry(value) { if (!(value instanceof NTBinaryData)) { if (value instanceof NSData) { const arr = new ArrayBuffer(value.length); value.getBytes(arr); value = arr; } value = NTBinaryData.alloc().initWithDataPtrSize(value, value.byteLength); } const result = this.getNative().readGeometry(value); if (result instanceof NTLineGeometry) { return new LineGeometry(null, result); } else if (result instanceof NTPointGeometry) { return new PointGeometry(null, result); } return null; } } __decorate([ nativeProperty ], WKBGeometryReader.prototype, "z", void 0); export class WKTGeometryReader extends BaseNative { createNative() { return NTWKTGeometryReader.alloc().init(); } readGeometry(value) { const result = this.getNative().readGeometry(value); if (result instanceof NTLineGeometry) { return new LineGeometry(null, result); } else if (result instanceof NTPointGeometry) { return new PointGeometry(null, result); } return null; } } __decorate([ nativeProperty ], WKTGeometryReader.prototype, "z", void 0); //# sourceMappingURL=reader.ios.js.map