I was about to suggest the use of a sextant for this. As far as I know, navigators are still trained to operate them in this day. Of course, the same operational principle can be integrated into a dedicated device.
Was going to say this, and in use by things like submarines and ships since the 60’s