Skip to content

Commit 69086a2

Browse files
committed
Ensure that Z/M ordinates of 3D/4D PostGIS geometries are saved to the database
1 parent 47aa8a5 commit 69086a2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

NHibernate.Spatial.PostGis/Type/PostGisGeometryType.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,15 @@ protected override byte[] FromGeometry(object value)
6666

6767
// Determine the ordinality of the geometry to ensure 3D and 4D geometries are
6868
// correctly serialized by PostGisWriter (see issue #66)
69+
// NOTE: Cannot use InteriorPoint here as that always returns a 2D point (see #120)
6970
// TODO: Is there a way of getting the ordinates directly from the geometry?
7071
var ordinates = Ordinates.XY;
71-
var interiorPoint = geometry.InteriorPoint;
72-
if (!interiorPoint.IsEmpty && !double.IsNaN(interiorPoint.Z))
72+
var coordinate = geometry.Coordinate;
73+
if (coordinate != null && !double.IsNaN(coordinate.Z))
7374
{
7475
ordinates |= Ordinates.Z;
7576
}
76-
if (!interiorPoint.IsEmpty && !double.IsNaN(interiorPoint.M))
77+
if (coordinate != null && !double.IsNaN(coordinate.M))
7778
{
7879
ordinates |= Ordinates.M;
7980
}

0 commit comments

Comments
 (0)