Source: temp/jsdocinputdirs/cercalia.widget.routingreport.js

/**
 * Constructor del widget RoutingReport
 * @class
 * @constructor
 * @param {cercaliax.widget.RoutingReportOptions} options Opciones del RoutingReport 
 */
cercalia.widget.RoutingReport = function (options) {
	
	/**
	 * Nombre de la classe
	 * @private
	 * @type {string}
	 */
	this.CLASS_NAME_ = "cercalia.widget.RoutingReport";
	
	/* OPTIONS */
	
	/**
	 * Id del div contenedor.
	 * @private
	 * @type {string}
	 */
	this.divId_ = options.div ? options.div : null;
	
	/**
	 * Servei de routing. Si se define podremos añadir opciones para subetapas.
	 * @private
	 * @type {cercalia.service.Routing|cercalia.service.LogisticsRouting}
	 */
	this.routingService_ = options.routingService ? options.routingService : null;
	
	
	/* VARIABLES PRIVADAS */
	
	/**
	 * Mapa
	 * @private
	 * @type {cercalia.Map}
	 */
	this.map_ = options.map ? options.map : null;
	
	/**
	 * Elemento contenedor.
	 * @private
	 * @type {Object}
	 */
	this.element_ = null;
	
	/**
	 * Report de la ruta
	 * @private
	 * @type {Object}
	 */
	this.report_ = null;
	
	/**
	 * Puntos de paso
	 * @private
	 * @type {Object}
	 */
	this.steps_ = null;
	
	/**
	 * WKTs de los substages
	 * @private
	 * @type {Object}
	 */
	this.substages_ = null;
	
	/**
	 * WKT actualmente dibujado en el mapa.
	 * @private
	 * @type {cercalia.Feature}
	 */
	this.currentSubstage_ = null;
	
	/**
	 * POIS actualmente dibujados en el mapa.
	 * @private
	 * @type {cercalia.Feature}
	 */
	this.currentPois_ = null;
	
	
	/* SERVICIOS Y WIDGETS DE CERCALIA */
	
	/**
	 * Servicio de proximidad para obtener pois por wkt.
	 * @private
	 * @type {cercalia.service.Pois}
	 */
	this.proximity_ = null;
	

	// Inicializamos
	this.initialize_();
};

/**
 * Inicializa el elemento.
 * @private
 */
cercalia.widget.RoutingReport.prototype.initialize_ = function () {

	if( ! this.divId_ ) {
		cercalia.Exception(cercalia.i18n._('WIDGET_ERR_NO_DIV "%"', this.CLASS_NAME_));
	} else {
		
		this.element_ = cercalia.jQuery("#" + this.divId_).addClass("cercalia-widget cercalia-widget-routingreport");
		this.proximity_ = new cercalia.service.Pois({buffer: 100});
		
	}
};

/**
 * Crea el report a partir de los datos devueltos por cercalia.
 * @param {Object} route Ruta devuelta por cercalia. Añadir al objeto la información de los puntos de paso en el parametro "cercalia.info".
 */
