diff --git a/sdl1090/draw.c b/sdl1090/draw.c index f5b4775..94112f7 100644 --- a/sdl1090/draw.c +++ b/sdl1090/draw.c @@ -27,9 +27,8 @@ void draw() { SDL_RenderClear(game.renderer); if (Modes.map) { - drawStatus(); - // SDL_RenderCopy(game.renderer,game.texture,NULL,NULL); drawMap(); + drawStatus(); } else { drawList(10,0); } diff --git a/sdl1090/input.c b/sdl1090/input.c index bd180cd..2ea16db 100644 --- a/sdl1090/input.c +++ b/sdl1090/input.c @@ -57,6 +57,30 @@ void getInput() Modes.maxDist *= 1.0 + event.wheel.y / 10.0; break; + + case SDL_MULTIGESTURE: + Modes.maxDist /=1.0 + 4.0*event.mgesture.dDist; + break; + + case SDL_FINGERMOTION:; + + // + // need to make lonlat to screen conversion class - this is just the inverse of the stuff in draw.c, without offsets + // + + double scale_factor = (Modes.screen_width > Modes.screen_height) ? Modes.screen_width : Modes.screen_height; + + double dx = -1.0 * (0.75*(double)Modes.screen_width / (double)Modes.screen_height) * Modes.screen_width * event.tfinger.dx * Modes.maxDist / (0.95 * scale_factor * 0.5); + double dy = -1.0 * Modes.screen_height * event.tfinger.dy * Modes.maxDist / (0.95 * scale_factor * 0.5); + + double outLat = dy * (1.0/6371.0) * (180.0f / M_PI); + + double outLon = dx * (1.0/6371.0) * (180.0f / M_PI) / cos(((Modes.fUserLat)/2.0f) * M_PI / 180.0f); + + + Modes.fUserLon += outLon; + Modes.fUserLat += outLat; + break; } } } diff --git a/sdl1090/interactive.c b/sdl1090/interactive.c index 4b20070..d292be8 100644 --- a/sdl1090/interactive.c +++ b/sdl1090/interactive.c @@ -396,11 +396,14 @@ struct aircraft *interactiveReceiveData(struct modesMessage *mm) { mm->fLat = a->lat; mm->fLon = a->lon; - double dLon = a->lon - Modes.fUserLon; - double dLat = a->lat - Modes.fUserLat; + // double dLon = a->lon;// - Modes.fUserLon; + // double dLat = a->lat;// - Modes.fUserLat; - a->dx = 6371.0 * dLon * M_PI / 180.0f * cos(((a->lat + Modes.fUserLat)/2.0f) * M_PI / 180.0f); - a->dy = 6371.0 * dLat * M_PI / 180.0f; + // a->dx = 6371.0 * dLon * M_PI / 180.0f * cos(((a->lat + Modes.fUserLat)/2.0f) * M_PI / 180.0f); + // a->dy = 6371.0 * dLat * M_PI / 180.0f; + + a->dx = a->lon; + a->dy = a->lat; if(time(NULL) - a->oldSeen[a->oldIdx] > MODES_INTERACTIVE_TRAIL_TTL_STEP) { a->oldIdx = (a->oldIdx+1) % 32; diff --git a/sdl1090/mapdata.c.REMOVED.git-id b/sdl1090/mapdata.c.REMOVED.git-id index 6388773..62add43 100644 --- a/sdl1090/mapdata.c.REMOVED.git-id +++ b/sdl1090/mapdata.c.REMOVED.git-id @@ -1 +1 @@ -c1ba33fa01b0542b5be9bdef8df2078491847af5 \ No newline at end of file +7ed2e5c3d762695e6aaf4111584830b537a549a0 \ No newline at end of file diff --git a/sdl1090/maps.c b/sdl1090/maps.c index a3cbfde..7e4bf67 100644 --- a/sdl1090/maps.c +++ b/sdl1090/maps.c @@ -64,6 +64,18 @@ int screenDist(double d) { } } +void pxFromLonLat(double *dx, double *dy, double lon, double lat) { + if(!lon || !lat) { + *dx = 0; + *dy = 0; + return; + } + + *dx = 6371.0 * (lon - Modes.fUserLon) * M_PI / 180.0f * cos(((lat + Modes.fUserLat)/2.0f) * M_PI / 180.0f); + *dy = 6371.0 * (lat - Modes.fUserLat) * M_PI / 180.0f; +} + + void screenCoords(int *outX, int *outY, double dx, double dy) { *outX = (Modes.screen_width>>1) + ((dx>0) ? 1 : -1) * screenDist(dx); *outY = (Modes.screen_height * CENTEROFFSET) + ((dy>0) ? 1 : -1) * screenDist(dy); @@ -211,7 +223,6 @@ void drawPlane(int x, int y, SDL_Color planeColor) void drawTrail(double *oldDx, double *oldDy, time_t * oldSeen, int idx) { - int currentIdx, prevIdx; int currentX, currentY, prevX, prevY; @@ -232,9 +243,15 @@ void drawTrail(double *oldDx, double *oldDy, time_t * oldSeen, int idx) { continue; } - screenCoords(¤tX, ¤tY, oldDx[currentIdx], oldDy[currentIdx]); + double dx, dy; - screenCoords(&prevX, &prevY, oldDx[prevIdx], oldDy[prevIdx]); + pxFromLonLat(&dx, &dy, oldDx[currentIdx], oldDy[currentIdx]); + + screenCoords(¤tX, ¤tY, dx, dy); + + pxFromLonLat(&dx, &dy, oldDx[prevIdx], oldDy[prevIdx]); + + screenCoords(&prevX, &prevY, dx, dy); if(outOfBounds(currentX,currentY)) { return; @@ -287,26 +304,45 @@ void drawGrid() void drawGeography() { int x1, y1, x2, y2; + for(int i=1; iseen) < Modes.interactive_display_ttl) { @@ -353,8 +389,11 @@ void drawMap(void) { SDL_Color planeColor = signalToColor(colorIdx); int x, y; - screenCoords(&x, &y, a->dx, a->dy); + //screenCoords(&x, &y, a->dx, a->dy); + double dx, dy; + pxFromLonLat(&dx, &dy, a->lon, a->lat); + screenCoords(&x, &y, dx, dy); if(outOfBounds(x,y)) { int outx, outy; @@ -468,4 +507,6 @@ void drawMap(void) { // screen_x[i] = out_x; // screen_y[i] = out_y; // } -// } \ No newline at end of file +// } + + diff --git a/sdl1090/view1090.REMOVED.git-id b/sdl1090/view1090.REMOVED.git-id index df19530..41ef2ad 100644 --- a/sdl1090/view1090.REMOVED.git-id +++ b/sdl1090/view1090.REMOVED.git-id @@ -1 +1 @@ -0199e60b8c42340f3cf63513ca0753fdc71eb190 \ No newline at end of file +2056de76ba9dff16057865185ffa2eb99617235e \ No newline at end of file