Created
December 5, 2009 20:02
-
-
Save jphastings/249839 to your computer and use it in GitHub Desktop.
Finds the most recent known location from a person's twitter user_timeline.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Just a snippet! | |
| typedef struct { | |
| float latitude; | |
| float longitude; | |
| int age; | |
| } Location; | |
| // The file should be a twitter user_timeline | |
| Location FindGeo(FILE *f) { | |
| char *str = "<georss:point>"; | |
| int s_pos; | |
| int c_pos; | |
| char *string; | |
| char ccnt; //char count | |
| Location position; | |
| position.age = -1; | |
| s_pos = -1; | |
| c_pos = 0; | |
| string = malloc(strlen(str)); | |
| while (!feof(f)) { | |
| if (c_pos == 0) | |
| for (ccnt = 1; ccnt <= strlen(str); ccnt++) | |
| if (!feof(f)) | |
| string[ccnt - 1] = getc(f); | |
| if (c_pos != 0) | |
| if (!feof(f)) { | |
| for (ccnt = 0; ccnt <= strlen(str) - 2; ccnt++) | |
| string[ccnt] = string[ccnt + 1]; | |
| string[strlen(str) - 1] = getc(f); | |
| } | |
| if (strcmp(string, str) == 0) { | |
| s_pos = c_pos; | |
| fscanf(f,"%f %f",&position.latitude,&position.longitude); | |
| position.age = 0; | |
| break; | |
| } | |
| c_pos++; | |
| } | |
| return(position); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment