diff --git a/geom/dump_coordinates_test.go b/geom/dump_coordinates_test.go index c67d3f81..9ef255e7 100644 --- a/geom/dump_coordinates_test.go +++ b/geom/dump_coordinates_test.go @@ -52,6 +52,11 @@ func TestDumpCoordinatesMultiPoint(t *testing.T) { inputWKT: "MULTIPOINT ZM(3 4 5 6)", want: NewSequence([]float64{3, 4, 5, 6}, DimXYZM), }, + { + description: "reproduce bug", + inputWKT: "MULTIPOINT Z(3 4 5,6 7 8)", + want: NewSequence([]float64{3, 4, 5, 6, 7, 8}, DimXYZ), + }, } { t.Run(tc.description, func(t *testing.T) { got := geomFromWKT(t, tc.inputWKT).AsMultiPoint().DumpCoordinates() diff --git a/geom/type_multi_point.go b/geom/type_multi_point.go index 23e2fe59..ad0ea10a 100644 --- a/geom/type_multi_point.go +++ b/geom/type_multi_point.go @@ -298,16 +298,17 @@ func (m MultiPoint) Dump() []Point { // DumpCoordinates returns the non-empty points in a MultiPoint represented as // a Sequence. func (m MultiPoint) DumpCoordinates() Sequence { + ctype := m.CoordinatesType() n := m.seq.Length() empty := m.empty.CountTrue() - nonEmpty := make([]float64, 0, n-empty) + nonEmpty := make([]float64, 0, ctype.Dimension()*(n-empty)) for i := 0; i < n; i++ { if m.empty.Get(i) { continue } nonEmpty = m.seq.Get(i).appendFloat64s(nonEmpty) } - seq := NewSequence(nonEmpty, m.seq.CoordinatesType()) + seq := NewSequence(nonEmpty, ctype) seq.assertNoUnusedCapacity() return seq }