Merge branch 'master'

This commit is contained in:
Sven Klomp 2018-06-19 22:03:35 +02:00
commit 9dc1f65466
7 changed files with 115 additions and 28 deletions

View File

@ -51,7 +51,7 @@
script.type = 'text/javascript'; script.type = 'text/javascript';
if (typeof apiKey != 'undefined' && apiKey != "" ) { if (typeof apiKey != 'undefined' && apiKey != "" ) {
script.src = 'https://maps.googleapis.com/maps/api/js?v=3' + script.src = 'https://maps.googleapis.com/maps/api/js?v=3' +
'&signed_in=true&key=' + apiKey +'&callback=initialize_googlemaps'; '&key=' + apiKey +'&callback=initialize_googlemaps';
} else { } else {
$("head").append("<link rel='stylesheet' href='https://unpkg.com/leaflet@1.0.2/dist/leaflet.css' type='text/css' />"); $("head").append("<link rel='stylesheet' href='https://unpkg.com/leaflet@1.0.2/dist/leaflet.css' type='text/css' />");

View File

@ -34,7 +34,7 @@
script.type = 'text/javascript'; script.type = 'text/javascript';
if (typeof apiKey != 'undefined' && apiKey != "" ) { if (typeof apiKey != 'undefined' && apiKey != "" ) {
script.src = 'https://maps.googleapis.com/maps/api/js?v=3' + script.src = 'https://maps.googleapis.com/maps/api/js?v=3' +
'&signed_in=true&key=' + apiKey +'&callback=initialize_googlemaps'; '&key=' + apiKey +'&callback=initialize_googlemaps';
} else { } else {
$("head").append("<link rel='stylesheet' href='https://unpkg.com/leaflet@1.2.0/dist/leaflet.css' type='text/css' />"); $("head").append("<link rel='stylesheet' href='https://unpkg.com/leaflet@1.2.0/dist/leaflet.css' type='text/css' />");
// Dynamic script loading from http://stackoverflow.com/a/8578840 // Dynamic script loading from http://stackoverflow.com/a/8578840

View File

@ -82,9 +82,10 @@ function initialize_googlemaps() {
tst: tst, tst: tst,
addr: event.feature.getProperty('address'), addr: event.feature.getProperty('address'),
fulldate: dt.format("DD MMM YYYY HH:mm:ss"), fulldate: dt.format("DD MMM YYYY HH:mm:ss"),
vel: event.feature.getProperty('vel'),
}; };
var t = "{{ addr }}<br/><span class='latlon'>({{ lat }},{{lon}})</span> {{ fulldate }}"; var t = "{{ addr }}<br/><span class='latlon'>({{ lat }},{{lon}})</span> vel={{vel}} {{ fulldate }}";
if (typeof(tst) === 'undefined') { if (typeof(tst) === 'undefined') {
t = "Position: {{lat}}, {{lon}}"; t = "Position: {{lat}}, {{lon}}";
} }

View File

@ -42,12 +42,23 @@ function initialize_leaflet() {
data.lon = feature.geometry.coordinates[1].toFixed(4); data.lon = feature.geometry.coordinates[1].toFixed(4);
data.addr = feature.properties.address; data.addr = feature.properties.address;
var tst = feature.properties.tst; var tst = feature.properties.tst;
// determine speed
data.speed = feature.properties.vel;
var speed = data.speed;
var dt = moment.utc(tst * 1000).local(); var dt = moment.utc(tst * 1000).local();
data.tst = tst; data.tst = tst;
data.fulldate = dt.format("DD MMM YYYY HH:mm:ss") data.fulldate = dt.format("DD MMM YYYY HH:mm:ss")
var t = "{{ addr }}<br/><span class='latlon'>({{ lat }},{{lon}})</span> {{ fulldate }}"; var t = "{{ addr }}<br/><span class='latlon'>({{ lat }},{{lon}})</span> {{ fulldate }}<br/> Speed: {{ speed }}";
// if speed is 0 then don't display speed
if (speed === 0) {
t = "{{ addr }}<br/><span class='latlon'>({{ lat }},{{lon}})</span> {{ fulldate }}"
}
if (typeof(tst) === 'undefined') { if (typeof(tst) === 'undefined') {
t = "Position: {{lat}}, {{lon}}"; t = "Position: ({{lat}},{{lon}})<br/>Speed: {{speed}}";
}
// if speed is 0 then don't display speed
if (typeof(tst) === 'undefined' && speed === 0) {
t = "Position: ({{lat}},{{lon}})";
} }
layer.bindPopup(Mustache.render(t, data)); layer.bindPopup(Mustache.render(t, data));

View File

@ -0,0 +1,70 @@
Flag Icons by GoSquared (http://www.gosquared.com/)
Version: 2.6
Last Updated: 8th March 2013
Usage:
You're free to use this set for both personal and commercial projects
(MIT License, see LICENSE.txt), and a back-link is not required
(but certainly appreciated).
Inclusion of flags:
This icon set includes all flags for recognized sovereign states, plus several other major
territories. As a rule, disputed states ARE included without discrimination.
Contacting Us:
If you have any suggestions of corrections (incorrectly named, missing, or out-of-date flags etc.),
then don't hesitate to get in touch at support@gosquared.com and we will do our best
to rectify any mistakes or omissions.
Changelog:
* 2.6: 8th March 2013
Added Saint Martin to bring total now to 260
* 2.5: 3rd March 2013
Couple more missing flags:
Canary Islands
Curaçao
* 2.4: 2nd March 2013
Added a couple more missing:
Basque Country
Martinique
Added "unknown"
Cleaned out some buggy files called ".png" that crept in somehow
* 2.3: 26th January 2013
Added more missing flags:
French Polynesia
Frensh Southern Territories
Tokelau
Wallis and Futuna
Removed Kosovo's ISO code (it doesn't have one, KV was wrong)
Corrected East Timor's ISO code (TP -> TL)
* 2.2: 29th October 2012
Added some missing flags:
British Antarctic Territories
Christmas Island
Cocos (Keeling) Islands
Cook Islands
Gibraltar
Mayotte
New Caledonia
Niue
Added ico and icns formats
Fixed problem where all flags in flats/flat had no extension (oops!)
Fixed alignment of Nepal overlay at 48x48
* 2.1: 19th October 2012
Fixed incorrect ISO code for Montenegro (CS -> ME)
* 2.0: 18th October 2012
Fully revamped with new "shiny" style, updated with changed and new flags
* 1.0: 16th September 2010
First created. Icon set containing 2400 flag icons

View File

@ -298,7 +298,7 @@
var script = document.createElement('script'); var script = document.createElement('script');
script.type = 'text/javascript'; script.type = 'text/javascript';
script.src = 'https://maps.googleapis.com/maps/api/js?v=3' + script.src = 'https://maps.googleapis.com/maps/api/js?v=3' +
'&signed_in=true&key=' + apiKey +'&callback=initialize'; '&key=' + apiKey +'&callback=initialize';
document.body.appendChild(script); document.body.appendChild(script);
} }

View File

@ -41,6 +41,7 @@
char STORAGEDIR[BUFSIZ] = STORAGEDEFAULT; char STORAGEDIR[BUFSIZ] = STORAGEDEFAULT;
#define LINESIZE 8192 #define LINESIZE 8192
#define LARGEBUF (BUFSIZ * 2)
static struct gcache *gc = NULL; static struct gcache *gc = NULL;
@ -49,9 +50,9 @@ void storage_init(int revgeo)
setenv("TZ", "UTC", 1); setenv("TZ", "UTC", 1);
if (revgeo) { if (revgeo) {
char path[BUFSIZ]; char path[LARGEBUF];
snprintf(path, BUFSIZ, "%s/ghash", STORAGEDIR); snprintf(path, LARGEBUF, "%s/ghash", STORAGEDIR);
gc = gcache_open(path, NULL, TRUE); gc = gcache_open(path, NULL, TRUE);
if (gc == NULL) { if (gc == NULL) {
olog(LOG_ERR, "storage_init(): gc is NULL"); olog(LOG_ERR, "storage_init(): gc is NULL");
@ -61,17 +62,17 @@ void storage_init(int revgeo)
void storage_gcache_dump(char *lmdbname) void storage_gcache_dump(char *lmdbname)
{ {
char path[BUFSIZ]; char path[LARGEBUF];
snprintf(path, BUFSIZ, "%s/ghash", STORAGEDIR); snprintf(path, LARGEBUF, "%s/ghash", STORAGEDIR);
gcache_dump(path, lmdbname); gcache_dump(path, lmdbname);
} }
void storage_gcache_load(char *lmdbname) void storage_gcache_load(char *lmdbname)
{ {
char path[BUFSIZ]; char path[LARGEBUF];
snprintf(path, BUFSIZ, "%s/ghash", STORAGEDIR); snprintf(path, LARGEBUF, "%s/ghash", STORAGEDIR);
gcache_load(path, lmdbname); gcache_load(path, lmdbname);
} }
@ -178,19 +179,19 @@ static void get_gw_data(char *username, char *device, JsonNode *last)
void append_card_to_object(JsonNode *obj, char *user, char *device) void append_card_to_object(JsonNode *obj, char *user, char *device)
{ {
char path[BUFSIZ], path1[BUFSIZ], *cardfile = NULL; char path[LARGEBUF], path1[LARGEBUF], *cardfile = NULL;
JsonNode *card; JsonNode *card;
if (!user || !*user) if (!user || !*user)
return; return;
snprintf(path, BUFSIZ, "%s/cards/%s/%s/%s-%s.json", snprintf(path, LARGEBUF, "%s/cards/%s/%s/%s-%s.json",
STORAGEDIR, user, device, user, device); STORAGEDIR, user, device, user, device);
if (access(path, R_OK) == 0) { if (access(path, R_OK) == 0) {
cardfile = path; cardfile = path;
} else { } else {
snprintf(path1, BUFSIZ, "%s/cards/%s/%s.json", snprintf(path1, LARGEBUF, "%s/cards/%s/%s.json",
STORAGEDIR, user, user); STORAGEDIR, user, user);
if (access(path1, R_OK) == 0) { if (access(path1, R_OK) == 0) {
@ -207,10 +208,10 @@ void append_card_to_object(JsonNode *obj, char *user, char *device)
void append_device_details(JsonNode *userlist, char *user, char *device) void append_device_details(JsonNode *userlist, char *user, char *device)
{ {
char path[BUFSIZ]; char path[LARGEBUF];
JsonNode *node, *last; JsonNode *node, *last;
snprintf(path, BUFSIZ, "%s/last/%s/%s/%s-%s.json", snprintf(path, LARGEBUF, "%s/last/%s/%s/%s-%s.json",
STORAGEDIR, user, device, user, device); STORAGEDIR, user, device, user, device);
last = json_mkobject(); last = json_mkobject();
@ -233,7 +234,7 @@ void append_device_details(JsonNode *userlist, char *user, char *device)
} }
/* Extra data */ /* Extra data */
snprintf(path, BUFSIZ, "%s/last/%s/%s/extra.json", snprintf(path, LARGEBUF, "%s/last/%s/%s/extra.json",
STORAGEDIR, user, device); STORAGEDIR, user, device);
json_copy_from_file(last, path); json_copy_from_file(last, path);
#if WITH_GREENWICH #if WITH_GREENWICH
@ -253,9 +254,9 @@ JsonNode *last_users(char *in_user, char *in_device, JsonNode *fields)
{ {
JsonNode *obj = json_mkobject(); JsonNode *obj = json_mkobject();
JsonNode *un, *dn, *userlist = json_mkarray(); JsonNode *un, *dn, *userlist = json_mkarray();
char path[BUFSIZ], user[BUFSIZ], device[BUFSIZ]; char path[LARGEBUF], user[BUFSIZ], device[BUFSIZ];
snprintf(path, BUFSIZ, "%s/last", STORAGEDIR); snprintf(path, LARGEBUF, "%s/last", STORAGEDIR);
// fprintf(stderr, "last_users(%s, %s)\n", (in_user) ? in_user : "<nil>", // fprintf(stderr, "last_users(%s, %s)\n", (in_user) ? in_user : "<nil>",
// (in_device) ? in_device : "<nil>"); // (in_device) ? in_device : "<nil>");
@ -918,7 +919,7 @@ void locations(char *filename, JsonNode *obj, JsonNode *arr, time_t s_lo, time_t
* *
*/ */
static void append_to_feature_array(JsonNode *features, double lat, double lon, char *tid, char *addr, long tst) static void append_to_feature_array(JsonNode *features, double lat, double lon, char *tid, char *addr, long tst, long vel)
{ {
JsonNode *geom, *props, *f = json_mkobject(); JsonNode *geom, *props, *f = json_mkobject();
@ -934,6 +935,7 @@ static void append_to_feature_array(JsonNode *features, double lat, double lon,
props = json_mkobject(); props = json_mkobject();
json_append_member(props, "name", json_mkstring(tid)); json_append_member(props, "name", json_mkstring(tid));
json_append_member(props, "address", json_mkstring(addr)); json_append_member(props, "address", json_mkstring(addr));
json_append_member(props, "vel", json_mknumber(vel));
json_append_member(props, "tst", json_mknumber(tst)); json_append_member(props, "tst", json_mknumber(tst));
json_append_member(f, "geometry", geom); json_append_member(f, "geometry", geom);
@ -957,7 +959,7 @@ JsonNode *geo_json(JsonNode *location_array)
json_foreach(one, location_array) { json_foreach(one, location_array) {
double lat = 0.0, lon = 0.0; double lat = 0.0, lon = 0.0;
char *addr = "", *tid = ""; char *addr = "", *tid = "";
long tst = 0; long tst = 0, vel = 0;
if ((j = json_find_member(one, "lat")) != NULL) { if ((j = json_find_member(one, "lat")) != NULL) {
lat = j->number_; lat = j->number_;
@ -975,8 +977,11 @@ JsonNode *geo_json(JsonNode *location_array)
if ((j = json_find_member(one, "tst")) != NULL) { if ((j = json_find_member(one, "tst")) != NULL) {
tst = j->number_; tst = j->number_;
} }
if ((j = json_find_member(one, "vel")) != NULL) {
vel = j->number_;
}
append_to_feature_array(feature_array, lat, lon, tid, addr, tst); append_to_feature_array(feature_array, lat, lon, tid, addr, tst, vel);
} }
json_append_member(fcollection, "features", feature_array); json_append_member(fcollection, "features", feature_array);
@ -1477,7 +1482,7 @@ void csv_output(JsonNode *array, output_type otype, JsonNode *fields, void (*fun
char *storage_userphoto(char *username) char *storage_userphoto(char *username)
{ {
static char path[BUFSIZ]; static char path[LARGEBUF];
if (!username || !*username) if (!username || !*username)
return (NULL); return (NULL);
@ -1494,7 +1499,7 @@ char *storage_userphoto(char *username)
void extra_http_json(JsonNode *array, char *user, char *device) void extra_http_json(JsonNode *array, char *user, char *device)
{ {
char path[BUFSIZ], *js_string; char path[LARGEBUF], *js_string;
JsonNode *node; JsonNode *node;
if (!array || !user || !*user || !device || !*device) if (!array || !user || !*user || !device || !*device)
@ -1503,7 +1508,7 @@ void extra_http_json(JsonNode *array, char *user, char *device)
return; return;
/* Extra data */ /* Extra data */
snprintf(path, BUFSIZ, "%s/last/%s/%s/http.json", snprintf(path, LARGEBUF, "%s/last/%s/%s/http.json",
STORAGEDIR, user, device); STORAGEDIR, user, device);
if ((js_string = slurp_file(path, TRUE)) == NULL) { if ((js_string = slurp_file(path, TRUE)) == NULL) {