public override void RequestImage()
 {
     fitsImage = dataset.WcsImage as FitsImage;
     if (fitsImage != null)
     {
         texReady       = true;
         Downloading    = false;
         errored        = fitsImage.errored;
         RequestPending = false;
         TileCache.RemoveFromQueue(this.Key, true);
         if (RenderContext.UseGlVersion2)
         {
             MakeTexture();
             ReadyToRender = true;
         }
         else
         {
             bmp           = fitsImage.GetBitmap();
             texture2d     = bmp.GetTexture();
             ReadyToRender = true;
         }
     }
     else
     {
         base.RequestImage();
     }
 }
Exemple #2
0
        public virtual void RequestImage()
        {
            if (Dataset.WcsImage != null)
            {
                texReady       = true;
                Downloading    = false;
                errored        = false;
                ReadyToRender  = true;
                RequestPending = false;
                TileCache.RemoveFromQueue(this.Key, true);
                return;
            }

            if (!Downloading && !ReadyToRender)
            {
                Downloading = true;
                texture     = (ImageElement)Document.CreateElement("img");
                CrossDomainImage xdomimg = (CrossDomainImage)(object)texture;

                texture.AddEventListener("load", delegate(ElementEvent e)
                {
                    texReady       = true;
                    Downloading    = false;
                    errored        = false;
                    ReadyToRender  = texReady && (DemReady || !demTile);
                    RequestPending = false;
                    TileCache.RemoveFromQueue(this.Key, true);
                    MakeTexture();
                }, false);

                texture.AddEventListener("error", delegate(ElementEvent e)
                {
                    if (!texture.HasAttribute("proxyattempt"))
                    {
                        texture.Src = Util.GetProxiedUrl(URL);
                        texture.SetAttribute("proxyattempt", true);
                    }
                    else
                    {
                        Downloading    = false;
                        ReadyToRender  = false;
                        errored        = true;
                        RequestPending = false;
                        TileCache.RemoveFromQueue(this.Key, true);
                    }
                }, false);

                xdomimg.crossOrigin = "anonymous";
                texture.Src         = this.URL.Replace("cdn.", "www.");
                //texture.Src = "dss.png";

                // TODO add event listener for failed!
            }
        }
Exemple #3
0
 public override void RequestImage()
 {
     if (IsCatalogTile)
     {
         if (!Downloading && !ReadyToRender)
         {
             Downloading = true;
             catalogData = new WebFile(this.URL);
             catalogData.OnStateChange = LoadCatalogData;
             catalogData.Send();
         }
     }
     else if (GetHipsFileExtention() == ".fits")
     {
         if (!Downloading && !ReadyToRender)
         {
             Downloading = true;
             if (RenderContext.UseGlVersion2)
             {
                 fitsImage = new FitsImageTile(dataset, URL, delegate(WcsImage wcsImage)
                 {
                     Downloading = false;
                     errored     = fitsImage.errored;
                     TileCache.RemoveFromQueue(this.Key, true);
                     if (!fitsImage.errored)
                     {
                         texReady       = true;
                         ReadyToRender  = texReady && (DemReady || !demTile);
                         RequestPending = false;
                         MakeTexture();
                     }
                 });
             }
             else
             {
                 FitsImageJs image = FitsImageJs.CreateHipsTile(dataset, URL, delegate(WcsImage wcsImage)
                 {
                     texReady       = true;
                     Downloading    = false;
                     errored        = false;
                     ReadyToRender  = texReady && (DemReady || !demTile);
                     RequestPending = false;
                     TileCache.RemoveFromQueue(this.Key, true);
                     texture2d = wcsImage.GetBitmap().GetTexture();
                 });
             }
         }
     }
     else
     {
         base.RequestImage();
     }
 }
Exemple #4
0
        public void RequestDem()
        {
            if (!ReadyToRender && !demDownloading)
            {
                demTile        = true;
                demDownloading = true;

                callCount++;
                XMLHttpRequest2 xhr = new XMLHttpRequest2();
                xhr.AddEventListener("load", delegate(ElementEvent e)
                {
                    DemReady       = true;
                    demDownloading = false;
                    ReadyToRender  = texReady && (DemReady || !demTile);
                    RequestPending = false;
                    try
                    {
                        demFile = new Float32Array(xhr.Response);
                    }
                    catch
                    {
                    }

                    TileCache.RemoveFromQueue(this.Key, true);
                }, false);

                xhr.AddEventListener("error", delegate(ElementEvent e)
                {
                    demDownloading = false;
                    DemReady       = false;
                    ReadyToRender  = false;
                    errored        = true;
                    RequestPending = false;
                    TileCache.RemoveFromQueue(this.Key, true);
                }, false);

                xhr.Open(HttpVerb.Get, DemURL /*.Replace("cdn.", "www.")*/, true);
                xhr.ResponseType = "arraybuffer";
                xhr.Send();
                // TODO add event listener for failed!
            }
        }
