changed doubles to float. wrote out mapdata.bin and read in, this is still hacky, but compiles faster now

Former-commit-id: 59f44288ca1838e89e1f8c7463e88e91d5252c4b
Former-commit-id: 8894cdb766d205bf630d4de44701894a53b95b12
This commit is contained in:
nathan 2020-02-26 22:44:30 -08:00
parent 8c281d95e5
commit 414d8aed65
29 changed files with 406 additions and 72 deletions

View file

@ -11,7 +11,7 @@ EXTRACFLAGS=-DHTMLPATH=\"$(SHAREDIR)\"
endif
CFLAGS=-O2 -g -Wall -W
LIBS=-lm -lSDL2 -lSDL2_ttf -lSDL2_gfx
LIBS=-lm -lSDL2 -lSDL2_ttf -lSDL2_gfx
CC=gcc
all: view1090
@ -19,8 +19,8 @@ all: view1090
%.o: %.c
$(CC) $(CFLAGS) $(EXTRACFLAGS) -c $<
view1090: view1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o planeObj.o input.o draw.o font.o init.o mapdata.o status.o list.o parula.o monokai.o allstates.o
$(CC) -g -o view1090 view1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o planeObj.o input.o draw.o font.o init.o mapdata.o status.o list.o parula.o monokai.o allstates.o $(LIBS) $(LDFLAGS)
view1090: view1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o planeObj.o input.o draw.o font.o init.o mapdata.o status.o list.o parula.o monokai.o
$(CC) -g -o view1090 view1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o planeObj.o input.o draw.o font.o init.o mapdata.o status.o list.o parula.o monokai.o $(LIBS) $(LDFLAGS)
clean:
rm -f *.o view1090

View file

