<commit_before>/*****************************************************************************
***
*** Create the map_utils object to act as a namespace for this file
***
*****************************************************************************/

var map_utils = {};

/*****************************************************************************
***
*** Lon/Lat Reprojection
***
*** Default map projection for OpenLayers is "Web Mercator"
*** (EPSG:3857), which is also the default for OpenStreetMap, Google
*** Maps, MapQuest, and Bing Maps.
***
*****************************************************************************/

map_utils.reproject_to_map = function (longitude, latitude) {
    return ol.proj.transform([Number(longitude), Number(latitude)],
                             "EPSG:4326",
                             "EPSG:3857");
};

map_utils.reproject_from_map = function (x, y) {
    return ol.proj.transform([Number(x), Number(y)],
                             "EPSG:3857",
                             "EPSG:4326");
};

map_utils.get_full_extent = function () {
    var llxy = map_utils.reproject_to_map(-180.0, -89.999999);
    var urxy = map_utils.reproject_to_map(180.0, 90.0);
    return [llxy[0], llxy[1], urxy[0], urxy[1]];
};

map_utils.get_view_extent = function () {
    var view = map_utils.map_ref.getView();
    var size = map_utils.map_ref.getSize();
    var extent = view.calculateExtent(size);
    return ol.proj.transformExtent(extent, "EPSG:3857", "EPSG:4326");
};

/*****************************************************************************
***
*** Create the default OpenLayers Map Object used on all pages
***
*****************************************************************************/

// This reference will hold the current page's OpenLayers map object
map_utils.map_ref = null;

map_utils.create_source = function (source_config) {
    if (source_config.type == "DigitalGlobe") {
        return new ol.source.XYZ({url: "http://api.tiles.mapbox.com/v4/" + source_config.imagery_id
                                       + "/{z}/{x}/{y}.png?access_token=" + source_config.access_token,
                                  attribution: "© DigitalGlobe, Inc"});
    } else if (source_config.type == "BingMaps") {
        return new ol.source.BingMaps({imagerySet: source_config.imagery_id,
                                       key: source_config.access_token,
                                       maxZoom: 19});
    } else if (source_config.type == "GeoServer") {
        return new ol.source.TileWMS({serverType: "geoserver",
                                      url: source_config.geoserver_url,
                                      params: source_config.geoserver_params});
    } else {
        alert("Cannot create layer with source type " + source_config.type + ".");
        return null;
    }
};

map_utils.create_layer = function (layer_config, visible) {
    var source = map_utils.create_source(layer_config.source_config);
    if (source) {
        if (layer_config.extent != null) {
            return new ol.layer.Tile({title: layer_config.title,
                                      visible: visible,
                                      extent: layer_config.extent,
                                      source: source});
        } else {
            return new ol.layer.Tile({title: layer_config.title,
                                      visible: visible,
                                      source: source});
        }
    } else {
        return null;
    }
};
<commit_msg>Updating map-utils.js to use camelCase for keys found in imagery-list.json.<commit_after>/*****************************************************************************
***
*** Create the map_utils object to act as a namespace for this file
***
*****************************************************************************/

var map_utils = {};

/*****************************************************************************
***
*** Lon/Lat Reprojection
***
*** Default map projection for OpenLayers is "Web Mercator"
*** (EPSG:3857), which is also the default for OpenStreetMap, Google
*** Maps, MapQuest, and Bing Maps.
***
*****************************************************************************/

map_utils.reproject_to_map = function (longitude, latitude) {
    return ol.proj.transform([Number(longitude), Number(latitude)],
                             "EPSG:4326",
                             "EPSG:3857");
};

map_utils.reproject_from_map = function (x, y) {
    return ol.proj.transform([Number(x), Number(y)],
                             "EPSG:3857",
                             "EPSG:4326");
};

map_utils.get_full_extent = function () {
    var llxy = map_utils.reproject_to_map(-180.0, -89.999999);
    var urxy = map_utils.reproject_to_map(180.0, 90.0);
    return [llxy[0], llxy[1], urxy[0], urxy[1]];
};

map_utils.get_view_extent = function () {
    var view = map_utils.map_ref.getView();
    var size = map_utils.map_ref.getSize();
    var extent = view.calculateExtent(size);
    return ol.proj.transformExtent(extent, "EPSG:3857", "EPSG:4326");
};

/*****************************************************************************
***
*** Create the default OpenLayers Map Object used on all pages
***
*****************************************************************************/

// This reference will hold the current page's OpenLayers map object
map_utils.map_ref = null;

map_utils.create_source = function (source_config) {
    if (source_config.type == "DigitalGlobe") {
        return new ol.source.XYZ({url: "http://api.tiles.mapbox.com/v4/" + source_config.imageryId
                                       + "/{z}/{x}/{y}.png?access_token=" + source_config.accessToken,
                                  attribution: "© DigitalGlobe, Inc"});
    } else if (source_config.type == "BingMaps") {
        return new ol.source.BingMaps({imagerySet: source_config.imageryId,
                                       key: source_config.accessToken,
                                       maxZoom: 19});
    } else if (source_config.type == "GeoServer") {
        return new ol.source.TileWMS({serverType: "geoserver",
                                      url: source_config.geoserverUrl,
                                      params: source_config.geoserverParams});
    } else {
        alert("Cannot create layer with source type " + source_config.type + ".");
        return null;
    }
};

map_utils.create_layer = function (layer_config, visible) {
    var source = map_utils.create_source(layer_config.sourceConfig);
    if (source) {
        if (layer_config.extent != null) {
            return new ol.layer.Tile({title: layer_config.title,
                                      visible: visible,
                                      extent: layer_config.extent,
                                      source: source});
        } else {
            return new ol.layer.Tile({title: layer_config.title,
                                      visible: visible,
                                      source: source});
        }
    } else {
        return null;
    }
};

{'fraction_non_alphanumeric': 0.23640430588564237, 'fraction_numerical': 0.015098560044736474, 'mean_word_length': 2.3697597739048515, 'pattern_counts': {'":': 0, '<': 3, '<?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': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5551664', 'n_tokens_mistral': 2017, 'n_tokens_neox': 1854, 'n_words': 397}