<commit_before>var plots = new Hash(), nodes = new Hash(), ways = new Hash(), styles, lastPos = [0,0], scale_factor = 100000, bleed_level = 1, initial_bleed_level = 2, zoom_out_limit, zoom_in_limit

// var spherical_mercator = Class.create({
// 	lon_to_x: function(lon) { return (lon - projection.center_lon()) * -1 * scale_factor },
// 	x_to_lon: function(x) { return (x/(-1*scale_factor)) + projection.center_lon() },
// 	lat_to_y: function(lat) { return ((180/Math.PI * (2 * Math.atan(Math.exp(lat*Math.PI/180)) - Math.PI/2))) * scale_factor * 1.7 },
// 	y_to_lat: function(y) { return (180/Math.PI * Math.log(Math.tan(Math.PI/4+(y/(scale_factor*1.7))*(Math.PI/180)/2))) },
// })
// 
// // Uses global values... should set these in the initializer/constructor:
// var projection = Class.create({
// 	current_projection: spherical_mercator,
// 	set: function(new_projection) {
// 		this.current_projection = new_projection
// 	},
// 	lon_to_x: function(lon) { return this.current_projection.lon_to_x() },
// 	x_to_lon: function(x) { return this.current_projection.x_to_lon() },
// 	lat_to_y: function(lat) { return this.current_projection.lat_to_y() },
// 	y_to_lat: function(y) { return this.current_projection.y_to_lat() },
// 	//required by spherical mercator:
// 	center_lon: function() { return (lng2+lng1)/2 },
// })

global_x = lon_to_x((lng1+lng2)/2)
global_y = lat_to_y((lat1+lat2)/2)

function map_pointerX() {
	return global_x+(((width/2)-pointerX)/zoom_level)
}
function map_pointerY() {
	return global_y+(((height/2)-pointerY)/zoom_level)
}

function number_precision(num,prec) {
	return (num * (1/prec)).round()/(1/prec)
}

// sort ways by area:
function objects_sort(a,b) {
	if (a instanceof Way) {
		if (b instanceof Way) {
			if ( a.area < b.area )
		    return 1;
		  if ( a.area > b.area )
		    return -1;
		  return 0; // a == b
		} else {
			return -1 // a wins no matter what if b is not a Way
		}
	} else {
		return 1 // b wins no matter what if a is not a Way
	}
}

// Runs every frame in the draw() method. An attempt to isolate cartagen code from general GLOP code
function cartagen() {
	// gss body style:
	if (styles) {
		if (styles.body.fillStyle) fillStyle(styles.body.fillStyle)
		if (styles.body.strokeStyle) strokeStyle(styles.body.strokeStyle)
		if (styles.body.lineWidth || styles.body.lineWidth == 0) lineWidth(styles.body.lineWidth)
		rect(0,0,width,height)
		strokeRect(0,0,width,height)
	}
	
	translate(width/2,height/2)
		rotate(global_rotate)
		scale(zoom_level,zoom_level)<commit_msg>iphone auto-simplify of 3<commit_after>var plots = new Hash(), nodes = new Hash(), ways = new Hash(), styles, lastPos = [0,0], scale_factor = 100000, bleed_level = 1, initial_bleed_level = 2, zoom_out_limit, zoom_in_limit

// var spherical_mercator = Class.create({
// 	lon_to_x: function(lon) { return (lon - projection.center_lon()) * -1 * scale_factor },
// 	x_to_lon: function(x) { return (x/(-1*scale_factor)) + projection.center_lon() },
// 	lat_to_y: function(lat) { return ((180/Math.PI * (2 * Math.atan(Math.exp(lat*Math.PI/180)) - Math.PI/2))) * scale_factor * 1.7 },
// 	y_to_lat: function(y) { return (180/Math.PI * Math.log(Math.tan(Math.PI/4+(y/(scale_factor*1.7))*(Math.PI/180)/2))) },
// })
// 
// // Uses global values... should set these in the initializer/constructor:
// var projection = Class.create({
// 	current_projection: spherical_mercator,
// 	set: function(new_projection) {
// 		this.current_projection = new_projection
// 	},
// 	lon_to_x: function(lon) { return this.current_projection.lon_to_x() },
// 	x_to_lon: function(x) { return this.current_projection.x_to_lon() },
// 	lat_to_y: function(lat) { return this.current_projection.lat_to_y() },
// 	y_to_lat: function(y) { return this.current_projection.y_to_lat() },
// 	//required by spherical mercator:
// 	center_lon: function() { return (lng2+lng1)/2 },
// })

global_x = lon_to_x((lng1+lng2)/2)
global_y = lat_to_y((lat1+lat2)/2)

function map_pointerX() {
	return global_x+(((width/2)-pointerX)/zoom_level)
}
function map_pointerY() {
	return global_y+(((height/2)-pointerY)/zoom_level)
}

function number_precision(num,prec) {
	return (num * (1/prec)).round()/(1/prec)
}

// sort ways by area:
function objects_sort(a,b) {
	if (a instanceof Way) {
		if (b instanceof Way) {
			if ( a.area < b.area )
		    return 1;
		  if ( a.area > b.area )
		    return -1;
		  return 0; // a == b
		} else {
			return -1 // a wins no matter what if b is not a Way
		}
	} else {
		return 1 // b wins no matter what if a is not a Way
	}
}

// Runs every frame in the draw() method. An attempt to isolate cartagen code from general GLOP code
function cartagen() {
	if (Prototype.Browser.MobileSafari) {
		simplify = 3
	}
	// gss body style:
	if (styles) {
		if (styles.body.fillStyle) fillStyle(styles.body.fillStyle)
		if (styles.body.strokeStyle) strokeStyle(styles.body.strokeStyle)
		if (styles.body.lineWidth || styles.body.lineWidth == 0) lineWidth(styles.body.lineWidth)
		rect(0,0,width,height)
		strokeRect(0,0,width,height)
	}
	
	translate(width/2,height/2)
		rotate(global_rotate)
		scale(zoom_level,zoom_level)
{'fraction_non_alphanumeric': 0.16305831870489565, 'fraction_numerical': 0.022625316949483127, 'mean_word_length': 3.846880907372401, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4989063', 'n_tokens_mistral': 2032, 'n_tokens_neox': 1914, 'n_words': 416}