* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * readpolygons.gsf * Written by J.M. Adams March 2003 * function readpolygons args = '8 34 67 98' _minlat = subwrd(args,1) _maxlat = subwrd(args,2) _minlon = subwrd(args,3) _maxlon = subwrd(args,4) * Set up a scaling environment for the polygons 'sdfopen http://monsoondata.org:9090/dods/model' 'set lat '_minlat' '_maxlat 'set lon '_minlon' '_maxlon * Draw a blank map 'set rgb 99 1 1 1' 'set annot 99' 'set clevs 0' 'set frame off' 'set grid off' 'set grads off' 'set map 0' 'set xlab off' 'set ylab off' 'd ta+10e4' * Read the first record from the polygon file file = 'india_polygons.asc' result = read(file) rc = sublin(result,1) rc = subwrd(rc,1) if (rc!=0) say 'Error reading 'file return endif newcmd = sublin(result,2) * Read subsequent records, allowing for read input buffer overflow flag = 1 polynum = 1 while (flag) wcmd = newcmd while(1) result = read(file) rc = sublin(result,1) rc = subwrd(rc,1) if (rc!=0) flag = 0 break else newcmd = sublin(result,2) if (subwrd(newcmd,2) != 'draw') wcmd = wcmd % newcmd else break endif endif endwhile subr = subwrd(wcmd,1) count = 4 cmdf = 'draw polyf ' cmdo = 'draw poly ' while (1) countx = count county = count + 1 wx = subwrd(wcmd,countx) wy = subwrd(wcmd,county) if ((wx = '') | (wy = '')) break endif * Convert world coordinates to screen coordinates 'q w2xy 'wx' 'wy sx = subwrd(result,3) sy = subwrd(result,6) cmdf = cmdf%sx' 'sy' ' cmdo = cmdo%sx' 'sy' ' count = count + 2 endwhile * Copy the draw command into a script variable array _drawpolyf.subr = cmdf _drawpoly.subr = cmdo polynum = polynum + 1 endwhile * END OF SCRIPT FUNCTION