import { delegateCombine, delegateRemove } from './type';
import { ShapefileConverter as ShapefileConverter_internal } from "./ShapefileConverter";
import { fromRect, toRect, ensureBool } from "./componentUtil";
import { IgcAsyncCompletedEventArgs } from './igc-async-completed-event-args';
import { IgcShapefileRecord } from './igc-shapefile-record';
import { IgcShapeFilterRecordEventArgs } from './igc-shape-filter-record-event-args';
/**
 * Class used to convert Shapefiles into CLR objects.
*/
var IgcShapeDataSource = /** @class */ /*@__PURE__*/ (function () {
    function IgcShapeDataSource() {
        //@@ZoneRunner
        this._importPending = null;
        this._importPending_wrapped = null;
        this._importCompleted = null;
        this._importCompleted_wrapped = null;
        this._filter = null;
        this._filter_wrapped = null;
        this._implementation = this.createImplementation();
        this._implementation.externalObject = this;
        this.onImplementationCreated();
    }
    IgcShapeDataSource.prototype.createImplementation = function () {
        return new ShapefileConverter_internal();
    };
    Object.defineProperty(IgcShapeDataSource.prototype, "i", {
        get: function () {
            return this._implementation;
        },
        enumerable: true,
        configurable: true
    });
    IgcShapeDataSource.prototype.onImplementationCreated = function () {
    };
    IgcShapeDataSource.prototype._provideImplementation = function (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;
    //   }
    IgcShapeDataSource.prototype.dataBind = function () {
        //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.
    */
    IgcShapeDataSource.prototype.getPointData = function () {
        var list = this.i.getPointData();
        var ret = [];
        for (var i = 0; i < list.count; i++) {
            var shapeRecord = list.item(i);
            if (!shapeRecord.externalObject) {
                var e = new IgcShapefileRecord();
                e._implementation = shapeRecord;
                shapeRecord.externalObject = e;
            }
            ret.push(shapeRecord.externalObject);
        }
        return ret;
    };
    Object.defineProperty(IgcShapeDataSource.prototype, "name", {
        get: function () {
            return this.i.name;
        },
        set: function (v) {
            this.i.name = v;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcShapeDataSource.prototype, "worldRect", {
        /**
         * Gets the world bounding rectangle, as read from the header of the Shapefile.
        */
        get: function () {
            return fromRect(this.i.worldRect);
        },
        set: function (v) {
            this.i.worldRect = toRect(v);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcShapeDataSource.prototype, "computedWorldRect", {
        /**
         * Gets the world bounding rectangle, based on the filtered shapes
        */
        get: function () {
            return fromRect(this.i.computedWorldRect);
        },
        set: function (v) {
            this.i.computedWorldRect = toRect(v);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcShapeDataSource.prototype, "shapeType", {
        /**
         * Gets the shape type, as read from the header of the Shapefile.
        */
        get: function () {
            return this.i.shapeType;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcShapeDataSource.prototype, "shapeHeader", {
        /**
         * Gets the header of the Shapefile.
        */
        get: function () {
            return this.i.shapeHeader;
        },
        set: function (v) {
            this.i.shapeHeader = v;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcShapeDataSource.prototype, "deferImportCompleted", {
        /**
         * The Uri of the .shp portion of the Shapefile.
        */
        get: function () {
            return this.i.deferImportCompleted;
        },
        set: function (v) {
            this.i.deferImportCompleted = ensureBool(v);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcShapeDataSource.prototype, "shapefileSource", {
        /**
         * The Uri of the .shp portion of the Shapefile.
        */
        get: function () {
            return this.i.shapefileSource;
        },
        set: function (v) {
            this.i.shapefileSource = v;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcShapeDataSource.prototype, "databaseSource", {
        /**
         * The Uri of the .dbf portion of the Shapefile.
        */
        get: function () {
            return this.i.databaseSource;
        },
        set: function (v) {
            this.i.databaseSource = v;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcShapeDataSource.prototype, "count", {
        /**
         * The total number of ShapefileRecords in the collection.
        */
        get: function () {
            return this.i.count;
        },
        enumerable: true,
        configurable: true
    });
    IgcShapeDataSource.prototype.getWorldBounds = function (useComputed) {
        var iv = this.i.getWorldBounds(useComputed);
        return fromRect(iv);
    };
    IgcShapeDataSource.prototype.setWorldBounds = function (setComputed, bounds) {
        this.i.setWorldBounds(setComputed, toRect(bounds));
    };
    IgcShapeDataSource.prototype.sendImportCompleted = function () {
        this.i.sendImportCompleted();
    };
    IgcShapeDataSource.prototype.getRecordsCount = function () {
        var iv = this.i.getRecordsCount();
        return (iv);
    };
    IgcShapeDataSource.prototype.getRecord = function (index) {
        var iv = this.i.getRecord(index);
        return (iv == null ? null : iv.externalObject);
    };
    IgcShapeDataSource.prototype.getRecordBounds = function (index) {
        var iv = this.i.getRecordBounds(index);
        return fromRect(iv);
    };
    IgcShapeDataSource.prototype.getRecordFieldNames = function (index) {
        var iv = this.i.getRecordFieldNames(index);
        return (iv);
    };
    IgcShapeDataSource.prototype.getRecordValue = function (index, fieldName) {
        var iv = this.i.getRecordValue(index, fieldName);
        return (iv);
    };
    IgcShapeDataSource.prototype.removeRecord = function (index) {
        this.i.removeRecord(index);
    };
    IgcShapeDataSource.prototype.shiftShapes = function (recordIndex, offsetX, offsetY) {
        this.i.shiftShapes(recordIndex, offsetX, offsetY);
    };
    IgcShapeDataSource.prototype.getMaxLongitude = function (recordIndex, useLargestShape, fromLongitude, toLongitude) {
        var iv = this.i.getMaxLongitude(recordIndex, useLargestShape, fromLongitude, toLongitude);
        return (iv);
    };
    IgcShapeDataSource.prototype.setRecordValue = function (index, fieldName, value) {
        this.i.setRecordValue(index, fieldName, value);
    };
    IgcShapeDataSource.prototype.getRecordValues = function (fieldName) {
        var iv = this.i.getRecordValues(fieldName);
        return (iv);
    };
    IgcShapeDataSource.prototype.setRecordValues = function (fieldName, values) {
        this.i.setRecordValues(fieldName, values);
    };
    IgcShapeDataSource.prototype.getLargestShapeBoundsForRecord = function (index) {
        var iv = this.i.getLargestShapeBoundsForRecord(index);
        return fromRect(iv);
    };
    Object.defineProperty(IgcShapeDataSource.prototype, "importPending", {
        /**
         * Event raised when the Shapefile has been imported from both the ShapefileSource and DatabaseSource Uris.
        */
        get: function () {
            return this._importPending;
        },
        set: function (ev) {
            var _this = this;
            if (this._importPending_wrapped !== null) {
                this.i.importPending = delegateRemove(this.i.importPending, this._importPending_wrapped);
                this._importPending_wrapped = null;
                this._importPending = null;
            }
            this._importPending = ev;
            this._importPending_wrapped = function (o, e) {
                var outerArgs = new IgcAsyncCompletedEventArgs();
                outerArgs._provideImplementation(e);
                if (_this.beforeImportPending) {
                    _this.beforeImportPending(_this, outerArgs);
                }
                if (_this._importPending) {
                    _this._importPending(_this, outerArgs);
                }
            };
            this.i.importPending = delegateCombine(this.i.importPending, this._importPending_wrapped);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcShapeDataSource.prototype, "importCompleted", {
        /**
         * Event raised when the Shapefile has been imported from both the ShapefileSource and DatabaseSource Uris.
        */
        get: function () {
            return this._importCompleted;
        },
        set: function (ev) {
            var _this = this;
            if (this._importCompleted_wrapped !== null) {
                this.i.importCompleted = delegateRemove(this.i.importCompleted, this._importCompleted_wrapped);
                this._importCompleted_wrapped = null;
                this._importCompleted = null;
            }
            this._importCompleted = ev;
            this._importCompleted_wrapped = function (o, e) {
                var outerArgs = new IgcAsyncCompletedEventArgs();
                outerArgs._provideImplementation(e);
                if (_this.beforeImportCompleted) {
                    _this.beforeImportCompleted(_this, outerArgs);
                }
                if (_this._importCompleted) {
                    _this._importCompleted(_this, outerArgs);
                }
            };
            this.i.importCompleted = delegateCombine(this.i.importCompleted, this._importCompleted_wrapped);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcShapeDataSource.prototype, "filter", {
        get: function () {
            return this._filter;
        },
        set: function (ev) {
            var _this = this;
            if (this._filter_wrapped !== null) {
                this.i.filter = delegateRemove(this.i.filter, this._filter_wrapped);
                this._filter_wrapped = null;
                this._filter = null;
            }
            this._filter = ev;
            this._filter_wrapped = function (o, e) {
                var outerArgs = new IgcShapeFilterRecordEventArgs();
                outerArgs._provideImplementation(e);
                if (_this.beforeFilter) {
                    _this.beforeFilter(_this, outerArgs);
                }
                if (_this._filter) {
                    _this._filter(_this, outerArgs);
                }
            };
            this.i.filter = delegateCombine(this.i.filter, this._filter_wrapped);
        },
        enumerable: true,
        configurable: true
    });
    return IgcShapeDataSource;
}());
export { IgcShapeDataSource };
//# sourceMappingURL=igc-shape-data-source.js.map
