ThinkGeo.com    |     Documentation    |     Premium Support

Exception when doing - layer.ImageSource.GetImage

Hello,

I’m trying to make some manipulation on “.tif” image
you can download the file from here:

Once the following code is invoked, I receive System.IndexOutOfRangeException, the exception is thrown on the layer.ImageSource.GetImage line.

public void Init(RasterLayer layer)
{
RectangleShape ImageBounds = layer.GetBoundingBox();
int ImageHeight = layer.ImageSource.GetImageHeight();
int ImageWidth = layer.ImageSource.GetImageWidth();

using (GeoImage sourceGeoImage = layer.ImageSource.GetImage(ImageBounds, ImageWidth, ImageHeight))
{



}
}

Values received from the “layer” and “layer.ImageSource” are:

ImageBounds = {-180.00000406988,89.9999964404851,180.000014705583,-90.0000129472464}
base: {-180.00000406988,89.9999964404851,180.000014705583,-90.0000129472464}
Height: 180.00000938773155
LowerLeftPoint: {-180.00000406988,-90.0000129472464,0}
LowerRightPoint: {180.000014705583,-90.0000129472464,0}
UpperLeftPoint: {-180.00000406988,89.9999964404851,0}
UpperRightPoint: {180.000014705583,89.9999964404851,0}
Width: 360.0000187754631

ImageHeight = 5400

ImageWidth = 10800

Could you please shed some light on the behavior of the GetImage method, The API of that function describes only ArgumentOutOfRangeException, which is thrown in case of height or width being lower or equal to 0 but neither is true in this case, but the IndexOutOfRagneException never mentioned in the API.

To overcome this problem I’ve tried to modify the values of both the ImageBounds and ImageHeight and ImageWidth. In case of ImageBounds modifications, I’ve changed the value to:

ImageBounds = {-179,89.9999964404851,179,-89.9999964404851}
base: {-179,89.9999964404851,179,-89.9999964404851}
Height: 179.99999288097021
LowerLeftPoint: {-179,-89.9999964404851,0}
LowerRightPoint: {179,-89.9999964404851,0}
UpperLeftPoint: {-179,89.9999964404851,0}
UpperRightPoint: {179,89.9999964404851,0}
Width: 358.0

And no exception happened

In case of ImageHeight and ImageWidth I’ve tried to change the values to

ImageHeight = 5000
ImageWidth = 10000

and again no crash happened.
Those are just experimental arbitrary values, and the injection of these values were done seperatly, in other words, one execution with modifying only ImageBounds, and another separate execution with modifying only ImageHeight and ImageWidth (both ImageHeight and ImageWidth in single execution).

Now I’m not sure about the correlation between the world extent argument to the height and width of the GetImage method so I definitely can’t implement some normalization logic for the images, because the images might be whatever the user might load in the application. But this Image does create and reproduce this exception each time, therefore same situation might happen for other images as well and surely the application must be able to deal with such a matter.

can you please advice?

Hi Miri,

Thanks for reporting this issue and your research.

  • We have some fixes to RasterLayer, please reinstall Map Suite Unmanaged Dependencies 9.0.295.0.msi. and have a try again.
  • Sorry I cannot download your tif file, and failed to reproduce your issue with our testing data, Could you please update it to forumsupport@thinkgeo.com or ask sales@thinkgeo.com for a FTP address to upload, So that we can work based on it. (If there is a TFW file for the TIF file, please share it to us)
  • I think the IndexOutOfRagneException is unexpected, so we did not describes it.

If something misunderstood here, please provide more information.

Thanks,
Emil

Hi

I have loaded my picture to ftp on https://clients.thinkgeo.com:5001/webman/index.cgi , under file station .

File name is TrueMarble.4km.10800x5400.tif

Can you please check the problem against that file? (I tried to update the version as you segested but it did not halped)

Thank you

Hi Miri,

Thanks for sharing,

We need some time to test, any updates I will let you know(maybe tomorrow).

Thanks,
Emil

Hi miri,
I can’t reproduce this issue, I guess your MapSuite assemblies’ version is old, I’m working on the version 9.0.372.0, you can get it from “Product center”. The attached is the test sample, you can have a try.

WpfApplication16.zip (9.0 KB)

Thanks,

Hi
I have uploaded to FTP on https://clients.thinkgeo.com:5001/webman/index.cgi
a test sample (forumtest.zip) from your answer. It throws exception in
GeoImage sourceGeoImage = layer.ImageSource.GetImage(ImageBounds, ImageWidth, ImageHeight) like in previous version. Test is on version “Daily Full Production 9.0.0.387”.
The only difference is that I have inherit from the GeoTiffRasterLayer in order to expose property public RasterSource ImageSource to enable updating the internal image source when applying filter.

Please advice.
Thanks,
Miri

Hi Miri,

Thanks for your feedback, it turns out to be a bug which has been fixed. It should be available in version 9.0.399.0/9.0.0.400 or later. Please get it when it’s available to have a try again.

Any questions please let me know.

NOTE:
Please remember to upgrade the “UnmnagedDependencies” to version 9.0.295.0.

Thanks,
Peter

Hi Peter,

Thanks for your feedback. When the version 9.0.399.0/9.0.0.400 will be available? The current version in ThinkGeo Product Center is 9.0.0.379.
I am using the following “managed assemblies” ( “Daily Full Production 9.0.0.387”)
GeoAPI.dll
MapSuiteCore.dll
WpfDesktopEdition.dll
NetTopologySuite.dll

Please explain what is “UnmanagedDependencies” and where I can found them?

Thank you
Miri

Hi Miri,

The version version 9.0.399.0/9.0.0.400 is available now, please download it from Product Center.

“UnmanagedDependencies” provides functions for some layers, such as, RasterLayer, CAD FeatureLayer, FileGeoDatabase, etc. Usually, it will be installed when the daily build downloaded if there is corresponding UnmanagedDependencies available.

Please download the Map Suite Unmanaged Dependencies 9.0.295.0 from https://ap.thinkgeo.com:5001/sharing/oQ2rmNF5q

Thanks,
Peter