comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Convert_Coords for map gives many 'error messages'?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Convert_Coords for map gives many 'error messages'? [message #31878] Tue, 27 August 2002 05:11
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Robbert Verweij (verweij@science-and-technology.nl) writes:

> we're implementing a piece of IDL code where multiple windows are used to
> visualise different parts of the data at the same time.
>
> The windows are individual draw_widgets. The active window is determined by
> the cursor position. This cursor position is being tracked and printed if
> the motion_events for that draw_widget are enabled (really much like one of
> the example IDL programs...). Two problems remain...
> 1) If I move the cursor to a MAP, convert_coords returns only NANs, until I
> redraw the map. It's not !P or so, I've stored and restored those (I
> think...). What can be the problem?

You are forgetting to save !MAP in addition to !P. (And !X and !Y, too,
probably. I always forget which ones I need, so I just save them all!)

> 2) Convert_coords returns the string 'Program caused arithmetic error:
> Floating illegal operand', if I move the cursor into the title field or so.
> Of course I could just not call Convert_coords for event.x < 10 and event.x
>> eg 400, but I don't know how many lines (hence pixels) the titlefield will
> be... Is it possible to call Convert_coords in 'Silent mode', ie to let it
> NOT return error messages?

Typically, you don't want to hard code numbers like 10 and 400
into your code because, of course, things can change. (You might
decide to use a resizable graphics window, for example.) If you
need to restrict the location of something, it is better
to use a value that changes with changing conditions (I.e.,
!D.X_SIZE and !D.Y_SIZE, etc.). In your case, you might want
to limit CONVERT_COORDS to the extent of your map projection.

For example, you might do something like this:

; Convert map boundaries to device coordinates.
xboundary = !X.Window * !D.X_SIZE
yboundary = !Y.Window * !D.Y_SIZE

; Restrict cursor location to map boundaries.
x = xboundary[0] > event.x < xboundary[1]
y = yboundary[0] > event.y < yboundary[1]
latlon = Convert_Coords(x, y, /Device, /To_Data)

> The source code is quite much.

It always is. :-)

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Convert_Coords for map gives many 'error messages'?
Next Topic: new link for examples

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 20:01:39 PDT 2025

Total time taken to generate the page: 1.19848 seconds