Exemple #5
0
 private void LoadCatalogData()
 {
     if (catalogData.State == StateType.Error)
     {
         RequestPending = false;
         Downloading    = false;
         errored        = true;
         TileCache.RemoveFromQueue(this.Key, true);
     }
     else if (catalogData.State == StateType.Received)
     {
         ExtractCatalogTileRows();
         texReady       = true;
         Downloading    = false;
         errored        = false;
         ReadyToRender  = true;
         RequestPending = false;
         TileCache.RemoveFromQueue(this.Key, true);
     }
 }
Exemple #6
0
 public void FileStateChange()
 {
     if (webFile.State == StateType.Error)
     {
         Downloading    = false;
         ReadyToRender  = false;
         errored        = true;
         RequestPending = false;
         TileCache.RemoveFromQueue(this.Key, true);
     }
     else if (webFile.State == StateType.Received)
     {
         texReady       = true;
         Downloading    = false;
         errored        = false;
         ReadyToRender  = texReady && (DemReady || !demTile);
         RequestPending = false;
         TileCache.RemoveFromQueue(this.Key, true);
         LoadData(webFile.GetText());
     }
 }
Exemple #7
0
        public virtual void RequestImage()
        {
            if (Dataset.WcsImage != null)
            {
                texReady       = true;
                Downloading    = false;
                errored        = false;
                ReadyToRender  = true;
                RequestPending = false;
                TileCache.RemoveFromQueue(this.Key, true);
                return;
            }

            if (!Downloading && !ReadyToRender)
            {
                Downloading = true;
                texture     = (ImageElement)Document.CreateElement("img");
                CrossDomainImage xdomimg = (CrossDomainImage)(object)texture;

                texture.AddEventListener("load", delegate(ElementEvent e)
                {
                    texReady       = true;
                    Downloading    = false;
                    errored        = false;
                    ReadyToRender  = texReady && (DemReady || !demTile);
                    RequestPending = false;
                    TileCache.RemoveFromQueue(this.Key, true);
                    MakeTexture();
                }, false);

                texture.AddEventListener("error", delegate(ElementEvent e)
                {
                    if (!texture.HasAttribute("proxyattempt"))
                    {
                        texture.SetAttribute("proxyattempt", true);

                        // NOTE: `this.URL` is dynamically generated using
                        // URLHelpers.rewrite(). Say that we request tiles from
                        // example.com, which requires CORS proxying. Say also
                        // that this callback is called for a request to a tile
                        // that should in fact be available. If a different
                        // request fails before this callback is called,
                        // activateProxy() will be called on the example.com
                        // domain, making it so that `this.URL` in the following
                        // call goes through the proxy, making it so that
                        // `new_url` is null, making it so that this tile is
                        // erroneously marked as failed when it should not be.
                        // The solution: make sure to check proxy activation
                        // with the *original* request URL, `texture.Src`, not
                        // the one that may have been updated, `this.URL`.
                        string new_url = URLHelpers.singleton.activateProxy(texture.Src);

                        if (new_url != null)
                        {  // null => don't bother: we know that the proxy won't help
                            texture.Src = new_url;
                            return;
                        }
                    }

                    Downloading    = false;
                    ReadyToRender  = false;
                    errored        = true;
                    RequestPending = false;
                    TileCache.RemoveFromQueue(this.Key, true);
                }, false);

                xdomimg.crossOrigin = "anonymous";
                texture.Src         = this.URL;
            }
        }
