UNPKG

@nativescript-community/ui-carto

Version:

NativeScript plugin for CARTO Mobile SDK

72 lines 2.66 kB
import { BaseNative } from '../BaseNative'; import { FeatureCollection } from './feature'; import { nativeProperty } from '..'; import { PolygonGeometry } from '.'; import { LineGeometry, PointGeometry } from './index.android'; export class GeoJSONGeometryReader extends BaseNative { createNative() { return new com.carto.geometry.GeoJSONGeometryReader(); } 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 com.carto.geometry.LineGeometry) { return new LineGeometry(null, result); } else if (result instanceof com.carto.geometry.PointGeometry) { return new PointGeometry(null, result); } else if (result instanceof com.carto.geometry.PolygonGeometry) { 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 new com.carto.geometry.WKBGeometryReader(); } readGeometry(value) { if (!(value instanceof com.carto.core.BinaryData)) { value = new com.carto.core.BinaryData(value); } const result = this.getNative().readGeometry(value); if (result instanceof com.carto.geometry.LineGeometry) { return new LineGeometry(null, result); } else if (result instanceof com.carto.geometry.PointGeometry) { return new PointGeometry(null, result); } return null; } } __decorate([ nativeProperty ], WKBGeometryReader.prototype, "z", void 0); export class WKTGeometryReader extends BaseNative { createNative() { return new com.carto.geometry.WKTGeometryReader(); } readGeometry(value) { const result = this.getNative().readGeometry(value); if (result instanceof com.carto.geometry.LineGeometry) { return new LineGeometry(null, result); } else if (result instanceof com.carto.geometry.PointGeometry) { return new PointGeometry(null, result); } return null; } } __decorate([ nativeProperty ], WKTGeometryReader.prototype, "z", void 0); //# sourceMappingURL=reader.android.js.map