
lbDate().init;
/*                                            INICIO INSTANCIA DE STORE VUEX                                            */


const store = new Vuex.Store({
  	state: {
		factor: 2,
		tipo_elemento_seleccionado: '',
		id_generico: 0,
		portavariables: [],
		layout_visible: 'layout_login',
		modal_visible: '',
		modo_seleccion: 'todo',
		hayconexion: true,
		control_cambios: false,
		centro: {latitud: -34.906563, longitud: -56.186266, zoom: 17},
		centro_gps: {latitud: -34.906563, longitud: -56.186266, zoom: 17},
		centro_mapa: {latitud: -34.906563, longitud: -56.186266, zoom: 17},
		centro_marca_ayuda: {x: 575000, y: 6145000},
		marcas_ayuda_en_mapa: [],
		toast_abierto: false,
		alerta: false,
		alerta_mensaje: [],
		datos_login: { usuario: '' , password: '', email: '', permisos: '', fecha: '', celular: '', empresa: '',mensaje: '', nivel_acceso: 0, revisar:0, elemento: 'Todos', municipio: 'Todos'},
		usuarios: [],
		conexiones_en_mapa: [],
		camaras1_en_mapa:[],
		colectores_en_mapa: [],
		camaras_en_mapa: [],
		calles_en_mapa: [],
		padrones_en_mapa: [],
		tramos_en_mapa:[],
		psingulares_en_mapa: [],
		captaciones_en_mapa: [],
		conex_capta_en_mapa: [],
    	tramo_seleccionado: {geometria:[],id_tramo:0,lon1:0,lat1:0,lon2:0,lat2:0,tiposec:0,tipotra:0,id_psig_aa:0,id_psig_ab:0,dim1:0,dim2:0,dim3:0,dim4:0,pendiente:0,contrato:0,proyecto:0,material:'',zarriba:0,zabajo:0,z_tapa_aa:0,z_tapa_ab:0,prof_aa:0,prof_ab:0,longitud:0,estado:'',salto:0, etapa:'',accion:'',historial:'',documentos:'',fotos:'',audios:'',videos:'',alta_fuente:'',alta_fecha:'',calle:'',via:0,hidraulica:'',economica:'',activo:1,comentarios:'',ccz:'',cuenca:'',plano:'',provisorio:0,dato1:'',dato2:'',dato3:0,dato4:2000,habilitado:'',publicado:'',fueraservicio:'',foto_blob:'', fotos_con_fecha: [], audios_con_fecha: []},
		psingular_seleccionado: {id_psingular:0,lon1:0,lat1:0,x:0,y:0,tipo:0,tramos:'',z_tapa:0,inspeccion:0,profundidad:0,salto:0,z_ab:0,alta_fuente:'',alta_fecha:'',calle:'',via:0,contrato:0,estado:'',etapa:'',proyecto:0,accion:'',historial:'',fotos:'',audios:'',documentos:'',comentarios:'',hidraulica:'',economica:'',activo:1,ccz:'',cuenca:'',plano:'',provisorio:0,dato1:'',dato2:'',dato3:0,dato4:0,habilitado:'',publicado:'',fueraservicio:'',foto_blob:'', fotos_con_fecha: [], audios_con_fecha: []},
		captacion_seleccionada: {id_captacion:0,lon1:0,lat1:0,id_tramo:0,id_conex_capt:0,tipo:0,clase:0,dim:0,cant_bocas:0,alta_fuente:'',alta_fecha:'',rotacion:0,z_col:0,z_tapa:0,calle:'',via:0,contrato:0,etapa:'',estado:'',proyecto:0,accion:'',historial:'',fotos:'',audios:'',documentos:'',comentarios:'',hidraulica:'',economica:'',activo:1,ccz:'',cuenca:'',plano:'',provisorio:0,dato1:'',dato2:'',dato3:0,dato4:0,habilitado:'',publicado:'',fueraservicio:'',foto_blob:'', fotos_con_fecha: [], audios_con_fecha: []},
		conex_capta_seleccionada: {id_conex_capta:0,lon1:0,lat1:0,lon2:0,lat2:0,id_captacion:0,id_conex_capt:0,id_tramo:0,longitud:0,rotacion:0,tipo:'',historial:'',proyecto:0,contrato:0,profundidad:0,comentarios:'',hidraulica:'',economica:'',accion:'',etapa:'',estado:'',alta_fuente:'',alta_fecha:'',material:'',seccion:'',activo:1,plano:'',provisorio:0,dato1:'',dato2:'',dato3:0,dato4:0,habilitado:'',publicado:'',fueraservicio:''},
		nueva_conexion:'',
		nuevo_tramo:'',
		nuevo_psingular:'',
		nueva_captacion:'',
		conexion_seleccionada: {id:0,lon1:0,lat1:0,lon2:0,lat2:0,padron:0,colector:0,profundidad:'',tipo:'',seccion:'',alta_fuent:'',alta_descr:'',alta_fecha:'',servicios:'',tgms:'',oses:'',sur:'',historial:'',etapa:'',ccz:'',accion:'',fotos:'',audios:'',activo:'',puertas:'',z_col:0,via:0,id_tramite:'',id_con_ant:0,calle:'',tramite:'',empresa:'',descripcion:'',foto_blob:'', fotos_con_fecha: [], audios_con_fecha: []},
		padron_seleccionado: 0,
		colector_seleccionado: 0,
		calle_seleccionada: '',
		via_seleccionada: 0,
		audio_temporal: {blob: [],archivo:''},
		dato_temporal: '',
		datos_filtro1: {zona:0,id:0,padron:0,calle1:'',calle2:'',colector:0},
		calles: [''],
		calles_cruzan: [''],
		datos_consulta_distribuida: {certificado:false,certificado_valor:'Con certificado',tramite:false,tramite_valor:'Nueva Inicio',sur:false,sur_valor:'Sin reclamos',servicios:false,servicios_valor:'Sin tarifa',fuente:false,fuente_valor:'Otros',etapa:false,etapa_valor:'Sin asignar',estado:false,estado_valor:'Sin determinar',accion:false,accion_valor:'Sin asignar',ccz:false,ccz_valor:'CCZ01',calle:false,calle_valor:'YI',fecha:false,fecha1_valor:new Date(),fecha2_valor:new Date()},
		datos_consulta_distribuida_colectores: {dim1:false,dim1_valor:'0.20',dim2:false,dim2_valor:'0.20',proyecto:false,avalidar:false,habilitado:false,publicado:false,fueraservicio:false,etapa:false,etapa_valor:'En construccion',estado:false,estado_valor:'Sin determinar',accion:false,accion_valor:'Sin asignar',tipo_seccion:false,tipo_seccion_valor:'ART',tipo_tramo:false,tipo_tramo_valor:'PL',material:false,material_valor:'PVC',ccz:false,ccz_valor:'CCZ01',calle:false,calle_valor:'AV 18 DE JULIO',fecha:false,fecha1_valor:new Date(),fecha2_valor:new Date()},
		datos_consulta_distribuida_psingulares: {profundidad:false,profundidad_valor:'2.00',salto:false,salto_valor:'0.20',avalidar:false,habilitado:false,publicado:false,fueraservicio:false,etapa:false,etapa_valor:'En construccion',estado:false,estado_valor:'Sin determinar',accion:false,accion_valor:'Sin asignar',tipo:false,tipo_valor:'CI',ccz:false,ccz_valor:'CCZ01',calle:false,calle_valor:'AV 18 DE JULIO',fecha:false,fecha1_valor:new Date(),fecha2_valor:new Date()},
		datos_consulta_distribuida_captaciones: {dimension:false,dimension_valor:'2.00',bocas:false,bocas_valor:'0.20',avalidar:false,habilitado:false,publicado:false,fueraservicio:false,etapa:false,etapa_valor:'En construccion',estado:false,estado_valor:'Sin determinar',accion:false,accion_valor:'Sin asignar',tipo:false,tipo_valor:'BT',ccz:false,ccz_valor:'CCZ01',calle:false,calle_valor:'AV 18 DE JULIO',fecha:false,fecha1_valor:new Date(),fecha2_valor:new Date()},
		modo_colectores: 0,
		modo_consulta_distribuida: 0,
		descripcion_consulta_distribuida: '',
		color_anterior_tramos: 'orange',
		color_anterior_psingulares: 'white',
		color_anterior_captaciones: 'cyan',
		color_anterior_conex_capt: 'blue',
		color_anterior_padron: 'grey',
		color_anterior_tramos_varios: [],
		indicadores: [],
		mantenimiento: [],
		movimientos: [],
		ultimos_movimientos: [],
		punto_en_tramo: '',
		adm_tipos: [],
		adm_clases: [],
		adm_proyectos: [],
		adm_contratos: [],
		adm_planos: [],
		intervenciones_captacion: [],
		int_captacion_seleccionada: {id_captacion:0,id_intervencion:0,fecha:'',usuario:'',estado_ini:'', estado_fin:'',tipo:'Inspeccion',accion:'Sin intervencion adicional',observaciones:'',fotos:'',audios:'',activo:1,foto_blob:'', fotos_con_fecha: [], audios_con_fecha: []},
		proyecto_activo: {geom:'',nombre:'Sin asignar',descripcion:'Sin asignar',id_proyecto:0, clasificacion:'Sin asignar', tipo:'Sin asignar', construido:0,anoproy:0,id:0,activo:1},
		contrato_activo: {nombre:'',descripcion:''},
		tramos_movidos_por_camara: [],
		conexcapta_movida_por_captacion: 0,
		geotif: false,
		datos_por_defecto: {importacion_etapa:'Construido sin Recepcion',tramo_tipotra: 50,tramo_tiposec: 47,tramo_dim1: 0.2,tramo_dim2: 0,tramo_dim3: 0,tramo_dim4: 0,contrato: 0,proyecto: 0,tramo_material: 'PVC', etapa: 'A Construir', psingular_tipo: 5, psingular_profundidad: 2, captacion_tipo: 1,captacion_clase: 1, conex_capta_tipo: 60, conex_capta_material: 'PVC', conex_capta_profundidad: 0, conex_capta_seccion: 0},
		estadisticas_tipos_datos: [],
		estadisticas_tipos_columnas: [],
		elemento_tipo_seleccionado: {tipo: 'Tipo de Tramo', id: 0, codigo: '', descripcion: '', diagrama: '', id_tipo: '0',color: '#FFFF99'}, 
		datos_tipo_eliminar: {tabla_tipo: '', id_tipo: 0, elemento: '', nombre_campo: ''},
		elementos_eliminados: [],
		planos_eliminados: [],
		proyectos_eliminados: [],
		proyectos_cercanos: [],
		monitoreo: [],
		modal_anterior: '',
		plano: ''
	},
/*INICIO DE GETTERS 
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111*/	
	getters: {

	},

/*INICIO DE MUTATIONS 
222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222*/
  	mutations:{

	},
/*INICIO DE ACTIIONS 
3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333*/
	actions: {
		},

})

/*                                              FIN DE DEFINICION DE STORE VUEX                                            */




