UNPKG

igniteui-angular-core

Version:

Ignite UI Angular Core logic used in multiple UI components.

306 lines (305 loc) 9.84 kB
import { EventEmitter } from '@angular/core'; import { delegateCombine } from './type'; import { ShapefileConverter as ShapefileConverter_internal } from "./ShapefileConverter"; import { fromRect, toRect, ensureBool } from "./componentUtil"; import { IgxAsyncCompletedEventArgs } from './igx-async-completed-event-args'; import { IgxShapefileRecord } from './igx-shapefile-record'; import { IgxShapeFilterRecordEventArgs } from './igx-shape-filter-record-event-args'; /** * Class used to convert Shapefiles into CLR objects. */ export class IgxShapeDataSource { constructor() { this._zoneRunner = null; this._importPending = null; this._importCompleted = null; this._filter = null; this._implementation = this.createImplementation(); this._implementation.externalObject = this; this.onImplementationCreated(); } createImplementation() { return new ShapefileConverter_internal(); } get i() { return this._implementation; } onImplementationCreated() { } _provideImplementation(i) { this._implementation = i; this._implementation.externalObject = this; this.onImplementationCreated(); } // private _databaseSource: string; ///** // * Gets the string Uri path of the .dbf portion of the Shapefile //*/ // get databaseSource(): string { // return this._databaseSource; // } ///** // * Sets the string Uri path of the .dbf portion of the Shapefile //*/ // set databaseSource(v: string) { // this._databaseSource = v; // } // private _shapefileSource: string; ///** // * Gets the string Uri path of the .shp portion of the Shapefile //*/ // get shapefileSource(): string { // return this._shapefileSource; // } ///** // * Sets the string Uri path of the .shp portion of the Shapefile //*/ // set shapefileSource(v: string) { // this._shapefileSource = v; // } dataBind() { //this.i.shapefileSource = null; //this.i.databaseSource = null; //if (this._shapefileSource && this._databaseSource) { // this.i.shapefileSource = new Uri(0, this._shapefileSource); // this.i.databaseSource = new Uri(0, this._databaseSource); //} } /** * Gets the point data. */ getPointData() { let list = this.i.getPointData(); let ret = []; for (var i = 0; i < list.count; i++) { var shapeRecord = list.item(i); if (!shapeRecord.externalObject) { let e = new IgxShapefileRecord(); e._implementation = shapeRecord; shapeRecord.externalObject = e; } ret.push(shapeRecord.externalObject); } return ret; } get name() { return this.i.name; } set name(v) { this.i.name = v; } /** * Gets the world bounding rectangle, as read from the header of the Shapefile. */ get worldRect() { return fromRect(this.i.worldRect); } set worldRect(v) { this.i.worldRect = toRect(v); } /** * Gets the world bounding rectangle, based on the filtered shapes */ get computedWorldRect() { return fromRect(this.i.computedWorldRect); } set computedWorldRect(v) { this.i.computedWorldRect = toRect(v); } /** * Gets the shape type, as read from the header of the Shapefile. */ get shapeType() { return this.i.shapeType; } /** * Gets the header of the Shapefile. */ get shapeHeader() { return this.i.shapeHeader; } set shapeHeader(v) { this.i.shapeHeader = v; } /** * The Uri of the .shp portion of the Shapefile. */ get deferImportCompleted() { return this.i.deferImportCompleted; } set deferImportCompleted(v) { this.i.deferImportCompleted = ensureBool(v); } /** * The Uri of the .shp portion of the Shapefile. */ get shapefileSource() { return this.i.shapefileSource; } set shapefileSource(v) { this.i.shapefileSource = v; } /** * The Uri of the .dbf portion of the Shapefile. */ get databaseSource() { return this.i.databaseSource; } set databaseSource(v) { this.i.databaseSource = v; } /** * The total number of ShapefileRecords in the collection. */ get count() { return this.i.count; } findByName(name) { if (this.findEphemera) { if (name && name.indexOf("@@e:") == 0) { return this.findEphemera(name); } } return null; } getWorldBounds(useComputed) { let iv = this.i.getWorldBounds(useComputed); return fromRect(iv); } setWorldBounds(setComputed, bounds) { this.i.setWorldBounds(setComputed, toRect(bounds)); } sendImportCompleted() { this.i.sendImportCompleted(); } getRecordsCount() { let iv = this.i.getRecordsCount(); return (iv); } getRecord(index) { let iv = this.i.getRecord(index); let ret = null; if (iv && iv.externalObject) { ret = iv.externalObject; } else { if (iv) { let e = new IgxShapefileRecord(); e._implementation = iv; iv.externalObject = e; ret = e; } } return ret; } getRecordBounds(index) { let iv = this.i.getRecordBounds(index); return fromRect(iv); } getRecordFieldNames(index) { let iv = this.i.getRecordFieldNames(index); return (iv); } getRecordValue(index, fieldName) { let iv = this.i.getRecordValue(index, fieldName); return (iv); } removeRecord(index) { this.i.removeRecord(index); } shiftAllShapes(offsetX, offsetY) { this.i.shiftAllShapes(offsetX, offsetY); } shiftShapes(recordIndex, offsetX, offsetY) { this.i.shiftShapes(recordIndex, offsetX, offsetY); } getMaxLongitude(recordIndex, useLargestShape, fromLongitude, toLongitude) { let iv = this.i.getMaxLongitude(recordIndex, useLargestShape, fromLongitude, toLongitude); return (iv); } setRecordValue(index, fieldName, value) { this.i.setRecordValue(index, fieldName, value); } getRecordValues(fieldName) { let iv = this.i.getRecordValues(fieldName); return (iv); } setRecordValues(fieldName, values) { this.i.setRecordValues(fieldName, values); } getLargestShapeBoundsForRecord(index) { let iv = this.i.getLargestShapeBoundsForRecord(index); return fromRect(iv); } _runInZone(act) { if (this._zoneRunner != null) { this._zoneRunner(act); } else { act(); } } /** * Event raised when the Shapefile has been imported from both the ShapefileSource and DatabaseSource Uris. */ get importPending() { if (this._importPending == null) { this._importPending = new EventEmitter(); this.i.importPending = delegateCombine(this.i.importPending, (o, e) => { this._runInZone(() => { let outerArgs = new IgxAsyncCompletedEventArgs(); outerArgs._provideImplementation(e); if (this.beforeImportPending) { this.beforeImportPending(this, outerArgs); } this._importPending.emit({ sender: this, args: outerArgs }); }); }); } return this._importPending; } /** * Event raised when the Shapefile has been imported from both the ShapefileSource and DatabaseSource Uris. */ get importCompleted() { if (this._importCompleted == null) { this._importCompleted = new EventEmitter(); this.i.importCompleted = delegateCombine(this.i.importCompleted, (o, e) => { this._runInZone(() => { let outerArgs = new IgxAsyncCompletedEventArgs(); outerArgs._provideImplementation(e); if (this.beforeImportCompleted) { this.beforeImportCompleted(this, outerArgs); } this._importCompleted.emit({ sender: this, args: outerArgs }); }); }); } return this._importCompleted; } get filter() { if (this._filter == null) { this._filter = new EventEmitter(); this.i.filter = delegateCombine(this.i.filter, (o, e) => { this._runInZone(() => { let outerArgs = new IgxShapeFilterRecordEventArgs(); outerArgs._provideImplementation(e); if (this.beforeFilter) { this.beforeFilter(this, outerArgs); } this._filter.emit({ sender: this, args: outerArgs }); }); }); } return this._filter; } }