Hi Guys,
Why do the WpfMap zoomLevel scales change when you run the control with MapUnit set to Meters?. The table below shows the change that occurs, which scale is right the WpfMap or the shape file? This behaviour is not evident when running in DecimalDegrees, both the WpfMap and the shape scales agree (WpfMap scales are the same as the shape layer).
This change is small but is enough to cause us severe problems when using caching and the higher zoom levels where millions of tiles can get generated needlessly.
ZoomLevel
WpfMap
Shape File
1
591,658,710.90
590,591,790.00
2
295,829,355.45
295,295,895.00
3
147,914,677.73
147,647,947.50
4
73,957,338.86
73,823,973.75
5
36,978,669.43
36,911,986.88
6
18,489,334.72
18,455,993.44
7
9,244,667.36
9,227,996.72
8
4,622,333.68
4,613,998.36
9
2,311,166.84
2,306,999.18
10
1,155,583.42
1,153,499.59
11
577,791.71
576,749.79
12
288,895.85
288,374.90
13
144,447.93
144,187.45
14
72,223.96
72,093.72
15
36,111.98
36,046.86
16
18,055.99
18,023.43
17
9,028.00
9,011.72
18
4,514.00
4,505.86
19
2,257.00
2,252.93
20
1,128.50
1,126.46
Regards
John
Zoomlevel Scales and Meters
Hi John,
Thanks for your post, actually when we render the map, the scale that takes effect is the one from WpfMap rather ShapeFile. The zoomlevelset for shapefile is basicly used to set the layer’s style.
if you have any more question , please feel free to let us know.
Best Regards
Summer
Hi Summer,
Thanks for that, I kind of guessed that the layer zoomlevels were only used for styles.
There is still a problem with zoomlevels when the map unit is meters, caching is used and you zoom in and out using the mouse wheel. As zoomlevel snapping is implicit in the wpf control one would expect that the scales would match as you zoom in and out. They do not. Zoomlveles below 7 are generally fine and nearly always match however as you go higher and start zooming and panning the map, the map scale, as reported by the CurrentScaleChanged event, will often differ from the zoomlevel scale of the control.
Whilst the actual difference is sometimes small it can under certain circumstances trigger the creation of another folder in cache structure where the control starts writing a whole new bunch of tiles.
After running our application for sometime we note that there are 3 folders in the cache one exactly matching the scale of zoomlevel14, the other two are very close, one above and one below. At zoomlevel14 for a world map each of these folders would contain 40,112,496 tiles!
At higher zoomlevels the problem gets exponentially worse.
Running the program with the mapunit set to degrees exhibits none of these problems and is rock solid.
Unfortunately we must use a Mercator projection which forces the use of meters. We want to generate tiles up to and including zoomlevel 14, this process will take some days to complete as the source used to produce the tiles is slow, the data changes weekly forcing us to regenerate weekly. What we want to ensure is that we generate one map cache that is effectively read-only up to zoomlevel14. Currently with 7.0 this is not possible as scales are not stable enough
The code below is our current comparison function:-
private void WpfMapCurrentScaleChanged(object sender, CurrentScaleChangedWpfMapEventArgs e)
{
var zlNum = 1;
foreach (var zl in WpfMap.ZoomLevelSet.GetZoomLevels())
{
if (Math.Abs(zl.Scale - e.CurrentScale) < Double.Epsilon)
{
StatusBarMessage.Text = zlNum.ToString(CultureInfo.InvariantCulture);
return;
}
zlNum++;
}
MessageBox.Show("Zoomlevel not found");
}
Any thoughts?
Regards
John
Hi John,
Thanks for your detail, actually in MapSuite if scaleA has already had a cache folder, then if (Math.Abs(scale - targetDirectoryScale) < 1e-4), we will not create a cache folder for scaleB. Would you please check if the D-Value of these three folders’ corresponding scalse metioned in your previous post are within 1e-4.
If not, would you please provide us some of your code and data for a further test, if possible, a self-contained sample will be highly appreciated.
If yes, would you please tell us your dll versions or upload your dlls for us to test?
Waiting for your further information.
Summer
Hi John,
Thanks for your detail, actually in MapSuite if scaleA has already had a cache folder, then if (Math.Abs(scale - targetDirectoryScale) < 1e-4), we will not create a cache folder for scaleB. Would you please check if the D-Value of these three folders’ corresponding scalse metioned in your previous post are within 1e-4.
If not, would you please provide us some of your code and data for a further test, if possible, a self-contained sample will be highly appreciated.
If yes, would you please tell us your dll versions or upload your dlls for us to test?
Waiting for your further information.
Summer
Hi Summer,
Providing you with code and data is not going to be possible, the project is huge and the data is protected by dongles. I can confirm the D-levels we see are mostly within 1e-4 but on occasions exceed this value hence the creation of additional folders.
Shown below you will see a directory listing of the current cache in our application, you can clearly see the two additional folders surrounding the 72223.9600000001 folder. Both are well outside 1e-4
19/09/2013 08:44 DIR 1128.50000000002
19/09/2013 08:44 DIR
1155583.42
19/09/2013 08:45 DIR
144447.93
19/09/2013 08:41 DIR
147914677.73
19/09/2013 08:45 DIR
18055.99
19/09/2013 08:44 DIR
18489334.72
19/09/2013 08:42 DIR
2257.00000000005
19/09/2013 08:43 DIR
2311166.84
19/09/2013 08:44 DIR
288895.85
19/09/2013 08:43 DIR
295829355.45
19/09/2013 08:45 DIR
36111.98
19/09/2013 08:44 DIR
36978669.43
19/09/2013 08:42 DIR
4514.00000000009
19/09/2013 08:44 DIR
4622333.68
19/09/2013 08:45 DIR
577791.71
19/09/2013 08:41 DIR
591658710.9
19/09/2013 08:47 DIR
72221.15
19/09/2013 08:45 DIR
72223.9600000001
19/09/2013 08:46 DIR
72224.2500000001
19/09/2013 08:43 DIR
73957338.86
19/09/2013 08:42 DIR
9027.99999999997
19/09/2013 08:44 DIR
9244667.36
The problem of the scale reported by the CurrentZoomLevelChanged event not matching the control zoomlevel scales is demonstrable by tweaking your sample application.
We are running with the 7.0 production Dlls (version 7.0.0.0), screen size is 2560 x 1600.
I would still like an explanation as to why scales always match when using Degrees but don’t always match when using Meters.
Regards
John
Hi John,
Thanks for your further informaiton. It’s very strange that it would generate 3 different but very close values for zoomlevel 14, as you cannot provide the code, attahced is my code to test. I zoomed in and out for a while, and the folders’ names in the cache folder look like below.
You can see there is no any similar values for 1 zoomlevel. Could you please confirm if there is anything different between my code and yours?
Waiting for your further information.
Summer
post11526.txt (873 Bytes)