<commit_before>var register = require("./util").register;
var Factory = require("../factory").Factory;
var UTIL = require("../util");
var PROJ = require("../proj");
var Polygon = require("./polygon").Polygon;
var Geometry = require("./geometry").Geometry;

var ReferencedEnvelope = Packages.org.geotools.geometry.jts.ReferencedEnvelope;
var Envelope = Packages.com.vividsolutions.jts.geom.Envelope;

var sameProjection = function(source, other) {
    if (source.projection && other.projection && !source.projection.equals(other.projection)) {
        other = other.transform(source.projection);
    }
    return other;
};

/** api: (define)
 *  module = geom
 *  class = Bounds
 */

var Bounds = UTIL.extend(Object, {
    
    /** api: constructor
     *  .. class:: Bounds
     *
     *      Create a new bounds given minx, miny, maxx, maxy, and an optional
     *      projection.
     */
    constructor: function Bounds(config) {  
        if (config) {
            var projection = config.projection;
            var isEmpty = (
                (typeof config.minx !== "number") || (typeof config.maxx !== "number") ||
                (typeof config.miny !== "number") || (typeof config.maxy !== "number") ||
                (config.maxx < config.minx) || (config.maxy < config.miny)
            );
            if (projection) {
                if (!(projection instanceof PROJ.Projection)) {
                    projection = new PROJ.Projection(projection);
                }
                var _projection = projection._projection;
                if (!isEmpty) {
                    this._bounds = new ReferencedEnvelope(
                        config.minx, config.maxx, config.miny, config.maxy, _projection
                    );                
                } else {
                    this._bounds = new ReferencedEnvelope(_projection);
                }
            } else {
                if (!isEmpty) {
                    this._bounds = new ReferencedEnvelope(
                        config.minx, config.maxx, config.miny, config.maxy, null
                    );                
                } else {
                    this._bounds = new ReferencedEnvelope();
                }
            }
        }
    },
    
    /** private: property[config]<commit_msg>Accept array in constructing bounds.<commit_after>var register = require("./util").register;
var Factory = require("../factory").Factory;
var UTIL = require("../util");
var PROJ = require("../proj");
var Polygon = require("./polygon").Polygon;
var Geometry = require("./geometry").Geometry;

var ReferencedEnvelope = Packages.org.geotools.geometry.jts.ReferencedEnvelope;
var Envelope = Packages.com.vividsolutions.jts.geom.Envelope;

var sameProjection = function(source, other) {
    if (source.projection && other.projection && !source.projection.equals(other.projection)) {
        other = other.transform(source.projection);
    }
    return other;
};

/** api: (define)
 *  module = geom
 *  class = Bounds
 */

var Bounds = UTIL.extend(Object, {
    
    /** api: constructor
     *  .. class:: Bounds
     *
     *      Create a new bounds given minx, miny, maxx, maxy, and an optional
     *      projection.
     */
    constructor: function Bounds(config) {
        if (config) {
            if (config instanceof Array) {
                config = {
                    minx: config[0], miny: config[1], 
                    maxx: config[2], maxy: config[3]                    
                };
            }
            var projection = config.projection;
            var isEmpty = (
                (typeof config.minx !== "number") || (typeof config.maxx !== "number") ||
                (typeof config.miny !== "number") || (typeof config.maxy !== "number") ||
                (config.maxx < config.minx) || (config.maxy < config.miny)
            );
            if (projection) {
                if (!(projection instanceof PROJ.Projection)) {
                    projection = new PROJ.Projection(projection);
                }
                var _projection = projection._projection;
                if (!isEmpty) {
                    this._bounds = new ReferencedEnvelope(
                        config.minx, config.maxx, config.miny, config.maxy, _projection
                    );                
                } else {
                    this._bounds = new ReferencedEnvelope(_projection);
                }
            } else {
                if (!isEmpty) {
                    this._bounds = new ReferencedEnvelope(
                        config.minx, config.maxx, config.miny, config.maxy, null
                    );                
                } else {
                    this._bounds = new ReferencedEnvelope();
                }
            }
        }
    },
    
    /** private: property[config]
{'fraction_non_alphanumeric': 0.12293046357615894, 'fraction_numerical': 0.0008278145695364238, 'mean_word_length': 1.5858747993579454, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4795697', 'n_tokens_mistral': 1325, 'n_tokens_neox': 1269, 'n_words': 278}