cercalia.widget.RoutingReport.prototype.createReport = function (route) {
	// Guardamos report
	if(route.cercalia.route) {
		this.report_ = route.cercalia.route;
		
		// Limpiamos report anterior
		this.clean();
		
		// Guardamos steps
		this.steps_ = [];
		this.substages_ = [];

		for(var index = 0 ; index < route.cercalia.route.stages.stage.length; index++ ) {
			var pos = route.cercalia.route.stages.stage[index].orig_stop_id;

			if(pos == 'o') {
				if(route.cercalia.info && route.cercalia.info[0]) this.steps_[index] = route.cercalia.info[0];
				else if(route.cercalia.route.stoplist.stop[0].mo) this.steps_[index] = route.cercalia.route.stoplist.stop[0].mo;
				else if(route.cercalia.route.stoplist.stop[0].ge) this.steps_[index] = route.cercalia.route.stoplist.stop[0].ge;
			} else {
				if(route.cercalia.info && route.cercalia.info[pos]) this.steps_[index] = route.cercalia.info[pos];
				else if(route.cercalia.route.stoplist.stop[pos].mo) this.steps_[index] = route.cercalia.route.stoplist.stop[pos].mo;
				else if(route.cercalia.route.stoplist.stop[pos].ge) this.steps_[index] = route.cercalia.route.stoplist.stop[pos].ge;
			
				var co = this.steps_[index].coord;
				//console.log("pintem step: " + this.steps_[index].coord.x + "," + this.steps_[index].coord.y + " isDrag " +  route.cercalia.info.isDragPoint );
			}			
		}
		
		
		// Añadimos destino final
		var last = route.cercalia.route.stoplist.stop.length - 1;
		if(route.cercalia.info && route.cercalia.info[last]) this.steps_[last] = route.cercalia.info[last];
		else if(route.cercalia.route.stoplist.stop[last].mo) this.steps_[last] = route.cercalia.route.stoplist.stop[last].mo;
		else if(route.cercalia.route.stoplist.stop[last].ge) this.steps_[last] = route.cercalia.route.stoplist.stop[last].ge;
		
		// Creamos report!
		this.reportLateral_();
	}
};

/**
 * Limpia los datos del report.
 */
cercalia.widget.RoutingReport.prototype.clean = function () {
	this.deletePoisOnRoute_();
	this.element_.empty();
	if(this.currentSubstage_ !== null) {
		this.currentSubstage_.destroy();
		this.currentSubstage_ = null;
	}
};

/**
 * Crea el report a partir de los datos devueltos por cercalia.
 * @private
 */
