mirror of https://github.com/acanas/swad-core.git
Version19.112.1
This commit is contained in:
parent
4cf24dba3c
commit
67d3b60ec3
|
@ -492,7 +492,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
|
|||
En OpenSWAD:
|
||||
ps2pdf source.ps destination.pdf
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 19.112 (2020-01-03)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 19.112.1 (2020-01-03)"
|
||||
#define CSS_FILE "swad19.112.css"
|
||||
#define JS_FILE "swad19.91.1.js"
|
||||
/*
|
||||
|
@ -500,6 +500,7 @@ ps2pdf source.ps destination.pdf
|
|||
// TODO: Impedir la creación y edición de proyectos si no son editables.
|
||||
// TODO: No se puede entrar con DNI '1' suponiendo que no tenga password ¿por qué?
|
||||
|
||||
Version 19.112.1: Jan 03, 2020 Code refactoring in maps. (278376 lines)
|
||||
Version 19.112: Jan 03, 2020 Map in country information. (278380 lines)
|
||||
Version 19.111.3: Jan 03, 2020 Code refactoring in maps. (278251 lines)
|
||||
Version 19.111.2: Jan 03, 2020 Map in institution information. (278231 lines)
|
||||
|
|
|
@ -247,14 +247,12 @@ static bool CtyCfg_GetIfMapIsAvailable (void)
|
|||
|
||||
static void CtyCfg_GetCoordAndZoom (struct Coordinates *Coord,unsigned *Zoom)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
double MaxDistance;
|
||||
char *Query;
|
||||
|
||||
/***** Get average coordinates of centres of current country
|
||||
with both coordinates set
|
||||
(coordinates 0, 0 means not set ==> don't show map) *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get centres with coordinates",
|
||||
if (asprintf (&Query,
|
||||
"SELECT AVG(centres.Latitude)," // row[0]
|
||||
"AVG(centres.Longitude)," // row[1]
|
||||
"GREATEST(MAX(centres.Latitude)-MIN(centres.Latitude),"
|
||||
|
@ -264,30 +262,10 @@ static void CtyCfg_GetCoordAndZoom (struct Coordinates *Coord,unsigned *Zoom)
|
|||
" AND institutions.InsCod=centres.InsCod"
|
||||
" AND centres.Latitude<>0"
|
||||
" AND centres.Longitude<>0",
|
||||
Gbl.Hierarchy.Cty.CtyCod))
|
||||
{
|
||||
/* Get row */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/* Get latitude (row[0]) */
|
||||
Coord->Latitude = Map_GetLatitudeFromStr (row[0]);
|
||||
|
||||
/* Get longitude (row[1]) */
|
||||
Coord->Longitude = Map_GetLongitudeFromStr (row[1]);
|
||||
|
||||
/* Get maximum distance (row[2]) */
|
||||
MaxDistance = Str_GetDoubleFromStr (row[2]);
|
||||
}
|
||||
else
|
||||
Coord->Latitude =
|
||||
Coord->Longitude =
|
||||
MaxDistance = 0.0;
|
||||
|
||||
/***** Convert distance to zoom *****/
|
||||
*Zoom = Map_GetZoomFromDistance (MaxDistance);
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
Gbl.Hierarchy.Cty.CtyCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Map_GetCoordAndZoom (Coord,Zoom,Query);
|
||||
free (Query);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -257,14 +257,12 @@ static bool InsCfg_GetIfMapIsAvailable (void)
|
|||
|
||||
static void InsCfg_GetCoordAndZoom (struct Coordinates *Coord,unsigned *Zoom)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
double MaxDistance;
|
||||
char *Query;
|
||||
|
||||
/***** Get average coordinates of centres of current institution
|
||||
with both coordinates set
|
||||
(coordinates 0, 0 means not set ==> don't show map) *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get centres with coordinates",
|
||||
if (asprintf (&Query,
|
||||
"SELECT AVG(Latitude)," // row[0]
|
||||
"AVG(Longitude)," // row[1]
|
||||
"GREATEST(MAX(Latitude)-MIN(Latitude),"
|
||||
|
@ -273,30 +271,10 @@ static void InsCfg_GetCoordAndZoom (struct Coordinates *Coord,unsigned *Zoom)
|
|||
" WHERE InsCod=%ld"
|
||||
" AND Latitude<>0"
|
||||
" AND Longitude<>0",
|
||||
Gbl.Hierarchy.Ins.InsCod))
|
||||
{
|
||||
/* Get row */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/* Get latitude (row[0]) */
|
||||
Coord->Latitude = Map_GetLatitudeFromStr (row[0]);
|
||||
|
||||
/* Get longitude (row[1]) */
|
||||
Coord->Longitude = Map_GetLongitudeFromStr (row[1]);
|
||||
|
||||
/* Get maximum distance (row[2]) */
|
||||
MaxDistance = Str_GetDoubleFromStr (row[2]);
|
||||
}
|
||||
else
|
||||
Coord->Latitude =
|
||||
Coord->Longitude =
|
||||
MaxDistance = 0.0;
|
||||
|
||||
/***** Convert distance to zoom *****/
|
||||
*Zoom = Map_GetZoomFromDistance (MaxDistance);
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
Gbl.Hierarchy.Ins.InsCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Map_GetCoordAndZoom (Coord,Zoom,Query);
|
||||
free (Query);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
57
swad_map.c
57
swad_map.c
|
@ -25,14 +25,10 @@
|
|||
/********************************* Headers ***********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
// #define _GNU_SOURCE // For asprintf
|
||||
// #include <stdbool.h> // For boolean type
|
||||
// #include <stddef.h> // For NULL
|
||||
// #include <stdio.h> // For asprintf
|
||||
// #include <string.h> // For string functions
|
||||
// #include <unistd.h> // For unlink
|
||||
#define _GNU_SOURCE // For asprintf
|
||||
#include <stdio.h> // For asprintf
|
||||
|
||||
// #include "swad_global.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_HTML.h"
|
||||
#include "swad_map.h"
|
||||
#include "swad_string.h"
|
||||
|
@ -59,12 +55,14 @@
|
|||
/***************************** Private prototypes ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/* https://leafletjs.com/examples/quick-start/ */
|
||||
static unsigned Map_GetZoomFromDistance (double MaxDistance);
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************* Leaflet CSS ******************************/
|
||||
/******************************** Leaflet CSS ********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/* https://leafletjs.com/examples/quick-start/ */
|
||||
|
||||
void Map_LeafletCSS (void)
|
||||
{
|
||||
HTM_Txt ("<link rel=\"stylesheet\""
|
||||
|
@ -165,6 +163,45 @@ void Map_AddPopup (const char *Title,const char *Subtitle,bool Open)
|
|||
HTM_Txt (";\n");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********* Get average coordinates of centres in current institution *********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Map_GetCoordAndZoom (struct Coordinates *Coord,unsigned *Zoom,
|
||||
const char *Query)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
double MaxDistance;
|
||||
|
||||
/***** Get average coordinates *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get coordinates",
|
||||
"%s",Query))
|
||||
{
|
||||
/* Get row */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/* Get latitude (row[0]) */
|
||||
Coord->Latitude = Map_GetLatitudeFromStr (row[0]);
|
||||
|
||||
/* Get longitude (row[1]) */
|
||||
Coord->Longitude = Map_GetLongitudeFromStr (row[1]);
|
||||
|
||||
/* Get maximum distance (row[2]) */
|
||||
MaxDistance = Str_GetDoubleFromStr (row[2]);
|
||||
}
|
||||
else
|
||||
Coord->Latitude =
|
||||
Coord->Longitude =
|
||||
MaxDistance = 0.0;
|
||||
|
||||
/***** Convert distance to zoom *****/
|
||||
*Zoom = Map_GetZoomFromDistance (MaxDistance);
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************ Get latitude from a string *************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -217,7 +254,7 @@ double Map_GetAltitudeFromStr (char *Str)
|
|||
/*********************** Get zoom level from distance ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Map_GetZoomFromDistance (double MaxDistance)
|
||||
static unsigned Map_GetZoomFromDistance (double MaxDistance)
|
||||
{
|
||||
/***** Convert distance to zoom *****/
|
||||
return (MaxDistance < 0.01) ? 16 :
|
||||
|
|
|
@ -49,10 +49,10 @@ void Map_CreateMap (const char *ContainerId,
|
|||
void Map_AddTileLayer (void);
|
||||
void Map_AddMarker (const struct Coordinates *Coord);
|
||||
void Map_AddPopup (const char *Title,const char *Subtitle,bool Open);
|
||||
|
||||
void Map_GetCoordAndZoom (struct Coordinates *Coord,unsigned *Zoom,
|
||||
const char *Query);
|
||||
double Map_GetLatitudeFromStr (char *Str);
|
||||
double Map_GetLongitudeFromStr (char *Str);
|
||||
double Map_GetAltitudeFromStr (char *Str);
|
||||
unsigned Map_GetZoomFromDistance (double MaxDistance);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue