DotSpatial / DotSpatial

Geographic information system library written for .NET
MIT License
881 stars 368 forks source link

Dotspatial can only display a part of the big tiff image #941

Open Huweijian opened 7 years ago

Huweijian commented 7 years ago

I did some work on DotSpatial.sln's DemoMap and found a problem.

Steps to reproduce

  1. I have a 2.16G image with only one band(a.tif) and a pyramid file (a.ovr) in the same folder.
  2. Because GdalImageProvider can identify the GDAL's pyramid file(.ovr) but GdalRasterProvider can't, so I changed GdalImageProvider's constructor as follows to make the image read by GdalImageProvider but not by GdalRasterProvider:
    
    public GdalImageProvider ()
        {
            GdalConfiguration.ConfigureGdal();
            string[] extensions = { ".tif", ".tiff", ".adf" };
            foreach (string extension in extensions)
            {
                if (!DataManager.DefaultDataManager.PreferredProviders.ContainsKey(extension))
                {
                    DataManager.DefaultDataManager.PreferredProviders.Add(extension, this);
                }
            }
        }

3. Run the DemoMap and use Add layers menu to add image.

DotSpatial version:  1.9 

### Expected behaviour

It should load the image quickly and return a bitmap in the screen as follow.
![1](https://cloud.githubusercontent.com/assets/10543096/23260191/a1861da4-fa0b-11e6-9b38-c2d499dc2ac7.PNG)

### Actual behaviour

But it shows a not complete image as follows.

![2](https://cloud.githubusercontent.com/assets/10543096/23260280/f8068cf4-fa0b-11e6-801a-fa9c33c0d775.PNG)

I tried to find some scale factors to change the image's size and its position in final bitmap but failed. I found GdalImage only saves the image's basic information but not saved any values( See GdalImage's line 89) so is it possible Dotspatial only read the partial image? Or the read process is correct but the write process has a bug?
jany-tenaj commented 7 years ago

If you have a look at the issue list you'll see that GdalImage is currently a little buggy.

Try the current source code from master to see whether your problem was solved with the fixes we added since 1.9. BTW in master you can simply select GDAL-Image from the drop down in Add layers instead of manipulating the code.

If this doesn't help maybe try the bigger-changes branch, where I'm currently trying to fix GdalImage.

If this doesn't help it would be nice if you could upload your source image somehow so we can use it to help us fix GdalImage.

Huweijian commented 7 years ago

@jany-tenaj Thank you for your answer! I have tried the methods you proposed above but failed. If you don't mind can you tell my your email address so that I can send my source image to you?