cercalia.widget.RoutingReport.prototype.reportLateral_ = function () {
	
	// Zona de puntos de paso
	var steps = cercalia.jQuery("<div />").addClass("cercalia-widget-routingreport-steps").appendTo(this.element_);
	var self = this;
	var classPosition;
	var stepNum = 1; //numero de punt de pass
	var scaleUnits = this.map_.getScaleUnits();

	for(var index = 0 ; index < this.steps_.length; index++) {
		var infoStep = this.steps_[index];
		
		//pasem si no és un dragPoint
		if((infoStep.isDragPoint === undefined || ! infoStep.isDragPoint) && infoStep.label){
			
			var color;
			var posRoute;
			if(index == 0) {
				color = "green";
				posRoute = "A";
				classPosition = "step-origin";
			} else if(index == this.steps_.length - 1) {
				color = "red";
				posRoute = "B";
				classPosition = "step-destination";
			} else {
				color = "gray";
				posRoute = stepNum;
				classPosition = "step-" + stepNum;
				stepNum ++;
			}		
					
			var step = cercalia.jQuery("<div />")
			    .addClass("cercalia-widget-routingreport-step")
				.addClass(classPosition)
				.appendTo(steps);
			
			var label = null;
	
			if(infoStep.label){
				label = infoStep.label;
			} else {
				if(infoStep.name!=null){
					if(infoStep.city){
						label = infoStep.name.value + ", " + infoStep.city.value;
					} else {
						label = infoStep.name.value;
					}
				} else {
					label = "";				
				}
			}
	
			
			cercalia.jQuery("<img />").attr("src", cercaliaGlobals.img + '/label-' + color + '.png').addClass("cercalia-widget-routingreport-step-img").appendTo(step);
			cercalia.jQuery("<span />").html(posRoute).addClass("cercalia-widget-routingreport-step-img-letter").appendTo(step);	
			cercalia.jQuery("<span />").html(label).addClass("cercalia-widget-routingreport-step-name").appendTo(step);
	
			var zoom = cercalia.jQuery("<div />").addClass("cercalia-widget-routingreport-step-zoom").appendTo(step).click({coord: infoStep.coord}, function (e) {
				self.map_.setCenter(new cercalia.LonLat(e.data.coord.x, e.data.coord.y), 16, true);
			});
			cercalia.jQuery("<span />").addClass("ui-icon cercalia-icon cercalia-icon-zoom").appendTo(zoom);
			cercalia.jQuery("<a />").html(cercalia.i18n._("Zoom")).appendTo(zoom);
		}else{
//			console.log("no es pinta per que és drag");
		}
	}
	
	// Resumen
	var resume = cercalia.jQuery("<div />").addClass("cercalia-widget-routingreport-resume").appendTo(this.element_);
	cercalia.jQuery("<h4 />").html(cercalia.i18n._('Resume')).addClass("cercalia-widget-routingreport-resume-title").appendTo(resume);
	
	var tiempoTotal = cercalia.jQuery("<div />").addClass("cercalia-widget-routingreport-resume-totalTime").appendTo(resume);
	cercalia.jQuery("<span />").html(cercalia.i18n._('Total time:')).addClass("cercalia-widget-routingreport-resume-key").appendTo(tiempoTotal);
	cercalia.jQuery("<span />").html(this.report_.time).addClass("cercalia-widget-routingreport-resume-value").appendTo(tiempoTotal);
	
	if(this.report_.realtime){
		var tiempoReal = cercalia.jQuery("<div />").addClass("cercalia-widget-routingreport-resume-totalTime").appendTo(resume);
		cercalia.jQuery("<span />").html(cercalia.i18n._('Real time:')).css('color', '#E63624', 'important').addClass("cercalia-widget-routingreport-resume-key").appendTo(tiempoReal);
		cercalia.jQuery("<span />").html(this.report_.realtime).css('color', '#E63624', 'important').addClass("cercalia-widget-routingreport-resume-value").appendTo(tiempoReal);
	}

	
	var distValStr =  scaleUnits == 'metric' ? (parseFloat(this.report_.dist).toFixed(2)) + " km" : cercalia.Util.distanceMetricToImperial(parseFloat(this.report_.dist)*1000);

	var distanciaTotal = cercalia.jQuery("<div />").addClass("cercalia-widget-routingreport-resume-totalDistance").appendTo(resume);
	cercalia.jQuery("<span />").html(cercalia.i18n._('Total distance:')).addClass("cercalia-widget-routingreport-resume-key").appendTo(distanciaTotal);
	cercalia.jQuery("<span />").html(distValStr).addClass("cercalia-widget-routingreport-resume-value").appendTo(distanciaTotal);
	
	var precioTotal = cercalia.jQuery("<div />").addClass("cercalia-widget-routingreport-resume-totalPrice").appendTo(resume);
	cercalia.jQuery("<span />").html(cercalia.i18n._('Toll (Spain & Portugal):')).addClass("cercalia-widget-routingreport-resume-key").appendTo(precioTotal);
	cercalia.jQuery("<br />").appendTo(precioTotal);
	cercalia.jQuery("<span />").html(cercalia.i18n._('Automobile:')).addClass("cercalia-widget-routingreport-resume-subkey").appendTo(precioTotal);
	cercalia.jQuery("<span />").html(this.report_.coste_v1 + " &euro;").addClass("cercalia-widget-routingreport-resume-value").appendTo(precioTotal);
	cercalia.jQuery("<br />").appendTo(precioTotal);
	cercalia.jQuery("<span />").html(cercalia.i18n._('Light industrial:')).addClass("cercalia-widget-routingreport-resume-subkey").appendTo(precioTotal);
	cercalia.jQuery("<span />").html(this.report_.coste_v2 + " &euro;").addClass("cercalia-widget-routingreport-resume-value").appendTo(precioTotal);
	cercalia.jQuery("<br />").appendTo(precioTotal);
	cercalia.jQuery("<span />").html(cercalia.i18n._('Heavy industrial:')).addClass("cercalia-widget-routingreport-resume-subkey").appendTo(precioTotal);
	cercalia.jQuery("<span />").html(this.report_.coste_v3 + " &euro;").addClass("cercalia-widget-routingreport-resume-value").appendTo(precioTotal);
	
	// Direcciones
	var directions = cercalia.jQuery("<div />").addClass("cercalia-widget-routingreport-directions").appendTo(this.element_);
	
	var step = 1;
	//for(var index in this.report_.stages.stage) {
	for(var index = 0 ; index < this.report_.stages.stage.length; index++ ) {
		
		var stage = this.report_.stages.stage[index];
		var origen = this.steps_[parseInt(index)];
		var destino = this.steps_[parseInt(index) + 1];
		
		//Puede haber una subetapa con solo un punto, lo convertimos a array para tratarlos todos iguales
		if(! (stage.sub_stage instanceof Array) ) {
			stage.sub_stage = [stage.sub_stage];
		}
		
		for(var jndex = 0 ; jndex < stage.sub_stage.length; jndex++ ) {
			
			var substage = stage.sub_stage[jndex];

			var directions_step = cercalia.jQuery("<div />").addClass("cercalia-widget-routingreport-directions-step").appendTo(directions);
			
			// Número de paso
			var directions_stepNum = cercalia.jQuery("<div />").addClass("cercalia-widget-routingreport-directions-stepNum").appendTo(directions_step);
			cercalia.jQuery("<img />").attr("src", cercaliaGlobals.img + '/label-' + 'blue' + '.png').addClass("").appendTo(directions_stepNum);
			var numPos = cercalia.jQuery("<span />").html(step).appendTo(directions_stepNum);
			
			if(step < 10) numPos.css({"left": "11px", "top": "7px"});
			else if (step < 100) numPos.css({"left": "8px", "top": "7px", "font-size": "10px"});
			else numPos.css({"left": "8px", "top": "9px", "font-size": "8px"});
			
			// Inicio de dirección
			var directions_stepIcon = cercalia.jQuery("<div />").addClass("cercalia-widget-routingreport-directions-stepIcon").appendTo(directions_step);
			cercalia.jQuery("<img />").attr("src", cercaliaGlobals.img + '/signs/' + this.getManiobra_(substage.type, substage.angle)).addClass("").appendTo(directions_stepIcon);
			
			// Descripción
			var directions_stepDesc = cercalia.jQuery("<div />").addClass("cercalia-widget-routingreport-directions-stepDesc").appendTo(directions_step);
		

			if(jndex == 0){
				var substageValue = substage.desc.value.indexOf('%') != -1 ? '%' : cercalia.i18n._('Origin'); 
				cercalia.jQuery("<div />").addClass("cercalia-widget-routingreport-directions-stepDesc-text").appendTo(directions_stepDesc).html(origen.label?substage.desc.value.replace(substageValue, origen.label):substage.desc.value);
			} else if(jndex == stage.sub_stage.length - 1) {
				var substageValue = substage.desc.value.indexOf('%') != -1 ? '%' : cercalia.i18n._('Destination');
				cercalia.jQuery("<div />").addClass("cercalia-widget-routingreport-directions-stepDesc-text").appendTo(directions_stepDesc).html(destino.label?substage.desc.value.replace(substageValue, destino.label):substage.desc.value);
			} else {
				cercalia.jQuery("<div />").addClass("cercalia-widget-routingreport-directions-stepDesc-text").appendTo(directions_stepDesc).html(substage.desc.value);
			}

			if(substage.time_sum && substage.time_sum.value && substage.dist_sum && substage.dist_sum.value){
				var distance = scaleUnits == 'metric' ? parseFloat(substage.dist_sum.value).toFixed(2) : cercalia.Util.distanceMetricToImperial(parseFloat(substage.dist_sum.value)*1000);
				var timeAct = substage.time_sum.value;
				cercalia.jQuery("<div />").addClass("cercalia-widget-routingreport-directions-stepDesc-timedist").appendTo(directions_stepDesc).html("<b>" + timeAct + " | " + distance + "</b>");
			}else{
				//no time
			}
			

			this.stepMenu_(directions_stepDesc, step-1, substage);
			
			// Limpiamos floats
			cercalia.jQuery("<div />").addClass("cercalia-clean").appendTo(directions_step);
			step++;
		}
	}
};