/*                                              INICIO INSTANCIA DE VUE                                                    */
var app = new Vue({
  el: '#app',
  data: {
		  pagina_visible: 'dl_login',
		  visitCount: 33,
		  hideCompletedTodos: false,
		  todos: [],
		  error: null,
		  time: '13:20',
		  location:null,
		  gettingLocation: false,
		  errorStr:null
		},	
  store:store,


  	/*
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
INICIO DE METODOS METODOS METODOS METODOS METODOS METODOS METODOS METODOS METODOS METODOS METODOS METODOS METODOS METODOS METODOS METODOS METODOS METODOS
	*/  
  methods: {
			marca_ayuda: function(lat,lon,mapa){
				var latlngini = [lat,lon];
				var marca = L.circle(latlngini, {
					color: 'red',
					fillColor: '#59D52A',
					fillOpacity: 1,
					radius:0.5
				}).addTo(mapa);	
			},
			chequeo_conexion: function(){
								var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
								var type = '';
								connection !== undefined ? type = connection.effectiveType : type = '';
								store.state.hayconexion = false;
								if(navigator.onLine) {
									store.state.hayconexion = true;
									if (type == '2g' || type == 'slow-2g')
									{
										store.state.hayconexion = false;
									}
									}
								},
			obtengo_ubicacion: async function(){
								if("geolocation" in navigator) {
									navigator.geolocation.getCurrentPosition(pos => {
										if ((pos.coords.latitude > -34.94 && pos.coords.latitude < -34.69) && (pos.coords.longitude > -56.44 && pos.coords.longitude < -55.99))
										{
										store.state.centro_gps.latitud = pos.coords.latitude;
										store.state.centro_gps.longitud = pos.coords.longitude;
										}
										else
										{
											store.state.centro_gps.latitud = -34.906563;
											store.state.centro_gps.longitud = -56.186266;	
										}
										store.state.centro_mapa.latitud = store.state.centro_gps.latitud;
										store.state.centro_mapa.longitud = store.state.centro_gps.longitud;	
																})
								}
								},
			permiso_por_zona_y_tipo_elemento: function(tipo, ccz){
			    console.log(tipo);
			    console.log(ccz);
				let municipio = 'Todos';
				if (store.state.datos_login.municipio != 'Todos')
				{
						switch (ccz)
						{
							case 'CCZ01': 
							municipio =  'B';
							break;
							case 'CCZ02': 
							municipio =  'B';
							break;
							case 'CCZ03': 
							municipio =  'C';
							break;
							case 'CCZ04': 
							municipio =  'CH';
							break;
							case 'CCZ05': 
							municipio =  'CH';
							break;
							case 'CCZ06': 
							municipio =  'E';
							break;
							case 'CCZ07': 
							municipio =  'E';
							break;
							case 'CCZ08': 
							municipio =  'E';
							break;
							case 'CCZ09': 
							municipio =  'F';
							break;
							case 'CCZ10': 
							municipio =  'D';
							break;
							case 'CCZ11': 
							municipio =  'D';
							break;
							case 'CCZ12': 
							municipio =  'G';
							break;
							case 'CCZ13': 
							municipio =  'G';
							break;
							case 'CCZ14': 
							municipio =  'A';
							break;
							case 'CCZ15': 
							municipio =  'C';
							break;
							case 'CCZ16': 
							municipio =  'C';
							break;
							case 'CCZ17': 
							municipio =  'A';
							break;
							case 'CCZ18': 
							municipio =  'A';
							break;
						}
				}
				if (store.state.datos_login.municipio == municipio && (store.state.datos_login.elemento == 'Todos' || store.state.datos_login.elemento == tipo))
				{
					return true;
				}
				else
				{
					return false;
				}
			},
			permiso_por_punto_y_tipo_elemento: function(tipo, lat, lng)
			{
				return new Promise((resolve, reject) => {
					const x = lng, y = lat;
					var municipio = 'Todos';
					const geojsonURL = 'archivos/geojson/municipios.geojson';
					fetch(geojsonURL).then(response =>  {
							if (!response.ok) {
							throw new Error('No se pudo cargar el archivo GeoJSON');
							}
							return response.json();
						})
						.then(geojsonData => {
							const geojson = geojsonData;
                            for (const feature of geojson.features) {
								const polygon = feature.geometry.coordinates[0];
								const point = [lng, lat]; // lng y lat son las coordenadas del punto
								const [px, py] = point; // Descomponemos las coordenadas del punto
								let angleSum = 0; // Inicializamos la suma de ángulos
								for (let i = 0; i < polygon.length; i++) {
									const [x1, y1] = polygon[i];
									const [x2, y2] = polygon[(i + 1) % polygon.length]; // Vertice siguiente
									const angle1 = Math.atan2(y1 - py, x1 - px);
									const angle2 = Math.atan2(y2 - py, x2 - px);
									let angle = angle2 - angle1;
									if (angle < -Math.PI) angle += 2 * Math.PI;
									if (angle > Math.PI) angle -= 2 * Math.PI;
									angleSum += angle; // Sumamos el ángulo al total
								}
								if (Math.abs(angleSum) > Math.PI) {
									municipio = feature.properties.MUNICIPIO;
									break; // Si encontramos un municipio donde el punto está dentro, salimos del bucle
								}
							}
							  if ((store.state.datos_login.municipio == 'Todos' || store.state.datos_login.municipio == municipio) && (store.state.datos_login.elemento == 'Todos' || store.state.datos_login.elemento == tipo))
							  {
								  resolve(true);
							  }
							  else
							  {
								  resolve(false);
							  }
						})
						.catch(error => {
							console.error('Error:', error);
						});
					});					
		},
		texto_normalizo: function(cadena){
				cadena = cadena.replace(/Ã/g, "Á");
				cadena = cadena.replace(/Ã¡/g, "á");
				cadena = cadena.replace(/Ã‰/g, "É");
				cadena = cadena.replace(/Ã©/g, "é");
				cadena = cadena.replace(/Ã/g, "Í");
				cadena = cadena.replace(/Ã­/g,  "í");
				cadena = cadena.replace(/Ã“/g, "Ó");
				cadena = cadena.replace(/Ã³/g, "ó");
				cadena = cadena.replace(/Ãš/g, "Ú");
				cadena = cadena.replace(/Ãº/g, "ú");
				cadena = cadena.replace(/Ã/g, "Ñ");
				cadena = cadena.replace(/Ã±/g, "ñ");
									return cadena;
								},
			obtengo_fecha: function(fecha){
				fecha.setHours(fecha.getHours()-3);
									var fecha2=  fecha.toISOString();
									var parte1 = fecha2.split("T")[0];
									var parte2 = fecha2.split("T")[1].substr(0,8);
									parte2 = parte2.replace(/-/g,":");
									return parte1 + " " + parte2;
								},
			obtengo_kml_circulo: function(latitud,longitud,radio,altura){
				let lat = parseFloat(latitud);
				let lon = parseFloat(longitud);
				let kml = (lon + radio).toString() + ',' + lat +  "," + altura + " "; 	

				kml = kml + (lon + (radio * 0.866)).toString() + ',' + (lat - (radio * 0.5)).toString()  + "," + altura + " ";
				kml = kml + (lon + (radio * 0.5)).toString() + ',' + (lat - (radio * 0.866)).toString()  + "," + altura + " ";
				kml = kml + lon + ',' + (lat - radio).toString()  + "," + altura + " ";
				kml = kml + (lon - (radio * 0.5)).toString() + ',' + (lat - (radio * 0.866)).toString()  + "," + altura + " ";
				kml = kml + (lon - (radio * 0.866)).toString() + ',' + (lat - (radio * 0.5)).toString()  + "," + altura + " ";
				kml = kml + (lon - radio).toString() + ',' + lat + "," + altura + " ";
				kml = kml + (lon - (radio * 0.866)).toString() + ',' + (lat + (radio * 0.5)).toString()  + "," + altura + " ";
				kml = kml + (lon - (radio * 0.5)) + ',' + (lat + (radio * 0.866)).toString()  + "," + altura + " ";
				kml = kml + lon + ',' + (lat + radio).toString()  + "," + altura + " ";
				kml = kml + (lon + (radio * 0.5)).toString() + ',' + (lat + (radio * 0.866)).toString()  + "," + altura + " ";
				kml = kml + (lon + (radio * 0.866)).toString() + ',' + (lat + (radio * 0.5)).toString()  + "," + altura + " ";				
				kml = kml + (lon + radio).toString() + ',' + lat + "," + altura + " "; 
														return kml;
													},
			limpio_mapa: function(mapa,alcance){

							if(typeof store.state.tramos_en_mapa !== 'undefined')
							{
								for(var i=0;i<store.state.tramos_en_mapa.length; i++)
								{
								store.state.tramos_en_mapa[i].remove(mapa);
								}
							}
							store.state.tramos_en_mapa = [];
							if(typeof store.state.padrones_en_mapa !== 'undefined'){
								for(var i=0;i<store.state.padrones_en_mapa.length; i++)
								{
								store.state.padrones_en_mapa[i].remove(mapa);
								}
							}
							store.state.padrones_en_mapa = [];
							if(typeof store.state.psingulares_en_mapa !== 'undefined'){
								for(var i=0;i<store.state.psingulares_en_mapa.length; i++)
								{
								store.state.psingulares_en_mapa[i].remove(mapa);
								}
							}
							store.state.psingulares_en_mapa = [];

							if(typeof store.state.captaciones_en_mapa !== 'undefined'){
								for(var i=0;i<store.state.captaciones_en_mapa.length; i++)
								{
								store.state.captaciones_en_mapa[i].remove(mapa);
								}
							}
							store.state.captaciones_en_mapa = [];

							
							if(typeof store.state.conex_capta_en_mapa !== 'undefined'){
								for(var i=0;i<store.state.conex_capta_en_mapa.length; i++)
								{
								store.state.conex_capta_en_mapa[i].remove(mapa);
								}
							}
							store.state.conex_capta_en_mapa = [];

							if(typeof store.state.calles_en_mapa !== 'undefined'){
								for(var i=0;i<store.state.calles_en_mapa.length; i++)
								{
								store.state.calles_en_mapa[i].remove(mapa);
								}
							}
							store.state.calles_en_mapa = [];

								if(typeof store.state.conexiones_en_mapa !== 'undefined'){
									for(var i=0;i<store.state.conexiones_en_mapa.length; i++)
									{
									store.state.conexiones_en_mapa[i].remove(mapa);
									}
								}
								store.state.conexiones_en_mapa = [];
								
			},
			limpio_mantenimiento: function(mapa){
				if (typeof legend !== 'undefined') {
					if (legend instanceof L.Control) { map.removeControl(legend) };
				  }
				if(typeof store.state.mantenimiento !== 'undefined')
				{
					for(var i=0;i<store.state.mantenimiento.length; i++)
					{
					store.state.mantenimiento[i].remove(mapa);
					}
				}
				store.state.mantenimiento = [];
			},		
			limpio_monitoreo: function(mapa){
				if(typeof store.state.monitoreo !== 'undefined')
				{
					for(var i=0;i<store.state.monitoreo.length; i++)
					{
					store.state.monitoreo[i].remove(mapa);
					}
				}
				store.state.monitoreo = [];
			},							
			cargo_saneamiento: function(mapa,datos){
										store.state.modo_consulta_distribuida = 0;
										app.limpio_mapa(mapa,0);
			//EJES DE CALLE---------------------COMIENZA FUNCION QUE CARGA LOS EJES DE CALLE AL MAPA_______________________________________________________________________________________									
										for(var i=0;i< datos[5].length;i++){
											var geom = datos[5][i]["geom"];
											var solocoord = geom.substring(11);
											solocoord = solocoord.slice(0,-1);
											var latlngs1 = solocoord.split(",");
											var latlngs = [];
											for (var j=0; j<latlngs1.length; j++)
											{
												var elemento = (latlngs1[j].split(" "));
												latlngs.push(elemento.reverse());
											}
											var calle = L.polyline(latlngs, {
														color: 'black',
														opacity: 0.5,
														weight: 4,
														customData:{
															nom_calle:datos[5][i]["nom_calle"],
															cod_nombre:datos[5][i]["cod_nombre"]
														}
												}).bindTooltip("<div style='background:black;color:white; padding:1px 3px 1px 3px'><b>" + datos[5][i]["cod_nombre"] + "-" + datos[5][i]["nom_calle"] + "</b></div>", 
														{
																	direction: 'left',
																	permanent: false,
																	sticky: true,
																	offset: [10, 0],
																	opacity: 0.75,
																	className: 'leaflet-tooltip-own' 
														}).addTo(mapa).on('click',function(e){
															if (store.state.modo_seleccion == 'calle_captacion' || store.state.modo_seleccion == 'calle_psingular' || store.state.modo_seleccion == 'calle_tramo' || store.state.modo_seleccion == 'todo')
															{
																for(var j=0; j<store.state.calles_en_mapa.length;j++)
																{
																	store.state.calles_en_mapa[j].setStyle({color:'black', weight:4});
																}
																this.setStyle({color:'cyan', weight: 8});
																store.state.calle_seleccionada = this.options.customData.nom_calle;
																store.state.via_seleccionada = this.options.customData.cod_nombre;
																store.state.alerta_mensaje = [];
																store.state.alerta_mensaje.push("Calle: " + this.options.customData.nom_calle);
																store.state.alerta_mensaje.push("Via: " +  this.options.customData.cod_nombre);
																store.state.alerta = true;
															}
														});
											store.state.calles_en_mapa.push(calle);
										};
			//EJES DE CALLE*******************FIN FUNCION QUE CARGA LOS EJES DE CALLE AL MAPA_______________________________________________________________________________________	
			//PADRONES---------------------COMIENZA FUNCION QUE CARGA LOS PADRONES AL MAPA_______________________________________________________________________________________
											for(var i=0;i< datos[7].length;i++){
												var geom = datos[7][i]["geom"];
												var solocoord = geom.substring(9);
												solocoord = solocoord.slice(0,-2);
												var latlngs1 = solocoord.split(",");
												var latlngs = [];
												for (var j=0; j<latlngs1.length; j++)
												{
													var elemento = (latlngs1[j].split(" "));
													latlngs.push(elemento.reverse());
												}
												var color_padron = 'grey';
												if (datos[7][i]["saneado"] != 1){color_padron = 'yellow';};
												var padron = L.polygon(latlngs, {
															color: color_padron,
															opacity: 0.5,
															weight: 3,
															customData:{
																padron:datos[7][i]["padron"],
																saneado:datos[7][i]["saneado"]
															}
													}).bindTooltip("<div style='background:black;color:white; padding:1px 3px 1px 3px'><b>" + datos[7][i]["padron"] + "</b></div>", 
															{
																		direction: 'left',
																		permanent: false,
																		sticky: true,
																		offset: [10, 0],
																		opacity: 0.75,
																		className: 'leaflet-tooltip-own' 
															}).addTo(mapa);
															store.state.padrones_en_mapa.push(padron);
											};
   			//PARONES*******************FIN FUNCION QUE CARGA LOS PADRONES AL MAPA_______________________________________________________________________________

			//CONEXIONES---------------------COMIENZA FUNCION QUE CARGA SANEAMIENTO AL MAPA_______________________________________________________________________________________
										for(var i=0;i< datos[0].length;i++){
											var lat1 = datos[0][i]["lat1"];
											var lon1 = datos[0][i]["lon1"];
											var lat2 = datos[0][i]["lat2"];
											var lon2 = datos[0][i]["lon2"];
											var latlngs = [[lat1,lon1],[lat2,lon2]];
											var latlngini = [lat1,lon1];
											var conexion = L.polyline(latlngs, {
														color: '#EEBDA2',
														opacity: 0.8,
														weight: 5,
														customData:{
															id:datos[0][i]["id"],
															lon1:datos[0][i]["lon1"],
															lat1:datos[0][i]["lat1"],
															lon2:datos[0][i]["lon2"],
															lat2:datos[0][i]["lat2"],
															padron:datos[0][i]["padron"],
															colector:datos[0][i]["colector"],
															profundidad:datos[0][i]["profundidad"],
															tipo:datos[0][i]["tipo"],
															seccion:datos[0][i]["seccion"],	
															ccz:datos[0][i]["ccz"],															
															servicios:datos[0][i]["servicios"],
															tgms:datos[0][i]["tgms"],
															oses:datos[0][i]["oses"],
															puertas:datos[0][i]["puertas"],
															z_col:datos[0][i]["z_col"],
															descripcion:datos[0][i]["descripcion"]
																	}
												}).bindTooltip("<div style='background:green; padding:6px 11px 11px 6px'><b>CONEXION:<br>Id: " + datos[0][i]["id"] + "</b><br><b>Zcol:" + datos[0][i]["z_col"].substring(0,5) + "</br></div>", 
												{
															direction: 'right',
															permanent: false,
															sticky: true,
															offset: [10, 0],
															opacity: 0.75,
															className: 'leaflet-tooltip-own' 
												}).addTo(mapa)
												store.state.conexiones_en_mapa.push(conexion);
											}
												
			//CONEXIONES _____FIN CONEXIONES---------------------COMIENZA FUNCION QUE CARGA SANEAMIENTO AL MAPA_______________________________________________________________________________________
			//COLECTORES---------------------COMIENZA FUNCION QUE CARGA SANEAMIENTO AL MAPA_______________________________________________________________________________________

										for(var i=0;i< datos[1].length;i++){
													var geom = datos[1][i]["geom"];
													var latlng_ini = [];
													var latlng_fin = [];
													var solocoord = geom.substring(11);
													solocoord = solocoord.slice(0,-1);
													var latlngs1 = solocoord.split(",");
													var latlngs = [];
													for (var j=0; j<latlngs1.length; j++)
													{
														var elemento = (latlngs1[j].split(" "));
														elemento = elemento.reverse();
														latlngs.push(elemento);
														if (j == 0){latlng_ini = elemento};
														if (j == latlngs1.length - 1){latlng_fin =  elemento};
													}
													if (datos[1][i]["etapa"] == 'A Construir')
													{
														var dasharrayvalue = '10,10';
														var dashoffsetvalue = '0';
														var opacityvalue = 0.9;
													}
													else
													{
														var dasharrayvalue = null;
														var dashoffsetvalue = null;
														var opacityvalue = 1;
													}
													var tipodetramo = "-";
													for (let j = 0; j < store.state.adm_tipos.length; j++) {
														if (store.state.adm_tipos[j]["id"] == datos[1][i]["tipotra"] ) {
														  tipodetramo = store.state.adm_tipos[j]["codigo"];
														}
													}
													var tipodeseccion = "-";
													for (let j = 0; j < store.state.adm_clases.length; j++) {
														if (store.state.adm_clases[j]["id"] == datos[1][i]["tiposec"] ) {
														  tipodeseccion = store.state.adm_clases[j]["codigo"];
														}
													}
													var tipdim3dim4 = '';
													if (datos[1][i]["dim3"] > 0 || datos[1][i]["dim4"] > 0)
													{
													 tipdim3dim4 = "</b><br><b>Dim3: " +  datos[1][i]["dim3"] + "</b><br><b>Dim4: " +  datos[1][i]["dim4"];
													}
													var colector = L.polyline(latlngs, {
																color: '#D5872A',
																opacity: opacityvalue,
																weight: 6,
																dashArray: dasharrayvalue,
																dashOffset: dashoffsetvalue,
																customData:{
																	id_tramo:datos[1][i]["id_tramo"],
																	lon1:datos[1][i]["lon1"],
																	lat1:datos[1][i]["lat1"],
																	lon2:datos[1][i]["lon2"],
																	lat2:datos[1][i]["lat2"],
																	tiposec:datos[1][i]["tiposec"],
																	tipotra:datos[1][i]["tipotra"],
																	id_psig_aa:datos[1][i]["id_psig_aa"],
																	id_psig_ab:datos[1][i]["id_psig_ab"],
																	dim1:datos[1][i]["dim1"],
																	dim2:datos[1][i]["dim2"],
																	dim3:datos[1][i]["dim3"],
																	dim4:datos[1][i]["dim4"],
																	pendiente:datos[1][i]["pendiente"],
																	salto:datos[1][i]["salto"],
																	contrato:datos[1][i]["contrato"],
																	proyecto:datos[1][i]["proyecto"],
																	material:datos[1][i]["material"],
																	zarriba:datos[1][i]["zarriba"],
																	zabajo:datos[1][i]["zabajo"],
																	z_tapa_aa:datos[1][i]["z_tapa_aa"],
																	z_tapa_ab:datos[1][i]["z_tapa_ab"],
																	prof_aa:datos[1][i]["prof_aa"],
																	prof_ab:datos[1][i]["prof_ab"],
																	longitud:datos[1][i]["longitud"],
																	etapa:datos[1][i]["etapa"],
																	estado:datos[1][i]["estado"],
																	accion:datos[1][i]["accion"],
																	ccz:datos[1][i]["ccz"],
																	cuenca:datos[1][i]["cuenca"],
																	historial:datos[1][i]["historial"],
																	documentos:datos[1][i]["documentos"],
																	fotos:datos[1][i]["fotos"],
																	audios:datos[1][i]["audios"],
																	videos:datos[1][i]["videos"],
																	alta_fuente:datos[1][i]["alta_fuente"],
																	alta_fecha:datos[1][i]["alta_fecha"],
																	calle:datos[1][i]["calle"],
																	via:datos[1][i]["via"],
																	hidraulica:datos[1][i]["hidraulica"],
																	economica:datos[1][i]["economica"],
																	comentarios:datos[1][i]["comentarios"],
																	plano:datos[1][i]["plano"],
																	provisorio:datos[1][i]["provisorio"],
																	dato1:datos[1][i]["dato1"],
																	dato2:datos[1][i]["dato2"],
																	dato3:datos[1][i]["dato3"],
																	dato4:datos[1][i]["dato4"],
																	habilitado:datos[1][i]["habilitado"],
																	publicado:datos[1][i]["publicado"],
																	fueraservicio:datos[1][i]["fueraservicio"]
																}
														}).bindTooltip("<div style='background:white;padding:6px 11px 11px 6px'><b>Id:" + datos[1][i]["id_tramo"] + "</b><br><b>Sec: " +  tipodeseccion + "</b><br><b>Ancho: " + datos[1][i]["dim1"] + "</b><br><b>Alto: " + datos[1][i]["dim2"] + "</b><br><b>ZAa: " + datos[1][i]["zarriba"].substring(0,5) + "</b><br><b>ZAb: " + datos[1][i]["zabajo"].substring(0,5)  + "</b><br><b>Long: " + datos[1][i]["longitud"].substring(0,5) +  "</b><br><b>Pend: " + datos[1][i]["pendiente"].substring(0,5)  + tipdim3dim4 +  "</b></div>", 
																{
																			direction: 'right',
																			permanent: false,
																			sticky: true,
																			offset: [10, 0],
																			opacity: 0.85,
																			className: 'leaflet-tooltip-own' 
														}).addTo(mapa).on('click',function(e){
															var auto = app.permiso_por_zona_y_tipo_elemento('Red', this.options.customData.ccz);
															if (!auto){alert('El usuario no tiene permisos para acceder a este elemento')};
															if (auto && (store.state.modo_seleccion == 'todo' || store.state.modo_seleccion == 'colector'  || store.state.modo_seleccion == 'tramo_conex_captacion'))
																{
																	for(var j=0; j<store.state.tramos_en_mapa.length;j++)
																	{
																		store.state.tramos_en_mapa[j].setStyle({weight:8});
																	}
																	this.setStyle({weight:12});
																store.state.tramo_seleccionado.geometria = JSON.parse(JSON.stringify(this.getLatLngs()));
																store.state.tramo_seleccionado.id_tramo = this.options.customData.id_tramo;
																store.state.tramo_seleccionado.lon1 = this.options.customData.lon1;
																store.state.tramo_seleccionado.lat1 = this.options.customData.lat1;
																store.state.tramo_seleccionado.lon2 = this.options.customData.lon2;
																store.state.tramo_seleccionado.lat2 = this.options.customData.lat2;
																store.state.tramo_seleccionado.tiposec = this.options.customData.tiposec;
																store.state.tramo_seleccionado.tipotra = this.options.customData.tipotra;
																store.state.tramo_seleccionado.id_psig_aa = this.options.customData.id_psig_aa;
																store.state.tramo_seleccionado.id_psig_ab = this.options.customData.id_psig_ab;
																store.state.tramo_seleccionado.dim1 = this.options.customData.dim1;
																store.state.tramo_seleccionado.dim2 = this.options.customData.dim2;
																store.state.tramo_seleccionado.dim3 = this.options.customData.dim3;
																store.state.tramo_seleccionado.dim4 = this.options.customData.dim4;
																store.state.tramo_seleccionado.pendiente = Number(this.options.customData.pendiente).toFixed(2);
																store.state.tramo_seleccionado.salto = Number(this.options.customData.salto).toFixed(2);
																store.state.tramo_seleccionado.contrato = this.options.customData.contrato;
																store.state.tramo_seleccionado.proyecto = this.options.customData.proyecto;
																store.state.tramo_seleccionado.material = this.options.customData.material;
																store.state.tramo_seleccionado.zarriba = Number(this.options.customData.zarriba).toFixed(2);
																store.state.tramo_seleccionado.zabajo = Number(this.options.customData.zabajo).toFixed(2);
																store.state.tramo_seleccionado.z_tapa_aa = Number(this.options.customData.z_tapa_aa).toFixed(2);
																store.state.tramo_seleccionado.z_tapa_ab = Number(this.options.customData.z_tapa_ab).toFixed(2);
																store.state.tramo_seleccionado.prof_aa = Number(this.options.customData.prof_aa).toFixed(2);
																store.state.tramo_seleccionado.prof_ab = Number(this.options.customData.prof_ab).toFixed(2);
																store.state.tramo_seleccionado.longitud = Number(this.options.customData.longitud).toFixed(2);
																store.state.tramo_seleccionado.etapa = this.options.customData.etapa;
																store.state.tramo_seleccionado.estado = this.options.customData.estado;
																store.state.tramo_seleccionado.accion = this.options.customData.accion;
																store.state.tramo_seleccionado.ccz = this.options.customData.ccz;
																store.state.tramo_seleccionado.cuenca = this.options.customData.cuenca;
																store.state.tramo_seleccionado.historial = this.options.customData.historial;
																store.state.tramo_seleccionado.documentos = this.options.customData.documentos;
																store.state.tramo_seleccionado.fotos = this.options.customData.fotos;
																store.state.tramo_seleccionado.audios = this.options.customData.audios;
																store.state.tramo_seleccionado.videos = this.options.customData.videos;
																store.state.tramo_seleccionado.alta_fuente = this.options.customData.alta_fuente;
																store.state.tramo_seleccionado.alta_fecha = this.options.customData.alta_fecha;
																store.state.tramo_seleccionado.calle = this.options.customData.calle;
																store.state.tramo_seleccionado.via = this.options.customData.via;
																store.state.tramo_seleccionado.hidraulica = this.options.customData.hidraulica;
																store.state.tramo_seleccionado.economica = this.options.customData.economica;
																store.state.tramo_seleccionado.comentarios = this.options.customData.comentarios;
																store.state.tramo_seleccionado.plano = this.options.customData.plano;
																store.state.tramo_seleccionado.provisorio = this.options.customData.provisorio;
																store.state.tramo_seleccionado.dato1 = this.options.customData.dato1;
																store.state.tramo_seleccionado.dato2 = this.options.customData.dato2;
																store.state.tramo_seleccionado.dato3 = this.options.customData.dato3;
																store.state.tramo_seleccionado.dato4 = this.options.customData.dato4;
																store.state.tramo_seleccionado.habilitado = this.options.customData.habilitado;
																store.state.tramo_seleccionado.publicado = this.options.customData.publicado;
																store.state.tramo_seleccionado.fueraservicio = this.options.customData.fueraservicio;
																store.state.punto_en_tramo = e;
																}
																if (auto && (store.state.modo_seleccion == 'todo'))
																{
																	store.state.modal_visible = 'Evento_Seleccion_Tramo';
																	store.state.tipo_elemento_seleccionado = 'TRAMO';
																}
																if (auto && (store.state.modo_seleccion == 'tramo_captacion' || store.state.modo_seleccion == 'tramo_conex_captacion'))
																{
																store.state.alerta_mensaje = [];
																store.state.alerta_mensaje.push("Tramo seleccionado: " + this.options.customData.id_tramo);
																store.state.alerta = true;
																}
													}).on('mouseover',function(e){
														this.setText('►', {repeat: true, attributes: {fill: 'brown',"font-weight": "bold","font-size": "18"}});
														store.state.color_anterior_tramos = this.options.color;
														this.setStyle({color :'red'});
														for (var s = 0;s < store.state.conex_capta_en_mapa.length; s++)
														{ 
															if (store.state.conex_capta_en_mapa[s].options.customData.id_tramo == this.options.customData.id_tramo)
																{
																	store.state.color_anterior_conex_capt = store.state.conex_capta_en_mapa[s].options.color;
																	store.state.conex_capta_en_mapa[s].setStyle({color :'red'});
																}
														}
														for (var s = 0;s < store.state.psingulares_en_mapa.length; s++)
														{ 
															let id_psingular = store.state.psingulares_en_mapa[s].options.customData.id_psingular;
															if (this.options.customData.id_psig_aa == id_psingular || this.options.customData.id_psig_ab == id_psingular)
															{
																	store.state.color_anterior_psingulares = store.state.psingulares_en_mapa[s].options.color;
																	store.state.psingulares_en_mapa[s].setStyle({color :'red'});
															}	
														}
														var lista_padrones = [];
														for (var s = 0;s < store.state.conexiones_en_mapa.length; s++)
														{ 
															if (store.state.conexiones_en_mapa[s].options.customData.colector == this.options.customData.id_tramo)
																{
																	store.state.conexiones_en_mapa[s].setStyle({color :'red'});
																	if (!lista_padrones.includes(store.state.conexiones_en_mapa[s].options.customData.padron))
																	{lista_padrones.push(store.state.conexiones_en_mapa[s].options.customData.padron)}
																}
														}	
														for (var s = 0;s < store.state.captaciones_en_mapa.length; s++)
														{ 
															if (store.state.captaciones_en_mapa[s].options.customData.id_tramo == this.options.customData.id_tramo)
																{
																	store.state.color_anterior_captaciones = store.state.captaciones_en_mapa[s].options.color;
																	store.state.captaciones_en_mapa[s].setStyle({color :'red'});
																}
														}
														for (var s = 0;s < store.state.padrones_en_mapa.length; s++)
														{ 
															if (lista_padrones.includes(store.state.padrones_en_mapa[s].options.customData.padron))
																{
																	store.state.color_anterior_padron = store.state.padrones_en_mapa[s].options.color;
																	store.state.padrones_en_mapa[s].setStyle({color :'red'});
																}
														}														
													}).on('mouseout',function(e){
														this.setText(null);														
														this.setStyle({color :store.state.color_anterior_tramos});
															for (var s = 0;s < store.state.conexiones_en_mapa.length; s++)
															{ 
																if (store.state.conexiones_en_mapa[s].options.customData.colector == this.options.customData.id_tramo)
																	{
																		store.state.conexiones_en_mapa[s].setStyle({color :'#EEBDA2'});
																	}
															}
															for (var s = 0;s < store.state.captaciones_en_mapa.length; s++)
															{ 
																if (store.state.captaciones_en_mapa[s].options.customData.id_tramo == this.options.customData.id_tramo)
																	{
																		store.state.captaciones_en_mapa[s].setStyle({color : store.state.color_anterior_captaciones});
																	}
															}
															for (var s = 0;s < store.state.psingulares_en_mapa.length; s++)
															{ 
																let id_psingular = store.state.psingulares_en_mapa[s].options.customData.id_psingular;
																if (this.options.customData.id_psig_aa == id_psingular || this.options.customData.id_psig_ab == id_psingular)
																{
																	store.state.psingulares_en_mapa[s].setStyle({color :store.state.color_anterior_psingulares});
																}
															}	
															for (var s = 0;s < store.state.conex_capta_en_mapa.length; s++)
															{ 
																if (store.state.conex_capta_en_mapa[s].options.customData.id_tramo == this.options.customData.id_tramo)
																	{
																		store.state.conex_capta_en_mapa[s].setStyle({color : store.state.color_anterior_conex_capt});
																	}
															}	
															for (var s = 0;s < store.state.padrones_en_mapa.length; s++)
															{ 
																		let color_padron = 'grey';
																		if (store.state.padrones_en_mapa[s].options.customData.saneado != 1){color_padron = 'yellow';};
																		store.state.padrones_en_mapa[s].setStyle({color : color_padron});
															}	
													});
											store.state.tramos_en_mapa.push(colector);
											};
			//COLECTORES FIN COLECTORES---------------------COMIENZA FUNCION QUE CARGA SANEAMIENTO AL MAPA_______________________________________________________________________________________
			//PUNTOS_SINGULARES CAMARAS---------------------COMIENZA FUNCION QUE CARGA SANEAMIENTO AL MAPA_______________________________________________________________________________________
													for(var i=0;i< datos[2].length;i++){
																	var tipodeps = "-";
																	for (let j = 0; j < store.state.adm_tipos.length; j++) {
																		if (store.state.adm_tipos[j]["id"] == datos[2][i]["tipo"] ) {
																		tipodeps = store.state.adm_tipos[j]["codigo"];
																		}
																	}

																	var lat1 = datos[2][i]["lat1"];
																	var lon1 = datos[2][i]["lon1"];
																	var latlngs = [lat1,lon1];
																	if (datos[2][i]["etapa"] == 'A Construir')
																	{
																		var opacityvalue = 0.7;
																		var colorfondo = 'grey';
																	}
																	else
																	{
																		var opacityvalue = 1;
																		var colorfondo = 'white';
																	}
																	var camara = L.circle(latlngs, {
																		color: 'black',
																		fillColor: colorfondo,
																		fillOpacity: 1,
																		radius:0.6,
																		opacity: opacityvalue,
																		customData:{
																			id_psingular:datos[2][i]["id_psingular"],
																			lon1:datos[2][i]["lon1"],
																			lat1:datos[2][i]["lat1"],
																			tipo:datos[2][i]["tipo"],
																			z_tapa:datos[2][i]["z_tapa"],
																			inspeccion:datos[2][i]["inspeccion"],
																			profundidad:datos[2][i]["profundidad"],
																			salto:datos[2][i]["salto"],
																			z_ab:datos[2][i]["z_ab"],
																			contrato:datos[2][i]["contrato"],
																			proyecto:datos[2][i]["proyecto"],
																			etapa:datos[2][i]["etapa"],
																			estado:datos[2][i]["estado"],
																			accion:datos[2][i]["accion"],
																			ccz:datos[2][i]["ccz"],
																			cuenca:datos[2][i]["cuenca"],
																			historial:datos[2][i]["historial"],
																			documentos:datos[2][i]["documentos"],
																			fotos:datos[2][i]["fotos"],
																			audios:datos[2][i]["audios"],
																			alta_fuente:datos[2][i]["alta_fuente"],
																			alta_fecha:datos[2][i]["alta_fecha"],
																			calle:datos[2][i]["calle"],
																			via:datos[2][i]["via"],
																			hidraulica:datos[2][i]["hidraulica"],
																			economica:datos[2][i]["economica"],
																			comentarios:datos[2][i]["comentarios"],
																			plano:datos[2][i]["plano"],
																			provisorio:datos[2][i]["provisorio"],
																			dato1:datos[2][i]["dato1"],
																			dato2:datos[2][i]["dato2"],
																			dato3:datos[2][i]["dato3"],
																			dato4:datos[2][i]["dato4"],
																			habilitado:datos[2][i]["habilitado"],
																			publicado:datos[2][i]["publicado"],
																			fueraservicio:datos[2][i]["fueraservicio"]
																		}
																	}).bindTooltip("<div style='background:white;padding:6px 11px 11px 6px'><b>PSINGULAR:</b><br><b>Id:" + datos[2][i]["id_psingular"] + "</b><br><b>Tipo: " +  tipodeps   + "</b><br><b>Z Tapa: " + datos[2][i]["z_tapa"].substring(0,5) + "m</b><br><b>Z ab: " + datos[2][i]["z_ab"] + "</b><br><b>Prof: " + datos[2][i]["profundidad"] + "</b></div>", 
																	{
																				direction: 'right',
																				permanent: false,
																				sticky: true,
																				offset: [10, 0],
																				opacity: 0.85,
																				className: 'leaflet-tooltip-own' 
																	}).addTo(mapa).on('click',function(e){
																		var auto = app.permiso_por_zona_y_tipo_elemento('Red', this.options.customData.ccz);
																		if (!auto){alert('El usuario no tiene permisos para acceder a este elemento')};
																	if (auto && (store.state.modo_seleccion == 'todo' || store.state.modo_seleccion == 'psingularaa' || store.state.modo_seleccion == 'psingularab'))
																			{
																				store.state.psingular_seleccionado.id_psingular = this.options.customData.id_psingular;
																				store.state.psingular_seleccionado.lon1 = this.options.customData.lon1;
																				store.state.psingular_seleccionado.lat1 = this.options.customData.lat1;
																				store.state.psingular_seleccionado.tipo = this.options.customData.tipo;
																				store.state.psingular_seleccionado.z_tapa = Number(this.options.customData.z_tapa).toFixed(2);
																				store.state.psingular_seleccionado.inspeccion = this.options.customData.inspeccion;
																				store.state.psingular_seleccionado.profundidad = Number(this.options.customData.profundidad).toFixed(2);
																				store.state.psingular_seleccionado.salto = Number(this.options.customData.salto).toFixed(2);
																				store.state.psingular_seleccionado.z_ab = Number(this.options.customData.z_ab).toFixed(2);
																				store.state.psingular_seleccionado.contrato = this.options.customData.contrato;
																				store.state.psingular_seleccionado.proyecto = this.options.customData.proyecto;
																				store.state.psingular_seleccionado.etapa = this.options.customData.etapa;
																				store.state.psingular_seleccionado.estado = this.options.customData.estado;
																				store.state.psingular_seleccionado.accion = this.options.customData.accion;
																				store.state.psingular_seleccionado.ccz = this.options.customData.ccz;
																				store.state.psingular_seleccionado.cuenca = this.options.customData.cuenca;
																				store.state.psingular_seleccionado.historial = this.options.customData.historial;
																				store.state.psingular_seleccionado.documentos = this.options.customData.documentos;
																				store.state.psingular_seleccionado.fotos = this.options.customData.fotos;
																				store.state.psingular_seleccionado.audios = this.options.customData.audios;
																				store.state.psingular_seleccionado.alta_fuente = this.options.customData.alta_fuente;
																				store.state.psingular_seleccionado.alta_fecha = this.options.customData.alta_fecha;
																				store.state.psingular_seleccionado.calle = this.options.customData.calle;
																				store.state.psingular_seleccionado.via = this.options.customData.via;
																				store.state.psingular_seleccionado.hidraulica = this.options.customData.hidraulica;
																				store.state.psingular_seleccionado.economica = this.options.customData.economica;
																				store.state.psingular_seleccionado.comentarios = this.options.customData.comentarios;
																				store.state.psingular_seleccionado.plano = this.options.customData.plano;
																				store.state.psingular_seleccionado.provisorio = this.options.customData.provisorio;
																				store.state.psingular_seleccionado.dato1 = this.options.customData.dato1;
																				store.state.psingular_seleccionado.dato2 = this.options.customData.dato2;
																				store.state.psingular_seleccionado.dato3 = this.options.customData.dato3;
																				store.state.psingular_seleccionado.dato4 = this.options.customData.dato4;
																				store.state.psingular_seleccionado.habilitado = this.options.customData.habilitado;
																				store.state.psingular_seleccionado.publicado = this.options.customData.publicado;
																				store.state.psingular_seleccionado.fueraservicio = this.options.customData.fueraservicio;
																				if (store.state.modo_seleccion == 'psingularaa' || store.state.modo_seleccion == 'psingularab')
																				{
																				this.setStyle({ weight: 8});
																				store.state.alerta_mensaje = [];
																				store.state.alerta_mensaje.push("Punto singular seleccionado: " + this.options.customData.id_psingular);
																				store.state.alerta = true;
																				}	
																				if (store.state.modo_seleccion == 'todo')
																				{
																					store.state.tipo_elemento_seleccionado = 'PSINGULAR';
																					store.state.modal_visible = 'Evento_Seleccion_Psingular';
																				}
																			}
																		}).on('mouseover',function(e){
																			store.state.color_anterior_psingulares = this.options.color;
																			this.setStyle({color :'yellow'});
																			store.state.color_anterior_tramos_varios = [];
																			let id_psingular = this.options.customData.id_psingular;
																			for (var s = 0;s < store.state.tramos_en_mapa.length; s++)
																			{ 	
																				if (id_psingular == store.state.tramos_en_mapa[s].options.customData.id_psig_aa || id_psingular == store.state.tramos_en_mapa[s].options.customData.id_psig_ab)
																				{
																					store.state.color_anterior_tramos_varios.push([store.state.tramos_en_mapa[s].options.customData.id_tramo,store.state.tramos_en_mapa[s].options.color])
																					store.state.tramos_en_mapa[s].setStyle({color :'yellow'});
																				}	
																			}
																		}).on('mouseout',function(e){
																			for(i=0;i<store.state.color_anterior_tramos_varios.length;i++)
																			{
																				let id_tramo = store.state.color_anterior_tramos_varios[i][0];
																					for (var s = 0;s < store.state.tramos_en_mapa.length; s++)
																					{ 	
																						if (store.state.tramos_en_mapa[s].options.customData.id_tramo == id_tramo)
																						{
																							store.state.tramos_en_mapa[s].setStyle({color :store.state.color_anterior_tramos_varios[i][1]});
																						}	
																					}
																			}
																			this.setStyle({color :store.state.color_anterior_psingulares});
																		});		
																		store.state.psingulares_en_mapa.push(camara);			
															};
			//PUNTOS SINGULARES____FIN CAMARAS---------------------COMIENZA FUNCION QUE CARGA SANEAMIENTO AL MAPA_______________________________________________________________________________________
			//CAPTACIONES___BOCAS DE TORMENTA---------------------COMIENZA FUNCION QUE CARGA SANEAMIENTO AL MAPA_______________________________________________________________________________________
									for(var i=0;i< datos[3].length;i++){
										var lat1 = datos[3][i]["lat1"];
										var lon1 = datos[3][i]["lon1"];
										var latlngs = [lat1,lon1];
										if (datos[3][i]["etapa"] == 'A Construir')
										{
											var opacityvalue = 0.7;
											var colorfondo = 'grey';
										}
										else
										{
											var opacityvalue = 1;
											var colorfondo = 'cyan';
										}
									
										var captacion = L.circle(latlngs, {
											opacity: opacityvalue,
											color: 'blue',
											fillColor: colorfondo,
											fillOpacity: 1,
											radius:1.1,
											customData:{
												id_captacion:datos[3][i]["id_captacion"],
												lon1:datos[3][i]["lon1"],
												lat1:datos[3][i]["lat1"],
												id_tramo:datos[3][i]["id_tramo"],
												id_conex_capt:datos[3][i]["id_conex_capt"],
												tipo:datos[3][i]["tipo"],
												clase:datos[3][i]["clase"],
												dim:datos[3][i]["dim"],
												cant_bocas:datos[3][i]["cant_bocas"],
												rotacion:datos[3][i]["rotacion"],
												z_col:datos[3][i]["z_col"],
												z_tapa:datos[3][i]["z_tapa"],
												contrato:datos[3][i]["contrato"],
												proyecto:datos[3][i]["proyecto"],
												etapa:datos[3][i]["etapa"],
												estado:datos[3][i]["estado"],
												accion:datos[3][i]["accion"],
												ccz:datos[3][i]["ccz"],
												cuenca:datos[3][i]["cuenca"],
												historial:datos[3][i]["historial"],
												documentos:datos[3][i]["documentos"],
												fotos:datos[3][i]["fotos"],
												audios:datos[3][i]["audios"],
												alta_fuente:datos[3][i]["alta_fuente"],
												alta_fecha:datos[3][i]["alta_fecha"],
												calle:datos[3][i]["calle"],
												via:datos[3][i]["via"],
												hidraulica:datos[3][i]["hidraulica"],
												economica:datos[3][i]["economica"],
												comentarios:datos[3][i]["comentarios"],
												plano:datos[3][i]["plano"],
												provisorio:datos[3][i]["provisorio"],
												dato1:datos[3][i]["dato1"],
												dato2:datos[3][i]["dato2"],
												dato3:datos[3][i]["dato3"],
												dato4:datos[3][i]["dato4"],
												habilitado:datos[3][i]["habilitado"],
												publicado:datos[3][i]["publicado"],
												fueraservicio:datos[3][i]["fueraservicio"]
											}
										}).bindTooltip("<div style='background:black;color:white; padding:1px 3px 1px 3px'><b>CAPTACION: <br>Id:" + datos[3][i]["id_captacion"] + "</b><br><b>Tramo: " + datos[3][i]["id_tramo"] + "</b></div>", 
										{
													direction: 'left',
													permanent: false,
													sticky: true,
													offset: [10, 0],
													opacity: 0.75,
													className: 'leaflet-tooltip-own' 
										}).addTo(mapa).on('click',function(e){
											var auto = app.permiso_por_zona_y_tipo_elemento('Captaciones', this.options.customData.ccz);
											if (!auto){alert('El usuario no tiene permisos para acceder a este elemento')};
											if (auto && (store.state.modo_seleccion == 'todo' || store.state.modo_seleccion == 'captacion'))
												{
													store.state.captacion_seleccionada.id_captacion = this.options.customData.id_captacion;
													store.state.captacion_seleccionada.lon1 = this.options.customData.lon1;
													store.state.captacion_seleccionada.lat1 = this.options.customData.lat1;
													store.state.captacion_seleccionada.id_tramo = this.options.customData.id_tramo;
													store.state.captacion_seleccionada.id_conex_capt = this.options.customData.id_conex_capt;
													store.state.captacion_seleccionada.tipo = this.options.customData.tipo;
													store.state.captacion_seleccionada.clase = this.options.customData.clase;
													store.state.captacion_seleccionada.dim = this.options.customData.dim;
													store.state.captacion_seleccionada.cant_bocas = this.options.customData.cant_bocas;
													store.state.captacion_seleccionada.rotacion = this.options.customData.rotacion;
													store.state.captacion_seleccionada.z_col = Number(this.options.customData.z_col).toFixed(2);
													store.state.captacion_seleccionada.z_tapa = Number(this.options.customData.z_tapa).toFixed(2);
													store.state.captacion_seleccionada.contrato = this.options.customData.contrato;
													store.state.captacion_seleccionada.proyecto = this.options.customData.proyecto;
													store.state.captacion_seleccionada.etapa = this.options.customData.etapa;
													store.state.captacion_seleccionada.estado = this.options.customData.estado;
													store.state.captacion_seleccionada.accion = this.options.customData.accion;
													store.state.captacion_seleccionada.ccz = this.options.customData.ccz;
													store.state.captacion_seleccionada.cuenca = this.options.customData.cuenca;
													store.state.captacion_seleccionada.historial = this.options.customData.historial;
													store.state.captacion_seleccionada.documentos = this.options.customData.documentos;
													store.state.captacion_seleccionada.fotos = this.options.customData.fotos;
													store.state.captacion_seleccionada.audios = this.options.customData.audios;
													store.state.captacion_seleccionada.alta_fuente = this.options.customData.alta_fuente;
													store.state.captacion_seleccionada.alta_fecha = this.options.customData.alta_fecha;
													store.state.captacion_seleccionada.calle = this.options.customData.calle;
													store.state.captacion_seleccionada.via = this.options.customData.via;
													store.state.captacion_seleccionada.hidraulica = this.options.customData.hidraulica;
													store.state.captacion_seleccionada.economica = this.options.customData.economica;
													store.state.captacion_seleccionada.comentarios = this.options.customData.comentarios;
													store.state.captacion_seleccionada.plano = this.options.customData.plano;
													store.state.captacion_seleccionada.provisorio = this.options.customData.provisorio;
													store.state.captacion_seleccionada.dato1 = this.options.customData.dato1;
													store.state.captacion_seleccionada.dato2 = this.options.customData.dato2;
													store.state.captacion_seleccionada.dato3 = this.options.customData.dato3;
													store.state.captacion_seleccionada.dato4 = this.options.customData.dato4;
													store.state.captacion_seleccionada.habilitado = this.options.customData.habilitado;
													store.state.captacion_seleccionada.publicado = this.options.customData.publicado;
													store.state.captacion_seleccionada.fueraservicio = this.options.customData.fueraservicio;
												}
												if (auto && (store.state.modo_seleccion == 'todo'))
												{
												    store.state.tipo_elemento_seleccionado = 'CAPTACION';
													store.state.modal_visible = 'Evento_Seleccion_Captacion';															
												}	
											}).on('mouseover',function(e){
												store.state.color_anterior_captaciones = this.options.color;
												this.setStyle({color :'blue'});
												for (var s = 0;s < store.state.tramos_en_mapa.length; s++)
												{ 	
													if (store.state.tramos_en_mapa[s].options.customData.id_tramo == this.options.customData.id_tramo)
													{
														store.state.color_anterior_tramos = store.state.tramos_en_mapa[s].options.color;
														store.state.tramos_en_mapa[s].setStyle({color :'blue'});
													}	
												}
												for (var s = 0;s < store.state.conex_capta_en_mapa.length; s++)
														{ 
															if (store.state.conex_capta_en_mapa[s].options.customData.id_conex_capt == this.options.customData.id_conex_capt)
																{
																	store.state.color_anterior_conex_capt = store.state.conex_capta_en_mapa[s].options.color;
																	store.state.conex_capta_en_mapa[s].setStyle({color :'blue'});
																}
														}
											}).on('mouseout',function(e){
												for (var s = 0;s < store.state.conex_capta_en_mapa.length; s++)
															{ 
																if (store.state.conex_capta_en_mapa[s].options.customData.id_conex_capt == this.options.customData.id_conex_capt)
																	{
																		store.state.conex_capta_en_mapa[s].setStyle({color : store.state.color_anterior_conex_capt});
																	}
															}
												for (var s = 0;s < store.state.tramos_en_mapa.length; s++)
														{ 	
															if (store.state.tramos_en_mapa[s].options.customData.id_tramo == this.options.customData.id_tramo)
															{
																store.state.tramos_en_mapa[s].setStyle({color :store.state.color_anterior_tramos});
															}	
														}
												this.setStyle({color :store.state.color_anterior_captaciones});
											});	
											store.state.captaciones_en_mapa.push(captacion);			
								};
			//CAPTACIONES******************FIN FUNCION QUE CARGA  BOCAS DE TORMENTA AL MAPA_______________________________________________________________________________________	
		//CONEXION_CAPTACION_________________---------------------COMIENZA FUNCION QUE CARGA SANEAMIENTO AL MAPA_________________________________________________________________
		for(var i=0;i< datos[4].length;i++){
			var lat1 = datos[4][i]["lat1"];
			var lon1 = datos[4][i]["lon1"];
			var lat2 = datos[4][i]["lat2"];
			var lon2 = datos[4][i]["lon2"];
			var latlngs = [[lat1,lon1],[lat2,lon2]];
			var latlngini = [lat1,lon1];
			if (datos[4][i]["etapa"] == 'A Construir')
			{
				var dasharrayvalue = '10,10';
				var dashoffsetvalue = '0';
			}
			else
			{
				var dasharrayvalue = null;
				var dashoffsetvalue = null;
			}
			var conex_capt = L.polyline(latlngs, {
						color: 'cyan',
						opacity: 0.8,
						weight: 6,
						dashArray: dasharrayvalue,
						dashOffset: dashoffsetvalue,
						customData:{
							id_conex_capt:datos[4][i]["id_conex_capt"],
							lon1:datos[4][i]["lon1"],
							lat1:datos[4][i]["lat1"],
							lon2:datos[4][i]["lon2"],
							lat2:datos[4][i]["lat2"],
							id_captacion:datos[4][i]["id_captacion"],
							id_tramo:datos[4][i]["id_tramo"],
							longitud:datos[4][i]["longitud"],
							tipo:datos[4][i]["tipo"],
							material:datos[4][i]["material"],
							seccion:datos[4][i]["seccion"],
							profundidad:datos[4][i]["profundidad"],
							contrato:datos[4][i]["contrato"],
							proyecto:datos[4][i]["proyecto"],
							etapa:datos[4][i]["etapa"],
							estado:datos[4][i]["estado"],
							accion:datos[4][i]["accion"],
							historial:datos[4][i]["historial"],
							documentos:datos[4][i]["documentos"],
							alta_fuente:datos[4][i]["alta_fuente"],
							alta_fecha:datos[4][i]["alta_fecha"],
							hidraulica:datos[4][i]["hidraulica"],
							economica:datos[4][i]["economica"],
							comentarios:datos[4][i]["comentarios"],
							plano:datos[4][i]["plano"],
							provisorio:datos[4][i]["provisorio"],
							dato1:datos[4][i]["dato1"],
							dato2:datos[4][i]["dato2"],
							dato3:datos[4][i]["dato3"],
							dato4:datos[4][i]["dato4"],
							habilitado:datos[4][i]["habilitado"],
							publicado:datos[4][i]["publicado"],
							fueraservicio:datos[4][i]["fueraservicio"]
				}
				}).bindTooltip("<div style='background:cyan; padding:6px 11px 11px 6px'><b>CONEX CAPTA:<br>Id:" + datos[4][i]["id_conex_capt"] + "</br></div>", 
				{
							direction: 'right',
							permanent: false,
							sticky: true,
							offset: [10, 0],
							opacity: 0.75,
							className: 'leaflet-tooltip-own' 
				}).addTo(mapa).on('click',function(e){
					for (var r = 0;r < store.state.captaciones_en_mapa.length; r++)
					{ 
						if (store.state.captaciones_en_mapa[r].options.customData.id_captacion == this.options.customData.id_captacion)
							{
								var ccz = store.state.captaciones_en_mapa[r].options.customData.ccz;
							}
					}
					var auto = app.permiso_por_zona_y_tipo_elemento('Captaciones', ccz);
					if (!auto){alert('El usuario no tiene permisos para acceder a este elemento')};
					if (auto && store.state.modo_seleccion == 'todo')
					{
					store.state.tipo_elemento_seleccionado = 'CONEX_CAPTA';
					store.state.modal_visible = 'Evento_Seleccion_Conex_capta';														
					}
					if (auto && (store.state.modo_seleccion == 'todo' || store.state.modo_seleccion == 'conex_capta' || store.state.modo_seleccion == 'conexion_captacion' ))
						{												
							store.state.conex_capta_seleccionada.id_conex_capt = this.options.customData.id_conex_capt;
							store.state.conex_capta_seleccionada.lon1 = this.options.customData.lon1;
							store.state.conex_capta_seleccionada.lat1 = this.options.customData.lat1;
							store.state.conex_capta_seleccionada.lon2 = this.options.customData.lon2;
							store.state.conex_capta_seleccionada.lat2 = this.options.customData.lat2;
							store.state.conex_capta_seleccionada.id_captacion = this.options.customData.id_captacion;
							store.state.conex_capta_seleccionada.id_tramo = this.options.customData.id_tramo;
							store.state.conex_capta_seleccionada.longitud = Number(this.options.customData.longitud).toFixed(2);
							store.state.conex_capta_seleccionada.tipo = this.options.customData.tipo;
							store.state.conex_capta_seleccionada.material = this.options.customData.material;
							store.state.conex_capta_seleccionada.seccion = this.options.customData.seccion;
							store.state.conex_capta_seleccionada.profundidad = Number(this.options.customData.profundidad).toFixed(2);
							store.state.conex_capta_seleccionada.contrato = this.options.customData.contrato;
							store.state.conex_capta_seleccionada.proyecto = this.options.customData.proyecto;
							store.state.conex_capta_seleccionada.etapa = this.options.customData.etapa;
							store.state.conex_capta_seleccionada.estado = this.options.customData.estado;
							store.state.conex_capta_seleccionada.accion = this.options.customData.accion;
							store.state.conex_capta_seleccionada.historial = this.options.customData.historial;
							store.state.conex_capta_seleccionada.documentos = this.options.customData.documentos;
							store.state.conex_capta_seleccionada.alta_fuente = this.options.customData.alta_fuente;
							store.state.conex_capta_seleccionada.alta_fecha = this.options.customData.alta_fecha;
							store.state.conex_capta_seleccionada.hidraulica = this.options.customData.hidraulica;
							store.state.conex_capta_seleccionada.economica = this.options.customData.economica;
							store.state.conex_capta_seleccionada.comentarios = this.options.customData.comentarios;
							store.state.conex_capta_seleccionada.plano = this.options.customData.plano;
							store.state.conex_capta_seleccionada.provisorio = this.options.customData.provisorio;
							store.state.conex_capta_seleccionada.dato1 = this.options.customData.dato1;
							store.state.conex_capta_seleccionada.dato2 = this.options.customData.dato2;
							store.state.conex_capta_seleccionada.dato3 = this.options.customData.dato3;
							store.state.conex_capta_seleccionada.dato4 = this.options.customData.dato4;
							store.state.conex_capta_seleccionada.habilitado = this.options.customData.habilitado;
							store.state.conex_capta_seleccionada.publicado = this.options.customData.publicado;
							store.state.conex_capta_seleccionada.fueraservicio = this.options.customData.fueraservicio;
						}
						if (auto && (store.state.modo_seleccion == 'conexion_captacion'))
						{
						store.state.alerta_mensaje = [];
						store.state.alerta_mensaje.push("Conexión de captación seleccionada: " + this.options.customData.id_conex_capt);
						store.state.alerta = true;
						}
					}).on('mouseover',function(e){
						store.state.color_anterior_conex_capt = this.options.color;
						this.setStyle({color :'cyan'});
						for (var s = 0;s < store.state.tramos_en_mapa.length; s++)
						{ 	
							if (this.options.customData.id_tramo == store.state.tramos_en_mapa[s].options.customData.id_tramo)
							{
								store.state.color_anterior_tramos = store.state.tramos_en_mapa[s].options.color;
								store.state.tramos_en_mapa[s].setStyle({color :'cyan'});
							}	
						}
						for (var s = 0;s < store.state.captaciones_en_mapa.length; s++)
						{ 
							if (store.state.captaciones_en_mapa[s].options.customData.id_captacion == this.options.customData.id_captacion)
								{
									store.state.color_anterior_captaciones = store.state.captaciones_en_mapa[s].options.color;
									store.state.captaciones_en_mapa[s].setStyle({color :'cyan'});
								}
						}
					}).on('mouseout',function(e){
						for (var s = 0;s < store.state.tramos_en_mapa.length; s++)
						{ 	
							if (store.state.tramos_en_mapa[s].options.customData.id_tramo == this.options.customData.id_tramo)
							{
								store.state.tramos_en_mapa[s].setStyle({color :store.state.color_anterior_tramos});
							}	
						}
						for (var s = 0;s < store.state.captaciones_en_mapa.length; s++)
						{ 
							if (store.state.captaciones_en_mapa[s].options.customData.id_captacion == this.options.customData.id_captacion)
								{
									store.state.captaciones_en_mapa[s].setStyle({color : store.state.color_anterior_captaciones});
								}
						}		
						this.setStyle({color :store.state.color_anterior_conex_capt});
					});	
					store.state.conex_capta_en_mapa.push(conex_capt);
			}
				
//CONEXION_CAPTACION__________FIN BOCAS CONEXIONES---------------------COMIENZA FUNCION QUE CARGA SANEAMIENTO AL MAPA______________________________________________________


						        let lati = datos[6][0];
								let long = datos[6][1];
								},
			cargo_mantenimiento: function(mapa,datos){
									app.limpio_mantenimiento(mapa);
								//---------------------COMIENZA FUNCION QUE CARGA controles AL MAPA_______________________________________________________________________________________
									for(var i=0;i< datos.length;i++){
												var id = datos[i]["id"];
												var xc = datos[i]["xc"];
												var yc = datos[i]["yc"];
												var tipo = datos[i]["tipo"];
												switch (tipo)
												{
													//TIPO1
													case 'Tramo sin punto singular': 
													color =  '#FE2712';
													radio = 20;
													break;
													case 'Psingular sin tramo': 
													color =  '#3333cc';
													radio = 10;
													break;

													//TIPO 2
													case 'Tramo sin dato PS': 
													color =  '#FE2712'; //rojo
													radio = 20;
													break;
													case 'Tramo sin dato Zamp': 
													color =  '#3333cc';//azul
													radio = 15;
													break;
													case 'Tramo sin dato Z Tapa': 
													color =  '#ff6600';//naranja
													radio = 7;
													break;
													case 'Tramo sin Seccion': 
													color =  '#ffff00';//amarillo
													radio = 5;
													break;
													case 'Tramo sin Tipo': 
													color =  '#33cc33'; //verde
													radio = 3;
													break;
													
													//TIPO 3
													case 'PS sin Tramos': 
													color =  '#FE2712'; //rojo
													radio = 20;
													break;
													case 'PS sin Tipo': 
													color =  '#3333cc';//azul
													radio = 15;
													break;
													case 'PS sin Z Tapa': 
													color =  '#ff6600';//naranja
													radio = 7;
													break;
													case 'PS sin Zab': 
													color =  '#ffff00';//amarillo
													radio = 5;
													break;
													case 'PS sin Profundidad': 
													color =  '#33cc33'; //verde
													radio = 3;
													break;

													//TIPO 4
													case 'Captacion sin Tramo': 
													color =  '#FE2712'; //rojo
													radio = 20;
													break;
													case 'Captacion sin Tipo': 
													color =  '#3333cc';//azul
													radio = 15;
													break;
													case 'Captacion sin Clase': 
													color =  '#757575';//naranja
													radio = 7;
													break;
													case 'Captacion sin Z Tapa': 
													color =  '#ffff00';//amarillo
													radio = 5;
													break;
													case 'Captacion sin Z Col': 
													color =  '#33cc33'; //verde
													radio = 3;
													break;													

														default:
														color =  '#FCCC1A';
														radio = 10;
												}
												var latlngini = [yc,xc];
												var mantenimiento = L.circle(latlngini, {
													color: color,
													fillColor: color,
													fillOpacity: 0.1,
													radius:radio,
													wheight:2,
													customData:{
														id:id,
														tipo:tipo
													}
												}).bindTooltip("<div style='background:#D5872A; padding:1px 3px 1px 3px'><b>Tipo:" + tipo + "</b><br><b>Id:" + id + "</b></div>", 
												{
															direction: 'right',
															permanent: false,
															sticky: true,
															offset: [10, 0],
															opacity: 0.75,
															className: 'leaflet-tooltip-own' 
												}).addTo(mapa);		
									store.state.mantenimiento.push(mantenimiento);
											}
							},
			cargo_monitoreo: function(mapa,datos){
								app.limpio_monitoreo(mapa);
							//---------------------COMIENZA FUNCION QUE CARGA controles AL MAPA_______________________________________________________________________________________
								for(var i=0;i< datos.length;i++){
											var id = datos[i]["id"];
											var xc = datos[i]["xc"];
											var yc = datos[i]["yc"];
											var tipo = datos[i]["tipo"];
											var cantidad = datos[i]["cantidad"];
											var radio = 8 * cantidad;
											var color =  '#424242'
											switch (tipo)
											{
												case 'Elementos a Revisar': 
												
														switch (cantidad)
															{
															case 1: 
															color =  '#E91E63';
															break;
															case 2: 
															color =  '#81C7843';
															break;
															case 3: 
															color =  '#2196F3';
															break;
															case 4: 
															color =  '#FFCA28';
															break;
															case 5: 
															color =  '#AB47BC ';
															break;
															default:
															color =  '#424242';
															}	
															var latlngini = [yc,xc];
															var monitoreo = L.circle(latlngini, {
																color: color,
																fillColor: color,
																fillOpacity: 0.1,
																radius:radio,
																wheight:2,
																customData:{
																	id:id,
																	tipo:tipo,
																	cantidad:cantidad
																}
															}).bindTooltip("<div style='background:#D5872A; padding:1px 3px 1px 3px'><b>Tipo:" + tipo + "</b><br><b>Id:" +id + "</b></div>", 
															{
																		direction: 'right',
																		permanent: false,
																		sticky: true,
																		offset: [10, 0],
																		opacity: 0.75,
																		className: 'leaflet-tooltip-own' 
															}).addTo(mapa);		
															store.state.monitoreo.push(monitoreo);
															break;

															case 'Acciones pendientes':
																			radio = radio * 2;
																			switch (cantidad)
																				{
																				case 1: 
																				color =  '#FF7F50';
																				break;
																				case 2: 
																				color =  '#DE3163';
																				break;
																				default:
																				color =  '#9FE2BF';
																				}	
																			var latlngini = [yc,xc];
																			var monitoreo = L.circle(latlngini, {
																				color: color,
																				fillColor: color,
																				fillOpacity: 0.1,
																				radius:radio,
																				wheight:2,
																				customData:{
																					id:id,
																					tipo:tipo,
																					cantidad:cantidad
																				}
																			}).bindTooltip("<div style='background:#D5872A; padding:1px 3px 1px 3px'><b>Tipo:" + tipo + "</b><br><b>Id:" +id + "</b></div>", 
																			{
																						direction: 'right',
																						permanent: false,
																						sticky: true,
																						offset: [10, 0],
																						opacity: 0.75,
																						className: 'leaflet-tooltip-own' 
																			}).addTo(mapa);		
																			store.state.monitoreo.push(monitoreo);
															break;	


															case 'Sin intervenciones':
																			radio = radio;
																			color =  '#DE3163';
																			var latlngini = [yc,xc];
																			var monitoreo = L.circle(latlngini, {
																				color: color,
																				fillColor: color,
																				fillOpacity: 0.1,
																				radius:radio,
																				wheight:2,
																				customData:{
																					id:id,
																					tipo:tipo,
																					cantidad:cantidad
																				}
																			}).bindTooltip("<div style='background:#D5872A; padding:1px 3px 1px 3px'><b>Tipo:" + tipo + "</b><br><b>Id:" +id + "</b></div>", 
																			{
																						direction: 'right',
																						permanent: false,
																						sticky: true,
																						offset: [10, 0],
																						opacity: 0.75,
																						className: 'leaflet-tooltip-own' 
																			}).addTo(mapa);		
																			store.state.monitoreo.push(monitoreo);
															break;	

														}	
													}
			},
			cargo_saneamiento2: function(mapa,datos,tipo){
				if (tipo == 'Colectores')
				{
											//---------------------COMIENZA FUNCION QUE CARGA COLECTORES DE SANEAMIENTO AL MAPA_______________________________________________________________________________________
												for(var i=0;i< datos[0].length;i++){
													var geom = datos[0][i]["geom"];
													var solocoord = geom.substring(11);
													solocoord = solocoord.slice(0,-1);
													var latlngs1 = solocoord.split(",");
													var latlngs = [];
													for (var j=0; j<latlngs1.length; j++)
													{
														var elemento = (latlngs1[j].split(" "));
														latlngs.push(elemento.reverse());
													}
													var colector = L.polyline(latlngs, {
																color: 'blue',
																opacity: 1,
																weight: 7,
																customData:{
																	id:datos[0][i]["id"],
																	geom:datos[0][i]["geom"],
																	tiposec:datos[0][i]["tiposec"],
																	tipotra:datos[0][i]["tipotra"],
																	elemred:datos[0][i]["elemred"],
																	id_psig_aa:datos[0][i]["id_psig_aa"],
																	id_psig_ab:datos[0][i]["id_psig_ab"],
																	dim1:datos[0][i]["dim1"],
																	dim2:datos[0][i]["dim2"],
																	dim3:datos[0][i]["dim3"],
																	dim4:datos[0][i]["dim4"],
																	contrato:datos[0][i]["contrato"],
																	proyecto:datos[0][i]["proyecto"],
																	material:datos[0][i]["material"],
																	zarriba:datos[0][i]["zarriba"],
																	zabajo:datos[0][i]["zabajo"],
																	z_tapa_aa:datos[0][i]["z_tapa_aa"],
																	z_tapa_ab:datos[0][i]["z_tapa_ab"],
																	prof_aa:datos[0][i]["prof_aa"],
																	prof_ab:datos[0][i]["prof_ab"],
																	longitud:datos[0][i]["longitud"],
																	pendiente:datos[0][i]["pendiente"],
																	salto:datos[0][i]["salto"],
																	estado:datos[0][i]["estado"],
																	accion:datos[0][i]["accion"],
																	ccz:datos[0][i]["ccz"],
																	cuenca:datos[0][i]["cuenca"],
																	historial:datos[0][i]["historial"],
																	documentos:datos[0][i]["documentos"],
																	fotos:datos[0][i]["fotos"],
																	audios:datos[0][i]["audios"],
																	videos:datos[0][i]["videos"],
																	alta_fuente:datos[0][i]["alta_fuente"],
																	alta_fecha:datos[0][i]["alta_fecha"],
																	calle:datos[0][i]["calle"],
																	via:datos[0][i]["via"],
																	hidraulica:datos[0][i]["hidraulica"],
																	economica:datos[0][i]["economica"],
																	activo:datos[0][i]["activo"],
																	comentarios:datos[0][i]["comentarios"],
																	etapa:datos[0][i]["etapa"],
																	plano:datos[0][i]["plano"],
																	provisorio:datos[0][i]["provisorio"],
																	dato1:datos[0][i]["dato1"],
																	dato2:datos[0][i]["dato2"],
																	dato3:datos[0][i]["dato3"],
																	dato4:datos[0][i]["dato4"],
																	habilitado:datos[0][i]["habilitado"],
																	publicado:datos[0][i]["publicado"],
																	fueraservicio:datos[0][i]["fueraservicio"],
																	
														}
														}).bindTooltip("<div style='background:cyan; padding:1px 3px 1px 3px'><b>Elemred:" + datos[0][i]["elemred"] + "</b><br><b>Long:" + datos[0][i]["longitud"].substring(0,5) + "</b><br><b>Pend:" + datos[0][i]["pendiente"].substring(0,5) + "</br></div>", 
														{
																	direction: 'right',
																	permanent: false,
																	sticky: true,
																	offset: [10, 0],
																	opacity: 0.75,
																	className: 'leaflet-tooltip-own' 
														}).addTo(mapa);
														store.state.tramos_en_mapa.push(colector);
											};
						//*******************FIN FUNCION QUE CARGA COLECTORES DE SANEAMIENTO AL MAPA_______________________________________________________________________________________	
										
					}								

					if (tipo == 'PSingulares')
					{
											//---------------------COMIENZA FUNCION QUE CARGA psingulares DE SANEAMIENTO AL MAPA_______________________________________________________________________________________
											for(var i=0;i< datos[0].length;i++){
												var lat1 = datos[0][i]["lat"];
												var lon1 = datos[0][i]["lon"];
												var latlngs = [lat1,lon1];
												var psingular = L.circle(latlngs, {
															color: 'blue',
															opacity: 1,
															weight: 7,
															customData:{
																id:datos[0][i]["id"],
																lat:datos[0][i]["lat"],
																lon:datos[0][i]["lon"],
																tipo:datos[0][i]["tipo"],
																elem_red:datos[0][i]["elem_red"],
																tramos:datos[0][i]["tramos"],
																z_tapa:datos[0][i]["z_tapa"],
																inspeccion:datos[0][i]["inspeccion"],
																profundidad:datos[0][i]["profundidad"],
																salto:datos[0][i]["salto"],
																z_ab:datos[0][i]["z_ab"],
																alta_fuente:datos[0][i]["alta_fuente"],
																alta_fecha:datos[0][i]["alta_fecha"],
																calle:datos[0][i]["calle"],
																via:datos[0][i]["via"],
																contrato:datos[0][i]["contrato"],
																estado:datos[0][i]["estado"],
																ccz:datos[0][i]["ccz"],
																cuenca:datos[0][i]["cuenca"],
																proyecto:datos[0][i]["proyecto"],
																accion:datos[0][i]["accion"],
																historial:datos[0][i]["historial"],
																fotos:datos[0][i]["fotos"],
																audios:datos[0][i]["audios"],
																documentos:datos[0][i]["documentos"],
																comentarios:datos[0][i]["comentarios"],
																hidraulica:datos[0][i]["hidraulica"],
																economica:datos[0][i]["economica"],
																activo:datos[0][i]["activo"],
																etapa:datos[0][i]["etapa"],
																plano:datos[0][i]["plano"],
																provisorio:datos[0][i]["provisorio"],
																dato1:datos[0][i]["dato1"],
																dato2:datos[0][i]["dato2"],
																dato3:datos[0][i]["dato3"],
																dato4:datos[0][i]["dato4"],
																habilitado:datos[0][i]["habilitado"],
																publicado:datos[0][i]["publicado"],
																fueraservicio:datos[0][i]["fueraservicio"]
													}
													}).bindTooltip("<div style='background:cyan; padding:1px 3px 1px 3px'><b>Elemred:" + datos[0][i]["elem_red"] + "</b><br><b>Tramos:" + datos[0][i]["tramos"] + "</b><br><b>ZTapa:" + datos[0][i]["z_tapa"].substring(0,5) + "</br></div>", 
													{
																direction: 'right',
																permanent: false,
																sticky: true,
																offset: [10, 0],
																opacity: 0.75,
																className: 'leaflet-tooltip-own' 
													}).addTo(mapa);
													store.state.psingulares_en_mapa.push(psingular);
										}



									}				
					//*******************FIN FUNCION QUE CARGA psingulares DE SANEAMIENTO AL MAPA_______________________________________________________________________________________	


					if (tipo == 'Captaciones')
					{
											//---------------------COMIENZA FUNCION QUE CARGA captaciones DE SANEAMIENTO AL MAPA_______________________________________________________________________________________
											for(var i=0;i< datos[0].length;i++){
												var lat1 = datos[0][i]["lat"];
												var lon1 = datos[0][i]["lon"];
												var latlngs = [lat1,lon1];
												var captacion = L.circle(latlngs, {
															color: 'green',
															opacity: 1,
															weight: 7,
															customData:{
																lat:datos[0][i]["lat"],
																lon:datos[0][i]["lon"],
																elem_red:datos[0][i]["elem_red"],
																id_tramo:datos[0][i]["id_tramo"],
																id_conex_capt:datos[0][i]["id_conex_capt"],
																tipo:datos[0][i]["tipo"],
																clase:datos[0][i]["clase"],
																dim:datos[0][i]["dim"],
																cant_bocas:datos[0][i]["cant_bocas"],
																alta_fuente:datos[0][i]["alta_fuente"],
																alta_fecha:datos[0][i]["alta_fecha"],
																rotacion:datos[0][i]["rotacion"],
																z_col:datos[0][i]["z_col"],
																z_tapa:datos[0][i]["z_tapa"],
																calle:datos[0][i]["calle"],
																via:datos[0][i]["via"],
																contrato:datos[0][i]["contrato"],
																estado:datos[0][i]["estado"],
																ccz:datos[0][i]["ccz"],
																cuenca:datos[0][i]["cuenca"],
																proyecto:datos[0][i]["proyecto"],
																accion:datos[0][i]["accion"],
																historial:datos[0][i]["historial"],
																fotos:datos[0][i]["fotos"],
																audios:datos[0][i]["audios"],
																documentos:datos[0][i]["documentos"],
																comentarios:datos[0][i]["comentarios"],
																hidraulica:datos[0][i]["hidraulica"],
																economica:datos[0][i]["economica"],
																activo:datos[0][i]["activo"],
																etapa:datos[0][i]["etapa"],
																plano:datos[0][i]["plano"],
																provisorio:datos[0][i]["provisorio"],
																dato1:datos[0][i]["dato1"],
																dato2:datos[0][i]["dato2"],
																dato3:datos[0][i]["dato3"],
																dato4:datos[0][i]["dato4"],
																habilitado:datos[0][i]["habilitado"],
																publicado:datos[0][i]["publicado"],
																fueraservicio:datos[0][i]["fueraservicio"]
													}
													}).bindTooltip("<div style='background:cyan; padding:1px 3px 1px 3px'><b>Elemred:" + datos[0][i]["elem_red"] + "</b><br><b>ZTapa:" + datos[0][i]["z_tapa"].substring(0,5) + "</b><br><b>ZCol:" + datos[0][i]["z_col"].substring(0,5) + "</br></div>", 
													{
																direction: 'right',
																permanent: false,
																sticky: true,
																offset: [10, 0],
																opacity: 0.75,
																className: 'leaflet-tooltip-own' 
													}).addTo(mapa);
													store.state.captaciones_en_mapa.push(captacion);
										}



									}				
					//*******************FIN FUNCION QUE CARGA captaciones DE SANEAMIENTO AL MAPA_______________________________________________________________________________________	


							},								
			obtengo_fecha2: function(fecha){
				fecha.setHours(fecha.getHours()-3);
									var fecha2=  fecha.toISOString();
									var parte1 = fecha2.split("T")[0];
									var parte2 = fecha2.split("T")[1].substr(0,8);
									parte2 = parte2.replace(/:/g,"-");
									return "_" + parte1 + "T" + parte2;
								},
			devuelvo_fecha: function(fechatexto){
				let partesFecha = fechatexto.split(/[\s-:]/);
				let fechares = new Date(partesFecha[0], partesFecha[1] - 1, partesFecha[2], partesFecha[3], partesFecha[4], partesFecha[5]);
				return fechares;
							},
			date_a_fechatexto: function(fecha){
				let año = fecha.getFullYear();
				let mes = ("0" + (fecha.getMonth() + 1)).slice(-2); // Agrega un cero al mes si es necesario y toma los dos últimos dígitos
				let dia = ("0" + fecha.getDate()).slice(-2); // Agrega un cero al día si es necesario y toma los dos últimos dígitos
				let horas = ("0" + fecha.getHours()).slice(-2); // Agrega un cero a las horas si es necesario y toma los dos últimos dígitos
				let minutos = ("0" + fecha.getMinutes()).slice(-2); // Agrega un cero a los minutos si es necesario y toma los dos últimos dígitos
				let segundos = ("0" + fecha.getSeconds()).slice(-2); // Agrega un cero a los segundos si es necesario y toma los dos últimos dígitos
				let textoFechaFormateada = año + "-" + mes + "-" + dia + " " + horas + ":" + minutos + ":" + segundos;
				return textoFechaFormateada;
											},				
			obtengo_punto_en_psingular: function(lat,lon){
									var menor_distancia = 999999;
									var latres = lat;
									var lonres = lon;
									var psigres = 0;
									if(typeof store.state.psingulares_en_mapa !== 'undefined')
									{
										for(var i=0;i<store.state.psingulares_en_mapa.length; i++)
										{
											let lat2 = store.state.psingulares_en_mapa[i].options.customData.lat1;
											let lon2 = store.state.psingulares_en_mapa[i].options.customData.lon1;
											let psi = store.state.psingulares_en_mapa[i].options.customData.id_psingular;
											let resdist = dl_geometria.dl_distancia_metros_de_geograficas(lat,lon,lat2,lon2);
											if (resdist < menor_distancia)
											{
												latres = lat2;
												lonres = lon2;
												psigres = psi;
												menor_distancia = resdist;
											}	
										}
									}
									var res = {lat:latres,lon:lonres,id:psigres};
									return res;
			},
			obtengo_punto_en_colector: function(lat,lon){
					var menor_distancia = 999999;
					var latres = lat;
					var lonres = lon;
					var id_tramo_res = 0;
					if(typeof store.state.tramos_en_mapa !== 'undefined')
					{
						for(var i=0;i<store.state.tramos_en_mapa.length; i++)
						{
							let linestring = '';
							let puntosline = store.state.tramos_en_mapa[i].getLatLngs();
							for (var j=0;j<puntosline.length; j++)
							{
								linestring += puntosline[j]['lng'] + " " + puntosline[j]['lat'] + ',';
							}
							linestring = linestring.substr(0, linestring.length - 1);
							let resdist = dl_geometria.dl_punto_cercano_linestring(lat,lon,linestring);
							if (resdist['distancia'] < menor_distancia)
							{
								latres = resdist['lat'];
								lonres = resdist['lon'];
								id_tramo_res = store.state.tramos_en_mapa[i].options.customData.id_tramo;
								menor_distancia = resdist['distancia'];
							}	
						}
					}
					var res = {lat:latres,lon:lonres,tramo:id_tramo_res};
					return res;
			},
			obtengo_punto_en_colector_pluvial_unitario_mixto: function(lat,lon){
				var menor_distancia = 999999;
				var latres = lat;
				var lonres = lon;
				var id_tramo_res = 0;
				var tipocol = 'Desconectado';
				if(typeof store.state.tramos_en_mapa !== 'undefined')
				{
					for(var i=0;i<store.state.tramos_en_mapa.length; i++)
					{
						let tipotr = store.state.tramos_en_mapa[i].options.customData.tipotra;
						if (tipotr == 49 || tipotr == 51 || tipotr == 53)
						{
							let linestring = '';
							let puntosline = store.state.tramos_en_mapa[i].getLatLngs();
							for (var j=0;j<puntosline.length; j++)
							{
								linestring += puntosline[j]['lng'] + " " + puntosline[j]['lat'] + ',';
							}
							linestring = linestring.substr(0, linestring.length - 1);
							let resdist = dl_geometria.dl_punto_cercano_linestring(lat,lon,linestring);
							if (resdist['distancia'] < menor_distancia)
							{
								latres = resdist['lat'];
								lonres = resdist['lon'];
								id_tramo_res = store.state.tramos_en_mapa[i].options.customData.id_tramo;
								menor_distancia = resdist['distancia'];
								tipocol = 'Pluvial';
							}
						}	
					}
					if(id_tramo_res == 0)
					{
					for(var i=0;i<store.state.tramos_en_mapa.length; i++)
						{
							let tipotr = store.state.tramos_en_mapa[i].options.customData.tipotra;
								let linestring = '';
								let puntosline = store.state.tramos_en_mapa[i].getLatLngs();
								for (var j=0;j<puntosline.length; j++)
								{
									linestring += puntosline[j]['lng'] + " " + puntosline[j]['lat'] + ',';
								}
								linestring = linestring.substr(0, linestring.length - 1);
								let resdist = dl_geometria.dl_punto_cercano_linestring(lat,lon,linestring);
								if (resdist['distancia'] < menor_distancia)
								{
									latres = resdist['lat'];
									lonres = resdist['lon'];
									id_tramo_res = store.state.tramos_en_mapa[i].options.customData.id_tramo;
									menor_distancia = resdist['distancia'];
									tipocol = 'Otros';
								}	
						}
					}
					if(id_tramo_res == 0)
						{
							latres = lat + 0.00003;
							lonres = lon + 0.00003;
						}
					
					
				}
				var res = {lat:latres,lon:lonres,tramo:id_tramo_res};
				return res;
		},
			calcular_z_en_col(lat,lon,colector) {
				if (typeof colector === 'object')
				{
				let puntoabajo = false;
				let distancia_abajo = 0;
					let listapuntos = colector.getLatLngs();
					let largototal = 0;
					let previousPoint = false;
					listapuntos.forEach(function (latLng) {
					  if (previousPoint) {
						largototal = largototal + previousPoint.distanceTo(latLng);
						puntoabajo = latLng;
					  }
					  previousPoint = latLng;
					});
					let zarriba = colector.options.customData.zarriba;
					let zabajo = colector.options.customData.zabajo;
					let puntoencolector = L.latLng(lat,lon);
					distancia_abajo = puntoencolector.distanceTo(puntoabajo);
					if (largototal > 0 && zarriba > 0 && zabajo > 0 && zarriba > zabajo && distancia_abajo >= 0 && distancia_abajo <= largototal) {
					  let zres = 0;
					  let fac1 = distancia_abajo / largototal;
					  let fac2 = zarriba - zabajo;
					  zres = Number(zabajo) + Number(fac2 * fac1);
					  zres = String(zres);
					  zres = zres.substring(0, 5);
					  return zres;
					}
					else
					{
					return 0.00;
					}
				}
				else
				{
				return 0.00;
				}	
			},
			calculo_salto_en_psingular(id_psingular){
				let salto = 0;
				let lista_zampeados = [];
				if(typeof store.state.tramos_en_mapa !== 'undefined')
				{
					for(var i=0;i<store.state.tramos_en_mapa.length; i++)
					{
						if (store.state.tramos_en_mapa[i].options.customData.id_psig_aa == id_psingular)
						{
							lista_zampeados.push(store.state.tramos_en_mapa[i].options.customData.zarriba);
						}
						if (store.state.tramos_en_mapa[i].options.customData.id_psig_ab == id_psingular)
						{
							lista_zampeados.push(store.state.tramos_en_mapa[i].options.customData.zabajo);
						}
					}	
					salto = Math.max(...lista_zampeados) - Math.min(...lista_zampeados);
				}
				(Math.max(...lista_zampeados) == 0.00 || Math.min(...lista_zampeados) == 0 || salto > 10)? salto = 0.00: true;
				return salto;	
			},
			obtengo_punto_iniciofin_en_colector: function(lat,lon){
				var menor_distancia = 999999;
				var resultado = [];
				var pures = L.latLng(lat,lon);
				var id_tramo_res = 0;
				var id_psing = 0;
				var panalizado = L.latLng(lat,lon);
				if(typeof store.state.tramos_en_mapa !== 'undefined')
				{
					for(var i=0;i<store.state.tramos_en_mapa.length; i++)
					{
						let linestring = '';
						let puntosline = store.state.tramos_en_mapa[i].getLatLngs();
						let pini = L.latLng(puntosline[0]);
						let pfin = L.latLng(puntosline[puntosline.length - 1]);
						let dist1 = panalizado.distanceTo(pini);
						let dist2 = panalizado.distanceTo(pfin);
						if (dist1 < menor_distancia)
						{
							menor_distancia = dist1;
							pures = pini;
							id_tramo_res = store.state.tramos_en_mapa[i].options.customData.id_tramo;
							id_psing = store.state.tramos_en_mapa[i].options.customData.id_psig_aa;

						}
						if (dist2 < menor_distancia)
						{
							menor_distancia = dist2;
							pures = pfin;
							id_tramo_res = store.state.tramos_en_mapa[i].options.customData.id_tramo;
							id_psing = store.state.tramos_en_mapa[i].options.customData.id_psig_ab;
						}
					}
				}
				resultado.push(pures);
				resultado.push({id_tramo:id_tramo_res,id_psingular:id_psing});
				return resultado;
			},
			genero_reporte_excel: function(tipo_reporte){
				return new Promise(resolve => {
									//INICIO REPORTE GENERAL DE RUIDO //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
									//obtengo datos a reportar
									////////////////////////////						

						if (tipo_reporte == 'Colectores')
						{
										var nombre_reporte= "Reporte_Colectores_" + this.obtengo_fecha2(new Date()) + ".xlsx";
										var excel = $JExcel.new("Lato 11 #666666");			// Default font										
										// excel.set is the main function to generate content:
										// 		We can use parameter notation excel.set(sheetValue,columnValue,rowValue,cellValue,styleValue) 
										// 		Or object notation excel.set({sheet:sheetValue,column:columnValue,row:rowValue,value:cellValue,style:styleValue })
										// 		null or 0 are used as default values for undefined entries
										let mensaje = store.state.descripcion_consulta_distribuida;	
										excel.set( {sheet:0,value: "Reporte_Colectores" } );
										excel.set({row:0,value: 35});
										excel.set({row:1,value: 40});
										excel.set({column:0,value: 10});
										excel.set(0,0,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,0,0,mensaje,excel.addStyle({align:"L C",fill: "#00823B",border:"none,none,none,none #666666",font: "Lato 14 #FFFFFF B"}));
										excel.set(0,0,1,"Id",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:1,value: 10});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,1,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,1,1,"TipoSec",excel.addStyle({align:"C C",fill: "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:2,value: 10});								// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,2,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,2,1,"TipoTra",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set({column:3,value: 10});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,3,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,3,1,"Elemred",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM			
										excel.set({column:4,value: 7});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,4,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,4,1,"PS_aa",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										
										excel.set({column:5,value: 10});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,5,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,5,1,"PS_ab",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set({column:6,value: 10});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,6,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,6,1,"dim1",excel.addStyle({align:"C C",fill:"#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set({column:7,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,7,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,7,1,"dim2",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set({column:8,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,8,0,"",excel.addStyle({align:"L C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,8,1,"dim3",excel.addStyle({align:"C C",fill:"#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set({column:9,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,9,0,"",excel.addStyle({align:"L C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,9,1,"dim4",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set({column:10,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,10,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,10,1,"Contrato",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set({column:11,value: 16});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,11,0,"",excel.addStyle({align:"L C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,11,1,"Proyecto",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set({column:12,value: 16});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,12,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,12,1,"Material",excel.addStyle({align:"C C",fill:"#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:13,value: 20});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,13,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,13,1,"Zarriba",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:14,value: 20});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,14,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,14,1,"Zabajo",excel.addStyle({align:"C C",fill:"#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));								
										excel.set({column:15,value: 16});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,15,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,15,1,"Ztapa_aa",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set({column:16,value: 16});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,16,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,16,1,"Ztapa_ab",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:17,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,17,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,17,1,"Prof_aa",excel.addStyle({align:"C C",fill: "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
									    excel.set({column:18,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,18,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,18,1,"Prof_ab",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:19,value: 18});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,19,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,19,1,"Longitud",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:20,value: 15});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,20,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,20,1,"Pendiente",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:21,value: 11});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,21,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,21,1,"Salto",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:22,value: 18});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,22,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,22,1,"Estado",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:23,value: 15});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,23,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,23,1,"Accion",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:24,value: 15});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,24,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,24,1,"CCZ",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:25,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,25,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,25,1,"Cuenca",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:26,value: 32});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,26,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,26,1,"Historial",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:27,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,27,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,27,1,"Documentos",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:28,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,28,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,28,1,"Fotos",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:29,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,29,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,29,1,"Audios",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:30,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,30,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,30,1,"Videos",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:31,value: 22});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,31,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,31,1,"Alta Fuente",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:32,value: 16});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,32,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,32,1,"Alta Fecha",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:33,value: 15});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,33,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,33,1,"Calle",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:34,value: 8});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,34,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,34,1,"Via",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:35,value: 14});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,35,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,35,1,"Hidraulica",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:36,value: 14});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,36,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,36,1,"Economica",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:37,value: 4});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,37,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,37,1,"Activo",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:38,value: 25});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,38,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,38,1,"Comentarios",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:39,value: 25});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,39,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,39,1,"Etapa",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										
																			fila = 2;
																			let registros = store.state.tramos_en_mapa;
																			for (i=0;i<registros.length;i++)
																			{
																				var registro = registros[i];
																				var id_registro = registro[0];
																				excel.set({row:fila,value: 17});
																				excel.set(0,0,fila,registro.options.customData.id,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,1,fila,registro.options.customData.tiposec,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,2,fila,registro.options.customData.tipotra,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,3,fila,registro.options.customData.elemred,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,4,fila,registro.options.customData.id_psig_aa,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,5,fila,registro.options.customData.id_psig_ab,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				let dim1 = registro.options.customData.dim1;
																				dim1 = parseFloat(dim1).toPrecision(3);
																				excel.set(0,6,fila,dim1,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				let dim2 = registro.options.customData.dim2;
																				dim1 = parseFloat(dim2).toPrecision(3);
																				excel.set(0,7,fila,dim2,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				let dim3 = registro.options.customData.dim3;
																				dim3 = parseFloat(dim3).toPrecision(3);
																				excel.set(0,8,fila,dim3,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				let dim4 = registro.options.customData.dim4;
																				dim4 = parseFloat(dim4).toPrecision(3);
																				excel.set(0,9,fila,dim4,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,10,fila,registro.options.customData.contrato,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,11,fila,registro.options.customData.proyecto,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,12,fila,registro.options.customData.material,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				let zarriba = registro.options.customData.zarriba;
																				zarriba = parseFloat(zarriba).toPrecision(3);
																				excel.set(0,13,fila,zarriba,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				let zabajo = registro.options.customData.zabajo;
																				zarriba = parseFloat(zabajo).toPrecision(3);
																				excel.set(0,14,fila,zabajo,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				let z_tapa_aa = registro.options.customData.z_tapa_aa;
																				z_tapa_aa = parseFloat(z_tapa_aa).toPrecision(3);
																				excel.set(0,15,fila,z_tapa_aa,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				let z_tapa_ab = registro.options.customData.zarriba;
																				z_tapa_ab = parseFloat(z_tapa_ab).toPrecision(3);
																				excel.set(0,16,fila,z_tapa_ab,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				let prof_aa = registro.options.customData.prof_aa;
																				prof_aa = parseFloat(prof_aa).toPrecision(3);
																				excel.set(0,17,fila,prof_aa,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				let prof_ab = registro.options.customData.prof_ab;
																				prof_ab = parseFloat(prof_ab).toPrecision(3);
																				excel.set(0,18,fila,prof_ab,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				let longitud = registro.options.customData.longitud;
																				longitud = parseFloat(longitud).toPrecision(3);
																				excel.set(0,19,fila,longitud,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				let pendiente = registro.options.customData.pendiente;
																				pendiente = parseFloat(pendiente).toPrecision(3);
																				excel.set(0,20,fila,pendiente,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				let salto = registro.options.customData.salto;
																				salto = parseFloat(salto).toPrecision(3);
																				excel.set(0,21,fila,salto,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,22,fila,registro.options.customData.estado,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,23,fila,registro.options.customData.accion,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,24,fila,registro.options.customData.ccz,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,25,fila,registro.options.customData.cuenca,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));			
																				let historial = JSON.parse(registro.options.customData.historial);					
																				dato = '';
																				for(var j=0; j < historial.length; j++)
																				{
																				if (j>0){ dato = dato + "\n" };	
																				let renglon = historial[j]["descripcion"] + " en " + historial[j]["fecha"].substr(0,10) + " usuario: " + historial[j]["usuario"];
																				dato = dato + renglon;
																				}		
																				excel.set(0,26,fila,dato,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,27,fila,registro.options.customData.documentos,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				let fotos = registro.options.customData.fotos;
																				fotos = fotos.replace(/\u0022/g,'');
																				fotos = fotos.replace(/\u005B/g,'');
																				fotos = fotos.replace(/\u005D/g,'');
																				excel.set(0,28,fila,fotos,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				let audios = registro.options.customData.audios;
																				audios = audios.replace(/\u0022/g,'');
																				audios = audios.replace(/\u005B/g,'');
																				audios = audios.replace(/\u005D/g,'');																				
																				excel.set(0,29,fila,audios,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				let videos = registro.options.customData.videos;
																				videos = videos.replace(/\u0022/g,'');
																				videos = videos.replace(/\u005B/g,'');
																				videos = videos.replace(/\u005D/g,'');																					
																				excel.set(0,30,fila,videos,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,31,fila,registro.options.customData.alta_fuente,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,32,fila,registro.options.customData.alta_fecha,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,33,fila,registro.options.customData.calle,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,34,fila,registro.options.customData.via,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,35,fila,registro.options.customData.hidraulica,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,36,fila,registro.options.customData.economica,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,37,fila,registro.options.customData.activo,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,38,fila,registro.options.customData.comentarios,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,39,fila,registro.options.customData.etapa,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));								
									fila++;
									}
										excel.generate(nombre_reporte);
										fila = fila * 2.5;
										setTimeout(function(){resolve(true)},fila);		
							}


							else if (tipo_reporte == 'PSingulares')
							{
											var nombre_reporte= "Reporte_PSingulares_" + this.obtengo_fecha2(new Date()) + ".xlsx";
											var excel = $JExcel.new("Lato 11 #666666");			// Default font										
											// excel.set is the main function to generate content:
											// 		We can use parameter notation excel.set(sheetValue,columnValue,rowValue,cellValue,styleValue) 
											// 		Or object notation excel.set({sheet:sheetValue,column:columnValue,row:rowValue,value:cellValue,style:styleValue })
											// 		null or 0 are used as default values for undefined entries
											let mensaje = store.state.descripcion_consulta_distribuida;	
											excel.set( {sheet:0,value: "Reporte_PSingulares" } );
											excel.set({row:0,value: 35});
											excel.set({row:1,value: 40});
											excel.set({column:0,value: 10});
											excel.set(0,0,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,0,0,mensaje,excel.addStyle({align:"L C",fill: "#00823B",border:"none,none,none,none #666666",font: "Lato 14 #FFFFFF B"}));
											excel.set(0,0,1,"Id",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
											excel.set({column:1,value: 10});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,1,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,1,1,"Tipo",excel.addStyle({align:"C C",fill: "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
											excel.set({column:2,value: 10});								// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,2,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,2,1,"Elemred",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set({column:3,value: 10});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,3,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,3,1,"Tramos",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM			
											excel.set({column:4,value: 10});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,4,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,4,1,"Z_Tapa",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										
											excel.set({column:5,value: 15});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,5,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,5,1,"Inspeccion",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set({column:6,value: 15});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,6,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,6,1,"Profundidad",excel.addStyle({align:"C C",fill:"#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set({column:7,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,7,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,7,1,"Salto",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set({column:8,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,8,0,"",excel.addStyle({align:"L C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,8,1,"Z_ab",excel.addStyle({align:"C C",fill:"#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set({column:9,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,9,0,"",excel.addStyle({align:"L C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,9,1,"Alta Fuente",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set({column:10,value: 18});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,10,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,10,1,"Alta Fecha",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set({column:11,value: 16});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,11,0,"",excel.addStyle({align:"L C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,11,1,"Calle",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set({column:12,value: 16});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,12,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,12,1,"Via",excel.addStyle({align:"C C",fill:"#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
											excel.set({column:13,value: 20});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,13,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,13,1,"Contrato",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
											excel.set({column:14,value: 20});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,14,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,14,1,"Estado",excel.addStyle({align:"C C",fill:"#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));								
											excel.set({column:15,value: 16});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,15,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,15,1,"CCZ",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set({column:16,value: 16});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,16,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,16,1,"Cuenca",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
											excel.set({column:17,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,17,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,17,1,"Proyecto",excel.addStyle({align:"C C",fill: "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
											excel.set({column:18,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,18,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,18,1,"Accion",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
											excel.set({column:19,value: 48});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,19,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,19,1,"Historial",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
											excel.set({column:20,value: 25});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,20,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,20,1,"Fotos",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
											excel.set({column:21,value: 21});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,21,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,21,1,"Audios",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
											excel.set({column:22,value: 18});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,22,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,22,1,"Documentos",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
											excel.set({column:23,value: 15});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,23,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,23,1,"Comentarios",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
											excel.set({column:24,value: 15});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,24,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,24,1,"Hidraulica",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
											excel.set({column:25,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,25,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,25,1,"Economica",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
											excel.set({column:26,value: 32});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,26,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,26,1,"Activo",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
											excel.set({column:27,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
											excel.set(0,27,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
											excel.set(0,27,1,"Etapa",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
											excel.set({column:28,value: 12});									fila = 2;
																				let registros = store.state.psingulares_en_mapa;
																				var dato_lista = '';
																				var dato_num = '';
																				for (i=0;i<registros.length;i++)
																				{
																					var registro = registros[i];
																					var id_registro = registro[0];
																					excel.set({row:fila,value: 17});
																					excel.set(0,0,fila,registro.options.customData.id,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					excel.set(0,1,fila,registro.options.customData.tipo,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					excel.set(0,2,fila,registro.options.customData.elem_red,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					dato_lista = registro.options.customData.tramos;
																					dato_lista = dato_lista.replace(/\u0022/g,'');
																					dato_lista = dato_lista.replace(/\u005B/g,'');
																					dato_lista = dato_lista.replace(/\u005D/g,'');
																					excel.set(0,3,fila,dato_lista,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					dato_num = registro.options.customData.z_tapa;
																					dato_num = parseFloat(dato_num).toPrecision(3);
																					excel.set(0,4,fila,dato_num,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					excel.set(0,5,fila,registro.options.customData.inspeccion,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));

																																										
																					dato_num = registro.options.customData.profundidad;
																					dato_num = parseFloat(dato_num).toPrecision(3);
																					excel.set(0,6,fila,dato_num,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					
																					dato_num = registro.options.customData.salto;
																					dato_num = parseFloat(dato_num).toPrecision(3);
																					excel.set(0,7,fila,dato_num,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					
																					
																					dato_num = registro.options.customData.z_ab;
																					dato_num = parseFloat(dato_num).toPrecision(3);
																					excel.set(0,8,fila,dato_num,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					
																					excel.set(0,9,fila,registro.options.customData.alta_fuente,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					
																			        excel.set(0,10,fila,registro.options.customData.alta_fecha,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					excel.set(0,11,fila,registro.options.customData.calle,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					excel.set(0,12,fila,registro.options.customData.via,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					excel.set(0,13,fila,registro.options.customData.contrato,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					excel.set(0,14,fila,registro.options.customData.estado,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					excel.set(0,15,fila,registro.options.customData.ccz,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					excel.set(0,16,fila,registro.options.customData.cuenca,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					excel.set(0,17,fila,registro.options.customData.proyecto,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					excel.set(0,18,fila,registro.options.customData.accion,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));

																					let historial = JSON.parse(registro.options.customData.historial);					
																					dato = '';
																					for(var j=0; j < historial.length; j++)
																					{
																					if (j>0){ dato = dato + "\n" };	
																					let renglon = historial[j]["descripcion"] + " en " + historial[j]["fecha"].substr(0,10) + " usuario: " + historial[j]["usuario"];
																					dato = dato + renglon;
																					}		
																					excel.set(0,19,fila,dato,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));

																					let fotos = registro.options.customData.fotos;
																					fotos = fotos.replace(/\u0022/g,'');
																					fotos = fotos.replace(/\u005B/g,'');
																					fotos = fotos.replace(/\u005D/g,'');
																					excel.set(0,20,fila,fotos,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					let audios = registro.options.customData.audios;
																					audios = audios.replace(/\u0022/g,'');
																					audios = audios.replace(/\u005B/g,'');
																					audios = audios.replace(/\u005D/g,'');																				
																					excel.set(0,21,fila,audios,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));

																					excel.set(0,22,fila,registro.options.customData.documentos,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					excel.set(0,23,fila,registro.options.customData.comentarios,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					excel.set(0,24,fila,registro.options.customData.hidraulica,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					excel.set(0,25,fila,registro.options.customData.economica,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					excel.set(0,26,fila,registro.options.customData.activo,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																					excel.set(0,27,fila,registro.options.customData.etapa,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));

										fila++;
										}
											excel.generate(nombre_reporte);
											fila = fila * 2.5;
											setTimeout(function(){resolve(true)},fila);		
								}



								else if (tipo_reporte == 'Captaciones')
								{
												var nombre_reporte= "Reporte_Captaciones_" + this.obtengo_fecha2(new Date()) + ".xlsx";
												var excel = $JExcel.new("Lato 11 #666666");			// Default font										
												// excel.set is the main function to generate content:
												// 		We can use parameter notation excel.set(sheetValue,columnValue,rowValue,cellValue,styleValue) 
												// 		Or object notation excel.set({sheet:sheetValue,column:columnValue,row:rowValue,value:cellValue,style:styleValue })
												// 		null or 0 are used as default values for undefined entries
												let mensaje = store.state.descripcion_consulta_distribuida;	
												excel.set( {sheet:0,value: "Reporte_Captaciones" } );
												excel.set({row:0,value: 35});
												excel.set({row:1,value: 40});
												excel.set({column:0,value: 10});
												excel.set(0,0,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,0,0,mensaje,excel.addStyle({align:"L C",fill: "#00823B",border:"none,none,none,none #666666",font: "Lato 14 #FFFFFF B"}));
												excel.set(0,0,1,"Elemred",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
												excel.set({column:1,value: 10});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,1,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,1,1,"Id Tramo",excel.addStyle({align:"C C",fill: "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
												excel.set({column:2,value: 10});								// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,2,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,2,1,"Id Conex",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set({column:3,value: 10});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,3,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,3,1,"Tipo",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM			
												excel.set({column:4,value: 10});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,4,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,4,1,"Clase",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										
												excel.set({column:5,value: 15});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,5,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,5,1,"Dim",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set({column:6,value: 15});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,6,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,6,1,"Cant Bocas",excel.addStyle({align:"C C",fill:"#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set({column:7,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,7,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,7,1,"Alta Fuente",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set({column:8,value: 18});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,8,0,"",excel.addStyle({align:"L C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,8,1,"Alta Fecha",excel.addStyle({align:"C C",fill:"#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set({column:9,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,9,0,"",excel.addStyle({align:"L C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,9,1,"Rotacion",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set({column:10,value: 18});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,10,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,10,1,"Z Colector",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set({column:11,value: 16});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,11,0,"",excel.addStyle({align:"L C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,11,1,"Z Tapa",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set({column:12,value: 36});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,12,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,12,1,"Calle",excel.addStyle({align:"C C",fill:"#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
												excel.set({column:13,value: 20});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,13,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,13,1,"Via",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
												excel.set({column:14,value: 20});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,14,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,14,1,"Contrato",excel.addStyle({align:"C C",fill:"#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));								
												excel.set({column:15,value: 16});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,15,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,15,1,"Estado",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set({column:16,value: 16});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,16,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,16,1,"Proyecto",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
												excel.set({column:17,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,17,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,17,1,"Accion",excel.addStyle({align:"C C",fill: "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
												excel.set({column:18,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,18,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,18,1,"CCZ",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
												excel.set({column:19,value: 25});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,19,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,19,1,"Cuenca",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
												excel.set({column:20,value: 45});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,20,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,20,1,"Historial",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
												excel.set({column:21,value: 21});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,21,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,21,1,"Fotos",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
												excel.set({column:22,value: 18});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,22,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,22,1,"Audios",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
												excel.set({column:23,value: 15});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,23,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,23,1,"Documentos",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
												excel.set({column:24,value: 15});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,24,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,24,1,"Comentarios",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
												excel.set({column:25,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,25,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,25,1,"Hidraulica",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
												excel.set({column:26,value: 32});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,26,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,26,1,"Economica",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
												excel.set({column:27,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,27,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,27,1,"Activo",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
												excel.set({column:28,value: 12});										// Align cell 3-3  to RIGHT-BOTTOM
												excel.set(0,28,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
												excel.set(0,28,1,"Etapa",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
												
												
												
																	fila = 2;
																					let registros = store.state.captaciones_en_mapa;
																					var dato_lista = '';
																					var dato_num = '';
																					var lista_bocas = [];
																					for (i=0;i<registros.length;i++)
																					{
																						var registro = registros[i];
																						lista_bocas.push(registro.options.customData.elem_red);
																						var id_registro = registro[0];
																						excel.set({row:fila,value: 17});
																						excel.set(0,0,fila,registro.options.customData.elem_red,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																						excel.set(0,1,fila,registro.options.customData.id_tramo,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																						excel.set(0,2,fila,registro.options.customData.id_conex_capt,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																						excel.set(0,3,fila,registro.options.customData.tipo,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																						excel.set(0,4,fila,registro.options.customData.clase,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));

																						dato_num = registro.options.customData.dim;
																						dato_num = parseFloat(dato_num).toPrecision(3);
																						excel.set(0,5,fila,dato_num,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));

																						excel.set(0,6,fila,registro.options.customData.cant_bocas,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																						excel.set(0,7,fila,registro.options.customData.alta_fuente,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																						excel.set(0,8,fila,registro.options.customData.alta_fecha,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));

																						dato_num = registro.options.customData.rotacion;
																						dato_num = parseFloat(dato_num).toPrecision(3);
																						excel.set(0,9,fila,dato_num,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));


																						dato_num = registro.options.customData.z_col;
																						dato_num = parseFloat(dato_num).toPrecision(3);
																						excel.set(0,10,fila,dato_num,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));


																						dato_num = registro.options.customData.z_tapa;
																						dato_num = parseFloat(dato_num).toPrecision(3);
																						excel.set(0,11,fila,dato_num,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));

																						excel.set(0,12,fila,registro.options.customData.calle,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																						excel.set(0,13,fila,registro.options.customData.via,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																						excel.set(0,14,fila,registro.options.customData.contrato,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																						excel.set(0,15,fila,registro.options.customData.estado,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																						excel.set(0,16,fila,registro.options.customData.proyecto,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																						excel.set(0,17,fila,registro.options.customData.accion,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																						excel.set(0,18,fila,registro.options.customData.ccz,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																						excel.set(0,19,fila,registro.options.customData.cuenca,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));


	
																						let historial = JSON.parse(registro.options.customData.historial);					
																						dato = '';
																						for(var j=0; j < historial.length; j++)
																						{
																						if (j>0){ dato = dato + "\n" };	
																						let renglon = historial[j]["descripcion"] + " en " + historial[j]["fecha"].substr(0,10) + " usuario: " + historial[j]["usuario"];
																						dato = dato + renglon;
																						}		
																						excel.set(0,20,fila,dato,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
	
																						let fotos = registro.options.customData.fotos;
																						fotos = fotos.replace(/\u0022/g,'');
																						fotos = fotos.replace(/\u005B/g,'');
																						fotos = fotos.replace(/\u005D/g,'');
																						excel.set(0,21,fila,fotos,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																						let audios = registro.options.customData.audios;
																						audios = audios.replace(/\u0022/g,'');
																						audios = audios.replace(/\u005B/g,'');
																						audios = audios.replace(/\u005D/g,'');																				
																						excel.set(0,22,fila,audios,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
	


																						excel.set(0,23,fila,registro.options.customData.documentos,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																						excel.set(0,24,fila,registro.options.customData.comentarios,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																						excel.set(0,25,fila,registro.options.customData.hidraulica,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																						excel.set(0,26,fila,registro.options.customData.economica,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																						excel.set(0,27,fila,registro.options.customData.activo,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																						excel.set(0,28,fila,registro.options.customData.etapa,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));

											fila++;
											}
											this.$buefy.dialog.confirm({
												message: 'Agregar datos de Intervenciones?',
												onConfirm: () => {
													app.chequeo_conexion();
													if (store.state.hayconexion == true) { // si hay conexion........................................................................
													  var fd = new FormData();
													  fd.append("lista_bocas", JSON.stringify(lista_bocas));
													  var getUrl = window.location;
													  var baseUrl = getUrl.protocol + "//" + getUrl.host + "/" + getUrl.pathname.split('/')[1];
													  var phpfile = baseUrl + '/php/obtengo_intervenciones_lista.php';
													  var xhr = new XMLHttpRequest();
													  xhr.open('POST', phpfile, true);
													  xhr.onload = function () {
														var data =  this.response;
														if (data.trim() !== '')
														{
															var intervenciones = JSON.parse(data);
															excel.addSheet("Reporte_intervenciones");
															excel.set({sheet: 1,row:0,value: 35});
															excel.set({sheet: 1,row:1,value: 40});
															excel.set({sheet: 1,column:0,value: 10});
															excel.set(1,0,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
															excel.set(1,0,0,mensaje,excel.addStyle({align:"L C",fill: "#00823B",border:"none,none,none,none #666666",font: "Lato 14 #FFFFFF B"}));
															excel.set(1,0,1,"Id captacion",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));

															excel.set({sheet: 1,column:1,value: 30});										// Align cell 3-3  to RIGHT-BOTTOM
															excel.set(1,1,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
															excel.set(1,1,1,"Calle",excel.addStyle({align:"C C",fill: "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
															excel.set({sheet: 1,column:2,value: 10});										// Align cell 3-3  to RIGHT-BOTTOM
															excel.set(1,2,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
															excel.set(1,2,1,"Puerta",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
															excel.set({sheet: 1,column:3,value: 30});										// Align cell 3-3  to RIGHT-BOTTOM
															excel.set(1,3,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
															excel.set(1,3,1,"Esquina 1",excel.addStyle({align:"C C",fill: "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
															excel.set({sheet: 1,column:4,value: 30});										// Align cell 3-3  to RIGHT-BOTTOM
															excel.set(1,4,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
															excel.set(1,4,1,"Esquina2",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
															
															excel.set({sheet: 1,column:5,value: 20});										// Align cell 3-3  to RIGHT-BOTTOM
															excel.set(1,5,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
															excel.set(1,5,1,"Id intervencion",excel.addStyle({align:"C C",fill: "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
															excel.set({sheet: 1,column:6,value: 20});								// Align cell 3-3  to RIGHT-BOTTOM
															excel.set(1,6,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
															excel.set(1,6,1,"Fecha",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
															excel.set({sheet: 1,column:7,value: 15});										// Align cell 3-3  to RIGHT-BOTTOM
															excel.set(1,7,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
															excel.set(1,7,1,"Usuario",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM			
															excel.set({sheet: 1,column:8,value: 20});										// Align cell 3-3  to RIGHT-BOTTOM
															excel.set(1,8,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
															excel.set(1,8,1,"Estado ini",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										
															excel.set({sheet: 1,column:9,value: 20});										// Align cell 3-3  to RIGHT-BOTTOM
															excel.set(1,9,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
															excel.set(1,9,1,"Estado fin",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
															excel.set({sheet: 1,column:10,value: 15});										// Align cell 3-3  to RIGHT-BOTTOM
															excel.set(1,10,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
															excel.set(1,10,1,"Tipo",excel.addStyle({align:"C C",fill:"#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
															excel.set({sheet: 1,column:11,value: 20});										// Align cell 3-3  to RIGHT-BOTTOM
															excel.set(1,11,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
															excel.set(1,11,1,"Accion",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
															excel.set({sheet: 1,column:12,value: 30});										// Align cell 3-3  to RIGHT-BOTTOM
															excel.set(1,12,0,"",excel.addStyle({align:"L C",border:"none,none,none,none #333333",fill: "#00823B"}));
															excel.set(1,12,1,"Observaciones",excel.addStyle({align:"C C",fill:"#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
															excel.set({sheet: 1,column:13,value: 40});										// Align cell 3-3  to RIGHT-BOTTOM
															excel.set(1,13,0,"",excel.addStyle({align:"L C",border:"none,none,none,none #333333",fill: "#00823B"}));
															excel.set(1,13,1,"Fotos",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
															excel.set({sheet: 1,column:14,value: 40});										// Align cell 3-3  to RIGHT-BOTTOM
															excel.set(1,14,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
															excel.set(1,14,1,"Audios",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
															let registros = intervenciones;
															fila2 = 2;
															for (i=0;i<registros.length;i++)
															{
																var registro = registros[i];
																excel.set({sheet: 1,row:fila2,value: 17});
																excel.set(1,0,fila2,registro.id_captacion,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																excel.set(1,1,fila2,registro.calle,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																excel.set(1,2,fila2,registro.puerta,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																excel.set(1,3,fila2,registro.calle1,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																excel.set(1,4,fila2,registro.calle2,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));												
																excel.set(1,5,fila2,registro.id_intervencion,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																excel.set(1,6,fila2,registro.fecha,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																excel.set(1,7,fila2,registro.usuario,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																excel.set(1,8,fila2,registro.estado_ini,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																excel.set(1,9,fila2,registro.estado_fin,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																excel.set(1,10,fila2,registro.tipo,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																excel.set(1,11,fila2,registro.accion,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																excel.set(1,12,fila2,registro.observaciones,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));

																let fotos = registro.fotos;
																fotos = fotos.replace(/\u0022/g,'');
																fotos = fotos.replace(/\u005B/g,'');
																fotos = fotos.replace(/\u005D/g,'');
																excel.set(1,13,fila2,fotos,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																let audios = registro.audios;
																audios = audios.replace(/\u0022/g,'');
																audios = audios.replace(/\u005B/g,'');
																audios = audios.replace(/\u005D/g,'');																				
																excel.set(1,14,fila2,audios,excel.addStyle({align:"L C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
															fila++;
															fila2++;
															}
														}
														excel.generate(nombre_reporte);
														fila = fila * 2.5;
														setTimeout(function(){resolve(true)},fila);	
													  };
													  xhr.send(fd);
													}
													else
													{
														this.$buefy.toast.open({duration: 5000, message: 'No fue posible generar reporte por falta de conexion'});
													}
												},
												onCancel:()=> {
												excel.generate(nombre_reporte);
												fila = fila * 2.5;
												setTimeout(function(){resolve(true)},fila);		
												}
											});
									}
	


							else
							{
								setTimeout(function(){resolve(true)},0);
							}					
										


					});
									//FIN REPORTE GENERAL DE RUIDO //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
									//FINALIZO REPORTE DE RUIDO TIPO 1
			},
			bajar_archivo: function(url, filename) {
										let xhr = new XMLHttpRequest();
										xhr.open("GET", url, true);
										xhr.responseType = "blob";
										xhr.onload = function(e) {
										  if (this.status == 200) {
											const blob = this.response;
											const a = document.createElement("a");
											document.body.appendChild(a);
											const blobUrl = window.URL.createObjectURL(blob);
											a.href = blobUrl;
											a.download = filename;
											a.click();
											setTimeout(() => {
											  window.URL.revokeObjectURL(blobUrl);
											  document.body.removeChild(a);
											}, 0);
										  }
										};
										xhr.send();
			},
			cargo_geotif: function(mapa,abuf){
					parseGeoraster(abuf).then(georaster => {
					layertif = new GeoRasterLayer({
						georaster: georaster,
						opacity: 0.5,
						resolution: 200 // optional parameter for adjusting display resolution
					});
					layertif.addTo(mapa);
					mapa.fitBounds(layertif.getBounds());
					layertif.bringToFront();
					layertif.setZIndex(100);				
				});
			},			
			genero_kml: function(tipo_reporte){
				return new Promise(resolve => {
										//INICIO kmz //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
										//obtengo datos a reportar
										////////////////////////////
						if (tipo_reporte == 'Colectores')
						{					
										var nombre_kml = "Reporte_Colectores_" + this.obtengo_fecha2(new Date()) + ".kml";	
										var registros = store.state.tramos_en_mapa;
										var latpromedio = 0;
										var lonpromedio = 0;
										var cantidad = 0;
										var registro;
										for (var s=0;s<registros.length;s++)
										{
										registro = registros[s];
										var geom = registro.options.customData.geom;
										var solocoord = geom.substring(11);
										solocoord = solocoord.slice(0,-1);
										var latlngs1 = solocoord.split(",");
										var elemento = (latlngs1[0].split(" "));
											latpromedio = latpromedio + Number(elemento[1]);									
											lonpromedio = lonpromedio + Number(elemento[0]);									
											cantidad++;
										}
										latpromedio = latpromedio / cantidad;
										lonpromedio = lonpromedio / cantidad;

							
									var kml = '<?xml version="1.0" encoding="UTF-8"?>\n';
									kml = kml + '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">\n';
									kml = kml + '<Document><name>Reporte de Colectores</name>\n';
									
				
									kml = kml + '<LookAt>';
									kml = kml + '<longitude>' + lonpromedio +'</longitude>';
									kml = kml + '<latitude>' + latpromedio + '</latitude>\n';
									kml = kml + '<altitude>0</altitude>';
									kml = kml + '<heading>0.01954018220427638</heading>\n';
									kml = kml + '<tilt>1.030498795460985</tilt>';
									kml = kml + '<range>504.7072132194871</range>';
									kml = kml + '<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>';
									kml = kml + '</LookAt>\n';




									kml = kml + '<Style id="CLASE1">';
									kml = kml + '<LineStyle>';
									kml = kml + '<color>ff6d1fac</color>';
									kml = kml + '<width>8</width>';
									kml = kml + '</LineStyle>';
									kml = kml + '<PolyStyle>';
									kml = kml + '<color>ff6d1fac</color>';
									kml = kml + '</PolyStyle>';
									kml = kml + '</Style>\n';
									
									
									kml = kml + '<Style id="CLASE2">';
									kml = kml + '<LineStyle>';
									kml = kml + '<color>ffEB1F15</color>';
									kml = kml + '<width>8</width>';
									kml = kml + '</LineStyle>';
									kml = kml + '<PolyStyle>';
									kml = kml + '<color>ffEB1F15</color>';
									kml = kml + '</PolyStyle>';
									kml = kml + '</Style>\n';
									
									
									kml = kml + '<Style id="CLASE3">';
									kml = kml + '<LineStyle>';
									kml = kml + '<color>fff417e9</color>';
									kml = kml + '<width>8</width>';
									kml = kml + '</LineStyle>';
									kml = kml + '<PolyStyle>';
									kml = kml + '<color>fff417e9</color>';
									kml = kml + '</PolyStyle>';
									kml = kml + '</Style>\n';
									
									
									kml = kml + '<Style id="CLASE4">';
									kml = kml + '<LineStyle>';
									kml = kml + '<color>ff48C919</color>';
									kml = kml + '<width>8</width>';
									kml = kml + '</LineStyle>';
									kml = kml + '<PolyStyle>';
									kml = kml + '<color>ff48C919</color>';
									kml = kml + '</PolyStyle>';
									kml = kml + '</Style>\n';
									
									
									kml = kml + '<Style id="CLASE5">';
									kml = kml + '<LineStyle>';
									kml = kml + '<color>ff800080</color>';
									kml = kml + '<width>8</width>';
									kml = kml + '</LineStyle>';
									kml = kml + '<PolyStyle>';
									kml = kml + '<color>ff800080</color>';
									kml = kml + '</PolyStyle>';
									kml = kml + '</Style>\n';
									
									
									kml = kml + '<Style id="CLASE6">';
									kml = kml + '<LineStyle>';
									kml = kml + '<color>ff0080ff</color>';
									kml = kml + '<width>8</width>';
									kml = kml + '</LineStyle>';
									kml = kml + '<PolyStyle>';
									kml = kml + '<color>ff0080ff</color>';
									kml = kml + '</PolyStyle>';
									kml = kml + '</Style>\n';


									kml = kml + '<Style id="CLASE7">';
									kml = kml + '<LineStyle>';
									kml = kml + '<color>ffff00ff</color>';
									kml = kml + '<width>8</width>';
									kml = kml + '</LineStyle>';
									kml = kml + '<PolyStyle>';
									kml = kml + '<color>ffff00ff</color>';
									kml = kml + '</PolyStyle>';
									kml = kml + '</Style>\n';



									kml = kml + '<Folder>';
									kml = kml + '<name>Colectores IM</name>';
									kml = kml + '<open>1</open>"';
									kml = kml + '"<visibility>1</visibility>\n';
						for (var i=0;i<registros.length;i++)
							{
								var registro = registros[i];

								var geom = registro.options.customData.geom;
								var solocoord = geom.substring(11);
								solocoord = solocoord.slice(0,-1);
								var latlngs1 = solocoord.split(",");
								var latlngs = [];
								for (var j=0; j<latlngs1.length; j++)
								{
									var elemento = (latlngs1[j].split(" "));
									latlngs.push(elemento.reverse());
								}

								var id_registro = registro[0];
						let estilo = 'CLASE1';
						let clave = registro.options.customData.tipotra;
						switch (clave){
								case "53":
									estilo = "CLASE1";
									break;
									case "50":
										estilo = "CLASE2";
									break;
									case "51":
										estilo = "CLASE3";
									break;
									case "49":
										estilo = "CLASE4";
									break;
									default:						
										estilo = "CLASE7";
										break;
						}

							
																	kml = kml + '<Placemark><name>Rangos por tipo de tramo</name><LookAt>\n';
																	kml = kml + '<longitude>' + latlngs[0][1] + '</longitude>\n';
																	kml = kml + '<latitude>' + latlngs[0][0] + '</latitude>\n';
																	kml = kml + '<altitude>0</altitude>\n';
																	kml = kml + '<range>1237.205460638887</range><gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode></LookAt>\n';
																	kml = kml + '<styleUrl>#' + estilo + '</styleUrl>\n';
											kml = kml + '<description><![CDATA[<table border="0"> <tr><td> <h2 width="620" style="color:darkbrown;text-align:center">\n';
																	kml = kml + 'Elemred: ' + registro.options.customData.elemred + '</table><table border="0">\n';
																	kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">';
																	kml = kml + 'IdPSaa: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + registro.options.customData.id_psig_aa  + '</td></tr>';
																	kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">';
																	kml = kml + 'IDPSab: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + registro.options.customData.id_psig_ab  + '</td></tr>';
																	kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';

																	let dim1 = registro.options.customData.dim1;
																	dim1 = parseFloat(dim1).toPrecision(3);
																	kml = kml + 'Dim1: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + dim1 + '</td></tr>';
																	kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';


																	let dim2 = registro.options.customData.dim2;
																	dim2 = parseFloat(dim2).toPrecision(3);
																	kml = kml + 'Dim2: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + dim2 + '</td></tr>';
																	kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';

																	
																	let longitud = registro.options.customData.longitud;
																	longitud = parseFloat(longitud).toPrecision(3);
																	kml = kml + 'Longitud: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + longitud + '</td></tr>';
																	kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';


																	let pendiente = registro.options.customData.pendiente;
																	pendiente = parseFloat(pendiente).toPrecision(3);
																	kml = kml + 'Pendiente: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + pendiente + '</td></tr>';
																	kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';

																	let zarriba = registro.options.customData.zarriba;
																	zarriba = parseFloat(zarriba).toPrecision(3);
																	kml = kml + 'Zarriba: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + zarriba + '</td></tr>';
																	kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';

																	let zabajo = registro.options.customData.zabajo;
																	zabajo = parseFloat(zabajo).toPrecision(3);
																	kml = kml + 'Zabajo: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + zabajo + '</td></tr>';
																	kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';

																	let ztarriba = registro.options.customData.z_tapa_aa;
																	ztarriba = parseFloat(ztarriba).toPrecision(3);
																	kml = kml + 'Z Tapa arriba: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + ztarriba + '</td></tr>';
																	kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';

																	let ztabajo = registro.options.customData.z_tapa_ab;
																	ztabajo = parseFloat(ztabajo).toPrecision(3);
																	kml = kml + 'Z tapa abajo: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + ztabajo + '</td></tr>';
																	kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';


																	kml = kml + 'Tipo: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + registro.options.customData.tipotra  + '</td></tr>';
																	kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';

																	kml = kml + 'Seccion: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + registro.options.customData.tiposec  + '</td></tr>';
																	kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';

								
																	kml = kml + 'Comentarios: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + registro.options.customData.comentarios  + '</td></tr>';
																	kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';

																	kml = kml + 'Etapa: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + registro.options.customData.etapa  + '</td></tr>';
																	kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';


																	kml = kml + '</table><p><font color="darkblue">IM</font></p> ]]></description>\n';	
																	kml = kml + '<LineString>\n';


																	kml = kml + '<extrude>1</extrude>';
																	kml = kml + '<tessellate>1</tessellate>';
																	kml = kml + '<altitudeMode>relativeToGround</altitudeMode>\n';
																	kml = kml + '<coordinates>\n';

																	for (var j=0; j<latlngs.length; j++)
																	{
																		kml = kml + latlngs[j][1] + "," + latlngs[j][0] + ",2 "; 
																	}
																	kml = kml + '</coordinates></LineString></Placemark>\n';
															}
																kml = kml + '</Folder></Document></kml>\n';
															
															
																var data = new Blob([kml], {type: 'text/plain'});
																textFile = window.URL.createObjectURL(data);
																this.bajar_archivo(textFile, nombre_kml);

										}


						if (tipo_reporte == 'PSingulares')
										{					
														var nombre_kml = "Reporte_Puntos_Singulares_" + this.obtengo_fecha2(new Date()) + ".kml";	
														var registros = store.state.psingulares_en_mapa;
														var latpromedio = 0;
														var lonpromedio = 0;
														var cantidad = 0;
														var registro;
														for (var s=0;s<registros.length;s++)
														{
														registro = registros[s];
															latpromedio = latpromedio + Number(registro.options.customData.lat);									
															lonpromedio = lonpromedio + Number(registro.options.customData.lon);									
															cantidad++;
														}
														latpromedio = latpromedio / cantidad;
														lonpromedio = lonpromedio / cantidad;

											
													var kml = '<?xml version="1.0" encoding="UTF-8"?>\n';
													kml = kml + '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">\n';
													kml = kml + '<Document><name>Reporte de Puntos Singulares</name>\n';
													
								
													kml = kml + '<LookAt>';
													kml = kml + '<longitude>' + lonpromedio +'</longitude>';
													kml = kml + '<latitude>' + latpromedio + '</latitude>\n';
													kml = kml + '<altitude>0</altitude>';
													kml = kml + '<heading>0.1018049974848869</heading>\n';
													kml = kml + '<tilt>7.065303438862514</tilt>';
													kml = kml + '<range>7502.187684726964</range>';
													kml = kml + '<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>';
													kml = kml + '</LookAt>\n';
				
														let color_borde = 'ffcab8b4';
														let color_fondo = 'ffcab8b4';
														let espesor_borde = '1.3';
														let escala = '1.2';

													kml = kml + '<StyleMap id="msn_ylw-pushpin">\n';
													kml = kml + '<Pair>\n';
													kml = kml + '<key>normal</key>\n';
													kml = kml + '<styleUrl>#sn_ylw-pushpin</styleUrl>\n';
													kml = kml + '</Pair>\n';
													kml = kml + '<Pair>\n';
													kml = kml + '<key>highlight</key>\n';
													kml = kml + '<styleUrl>#sh_ylw-pushpin</styleUrl>\n';
													kml = kml + '</Pair>\n';
													kml = kml + '</StyleMap>\n';
													kml = kml + '<Style id="sh_ylw-pushpin">\n';
													kml = kml + '<IconStyle>\n';
													kml = kml + '<scale>' + escala +'</scale>\n';
													kml = kml + '</IconStyle>\n';
													kml = kml + '<BalloonStyle>\n';
													kml = kml + '</BalloonStyle>\n';
													kml = kml + '<LineStyle>\n';
													kml = kml + '<color>' + color_borde + '</color>\n';
													kml = kml + '<width>' + espesor_borde + '</width>\n';
													kml = kml + '</LineStyle>\n';
													kml = kml + '<PolyStyle>\n';
													kml = kml + '<color>' + color_fondo + '</color>\n';
													kml = kml + '</PolyStyle>\n';
													kml = kml + '</Style>\n';
													kml = kml + '<Style id="sn_ylw-pushpin">\n';
													kml = kml + '<BalloonStyle>\n';
													kml = kml + '</BalloonStyle>\n';
													kml = kml + '<LineStyle>\n';
													kml = kml + '<color>' + color_borde + '</color>\n';
													kml = kml + '<width>' + espesor_borde + '</width>\n';
													kml = kml + '</LineStyle>\n';
													kml = kml + '<PolyStyle>\n';
													kml = kml + '<color>' + color_borde + '</color>\n';
													kml = kml + '</PolyStyle>\n';
													kml = kml + '</Style>\n';


     												kml = kml + '<Folder>';
													kml = kml + '<name>Puntos Singulares IM</name>';
													kml = kml + '<open>1</open>"';
													kml = kml + '"<visibility>1</visibility>\n';


													kml = kml + '<Region>' ;	
													kml = kml +  '<LatLonAltBox>' ;	
													kml = kml +  '<north>-32</north>' ;
													kml = kml +  '<south>-35</south>' ;	
													kml = kml +  '<east>-55</east>' ;
													kml = kml +  '<west>-58</west>' ;
													kml = kml +  '<minAltitude>0</minAltitude>' ;	
													kml = kml +  '<maxAltitude>10000</maxAltitude>' ;
													kml = kml + '<altitudeMode>absolute</altitudeMode>' ;
													kml = kml + '</LatLonAltBox>' ;
													kml = kml + '<Lod>' ;
													kml = kml + '<minLodPixels>50000</minLodPixels>' ;
													kml = kml + '<maxLodPixels>-1</maxLodPixels>' ;
													kml = kml + '<minFadeExtent>0</minFadeExtent>' ;
													kml = kml + '<maxFadeExtent>0</maxFadeExtent>' ;
													kml = kml + '</Lod>' ;
													kml = kml + '</Region>' ;




								for (var i=0;i<registros.length;i++)
								{
												registro = registros[i];
				
											
																					kml = kml + '<Placemark><name></name>\n';																		
																					kml = kml + '<styleUrl>#msn_ylw-pushpin</styleUrl>\n';
																					kml = kml + '<description><![CDATA[<table border="0"> <tr><td> <h2 width="620" style="color:darkbrown;text-align:center">\n';
																					kml = kml + 'Elemred: ' + registro.options.customData.elem_red + '</table><table border="0">\n';
																					kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">';
																					kml = kml + 'Tipo: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + registro.options.customData.tipo  + '</td></tr>';
																					kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">';
																					kml = kml + 'Tramos: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + registro.options.customData.tramos  + '</td></tr>';
																					kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';
				
																					let val = registro.options.customData.z_tapa;
																					val = parseFloat(val).toPrecision(3);
																					kml = kml + 'Ztapa: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + val + '</td></tr>';
																					kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';
				
																					val = registro.options.customData.profundidad;
																					val = parseFloat(val).toPrecision(3);
																					kml = kml + 'Profundidad: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + val + '</td></tr>';
																					kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';
				
																					val = registro.options.customData.salto;
																					val = parseFloat(val).toPrecision(3);
																					kml = kml + 'Salto: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + val + '</td></tr>';
																					kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';
				
																					val = registro.options.customData.z_ab;
																					val = parseFloat(val).toPrecision(3);
																					kml = kml + 'Zamp ab: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + val + '</td></tr>';
																					kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';
				
											
																					kml = kml + 'Comentarios: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + registro.options.customData.comentarios  + '</td></tr>';
																					kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';
				
																					kml = kml + 'Etapa: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + registro.options.customData.etapa  + '</td></tr>';
																					kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';
				
				
																					kml = kml + '</table><p><font color="darkblue">IM</font></p> ]]></description>\n';	
																					kml = kml + '<Polygon><tessellate>1</tessellate><extrude>1</extrude><altitudeMode>relativeToGround</altitudeMode>\n<outerBoundaryIs><LinearRing><coordinates>\n';

																					kml = kml + this.obtengo_kml_circulo(registro.options.customData.lat, registro.options.customData.lon,0.000012,3); 

																					kml = kml + '\n</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark>\n';
																			}
																				kml = kml + '</Folder></Document></kml>\n';
																			
																			
																				var data = new Blob([kml], {type: 'text/plain'});
																				textFile = window.URL.createObjectURL(data);
																				this.bajar_archivo(textFile, nombre_kml);
				
														}


						if (tipo_reporte == 'Captaciones')
														{					
																		var nombre_kml = "Reporte_Captaciones_" + this.obtengo_fecha2(new Date()) + ".kml";	
																		var registros = store.state.captaciones_en_mapa;
																		var latpromedio = 0;
																		var lonpromedio = 0;
																		var cantidad = 0;
																		var registro;
																		for (var s=0;s<registros.length;s++)
																		{
																		registro = registros[s];
																			latpromedio = latpromedio + Number(registro.options.customData.lat);									
																			lonpromedio = lonpromedio + Number(registro.options.customData.lon);									
																			cantidad++;
																		}
																		latpromedio = latpromedio / cantidad;
																		lonpromedio = lonpromedio / cantidad;
				
															
																	var kml = '<?xml version="1.0" encoding="UTF-8"?>\n';
																	kml = kml + '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">\n';
																	kml = kml + '<Document><name>Reporte de Captaciones</name>\n';
																	
												
																	kml = kml + '<LookAt>';
																	kml = kml + '<longitude>' + lonpromedio +'</longitude>';
																	kml = kml + '<latitude>' + latpromedio + '</latitude>\n';
																	kml = kml + '<altitude>0</altitude>';
																	kml = kml + '<heading>0.1018049974848869</heading>\n';
																	kml = kml + '<tilt>7.065303438862514</tilt>';
																	kml = kml + '<range>7502.187684726964</range>';
																	kml = kml + '<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>';
																	kml = kml + '</LookAt>\n';
								
								
																	let color_borde = 'ffffba52';
																	let color_fondo = 'ffffba52';
																	let espesor_borde = '1';
																	let escala = '1.5';
			
																kml = kml + '<StyleMap id="msn_ylw-pushpin">\n';
																kml = kml + '<Pair>\n';
																kml = kml + '<key>normal</key>\n';
																kml = kml + '<styleUrl>#sn_ylw-pushpin</styleUrl>\n';
																kml = kml + '</Pair>\n';
																kml = kml + '<Pair>\n';
																kml = kml + '<key>highlight</key>\n';
																kml = kml + '<styleUrl>#sh_ylw-pushpin</styleUrl>\n';
																kml = kml + '</Pair>\n';
																kml = kml + '</StyleMap>\n';
																kml = kml + '<Style id="sh_ylw-pushpin">\n';
																kml = kml + '<IconStyle>\n';
																kml = kml + '<scale>' + escala +'</scale>\n';
																kml = kml + '</IconStyle>\n';
																kml = kml + '<BalloonStyle>\n';
																kml = kml + '</BalloonStyle>\n';
																kml = kml + '<LineStyle>\n';
																kml = kml + '<color>' + color_borde + '</color>\n';
																kml = kml + '<width>' + espesor_borde + '</width>\n';
																kml = kml + '</LineStyle>\n';
																kml = kml + '<PolyStyle>\n';
																kml = kml + '<color>' + color_fondo + '</color>\n';
																kml = kml + '</PolyStyle>\n';
																kml = kml + '</Style>\n';
																kml = kml + '<Style id="sn_ylw-pushpin">\n';
																kml = kml + '<BalloonStyle>\n';
																kml = kml + '</BalloonStyle>\n';
																kml = kml + '<LineStyle>\n';
																kml = kml + '<color>' + color_borde + '</color>\n';
																kml = kml + '<width>' + espesor_borde + '</width>\n';
																kml = kml + '</LineStyle>\n';
																kml = kml + '<PolyStyle>\n';
																kml = kml + '<color>' + color_borde + '</color>\n';
																kml = kml + '</PolyStyle>\n';
																kml = kml + '</Style>\n';
			


								
						
																	kml = kml + '<Folder>';
																	kml = kml + '<name>Puntos Singulares IM</name>';
																	kml = kml + '<open>1</open>"';
																	kml = kml + '"<visibility>1</visibility>\n';
				
				
																	kml = kml + '<Region>' ;	
																	kml = kml + '<LatLonAltBox>' ;	
																	kml = kml + '<north>-32</north>' ;
																	kml = kml + '<south>-35</south>' ;	
																	kml = kml + '<east>-55</east>' ;
																	kml = kml + '<west>-58</west>' ;
																	kml = kml + '<minAltitude>0</minAltitude>' ;	
																	kml = kml + '<maxAltitude>10000</maxAltitude>' ;
																	kml = kml + '<altitudeMode>absolute</altitudeMode>' ;
																	kml = kml + '</LatLonAltBox>' ;
																	kml = kml + '<Lod>' ;
																	kml = kml + '<minLodPixels>50000</minLodPixels>' ;
																	kml = kml + '<maxLodPixels>-1</maxLodPixels>' ;
																	kml = kml + '<minFadeExtent>0</minFadeExtent>' ;
																	kml = kml + '<maxFadeExtent>0</maxFadeExtent>' ;
																	kml = kml + '</Lod>' ;
																	kml = kml + '</Region>' ;
				
				
				
				
												for (var i=0;i<registros.length;i++)
												{
																registro = registros[i];
								
										
															
																									kml = kml + '<Placemark><name></name>\n';																		
																									kml = kml + '<styleUrl>#msn_ylw-pushpin</styleUrl>\n';
																									kml = kml + '<description><![CDATA[<table border="0"> <tr><td> <h2 width="620" style="color:darkbrown;text-align:center">\n';
																									kml = kml + 'Elemred: ' + registro.options.customData.elem_red + '</table><table border="0">\n';
																									kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">';
																									kml = kml + 'Id Tramo: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + registro.options.customData.id_tramo  + '</td></tr>';
																									kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">';
																									kml = kml + 'Id Conex Capta: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + registro.options.customData.id_conex_capt  + '</td></tr>';
																									kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">';
																									kml = kml + 'Tipo: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + registro.options.customData.tipo  + '</td></tr>';
																									kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">';
																									kml = kml + 'Clase: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + registro.options.customData.clase  + '</td></tr>';
																									kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';
																									kml = kml + 'Bocas: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + registro.options.customData.cant_bocas  + '</td></tr>';
																									kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">';
																									kml = kml + 'Dim: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + registro.options.customData.dim  + '</td></tr>';
																									kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">';


																									let val = registro.options.customData.z_tapa;
																									val = parseFloat(val).toPrecision(3);
																									kml = kml + 'Ztapa: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + val + '</td></tr>';
																									kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';
								

																									val = registro.options.customData.z_col;
																									val = parseFloat(val).toPrecision(3);
																									kml = kml + 'Zcol: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + val + '</td></tr>';
																									kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';
								
																									kml = kml + 'Comentarios: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + registro.options.customData.comentarios  + '</td></tr>';
																									kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';
								
																									kml = kml + 'Etapa: </th><td width=\"450\" style=\"background-color:khaki;text-align:right">' + registro.options.customData.etapa  + '</td></tr>';
																									kml = kml + '<tr><th width="220" style="background-color:darkgrey;text-align:left">\n';
																									kml = kml + '</table><p><font color="darkblue">IM</font></p> ]]></description>\n';	

																									kml = kml + '<Polygon><tessellate>1</tessellate><extrude>1</extrude><altitudeMode>relativeToGround</altitudeMode>\n<outerBoundaryIs><LinearRing><coordinates>\n';
																									kml = kml + this.obtengo_kml_circulo(registro.options.customData.lat, registro.options.customData.lon,0.000014,3); 
																									kml = kml + '\n</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark>\n';

																							}
																								kml = kml + '</Folder></Document></kml>\n';
																							
																							
																								var data = new Blob([kml], {type: 'text/plain'});
																								textFile = window.URL.createObjectURL(data);
																								this.bajar_archivo(textFile, nombre_kml);
								
																		}

										 resolve(true);										
					  });
					

										
									

			},
			genero_reporte_excel_log: function(){
				return new Promise(resolve => {
										var nombre_reporte= "Reporte_Log_Red_Sanea_" + this.obtengo_fecha2(new Date()) + ".xlsx";
										var excel = $JExcel.new("Lato 11 #666666");			// Default font
										excel.set( {sheet:0,value: "Reporte_Log_Red_Sanea" } );
					
										
										excel.set({row:0,value: 35});
										excel.set({row:1,value: 40});
									
										excel.set({column:0,value: 15});
										excel.set(0,0,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,0,0,"Reporte LOG de Aplicación de Conexiones",excel.addStyle({align:"L C",fill: "#00823B",border:"none,none,none,none #666666",font: "Lato 14 #FFFFFF B"}));
										excel.set(0,0,1,"Id",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:1,value: 30});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,1,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,1,1,"Tipo",excel.addStyle({align:"C C",fill: "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));
										excel.set({column:2,value: 20});								// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,2,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,2,1,"Fecha",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set({column:3,value: 20});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,3,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,3,1,"Usuario",excel.addStyle({align:"C C",fill:  "#E2EFDA",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										// Align cell 3-3  to RIGHT-BOTTOM			
										excel.set({column:4,value: 70});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,4,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,4,1,"Descripcion",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										
										excel.set({column:5,value: 30});										// Align cell 3-3  to RIGHT-BOTTOM
										excel.set(0,4,0,"",excel.addStyle({align:"C C",border:"none,none,none,none #333333",fill: "#00823B"}));
										excel.set(0,4,1,"Elemento",excel.addStyle({align:"C C",fill: "#FFFFFF",border:"none,none,none,none #666666",font: "Lato 12 #666666 B"}));										
																															
																			fila = 2;
																			let registros = store.state.datos_log;
																			for (i=0;i<registros.length;i++)
																			{
																				var registro = registros[i];
																				var id_registro = registro[0];
																				excel.set({row:fila,value: 17});
																				excel.set(0,0,fila,registro.id_elemento,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,1,fila,registro.tipo,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,2,fila,registro.fecha,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,3,fila,registro.usuario,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,4,fila,registro.descripcion,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																				excel.set(0,5,fila,registro.tipo_elemento,excel.addStyle({align:"C C",border:"none,none,none,thin #333333",font: "Lato 10 #666666"}));
																			fila++;
																			}
										excel.generate(nombre_reporte);
										fila = fila * 2.5;
										setTimeout(function(){resolve(true)},fila);										
					});
			}

	/*
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
FIN DE METODOS METODOS METODOS METODOS METODOS METODOS METODOS METODOS METODOS METODOS METODOS METODOS METODOS METODOS METODOS METODOS METODOS METODOS
	*/  
}
})
/*                                              FIN INSTANCIA DE VUE                                                    */


//FUNCIONES GLOBALES
window.addEventListener('offline', () => {store.state.hayconexion = false});
window.addEventListener('online', () => { 
	console.log("se retoma conexion");
	store.state.hayconexion = true;
});

var forzar_carga_registros = false;

function obtengo_nuevo_id(){
	var date = new Date();
	var p1 = String(date.getYear());
	if (date.getMonth() < 10)
	{
		var p2 = "0" + String(date.getMonth());
	}else
	{
		var p2 = String(date.getMonth());
	}
	if (date.getDate() < 10)
	{
		var p3 = "0" + String(date.getDate());
	}else
	{
		var p3 = String(date.getDate());
	}
	if (date.getHours() < 10)
	{
		var p4 = "0" + String(date.getHours());
	}else
	{
		var p4 = String(date.getHours());
	}
	if (date.getMinutes() < 10)
	{
		var p5 = "0" + String(date.getMinutes());
	}else
	{
		var p5 = String(date.getMinutes());
	}
	var id_registro = p1 + p2 + p3 + p4 + p5 + String(parseInt(0 + (Math.random() * 500)));
	return id_registro;
}













