Closed gertcuykens closed 6 years ago
Good idea IMHO.
But why the shape type parameter for shp.Append()
? Wouldn't the shape type be given by the existing file already? Or is your idea to have Append
check and return an error
if the type in the call to Append
and the one in segments.shp
do not match?
yep you are 100% correct, sorry forgot about that :D
So it would be
shape, err := shp.Append("static-segments/segments.shp")
No type checking just the same Error handling as shp.Open
does
@gertcuykens, @tdilo I invite you to test and review https://github.com/fawick/go-shp/tree/addAppend
Any specific reason not to recycle err instead of er?
er := &errReader{Reader: shp}
w.bbox.MinX = readFloat64(er)
w.bbox.MinY = readFloat64(er)
w.bbox.MaxX = readFloat64(er)
w.bbox.MaxY = readFloat64(er)
if er.e != nil {
return nil, fmt.Errorf("cannot read bounding box: %v", err)
}
The reason is that readFloat64 does not return an error by itself. The errReader allow to check whether should could actually be read from in these four calls.to readFloat64.
On November 17, 2017 9:41:27 PM GMT+01:00, Gert Cuykens notifications@github.com wrote:
Any specific reason not to recycle err instead of er?
er := &errReader{Reader: shp} w.bbox.MinX = readFloat64(er) w.bbox.MinY = readFloat64(er) w.bbox.MaxX = readFloat64(er) w.bbox.MaxY = readFloat64(er) if er.e != nil { return nil, fmt.Errorf("cannot read bounding box: %v", err) }
-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/jonas-p/go-shp/issues/7#issuecomment-345359791
Ok i see maybe the last line should be
return nil, fmt.Errorf("cannot read bounding box: %v", er.e)
then ?
Yes, you're absolutely right, thank you, good catch! Fixed.
Hi Jonas, as far as I understand, we can open a shapefile or create one but not append to one
Can we have a
shape, err := shp.Append("static-segments/segments.shp", shp.MULTIPOINT)
?Thanks