ThinkGeo.com    |     Documentation    |     Premium Support

White line where the pictures come together in MultiGeorasterlayer

 


Hello,


we display raster data with our own layer based on your "MultiGeorasterLayer" sample.


Sometimes when I zoom in or change extent of the map by panning to another position the map seems not to be drawn correct.


As you can see on the picture there is a white line where the pictures come together. If I change extent e.g. I pan a little bit to the left the line dissapears. If I pan back the line comes back.


Any ideas?


 




Thomas, 
  
 I have reviewed the code of "MultiGeorasterLayer" sample. I think if you want to use that way, it has precision problem when translate world extent to screen extent, because world extent uses double, screen extent uses integer 
  
 If you want to avoid white line, you need draw screen image manually instead of using layer draw. 
  
 You can use the API DrawScreenImage(GeoImage image, float centerXInScreen, float centerYInScreen, float widthInScreen, float heightInScreen, DrawingLevel drawingLevel, float xOffset, float yOffset, float rotateAngle) 
  
 You can calculate every parameter by yourself that can fix the precision problem.  
  
 Please let me know if you have questions 
  
 Thanks 
 James 


Hello James,


I have implemented DrawScreenImage. But it seems not to work. I still can see the white line (sample.png) and if I zoom in this time the white lines get bigger  (sampleZoomIn.png).




I have attached my code I try to paint the image!



1490-SampleCode.vb (2.06 KB)

 


Thomas,
 
I have written a DrawCore code which can work properly.
 
My idea is that you can look at following steps:
1.       Get drawing images by spatialIndex.Query.
2.       Calculate the entire extent which contains all drawing images.
3.       Merge these images to a big image by entire extent.
At this time, the big image has no white line because the small images are still in the original scale, no precision problem.
4.       Scale big image which can fit the canvas.
5.       Draw scaled big image to canvas.
 
Thanks
 
James 

1496-DrawCore.zip (2.71 KB)

Thomas, 
  
   The issue it seems is that there may be some rounding issues when calculating the scales bounding boxes.  When we go from the world rectangles then scale them up and then convert them to pixels there is the possibility that there would be a one pixel gap due to the fact that the resolution of world coordinates are much finer than the screen coordinates which are floats.  We see this from time to time, I will see what we can do and maybe we can round up or do some kind of one pixel overlap to fill the gap. 
  
 David

Thomas, 
  
   Quick question.  Are you drawing GeoTiffs?  Also where specifically did you get the "MultiGeorasterLayer" code from?  I just want to make sure because if you are using GeoTiffs you can update the code a bit and get a big performance increase.  This is not related to the gap though. 
  
 David

Hello James/David, 
  
 James - Thanks for your sample code. I will try to test it within the next days. 
  
 David - The images we draw are worlfiles in Tiff-Format. The "MultiGeorasterLayer" code is from your "ExtendingMapSuiteExploringLayers" project your presented in an webinar. I hope there will be some more webinars in the future. 
  
 Thomas 


Thomas, 
  
 You’re welcome. 
  
 Please let me know the result after you test. 
  
 James

Thomas, 
  
   I think we know the source of the problem and are working on a solution. 
  
 David

Hello David,


How about the solution you mentioned? Are there any new results?


Thomas



Thomas, 
  
 Thanks for your post. 
  
 Recently, I have discussed this problem with David, and he came out some solutions. We will try them as soon as possible. 
  
 Besides, I worked with James out one solution, did you tried that? Basically this solution should can solve your problem; it will first merge a bitmap without any while line and then use it zoom in or zoom out to match the control. Can you try this? 
  
 Thanks. 
  
 Yale 


Thomas,


Thank you for your post!


Have you try my solution before? If you did, please let me know the result.


And I also write the code for David's solution that is making 2 pixels larger for each tile. You can try it which I attached. Please let me know if there is any different result.


Thanks


James



1541-David's_Solution.zip (1.33 KB)

Hello James, 
  
 I have implemeted David’s solution and it works fine. 
  
 Thanks for help!

Thomas, 
  
 It’s awesome. 
  
 So how about the solution of mine which send to you at 11-24-2009 01:08 AM?  
  
 Thanks 
 James

Hello James, 
  
 sorry but Davids code was easy to implement so I decided to use it. 
 I do not want to try your code because it works now and I have many other points to realize. 
  
 Thanks 
 Thomas

Guys, 
  
   While I am flattered you named this solution after me it isn’t exactly what needs to be done to properly fix the issue.  The problem is that rounding can cause the images to be, in some cases, smaller or larger than normal.  While adding two to the height and width will make things look good I think we can do better.  I suggested that we consider the rounding of the X & Y depending on their location and adjust values.  It is a little complex to get into here but I think we can make a fix in the RasterSource and RasterLayer base class to fix all the instances of this issue.   
  
   For now enjoy the code that was posted.  We will continue to work on the real solution behind the scenes. 
  
 David

Hello David, 
  
 I reopen this thread again because I tested it today with Desktop Edition 4.0.40.44 and I still can see those white lines. How about the real solution you mentioned above. 
  
 Thomas

Thomas, this post is a long history now:).


I read through the thread and as far as I understand, this should be an issue when we implement a customized layer MultiGeorasterLayer, which is already a code sample in our code gallery. 

code.thinkgeo.com/projects/show/11


And James told me that this issue can be definitely fixed by his solution pasted on “11-24-2009 01:08 AM “, did you have a chance to have a try that. At last, it would be nice and it will of course make better communication if a small sample to show this problem can be made.


Feel free to let me know if I misunderstood anything.


Any more questions just feel free to let me know.


Thanks.


Yale

 



OK Yale, 
  
 i will try James solution and come back if I have any more questions. 
  
 Thomas

Thomas, 
  
 Thanks for your update and feel free to let me know if any results. 
  
 Thanks. 
  
 Yale