<commit_before>﻿/*global define*/
define(["dojo/Deferred", "dojo/promise/all"], function (Deferred, all) {

	/**
	 * Creates a query string.
	 * @param {Object} obj
	 * @returns {string}
	 */
	function objToQuery(obj) {
		var output = [];
		for (var propName in obj) {
			if (obj.hasOwnProperty) {
				output.push([propName, encodeURIComponent(obj[propName])].join("="));
			}
		}
		return output.join("&");
	}

	/**
	 * Creates a canvas element that displays the contents of a map.
	 * @param {esri/Map} map
	 * @param {HTMLCanvasElement} canvas
	 */
	function mapToCanvas(map, canvas) {
		var ctx;
		if (!canvas) {
			canvas = document.createElement("canvas");
		} else {
			ctx = canvas.getContext("2d");
			ctx.clearRect(0,0,canvas.width, canvas.height);
		}
		canvas.width = map.width;
		canvas.height = map.height;
		if (!ctx) {
			ctx = canvas.getContext("2d");
		}
		var requests = [];

		// Loop through map layers
		map.layerIds.forEach(function (layerId) {
			var layer = map.getLayer(layerId);
			var url;
			var exportParams;
			var image;
			var deferred;

			if (layer.url) {
				deferred = new Deferred();
				exportParams = {
					f: "image",
					size: [map.width, map.height].join(","),
					bbox: [map.extent.xmin, map.extent.ymin, map.extent.xmax, map.extent.ymax].join(","),
					bboxSR: map.extent.wkid,
					format: "png",
					transparent: true
				};
				exportParams = objToQuery(exportParams);
				url = [layer.url, "/export?", exportParams].join("");
				url = url.replace("//export", "/export");

				image = new Image(map.width, map.height);
				requests.push(deferred);
				image.addEventListener("load", function () {
					// ctx.drawImage(image, 0, 0);
					deferred.resolve(image);
				}, false);
				image.src = url;
			} else {
				console.log("No URL for layer: " + layerId);
			}
		});

		// Once all of the images have loaded, add them to the canvas.
		all(requests).then(function (images) {
			images.forEach(function (image) {
				ctx.drawImage(image, 0, 0);<commit_msg>:bug: fixed incorrect bboxSR parameter specification<commit_after>﻿/*global define*/
define(["dojo/Deferred", "dojo/promise/all"], function (Deferred, all) {

	/**
	 * Creates a query string.
	 * @param {Object} obj
	 * @returns {string}
	 */
	function objToQuery(obj) {
		var output = [];
		for (var propName in obj) {
			if (obj.hasOwnProperty) {
				output.push([propName, encodeURIComponent(obj[propName])].join("="));
			}
		}
		return output.join("&");
	}

	/**
	 * Creates a canvas element that displays the contents of a map.
	 * @param {esri/Map} map
	 * @param {HTMLCanvasElement} canvas
	 */
	function mapToCanvas(map, canvas) {
		var ctx;
		if (!canvas) {
			canvas = document.createElement("canvas");
		} else {
			ctx = canvas.getContext("2d");
			ctx.clearRect(0,0,canvas.width, canvas.height);
		}
		canvas.width = map.width;
		canvas.height = map.height;
		if (!ctx) {
			ctx = canvas.getContext("2d");
		}
		var requests = [];

		// Loop through map layers
		map.layerIds.forEach(function (layerId) {
			var layer = map.getLayer(layerId);
			var url;
			var exportParams;
			var image;
			var deferred;

			if (layer.url) {
				deferred = new Deferred();
				exportParams = {
					f: "image",
					size: [map.width, map.height].join(","),
					bbox: [map.extent.xmin, map.extent.ymin, map.extent.xmax, map.extent.ymax].join(","),
					bboxSR: map.extent.spatialReference.wkid,
					format: "png",
					transparent: true
				};
				exportParams = objToQuery(exportParams);
				url = [layer.url, "/export?", exportParams].join("");
				url = url.replace("//export", "/export");

				image = new Image(map.width, map.height);
				requests.push(deferred);
				image.addEventListener("load", function () {
					// ctx.drawImage(image, 0, 0);
					deferred.resolve(image);
				}, false);
				image.src = url;
			} else {
				console.log("No URL for layer: " + layerId);
			}
		});

		// Once all of the images have loaded, add them to the canvas.
		all(requests).then(function (images) {
			images.forEach(function (image) {
				ctx.drawImage(image, 0, 0);
{'fraction_non_alphanumeric': 0.16642156862745097, 'fraction_numerical': 0.00392156862745098, 'mean_word_length': 3.1347517730496453, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7283849', 'n_tokens_mistral': 1649, 'n_tokens_neox': 1374, 'n_words': 322}