@ -52,6 +52,10 @@ cd spidr
###HARDWARE
Right now, Pixel 2 is $109 on Amazon (https://www.amazon.com/Google-Pixel-64-Black-Refurbished/dp/B0787V183F).
This significantly outperforms a rpi4.
best option seems to be pi4 + pijuice zero (w/ rewired i2c) + hyperpixel 4. RTLSDR (stratux) sticks down or needs u shaped adapter.
For future tuner, need to test audio phat w/ little speaker, i2c knob, etc.

37
TODO.md Normal file
View file

@ -0,0 +1,37 @@
todo
UI stuff
+tap on plane sets plane to active
+animated recenter to active
+toggle follow and orient (and other popup info?)
double tap to zoom
animated label show and hide
+draw map to texture and only redraw on move
color themes (requires settings load)
settings (button popups or panes, sliders, etc)
battery level (need separate linux/win/android)
Utility stuff
zipped map load (and write from python) --> start by reducing lat/lon precision to 4 or 5 decimal places and change storage to float instead of double
libconfig load settings
Platforms
migrate Android project into main repo
SDL_AndroidGetJNIEnv() to access parameters, system info, etc
windows
naming
viz1090
map1090
sdl1090

View file

@ -1 +0,0 @@
e1983f2439326aba30a2576504aac03b2f3cd2fc

View file

@ -1 +0,0 @@
9bee8f55a87c0c25e624b913e8e728619074d9ee

21
android_notes Normal file
View file

@ -0,0 +1,21 @@
Android build notes
This example works:
https://github.com/pvallet/hello-sdl2-android
the only JDK that seems to work is oracle-java8-installer, discontinued but available as of 2/18/2020 from
sudo add-apt-repository ppa:ts.sch.gr/ppa
sudo apt-get update
sudo apt-get install oracle-java8-installer
per https://askubuntu.com/questions/1139387/update-to-latest-version-of-java-after-ppa-is-discontinued
SDL2, SDL2_gfx, SDL2_ttf official need to go in external
SDL2_gfx official doesn't have Android.mk, but this one does:
https://github.com/keera-studios/SDL2_gfx
App parameters are in android/app/src/main/java/[pvallet/com/github/hellosdl2/helloSDL2Activity.java] (network access, fullscreen immersive mode"
Resources (fonts etc) need to go in android/app/src/main/res
build settings (arch, android version) are in android/AndroidManifest.xml AND android/SDL2/src/main/AndroidManifest.xml (not sure if the second one needs to be changed)

84
draw.c
View file

@ -21,7 +21,7 @@ float sign(float x) {
return (x > 0) - (x < 0);
}
void CROSSVP(double *v, double *u, double *w)
void CROSSVP(float *v, float *u, float *w)
{
v[0] = u[1]*w[2] - u[2]*(w)[1];
v[1] = u[2]*w[0] - u[0]*(w)[2];
@ -69,9 +69,9 @@ SDL_Color lerpColor(SDL_Color aColor, SDL_Color bColor, float factor) {
return out;
}
SDL_Color hsv2SDLColor(double h, double s, double v)
SDL_Color hsv2SDLColor(float h, float s, float v)
{
double hh, p, q, t, ff;
float hh, p, q, t, ff;
long i;
SDL_Color out;
@ -127,9 +127,9 @@ SDL_Color hsv2SDLColor(double h, double s, double v)
return out;
}
int screenDist(double d) {
int screenDist(float d) {
double scale_factor = (appData.screen_width > appData.screen_height) ? appData.screen_width : appData.screen_height;
float scale_factor = (appData.screen_width > appData.screen_height) ? appData.screen_width : appData.screen_height;
if(appData.mapLogDist) {
return round(0.95 * scale_factor * 0.5 * log(1.0+fabs(d)) / log(1.0+appData.maxDist));
@ -138,7 +138,7 @@ int screenDist(double d) {
}
}
void pxFromLonLat(double *dx, double *dy, double lon, double lat) {
void pxFromLonLat(float *dx, float *dy, float lon, float lat) {
if(!lon || !lat) {
*dx = 0;
*dy = 0;
@ -149,18 +149,18 @@ void pxFromLonLat(double *dx, double *dy, double lon, double lat) {
*dy = 6371.0 * (lat - appData.centerLat) * M_PI / 180.0f;
}
void latLonFromScreenCoords(double *lat, double *lon, int x, int y) {
double scale_factor = (appData.screen_width > appData.screen_height) ? appData.screen_width : appData.screen_height;
void latLonFromScreenCoords(float *lat, float *lon, int x, int y) {
float scale_factor = (appData.screen_width > appData.screen_height) ? appData.screen_width : appData.screen_height;
double dx = appData.maxDist * (x - (appData.screen_width>>1)) / (0.95 * scale_factor * 0.5 );
double dy = appData.maxDist * (y - (appData.screen_height * CENTEROFFSET)) / (0.95 * scale_factor * 0.5 );
float dx = appData.maxDist * (x - (appData.screen_width>>1)) / (0.95 * scale_factor * 0.5 );
float dy = appData.maxDist * (y - (appData.screen_height * CENTEROFFSET)) / (0.95 * scale_factor * 0.5 );
*lat = 180.0f * dy / (6371.0 * M_PI) + appData.centerLat;
*lon = 180.0 * dx / (cos(((*lat + appData.centerLat)/2.0f) * M_PI / 180.0f) * 6371.0 * M_PI) + appData.centerLon;
}
void screenCoords(int *outX, int *outY, double dx, double dy) {
void screenCoords(int *outX, int *outY, float dx, float dy) {
*outX = (appData.screen_width>>1) + ((dx>0) ? 1 : -1) * screenDist(dx);
*outY = (appData.screen_height * CENTEROFFSET) + ((dy>0) ? -1 : 1) * screenDist(dy);
}
@ -175,7 +175,7 @@ int outOfBounds(int x, int y) {
void drawPlaneOffMap(int x, int y, int *returnx, int *returny, SDL_Color planeColor) {
double arrowWidth = 6.0 * appData.screen_uiscale;
float arrowWidth = 6.0 * appData.screen_uiscale;
float inx = x - (appData.screen_width>>1);
float iny = y - appData.screen_height * CENTEROFFSET;
@ -195,15 +195,15 @@ void drawPlaneOffMap(int x, int y, int *returnx, int *returny, SDL_Color planeCo
// circleRGBA (appData.renderer,(appData.screen_width>>1) + outx, appData.screen_height * CENTEROFFSET + outy,50,planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
// thickLineRGBA(appData.renderer,appData.screen_width>>1,appData.screen_height * CENTEROFFSET, (appData.screen_width>>1) + outx, appData.screen_height * CENTEROFFSET + outy,arrowWidth,planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
double inmag = sqrt(inx *inx + iny*iny);
double vec[3];
float inmag = sqrt(inx *inx + iny*iny);
float vec[3];
vec[0] = inx / inmag;
vec[1] = iny /inmag;
vec[2] = 0;
double up[] = {0,0,1};
float up[] = {0,0,1};
double out[3];
float out[3];
CROSSVP(out,vec,up);
@ -231,21 +231,21 @@ void drawPlaneOffMap(int x, int y, int *returnx, int *returny, SDL_Color planeCo
*returny = y3;
}
void drawPlaneHeading(int x, int y, double heading, SDL_Color planeColor)
void drawPlaneHeading(int x, int y, float heading, SDL_Color planeColor)
{
double body = 8.0 * appData.screen_uiscale;
double wing = 6.0 * appData.screen_uiscale;
double tail = 3.0 * appData.screen_uiscale;
double bodyWidth = 2.0 * appData.screen_uiscale;
float body = 8.0 * appData.screen_uiscale;
float wing = 6.0 * appData.screen_uiscale;
float tail = 3.0 * appData.screen_uiscale;
float bodyWidth = 2.0 * appData.screen_uiscale;
double vec[3];
float vec[3];
vec[0] = sin(heading * M_PI / 180);
vec[1] = -cos(heading * M_PI / 180);
vec[2] = 0;
double up[] = {0,0,1};
float up[] = {0,0,1};
double out[3];
float out[3];
CROSSVP(out,vec,up);
@ -291,7 +291,7 @@ void drawPlane(int x, int y, SDL_Color planeColor)
}
void drawTrail(double *oldDx, double *oldDy, double *oldHeading, time_t * oldSeen, int idx) {
void drawTrail(float *oldDx, float *oldDy, float *oldHeading, time_t * oldSeen, int idx) {
int currentIdx, prevIdx;
@ -313,7 +313,7 @@ void drawTrail(double *oldDx, double *oldDy, double *oldHeading, time_t * oldSee
continue;
}
double dx, dy;
float dx, dy;
pxFromLonLat(&dx, &dy, oldDx[currentIdx], oldDy[currentIdx]);
@ -331,7 +331,7 @@ void drawTrail(double *oldDx, double *oldDy, double *oldHeading, time_t * oldSee
continue;
}
double age = pow(1.0 - (double)(now - oldSeen[currentIdx]) / TRAIL_TTL, 2.2);
float age = pow(1.0 - (float)(now - oldSeen[currentIdx]) / TRAIL_TTL, 2.2);
if(age < 0) {
age = 0;
@ -343,17 +343,17 @@ void drawTrail(double *oldDx, double *oldDy, double *oldHeading, time_t * oldSee
//tick marks
age = 1.0 - (double) 4.0 * (now - oldSeen[currentIdx]) / TRAIL_TTL;
age = 1.0 - (float) 4.0 * (now - oldSeen[currentIdx]) / TRAIL_TTL;
colorVal = (uint8_t)floor(255.0 * age);
double vec[3];
float vec[3];
vec[0] = sin(oldHeading[currentIdx] * M_PI / 180);
vec[1] = -cos(oldHeading[currentIdx] * M_PI / 180);
vec[2] = 0;
double up[] = {0,0,1};
float up[] = {0,0,1};
double out[3];
float out[3];
CROSSVP(out,vec,up);
@ -425,7 +425,7 @@ void drawScaleBars()
// drawString("100km", (appData.screen_width>>1) + (0.707 * p100km) + 5, (appData.screen_height * CENTEROFFSET) + (0.707 * p100km) + 5, appData.mapFont, pink);
}
void drawPolys(QuadTree *tree, double screen_lat_min, double screen_lat_max, double screen_lon_min, double screen_lon_max) {
void drawPolys(QuadTree *tree, float screen_lat_min, float screen_lat_max, float screen_lon_min, float screen_lon_max) {
if(tree == NULL) {
return;
}
@ -462,7 +462,7 @@ void drawPolys(QuadTree *tree, double screen_lat_min, double screen_lat_max, dou
drawPolys(tree->se, screen_lat_min, screen_lat_max, screen_lon_min, screen_lon_max);
double dx, dy;
float dx, dy;
// if(!(tree->lat_min > screen_lat_min &&
// tree->lat_max < screen_lat_max &&
// tree->lon_min > screen_lon_min &&
@ -519,7 +519,7 @@ void drawPolys(QuadTree *tree, double screen_lat_min, double screen_lat_max, dou
// }
// }
// double alpha = 1.0;
// float alpha = 1.0;
// //filledPolygonRGBA (appData.renderer, px, py, i, 0, 0, 0, 255);
// polygonRGBA (appData.renderer, px, py, i, alpha * purple.r + (1.0-alpha) * blue.r, alpha * purple.g + (1.0-alpha) * blue.g, alpha * purple.b + (1.0-alpha) * blue.b, 255 * alpha);
@ -545,7 +545,7 @@ void drawPolys(QuadTree *tree, double screen_lat_min, double screen_lat_max, dou
continue;
}
double d1 = dx* dx + dy * dy;
float d1 = dx* dx + dy * dy;
pxFromLonLat(&dx, &dy, currentPoint->lon, currentPoint->lat);
screenCoords(&x2, &y2, dx, dy);
@ -562,9 +562,9 @@ void drawPolys(QuadTree *tree, double screen_lat_min, double screen_lat_max, dou
continue;
}
double d2 = dx* dx + dy * dy;
float d2 = dx* dx + dy * dy;
double factor = 1.0 - (d1+d2) / (3* appData.maxDist * appData.maxDist);
float factor = 1.0 - (d1+d2) / (3* appData.maxDist * appData.maxDist);
SDL_Color lineColor = lerpColor(purple, blue, factor);
@ -598,7 +598,7 @@ void drawPolys(QuadTree *tree, double screen_lat_min, double screen_lat_max, dou
}
void drawGeography() {
double screen_lat_min, screen_lat_max, screen_lon_min, screen_lon_max;
float screen_lat_min, screen_lat_max, screen_lon_min, screen_lon_max;
latLonFromScreenCoords(&screen_lat_min, &screen_lon_min, 0, appData.screen_height * -0.2);
latLonFromScreenCoords(&screen_lat_max, &screen_lon_max, appData.screen_width, appData.screen_height * 1.2);
@ -991,7 +991,7 @@ void drawPlanes() {
int x, y;
double dx, dy;
float dx, dy;
pxFromLonLat(&dx, &dy, p->lon, p->lat);
screenCoords(&x, &y, dx, dy);
@ -999,7 +999,7 @@ void drawPlanes() {
p->created = mstime();
}
double age_ms = (double)(mstime() - p->created);
float age_ms = (float)(mstime() - p->created);
if(age_ms < 500) {
circleRGBA(appData.renderer, x, y, 500 - age_ms, 255,255, 255, (uint8_t)(255.0 * age_ms / 500.0));
} else {
@ -1014,8 +1014,8 @@ void drawPlanes() {
pxFromLonLat(&dx, &dy, p->oldLon[idx], p->oldLat[idx]);
screenCoords(&oldx, &oldy, dx, dy);
double velx = (x - oldx) / (1000.0 * (p->seenLatLon - p->oldSeen[idx]));
double vely = (y - oldy) / (1000.0 * (p->seenLatLon - p->oldSeen[idx]));
float velx = (x - oldx) / (1000.0 * (p->seenLatLon - p->oldSeen[idx]));
float vely = (y - oldy) / (1000.0 * (p->seenLatLon - p->oldSeen[idx]));
usex = x + (mstime() - p->msSeenLatLon) * velx;
usey = y + (mstime() - p->msSeenLatLon) * vely;

View file

@ -1 +1 @@
4019e6c1da59af5e54909b8625f116916ed7b2de
7a72d06a00457897159cc7ebf3afff0f1806f3ab

BIN
font.o

Binary file not shown.

BIN
init.o

Binary file not shown.

View file

@ -1 +1 @@
e65446c295519dac23cf6b702c274d4cfb873e7f
7108d34870f6546900fb6d69ee9e1789e1e0a175

BIN
list.o

Binary file not shown.

21
map_conversion/README.md Normal file
View file

@ -0,0 +1,21 @@
Very hacky map pipeline:
using latlon maps from sourced from http://www.mccurley.org/svg/
get all.svg
run mapconverted.py
**at this point you have to manually format into a c array and get the length.**
now compile write2bin
gcc write2bin.c allstates.c -o write2bin
and run write2bin
this will produce mapdata.bin that the main program reads in
** this should be one python that generates the binary file **
** then it should be grabbed from mapbox or something **

View file

@ -0,0 +1 @@
4a9fe852dcd3e65638b4f5a4f943c0e85c5e2ddb

View file

@ -0,0 +1 @@
a617d7924210634db9b7a5c7323d803d371319df

View file

@ -0,0 +1 @@
d970486a784f62d0e7072845fb9ba545adb51332

View file

@ -0,0 +1,12 @@
//
#include<stdio.h>
extern float mapPoints[3878131];
int main(int argc, char **argv) {
FILE *file = fopen("mapdata.bin", "wb");
fwrite(mapPoints, sizeof(mapPoints), 1, file);
fclose(file);
return(0);
}

View file

@ -1 +0,0 @@
cef8f740e8ef23f03d0d46f43348d73f1ca76c8e

View file

@ -0,0 +1 @@
d970486a784f62d0e7072845fb9ba545adb51332

237
mapdata.c Normal file
View file

@ -0,0 +1,237 @@
#include "dump1090.h"
#include "mapdata.h"
#include <stdbool.h>
//sourced from http://www.mccurley.org/svg/
//
//extern float mapPoints[3878131];
bool QTInsert(QuadTree *tree, Polygon* polygon) {
// printf("Inserting %d point poly\n", polygon->numPoints);
if (!(polygon->lat_min >= tree->lat_min &&
polygon->lat_max <= tree->lat_max &&
polygon->lon_min >= tree->lon_min &&
polygon->lon_max <= tree->lon_max)) {
// printf("doesnt fit: %f > %f, %f < %f, %f < %f,%f > %f \n",polygon->lat_min, tree->lat_min, polygon->lat_max, tree->lat_max, polygon->lon_min, tree->lon_min, polygon->lon_max,tree->lon_max);
return false;
}
if (tree->nw == NULL) {
tree->nw = (QuadTree*)malloc(sizeof(QuadTree));
tree->nw->polygons = NULL;
tree->nw->nw = NULL;
tree->nw->ne = NULL;
tree->nw->sw = NULL;
tree->nw->se = NULL;
tree->nw->lat_min = tree->lat_min;
tree->nw->lat_max = tree->lat_min + 0.5 * (tree->lat_max - tree->lat_min);
tree->nw->lon_min = tree->lon_min;
tree->nw->lon_max = tree->lon_min + 0.5 * (tree->lon_max - tree->lon_min);
}
if (QTInsert(tree->nw,polygon)){
return true;
}
if (tree->sw == NULL) {
tree->sw = (QuadTree*)malloc(sizeof(QuadTree));
tree->sw->polygons = NULL;
tree->sw->nw = NULL;
tree->sw->ne = NULL;
tree->sw->sw = NULL;
tree->sw->se = NULL;
tree->sw->lat_min = tree->lat_min;
tree->sw->lat_max = tree->lat_min + 0.5 * (tree->lat_max - tree->lat_min);
tree->sw->lon_min = tree->lon_min + 0.5 * (tree->lon_max - tree->lon_min);
tree->sw->lon_max = tree->lon_max;
}
if (QTInsert(tree->sw,polygon)){
return true;
}
if (tree->ne == NULL) {
tree->ne = (QuadTree*)malloc(sizeof(QuadTree));
tree->ne->polygons = NULL;
tree->ne->nw = NULL;
tree->ne->ne = NULL;
tree->ne->sw = NULL;
tree->ne->se = NULL;
tree->ne->lat_min = tree->lat_min + 0.5 * (tree->lat_max - tree->lat_min);
tree->ne->lat_max = tree->lat_max;
tree->ne->lon_min = tree->lon_min;
tree->ne->lon_max = tree->lon_min + 0.5 * (tree->lon_max - tree->lon_min);
}
if (QTInsert(tree->ne,polygon)){
return true;
}
if (tree->se == NULL) {
tree->se = (QuadTree*)malloc(sizeof(QuadTree));
tree->se->polygons = NULL;
tree->se->nw = NULL;
tree->se->ne = NULL;
tree->se->sw = NULL;
tree->se->se = NULL;
tree->se->lat_min = tree->lat_min + 0.5 * (tree->lat_max - tree->lat_min);
tree->se->lat_max = tree->lat_max;
tree->se->lon_min = tree->lon_min + 0.5 * (tree->lon_max - tree->lon_min);
tree->se->lon_max = tree->lon_max;
}
if (QTInsert(tree->se,polygon)){
return true;
}
polygon->next = tree->polygons;
tree->polygons = polygon;
// printf("insert done\n");
return true;
}
void initMaps() {
mapPoints_count = sizeof(mapPoints) / sizeof(float);
FILE *fileptr;
fileptr = fopen("mapdata.bin", "rb"); // Open the file in binary mode
fseek(fileptr, 0, SEEK_END); // Jump to the end of the file
mapPoints_count = ftell(fileptr) / sizeof(float); // Get the current byte offset in the file
rewind(fileptr); // Jump back to the beginning of the file
mapPoints = (float *)malloc(mapPoints_count * sizeof(float)); // Enough memory for the file
fread(mapPoints, sizeof(float), mapPoints_count, fileptr); // Read in the entire file
fclose(fileptr); // Close the fileptr
printf("%d points read\n",mapPoints_count);
//mapPoints_relative = (float *) malloc(sizeof(mapPoints));
// mapPoints_count = sizeof(mapPoints) / (2 * sizeof(double));
// mapPoints_x = (double *) malloc(sizeof(mapPoints) / 2);
// mapPoints_y = (double *) malloc(sizeof(mapPoints) / 2);
// int current = 0;
// for(int i = 0; i < 2 * mapPoints_count; i++) {
// if(mapPoints[i] != 0) {
// if(i%2 == 0) { //longitude points
// double dLon = mapPoints[i] - Modes.fUserLon;
// mapPoints_x[current] = 6371.0 * dLon * M_PI / 180.0 * cos(((mapPoints[i+1] + Modes.fUserLat)/2.0) * M_PI / 180.0);
// } else { //latitude points
// double dLat = mapPoints[i] - Modes.fUserLat;
// mapPoints_y[current] = 6371.0 * dLat * M_PI / 180.0f;
// current++;
// }
// }
// }
root.lat_min = 180;
root.lon_min = 180;
root.lat_max = -180;
root.lon_max = -180;
root.nw = NULL;
root.ne = NULL;
root.sw = NULL;
root.se = NULL;
for(int i = 0; i < mapPoints_count; i+=2) {
if(mapPoints[i] == 0)
continue;
if(mapPoints[i] < root.lon_min) {
root.lon_min = mapPoints[i];
} else if(mapPoints[i] > root.lon_max) {
root.lon_max = mapPoints[i];
}
if(mapPoints[i+1] < root.lat_min) {
root.lat_min = mapPoints[i+1];
} else if(mapPoints[i+1] > root.lat_max) {
root.lat_max = mapPoints[i+1];
}
}
Polygon *currentPolygon = (Polygon*)malloc(sizeof(Polygon));
currentPolygon->lat_min = 180.0;
currentPolygon->lon_min = 180.0;
currentPolygon->lat_max = -180.0;
currentPolygon->lon_max = -180.0;
currentPolygon->numPoints = 0;
currentPolygon->points = NULL;
currentPolygon->next = NULL;
for(int i = 0; i < mapPoints_count; i+=2) {
if(mapPoints[i] == 0) { //end of polygon
if(currentPolygon->numPoints != 7)
QTInsert(&root, currentPolygon);
currentPolygon = (Polygon*)malloc(sizeof(Polygon));
currentPolygon->lat_min = 180.0;
currentPolygon->lon_min = 180.0;
currentPolygon->lat_max = -180.0;
currentPolygon->lon_max = -180.0;
currentPolygon->numPoints = 0;
currentPolygon->points = NULL;
currentPolygon->next = NULL;
continue;
}
currentPolygon->numPoints++;
Point *currentPoint = (Point*)malloc(sizeof(Point));
if(mapPoints[i] < currentPolygon->lon_min) {
currentPolygon->lon_min = mapPoints[i];
} else if(mapPoints[i] > currentPolygon->lon_max) {
currentPolygon->lon_max = mapPoints[i];
}
if(mapPoints[i+1] < currentPolygon->lat_min) {
currentPolygon->lat_min = mapPoints[i+1];
} else if(mapPoints[i+1] > currentPolygon->lat_max) {
currentPolygon->lat_max = mapPoints[i+1];
}
currentPoint->lon = mapPoints[i];
currentPoint->lat = mapPoints[i+1];
currentPoint->next = currentPolygon->points;
currentPolygon->points = currentPoint;
}
}
// void recenter() {
// for(int i = 0; i < mapPoints_count; i++) {
// if(mapPoints[i] == 0) {
// mapPoints_relative[i] = 0;
// } else {
// if(i%2 == 0) { //longitude points
// double dLon = mapPoints[i] - Modes.fUserLon;
// mapPoints_relative[i] = 6371.0 * dLon * M_PI / 180.0 * cos(((mapPoints[i+1] + Modes.fUserLat)/2.0) * M_PI / 180.0);
// } else { //latitude points
// double dLat = mapPoints[i] - Modes.fUserLat;
// mapPoints_relative[i] = 6371.0 * dLat * M_PI / 180.0f;
// }
// }
// }
// }

View file

@ -1 +0,0 @@
1420a2ee0d38618a03222daea18788de0178f471

View file

@ -1,22 +1,24 @@
#ifndef MAPPOINTS_H
#define MAPPOINTS_H
double *mapPoints_relative;
float *mapPoints_relative;
int mapPoints_count;
extern double mapPoints[];
//extern float mapPoints[];
float *mapPoints;
typedef struct Point{
double lat;
double lon;
float lat;
float lon;
struct Point *next;
} Point;
typedef struct Polygon{
double lat_min;
double lat_max;
double lon_min;
double lon_max;
float lat_min;
float lat_max;
float lon_min;
float lon_max;
Point *points;
int numPoints;
@ -25,10 +27,10 @@ typedef struct Polygon{
} Polygon;
typedef struct QuadTree{
double lat_min;
double lat_max;
double lon_min;
double lon_max;
float lat_min;
float lat_max;
float lon_min;
float lon_max;
Polygon *polygons;

BIN
mapdata.o

Binary file not shown.

BIN
monokai.o

Binary file not shown.

Binary file not shown.

View file

@ -1 +1 @@
00319fecb996b4196487ff551c1c4fcd04063dcc
bf0a21d45c74ca1ec5086a28d3c765f51ca09193

View file

@ -36,8 +36,8 @@ typedef struct AppData
int screen_depth;
int fullscreen;
double centerLon;
double centerLat;
float centerLon;
float centerLat;
uint64_t touchDownTime;
int touchx;
@ -68,9 +68,9 @@ struct planeObj {
double lat, lon; // Coordinated obtained from CPR encoded data
//history
double oldLon[TRAIL_LENGTH];
double oldLat[TRAIL_LENGTH];
double oldHeading[TRAIL_LENGTH];
float oldLon[TRAIL_LENGTH];
float oldLat[TRAIL_LENGTH];
float oldHeading[TRAIL_LENGTH];
time_t oldSeen[TRAIL_LENGTH];
uint8_t oldIdx;
uint64_t created;
@ -125,7 +125,7 @@ void drawList(int top);
//draw.c
void draw();
void latLonFromScreenCoords(double *lat, double *lon, int x, int y);
void latLonFromScreenCoords(float *lat, float *lon, int x, int y);
//status.c

View file

@ -1 +1 @@
c71ae5a169099a989da238f49c409fb014f13fd2
57081b3b8e95e553e4b5ef8d741befabb4cbbcdd

View file

@ -1 +1 @@
71f6442ad1518278cce9fee8235924b9bbe56cc6
14bceef428bd087e58e4552f6ee11d3afc8586ed