diff --git a/estaticos/datosMapa.geo.json b/estaticos/datosMapa.geo.json index 1172190..5ac569f 100644 --- a/estaticos/datosMapa.geo.json +++ b/estaticos/datosMapa.geo.json @@ -1 +1 @@ -{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"slug":"barrancas","nombre":"Barrancas","conteo":1},"geometry":{"type":"Point","coordinates":[-72.79636,10.95454]}},{"type":"Feature","properties":{"slug":"barranquilla","nombre":"Barranquilla","conteo":1},"geometry":{"type":"Point","coordinates":[-74.80363,10.9723]}},{"type":"Feature","properties":{"slug":"bogota","nombre":"Bogotá","conteo":10},"geometry":{"type":"Point","coordinates":[-74.10378,4.64958]}},{"type":"Feature","properties":{"slug":"boyaca","nombre":"Boyacá","conteo":1},"geometry":{"type":"Point","coordinates":[-73.27533,5.40013]}},{"type":"Feature","properties":{"slug":"bucaramanga","nombre":"Bucaramanga","conteo":1},"geometry":{"type":"Point","coordinates":[-73.12099,7.11168]}},{"type":"Feature","properties":{"slug":"cajibio","nombre":"Cajibio","conteo":1},"geometry":{"type":"Point","coordinates":[-76.56992,2.6224]}},{"type":"Feature","properties":{"slug":"cartagena","nombre":"Cartagena","conteo":3},"geometry":{"type":"Point","coordinates":[-75.49685,10.39361]}},{"type":"Feature","properties":{"slug":"cota","nombre":"Cota","conteo":1},"geometry":{"type":"Point","coordinates":[-74.10352,4.80948]}},{"type":"Feature","properties":{"slug":"coyaima","nombre":"Coyaima","conteo":1},"geometry":{"type":"Point","coordinates":[-75.19485,3.79766]}},{"type":"Feature","properties":{"slug":"el-paso","nombre":"El paso","conteo":1},"geometry":{"type":"Point","coordinates":[-73.74695,9.66267]}},{"type":"Feature","properties":{"slug":"fonseca","nombre":"Fonseca","conteo":1},"geometry":{"type":"Point","coordinates":[-72.52046,11.35477]}},{"type":"Feature","properties":{"slug":"funza","nombre":"Funza","conteo":1},"geometry":{"type":"Point","coordinates":[-74.2062,4.71154]}},{"type":"Feature","properties":{"slug":"fuquene","nombre":"Fúquene","conteo":1},"geometry":{"type":"Point","coordinates":[-73.79561,5.40432]}},{"type":"Feature","properties":{"slug":"girardot","nombre":"Girardot","conteo":1},"geometry":{"type":"Point","coordinates":[-74.80311,4.31039]}},{"type":"Feature","properties":{"slug":"guane","nombre":"Guane","conteo":1},"geometry":{"type":"Point","coordinates":[-73.24005,6.67952]}},{"type":"Feature","properties":{"slug":"guangzhou","nombre":"Guangzhou","conteo":1},"geometry":{"type":"Point","coordinates":[113.2441,23.1591]}},{"type":"Feature","properties":{"slug":"inza","nombre":"Inzá","conteo":1},"geometry":{"type":"Point","coordinates":[-76.06483,2.54871]}},{"type":"Feature","properties":{"slug":"maicao","nombre":"Maicao","conteo":1},"geometry":{"type":"Point","coordinates":[-72.24339,11.37785]}},{"type":"Feature","properties":{"slug":"manizales","nombre":"Manizales","conteo":1},"geometry":{"type":"Point","coordinates":[-75.49738,5.053644]}},{"type":"Feature","properties":{"slug":"marmato","nombre":"Marmato","conteo":1},"geometry":{"type":"Point","coordinates":[-75.60018,5.475047]}},{"type":"Feature","properties":{"slug":"medellin","nombre":"Medellín","conteo":2},"geometry":{"type":"Point","coordinates":[-75.57667,6.216123]}},{"type":"Feature","properties":{"slug":"minca","nombre":"Minca","conteo":1},"geometry":{"type":"Point","coordinates":[-74.11705,11.14285]}},{"type":"Feature","properties":{"slug":"mocoa","nombre":"Mocoa","conteo":1},"geometry":{"type":"Point","coordinates":[-76.65068,1.152415]}},{"type":"Feature","properties":{"slug":"mompox","nombre":"Mompox","conteo":3},"geometry":{"type":"Point","coordinates":[-74.42586,9.241184]}},{"type":"Feature","properties":{"slug":"monteria","nombre":"Montería","conteo":1},"geometry":{"type":"Point","coordinates":[-75.87888,8.749009]}},{"type":"Feature","properties":{"slug":"natagaima","nombre":"Natagaima","conteo":1},"geometry":{"type":"Point","coordinates":[-75.09344,3.622402]}},{"type":"Feature","properties":{"slug":"nemocon","nombre":"Nemocón","conteo":3},"geometry":{"type":"Point","coordinates":[-73.87776,5.066891]}},{"type":"Feature","properties":{"slug":"nilo","nombre":"Nilo","conteo":2},"geometry":{"type":"Point","coordinates":[-74.61933,4.307488]}},{"type":"Feature","properties":{"slug":"ortega","nombre":"Ortega","conteo":1},"geometry":{"type":"Point","coordinates":[-75.22142,3.934056]}},{"type":"Feature","properties":{"slug":"pasto","nombre":"Pasto","conteo":1},"geometry":{"type":"Point","coordinates":[-77.27464,1.210092]}},{"type":"Feature","properties":{"slug":"piendamo","nombre":"Piendamo","conteo":1},"geometry":{"type":"Point","coordinates":[-76.56926,2.713528]}},{"type":"Feature","properties":{"slug":"pitalito","nombre":"Pitalito","conteo":2},"geometry":{"type":"Point","coordinates":[-76.04796,1.85864]}},{"type":"Feature","properties":{"slug":"popayan","nombre":"Popayán","conteo":1},"geometry":{"type":"Point","coordinates":[-76.61418,2.441091]}},{"type":"Feature","properties":{"slug":"puerto-rondon","nombre":"Puerto Rondón","conteo":1},"geometry":{"type":"Point","coordinates":[-71.10065,6.279994]}},{"type":"Feature","properties":{"slug":"quibdo","nombre":"Quibdó","conteo":1},"geometry":{"type":"Point","coordinates":[-76.65319,5.68914]}},{"type":"Feature","properties":{"slug":"quinchia","nombre":"Quinchía","conteo":1},"geometry":{"type":"Point","coordinates":[-75.73108,5.340411]}},{"type":"Feature","properties":{"slug":"quipile","nombre":"Quipile","conteo":1},"geometry":{"type":"Point","coordinates":[-74.53333,4.745296]}},{"type":"Feature","properties":{"slug":"raquira","nombre":"Ráquira","conteo":1},"geometry":{"type":"Point","coordinates":[-73.6317,5.539581]}},{"type":"Feature","properties":{"slug":"sabanagrande","nombre":"Sabanagrande","conteo":1},"geometry":{"type":"Point","coordinates":[-74.75713,10.7888]}},{"type":"Feature","properties":{"slug":"san-agustin","nombre":"San Agustín","conteo":2},"geometry":{"type":"Point","coordinates":[-76.26856,1.881113]}},{"type":"Feature","properties":{"slug":"san-juan-del-cesar","nombre":"San Juan del Cesar","conteo":1},"geometry":{"type":"Point","coordinates":[-73.00323,10.77296]}},{"type":"Feature","properties":{"slug":"serrania-del-perija","nombre":"Serranía del perijá","conteo":1},"geometry":{"type":"Point","coordinates":[-73.01104,10.1198]}},{"type":"Feature","properties":{"slug":"shanghai","nombre":"Shanghai","conteo":1},"geometry":{"type":"Point","coordinates":[121.52756,31.2245159]}},{"type":"Feature","properties":{"slug":"sierra-nevada-de-santa-marta","nombre":"Sierra Nevada de Santa Marta","conteo":3},"geometry":{"type":"Point","coordinates":[-73.70472,10.80322]}},{"type":"Feature","properties":{"slug":"silvia","nombre":"Silvia","conteo":1},"geometry":{"type":"Point","coordinates":[-76.37683,2.612557]}},{"type":"Feature","properties":{"slug":"simijaca","nombre":"Simijaca","conteo":1},"geometry":{"type":"Point","coordinates":[-73.85283,5.502895]}},{"type":"Feature","properties":{"slug":"sopo","nombre":"Sopó","conteo":1},"geometry":{"type":"Point","coordinates":[-73.9415,4.907192]}},{"type":"Feature","properties":{"slug":"suarez","nombre":"Suárez","conteo":2},"geometry":{"type":"Point","coordinates":[-76.6943,2.954501]}},{"type":"Feature","properties":{"slug":"susa","nombre":"Susa","conteo":1},"geometry":{"type":"Point","coordinates":[-73.8147,5.453561]}},{"type":"Feature","properties":{"slug":"sutamarchan","nombre":"Sutamarchan","conteo":1},"geometry":{"type":"Point","coordinates":[-73.62027,5.62011]}},{"type":"Feature","properties":{"slug":"tablon-de-gomez","nombre":"Tablón de Gómez","conteo":6},"geometry":{"type":"Point","coordinates":[-77.09767,1.427297]}},{"type":"Feature","properties":{"slug":"tambo","nombre":"Tambo","conteo":1},"geometry":{"type":"Point","coordinates":[-76.81125,2.452202]}},{"type":"Feature","properties":{"slug":"tierrafirme","nombre":"Tierrafirme","conteo":1},"geometry":{"type":"Point","coordinates":[-74.36345,9.328041]}},{"type":"Feature","properties":{"slug":"tinjaca","nombre":"Tinjacá","conteo":1},"geometry":{"type":"Point","coordinates":[-73.64729,5.578859]}},{"type":"Feature","properties":{"slug":"tolemaida","nombre":"Tolemaida","conteo":2},"geometry":{"type":"Point","coordinates":[-74.64637,4.254571]}},{"type":"Feature","properties":{"slug":"tubara","nombre":"Tubará","conteo":1},"geometry":{"type":"Point","coordinates":[-74.97791,10.87381]}},{"type":"Feature","properties":{"slug":"turbo","nombre":"Turbo","conteo":1},"geometry":{"type":"Point","coordinates":[-76.73141,8.093867]}},{"type":"Feature","properties":{"slug":"uribia","nombre":"Uribia","conteo":2},"geometry":{"type":"Point","coordinates":[-72.26593,11.71557]}},{"type":"Feature","properties":{"slug":"valle-de-aburra","nombre":"Valle de aburrá","conteo":1},"geometry":{"type":"Point","coordinates":[-75.57667,6.216123]}},{"type":"Feature","properties":{"slug":"valledupar","nombre":"Valledupar","conteo":3},"geometry":{"type":"Point","coordinates":[-73.25601,10.46568]}},{"type":"Feature","properties":{"slug":"villa-de-leiva","nombre":"Villa de leiva","conteo":1},"geometry":{"type":"Point","coordinates":[-73.52697,5.63714]}},{"type":"Feature","properties":{"slug":"villeta","nombre":"Villeta","conteo":1},"geometry":{"type":"Point","coordinates":[-74.47217,5.01063]}},{"type":"Feature","properties":{"slug":"washington","nombre":"Washington","conteo":1},"geometry":{"type":"Point","coordinates":[-77.02963,38.89572]}},{"type":"Feature","properties":{"slug":"rio-beni","nombre":"Río Beni","conteo":1},"geometry":{"type":"Point","coordinates":[-66.24339300115354,-11.290710332691877]}},{"type":"Feature","properties":{"slug":"sabana-de-bogota","nombre":"Sabana de Bogotá","conteo":1},"geometry":{"type":"Point","coordinates":[-73.99977075338786,4.858062622596899]}},{"type":"Feature","properties":{"slug":"region-cuenca-media-del-rio-cauca","nombre":"Región cuenca media del río Cauca","conteo":1},"geometry":{"type":"Point","coordinates":[-75.65197362488038,5.787082773904699]}},{"type":"Feature","properties":{"slug":"sutamarchan","nombre":"Sutamarchán","conteo":1},"geometry":{"type":"Point","coordinates":[-73.62095797820405,5.61968315930457]}},{"type":"Feature","properties":{"slug":"samaca","nombre":"Samacá","conteo":1},"geometry":{"type":"Point","coordinates":[-73.48549388275097,5.493196843626004]}},{"type":"Feature","properties":{"slug":"rio-inirida","nombre":"Río Inirida","conteo":1},"geometry":{"type":"Point","coordinates":[-69.6606021607646,2.5108141269105655]}},{"type":"Feature","properties":{"slug":"rio-atabapo","nombre":"Río Atabapo","conteo":1},"geometry":{"type":"Point","coordinates":[-67.43100896035111,3.575365231472792]}},{"type":"Feature","properties":{"slug":"ciudad-perdida","nombre":"Ciudad Pérdida","conteo":1},"geometry":{"type":"Point","coordinates":[-73.92244339622708,11.033266372215062]}},{"type":"Feature","properties":{"slug":"santa-marta","nombre":"Santa Marta","conteo":2},"geometry":{"type":"Point","coordinates":[-74.1904221703084,11.236576368059053]}}]} \ No newline at end of file +{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"slug":"amazonas","nombre":"Amazonas","tipo":"departamentos","conteo":3},"geometry":{"type":"Point","coordinates":[-73.21223,-2.05846]}},{"type":"Feature","properties":{"slug":"antioquia","nombre":"Antioquia","tipo":"departamentos","conteo":7},"geometry":{"type":"Point","coordinates":[-75.55128,6.60299]}},{"type":"Feature","properties":{"slug":"barrancas","nombre":"Barrancas","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-72.79636,10.95454]}},{"type":"Feature","properties":{"slug":"barranquilla","nombre":"Barranquilla","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-74.80363,10.9723]}},{"type":"Feature","properties":{"slug":"bogota","nombre":"Bogotá","tipo":"municipios","conteo":10},"geometry":{"type":"Point","coordinates":[-74.10378,4.64958]}},{"type":"Feature","properties":{"slug":"bogota","nombre":"Bogotá","tipo":"departamentos","conteo":2},"geometry":{"type":"Point","coordinates":[-74.10378,4.64958]}},{"type":"Feature","properties":{"slug":"boyaca","nombre":"Boyacá","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-73.27533,5.40013]}},{"type":"Feature","properties":{"slug":"boyaca","nombre":"Boyacá","tipo":"departamentos","conteo":5},"geometry":{"type":"Point","coordinates":[-73.27533,5.40013]}},{"type":"Feature","properties":{"slug":"bucaramanga","nombre":"Bucaramanga","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-73.12099,7.11168]}},{"type":"Feature","properties":{"slug":"buenaventura","nombre":"Buenaventura","tipo":"departamentos","conteo":1},"geometry":{"type":"Point","coordinates":[-76.99934,3.88045]}},{"type":"Feature","properties":{"slug":"cajibio","nombre":"Cajibio","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-76.56992,2.6224]}},{"type":"Feature","properties":{"slug":"caldas","nombre":"Caldas","tipo":"departamentos","conteo":3},"geometry":{"type":"Point","coordinates":[-75.69462,5.19088]}},{"type":"Feature","properties":{"slug":"caqueta","nombre":"Caquetá","tipo":"departamentos","conteo":1},"geometry":{"type":"Point","coordinates":[-74.26029,1.07351]}},{"type":"Feature","properties":{"slug":"cartagena","nombre":"Cartagena","tipo":"municipios","conteo":3},"geometry":{"type":"Point","coordinates":[-75.49685,10.39361]}},{"type":"Feature","properties":{"slug":"cauca","nombre":"Cauca","tipo":"departamentos","conteo":7},"geometry":{"type":"Point","coordinates":[-76.8397,2.31008]}},{"type":"Feature","properties":{"slug":"choco","nombre":"Chocó","tipo":"departamentos","conteo":3},"geometry":{"type":"Point","coordinates":[-77.18981,5.88913]}},{"type":"Feature","properties":{"slug":"colombia","nombre":"Colombia","tipo":"paises","conteo":149},"geometry":{"type":"Point","coordinates":[-74.10378,4.64958]}},{"type":"Feature","properties":{"slug":"cota","nombre":"Cota","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-74.10352,4.80948]}},{"type":"Feature","properties":{"slug":"coyaima","nombre":"Coyaima","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-75.19485,3.79766]}},{"type":"Feature","properties":{"slug":"cundinamarca","nombre":"Cundinamarca","tipo":"departamentos","conteo":24},"geometry":{"type":"Point","coordinates":[-74.14277,4.86458]}},{"type":"Feature","properties":{"slug":"el-paso","nombre":"El paso","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-73.74695,9.66267]}},{"type":"Feature","properties":{"slug":"fonseca","nombre":"Fonseca","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-72.52046,11.35477]}},{"type":"Feature","properties":{"slug":"funza","nombre":"Funza","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-74.2062,4.71154]}},{"type":"Feature","properties":{"slug":"fuquene","nombre":"Fúquene","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-73.79561,5.40432]}},{"type":"Feature","properties":{"slug":"girardot","nombre":"Girardot","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-74.80311,4.31039]}},{"type":"Feature","properties":{"slug":"guajira","nombre":"Guajira","tipo":"departamentos","conteo":8},"geometry":{"type":"Point","coordinates":[-72.95362,11.53443]}},{"type":"Feature","properties":{"slug":"guane","nombre":"Guane","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-73.24005,6.67952]}},{"type":"Feature","properties":{"slug":"guangzhou","nombre":"Guangzhou","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[113.2441,23.1591]}},{"type":"Feature","properties":{"slug":"guaviare","nombre":"Guaviare","tipo":"departamentos","conteo":1},"geometry":{"type":"Point","coordinates":[-72.14625,1.96099]}},{"type":"Feature","properties":{"slug":"inza","nombre":"Inzá","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-76.06483,2.54871]}},{"type":"Feature","properties":{"slug":"maicao","nombre":"Maicao","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-72.24339,11.37785]}},{"type":"Feature","properties":{"slug":"manizales","nombre":"Manizales","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-75.49738,5.053644]}},{"type":"Feature","properties":{"slug":"marmato","nombre":"Marmato","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-75.60018,5.475047]}},{"type":"Feature","properties":{"slug":"medellin","nombre":"Medellín","tipo":"municipios","conteo":2},"geometry":{"type":"Point","coordinates":[-75.57667,6.216123]}},{"type":"Feature","properties":{"slug":"mexico","nombre":"México","tipo":"paises","conteo":2},"geometry":{"type":"Point","coordinates":[-99.45544,19.39046]}},{"type":"Feature","properties":{"slug":"minca","nombre":"Minca","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-74.11705,11.14285]}},{"type":"Feature","properties":{"slug":"mocoa","nombre":"Mocoa","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-76.65068,1.152415]}},{"type":"Feature","properties":{"slug":"mompox","nombre":"Mompox","tipo":"municipios","conteo":3},"geometry":{"type":"Point","coordinates":[-74.42586,9.241184]}},{"type":"Feature","properties":{"slug":"monteria","nombre":"Montería","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-75.87888,8.749009]}},{"type":"Feature","properties":{"slug":"natagaima","nombre":"Natagaima","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-75.09344,3.622402]}},{"type":"Feature","properties":{"slug":"nemocon","nombre":"Nemocón","tipo":"municipios","conteo":3},"geometry":{"type":"Point","coordinates":[-73.87776,5.066891]}},{"type":"Feature","properties":{"slug":"nilo","nombre":"Nilo","tipo":"municipios","conteo":2},"geometry":{"type":"Point","coordinates":[-74.61933,4.307488]}},{"type":"Feature","properties":{"slug":"ortega","nombre":"Ortega","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-75.22142,3.934056]}},{"type":"Feature","properties":{"slug":"pasto","nombre":"Pasto","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-77.27464,1.210092]}},{"type":"Feature","properties":{"slug":"piendamo","nombre":"Piendamo","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-76.56926,2.713528]}},{"type":"Feature","properties":{"slug":"pitalito","nombre":"Pitalito","tipo":"municipios","conteo":2},"geometry":{"type":"Point","coordinates":[-76.04796,1.85864]}},{"type":"Feature","properties":{"slug":"popayan","nombre":"Popayán","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-76.61418,2.441091]}},{"type":"Feature","properties":{"slug":"puerto-rondon","nombre":"Puerto Rondón","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-71.10065,6.279994]}},{"type":"Feature","properties":{"slug":"quibdo","nombre":"Quibdó","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-76.65319,5.68914]}},{"type":"Feature","properties":{"slug":"quinchia","nombre":"Quinchía","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-75.73108,5.340411]}},{"type":"Feature","properties":{"slug":"quindio","nombre":"Quindío","tipo":"departamentos","conteo":1},"geometry":{"type":"Point","coordinates":[-75.87984,4.535765]}},{"type":"Feature","properties":{"slug":"quipile","nombre":"Quipile","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-74.53333,4.745296]}},{"type":"Feature","properties":{"slug":"raquira","nombre":"Ráquira","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-73.6317,5.539581]}},{"type":"Feature","properties":{"slug":"risaralda","nombre":"Risaralda","tipo":"departamentos","conteo":2},"geometry":{"type":"Point","coordinates":[-75.85371,4.876955]}},{"type":"Feature","properties":{"slug":"sabanagrande","nombre":"Sabanagrande","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-74.75713,10.7888]}},{"type":"Feature","properties":{"slug":"san-agustin","nombre":"San Agustín","tipo":"municipios","conteo":2},"geometry":{"type":"Point","coordinates":[-76.26856,1.881113]}},{"type":"Feature","properties":{"slug":"san-juan-del-cesar","nombre":"San Juan del Cesar","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-73.00323,10.77296]}},{"type":"Feature","properties":{"slug":"serrania-del-perija","nombre":"Serranía del perijá","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-73.01104,10.1198]}},{"type":"Feature","properties":{"slug":"shanghai","nombre":"Shanghai","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[121.52756,31.2245159]}},{"type":"Feature","properties":{"slug":"sierra-nevada-de-santa-marta","nombre":"Sierra Nevada de Santa Marta","tipo":"municipios","conteo":3},"geometry":{"type":"Point","coordinates":[-73.70472,10.80322]}},{"type":"Feature","properties":{"slug":"sierra-nevada-de-santa-marta","nombre":"Sierra Nevada de Santa Marta","tipo":"departamentos","conteo":3},"geometry":{"type":"Point","coordinates":[-73.70472,10.80322]}},{"type":"Feature","properties":{"slug":"silvia","nombre":"Silvia","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-76.37683,2.612557]}},{"type":"Feature","properties":{"slug":"simijaca","nombre":"Simijaca","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-73.85283,5.502895]}},{"type":"Feature","properties":{"slug":"sopo","nombre":"Sopó","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-73.9415,4.907192]}},{"type":"Feature","properties":{"slug":"suarez","nombre":"Suárez","tipo":"municipios","conteo":2},"geometry":{"type":"Point","coordinates":[-76.6943,2.954501]}},{"type":"Feature","properties":{"slug":"susa","nombre":"Susa","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-73.8147,5.453561]}},{"type":"Feature","properties":{"slug":"sutamarchan","nombre":"Sutamarchan","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-73.62027,5.62011]}},{"type":"Feature","properties":{"slug":"tablon-de-gomez","nombre":"Tablón de Gómez","tipo":"municipios","conteo":6},"geometry":{"type":"Point","coordinates":[-77.09767,1.427297]}},{"type":"Feature","properties":{"slug":"tambo","nombre":"Tambo","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-76.81125,2.452202]}},{"type":"Feature","properties":{"slug":"tierrafirme","nombre":"Tierrafirme","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-74.36345,9.328041]}},{"type":"Feature","properties":{"slug":"tinjaca","nombre":"Tinjacá","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-73.64729,5.578859]}},{"type":"Feature","properties":{"slug":"tolemaida","nombre":"Tolemaida","tipo":"municipios","conteo":2},"geometry":{"type":"Point","coordinates":[-74.64637,4.254571]}},{"type":"Feature","properties":{"slug":"tubara","nombre":"Tubará","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-74.97791,10.87381]}},{"type":"Feature","properties":{"slug":"turbo","nombre":"Turbo","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-76.73141,8.093867]}},{"type":"Feature","properties":{"slug":"uribia","nombre":"Uribia","tipo":"municipios","conteo":2},"geometry":{"type":"Point","coordinates":[-72.26593,11.71557]}},{"type":"Feature","properties":{"slug":"valle-de-aburra","nombre":"Valle de aburrá","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-75.57667,6.216123]}},{"type":"Feature","properties":{"slug":"valledupar","nombre":"Valledupar","tipo":"municipios","conteo":3},"geometry":{"type":"Point","coordinates":[-73.25601,10.46568]}},{"type":"Feature","properties":{"slug":"vichada","nombre":"Vichada","tipo":"departamentos","conteo":1},"geometry":{"type":"Point","coordinates":[-69.50606,4.859591]}},{"type":"Feature","properties":{"slug":"villa-de-leiva","nombre":"Villa de leiva","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-73.52697,5.63714]}},{"type":"Feature","properties":{"slug":"villeta","nombre":"Villeta","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-74.47217,5.01063]}},{"type":"Feature","properties":{"slug":"washington","nombre":"Washington","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-77.02963,38.89572]}},{"type":"Feature","properties":{"slug":"vaupes","nombre":"Vaupés","tipo":"departamentos","conteo":2},"geometry":{"type":"Point","coordinates":[-70.86352,0.68265]}},{"type":"Feature","properties":{"slug":"sudafrica","nombre":"Sudáfrica","tipo":"paises","conteo":5},"geometry":{"type":"Point","coordinates":[185.51412,-33.991]}},{"type":"Feature","properties":{"slug":"alemania","nombre":"Alemania","tipo":"paises","conteo":2},"geometry":{"type":"Point","coordinates":[13.409434464984658,52.50245520250017]}},{"type":"Feature","properties":{"slug":"peru","nombre":"Perú","tipo":"paises","conteo":3},"geometry":{"type":"Point","coordinates":[-77.07333938405047,-12.042851360296227]}},{"type":"Feature","properties":{"slug":"camboya","nombre":"Camboya","tipo":"paises","conteo":2},"geometry":{"type":"Point","coordinates":[104.85240072278076,11.559136592207144]}},{"type":"Feature","properties":{"slug":"dubai","nombre":"Dubai","tipo":"paises","conteo":1},"geometry":{"type":"Point","coordinates":[55.24700319430791,25.1667024771733]}},{"type":"Feature","properties":{"slug":"meta","nombre":"Meta","tipo":"departamentos","conteo":3},"geometry":{"type":"Point","coordinates":[-73.07464066969091,3.4739954877001944]}},{"type":"Feature","properties":{"slug":"putumayo","nombre":"Putumayo","tipo":"departamentos","conteo":4},"geometry":{"type":"Point","coordinates":[-75.8468353176599,0.4814555887100976]}},{"type":"Feature","properties":{"slug":"rio-beni","nombre":"Río Beni","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-66.24339300115354,-11.290710332691877]}},{"type":"Feature","properties":{"slug":"ecuador","nombre":"Ecuador","tipo":"paises","conteo":3},"geometry":{"type":"Point","coordinates":[-78.27723694046082,-0.9603258618273744]}},{"type":"Feature","properties":{"slug":"sabana-de-bogota","nombre":"Sabana de Bogotá","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-73.99977075338786,4.858062622596899]}},{"type":"Feature","properties":{"slug":"region-cuenca-media-del-rio-cauca","nombre":"Región cuenca media del río Cauca","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-75.65197362488038,5.787082773904699]}},{"type":"Feature","properties":{"slug":"sutamarchan","nombre":"Sutamarchán","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-73.62095797820405,5.61968315930457]}},{"type":"Feature","properties":{"slug":"samaca","nombre":"Samacá","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-73.48549388275097,5.493196843626004]}},{"type":"Feature","properties":{"slug":"venezuela","nombre":"Venezuela","tipo":"paises","conteo":2},"geometry":{"type":"Point","coordinates":[-66.857381058887,10.434971257938633]}},{"type":"Feature","properties":{"slug":"rio-inirida","nombre":"Río Inirida","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-69.6606021607646,2.5108141269105655]}},{"type":"Feature","properties":{"slug":"rio-atabapo","nombre":"Río Atabapo","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-67.43100896035111,3.575365231472792]}},{"type":"Feature","properties":{"slug":"narino","nombre":"Nariño","tipo":"departamentos","conteo":8},"geometry":{"type":"Point","coordinates":[-77.95780064609797,1.6349764242024165]}},{"type":"Feature","properties":{"slug":"ciudad-perdida","nombre":"Ciudad Pérdida","tipo":"municipios","conteo":1},"geometry":{"type":"Point","coordinates":[-73.92244339622708,11.033266372215062]}},{"type":"Feature","properties":{"slug":"bolivia","nombre":"Bolivia","tipo":"paises","conteo":2},"geometry":{"type":"Point","coordinates":[-64.56453216281521,-17.227338992193364]}},{"type":"Feature","properties":{"slug":"santa-marta","nombre":"Santa Marta","tipo":"municipios","conteo":2},"geometry":{"type":"Point","coordinates":[-74.1904221703084,11.236576368059053]}}]} \ No newline at end of file diff --git a/estaticos/datosMapaEgresados.geo.json b/estaticos/datosMapaEgresados.geo.json index 4083ba4..96ce5d8 100644 --- a/estaticos/datosMapaEgresados.geo.json +++ b/estaticos/datosMapaEgresados.geo.json @@ -1 +1 @@ -{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"slug":"berlin","nombre":"Berlín","conteo":2},"geometry":{"type":"Point","coordinates":[13.259928,52.50673]}},{"type":"Feature","properties":{"slug":"bogota","nombre":"Bogotá","conteo":53},"geometry":{"type":"Point","coordinates":[-74.10378,4.64958]}},{"type":"Feature","properties":{"slug":"bucaramanga","nombre":"Bucaramanga","conteo":1},"geometry":{"type":"Point","coordinates":[-73.12099,7.11168]}},{"type":"Feature","properties":{"slug":"cali","nombre":"Cali","conteo":2},"geometry":{"type":"Point","coordinates":[-76.68155,3.39505]}},{"type":"Feature","properties":{"slug":"cambridge","nombre":"Cambridge","conteo":2},"geometry":{"type":"Point","coordinates":[0.04205,52.19881]}},{"type":"Feature","properties":{"slug":"honda","nombre":"Honda","conteo":1},"geometry":{"type":"Point","coordinates":[-74.84303,5.2104266]}},{"type":"Feature","properties":{"slug":"johannesburgo","nombre":"Johannesburgo","conteo":1},"geometry":{"type":"Point","coordinates":[27.9988,-26.17151]}},{"type":"Feature","properties":{"slug":"madrid","nombre":"Madrid","conteo":2},"geometry":{"type":"Point","coordinates":[-3.84434,40.43783]}},{"type":"Feature","properties":{"slug":"medellin","nombre":"Medellín","conteo":2},"geometry":{"type":"Point","coordinates":[-75.57667,6.216123]}},{"type":"Feature","properties":{"slug":"oakland","nombre":"Oakland","conteo":1},"geometry":{"type":"Point","coordinates":[-122.4001,37.7586]}},{"type":"Feature","properties":{"slug":"oregon","nombre":"Oregon","conteo":1},"geometry":{"type":"Point","coordinates":[-123.2223,44.1152]}},{"type":"Feature","properties":{"slug":"oxford","nombre":"Oxford","conteo":1},"geometry":{"type":"Point","coordinates":[-1.288787,51.75041]}},{"type":"Feature","properties":{"slug":"quibdo","nombre":"Quibdó","conteo":1},"geometry":{"type":"Point","coordinates":[-76.65319,5.68914]}},{"type":"Feature","properties":{"slug":"utrecht","nombre":"Utrecht","conteo":1},"geometry":{"type":"Point","coordinates":[5.00009,52.0841]}},{"type":"Feature","properties":{"slug":"viena","nombre":"Viena","conteo":1},"geometry":{"type":"Point","coordinates":[16.29727,48.22025]}},{"type":"Feature","properties":{"slug":"dubai","nombre":"Dubai","conteo":1},"geometry":{"type":"Point","coordinates":[55.24700319430791,25.1667024771733]}}]} \ No newline at end of file +{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"slug":"berlin","nombre":"Berlín","tipo":"ciudades","conteo":2},"geometry":{"type":"Point","coordinates":[13.259928,52.50673]}},{"type":"Feature","properties":{"slug":"bogota","nombre":"Bogotá","tipo":"ciudades","conteo":53},"geometry":{"type":"Point","coordinates":[-74.10378,4.64958]}},{"type":"Feature","properties":{"slug":"bucaramanga","nombre":"Bucaramanga","tipo":"ciudades","conteo":1},"geometry":{"type":"Point","coordinates":[-73.12099,7.11168]}},{"type":"Feature","properties":{"slug":"cali","nombre":"Cali","tipo":"ciudades","conteo":2},"geometry":{"type":"Point","coordinates":[-76.68155,3.39505]}},{"type":"Feature","properties":{"slug":"cambridge","nombre":"Cambridge","tipo":"ciudades","conteo":2},"geometry":{"type":"Point","coordinates":[0.04205,52.19881]}},{"type":"Feature","properties":{"slug":"colombia","nombre":"Colombia","tipo":"paises","conteo":60},"geometry":{"type":"Point","coordinates":[-74.10378,4.64958]}},{"type":"Feature","properties":{"slug":"honda","nombre":"Honda","tipo":"ciudades","conteo":1},"geometry":{"type":"Point","coordinates":[-74.84303,5.2104266]}},{"type":"Feature","properties":{"slug":"johannesburgo","nombre":"Johannesburgo","tipo":"ciudades","conteo":1},"geometry":{"type":"Point","coordinates":[27.9988,-26.17151]}},{"type":"Feature","properties":{"slug":"madrid","nombre":"Madrid","tipo":"ciudades","conteo":2},"geometry":{"type":"Point","coordinates":[-3.84434,40.43783]}},{"type":"Feature","properties":{"slug":"medellin","nombre":"Medellín","tipo":"ciudades","conteo":2},"geometry":{"type":"Point","coordinates":[-75.57667,6.216123]}},{"type":"Feature","properties":{"slug":"oakland","nombre":"Oakland","tipo":"ciudades","conteo":1},"geometry":{"type":"Point","coordinates":[-122.4001,37.7586]}},{"type":"Feature","properties":{"slug":"oregon","nombre":"Oregon","tipo":"ciudades","conteo":1},"geometry":{"type":"Point","coordinates":[-123.2223,44.1152]}},{"type":"Feature","properties":{"slug":"oxford","nombre":"Oxford","tipo":"ciudades","conteo":1},"geometry":{"type":"Point","coordinates":[-1.288787,51.75041]}},{"type":"Feature","properties":{"slug":"quibdo","nombre":"Quibdó","tipo":"ciudades","conteo":1},"geometry":{"type":"Point","coordinates":[-76.65319,5.68914]}},{"type":"Feature","properties":{"slug":"utrecht","nombre":"Utrecht","tipo":"ciudades","conteo":1},"geometry":{"type":"Point","coordinates":[5.00009,52.0841]}},{"type":"Feature","properties":{"slug":"viena","nombre":"Viena","tipo":"ciudades","conteo":1},"geometry":{"type":"Point","coordinates":[16.29727,48.22025]}},{"type":"Feature","properties":{"slug":"alemania","nombre":"Alemania","tipo":"paises","conteo":2},"geometry":{"type":"Point","coordinates":[13.409434464984658,52.50245520250017]}},{"type":"Feature","properties":{"slug":"dubai","nombre":"Dubai","tipo":"ciudades","conteo":1},"geometry":{"type":"Point","coordinates":[55.24700319430791,25.1667024771733]}}]} \ No newline at end of file diff --git a/procesador/egresados.ts b/procesador/egresados.ts index 88393e5..19ac187 100644 --- a/procesador/egresados.ts +++ b/procesador/egresados.ts @@ -1,26 +1,8 @@ import { getXlsxStream } from 'xlstream'; import slugificar from 'slug'; -import type { DefinicionSimple, ElementoLista, CamposEgresados } from '../src/tipos.js'; +import type { DefinicionSimple, ElementoLista, CamposEgresados, ListasEgresados, Egresado } from '../src/tipos.js'; import { guardarJSON, ordenarListaObjetos } from './ayudas.js'; -export interface Egresado { - id: number; - nombre: string; - graduacion?: string; - institucion?: DefinicionSimple; - temas?: DefinicionSimple[]; - ambitos?: DefinicionSimple[]; - ciudades?: DefinicionSimple[]; - paises?: DefinicionSimple[]; -} - -export interface ListasEgresados { - temas: ElementoLista[]; - ambitos: ElementoLista[]; - paises: ElementoLista[]; - ciudades: ElementoLista[]; -} - const camposMultiplesEgresados: CamposEgresados = [ { llave: 'ambitos', indice: 4 }, { llave: 'paises', indice: 6 }, diff --git a/procesador/lugares.ts b/procesador/lugares.ts index 3836c5f..8bc85b5 100644 --- a/procesador/lugares.ts +++ b/procesador/lugares.ts @@ -1,152 +1,101 @@ import { getXlsxStream } from 'xlstream'; import slugificar from 'slug'; -import type { Listas, Lugar } from '../src/tipos.js'; +import type { Listas, Lugar, TiposLugares } from '../src/tipos.js'; import { guardarJSON } from './ayudas.js'; import type { Feature, FeatureCollection, Point } from 'geojson'; import type { ListasEgresados } from './egresados.js'; -export async function procesarLugares(archivo: string, listas: Listas): Promise { - return new Promise(async (resolver) => { - const flujoLugares = await getXlsxStream({ - filePath: archivo, - sheet: 'lugares', - withHeader: false, - ignoreEmpty: true - }); - - let numeroFila = 1; - const lugares: Lugar[] = []; - const geojson: FeatureCollection = { type: 'FeatureCollection', features: [] }; - - flujoLugares.on('data', (fila) => { - if (numeroFila > 2) { - procesarLugar(fila.formatted.arr); - } else { - } - - numeroFila++; - }); - - flujoLugares.on('close', () => { - procesarDatosMapa(); - guardarJSON(geojson, 'datosMapa.geo'); +function procesarDatosMapa(lugares: Lugar[]) { + const geojson: FeatureCollection = { type: 'FeatureCollection', features: [] }; - resolver(); - }); + for (let lugar in lugares) { + const datosLugar = lugares[lugar]; + const conteo = datosLugar.conteo; - function procesarLugar(fila: string[]) { - const nombreLugar = fila[0].trim(); - const slug = slugificar(nombreLugar); - const longitud = fila[6]; - const latitud = fila[5]; - const lugar = listas.municipios.filter((elemento) => elemento.slug === slug); - const conteo = lugar[0] ? lugar[0].conteo : 0; - - const respuesta: Lugar = { - nombre: nombreLugar, - slug: slug, - lon: +longitud, - lat: +latitud, + const elemento: Feature = { + type: 'Feature', + properties: { + slug: datosLugar.slug, + nombre: datosLugar.nombre, + tipo: datosLugar.tipo, conteo - }; + }, + geometry: { type: 'Point', coordinates: [datosLugar.lon, datosLugar.lat] } + }; - if (respuesta.lon && respuesta.lat) { - lugares.push(respuesta); - } + if (conteo > 0) { + geojson.features.push(elemento); } + } - // Función para crear geojson con lugares y cantidad de proyectos por lugar - function procesarDatosMapa() { - for (let lugar in lugares) { - const conteo = lugares[lugar].conteo; - - const elemento: Feature = { - type: 'Feature', - properties: { - slug: lugares[lugar].slug, - nombre: lugares[lugar].nombre, - conteo - }, - geometry: { type: 'Point', coordinates: [lugares[lugar].lon, lugares[lugar].lat] } - }; - - if (conteo > 0) { - geojson.features.push(elemento); - } - } - } - }); + return geojson; +} + +function agregarLugarALista( + nombre: string, + slug: string, + lon: number, + lat: number, + conteo: number, + tipo: TiposLugares, + lista: Lugar[] +) { + const respuesta: Lugar = { + nombre, + slug, + lon, + lat, + conteo, + tipo + }; + + if (respuesta.lon && respuesta.lat) { + lista.push(respuesta); + } } -export async function procesarLugaresEgresados(archivo: string, listas: ListasEgresados): Promise { +export async function procesarLugares(archivo: string, listas: Listas, listasE: ListasEgresados): Promise { return new Promise(async (resolver) => { const flujoLugares = await getXlsxStream({ filePath: archivo, sheet: 'lugares', - withHeader: false, + withHeader: true, ignoreEmpty: true }); - let numeroFila = 1; - const lugares: Lugar[] = []; - const geojson: FeatureCollection = { type: 'FeatureCollection', features: [] }; + const lugaresProyectos: Lugar[] = []; + const lugaresEgresados: Lugar[] = []; flujoLugares.on('data', (fila) => { - if (numeroFila > 2) { - procesarLugar(fila.formatted.arr); - } else { - } + const datos = fila.formatted.arr; + const nombreLugar = datos[0].trim(); + const slug = slugificar(nombreLugar); + const longitud = datos[6]; + const latitud = datos[5]; + + const mun = listas.municipios.find((m) => m.slug === slug); + if (mun) agregarLugarALista(nombreLugar, slug, +longitud, +latitud, mun.conteo, 'municipios', lugaresProyectos); + + const dep = listas.departamentos.find((d) => d.slug === slug); + if (dep) + agregarLugarALista(nombreLugar, slug, +longitud, +latitud, dep.conteo, 'departamentos', lugaresProyectos); + + const pais = listas.paises.find((p) => p.slug === slug); + if (pais) agregarLugarALista(nombreLugar, slug, +longitud, +latitud, pais.conteo, 'paises', lugaresProyectos); - numeroFila++; + // Egresados + const ciudad = listasE.ciudades.find((c) => c.slug === slug); + if (ciudad) + agregarLugarALista(nombreLugar, slug, +longitud, +latitud, ciudad.conteo, 'ciudades', lugaresEgresados); + + const paisE = listasE.paises.find((p) => p.slug === slug); + if (paisE) agregarLugarALista(nombreLugar, slug, +longitud, +latitud, paisE.conteo, 'paises', lugaresEgresados); }); flujoLugares.on('close', () => { - procesarDatosMapaEgresados(); - guardarJSON(geojson, 'datosMapaEgresados.geo'); - console.log('listo'); + guardarJSON(procesarDatosMapa(lugaresProyectos), 'datosMapa.geo'); + guardarJSON(procesarDatosMapa(lugaresEgresados), 'datosMapaEgresados.geo'); resolver(); }); - - function procesarLugar(fila: string[]) { - const nombreLugar = fila[0].trim(); - const slug = slugificar(nombreLugar); - const longitud = fila[6]; - const latitud = fila[5]; - const lugar = listas.ciudades.filter((elemento) => elemento.slug === slug); - const conteo = lugar[0] ? lugar[0].conteo : 0; - - const respuesta: Lugar = { - nombre: nombreLugar, - slug: slug, - lon: +longitud, - lat: +latitud, - conteo - }; - - if (respuesta.lon && respuesta.lat) { - lugares.push(respuesta); - } - } - - // Función para crear geojson con lugares y cantidad de proyectos por lugar - function procesarDatosMapaEgresados() { - for (let lugar in lugares) { - const conteo = lugares[lugar].conteo; - - const elemento: Feature = { - type: 'Feature', - properties: { - slug: lugares[lugar].slug, - nombre: lugares[lugar].nombre, - conteo - }, - geometry: { type: 'Point', coordinates: [lugares[lugar].lon, lugares[lugar].lat] } - }; - - if (conteo > 0) { - geojson.features.push(elemento); - } - } - } }); } diff --git a/procesador/procesador.ts b/procesador/procesador.ts index e8d3c52..9eb79d1 100644 --- a/procesador/procesador.ts +++ b/procesador/procesador.ts @@ -12,7 +12,7 @@ import type { import { getXlsxStream } from 'xlstream'; import slugificar from 'slug'; import { enMinusculas, guardarJSON, ordenarListaObjetos } from './ayudas.js'; -import { procesarLugares, procesarLugaresEgresados } from './lugares.js'; +import { procesarLugares } from './lugares.js'; import procesarEgresados from './egresados.js'; import { existsSync, readdirSync } from 'fs'; import { resolve } from 'path'; @@ -66,21 +66,17 @@ async function procesar() { personas = await procesarPersonas(archivo); const egresados = await procesarEgresados(archivo, listasEgresados); + await procesarProyectos(); console.log('Proyectos procesados'); - await procesarLugares(archivo, listas); - + await procesarLugares(archivo, listas, listasEgresados); console.log('fin de lugares'); - await procesarLugaresEgresados(archivo, listasEgresados); - procesarDatosBuscador(egresados); console.log('listos datos buscador'); - await agregarDescripciones(); console.log('listas descripciones áreas'); await agregarDescripcionesRamas(); console.log('listas descripciones ramas'); - guardarJSON(listas, 'listas'); console.log('fin'); } diff --git a/src/componentes/Mapa.astro b/src/componentes/Mapa.astro index f3db734..c300450 100644 --- a/src/componentes/Mapa.astro +++ b/src/componentes/Mapa.astro @@ -10,6 +10,7 @@ import { actualizarUrl, datosListas, datosListasEgresados, geo } from '@/utilidades/cerebro'; import 'mapbox-gl/dist/mapbox-gl.css'; import { vista } from '@/utilidades/cerebro'; + import type { Listas, ListasEgresados, TiposLugaresEgresados, TiposLugaresProyectos } from '@/tipos'; let mapaCreado = false; // Instancia creada let mapaCargado = false; // Instancia creada y ya terminó de cargar en la página @@ -177,14 +178,16 @@ const datosPunto = evento.features?.[0].properties; if (datosPunto && datosPunto.slug) { const esProyectos = vista.get() === 'proyectos'; - const fuente = esProyectos ? datosListas.get().municipios : datosListasEgresados.get().ciudades; + const fuente = esProyectos + ? datosListas.get()[datosPunto.tipo as TiposLugaresProyectos] + : datosListasEgresados.get()[datosPunto.tipo as TiposLugaresEgresados]; const indiceLugar = fuente.findIndex((obj) => obj.slug === datosPunto.slug); + actualizarUrl([ { nombre: 'id', valor: `${indiceLugar}` }, - { nombre: 'tipo', valor: esProyectos ? 'municipios' : 'ciudades' } + { nombre: 'tipo', valor: datosPunto.tipo } ]); } - // mapa.getCanvas().style.cursor = ''; }); mapa.on('click', 'grupos', (evento) => { @@ -203,9 +206,20 @@ contenedor.className = 'listaLugares'; const esProyectos = vista.get() === 'proyectos'; - const fuente = esProyectos ? datosListas.get().municipios : datosListasEgresados.get().ciudades; + const baseFuente = esProyectos ? datosListas.get() : datosListasEgresados.get(); + + features.sort((a, b) => { + if (a.properties?.slug < b.properties?.slug) return -1; + else if (a.properties?.slug > b.properties?.slug) return 1; + return 0; + }); features.forEach((lugar) => { + const tipo = lugar.properties?.tipo; + const fuente = esProyectos + ? (baseFuente as Listas)[tipo as TiposLugaresProyectos] + : (baseFuente as ListasEgresados)[tipo as TiposLugaresEgresados]; + const indiceLugar = fuente.findIndex((obj) => obj.slug === lugar.properties?.slug); const datosLugar = fuente[indiceLugar]; @@ -215,9 +229,10 @@ enlaceIdeaJulian.onclick = () => { popup.remove(); + actualizarUrl([ { nombre: 'id', valor: `${indiceLugar}` }, - { nombre: 'tipo', valor: esProyectos ? 'municipios' : 'ciudades' } + { nombre: 'tipo', valor: tipo } ]); }; diff --git a/src/tipos.ts b/src/tipos.ts index 97c7db1..da626d2 100644 --- a/src/tipos.ts +++ b/src/tipos.ts @@ -72,6 +72,9 @@ export type Listas = { }; export type Campos = { llave: LLavesMultiples; indice: number; procesarAparte?: boolean }[]; +export type TiposLugaresProyectos = 'municipios' | 'departamentos' | 'paises'; +export type TiposLugaresEgresados = 'ciudades' | 'paises'; +export type TiposLugares = TiposLugaresProyectos | TiposLugaresEgresados; export type Lugar = { nombre: string; @@ -79,6 +82,7 @@ export type Lugar = { lat: number; lon: number; conteo: number; + tipo: TiposLugares; }; export interface ElementoFicha { @@ -155,3 +159,21 @@ export interface ElementoBuscador extends OpcionBuscadorDatos { export interface PersonaID { [nombre: string]: number; } + +export interface Egresado { + id: number; + nombre: string; + graduacion?: string; + institucion?: DefinicionSimple; + temas?: DefinicionSimple[]; + ambitos?: DefinicionSimple[]; + ciudades?: DefinicionSimple[]; + paises?: DefinicionSimple[]; +} + +export interface ListasEgresados { + temas: ElementoLista[]; + ambitos: ElementoLista[]; + paises: ElementoLista[]; + ciudades: ElementoLista[]; +} diff --git a/src/utilidades/cerebro.ts b/src/utilidades/cerebro.ts index 31bae41..0599c41 100644 --- a/src/utilidades/cerebro.ts +++ b/src/utilidades/cerebro.ts @@ -9,10 +9,15 @@ import type { ElementoFicha, ElementoEgresado, ElementoBuscador, - OpcionBuscadorDatos + OpcionBuscadorDatos, + ElementoLista, + DefinicionSimple, + TiposLugaresProyectos, + TiposLugaresEgresados, + ListasEgresados, + Egresado } from '@/tipos'; -import type { Feature, FeatureCollection, Point } from 'geojson'; -import type { Egresado, ListasEgresados } from '../../procesador/egresados'; +import type { FeatureCollection, Point } from 'geojson'; export const datosProyectos = atom([]); export const datosFicha = map({ visible: false }); @@ -122,34 +127,18 @@ vista.subscribe(async (vistaActual) => { export function filtrarMapa(lugares?: { slug: string; conteo: number }[]) { if (lugares) { const vistaActual = vista.get(); - let lugaresFiltrados: Feature[] = []; - - if (vistaActual === 'proyectos') { - lugaresFiltrados = _copiaDatosMapa?.features.filter((lugar) => - lugares.find((obj) => obj.slug === lugar.properties?.slug) - ); - - lugaresFiltrados.map((punto) => { - if (punto.properties) { - const datosLugar = lugares.find((obj) => obj.slug === punto.properties?.slug); - punto.properties.conteo = datosLugar?.conteo; - } - return punto; - }); - } else if (vistaActual === 'egresados') { - lugaresFiltrados = _copiaDatosMapaEgresados?.features.filter((lugar) => - lugares.find((obj) => obj.slug === lugar.properties?.slug) - ); - - lugaresFiltrados.map((punto) => { - if (punto.properties) { - const datosLugar = lugares.find((obj) => obj.slug === punto.properties?.slug); - punto.properties.conteo = datosLugar?.conteo; - } + const fuente = vistaActual === 'proyectos' ? _copiaDatosMapa : _copiaDatosMapaEgresados; + const lugaresFiltrados = fuente?.features.filter((lugar) => + lugares.find((obj) => obj.slug === lugar.properties?.slug) + ); + + lugaresFiltrados.forEach((punto) => { + if (punto.properties) { + const datosLugar = lugares.find((obj) => obj.slug === punto.properties?.slug); + punto.properties.conteo = datosLugar?.conteo; + } + }); - return punto; - }); - } if (lugaresFiltrados) { geo.setKey('features', lugaresFiltrados); } @@ -162,6 +151,81 @@ export function filtrarMapa(lugares?: { slug: string; conteo: number }[]) { } } +function actualizarLugar(tipo: string, slug: string, conteo: number, relaciones: ElementoLista['relaciones']) { + if (tipo === 'municipios' || tipo === 'departamentos' || tipo === 'paises' || tipo === 'ciudades') { + filtrarMapa([{ slug, conteo }]); + } else { + const lugaresMapa = relaciones.filter((relacion) => { + return ( + relacion.tipo === 'municipios' || + relacion.tipo === 'departamentos' || + relacion.tipo === 'paises' || + relacion.tipo === 'ciudades' + ); + }); + + filtrarMapa( + lugaresMapa.map((lugar) => { + return { slug: lugar.slug, conteo: lugar.conteo }; + }) + ); + } +} + +function buscarLugares(tipo: 'proyectos' | 'egresados', datos: Proyecto | Egresado) { + const lugares: { slug: string; conteo: number }[] = []; + + if (tipo === 'proyectos') { + const { departamentos, municipios } = datos as Proyecto; + if (municipios) lugares.push(...filtrar('municipios', municipios)); + if (departamentos) lugares.push(...filtrar('departamentos', departamentos)); + } else { + const { ciudades } = datos as Egresado; + if (ciudades) lugares.push(...filtrar('ciudades', ciudades)); + } + + if (datos.paises) lugares.push(...filtrar('paises', datos.paises)); + lugares.length ? filtrarMapa(lugares) : filtrarMapa([]); + + function filtrar(tipoLugar: 'municipios' | 'departamentos' | 'paises' | 'ciudades', lugares: DefinicionSimple[]) { + const esProyectos = tipo === 'proyectos'; + + const datosLugares = esProyectos + ? datosListas.get()[tipoLugar as TiposLugaresProyectos] + : datosListasEgresados.get()[tipoLugar as TiposLugaresEgresados]; + + return lugares.map((obj) => { + const lugar = datosLugares.find((l) => l.slug === obj.slug); + return { slug: obj.slug, conteo: lugar ? lugar.conteo : 1 }; + }); + } +} + +function agruparRelaciones( + tipo: 'proyectos' | 'egresados', + relaciones: ElementoLista['relaciones'], + listas: Listas | ListasEgresados +) { + return relaciones.reduce((lista: { [llave: string]: ElementoFicha[] }, valorActual) => { + if (!lista[valorActual.tipo]) { + lista[valorActual.tipo] = []; + } + const { nombre } = + tipo === 'proyectos' + ? (listas as Listas)[valorActual.tipo as keyof Listas][valorActual.indice] + : (listas as ListasEgresados)[valorActual.tipo as keyof ListasEgresados][valorActual.indice]; + + lista[valorActual.tipo].push({ + slug: valorActual.slug, + conteo: valorActual.conteo, + nombre + }); + + ordenarListaObjetos(lista[valorActual.tipo], 'slug', true); + return lista; + }, {}); +} + elementoSeleccionado.subscribe((elemento) => { if (!Object.keys(elemento).length) return; @@ -171,18 +235,9 @@ elementoSeleccionado.subscribe((elemento) => { if (!enEgresados) { if (tipo === 'proyecto') { const datosProyecto = datosProyectos.get()[+id]; - if (!datosProyecto) return; - if (datosProyecto.municipios) { - filtrarMapa( - datosProyecto.municipios.map((lugar) => { - return { slug: lugar.slug, conteo: 1 }; - }) - ); - } else { - filtrarMapa([]); - } + buscarLugares('proyectos', datosProyecto); datosFicha.set({ visible: true, @@ -205,48 +260,19 @@ elementoSeleccionado.subscribe((elemento) => { } else { const listas = datosListas.value; if (!listas) return; + const datos = listas[tipo as keyof Listas][+id]; if (datos) { const proyectos = datos.proyectos?.reduce((lista: ElementoProyecto[], indiceProyecto) => { const proyecto = datosProyectos.value?.find((p) => p.id === indiceProyecto); - if (proyecto) { - lista.push({ nombre: proyecto.nombre.nombre, id: proyecto.id }); - } - + if (proyecto) lista.push({ nombre: proyecto.nombre.nombre, id: proyecto.id }); ordenarListaObjetos(lista, 'nombre', true); return lista; }, []); - const relaciones: RelacionesFicha = datos.relaciones.reduce( - (lista: { [llave: string]: ElementoFicha[] }, valorActual) => { - if (!lista[valorActual.tipo]) { - lista[valorActual.tipo] = []; - } - - lista[valorActual.tipo].push({ - slug: valorActual.slug, - conteo: valorActual.conteo, - nombre: listas[valorActual.tipo as keyof Listas][valorActual.indice].nombre - }); - - ordenarListaObjetos(lista[valorActual.tipo], 'slug', true); - return lista; - }, - {} - ); - - if (tipo === 'municipios') { - filtrarMapa([{ slug: datos.slug, conteo: datos.conteo }]); - } else { - const lugaresMapa = datos.relaciones.filter((relacion) => relacion.tipo === 'municipios'); - - filtrarMapa( - lugaresMapa.map((lugar) => { - return { slug: lugar.slug, conteo: lugar.conteo }; - }) - ); - } + actualizarLugar(tipo, datos.slug, datos.conteo, datos.relaciones); + const relaciones: RelacionesFicha = agruparRelaciones('proyectos', datos.relaciones, listas); datosFicha.set({ visible: true, @@ -271,9 +297,10 @@ elementoSeleccionado.subscribe((elemento) => { } else { if (tipo === 'egresado') { const datosEgresado = datosEgresados.get()[+id]; - if (!datosEgresado) return; + buscarLugares('egresados', datosEgresado); + datosFicha.set({ visible: true, lista: 'Egresado/a', @@ -292,43 +319,13 @@ elementoSeleccionado.subscribe((elemento) => { if (datos) { const egresados = datos.egresados?.reduce((lista: ElementoEgresado[], indiceEgresado) => { const egresado = datosEgresados.value?.find((p) => p.id === indiceEgresado); - if (egresado) { - lista.push({ nombre: egresado.nombre, id: egresado.id }); - } - + if (egresado) lista.push({ nombre: egresado.nombre, id: egresado.id }); ordenarListaObjetos(lista, 'nombre', true); return lista; }, []); - const relaciones: RelacionesFicha = datos.relaciones.reduce( - (lista: { [llave: string]: ElementoFicha[] }, valorActual) => { - if (!lista[valorActual.tipo]) { - lista[valorActual.tipo] = []; - } - - lista[valorActual.tipo].push({ - slug: valorActual.slug, - conteo: valorActual.conteo, - nombre: listas[valorActual.tipo as keyof ListasEgresados][valorActual.indice].nombre - }); - - ordenarListaObjetos(lista[valorActual.tipo], 'slug', true); - return lista; - }, - {} - ); - - if (tipo === 'ciudades') { - filtrarMapa([{ slug: datos.slug, conteo: datos.conteo }]); - } else { - const lugaresMapa = datos.relaciones.filter((relacion) => relacion.tipo === 'ciudades'); - - filtrarMapa( - lugaresMapa.map((lugar) => { - return { slug: lugar.slug, conteo: lugar.conteo }; - }) - ); - } + actualizarLugar(tipo, datos.slug, datos.conteo, datos.relaciones); + const relaciones: RelacionesFicha = agruparRelaciones('egresados', datos.relaciones, listas); datosFicha.set({ visible: true, @@ -360,11 +357,8 @@ export function actualizarUrl(valores: { nombre: string; valor: string }[], nuev const parametros = new URLSearchParams(window.location.search); valores.forEach((obj) => { - if (obj.valor) { - parametros.set(obj.nombre, obj.valor); - } else { - parametros.delete(obj.nombre); - } + if (obj.valor) parametros.set(obj.nombre, obj.valor); + else parametros.delete(obj.nombre); }); window.history.pushState({}, '', decodeURIComponent(`${window.location.pathname}?${parametros}`));