<commit_before>﻿/** Copyright 2012 Washington State Department of Transportation.  Licensed under The MIT License (http://opensource.org/licenses/MIT). **/
/*global require, esri, dojo, jQuery, Proj4js, ogc*/
/*jslint nomen: true, regexp: true, white:true, plusplus:true */
/// <reference path="jsapi_vsdoc_v31.js" />
/// <reference path="ogc/ogcSimpleGeometry.vsdoc.js" />


(function ($) {
	"use strict";

	function createLocationId() {
		return new Date().getTime();
	}

	function groupGraphicsByAttribute(graphics, attribute) {
		/// <summary>Arranges graphics into groups based on an attribute.</summary>
		/// <param name="graphics" type="esri.Graphic[]">An array of graphics.  Although this function is designed for use with esri.Graphic objects, any object with an "attributes" object property will actually work.</param>
		/// <param name="attribute" type="String">The name of the attribute on which the graphics will be grouped.</param>
		/// <returns type="Object">Returns an object.  Each property of the object will be named after the attribute value.</returns>

		var i, l, graphic, output = {}, attrVal;

		for (i = 0, l = graphics.length; i < l; i++) {
			graphic = graphics[i];
			attrVal = String(graphic.attributes[attribute]);
			if (!output.hasOwnProperty(attrVal)) {
				output[attrVal] = [];
			}
			output[attrVal].push(graphic);
		}

		return output;
	}

	function splitRouteName(routeName) {
		/// <summary>Splits a route name into its four component street names.</summary>
		/// <returns type="Object">An object with the following properties: main, start, and end.</returns>
		var match, streetNames, _routeNameRegex = /^([^\-&]+?)\s*&\s*([^\-&]+?)\s*-\s*([^\-&]+?)\s*&\s*([^\-&]+)$/i; // This will be used to split the segment names.

		function findMainStreetName(streetNames) {
			/// <summary>Compares the list of street names and determines which is the main street.  This will be the street name that is included in the array twice.</summary>
			/// <param name="streetNames" type="String[]">An array containing five strings.</param>
			/// <returns type="Object" />

			var i, j, main, output = null;

			for (i = 1; i <= 2; i += 1) {
				for (j = 3; j <= 4; j += 1) {
					if (streetNames[i] === streetNames[j]) {
						main = streetNames[i];
						break;
					}
				}
				if (main) {
					break;
				}
			}

			if (main) {
				output = {
					main: main,
					start: i === 1 ? streetNames[2] : streetNames[1],
					end: j === 3 ? streetNames[4] : streetNames[3]
				};
			}

			return output;
		}

		match = _routeNameRegex.exec(routeName);

		if (match) {
			streetNames = findMainStreetName(match);
			if (!streetNames) {
				streetNames = match;
			}
		} else {
			streetNames = null;
		}

		return streetNames;
	}

	function addGeometryToGraphic(graphic) {
		/// <summary>Adds geometry to a graphic if it does not already have one.</summary>
		var geometry, projector;

		function projectGeometry(geometry) {
			if (geometry.spatialReference.wkid === 2927) {
				geometry = projector.project(geometry);
			}
			if (graphic.setGeometry !== undefined) {
				graphic.setGeometry(geometry);
			} else {
				graphic.geometry = geometry;
			}
			return geometry;
		}

		projector = new Proj4js.EsriProjector(new Proj4js.Proj("EPSG:2927"), new Proj4js.Proj("EPSG:3857"));

		if (!graphic.geometry) {  // If graphic does not have geometry...

			if (graphic.attributes.ogcSimpleGeometry) {

				// Ensure that ogcSimpleGeometry is an ogc.SimpleGeometry object.<commit_msg>Updated documentation.<commit_after>﻿/** Copyright 2012 Washington State Department of Transportation.  Licensed under The MIT License (http://opensource.org/licenses/MIT). **/
/*global require, esri, dojo, jQuery, Proj4js, ogc*/
/*jslint nomen: true, regexp: true, white:true, plusplus:true */
/// <reference path="jsapi_vsdoc_v31.js" />
/// <reference path="ogc/ogcSimpleGeometry.vsdoc.js" />


(function ($) {
	"use strict";

	function createLocationId() {
		return new Date().getTime();
	}

	function groupGraphicsByAttribute(graphics, attribute) {
		/// <summary>Arranges graphics into groups based on an attribute.</summary>
		/// <param name="graphics" type="esri.Graphic[]">An array of graphics.  Although this function is designed for use with esri.Graphic objects, any object with an "attributes" object property will actually work.</param>
		/// <param name="attribute" type="String">The name of the attribute on which the graphics will be grouped.</param>
		/// <returns type="Object">Returns an object.  Each property of the object will be named after the attribute value.</returns>

		var i, l, graphic, output = {}, attrVal;

		for (i = 0, l = graphics.length; i < l; i++) {
			graphic = graphics[i];
			attrVal = String(graphic.attributes[attribute]);
			if (!output.hasOwnProperty(attrVal)) {
				output[attrVal] = [];
			}
			output[attrVal].push(graphic);
		}

		return output;
	}

	function splitRouteName(routeName) {
		/// <summary>Splits a route name into its four component street names.</summary>
		/// <returns type="Object">An object with the following properties: main, start, and end.</returns>
		var match, streetNames, _routeNameRegex = /^([^\-&]+?)\s*&\s*([^\-&]+?)\s*-\s*([^\-&]+?)\s*&\s*([^\-&]+)$/i; // This will be used to split the segment names.

		function findMainStreetName(streetNames) {
			/// <summary>Compares the list of street names and determines which is the main street.  This will be the street name that is included in the array twice.</summary>
			/// <param name="streetNames" type="String[]">An array containing five strings.</param>
			/// <returns type="Object" />

			var i, j, main, output = null;

			for (i = 1; i <= 2; i += 1) {
				for (j = 3; j <= 4; j += 1) {
					if (streetNames[i] === streetNames[j]) {
						main = streetNames[i];
						break;
					}
				}
				if (main) {
					break;
				}
			}

			if (main) {
				output = {
					main: main,
					start: i === 1 ? streetNames[2] : streetNames[1],
					end: j === 3 ? streetNames[4] : streetNames[3]
				};
			}

			return output;
		}

		match = _routeNameRegex.exec(routeName);

		if (match) {
			streetNames = findMainStreetName(match);
			if (!streetNames) {
				streetNames = match;
			}
		} else {
			streetNames = null;
		}

		return streetNames;
	}

	function addGeometryToGraphic(graphic) {
		/// <summary>Adds geometry to a graphic if it does not already have one.</summary>
		/// <returns type="esri.Graphic">Returns the same graphic that was input to the function.</returns>
		var geometry, projector;

		function projectGeometry(geometry) {
			if (geometry.spatialReference.wkid === 2927) {
				geometry = projector.project(geometry);
			}
			if (graphic.setGeometry !== undefined) {
				graphic.setGeometry(geometry);
			} else {
				graphic.geometry = geometry;
			}
			return geometry;
		}

		projector = new Proj4js.EsriProjector(new Proj4js.Proj("EPSG:2927"), new Proj4js.Proj("EPSG:3857"));

		if (!graphic.geometry) {  // If graphic does not have geometry...

			if (graphic.attributes.ogcSimpleGeometry) {

				// Ensure that ogcSimpleGeometry is an ogc.SimpleGeometry object.
{'fraction_non_alphanumeric': 0.14885549782333943, 'fraction_numerical': 0.009830080044937508, 'mean_word_length': 3.41537507749535, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 47, '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': '335806', 'n_tokens_mistral': 2612, 'n_tokens_neox': 2204, 'n_words': 655}