/**
 * Crea el menu de opciones de u paso de la ruta.
 * @private
 * @param {Object} parent Elemento dom donde pondremos las opciones. 
 * @param {number} stageNum Núemro de paso.
 * @param {Object} stageInfo Información del paso.
 */
cercalia.widget.RoutingReport.prototype.stepMenu_ = function (parent, stageNum, stageInfo) {
	var self = this;
	var button = cercalia.jQuery("<ul />").appendTo(parent).addClass("cercalia-widget-routingreport-directions-stepDesc-options");
	
	var menuElement = cercalia.jQuery("<li />").html('<a href="#" class="ui-state-default"><span class="ui-icon cercalia-report cercalia-report-gear"></span></a>').appendTo(button);
	
	var menu = cercalia.jQuery("<ul />").addClass("ui-submenu").appendTo(menuElement);
	
	cercalia.jQuery("<li />").append(
			cercalia.jQuery("<a />")
				.attr("href","#")
				.addClass("ui-state-default")
				.html('<span class="ui-icon cercalia-report cercalia-report-zoom"></span>'  + cercalia.i18n._('Zoom to this point'))
				.click(function () { 
					self.getSubWKT_(stageNum, stageInfo); 
				})
		).appendTo(menu);
	cercalia.jQuery("<li />").append(
			cercalia.jQuery("<a />")
				.attr("href","#")
				.addClass("ui-state-default")
				.html('<span class="ui-icon cercalia-report cercalia-report-gas"></span>' + cercalia.i18n._('Nearby gas stations'))
				.click(function () {
					var clickFunction = function (wkt) {
						self.proximity_.setQueryPois(["C001"]);
						self.proximity_.setWkt(wkt);
						self.proximity_.doPoisRequest(function (result) { 
							if(result.cercalia.proximity.poilist.num > 0) {
								self.deletePoisOnRoute_();
								self.addPoisOnRoute_(result.cercalia.proximity.poilist.poi);
							} else { alert(cercalia.i18n._('ERR_NO_POIS_IN_SUBSTAGE')); }
						});
					};
					
					self.getSubWKT_(stageNum, stageInfo, clickFunction); 
				})
		).appendTo(menu);
	cercalia.jQuery("<li />").append(
			cercalia.jQuery("<a />")
				.attr("href","#")
				.addClass("ui-state-default")
				.html('<span class="ui-icon cercalia-report cercalia-report-cup"></span>' + cercalia.i18n._('Nearby service area'))
				.click(function () {
					var clickFunction = function (wkt) {
						self.proximity_.setQueryPois(["C003"]);
						self.proximity_.setWkt(wkt);
						self.proximity_.doPoisRequest(function (result) { 
							if(result.cercalia.proximity.poilist.num > 0) {
								self.deletePoisOnRoute_();
								self.addPoisOnRoute_(result.cercalia.proximity.poilist.poi);
							} else { alert(cercalia.i18n._('ERR_NO_POIS_IN_SUBSTAGE')); }
						});
					};
					
					self.getSubWKT_(stageNum, stageInfo, clickFunction); 
				})
		).appendTo(menu);
	cercalia.jQuery("<li />").append(
			cercalia.jQuery("<a />")
				.attr("href","#")
				.addClass("ui-state-default")
				.html('<span class="ui-icon cercalia-report cercalia-report-parking"></span>' + cercalia.i18n._('Nearby parking'))
				.click(function () {
					var clickFunction = function (wkt) {
						self.proximity_.setQueryPois(["C007"]);
						self.proximity_.setWkt(wkt);
						self.proximity_.doPoisRequest(function (result) { 
							if(result.cercalia.proximity.poilist.num > 0) {
								self.deletePoisOnRoute_();
								self.addPoisOnRoute_(result.cercalia.proximity.poilist.poi);
							} else { alert(cercalia.i18n._('ERR_NO_POIS_IN_SUBSTAGE')); }
						});
					};
					
					self.getSubWKT_(stageNum, stageInfo, clickFunction); 
				})
		).appendTo(menu);
	

	//cercalia.jQuery("#" + button.attr("id")).menu();
	//cercalia.jQuery("#menu").menu();
	button.menu({ position: { my: "left top", at: "right top", of: button } });
};

