Re: polyfill problem [message #6264] |
Fri, 24 May 1996 00:00 |
Andy Loughe
Messages: 174 Registered: November 1995
|
Senior Member |
|
|
Recently a few users indicated that polyfill reacts poorly
on many map projections. I have written a simple "wrapper"
which prevents bad boy polygons from being drawn at all
(providing a better solution doesn't fit my job description).
Please let me know if this doesn't work as advertised.
Instead of calling polyfill, call my_polyfill within
your procedures.
;
; Name ............ my_polyfill.pro
;
; Description ..... Before executing polyfill, check that
; the (x,y) coordinates are valid.
;
; Parameters ...... x,y contain vertices of the polygon.
;
; Keywords ........ See documentation for polyfill.
;
; Originator ...... Andrew F. Loughe, NOAA/ERL/CDC, 21 MAY 1996.
pro my_polyfill, x, y, _EXTRA=e
on_error, 2
; Convert the x,y coordinates to the normalized system.
result = CONVERT_COORD(x, y, /data, /to_normal) ; DEFAULT: From /data
; Check that /normal or /device might have been set.
if ( KEYWORD_SET(e) ) then begin
names = TAG_NAMES(e)
for i = 0, N_TAGS(e)-1 do begin
if ( names(i) eq 'NORMAL' ) then $
result = CONVERT_COORD(x, y, /normal, /to_normal) ; From /normalized
if ( names(i) eq 'DEVICE' ) then $
result = CONVERT_COORD(x, y, /device, /to_normal) ; From /device
endfor ; i-loop
endif ; KEYWORD_SET(e)
; Check that the normalized coordinates are within the bounds
; set by !x.window and !y.window
out_of_bounds = 0
if ( MIN(result(0,*)) lt !x.window(0) or $
MAX(result(0,*)) gt !x.window(1) or $
MIN(result(1,*)) lt !y.window(0) or $
MAX(result(1,*)) gt !y.window(1) ) then out_of_bounds = 1
if (out_of_bounds eq 1) then print, '(x,y) coordinates are out of bounds!'
if (out_of_bounds eq 0) then polyfill, x, y, _EXTRA=e
end
--
Andrew F. Loughe [afl@cdc.noaa.gov, http://cdc.noaa.gov/~afl]
University of Colorado, CIRES * Campus Box 449 * Boulder, CO 80309
phone: (303) 492-0707 fax: (303) 497-7013
"Give me ambiguity or give me something else!"
|
|
|