# README
yxdb-go
yxdb is a package for reading YXDB files into Go applications. Install it using:
go get github.com/tlarsendataguy-yxdb/yxdb-go
The library does not have external dependencies.
The public API is contained in the YxdbReader interface. Instantiate a YxdbReader using one of the two functions:
ReadFile(String)
- load from a fileReadStream(io.ReadCloser)
- load from a reader
Iterate through the records in the file using the Next()
method in a for loop:
for reader.Next() {
// do something
}
Fields can be access via the ReadXxxWithName()
and ReadXxxWithIndex()
methods on YxdbReader. There are readers for each kind of data field supported by YXDB files:
ReadByteWithX()
- read Byte fieldsReadBlobWithX()
- read Blob and SpatialObj fieldsReadBooleanWithX()
- read Bool fieldsReadTimeWithX()
- read Date and DateTime fieldsReadFloat64WithX()
- read FixedDecimal, Float, and Double fieldsReadInt64WithX()
- read Int16, Int32, and Int64 fieldsReadStringWithX()
- read String, WString, V_String, and V_WString fields
The WithName()
methods read a field by its name. The WithIndex()
methods read a field by its index in the file.
If either the index number or field name is invalid, the application will panic.
To read spatial objects, use the ToGeoJSON()
function located in yxdb/spatial
. The ToGeoJSON()
function translates the binary SpatialObj format into a GeoJSON string.