/**
 * Hace una petición a Cercalia para obtener el WKT del paso.
 * @private
 * @param {number} stageNum Número de paso.
 * @param {Object} stageInfo Información del paso.
 * @param {Function} clickFunction Función de callback que se llamará al responder el servidor.
 */
cercalia.widget.RoutingReport.prototype.getSubWKT_ = function (stageNum, stageInfo, clickFunction) {

	var self = this;
	var centerFunction = function (wkt) {
		//var subWKTs = self.substages_.cercalia.geometry.route;						
		if(self.currentSubstage_ !== null) {
			self.currentSubstage_.destroy();
			self.currentSubstage_ = null;
		}

		self.currentSubstage_ = new cercalia.Feature({
			wkt: wkt,
			fillColor: '#FF6666',
			strokeColor: '#FF6666',
			outlineColor: '#BF1818',
			zIndex: 102,
			strokeWidth: 7,
			outlineWidth: 9
		});
		self.map_.addFeature(self.currentSubstage_);
	};
	
	var bbox = new cercalia.Bounds();
	bbox.extend(new cercalia.LonLat(stageInfo.start.x, stageInfo.start.y, "EPSG:54004"));
	bbox.extend(new cercalia.LonLat(stageInfo.end.x, stageInfo.end.y, "EPSG:54004"));
	this.map_.fitBounds(bbox);
	
	if(typeof(this.substages_[stageNum]) === "undefined" || this.substages_[stageNum] === null) {
		this.routingService_.getSubstageWKT([stageInfo.id], function (wkts) { 
			self.substages_[stageNum] = wkts.cercalia.geometry.route &&  wkts.cercalia.geometry.route.length > 0  ? wkts.cercalia.geometry.route[0].wkt.value :  undefined;
				
			centerFunction(self.substages_[stageNum]);
			if(typeof(clickFunction) === "function") clickFunction(self.substages_[stageNum]);
		});
	} else {
		centerFunction(self.substages_[stageNum]);
		if(typeof(clickFunction) === "function") clickFunction(self.substages_[stageNum]);
	}
};


