"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParsedFeatures = void 0;
var tslib_1 = require("tslib");
var string_1 = require("../../utils/string");
var ParsedFeatures = /** @class */ (function () {
    function ParsedFeatures(type, size, features, hasFeaturesFlag, geometryTypes, propertyNames, projection) {
        if (projection === void 0) { projection = null; }
        this.type = type;
        this.size = size;
        this.features = features;
        this.hasFeaturesFlag = hasFeaturesFlag;
        this.geometryTypes = geometryTypes;
        this.propertyNames = propertyNames;
        this.projection = projection;
    }
    ParsedFeatures.prototype.hasFeatures = function () { return this.hasFeaturesFlag; };
    ParsedFeatures.prototype.addTo = function (source, mapProjection, dataProjection) {
        return tslib_1.__awaiter(this, void 0, void 0, function () {
            var features, _i, features_1, f, g, tg;
            return tslib_1.__generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.features()];
                    case 1:
                        features = _a.sent();
                        if (dataProjection) {
                            for (_i = 0, features_1 = features; _i < features_1.length; _i++) {
                                f = features_1[_i];
                                g = f.getGeometry();
                                if (g) {
                                    tg = g.transform(dataProjection, mapProjection);
                                    f.setGeometry(tg);
                                }
                            }
                        }
                        source.addFeatures(features);
                        return [2 /*return*/];
                }
            });
        });
    };
    ParsedFeatures.prototype.getDistinctValues = function (propertyName) {
        return tslib_1.__awaiter(this, void 0, void 0, function () {
            var values, features, _i, features_2, f, v;
            return tslib_1.__generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        values = [];
                        return [4 /*yield*/, this.features()];
                    case 1:
                        features = _a.sent();
                        for (_i = 0, features_2 = features; _i < features_2.length; _i++) {
                            f = features_2[_i];
                            v = f.get(propertyName);
                            if (!(0, string_1.strIsNullOrEmpty)(v) && !values.includes(v))
                                values.push(v);
                        }
                        return [2 /*return*/, values];
                }
            });
        });
    };
    return ParsedFeatures;
}());
exports.ParsedFeatures = ParsedFeatures;
//# sourceMappingURL=parsed-features.js.map