-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathPostGis20ConformanceItemsFixture.cs
100 lines (85 loc) · 3.07 KB
/
PostGis20ConformanceItemsFixture.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using System.Linq;
using NetTopologySuite.Geometries;
using NHibernate.Cfg;
using NUnit.Framework;
using Tests.NHibernate.Spatial.OgcSfSql11Compliance;
using Tests.NHibernate.Spatial.OgcSfSql11Compliance.Model;
namespace Tests.NHibernate.Spatial
{
[TestFixture]
public class PostGis20ConformanceItemsFixture : ConformanceItemsFixture
{
/// <summary>
/// Overridden because GeometryType includes ISO prefix in PostGIS
/// </summary>
[Test]
public override void ConformanceItemT07Hql()
{
string query =
@"select NHSP.GeometryType(t.Centerlines)
from DividedRoute t
where t.Name = 'Route 75'
";
string result = session.CreateQuery(query)
.UniqueResult<string>();
Assert.AreEqual("ST_MULTILINESTRING", result.ToUpper());
}
[Test]
public override void ConformanceItemT07Linq()
{
var query =
from t in session.Query<DividedRoute>()
where t.Name == "Route 75"
select t.Centerlines.GeometryType;
string result = query.Single();
Assert.AreEqual("ST_MULTILINESTRING", result.ToUpper());
}
/// <summary>
/// Overridden because GetPointN is not zero-based in PostGIS
/// </summary>
[Test]
public override void ConformanceItemT23Linq()
{
var query =
from t in session.Query<RoadSegment>()
where t.Fid == 102
select ((LineString) t.Centerline)
.GetPointN(1);
Geometry geometry = query.Single();
var expected = Wkt.Read("POINT( 0 18 )");
Assert.IsTrue(expected.EqualsTopologically(geometry));
}
/// <summary>
/// Overridden because GetInteriorRingN is not zero-based in PostGIS
/// </summary>
[Test]
public override void ConformanceItemT29Linq()
{
var query =
from t in session.Query<Lake>()
where t.Name == "Blue Lake"
select ((Polygon) t.Shore).GetInteriorRingN(1);
Geometry geometry = query.Single();
var expected = Wkt.Read("LINESTRING(59 18, 67 18, 67 13, 59 13, 59 18)");
Assert.IsTrue(expected.EqualsTopologically(geometry));
}
/// <summary>
/// Overridden because GetGeometryN is not zero-based in PostGIS
/// </summary>
[Test]
public override void ConformanceItemT31Linq()
{
var query =
from t in session.Query<DividedRoute>()
where t.Name == "Route 75"
select t.Centerlines.GetGeometryN(2);
var geometry = query.Single();
var expected = Wkt.Read("LINESTRING( 16 0, 16 23, 16 48 )");
Assert.IsTrue(expected.EqualsTopologically(geometry));
}
protected override void Configure(Configuration configuration)
{
TestConfiguration.Configure(configuration);
}
}
}