Exemple #8
0
        public virtual void RequestImage()
        {
            if (dataset.Extension.ToLowerCase().IndexOf("fits") > -1)
            {
                if (!Downloading && !ReadyToRender)
                {
                    Downloading = true;
                    if (RenderContext.UseGlVersion2)
                    {
                        fitsImage = new FitsImageTile(dataset, URL, delegate(WcsImage wcsImage)
                        {
                            Downloading = false;
                            errored     = fitsImage.errored;
                            TileCache.RemoveFromQueue(this.Key, true);
                            if (!fitsImage.errored)
                            {
                                // For a non-HiPS tiled FITS, this is our
                                // mechanism for notifying the layer creator
                                // that the initial FITS data have loaded and
                                // the FitsProperties can be trusted.
                                if (Level == 0)
                                {
                                    dataset.FitsProperties.FireMainImageLoaded(fitsImage);
                                    fitsImage.ApplyDisplaySettings();
                                }
                                texReady       = true;
                                ReadyToRender  = texReady && (DemReady || !demTile);
                                RequestPending = false;
                                MakeTexture();
                            }
                        });
                    }
                    else
                    {
                        fitsImage = FitsImageJs.CreateTiledFits(dataset, URL, delegate(WcsImage wcsImage)
                        {
                            if (Level == 0)
                            {
                                dataset.FitsProperties.FireMainImageLoaded(fitsImage);
                            }
                            texReady       = true;
                            Downloading    = false;
                            errored        = fitsImage.errored;
                            ReadyToRender  = texReady && (DemReady || !demTile);
                            RequestPending = false;
                            TileCache.RemoveFromQueue(this.Key, true);
                            texture2d = wcsImage.GetBitmap().GetTexture();
                        });
                    }
                }
            }
            else
            {
                if (Dataset.WcsImage != null)
                {
                    texReady       = true;
                    Downloading    = false;
                    errored        = false;
                    ReadyToRender  = true;
                    RequestPending = false;
                    TileCache.RemoveFromQueue(this.Key, true);
                    return;
                }

                if (!Downloading && !ReadyToRender)
                {
                    Downloading = true;
                    texture     = (ImageElement)Document.CreateElement("img");
                    CrossDomainImage xdomimg = (CrossDomainImage)(object)texture;

                    texture.AddEventListener("load", delegate(ElementEvent e)
                    {
                        texReady       = true;
                        Downloading    = false;
                        errored        = false;
                        ReadyToRender  = texReady && (DemReady || !demTile);
                        RequestPending = false;
                        TileCache.RemoveFromQueue(this.Key, true);
                        MakeTexture();
                    }, false);

                    texture.AddEventListener("error", delegate(ElementEvent e)
                    {
                        if (!texture.HasAttribute("proxyattempt"))
                        {
                            texture.SetAttribute("proxyattempt", true);

                            // NOTE: `this.URL` is dynamically generated using
                            // URLHelpers.rewrite(). Say that we request tiles from
                            // example.com, which requires CORS proxying. Say also
                            // that this callback is called for a request to a tile
                            // that should in fact be available. If a different
                            // request fails before this callback is called,
                            // activateProxy() will be called on the example.com
                            // domain, making it so that `this.URL` in the following
                            // call goes through the proxy, making it so that
                            // `new_url` is null, making it so that this tile is
                            // erroneously marked as failed when it should not be.
                            // The solution: make sure to check proxy activation
                            // with the *original* request URL, `texture.Src`, not
                            // the one that may have been updated, `this.URL`.
                            string new_url = URLHelpers.singleton.activateProxy(texture.Src);

                            if (new_url != null)
                            {  // null => don't bother: we know that the proxy won't help
                                texture.Src = new_url;
                                return;
                            }
                        }

                        Downloading    = false;
                        ReadyToRender  = false;
                        errored        = true;
                        RequestPending = false;
                        TileCache.RemoveFromQueue(this.Key, true);
                    }, false);

                    xdomimg.crossOrigin = "anonymous";
                    texture.Src         = this.URL;
                }
            }
        }
Exemple #9
0
        public override void RequestImage()
        {
            fitsImage = dataset.WcsImage as FitsImage;
            if (fitsImage != null)
            {
                texReady       = true;
                Downloading    = false;
                errored        = fitsImage.errored;
                RequestPending = false;
                TileCache.RemoveFromQueue(this.Key, true);
                if (RenderContext.UseGlVersion2)
                {
                    MakeTexture();
                    ReadyToRender = true;
                }
                else
                {
                    bmp           = fitsImage.GetBitmap();
                    texture2d     = bmp.GetTexture();
                    ReadyToRender = true;
                }
            }
            else if (dataset.Extension == ".fits" && dataset.WcsImage == null)
            {
                if (!Downloading && !ReadyToRender)
                {
                    Downloading = true;
                    if (RenderContext.UseGlVersion2)
                    {
                        fitsImage = new FitsImageTile(dataset, URL, delegate(WcsImage wcsImage)
                        {
                            Downloading = false;
                            errored     = fitsImage.errored;
                            TileCache.RemoveFromQueue(this.Key, true);
                            if (!fitsImage.errored)
                            {
                                // For a non-HiPS tiled FITS, this is our
                                // mechanism for notifying the layer creator
                                // that the initial FITS data have loaded and
                                // the FitsProperties can be trusted.
                                if (Level == 0)
                                {
                                    dataset.FitsProperties.FireMainImageLoaded(fitsImage);
                                }

                                texReady       = true;
                                ReadyToRender  = texReady && (DemReady || !demTile);
                                RequestPending = false;
                                MakeTexture();
                                ReadyToRender = true;
                            }
                        });
                    }
                    else
                    {
                        fitsImage = FitsImageJs.CreateTiledFits(dataset, URL, delegate(WcsImage wcsImage)
                        {
                            if (Level == 0)
                            {
                                dataset.FitsProperties.FireMainImageLoaded(fitsImage);
                            }

                            texReady       = true;
                            Downloading    = false;
                            errored        = fitsImage.errored;
                            ReadyToRender  = texReady && (DemReady || !demTile);
                            RequestPending = false;
                            TileCache.RemoveFromQueue(this.Key, true);
                            bmp           = wcsImage.GetBitmap();
                            texture2d     = bmp.GetTexture();
                            ReadyToRender = true;
                        });
                    }
                }
            }
            else
            {
                base.RequestImage();
            }
        }