svg conversion in python, full 48 us states

Former-commit-id: 916991bafcbdcd5096382e11b1a75ca8da4d36ad
Former-commit-id: 74aafae150f8cd26b383bf37449cc861162ce7f5
This commit is contained in:
nathan 2020-01-21 23:24:29 -08:00
parent 3097d6fdb3
commit 3a0b1aecf3
18 changed files with 84 additions and 49 deletions

View file

@ -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
$(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)
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)
clean:
rm -f *.o view1090

View file

@ -0,0 +1 @@
e1983f2439326aba30a2576504aac03b2f3cd2fc

View file

@ -0,0 +1 @@
9bee8f55a87c0c25e624b913e8e728619074d9ee

100
draw.c
View file

@ -373,13 +373,6 @@ void drawGrid()
void drawPolys(QuadTree *tree, double screen_lat_min, double screen_lat_max, double screen_lon_min, double screen_lon_max) {
// int skip = (int)(appData.maxDist / 25.0f);
// if(skip < 2) {
// skip = 2;
// }
int skip = 1;
if(tree == NULL) {
return;
}
@ -429,57 +422,82 @@ void drawPolys(QuadTree *tree, double screen_lat_min, double screen_lat_max, dou
while(currentPolygon != NULL) {
Sint16 *px = (Sint16*)malloc(sizeof(Sint16*)*currentPolygon->numPoints);
Sint16 *py = (Sint16*)malloc(sizeof(Sint16*)*currentPolygon->numPoints);
////polygon mode
// Sint16 *px = (Sint16*)malloc(sizeof(Sint16*)*currentPolygon->numPoints);
// Sint16 *py = (Sint16*)malloc(sizeof(Sint16*)*currentPolygon->numPoints);
Point *currentPoint = currentPolygon->points;
// Point *currentPoint = currentPolygon->points;
int i = 0;
while(currentPoint != NULL){
pxFromLonLat(&dx, &dy, currentPoint->lon, currentPoint->lat);
screenCoords(&x, &y, dx, dy);
// int i = 0;
// while(currentPoint != NULL){
// pxFromLonLat(&dx, &dy, currentPoint->lon, currentPoint->lat);
// screenCoords(&x, &y, dx, dy);
px[i] = x;
py[i] = y;
// px[i] = x;
// py[i] = y;
i++;
// i++;
for(int k = 0; k < skip; k++) {
currentPoint = currentPoint->next;
if(currentPoint == NULL)
break;
}
}
// for(int k = 0; k < skip; k++) {
// currentPoint = currentPoint->next;
// if(currentPoint == NULL)
// break;
// }
// }
double alpha = 1.0;
//filledPolygonRGBA (appData.renderer, px, py, i, 0, 0, 0, 255);
// double 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);
// 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);
//// line version
// int x1,y1,x2,y2;
int x1,y1,x2,y2;
// if(currentPolygon->points == NULL)
// continue;
if(currentPolygon->points == NULL)
continue;
// Point *prevPoint = currentPolygon->points;
// Point *currentPoint = prevPoint->next;
Point *prevPoint = currentPolygon->points;
Point *currentPoint = prevPoint->next;
// while(currentPoint != NULL){
// pxFromLonLat(&dx, &dy, prevPoint->lon, prevPoint->lat);
// screenCoords(&x1, &y1, dx, dy);
while(currentPoint != NULL){
pxFromLonLat(&dx, &dy, prevPoint->lon, prevPoint->lat);
screenCoords(&x1, &y1, dx, dy);
if(outOfBounds(x1,y1)) {
prevPoint = currentPoint;
currentPoint = currentPoint->next;
continue;
}
double d1 = dx* dx + dy * dy;
pxFromLonLat(&dx, &dy, currentPoint->lon, currentPoint->lat);
screenCoords(&x2, &y2, dx, dy);
if(outOfBounds(x2,y2)) {
prevPoint = currentPoint;
currentPoint = currentPoint->next;
continue;
}
if((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1) < 100){
currentPoint = currentPoint->next;
continue;
}
double d2 = dx* dx + dy * dy;
// pxFromLonLat(&dx, &dy, currentPoint->lon, currentPoint->lat);
// screenCoords(&x2, &y2, dx, dy);
double alpha = 1.0 - (d1+d2) / (3* appData.maxDist * appData.maxDist);
// double alpha = 1.0;
// thickLineRGBA(appData.renderer, x1, y1, x2, y2, appData.screen_uiscale, 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);
lineRGBA(appData.renderer, x1, y1, x2, y2, 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);
// prevPoint = currentPoint;
// currentPoint = currentPoint->next;
// }
prevPoint = currentPoint;
currentPoint = currentPoint->next;
}
////bounding boxes

View file

@ -1 +1 @@
b44aeb09f69d729d671d17f19bfd669b615a3702
876851c7cb19383223314e1599b55727c8695ce2

BIN
font.o

Binary file not shown.

View file

@ -1 +1 @@
bb8d618a3de2096192e6fd03ba715f6346df1193
16d52890261f72e78ba71c37bea36a5c18405767

BIN
list.o

Binary file not shown.

View file

@ -0,0 +1 @@
f94cfbe36f64a1d81f38c7a21ed5ea789092d0b2

View file

@ -0,0 +1 @@
15dc88c67daedfe75f3e5ac04fe1cb6b96908c09

View file

@ -0,0 +1,14 @@
from lxml import etree as ElementTree
parser = ElementTree.XMLParser(recover=True)
tree = ElementTree.parse('all.svg', parser)
polys = tree.xpath('//polygon')
text_file = open("test.txt", "wt")
for p in polys:
currentPoints = p.attrib['points']
currentPoints = currentPoints.replace(" ", ",")
text_file.write(currentPoints + ",0,0")
text_file.close()

View file

@ -1 +1 @@
1392d6dd9fcc07ddac1768bd620a3355a2f836eb
1420a2ee0d38618a03222daea18788de0178f471

BIN
mapdata.o Normal file

Binary file not shown.

View file

@ -1 +0,0 @@
76782b1a281904545022bc5880c90dcc50d20ec5

BIN
monokai.o

Binary file not shown.

Binary file not shown.

View file

@ -1 +1 @@
ad8dd0e24a66f4d0d8df1297c6b9d65e3e429797
b1eb5d50ff478da938172f368ef72d8de4100ceb

View file

@ -1 +1 @@
4a7d01d6e64697656eef39194bc58105fdcba550
53b830e927a180703148d0394461fe22fe54dc54