Skip to content

Commit 3766e6e

Browse files
committed
Fixing some more tests that failed
git-tfs-id: [https://tfs.codeplex.com/tfs/TFS01]$/SharpMap/Trunk;C98521
1 parent d8e22c4 commit 3766e6e

12 files changed

Lines changed: 44 additions & 20 deletions

File tree

SharpMap.Serialization/MapSerialization.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,17 @@ public static Map LoadMapFromStream(Stream s)
4545
cred = new NetworkCredential((l as WmsLayer).WmsUser, (l as WmsLayer).WmsPassword);
4646

4747
SharpMap.Layers.WmsLayer wmsl = new Layers.WmsLayer(l.Name, (l as WmsLayer).OnlineURL, TimeSpan.MaxValue, WebRequest.DefaultWebProxy, cred);
48-
string[] layers = (l as WmsLayer).WmsLayers.Split(',');
49-
foreach (var wl in layers)
48+
if ((l as WmsLayer).WmsLayers != null)
5049
{
51-
wmsl.AddLayer(wl);
50+
string[] layers = (l as WmsLayer).WmsLayers.Split(',');
51+
foreach (var wl in layers)
52+
{
53+
wmsl.AddLayer(wl);
54+
}
55+
}
56+
else
57+
{
58+
wmsl.AddChildLayers(wmsl.RootLayer,true);
5259
}
5360
lay = wmsl;
5461
}

SharpMap.Serialization/MapServerMapFileLoader.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using System.Drawing;
88
using SharpMap.Layers;
99
using System.Globalization;
10-
using System.Linq;
1110
using SharpMap.Styles;
1211
using GeoAPI.Geometries;
1312
namespace SharpMap.Serialization

SharpMap/Layers/Symbolizer/BaseVectorLayer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ protected virtual void OnRendering(Graphics graphics, Map map)
191191
//}
192192
foreach (var geometry in _geometries)
193193
{
194-
Symbolizer.Render(map, geometry as TGeometry, graphics);
194+
if (geometry != null)
195+
Symbolizer.Render(map, geometry as TGeometry, graphics);
195196
}
196197
Symbolizer.Symbolize(graphics, map);
197198
}

UnitTests/Data/Providers/ShapeFileProviderTests.cs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
namespace UnitTests.Data.Providers
1+
using System.IO;
2+
namespace UnitTests.Data.Providers
23
{
34

45
[NUnit.Framework.TestFixture]
@@ -23,19 +24,21 @@ public void TestFixtureTearDown()
2324
((double)_msLineal / _msVector * 100)));
2425
}
2526

26-
private const string ReallyBigShapeFile =
27-
//@"C:\Users\obe.IVV-AACHEN\Documents\vaglag\vaglag.shp";
28-
@"C:\temp\Data\niedersachsen.shp\roads.shp";
27+
28+
private string GetTestFile()
29+
{
30+
return Path.Combine(Path.GetDirectoryName(this.GetType().Assembly.CodeBase.Replace("file:///", "")), @"TestData\roads_ugl.shp");
31+
}
2932

