moagrius/TileView

Support Remote Images

daominhsangvn opened this issue · 3 comments

I already have an server that serve images for the tileview and it's working great with the leafletjs.
Now i want to bring those tiles into this module.
For Example:

        new TileView.Builder(tileView)
                .setSize(1024, 1444)
                .defineZoomLevel(1, "http://nois.newoceaninfosys.com:44413/media/a5cbb8780015449fa068f8dfde02f856/1-%1$d-%2$d.png")
                .defineZoomLevel(2, "http://nois.newoceaninfosys.com:44413/media/a5cbb8780015449fa068f8dfde02f856/2-%1$d-%2$d.png")
                .defineZoomLevel(3, "http://nois.newoceaninfosys.com:44413/media/a5cbb8780015449fa068f8dfde02f856/3-%1$d-%2$d.png")

                .addReadyListener(new TileView.ReadyListener() {
                    @Override
                    public void onReady(TileView tileView) {

                    }
                })
                .build();

You need a remote stream provider. There is a built-in one but feel free to use your preferred image loading library (Glide, Volley, etc).

You also want to start at detail level 0.

        new TileView.Builder(tileView)
                .setStreamProvider(new StreamProviderHttp())
                .setSize(1024, 1444)
                .defineZoomLevel(0, "http://nois.newoceaninfosys.com:44413/media/a5cbb8780015449fa068f8dfde02f856/1-%1$d-%2$d.png")
                .defineZoomLevel(1, "http://nois.newoceaninfosys.com:44413/media/a5cbb8780015449fa068f8dfde02f856/2-%1$d-%2$d.png")
                .defineZoomLevel(2, "http://nois.newoceaninfosys.com:44413/media/a5cbb8780015449fa068f8dfde02f856/3-%1$d-%2$d.png")

                .addReadyListener(new TileView.ReadyListener() {
                    @Override
                    public void onReady(TileView tileView) {

                    }
                })
                .build();

I ran a quick test and I see that most of those tiles aren't defined. Even on a small screen, you're going to need more than 1 or 2 tiles...

07-17 15:12:36.683 24764-24827/tileview.demo D/TV: failed to decode: http://nois.newoceaninfosys.com:44413/media/a5cbb8780015449fa068f8dfde02f856/1-2-0.png
07-17 15:12:36.683 24764-24828/tileview.demo D/TV: failed to decode: http://nois.newoceaninfosys.com:44413/media/a5cbb8780015449fa068f8dfde02f856/1-3-0.png
07-17 15:12:36.933 24764-24828/tileview.demo D/TV: failed to decode: http://nois.newoceaninfosys.com:44413/media/a5cbb8780015449fa068f8dfde02f856/1-2-1.png

If you're image is really 1024 x 1444 you don't need TileView, you can display that in an ImageView. If you want pan and zoom, you can use ScalingScrollView (also part of this library).

Hi @moagrius, Thanks for your reply.
I have a server to process the image.
First, i resize the original image to 256x256 and split the image into 4 tiles. Each tile will have 128x128. This is zoom level 1
For examples:
http://nois.newoceaninfosys.com:44413/media/a5cbb8780015449fa068f8dfde02f856/1-0-0.png
http://nois.newoceaninfosys.com:44413/media/a5cbb8780015449fa068f8dfde02f856/1-0-1.png
http://nois.newoceaninfosys.com:44413/media/a5cbb8780015449fa068f8dfde02f856/1-1-0.png
http://nois.newoceaninfosys.com:44413/media/a5cbb8780015449fa068f8dfde02f856/1-1-1.png

----------------
|    x      |     x     |
------- |--------
|    x      |      x     |
----------------

For zoom level 2, i resized image to 512x512 and i got 14 tiles in 128x128
For zoom level 3, i resized image to 1028x1028 and got 64 tiles in 128x128
And so on... until level 5

I don't know if this Library support this kind of image tiles?

it does support this, you're just in reverse order, i think. zoom level 0 is "fully zoomed in" and thus the largest image / largest number of tiles. try swapping that around, along with the other changes i mentioned before.

if that still doesn't work, if you can post your project somewhere i can get to it, along with some rules about the image generation api, i can take a look