Go package to implement the whosonfirst/go-whosonfirst-spr
interface for "standard places result" (SPR) data stored in a SQLite database that has been indexed using the whosonfirst/go-whosonfirst-sqlite-features
package.
go-whosonfirst-sqlite-spr
is a Go package to implement the whosonfirst/go-whosonfirst-spr
interface for "standard places result" (SPR) data stored in a SQLite database, specifically data stored in an spr
table as indexed by the go-whosonfirst-sqlite-features
package.
This package exposes a single public method called RetrieveSPR
that retrieves a row from a spr
table in a SQLite database and returns it as an instance that implements the go-whosonfirst-spr.SPR
interface.
The method signature is:
func RetrieveSPR(context.Context, database.SQLiteDatabase, sqlite.Table, int64, string) (spr.StandardPlacesResult, error)
For example:
import (
"context"
"database/sql"
_ "github.com/mattn/go-sqlite3"
"github.com/whosonfirst/go-whosonfirst-database/sql/tables"
"github.com/whosonfirst/go-whosonfirst-sqlite-spr/v2"
)
ctx := context.Background()
db, _ := sql.Open("sqlite3", "test.db")
spr_table, _ := tables.NewSPRTableWithDatabase(db)
id := 1234
alt_label := ""
spr_r, _ := spr.RetrieveSPR(ctx, db, spr_table, id, alt_label)
Error handling omitted for the sake of brevity.
The spr_r
instance returned will have the type SQLiteStandardPlacesResult
and implements all of the spr.StandardPlacesResult
methods. Under the hood it looks like this:
type SQLiteStandardPlacesResult struct {
spr.StandardPlacesResult `json:",omitempty"`
WOFId string `json:"wof:id"`
WOFParentId string `json:"wof:parent_id"`
WOFName string `json:"wof:name"`
WOFCountry string `json:"wof:country"`
WOFPlacetype string `json:"wof:placetype"`
MZLatitude float64 `json:"mz:latitude"`
MZLongitude float64 `json:"mz:longitude"`
MZMinLatitude float64 `json:"mz:min_latitude"`
MZMinLongitude float64 `json:"mz:min_longitude"`
MZMaxLatitude float64 `json:"mz:max_latitude"`
MZMaxLongitude float64 `json:"mz:max_longitude"`
MZIsCurrent int64 `json:"mz:is_current"`
MZIsDeprecated int64 `json:"mz:is_deprecated"`
MZIsCeased int64 `json:"mz:is_ceased"`
MZIsSuperseded int64 `json:"mz:is_superseded"`
MZIsSuperseding int64 `json:"mz:is_superseding"`
WOFPath string `json:"wof:path"`
WOFRepo string `json:"wof:repo"`
WOFLastModified int64 `json:"wof:lastmodified"`
}