24 static char key[100],
data[500];
37 G_debug(3,
" get_key_data(): %s", buf);
162 el->
coor.
line.alloc *
sizeof(
double));
165 el->
coor.
line.alloc *
sizeof(
double));
196 while (
G_getl2(buf, 500, fp) != 0) {
200 if ((buf[0] ==
'#') || (buf[0] ==
'\0'))
205 if (strcmp(key,
"END") == 0) {
210 if (sscanf(buf,
"%lf %lf", &x, &y) != 2) {
211 G_warning(
_(
"Cannot read symbol line coordinates: %s"), buf);
214 G_debug(5,
" x = %f y = %f", x, y);
239 char group[500],
name[500], buf[2001], buf2[2048];
242 double x, y, x2, y2, rad, ang1, ang2;
253 G_debug(3,
"S_read(): sname = %s", sname);
257 strcpy(group, sname);
258 c = strchr(group,
'/');
260 G_warning(
_(
"Incorrect symbol name: '%s' (should be: group/name or group/name@mapset)"),
269 G_debug(3,
" group: '%s' name: '%s'", group, name);
272 sprintf(buf,
"symbol/%s", group);
279 sprintf(buf,
"%s/etc/symbol/%s",
G_gisbase(), sname);
280 fp = fopen(buf,
"r");
284 G_warning(
_(
"Cannot find/open symbol: '%s'"), sname);
294 while (
G_getl2(buf, 2000, fp) != 0) {
299 if ((buf[0] ==
'#') || (buf[0] ==
'\0'))
304 if (strcmp(key,
"VERSION") == 0) {
305 if (strcmp(
data,
"1.0") != 0) {
306 sprintf(buf,
"Wrong symbol version: '%s'",
data);
307 return (
err(fp, symb, buf));
310 else if (strcmp(key,
"BOX") == 0) {
311 if (sscanf(
data,
"%lf %lf %lf %lf", &x, &y, &x2, &y2) != 4) {
312 sprintf(buf,
"Incorrect box definition: '%s'",
data);
313 return (
err(fp, symb, buf));
316 symb->
yscale = 1 / (y2 - y);
317 if (x2 - x > y2 - y) {
324 else if (strcmp(key,
"STRING") == 0) {
333 else if (strcmp(key,
"POLYGON") == 0) {
340 else if (strcmp(key,
"RING") == 0) {
347 else if (strcmp(key,
"LINE") == 0) {
354 else if (strcmp(key,
"ARC") == 0) {
357 sscanf(
data,
"%lf %lf %lf %lf %lf %c", &x, &y, &rad, &ang1,
360 sprintf(buf2,
"Incorrect arc definition: '%s'", buf);
361 return (
err(fp, symb, buf2));
363 if (ret == 6 && (clock ==
'c' || clock ==
'C'))
367 elem =
new_arc(x, y, rad, ang1, ang2, i);
371 else if (strcmp(key,
"END") == 0) {
387 else if (strcmp(key,
"COLOR") == 0) {
391 else if (sscanf(
data,
"%d %d %d", &r, &g, &b) == 3) {
392 if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255)
393 G_warning(
_(
"Incorrect symbol color: '%s', using default."),
406 G_debug(4,
" color [%d %d %d] = [%.3f %.3f %.3f]", r, g,
411 G_warning(
_(
"Incorrect symbol color: '%s', using default."),
415 else if (strcmp(key,
"FCOLOR") == 0) {
419 else if (sscanf(
data,
"%d %d %d", &r, &g, &b) == 3) {
420 if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255)
421 G_warning(
_(
"Incorrect symbol color: '%s', using default."),
434 G_debug(4,
" color [%d %d %d] = [%.3f %.3f %.3f]", r, g,
439 G_warning(
_(
"Incorrect symbol color: '%s', using default."),
444 sprintf(buf2,
"Unknown keyword in symbol: '%s'", buf);
445 return (
err(fp, symb, buf2));
453 for (i = 0; i < symb->
count; i++) {
454 part = symb->
part[i];
455 G_debug(4,
" Part %d: type: %d number of chains: %d", i, part->
type,
459 for (j = 0; j < part->
count; j++) {
460 chain = part->
chain[j];
461 G_debug(4,
" Chain %d: number of elements: %d", j,
463 for (k = 0; k < chain->
count; k++) {
464 elem = chain->
elem[k];
465 G_debug(4,
" Element %d: type: %d", k, elem->
type);
467 G_debug(4,
" Number of points %d",
469 for (l = 0; l < elem->
coor.
line.count; l++) {
int G_getl2(char *, int, FILE *)
Gets a line of text from a file of any pedigree.
void read_coor(FILE *fp, SYMBEL *e)
SYMBOL * S_read(const char *sname)
SYMBCHAIN * new_chain(void)
void get_key_data(char *buf)
SYMBOL * new_symbol(void)
void G_free(void *)
Free allocated memory.
SYMBEL * new_arc(double x, double y, double r, double a1, double a2, int c)
void add_element(SYMBCHAIN *s, SYMBEL *e)
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)
struct SYMBEL::@6::@8 arc
int int G_strcasecmp(const char *, const char *)
String compare ignoring case (upper or lower)
void add_chain(SYMBPART *p, SYMBCHAIN *s)
struct SYMBEL::@6::@7 line
FILE * G_fopen_old(const char *, const char *, const char *)
Open a database file for reading.
char * G_chop(char *)
Chop leading and trailing white spaces.
const char * G_find_file(const char *, char *, const char *)
Searches for a file from the mapset search list or in a specified mapset.
const char * G_gisbase(void)
Get full path name of the top level module directory.
void G_warning(const char *,...) __attribute__((format(printf
SYMBPART * new_part(int type)
void add_part(SYMBOL *s, SYMBPART *p)
void add_point(SYMBEL *el, double x, double y)
int G_debug(int, const char *,...) __attribute__((format(printf