Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client side raster reprojection #581

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

gberaudo
Copy link
Member

@gberaudo gberaudo commented May 2, 2018

Restore #562.

@gberaudo
Copy link
Member Author

gberaudo commented May 2, 2018

There is an issue with this branch and the ImageWMS example.

@wallw-teal
Copy link

wallw-teal commented Jun 15, 2018

We were interested something similar, not for raster reprojection itself but just getting Cesium to use the OL tile load stack. That way, implementing a custom tile layer (such as GeoPackage) only needs to be done in OpenLayers and Cesium will run through the same stack.

Our PR for the work on that is here, with the relevant ImageryProvider changes here. Just a couple of notes compared with what you have here:

  • Do not assume that the minimum zoom level of the tile grid is 0 for the tileWidth and tileHeight getters. Use tg.getMinZoom() instead.
  • I tried the logic here for tiles in the ol.TileState.EMPTY state (in an overlay tile layer) which caused completely transparent tiles (base map layer should have shown). We went with making that state its own case.

Additionally, I went ahead and made a TilingScheme implementation that uses the original OpenLayers TileGrid instead directly. This allows for more (but not all) of the non-typical cases handled by the TileGrid class. This has the added advantage of not having to adjust the zoom level by 1 for the GeographicTilingScheme versus the WebMercatorTilingScheme.

Note that the custom TilingScheme requires Cesium >1.46.

@gberaudo
Copy link
Member Author

Thanks @wallw-bits for the infos. It is pretty cool!

@samuel-girard
Copy link
Contributor

Hi,

I am trying to rebase this branch onto ol-cesium v2 (currently working on the branch https://github.com/samuel-girard/ol-cesium/tree/olcs2-raster-reprojection).
Everything works well, except for 2 examples:

  • imageWMS: half of the globe is fine, the other half is black, not even loading OSM
  • customProj: the globe is all black

I get in fact the same results than I faced last time (screenshots here: #37 (comment))

It turns out these are the examples using an image source (ol/source/Image.js), other examples using tiled sources (ol/source/Tile*), I don't know if it is related though.

@wallw-teal
Copy link

I completed this work for OpenSphere in these two files:

Those classes require Cesium >= 1.46.

You can also check out my last comment above which has the details.

@samuel-girard
Copy link
Contributor

Hi @wallw-bits
Thanks for your advice.
I started to integrate the changes you did in opensphere for the reprojection (branch available here: https://github.com/samuel-girard/ol-cesium/tree/raster-reprojection), but I am facing the exact same problem than with the previous work in ol-cesium: everything works well except for the examples customProj (globe is totally black) and imageWMS (only half of the globe has OSM map).

So far, I have no idea why I get these problems, but I will keep investigating.

@wallw-teal
Copy link

You still have assumptions of a zero-level zoom in the tileWidth and tileHeight getters in OLImageryProvider. Also, this line should not use an instanceof <SomeTilingScheme> to check the projection. Use this.tilingScheme_.projection instanceof CesiumGeographicProjection instead.

However, neither of those are really your problem in those examples. The changes to OpenSphere were to support tile layers. Both of the examples you are referencing use image layers, which do not use TileGridTilingScheme or OLImageryProvider. I think your problem is here. That blurb is assuming that the source projection is EPSG:4326. You need to convert source.getImageExtent() from the source projection to EPSG:4326 first. If that extent is in EPSG:3857, then the image is already being reprojected. If it is in EPSG:21781, then you will need to have OpenLayers reproject it first before showing it.

@samuel-girard
Copy link
Contributor

Thanks @wallw-bits for your feedback.

I think your problem is here. That blurb is assuming that the source projection is EPSG:4326. You need to convert source.getImageExtent() from the source projection to EPSG:4326 first. If that extent is in EPSG:3857, then the image is already being reprojected. If it is in EPSG:21781, then you will need to have OpenLayers reproject it first before showing it.

The part you are referring to is about Static image sources (see the condition here). It wouldn't be the cause of the black globe issue (but I agree that it is another issue).

The problem I am facing is about ImageWMS sources (as you said, both failing examples use image layers), which are converted to TileWMS source here.
Even if I add these layers as TileWMS source using a tiled layer, the problem is still here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants