https://github.com/whosonfirst/go-whosonfirst-sqlite-spr
Go package to implement the whosonfirst/go-whosonfirst-spr interface for "standard places result" (SPR) data stored in a SQLite database.
https://github.com/whosonfirst/go-whosonfirst-sqlite-spr
golang spr sqlite whosonfirst
Last synced: 4 months ago
JSON representation
Go package to implement the whosonfirst/go-whosonfirst-spr interface for "standard places result" (SPR) data stored in a SQLite database.
- Host: GitHub
- URL: https://github.com/whosonfirst/go-whosonfirst-sqlite-spr
- Owner: whosonfirst
- Created: 2020-12-29T01:48:05.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-12-13T19:51:58.000Z (6 months ago)
- Last Synced: 2024-12-13T20:32:03.776Z (6 months ago)
- Topics: golang, spr, sqlite, whosonfirst
- Language: Go
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-whosonfirst-sqlite-spr
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.
## Documentation
[](https://pkg.go.dev/github.com/whosonfirst/go-whosonfirst-sqlite-spr)
## Description
`go-whosonfirst-sqlite-spr` is a Go package to implement the `whosonfirst/go-whosonfirst-spr` interface for ["standard places result"](https://github.com/whosonfirst/go-whosonfirst-spr) (SPR) data stored in a SQLite database, specifically data stored in [an `spr` table](https://github.com/whosonfirst/go-whosonfirst-sqlite-features#spr) 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"`
}
```## See also
* https://github.com/whosonfirst/go-whosonfirst-spr
* https://github.com/whosonfirst/go-whosonfirst-database