1/* 2 * Addax Software Development, S.A. Copyright (c) 2019. 3 */ 4 5function mostrarMensaje(titulo, mensaje) 6{ 7 swal(titulo, mensaje); 8 console.log("mensaje"); 9} 10 11function reproyectarPunto(strOrigen, strDestino, x, y) 12{ 13 var reproyectador = proj4(strOrigen, strDestino); 14 var resultado = reproyectador.forward([Number(x), Number(y)]); 15 var mensaje = 'x: '+resultado[0] +'\ny: '+ resultado[1]; 16 17 //swal("Resultado de reproyección de coordenadas", mensaje); 18 mostrarMensaje("Resultado de reproyección de coordenadas", mensaje); 19 20} 21 22function convertirGradosADecimal(gradosstr){ 23 if(!gradosstr || gradosstr ==''){ 24 return gradosstr; 25 } 26 if( 27 gradosstr.indexOf("°") == -1 28 || gradosstr.indexOf("'") == -1 29 || gradosstr.indexOf('"') == -1 30 ){ 31 //cualquier que falte no sirve. 32 swal('Lectura de grados decimal', 'El valor de grados decimal no es correcto, verifique que el mismo se ajuste al ejemplo siguiente: -84°14\'46.86" y 10°19\'20.85" (Nóte que los caracteres son comilla simple y comilla doble)', 'error'); 33 return false; 34 } 35 36 37 var resD = gradosstr.split("°"); 38 var d = resD[0].trim() * 1; 39 40 var resM = resD[1].split("'"); 41 var m = resM[0].trim() * 1; 42 43 var resS = resM[1].split('"'); 44 var s = resS[0].trim() * 1; 45 46 if(d < 0){ 47 //negativos 48 m = -1*m; 49 s = -1*s; 50 } 51 var decimal = d + m/60 + s/3600; 52 53 return decimal; 54 55} 56 57function convertirDecimalAGrados(decimal){ 58 var d = parseInt(decimal) ; 59 var m = parseInt((decimal - d) * 60) ; 60 var s = (decimal - d - m/60) * 3600; 61 62 if(d < 0){ 63 //negativos 64 m = -1*m; 65 s = -1*s; 66 } 67 68 var valor = d+'° ' +m+"' " +s+'"'; 69 return valor; 70} 71 72 73 74function setMascarasCoordenadas (selectorX, selectorY, proyeccion) 75{ 76 // console.log("Sist de coord cambió a -> " + proyeccion); 77 // console.log((typeof selector) + ": " + selector); 78 79 // Es indispensable que en el nombre se ponga latitud o longitud para discriminar cuál es el campo 80 81 if(proyeccion == "CRTM05" || proyeccion=="EPSG:5367"){ 82 var maskStringX = "9{1,6}[.9{1,4}]"; 83 var maskStringY = "9{1,7}[.9{1,4}]"; 84 $(selectorX).inputmask(maskStringX); 85 $(selectorY).inputmask(maskStringY); 86 $('#coordenadaX').attr("placeholder", "ej: 492997.111"); 87 $('#coordenadaY').attr("placeholder", "ej: 1099308.021"); 88 } 89 if(proyeccion == "CR-SIRGAS / CRTM05" ||proyeccion == "CR-SIRGAS" || proyeccion=="EPSG:8908"){ 90 var maskStringX = "9{1,6}[.9{1,4}]"; 91 var maskStringY = "9{1,7}[.9{1,4}]"; 92 $(selectorX).inputmask(maskStringX); 93 $(selectorY).inputmask(maskStringY); 94 $('#coordenadaX').attr("placeholder", "ej: 491187.527"); 95 $('#coordenadaY').attr("placeholder", "ej: 1098498.068"); 96 97 } 98 if(proyeccion == "WGS84 (Decimal)" || proyeccion=="EPSG:4326"){ 99 var maskStringX = "-9{2}[.9{1,6}]"; 100 var maskStringY = "9{2}[.9{1,6}]"; 101 102 $(selectorX).inputmask(maskStringX); 103 $(selectorY).inputmask(maskStringY); 104 $('#coordenadaX').attr("placeholder", "ej: -84.06386"); 105 $('#coordenadaY').attr("placeholder", "ej: 09.94179"); 106 } 107 108 if(proyeccion == "WGS84 (G/M/S)" || proyeccion=="EPSG:4326Z"){ 109 110 var maskStringX = "-9{2}°9{1,2}'9{1,2}[.9{1,4}]\""; 111 var maskStringY = "9{2}°9{1,2}'9{1,2}[.9{1,4}]\""; 112 $(selectorX).inputmask({mask: maskStringX, greedy: false}); 113 $(selectorY).inputmask({mask: maskStringY, greedy: false}); 114 115 $('#coordenadaX').attr("placeholder", "ej: -84°3'49.921\""); 116 $('#coordenadaY').attr("placeholder", "ej: 09°56'30.474\""); 117 } 118 if(proyeccion == "Lambert Norte" || proyeccion=="EPSG:5456"){ 119 var maskStringX = "9{1,6}[.9{1,4}]"; 120 var maskStringY = "9{1,6}[.9{1,4}]"; 121 122 $(selectorX).inputmask(maskStringX); 123 $(selectorY).inputmask(maskStringY); 124 125 126 $('#coordenadaX').attr("placeholder", "ej: 529336.59"); 127 $('#coordenadaY').attr("placeholder", "ej: 213939.61"); 128 } 129 130 if(proyeccion == "Lambert Sur" || proyeccion=="EPSG:5457"){
131 var maskStringX = "9{1,6}[.9{1,4}]"; 132 var maskStringY = "9{1,6}[.9{1,4}]"; 133 134 $(selectorX).inputmask(maskStringX); 135 $(selectorY).inputmask(maskStringY); 136 137 138 $('#coordenadaX').attr("placeholder", "ej: 456226.19"); 139 $('#coordenadaY').attr("placeholder", "ej: 432328.83"); 140 } 141 142 return false; 143 144 145} 146 147function initReproyeccionBox() { 148 // $(".numeric").numeric({ decimal : ".", negative : true, scale: 6 }); 149 { 150 //aplicar la máscara :) 151 152 $('#selectOrigen').change(function () { 153 var proyeccion = $(this).val(); 154 155 var selectorX = "#coordenadaX"; 156 var selectorY = "#coordenadaY"; 157 setMascarasCoordenadas(selectorX, selectorY, proyeccion); 158 159 160 }); 161 162 $('#selectOrigenMovil').change(function () { 163 var proyeccion = $(this).val(); 164 165 var selectorX = "#coordenadaX"; 166 var selectorY = "#coordenadaY"; 167 setMascarasCoordenadas(selectorX, selectorY, proyeccion); 168 169 170 }); 171 172 173 } 174 175 $("#botonReproyectar").click(function (e) { 176 177 var x = document.getElementById("coordenadaX").value; 178 var y = document.getElementById("coordenadaY").value; 179 180 var origen = document.getElementById("selectOrigen"); 181 var strOrigen = origen.options[origen.selectedIndex].value; 182 183 var destino = document.getElementById("selectDestino"); 184 var strDestino = destino.options[destino.selectedIndex].value; 185 186 console.log('origen '+strOrigen+' destino '+strDestino+' x '+x+' y '+y); 187 console.log(origen); 188 console.log(destino); 189 190 if(strOrigen != strDestino) 191 { 192 if((strOrigen == 'EPSG:8908')){ 193 //Primero hay que pasar por crtm05 194 var reproyectador = proj4(strOrigen, 'EPSG:5367'); 195 console.log("Primero x: " + x + " y Y: " + y + " origen: " + strOrigen); 196 var resultado = reproyectador.forward([Number(x), Number(y)]); 197 x = resultado[0]; 198 y = resultado[1]; 199 console.log("Entra a x: " + x + " y Y: " + y); 200 strOrigen = 'EPSG:5367';//para que haga el siguiente salto. 201 } 202 if((strOrigen == 'EPSG:4326') && (strDestino == 'EPSG:4326Z')) //DD to DMS 203 { 204 x = convertirDecimalAGrados(x); 205 y = convertirDecimalAGrados(y); 206 207 console.log([x, y]); 208 209 var mensaje = 'x: '+x +'\ny: '+ y; 210 211 mostrarMensaje("Resultado de reproyección de coordenadas", mensaje); 212 } 213 else if((strOrigen == 'EPSG:4326Z') && (strDestino == 'EPSG:4326')) //DMS to DD 214 { 215 x = convertirGradosADecimal(x); 216 y = convertirGradosADecimal(y); 217 218 var mensaje = 'x: '+x +'\ny: '+ y; 219 220 mostrarMensaje("Resultado de reproyección de coordenadas", mensaje); 221 } 222 else 223 { 224 if(strDestino == 'EPSG:4326Z'){ 225 226 var reproyectador = proj4(strOrigen, 'EPSG:4326'); 227 228 var resultado = reproyectador.forward([Number(x), Number(y)]); 229 230 x = resultado[0]; 231 y = resultado[1]; 232 233 console.log(resultado); 234 235 x = convertirDecimalAGrados(x); 236 y = convertirDecimalAGrados(y); 237 238 var mensaje = 'x: '+x +'\ny: '+ y; 239 240 mostrarMensaje("Resultado de reproyección de coordenadas", mensaje); 241 e.preventDefault(); 242 }else if(strOrigen == 'EPSG:4326Z'){ 243 x = convertirGradosADecimal(x); 244 y = convertirGradosADecimal(y); 245 246 var reproyectador = proj4('EPSG:4326', strDestino); 247 248 var resultado = reproyectador.forward([Number(x), Number(y)]); 249 250 x = resultado[0]; 251 y = resultado[1]; 252 253 var mensaje = 'x: '+x +'\ny: '+ y; 254 255 mostrarMensaje("Resultado de reproyección de coordenadas", mensaje); 256 e.preventDefault(); 257 }else if(strDestino == 'EPSG:8908'){ 258 259 //Primero por crtm05. 260 let reproyectador = proj4(strOrigen, 'EPSG:5367'); 261 let resultado = reproyectador.forward([Number(x), Number(y)]); 262 x = resultado[0];
263 y = resultado[1]; 264 //ahora siguiente paso crtm05 a crsirgas 265 reproyectador = proj4('EPSG:5367', 'EPSG:8908'); 266 resultado = reproyectador.forward([Number(x), Number(y)]); 267 x = resultado[0]; 268 y = resultado[1]; 269 var mensaje = 'x: '+ x +'\ny: '+ y; 270 271 mostrarMensaje("Resultado de reproyección de coordenadas", mensaje); 272 e.preventDefault(); 273 } 274 else{ 275 276 reproyectarPunto(strOrigen, strDestino, x, y); 277 console.log("Origen: " + strOrigen + " strDestino " + strDestino + " Valor X: " + x + " Valor Y: " + y); 278 e.preventDefault(); 279 } 280 281 } 282 } 283 else 284 { 285 // swal('El mismo origen y destino producen la misma reproyección.'); 286 mostrarMensaje("Precaución", 'El mismo origen y destino producen la misma reproyección.'); 287 } 288 289 290 /** 291 var destinogrados = origengrados = false; 292 if(strOrigen == 'EPSG:4326Z'){ 293 x = convertirGradosADecimal(x); 294 y = convertirGradosADecimal(y); 295 296 strOrigen = 'EPSG:4326'; 297 origengrados = true; 298 } 299 if(strDestino == 'EPSG:4326Z'){ 300 301 strDestino = 'EPSG:4326'; 302 303 destinogrados = true; 304 } 305 306 if(strOrigen!="0" && strDestino!= "0") { 307 308 if (strOrigen != strDestino) { 309 reproyectarPunto(strOrigen, strDestino, x, y); 310 e.preventDefault(); 311 312 if(destinogrados){ 313 x = convertirDecimalAGrados(x); 314 y = convertirDecimalAGrados(y); 315 } 316 } else { 317 if(origengrados && !destinogrados){ 318 //quiere quitarle los grados y es la misma proyeccion. 319 var mensaje = "<p>RESULTADO:</p>" + "<p>"+"<span id=\"respt\">" + x + ', '+y +"</span>"+"</p>"; 320 321 mostrarMensaje("Reproyección de coordenadas", mensaje); 322 323 }else{ 324 alert("El Origen y Destino no pueden ser iguales, favor revisar los datos"); } 325 } 326 327 }else{ 328 alert("No ha seleccionado algun Origen o Destino"); 329 } 330 **/ 331 }); 332 333 /**@TODO 334 * Parametrizar la función para cuando se utiliza en dispositivos moviles para evitar el código repetido 335 * **/ 336 $("#botonReproyectarMovil").click(function (e) { 337 338 var x = document.getElementById("coordenadaXMovil").value; 339 var y = document.getElementById("coordenadaYMovil").value; 340 341 var origen = document.getElementById("selectOrigenMovil"); 342 var strOrigen = origen.options[origen.selectedIndex].value; 343 344 var destino = document.getElementById("selectDestinoMovil"); 345 var strDestino = destino.options[destino.selectedIndex].value; 346 347 console.log('origen '+strOrigen+' destino '+strDestino+' x '+x+' y '+y); 348 console.log(origen); 349 console.log(destino); 350 351 if(strOrigen != strDestino) 352 { 353 if((strOrigen == 'EPSG:8908')){ 354 //Primero hay que pasar por crtm05 355 var reproyectador = proj4(strOrigen, 'EPSG:5367'); 356 var resultado = reproyectador.forward([Number(x), Number(y)]); 357 x = resultado[0]; 358 y = resultado[1]; 359 strOrigen = 'EPSG:5367';//para que haga el siguiente salto. 360 } 361 if((strOrigen == 'EPSG:4326') && (strDestino == 'EPSG:4326Z')) //DD to DMS 362 { 363 x = convertirDecimalAGrados(x); 364 y = convertirDecimalAGrados(y); 365 366 console.log([x, y]); 367 368 var mensaje = 'x: '+x +'\ny: '+ y; 369 370 mostrarMensaje("Resultado de reproyección de coordenadas", mensaje); 371 } 372 else if((strOrigen == 'EPSG:4326Z') && (strDestino == 'EPSG:4326')) //DMS to DD 373 { 374 x = convertirGradosADecimal(x); 375 y = convertirGradosADecimal(y); 376 377 var mensaje = 'x: '+x +'\ny: '+ y; 378 379 mostrarMensaje("Resultado de reproyección de coordenadas", mensaje); 380 } 381 else 382 { 383 if(strDestino == 'EPSG:4326Z'){ 384 385 var reproyectador = proj4(strOrigen, 'EPSG:4326'); 386 387 var resultado = reproyectador.forward([Number(x), Number(y)]); 388 389 x = resultado[0];
390 y = resultado[1]; 391 392 console.log(resultado); 393 394 x = convertirDecimalAGrados(x); 395 y = convertirDecimalAGrados(y); 396 397 var mensaje = 'x: '+x +'\ny: '+ y; 398 399 mostrarMensaje("Resultado de reproyección de coordenadas", mensaje); 400 e.preventDefault(); 401 }else if(strOrigen == 'EPSG:4326Z'){ 402 x = convertirGradosADecimal(x); 403 y = convertirGradosADecimal(y); 404 405 var reproyectador = proj4('EPSG:4326', strDestino); 406 407 var resultado = reproyectador.forward([Number(x), Number(y)]); 408 409 x = resultado[0]; 410 y = resultado[1]; 411 412 var mensaje = 'x: '+x +'\ny: '+ y; 413 414 mostrarMensaje("Resultado de reproyección de coordenadas", mensaje); 415 e.preventDefault(); 416 }else if(strDestino == 'EPSG:8908'){ 417 418 //Primero por crtm05. 419 let reproyectador = proj4(strOrigen, 'EPSG:5367'); 420 let resultado = reproyectador.forward([Number(x), Number(y)]); 421 422 x = resultado[0]; 423 y = resultado[1]; 424 //ahora siguiente paso crtm05 a crsirgas 425 reproyectador = proj4('EPSG:5367', 'EPSG:8908'); 426 resultado = reproyectador.forward([Number(x), Number(y)]); 427 428 x = resultado[0]; 429 y = resultado[1]; 430 var mensaje = 'x: '+x +'\ny: '+ y; 431 432 mostrarMensaje("Resultado de reproyección de coordenadas", mensaje); 433 e.preventDefault(); 434 } 435 else{ 436 437 reproyectarPunto(strOrigen, strDestino, x, y); 438 e.preventDefault(); 439 } 440 441 } 442 } 443 else 444 { 445 // swal('El mismo origen y destino producen la misma reproyección.'); 446 mostrarMensaje("Precaución", 'El mismo origen y destino producen la misma reproyección.'); 447 } 448 }); 449} 450 451var wfsIcon = function(cell, formatterParams){ 452 return '<a name="wfs" href="#" class="btn bg-info" role="button">WFS</a>'; 453}; 454 455var wmsIcon = function(cell, formatterParams){ 456 return '<a name="wfs" href="#" class="btn bg-danger" role="button">WMS</a>'; 457}; 458 459var visorIcon = function(cell, formatterParams){ 460 var key = cell.getRow().getData().key; 461 return `<a name="wfs" target="_blank" href="/Visor/indexver2?k=${key}" class="btn bg-primary" role="button">VISOR</a>`; 462}; 463 464var urlIcon = function (cell, formatterParams){ 465 var URL = cell.getRow().getData().URL1; 466 if(URL){ 467 return `<a name="url1" target="_blank" href="${URL}" class="btn nodos_info" role="button" ><span title="Fundamento legal" class="avf ico_info"></span></a>`; 468 } 469} 470var urlIcon2 = function (cell, formatterParams){ 471 var URL = cell.getRow().getData().URL2; 472 if(URL){ 473 return `<a name="url2" target="_blank" href="${URL}" class="btn nodos_info" role="button" ><span title="Fundamento legal" class="avf ico_info"></span></a>`; 474 } 475} 476var urlIcon3 = function (cell, formatterParams){ 477 var URL = cell.getRow().getData().URL3; 478 if(URL){ 479 return `<a name="url3" target="_blank" href="${URL}" class="btn nodos_info" role="button" ><span title="Fundamento legal" class="avf ico_info"></span></a>`; 480 } 481} 482 483var urlIcon4 = function (cell, formatterParams){ 484 var URL = cell.getRow().getData().URL4; 485 if(URL){ 486 return `<a name="url4" target="_blank" href="${URL}" class="btn nodos_info" role="button" ><span title="Fundamento legal" class="avf ico_info"></span></a>`; 487 } 488} 489var urlIcon5 = function (cell, formatterParams){ 490 var URL = cell.getRow().getData().URL5; 491 if(URL){ 492 return `<a name="url5" target="_blank" href="${URL}" class="btn nodos_info" role="button" ><span title="Fundamento legal" class="avf ico_info"></span></a>`; 493 } 494} 495 496function respuesta(url, params, response) { 497 console.log(response); 498 console.log(params); 499 if (response.resultado && response.success){ 500 console.log('success'); 501 console.log(response.data); 502 return response.data; 503 }else{ 504 console.log('error'); 505 } 506} 507var configuracionTabla = { 508 // height: "350px", 509 layout: "fitDataFill", 510 // responsiveLayout: "hide", 511 responsiveLayoutCollapseStartOpen: false, 512 addRowPos: "bottom", 513 selectable: false, //make rows selectable 514 pagination: "local", 515 paginationSize: 10, 516 langs: { 517 "spa-spa": { 518 "pagination": { 519 "page_size": "Tamaño", 520 "first": '<i class="fas fa-fast-backward"></i>', 521 "first_title": "Primera Página", 522 "last": '<i class="fas fa-fast-forward"></i>', 523 "last_title": "Ãltima Página", 524 "prev": '<i class="fas fa-caret-left"></i>', 525 "prev_title": "Página Anterior", 526 "next": '<i class="fas fa-caret-right"></i>', 527 "next_title": "Siguiente Página", 528 } 529 } 530 }, 531 532}; 533 534function cargarNavRegistro() { 535 $.ajax({ 536 url: '/get_nav_registro', 537 type: 'post', 538 dataType: 'json', 539 contentType: 'application/json', 540 success: function (data) { 541 $('#navbar-registro ul').empty(); 542 for(var i = 0; i < data.length; i++){ 543 544 window.data = data; 545 546 547 var li = document.createElement('li'); 548 li.setAttribute('class','nav-item'); 549 if (data[i].links) li.classList.add('dropdown'); 550 if (data[i].resp)li.classList.add('resp_item'); 551 552 var a = document.createElement('a'); 553 a.setAttribute('class', 'nav-link'); 554 a.setAttribute('href',data[i].url); 555 if (data[i].links){ 556 a.classList.add('dropdown-toggle'); 557 a.setAttribute('id', data[i].id + '-dropdown'); 558 a.setAttribute('role', 'button'); 559 a.setAttribute('data-toggle', 'dropdown'); 560 a.setAttribute('aria-haspopup', 'true'); 561 a.setAttribute('aria-expanded', 'false'); 562 563 564 } 565 566 var innerHTML = ''; 567 if (data[i].icon){ 568 innerHTML += '<i class="align-middle '+data[i].icon+'">'; 569 } 570 innerHTML += data[i].title; 571 572 a.innerHTML = innerHTML; 573 574 li.appendChild(a); 575 576 if (data[i].links){ 577 var div = document.createElement('div'); 578 div.setAttribute('class','dropdown-menu'); 579 div.setAttribute('aria-labeledby',data[i].id+'-dropdown'); 580 for (var j = 0; j < data[i].links.length; j++) { 581 var a = document.createElement('a'); 582 a.setAttribute('class', 'dropdown-item'); 583 a.setAttribute('href',data[i].links[j].url); 584 a.innerHTML = data[i].links[j].title; 585 div.appendChild(a); 586 } 587 li.appendChild(div); 588 } 589 590 591 592 593 $('#navbar-registro ul').append(li); 594 595 } 596 }, 597 598 }); 599} 600/* Open when someone clicks on the span element */ 601function openNav() { 602 document.getElementById("myNav").style.width = "100%"; 603 $('#buscador').focus(); 604} 605 606function detalleUsuario(event) { 607 console.log(event); 608} 609 610function openSeleccionador(){ 611 $('#tabulator').empty(); 612 613 var configuracion = Object.assign({}, configuracionTabla); 614 configuracion.columns = [ 615 {title:"CAPA", width:'47%',field:"nombre", sorter:"string", headerFilter:"input", headerFilterPlaceholder:"Digite para filtrar..."}, 616 //{title:"FECHA",width:'10%', field:"fecha", sorter:"date"}, 617 // {formatter:wfsIcon, width:'10%', headerSort:false, align:"center"}, 618 // {formatter:wmsIcon, width:'10%', headerSort:false, align:"center"}, 619 {formatter:visorIcon, width:'10%', headerSort:false, align:"center"}, 620 {formatter:urlIcon, width:'10%', headerSort:false, align:"center"}, 621 {formatter:urlIcon2, width:'10%', headerSort:false, align:"center"}, 622 {formatter:urlIcon3, width:'10%', headerSort:false, align:"center"}, 623 {formatter:urlIcon4, width:'10%', headerSort:false, align:"center"}, 624 {formatter:urlIcon5, width:'10%', headerSort:false, align:"center"}, 625 626 ]; 627 configuracion.ajaxResponse = respuesta; 628 629 var table = new Tabulator("#tabulator", configuracion); 630 631 let institucion = $('#seleccionar-capas').val(); 632 console.log(institucion); 633 table.setData("/get_capas_oficiales", {institucion: institucion}); 634 table.setLocale("spa-spa"); 635} 636 637/* Close when someone clicks on the "x" symbol inside the overlay */ 638function closeNav() { 639 document.getElementById("myNav").style.width = "0%"; 640 $('#capas').empty(); 641} 642 643function getInstitucion(institucion){ 644 var institucionActual = ""; 645 switch (institucion){ 646 case "Dirección de Agua, MINAE": 647 institucionActual = "DA"; 648 break; 649 case "IGN": 650 institucionActual = "IGN"; 651 break; 652 case "Instituto Nacional de Vivienda": 653 case "Instituto Nacional de Vivienda y Urbanismo y el Programa de las Naciones Unidas para Costa Rica": 654 case "INVU-Urbanismo": 655 institucionActual = "INVU"; 656 break; 657 case "Ministerio de Educación Pública (MEP)": 658 institucionActual = "MEP"; 659 break; 660 case "Sistema Nacional de Ãreas de Conservación": 661 institucionActual = "SINAC"; 662 break; 663 case "Servicio Nacional de Aguas Subterráneas, Riego y Avenamiento - ESTACIONES METEOROLÃGICAS": 664 case "Servicio Nacional de Aguas Subterráneas, Riego y Avenamiento - RECARGA": 665 case "Servicio Nacional de Aguas Subterráneas, Riego y Avenamiento - VULNERABILIDAD": 666 institucionActual = "SENARA"; 667 break; 668 case "Benemérito Cuerpo de Bomberos de Costa Rica": 669 institucionActual = "BOMBEROS_CR"; 670 break; 671 case "Instituto Costarricense de Turismo": 672 institucionActual = "ICT"; 673 break; 674 default: 675 institucionActual = ""; 676 } 677 return institucionActual; 678} 679 680let capasOficiales = []; 681 682function mostrarResultado(resultados){ 683 console.log('mostrando resultado'); 684 console.log("Resultados:",resultados); 685 $('#capas').empty(); 686 var resultado = $('#capas');
687 console.log(resultado); 688 689 console.log('capasOficiales',capasOficiales) 690 for(let i = 0; i < resultados.length; i++) { 691 692 693 var urlString = resultados[i].url; 694 var url = new URL(urlString, window.location.origin); 695 var params = new URLSearchParams(url.search); 696 var substring = params.get("k"); 697 698 var oficial = false; 699 if (capasOficiales != null) { 700 // console.log("params: ", params); 701 // console.log("substring: ", substring); 702 // console.log("capasOficiales: ", capasOficiales); 703 //oficial = capasOficiales.some(element => element.key === substring); 704 oficial = capasOficiales.some(element => { 705 706 if(element.key === 'Y2FwYTo6Ukk6OmNhdGFzdHJv==') { 707 console.log("viendo si es oficial element.key: ", element.key, "=", substring); 708 } 709 710 return element.key === substring; 711 }); 712 } 713 714 var esOficial = oficial ? 'SÃ' : 'No'; 715 console.log('es oficial?',esOficial) 716 html = $("#capa-info").clone().removeAttr('id'); 717 // la llenamos con la información de la capa 718 html.find('.visorbtn').parent().attr('id', (resultados[i].id)); 719 html.find('.previsualizarlink').attr('href', (resultados[i].url)); 720 // https://www.snitcr.go.cr/ico_servicios_ogc_info?k=bm9kbzo6NTg=&nombre=INVU-PNUD 721 let linkNodo = `/ico_servicios_ogc_info?k=` + resultados[i].NodoPadreKey + `&nombre=` + resultados[i].node_name; 722 html.find('.nodolink').attr('href', (linkNodo)); 723 724 html.find('.btnvermetadatos-holder').attr('data-capa', (resultados[i].id)); 725 726 if(resultados[i].TieneMetadatos){ 727 html.find('.btnvermetadatos').html('VER METADATOS'); 728 729 var dataString = {k: resultados[i].id}; 730 var url = CONFIG.getUrlMetadatosCapa(); 731 $.ajax({ 732 type:"post", dataType:"json", url:url, data:dataString, async: false 733 }).done(function( data ) { 734 if(data.Result != false){ 735 /* var obj = data.data; 736 var fecha = (obj.fecha.substring(0, 10)).split('-').reverse().join('-'); 737 html.find('span[name=fechaUltAct]').html("Fecha de última actualización: "+fecha);*/ 738 739 html.find('span[name=capaOficial]').html("¿Capa oficial? " + esOficial); 740 } 741 }); 742 743 }else{ 744 html.find('.btnvermetadatos').html('NO TIENE METADATOS'); 745 html.find('.btnvermetadatos').attr('disabled', 'disabled'); 746 747 // html.find('span[name=fechaUltAct]').html("Fecha de última actualización: "+resultados[i].fecha); 748 html.find('span[name=capaOficial]').html("¿Capa oficial? " + esOficial); 749 } 750 //html.find('span[name=fechaUltAct]').html("obj.fecha"); 751 html.find('span[name=nombre]').html(resultados[i].nombre); 752 html.find('span[name=institucion]').html(resultados[i].institucion); 753 // html.find('span[name=fecha]').html(resultados[i].fecha); 754 html.find('span[name=TieneMetadatos]').html(resultados[i].TieneMetadatos); 755 // mostramos la tarjeta 756 html.show(); 757 //devolvemos la tarjeta 758 resultado.append(html); 759 760 } 761 762 $("#resultados-capas").on("click", ".label-wfs-resultado-busqueda", function(e) { 763 if($(this).hasClass("disabled") == false) { 764 agregarCapaEnWFS(this); 765 e.preventDefault(); 766 } 767 }); 768 $("#resultados-capas").on("click", ".label-wms-resultado-busqueda", function(e) { 769 if($(this).hasClass("disabled") == false) { 770 agregarCapaEnWMS(this); 771 e.preventDefault(); 772 } 773 }); 774 $("#resultados-capas .btnvermetadatos").on("click", function(e) { 775 cargarMetadatosCapaBusqueda(this); 776 //e.preventDefault(); 777 }); 778 779 $('#exitMetadatosCapa').click(function() { 780 $('#controles-holder-metadatos-capa').hide(); 781 }); 782 783 784} 785 786function cargarCapasOficiales(){ 787 let institucion = ['IGN', 'SINAC', 'INVU', 'MEP', 'DA', 'SENARA', 'BOMBEROS_CR', 'ICT', 'ICE', 'MOPT', 'MUNIBARVA',"CTP","COSEVI", "MUNIESCAZU","REGISTRO_INMOBILIARIO","TSE","INEC","MUNILIBERIA"]; 788 789 790 let urlOficial = "../get_capas_oficiales"; 791 institucion.forEach((item)=>{ 792 let dataStringOficial = { institucion: item }; 793 $.ajax({ 794 type:"post", dataType:"json", url:urlOficial, data:dataStringOficial 795 }).done(function(data) { 796 console.log("item: ", item); 797 console.log("Cargando capas oficiales", data.data) 798 capasOficiales = capasOficiales.concat(data.data); 799 }); 800 }); 801} 802 803function onSeleccionarCapasChanged() { 804 $('#seleccionar-capas').on('change', function () { 805 if ( 806 $(this).val() === 'IGN' 807 || $(this).val() === 'SINAC' 808 || $(this).val() === 'INVU' 809 || $(this).val() === 'MEP' 810 || $(this).val() === 'DA' 811 || $(this).val() === 'ARESEP' 812 || $(this).val() === 'SENARA' 813 || $(this).val() === 'BOMBEROS_CR' 814 || $(this).val() === 'ICT' 815 || $(this).val() === 'ICE' 816 || $(this).val() === 'MOPT' 817 || $(this).val() === 'MUNIBARVA' 818 || $(this).val() === 'CTP' 819 || $(this).val() === 'COSEVI' 820 || $(this).val() === 'MUNIESCAZU' 821 || $(this).val() === 'REGISTRO_INMOBILIARIO' 822 || $(this).val() === 'TSE' 823 || $(this).val() === 'INEC' 824 || $(this).val() === 'MUNILIBERIA' 825 826 827 ) { 828 mostrarTablaCapas(); 829 openSeleccionador(); 830 } else { 831 ocultarTablaCapas(); 832 } 833 }); 834} 835 836function mostrarTablaCapas() { 837 $('#tabulator').show(); 838} 839 840function ocultarTablaCapas() { 841 $('#tabulator').hide(); 842} 843 844 845function EditarSelectorCapas(){ 846 847 $('#seleccionar-capas').select2({ 848 placeholder: "Buscar institución...", 849 allowClear: true, 850 width: '250px' 851 }); 852 853} 854 855 856$( document ).ready(function() { 857 const urlActual = window.location.href; 858 console.log(urlActual); 859 if (urlActual.includes('global_mensaje_comprobante_envio_crear_institucion')) { 860 var contenido = document.getElementById("nombre_completo").innerText; 861 if(contenido.includes("Anonymous")){ 862 document.getElementById("nombre_completo").style.display = "none"; 863 } 864 } 865 $('#elementos').hide(); 866 867 cargarNavRegistro(); 868 869 EditarSelectorCapas(); 870 initReproyeccionBox(); 871 872 if(typeof jQuery.fn.select2 == 'function'){ 873 874 $('#select-origen, #select-destino').select2(); 875 } 876 877 $('#buscador-info-boton').on("click", openNav); 878 cargarCapasOficiales(); 879 onSeleccionarCapasChanged(); 880 // $('#seleccionador-capas').on('click', openSeleccionador); 881 882 $("#buscador").bind("change paste keyup", function (data) { 883 console.log('buscando'); 884 console.log($(this).val()); 885 console.log(data); 886 887 searchString = $(this).val(); 888 889 if (searchString.length >= 3){ 890 891 $.ajax({ 892 url: '/busqueda_capas', 893 type: 'get', 894 // dataType: 'json', 895 contentType: 'application/x-www-form-urlencoded', 896 data: {searchString: searchString}, 897 success: function (results) { 898 console.log(results); 899 if (results.resultado && results.success){ 900 //console.log('success') 901 mostrarResultado(results.data); 902 } 903 904 } 905 906 }); 907 908 } 909 910 }); 911 912 913 914 915 916 917 if(typeof cargarDatosUsuario != 'undefined'){ 918 cargarDatosUsuario(); 919 } 920 if(typeof initReproyeccionAvanzada != 'undefined'){ 921 initReproyeccionAvanzada(); 922 } 923 if(typeof initUserBox != 'undefined'){ 924 initUserBox(); 925 } 926 927 928}); 929 930 931document.addEventListener("DOMContentLoaded", function() { 932 var inputField = document.getElementById("buscador"); 933 if(inputField){ 934 inputField.addEventListener("keydown", function(event) { 935 if (event.key === "Enter") { 936 event.preventDefault(); 937 return false;
938 } 939 }); 940 } 941 942});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.