if (typeof(MyRoute) == "undefined")
{
	MyRoute = OpenLayers.Class({CLASS_NAME: "MyRoute"});
}
if (typeof(MyRoute.Format) == "undefined")
{
	MyRoute.Format = OpenLayers.Class({CLASS_NAME: "MyRoute.Format"});
}

/**
 * @requires OpenLayers/Format.js
 * @requires OpenLayers/Feature/Vector.js
 * @requires OpenLayers/Geometry/Point.js
 */

/**
 * Class: MyRoute.Format.JSONPOI
 * Read JSONPOI.
 */
MyRoute.Format.JSONPOI = OpenLayers.Class(OpenLayers.Format, {

    initialize: function(options) {
        OpenLayers.Format.prototype.initialize.apply(this, [options]);
    },

    read: function(json) {
		var MAX = 1000000;
	
		var data = eval(json);
		var features = new Array(Math.min(MAX, data.length));
		
		for(var i=0; i<features.length; i++)
		{
			var poi = data[i];
			var p = new OpenLayers.Geometry.Point(poi.x, poi.y);
			
			/*
			if (this.internalProjection && this.externalProjection)
			{
				p = OpenLayers.Projection.transform(p, this.internalProjection, this.externalProjection);
			}
			*/
			
			var attributes = {
				"id": poi.id,
				"name" : poi.n
			};
			features[i] = new OpenLayers.Feature.Vector(p, attributes);
		}

		return features;
    },

    CLASS_NAME: "MyRoute.Format.JSONPOI" 
});     

