-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap-parser.cpp
More file actions
34 lines (28 loc) · 800 Bytes
/
map-parser.cpp
File metadata and controls
34 lines (28 loc) · 800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "all.h"
#include "map-parser.h"
static const int
POINTS_CNT=30,
FIRST_STRS=9,
LEN=100;
pair<const char*,parseOut> parse(const char *FileName){
FILE* file=fopen(FileName,"r");
char (*S)[LEN]=new char[FIRST_STRS][LEN];
forn(i,FIRST_STRS)
fgets(S[i],LEN,file);
parseOut answer;
forn(i,POINTS_CNT){
int x,y,latdeg,londeg;
double latmin,lonmin;
char latc,lonc;
if(fscanf(file,"%*[^,],%*s %d,%d,%*[^,],%*[^,],%d,%lf,%c,%d,%lf,%c%*[^\n]\n",&x,&y,&latdeg,&latmin,&latc,&londeg,&lonmin,&lonc)!=8)
break;
LD lat=latdeg+latmin/60, lon=londeg+lonmin/60;
lat*=(latc=='N'?+1:-1), lon*=(lonc=='E'?+1:-1);
answer.pb(mp(point<int>(x,y),point<LD>(lat,lon)));
}
int L=strlen(S[2]);
while(L && isspace(S[2][L-1]))
S[2][L-1]=0, --L;
fclose(file);
return mp(S[2],answer);
}