Skip to content

Go package to implement the whosonfirst/go-whosonfirst-spr interface for "standard places result" (SPR) data stored in a SQLite database.

Notifications You must be signed in to change notification settings

whosonfirst/go-whosonfirst-sqlite-spr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Go Reference

Description

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"
	"github.com/aaronland/go-sqlite/v2"
	"github.com/whosonfirst/go-whosonfirst-sqlite-features/v2/tables"
	"github.com/whosonfirst/go-whosonfirst-sqlite-spr/v2"
)

ctx := context.Background()

db, _ := sqlite.NewDatabase(ctx, "modernc://cwd/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

About

Go package to implement the whosonfirst/go-whosonfirst-spr interface for "standard places result" (SPR) data stored in a SQLite database.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages