Skip to content

Commit

Permalink
fix lastElement()
Browse files Browse the repository at this point in the history
  • Loading branch information
roelarents committed Dec 11, 2023
1 parent 5febca4 commit 41851a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion snap/snap.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ func kmpTable(find [][2]float64, table []int) {

func lastElement[T any](elements []T) *T {
length := len(elements)
if length > 1 {
if length > 0 {
return &elements[length-1]
}
return nil
Expand Down
14 changes: 12 additions & 2 deletions snap/snap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,26 @@ func Test_snapPolygon(t *testing.T) {
{69878.365, 445712.156},
{69879.413, 445710.912},
{69837.833, 445705.673},
{69840.279, 445755.872},
}},
want: map[tms20.TMID]geom.Polygon{5: {{
{69840.8, 445753.12},
{69840.8, 445753.12},
{69840.8, 445712.8},
{69881.12, 445712.8},
{69840.8, 445712.8},
}}},
},
{
name: "lines and points are filtered out (for now)",
tms: loadEmbeddedTileMatrixSet(t, "NetherlandsRDNewQuad"),
tmIDs: []tms20.TMID{0},
polygon: geom.Polygon{{
{90713.55, 530388.466},
{90741.04, 530328.675},
{90673.689, 530324.552},
{90664.068, 530379.532},
}},
want: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 41851a0

Please sign in to comment.