Skip to content

Commit

Permalink
Fix comments for pr
Browse files Browse the repository at this point in the history
  • Loading branch information
furstenheim committed Mar 27, 2018
1 parent 45618a9 commit a558ca4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions path.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,16 @@ func NewPathFromXYData(data [][2]float64) *Path {
}

// NewPathFromFlatXYData creates a path from a slice of float64 values
// representing horizontal, vertical type data, for example lng/lat values from geojson.
// representing horizontal, vertical type data.
// Coordinates in even positions correspond to X values. Coordinates in odd positions correspond to Y values
func NewPathFromFlatXYData(data []float64) *Path {
if (len(data) % 2 != 0) {
log.Fatal("Flat path requires an even number of coordinates")
if len(data)%2 != 0 {
panic("Flat path requires an even number of coordinates")
}
p := NewPathPreallocate(0, len(data) / 2)
p := NewPathPreallocate(0, len(data)/2)

for i := 0; i < len(data) / 2; i++ {
p.PointSet = append(p.PointSet, Point{data[2 * i], data[2 * i + 1]})
for i := 0; i < len(data)/2; i++ {
p.PointSet = append(p.PointSet, Point{data[2*i], data[2*i+1]})
}

return p
Expand Down
4 changes: 2 additions & 2 deletions path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ func TestNewPathFromFlatXYData(t *testing.T) {
}

p := NewPathFromFlatXYData(data)
if l := p.Length(); l != len(data) / 2 {
t.Errorf("path, should take full length of data, expected %d, got %d", len(data) / 2, l)
if l := p.Length(); l != len(data)/2 {
t.Errorf("path, should take full length of data, expected %d, got %d", len(data)/2, l)
}

if point := p.GetAt(0); !point.Equals(&Point{1, 2}) {
Expand Down

0 comments on commit a558ca4

Please sign in to comment.