ThinkGeo.com    |     Documentation    |     Premium Support

Scale changes if I change the size of the control

 


I set this value when I start the application


 


 



winformsMap1.MapResizeMode =



MapResizeMode.PreserveScale;

On the  OnSizeChanged This changes winformsMap1.CurrentScale


I call 

winformsMap1.Height = e.NewSize.Height;


winformsMap1.Width = e.NewSize.Width;


 


 I use a Jp2 image map for my background and this alteration messes up performance beause I have to set it back to a scale that matches my precreated TILE zoom level.


 


 

 




Bob,


Thanks for your post. I am not quite sure about your problem. Is it the same problem mentioned in following post?
gis.thinkgeo.com/Support/Dis...fault.aspx
 
Could you send me a small sample application to recreate your problem? Sorry for the inconvenience.
 
Any more questions just feel free to let me know.
 
Thanks.
 
Yale

I have to make one. I sent a map file to you guys a long time ago but they they are big and we have firewall issues here.  
 See what I can do…

Bob, 
  
 Sorry for the inconvenience and looking forward to your code. 
  
 Thanks. 
  
 Yale 


Yale just wondering where this is at.  Cache performance is vital and the control is making up its own cache folders because it is not minding the CurrentScale Value. (far as I can tell) I have tried different options to stop this from occuring but they all do nothing. We have a test on a lower powered machine where this becomes an issue so if you can take a peak at the source I sent and if you need me to I will send more.



Bob, 
 Please check your FTP account for an updated sample from Yale.

OK Ryan I will when I can. I cant get FTP from work (firewall) but I will get it later today.  


Bob, 
  
 Thanks for letting me know the status. 
  
 Any more questions just feel free to let me know. 
  
 Thanks. 
  
 Yale 


Yale, I dont really understand the comment in the code. 



"The issue for me is the very minor difference between the two scales" This is my issue. It causes the creation of new folders and that drastically slows the application down. Its the reason you create an image cache with names like 2251.99878392066 while I have a precreated cache folder of 2252. I have tried the snap to ZoomLevelSnappingMode.SnapUp or Default. 

It did nothing far as I can tell. What is it snapping to? 

I altered the default zoom scale values. So what value is it going after? 

When I execute this it tells it to PreserveScale. What does that flag do? It seems like nothing at all. 



ExtentHelper.ResizeExtent(winformsMap1.CurrentExtent, previousWidth, (float)Width, (float)Height, winformsMap1.MapUnit, MapResizeMode.PreserveScale); 



Long story short I precreate an image cache for performance. The application creating these images hinder performance and make the application very slugish. HOW do I resize the control to fit the window without effecting the Scale so I can use the precreated cache? 

Its important as we try and test on a small low powered unit.


Thanks.. Sorry if I sound frustrated lack of sleep I guess. You guys are doing great.



Just and adendum I tired this piece of code and what do you know the resizedScale is still not a memeber of winformsMap1.ZoomLevelSet  
 It seems it doesnt care what values I set for scale at all.  
  
 RectangleShape resizedExtent = ExtentHelper.SnapToZoomLevel(winformsMap1.CurrentExtent, winformsMap1.MapUnit, (float)winformsMap1.Width, (float)winformsMap1.Height, winformsMap1.ZoomLevelSet); 
     double resizedScale = ExtentHelper.GetScale(resizedExtent, (float)winformsMap1.Width, winformsMap1.MapUnit); 
      


I found a small fix but not a total fix yet. Here is what I have found.  
  
 1) I have to fill in all 20 zoom levels. This allows me to set the winformsMap1.CurrentScale to one of the Zooms levels I have created. 
  
 2) It still creates folders with fractional values and a lot of time is wasted creating these images in the cache folder.  
 A folder like this still gets created. 36045.9805351705  
  
 3) After reset the CurrentScale back to 36046 it will not acces that folder and worked from the precreated folder.  
  
 Fix or tell me how to work around… Please…  The disk space on this small system is critical and speed is as well.  


I am pretty convinced that ExtentHelper.GetScale(resizedExtent, (float)winformsMap1.Width, winformsMap1.MapUnit) fractional error

is causing an issue. It seems to return scale values that are not within the winformsMap1.ZoomLevelSet no matter what flag I set.This causes the control to create a folder and sub images which are not precreated or in the cache set and messes up performance.


This makes a precreated image cache totally useless. I have another jpeg sattelite image which makes the probelm even worse.  It wont even snap to the cache scale values.  Need help or a fix for the performance.



Bob,


Sorry for the misunderstanding of you previous post.
 
You code seems related with a lot of C++ code, which some of them I cannot fully understand, for example, why you call the WndProc to rewrite the Size-changed event? I will spend some time to investigate your code.
 
During this, could you have a test based on following very simple code to see if this problem still exists, here just replace your data folder in the first statement?

private void DisplaySatelliteImage_Load(object sender, EventArgs e)
        {
            string dataFolder = @"yourdataFolder here";
 
            winformsMap1.MapUnit = GeographyUnit.Meter;
            //winformsMap1.CurrentExtent = new RectangleShape(-118.098, 84.3, 118.098, -84.3);
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
 
            Jpeg2000RasterLayer jpeg2000RasterLayer = new Jpeg2000RasterLayer(dataFolder + @"\MemphisHub.jp2");
            jpeg2000RasterLayer.UpperThreshold = double.MaxValue;
            jpeg2000RasterLayer.LowerThreshold = 0;
 
            LayerOverlay ImageOverlay = new LayerOverlay();
 
            string cacheFolder = dataFolder + @"\CacheFolder";
            ImageOverlay.TileCache = new FileBitmapTileCache(cacheFolder,string.Empty);
 
            ImageOverlay.Layers.Add("EcwImageLayer", jpeg2000RasterLayer);
            winformsMap1.Overlays.Add(ImageOverlay);
 
            jpeg2000RasterLayer.Open();
            winformsMap1.CurrentExtent = jpeg2000RasterLayer.GetBoundingBox();
            jpeg2000RasterLayer.Close();
 
            winformsMap1.Refresh();
        }


 
Any more questions just feel free to let me know.
 
Thanks.
 
Yale

Bob, 
  
 I am sorry to say that I did not test against the size change in my previous post. I will do more test and let you know the result as soon as possible. 
  
 Thanks. 
  
 Yale

why you call the WndProc to rewrite the Size-changed event? >>>> Because you get only one when the window is finished resizing in WPF. Otherwise you get them continually while the Window is being re-sized. This effects performance drastically.

Check the function LoadTiles that should be what you sent with different ZoomLevels being sent. If I use your code above I have no control over the zoomlevel cache which was the point of setting them. Also the ZoomLevels had to be adjusted from the original 20 because it was too small to start with.

Let me know when you can get chance to see this,

Bob, 
  
    I just wanted to thank you for putting into words what we have been experiencing for a while now.  I assumed that I was incorrectly using the cache since we would consistently see new files created instead of using the pregenerated ones.  I am very interested in the details of the fix/work around.  I still don’t put it past me doing something incorrect, but in light of this post I do feel better about my experience.  We are using wpf sliding panels to display/hide different information and it was killing our performance each time we opened and collapsed the panel. 
  
 Jake

Bob & Jake, 
  
 We have fixed this problem and it should be ready in the comming public release. 
  
 Thanks for your patience and input, Bob, I appricate it very much. 
  
 Thanks. 
  
 Yale

THANK YOU YALE !!!   
 FYI I think this is broken in the C# version as well? Wil the fix fix both?  
  
 And now that you are done with my needs hurry up with the speed ups for WPF :-),   
 A programmers work is never done…  
 Thanks again.