/* * GPSTOGOOG * Copyright (C) 2013 Adam Williams * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include #include int main(int argv, char *argc[]) { FILE *fd = fopen(argc[1], "r"); if(!fd) return; printf("\n" "\n" "\n" " recorded.kml\n" " \n" " \n" " \n" " normal\n" " #sn_ylw-pushpin\n" " \n" " \n" " highlight\n" " #sh_ylw-pushpin\n" " \n" " \n" " \n" " \n" " recorded\n" " #msn_ylw-pushpin\n" " \n" " 1\n" " \n"); char string[1024]; char string1[1024]; char string2[1024]; char string3[1024]; double lat, lon, alt; int counter = 0; do { fscanf(fd, "%s", string); counter++; if(counter == 1) continue; // printf("%s\n", string); char *ptr = string; string1[0] = 0; string2[0] = 0; string3[0] = 0; while(*ptr != ',' && *ptr != 0) ptr++; if(*ptr) ptr++; char *ptr2 = string1; while(*ptr != ',' && *ptr != 0) *ptr2++ = *ptr++; *ptr2++ = 0; if(*ptr) ptr++; ptr2 = string2; while(*ptr != ',' && *ptr != 0) *ptr2++ = *ptr++; *ptr2++ = 0; if(*ptr) ptr++; ptr2 = string3; while(*ptr != ',' && *ptr != 0) *ptr2++ = *ptr++; *ptr2++ = 0; // printf("%s %s %s\n", string1, string2, string3); lat = atof(string1); lon = atof(string2); alt = atof(string3); printf("%f,%f,%f\n", lon, lat, alt); }while(!feof(fd)); printf(" \n" " \n" " \n" "\n" "\n"); }