Hello,
Is there a way to display a geotiff image in the gis module using a byte[] or a stream instead of specifying the filepath of the geotiff?
Sebastien
Hello,
Is there a way to display a geotiff image in the gis module using a byte[] or a stream instead of specifying the filepath of the geotiff?
Sebastien
Sebastien,
If you are using GeoTiffRasterSource, we would use a 3rd part assembly for rendering a geotiff image and that assembly doesn’t support Stream loading, so I’m afraid we cannot do too much about it.
If you open a tiff using GDIPlusRasterSource though, you can load it from a byte[] or a stream with the help of event “StreamLoading”, we have a sample (Data Provider->LoadAMpaFromStream) for it please have a look.
Let me know if you have any issues about it.
Thanks,
Ben
if i understand well, i can load a GEOTiff with GdiPlusRasterLayer, for this we have to set the file path name of the tiff and we have to have the tfw file in the same folder. But how to set the tfw path (or stream ideally) when using the method you provided?
Hi Sebastien,
You are right that can load GEOTiff with GdiPlusRasterLayer. When you load GEOTiff, we’ll raise stream loading event twice to load both *.tiff and *.tfw.
Please see the code below, if you have any questions please let me know.private void LoadAMapFromStreams_StreamLoading(object sender, StreamLoadingEventArgs e)
{
string extension = Path.GetExtension(e.AlternateStreamName);
switch (extension.ToUpper())
{
case "TIFF":
e.AlternateStream = new FileStream("TIFF_File_Path", FileMode.Open);
break;
case "TFW":
e.AlternateStream = new FileStream("TFW_File_Path", FileMode.Open);
break;
default: break;
}
}
Thanks,
Howard
do you have a sample to load streams, i can not make it work ? i would like to load a png and a pgw as well.
Sebastien,
I guess, you didn't hang up the event, In my last, I just pasted the event, but didn't paste the code for hook it up. May be if you add the following code in the PageLoad function, it'll be fine. Also, you can set a break point and see whether this event is raised.
((ShapeFileFeatureSource)shapeFileLayer.FeatureSource).StreamLoading += new EventHandler<StreamLoadingEventArgs>(LoadAMapFromStreams_StreamLoading);
We have an installed sample at "Samples/DataProviders/LoadAMapFromStreams.aspx", but it loads from ShapeFile.
If you have any questions please let me know.
Thanks,
Howard
Hello,
I try what you ve said, but i am still struggling to make it work.
I enclosed my source code and the images i try to display.
1) when i set the background as a GoogleOverlay the StreamLoading is not fired anymore.
2) the example i developped dont use custom layers, is it possible to use custom layers with loading streams?
3) when i try to load a png image, i have a blue map displayed with the error "illegal characters in path"
Thanks in advance,
Sebastien
Hi sebastien,
I found there are some issues caused your issue; let’s review them one by one.
1. In the event “LoadAMapFromStreams_StreamLoading”, you initialize a new FileStream but it’s not readonly and not closed. I just make it readonly.
2. In your sample, you commended out the current extent.
3. e.AlternateStreamName should be set.
4. BackgroundOverlay and StaticOverlay are base overlays; we don’t allow user to use two base overlay at the same time. So it automatically hide the StaticOverlay.
It works fine now, please change the file path you are using to the correct one.
Any questions please let me know.
Thanks,
Howard
870-LoadStreamInMemoryLayer.aspx.cs (5.2 KB)
thats great, it works perfectly as i expected. I must say your support is high quality.
Though it would be very interesting for a developper point of view to have a base knowledge of all we can do with your gis module, the sample you provide shows only basic features. What i mean is, throughout the forum you post bit of source code, and if it would be great to gather them and make them available in page grouped by theme. Developpers could upload their code to share their work to the comunity. (i am a telerik developper and i appriciate what they ve done in terms of support)
Well thats just a general idea, i know it s time consuming.
sebastien
Sebastien
Thank you for your affirmation of my work.
Your suggestion is pretty good; like some scenario categories. we have written it down and will carefully discuss it.
Please feel free to let me know if you have more questions.
Thanks,
Howard