3033
[NUnit.Framework.Test]
3134
public void TestPerformanceVectorLayer()
3235
{
33-
NUnit.Framework.Assert.IsTrue(System.IO.File.Exists(ReallyBigShapeFile),
36+
NUnit.Framework.Assert.IsTrue(System.IO.File.Exists(GetTestFile()),
3437
"Specified shapefile is not present!");
3538

3639
var map = new SharpMap.Map(new System.Drawing.Size(1024, 768));
3740

38-
var shp = new SharpMap.Data.Providers.ShapeFile(ReallyBigShapeFile, false, false);
41+
var shp = new SharpMap.Data.Providers.ShapeFile(GetTestFile(), false, false);
3942
var lyr = new SharpMap.Layers.VectorLayer("Roads", shp);
4043

4144
map.Layers.Add(lyr);
@@ -44,20 +47,20 @@ public void TestPerformanceVectorLayer()
4447
RepeatedRendering(map, shp.GetFeatureCount(), NumberOfRenderCycles, out _msVector);
4548

4649
var res = map.GetMap();
47-
var path = System.IO.Path.ChangeExtension(ReallyBigShapeFile, ".vector.png");
50+
var path = System.IO.Path.ChangeExtension(GetTestFile(), ".vector.png");
4851
res.Save(path, System.Drawing.Imaging.ImageFormat.Png);
4952
System.Console.WriteLine("\nResult saved at file://" + path.Replace('\\', '/'));
5053
}
5154

5255
[NUnit.Framework.Test]
5356
public void TestPerformanceLinealLayer()
5457
{
55-
NUnit.Framework.Assert.IsTrue(System.IO.File.Exists(ReallyBigShapeFile),
58+
NUnit.Framework.Assert.IsTrue(System.IO.File.Exists(GetTestFile()),
5659
"Specified shapefile is not present!");
5760

5861
var map = new SharpMap.Map(new System.Drawing.Size(1024, 768));
5962

60-
var shp = new SharpMap.Data.Providers.ShapeFile(ReallyBigShapeFile, false, false);
63+
var shp = new SharpMap.Data.Providers.ShapeFile(GetTestFile(), false, false);
6164
var lyr = new SharpMap.Layers.Symbolizer.LinealVectorLayer("Roads", shp)
6265
{
6366
Symbolizer =
@@ -75,7 +78,7 @@ public void TestPerformanceLinealLayer()
7578
RepeatedRendering(map, shp.GetFeatureCount(), 1, out tmp);
7679

7780
var res = map.GetMap();
78-
var path = System.IO.Path.ChangeExtension(ReallyBigShapeFile, "lineal.png");
81+
var path = System.IO.Path.ChangeExtension(GetTestFile(), "lineal.png");
7982
res.Save(path, System.Drawing.Imaging.ImageFormat.Png);
8083
System.Console.WriteLine("\nResult saved at file://" + path.Replace('\\', '/'));
8184
}
@@ -107,10 +110,10 @@ private static void RepeatedRendering(SharpMap.Map map, int numberOfFeatures, in
107110
[NUnit.Framework.Test]
108111
public void TestExecuteIntersectionQuery()
109112
{
110-
NUnit.Framework.Assert.IsTrue(System.IO.File.Exists(ReallyBigShapeFile),
113+
NUnit.Framework.Assert.IsTrue(System.IO.File.Exists(GetTestFile()),
111114
"Specified shapefile is not present!");
112115

113-
var shp = new SharpMap.Data.Providers.ShapeFile(ReallyBigShapeFile, false, false);
116+
var shp = new SharpMap.Data.Providers.ShapeFile(GetTestFile(), false, false);
114117
shp.Open();
115118

116119
var fds = new SharpMap.Data.FeatureDataSet();
@@ -144,10 +147,10 @@ public void TestExecuteIntersectionQuery()
144147
[NUnit.Framework.Test]
145148
public void TestExecuteIntersectionQueryWithFilterDelegate()
146149
{
147-
NUnit.Framework.Assert.IsTrue(System.IO.File.Exists(ReallyBigShapeFile),
150+
NUnit.Framework.Assert.IsTrue(System.IO.File.Exists(GetTestFile()),
148151
"Specified shapefile is not present!");
149152

150-
var shp = new SharpMap.Data.Providers.ShapeFile(ReallyBigShapeFile, false, false);
153+
var shp = new SharpMap.Data.Providers.ShapeFile(GetTestFile(), false, false);
151154
shp.Open();
152155

153156
var fds = new SharpMap.Data.FeatureDataSet();

UnitTests/Serialization/MapDocSerializationTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,21 @@ public void TestSerializeWmsLayerWithCredentials()
114114
SharpMap.Map m = new SharpMap.Map();
115115
SharpMap.Layers.WmsLayer l = new SharpMap.Layers.WmsLayer("testwms", "http://mapus.jpl.nasa.gov/wms.cgi?", TimeSpan.MaxValue,
116116
System.Net.WebRequest.DefaultWebProxy, new NetworkCredential("test", "pw"));
117+
l.AddChildLayers(l.RootLayer, false);
117118
m.Layers.Add(l);
118119
MemoryStream ms = new MemoryStream();
119120
SharpMap.Serialization.MapSerialization.SaveMapToStream(m, ms);
120121
string txt = System.Text.ASCIIEncoding.ASCII.GetString(ms.ToArray());
122+
Console.WriteLine(txt);
121123
Assert.IsTrue(txt.Contains(@"<Layers>
122124
<MapLayer xsi:type=""WmsLayer"">
123125
<Name>testwms</Name>
124126
<MinVisible>0</MinVisible>
125127
<MaxVisible>1.7976931348623157E+308</MaxVisible>
126128
<OnlineURL>http://mapus.jpl.nasa.gov/wms.cgi?</OnlineURL>
127-
<WmsLayers>global_mosaic,global_mosaic_base,us_landsat_wgs84,srtm_mag,daily_planet,daily_afternoon,BMNG,modis,huemapped_srtm,srtmplus,worldwind_dem,us_ned,us_elevation,us_colordem,gdem</WmsLayers>
128129
<WmsUser>test</WmsUser>
129130
<WmsPassword>pw</WmsPassword>
131+
<WmsLayers>global_mosaic,global_mosaic_base,us_landsat_wgs84,srtm_mag,daily_planet,daily_afternoon,BMNG,modis,huemapped_srtm,srtmplus,worldwind_dem,us_ned,us_elevation,us_colordem,gdem</WmsLayers>
130132
</MapLayer>
131133
</Layers>"));
132134
ms.Close();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="utf-8"?><ItemProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Properties><Property><Name>svn:mime-type</Name><Value>application/octet-stream</Value></Property></Properties></ItemProperties>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="utf-8"?><ItemProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Properties><Property><Name>svn:mime-type</Name><Value>application/octet-stream</Value></Property></Properties></ItemProperties>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="utf-8"?><ItemProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Properties><Property><Name>svn:mime-type</Name><Value>application/octet-stream</Value></Property></Properties></ItemProperties>

UnitTests/TestData/roads_ugl.dbf

408 KB
Binary file not shown.

UnitTests/TestData/roads_ugl.shp

3.15 MB
Binary file not shown.

0 commit comments

Comments
 (0)