function SpatialFilter() {
	this.accuracy = 1; /* only round coordinates */
	this.toAccuracy = Math.floor; /* efficiency hack */
	this.points = {};
}
SpatialFilter.prototype = {
	filter: function(bounds) {
		var west = this.toAccuracy(bounds.getSouthWest().lng());
		var east = this.toAccuracy(bounds.getNorthEast().lng()) + 1;
		var south = this.toAccuracy(bounds.getSouthWest().lat());
		var north = this.toAccuracy(bounds.getNorthEast().lat()) + 1;
		
		var filteredPoints = [];
		var x, y, i, p;
		
		for (y = north - 1; y >= south; y --) {
			for (x = west; x < east; x ++) {
				p = this.points[x + ',' + y];
				if (p == null) continue;
				for (i = 0; i < p.length; i ++) {
					if (bounds.contains(p[i].point)) {
						filteredPoints.push(p[i]);
					}
				}
			}
		}
		
		return filteredPoints;
	},
	
	/* private */
	/* efficiency hacked: replaced by Math.floor */
	toAccuracy: function(x) {
		return Math.floor(x * this.accuracy);
	},
	
	addPoint: function(p) {
		var key = this.toAccuracy(p.point.lng()) + ',' +
					this.toAccuracy(p.point.lat());
		if (this.points[key] == null) {
			this.points[key] = [p];
		} else {
			this.points[key].push(p);
		}
	},
	
	clear: function() {
		this.points = {};
	}
}