/**
 * Elimina los POIs de una sub etapa pintados en el mapa.
 * @private
 */
cercalia.widget.RoutingReport.prototype.deletePoisOnRoute_ = function () {

	if(this.currentPois_){
		for(var index = 0 ; index < this.currentPois_.length; index++) {
			this.currentPois_[index].destroy();
		}
	}
	this.currentPois_ = [];
};

/**
 * Añade al mapa los POIs de una subetapa.
 * @private
 * @param {Object} pois Listado de POIS a pintar.
 */
cercalia.widget.RoutingReport.prototype.addPoisOnRoute_ = function (pois) {
	
	for(var index = 0 ; index < pois.length; index++) {
		var poi = pois[index];
		
		// Pintamos marcador y popup de informacion
		var popup = new cercalia.Popup({
			visible: false,
			title: poi.name.value,
			content: this.popupContent_(poi)
		});
		
		var marker = new cercalia.Marker({
			position: new cercalia.LonLat(poi.coord.x, poi.coord.y),
			icon : new cercalia.Icon({ src: cercaliaGlobals.img + '/pois/' +  poi.category_id + '.png', size: [28, 38], anchor: [14, 38] }),
			popup: popup
		});
		
		this.map_.addMarker(marker);
		this.currentPois_.push(marker);
	}
};

/**
 * Genera el contenido HTML del Popup.
 * @private
 * @param {Object} poi Objeto POI de Cercalia.
 * @return {string}
 */
