"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CustomBBoxValidator = void 0;
class CustomBBoxValidator {
    static isLatitudeValid(latitude) {
        return latitude >= -90 && latitude <= 90;
    }
    static isLongitudeValid(longitude) {
        return longitude >= -180 && longitude <= 180;
    }
}
exports.CustomBBoxValidator = CustomBBoxValidator;
_a = CustomBBoxValidator;
/**
 * Bounding box format: topLat,topLon,bottomLat,bottomLon
 * 4 positive or negative floating point numbers separated by commas
 * @example 50.073619,14.414826,50.092867,14.438086
 */
CustomBBoxValidator.BOUNDING_BOX_REGEX = /^(?:-?\d+?(?:\.\d+?)?,){3}-?\d+?(?:\.\d+?)?$/;
CustomBBoxValidator.validate = (value, _) => {
    if (typeof value !== "string" || value.trim().length === 0 || value.length > 80 || !_a.BOUNDING_BOX_REGEX.test(value)) {
        return false;
    }
    const [topLat, topLon, bottomLat, bottomLon] = value.split(",").map((coordinate) => Number.parseFloat(coordinate));
    return (_a.isLatitudeValid(topLat) &&
        _a.isLatitudeValid(bottomLat) &&
        _a.isLongitudeValid(topLon) &&
        _a.isLongitudeValid(bottomLon));
};
//# sourceMappingURL=CustomBBoxValidator.js.map