WorldWideTelescope / wwt-web-client

The WorldWide Telescope web client lets you explore the universe in your browser.
https://worldwidetelescope.org/webclient/
MIT License
104 stars 35 forks source link

How do you superimpose an image from Nova #345

Closed MSmithDev closed 3 years ago

MSmithDev commented 3 years ago

Hello, I'm trying to figure out programmatically how do you superimpose an image from Nova onto the viewer. I know you can click the link from Nova's site and it will do it automatically but how is this done in code?

Thanks!

pkgw commented 3 years ago

Hi — to clarify, do you mean the nova.astrometry.net website?

MSmithDev commented 3 years ago

Hi — to clarify, do you mean the nova.astrometry.net website?

Yes, Basically looking for the programmatic approach to this:

Screenshot 2021-04-26 104431 Screenshot 2021-04-26 104457

pkgw commented 3 years ago

I'll try to give a brief outline of how the pieces fit together here. I'll be happy to follow up as needed — I'm trying to keep it clear but the system has some intrinsic complexity.

The basic way that the overlay happens is that the webclient is loaded up with a wtml URL parameter:

http://worldwidetelescope.org/webclient/?wtml=URL

where URL is the location of a WTML collection file containing information about the image to be overlaid as a <Place> item. When you start up the webclient with this parameter it loads up the WTML and auto-seeks to the image.

So where do we get this WTML? For the Astrometry.Net example, the URL is a call to the WWT ShowImage API endpoint. This API takes astrometric information for an image as URL arguments and synthesizes them into a sort of single-use WTML file that can then be fed to the webclient.

Finally, Astrometry.Net knows what parameters to send to the ShowImage API from its WCS solution of your image. When it generates the HTML code for your image's landing page, it translates that solution into the proper arguments to the ShowImage API.

So what can you do? If you're in a position to run Python code and serve your own WTML files, you can use the wwt_data_formats and/or toasty Python modules to generate your own WTML from a WCS solution and convey it to the webclient. These packages provide helper routiness that aim to make that process very easy.

In other circumstances, it might make sense for you to generate a URL that uses the ShowImage API in the same way that Astrometry.net does. You'll have to translate your coordinate solution to URL parameters manually, basically re-implementing the work that wwt_data_formats does, but with the documentation and some trial-and-error hopefully that's not too hard.

I hope that helps.

MSmithDev commented 3 years ago

Okay, that definitely clears it up some. I guess the only other question I have is whether or not this also supports multiple images or just one at a time.

Edit: I suppose this answers my question

This API returns a WTML collection XML document that points to a single web-accessible image no larger than 2048×2048 pixels.

Thanks for your help!

pkgw commented 3 years ago

@MSmithDev Yes, the high-level APIs only support a single image. The underlying rendering engine can layer any number of images, though, and that's the kind of thing that we want to be easy for people to do if they're willing and able to get into writing some JavaScript.

I'm going to close this issue, but feel free to comment or file a new one if there's more to discuss.