cercalia.widget.RoutingReport.prototype.popupContent_ = function (poi) {
	var content = cercalia.jQuery("<div />");
	var table = cercalia.jQuery("<table />").css("width", "300px").appendTo(content);
	var ge = poi.ge;
	
	if(poi.info) {
		var tr = cercalia.jQuery("<tr />").appendTo(table);
		cercalia.jQuery("<td />").css("font-weight", "bold").html(cercalia.i18n._("Information")).appendTo(tr);
		cercalia.jQuery("<td />").css("width", "225px").html(poi.info.value).appendTo(tr);
	}
	
	if(ge.city) {
		var tr = cercalia.jQuery("<tr />").appendTo(table);
		cercalia.jQuery("<td />").css("font-weight", "bold").html(cercalia.i18n._("City")).appendTo(tr);
		cercalia.jQuery("<td />").html(ge.city.value).appendTo(tr);
	}
	
	if(ge.postalcode) {
		var tr = cercalia.jQuery("<tr />").appendTo(table);
		cercalia.jQuery("<td />").css("font-weight", "bold").html(cercalia.i18n._("Postal code")).appendTo(tr);
		cercalia.jQuery("<td />").html(ge.postalcode.id).appendTo(tr);
	}
	
	if(ge.municipality) {
		var tr = cercalia.jQuery("<tr />").appendTo(table);
		cercalia.jQuery("<td />").css("font-weight", "bold").html(cercalia.i18n._("Municipality")).appendTo(tr);
		cercalia.jQuery("<td />").html(ge.municipality.value).appendTo(tr);
	}
	
	if(ge.subregion) {
		var tr = cercalia.jQuery("<tr />").appendTo(table);
		cercalia.jQuery("<td />").css("font-weight", "bold").html(cercalia.i18n._("Subregion")).appendTo(tr);
		cercalia.jQuery("<td />").html(ge.subregion.value).appendTo(tr);
	}
	
	if(ge.region) {
		tr = cercalia.jQuery("<tr />").appendTo(table);
		cercalia.jQuery("<td />").css("font-weight", "bold").html(cercalia.i18n._("Region")).appendTo(tr);
		cercalia.jQuery("<td />").html(ge.region.value).appendTo(tr);
	}
	
	if(ge.country) {
		tr = cercalia.jQuery("<tr />").appendTo(table);
		cercalia.jQuery("<td />").css("font-weight", "bold").html(cercalia.i18n._("Country")).appendTo(tr);
		cercalia.jQuery("<td />").html(ge.country.value).appendTo(tr);
	}
	
	if(poi.coord) {
		tr = cercalia.jQuery("<tr />").appendTo(table);
		cercalia.jQuery("<td />").css("font-weight", "bold").html(cercalia.i18n._("Coords")).appendTo(tr);
		cercalia.jQuery("<td />").html(poi.coord.x +", " + poi.coord.y).appendTo(tr);
	}
	
	return content.html();
};

/**
 * Devuelve la imagen de maniobra a pintar.
 * @private
 * @param {string} type Tipo de carretera. 
 * @param {number} angle Angulo del giro. 
 * @returns {String}
 */
cercalia.widget.RoutingReport.prototype.getManiobra_ = function (type, angle) {
	
	if(type == 'R') return 'rotonda.png';
	else if(type == 'G') return 'ferri.png';
	else if (type == 'H') return 'cremallera.png';
	else {
		if(angle > 314 && angle < 350) return 'mantener_derecha.png';
		else if(angle > 180 && angle < 315) return 'girar_derecha.png';
		else if(angle > 10 && angle < 45) return 'mantener_izquierda.png';
		else if(angle > 44 && angle < 180) return 'girar_izquierda.png';
		else return 'recto.png';
	}
};

/**
 * Modifica el mapa con el que interactua el widget.
 * @param {cercalia.Map} map Mapa con el que interactuará el Widget. 
 */
cercalia.widget.RoutingReport.prototype.setMap = function (map) {
	this.map_ = map;
};

/**
 * Modifica el servicio que calcula las rutas.
 * @param {cercalia.service.Routing|cercalia.service.LogisticsRouting} routingService Routing service. 
 */
cercalia.widget.RoutingReport.prototype.setRoutingService = function (routingService) {
	if(routingService instanceof cercalia.service.Routing || routingService instanceof cercalia.service.LogisticsRouting) {
    	this.routingService_ = routingService;
    } else {
    	alert('Error en el tipo parametro cercalia.widget.RoutingReport.prototype.setRoutingService');
    }
};


/**
* Devuelve el tipo del objeto.
* @return {string}
*/
cercalia.widget.RoutingReport.prototype.getClass = function (){
	return this.CLASS_NAME_;
};