sqlite

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2020 License: BSD-3-Clause Imports: 19 Imported by: 0

README

go-whosonfirst-spatial-database-sqlite

Important

This is work in progress. It may change, probably has bugs and isn't properly documented yet.

The goal is to have a package that conforms to the database.SpatialDatabase interface using mattn/go-sqlite3 and SQLite's RTree extension.

Tools

query
$> ./bin/query \
	-database-uri 'sqlite3://?dsn=/tmp/test.db' \
	-latitude 37.616951 \
	-longitude -122.383747 \
| jq \
| grep wof:path

      "wof:path": "115/939/625/7/1159396257.geojson",
      "wof:path": "115/939/628/3/1159396283.geojson",
      "wof:path": "147/785/565/5/1477855655.geojson",
      "wof:path": "115/939/616/5/1159396165.geojson",
      "wof:path": "115/939/613/3/1159396133.geojson",
      "wof:path": "115/939/613/1/1159396131.geojson",
      "wof:path": "115/915/732/7/1159157327.geojson",
      "wof:path": "115/939/612/1/1159396121.geojson",
      "wof:path": "115/939/617/1/1159396171.geojson",
      "wof:path": "136/052/154/3/1360521543.geojson",
      "wof:path": "115/939/614/9/1159396149.geojson",
      "wof:path": "136/052/154/5/1360521545.geojson",
      "wof:path": "115/939/632/9/1159396329.geojson",
      "wof:path": "115/955/482/7/1159554827.geojson",
      "wof:path": "115/939/610/9/1159396109.geojson",
      "wof:path": "115/955/482/9/1159554829.geojson",
      "wof:path": "147/785/560/7/1477855607.geojson",
      "wof:path": "115/955/480/3/1159554803.geojson",
      "wof:path": "115/915/732/5/1159157325.geojson",
      "wof:path": "115/939/632/1/1159396321.geojson",
      "wof:path": "147/785/560/5/1477855605.geojson",
      "wof:path": "115/939/633/3/1159396333.geojson",
      "wof:path": "115/939/631/9/1159396319.geojson",
      "wof:path": "115/939/633/7/1159396337.geojson",

Note: This assumes a database that was previously indexed using the whosonfirst/go-whosonfirst-sqlite-features wof-sqlite-index-features tool. For example:

$> ./bin/wof-sqlite-index-features -rtree -geojson -dsn /tmp/test.db -mode repo:// /usr/local/data/sfomuseum-data-architecture/

See also

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSQLiteSpatialDatabase

func NewSQLiteSpatialDatabase(ctx context.Context, uri string) (database.SpatialDatabase, error)

Types

type RTreeSpatialIndex

type RTreeSpatialIndex struct {
	Id string
	// contains filtered or unexported fields
}

func (RTreeSpatialIndex) Bounds

func (sp RTreeSpatialIndex) Bounds() geom.Rect

type SQLiteResults

type SQLiteResults struct {
	spr.StandardPlacesResults `json:",omitempty"`
	Places                    []spr.StandardPlacesResult `json:"places"`
}

func (*SQLiteResults) Results

func (r *SQLiteResults) Results() []spr.StandardPlacesResult

type SQLiteSpatialDatabase

type SQLiteSpatialDatabase struct {
	database.SpatialDatabase
	Logger *log.WOFLogger
	// contains filtered or unexported fields
}

func (*SQLiteSpatialDatabase) Close

func (*SQLiteSpatialDatabase) IndexFeature

func (*SQLiteSpatialDatabase) PointInPolygon

func (r *SQLiteSpatialDatabase) PointInPolygon(ctx context.Context, coord *geom.Coord, filters filter.Filter) (spr.StandardPlacesResults, error)

func (*SQLiteSpatialDatabase) PointInPolygonCandidates

func (r *SQLiteSpatialDatabase) PointInPolygonCandidates(ctx context.Context, coord *geom.Coord) (*geojson.GeoJSONFeatureCollection, error)

func (*SQLiteSpatialDatabase) PointInPolygonCandidatesWithChannels

func (r *SQLiteSpatialDatabase) PointInPolygonCandidatesWithChannels(ctx context.Context, coord *geom.Coord, rsp_ch chan geojson.GeoJSONFeature, err_ch chan error, done_ch chan bool)

func (*SQLiteSpatialDatabase) PointInPolygonWithChannels

func (r *SQLiteSpatialDatabase) PointInPolygonWithChannels(ctx context.Context, coord *geom.Coord, filters filter.Filter, rsp_ch chan spr.StandardPlacesResult, err_ch chan error, done_ch chan bool)

func (*SQLiteSpatialDatabase) StandardPlacesResultsToFeatureCollection

func (db *SQLiteSpatialDatabase) StandardPlacesResultsToFeatureCollection(ctx context.Context, results spr.StandardPlacesResults) (*geojson.GeoJSONFeatureCollection, error)

Directories

Path Synopsis
cmd
query command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL