c03 #include #include #include #include #include #include "mapview.h" #include "e00.h" #include "dcw.h" static unsigned long landcolor = -1; static unsigned long getiscolor(E00MAP *map) { unsigned long color = bgcolor; switch (map->covtype) { case PPPOLY: if (landcolor != -1) color = landcolor; break; case DNNET: if (landcolor != -1) color = landcolor; break; } return color; } static unsigned long getfillcolor(E00MAP *map, POLY *ply) { unsigned long color = map->fillcolor; switch (map->covtype) { case PONET: if (ply->type == 2) color = bgcolor; break; case PPPOLY: if (ply->type == 9) color = (landcolor != -1) ? landcolor : bgcolor; break; case DNNET: if (ply->type != 1) color = (landcolor != -1) ? landcolor : bgcolor; break; case HYNET: if (ply->type == 1) color = bgcolor; break; } return color; } void drawdcw(E00MAP *map) { drawe00(map, getiscolor, getfillcolor); } static void parseaat(FILE *f, char *hdr, E00MAP *map) { char s[100]; char name[50], extflag[5]; int anum, tanum, reclen, recnum; int i; sscanf(hdr, "%s %s %d %d %d %d", name, extflag, &anum, &tanum, &reclen, &recnum); /* Skip over attribute info */ for (i = 0; i < tanum; i++) fgets(s, 100, f); for (i = 0; i < recnum; i++) { int fnode, tnode, lpoly, rpoly; double length; int recnum, recid, rectype, recstat; fscanf(f, "%d %d %d %d %lf %d %d %d %d", &fnode, &tnode, &lpoly, &rpoly, &length, &recnum, &recid, &rectype, &recstat); map->arcs[i]->type = rectype; } } static void parsepat(FILE *f, char *hdr, E00MAP *map) { char s[100]; char name[50], extflag[5]; int anum, tanum, reclen, recnum; POLY *ply; int i; sscanf(hdr, "%s %s %d %d %d %d", name, extflag, &anum, &tanum, &reclen, &recnum); /* Skip over attribute info */ for (i = 0; i < tanum; i++) fgets(s, 100, f); /* Skip over universal polygon */ fgets(s, 100, f); recnum--; ply = map->polys; for (i = 0; i < recnum; i++) { double area, perimeter; int recnum, recid, rectype; fscanf(f, "%lf %lf %d %d %d", &area, &perimeter, &recnum, &recid, &rectype); ply->type = rectype; ply = ply->next; } } E00MAP *loaddcw(char *fname, unsigned long color, unsigned long fillcolor, int width) { E00MAP *map; map = loade00(fname, color, fillcolor, width, parseaat, parsepat); map->type = DCW; if (! strcmp(map->covname, "ponet")) { map->covtype = PONET; if (map->fillcolor != -1) landcolor = label_bgcolor = map->fillcolor; } else if (! strcmp(map->covname, "pppoly")) map->covtype = PPPOLY; else if (! strcmp(map->covname, "dnnet")) map->covtype = DNNET; else if (! strcmp(map->covname, "hynet")) map->covtype = HYNET; return map; } . 0