Documentation ¶
Overview ¶
package sqlite provides methods for indexing and performing spatial queries on data stored in a SQLite databases from tables defined by the `whosonfirst/go-whosonfirst-sqlite-features/tables` package.
Index ¶
- func NewSQLiteSpatialDatabase(ctx context.Context, uri string) (database.SpatialDatabase, error)
- func NewSQLiteSpatialDatabaseReader(ctx context.Context, uri string) (reader.Reader, error)
- func NewSQLiteSpatialDatabaseWithDatabase(ctx context.Context, uri string, sqlite_db sqlite.Database) (database.SpatialDatabase, error)
- func NewSQLiteSpatialDatabaseWriter(ctx context.Context, uri string) (writer.Writer, error)
- type RTreeSpatialIndex
- type SQLiteResults
- type SQLiteSpatialDatabase
- func (r *SQLiteSpatialDatabase) Close(ctx context.Context) error
- func (r *SQLiteSpatialDatabase) Disconnect(ctx context.Context) error
- func (r *SQLiteSpatialDatabase) Flush(ctx context.Context) error
- func (r *SQLiteSpatialDatabase) IndexFeature(ctx context.Context, body []byte) error
- func (r *SQLiteSpatialDatabase) PointInPolygon(ctx context.Context, coord *orb.Point, filters ...spatial.Filter) (spr.StandardPlacesResults, error)
- func (r *SQLiteSpatialDatabase) PointInPolygonCandidates(ctx context.Context, coord *orb.Point, filters ...spatial.Filter) ([]*spatial.PointInPolygonCandidate, error)
- func (r *SQLiteSpatialDatabase) PointInPolygonCandidatesWithChannels(ctx context.Context, rsp_ch chan *spatial.PointInPolygonCandidate, ...)
- func (r *SQLiteSpatialDatabase) PointInPolygonWithChannels(ctx context.Context, rsp_ch chan spr.StandardPlacesResult, err_ch chan error, ...)
- func (r *SQLiteSpatialDatabase) Read(ctx context.Context, str_uri string) (io.ReadSeekCloser, error)
- func (r *SQLiteSpatialDatabase) ReaderURI(ctx context.Context, str_uri string) string
- func (r *SQLiteSpatialDatabase) RemoveFeature(ctx context.Context, str_id string) error
- func (r *SQLiteSpatialDatabase) SetLogger(ctx context.Context, logger *log.Logger) error
- func (r *SQLiteSpatialDatabase) Write(ctx context.Context, key string, fh io.ReadSeeker) (int64, error)
- func (r *SQLiteSpatialDatabase) WriterURI(ctx context.Context, str_uri string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSQLiteSpatialDatabase ¶
NewSQLiteSpatialDatabase returns a new `whosonfirst/go-whosonfirst-spatial/database.database.SpatialDatabase` instance for performing spatial operations derived from 'uri'.
func NewSQLiteSpatialDatabaseReader ¶ added in v0.5.5
func NewSQLiteSpatialDatabaseWithDatabase ¶ added in v0.0.20
func NewSQLiteSpatialDatabaseWithDatabase(ctx context.Context, uri string, sqlite_db sqlite.Database) (database.SpatialDatabase, error)
NewSQLiteSpatialDatabaseWithDatabase returns a new `whosonfirst/go-whosonfirst-spatial/database.database.SpatialDatabase` instance for performing spatial operations derived from 'uri' and an existing `aaronland/go-sqlite/database.SQLiteDatabase` instance defined by 'sqlite_db'.
Types ¶
type RTreeSpatialIndex ¶
type RTreeSpatialIndex struct { Id string FeatureId string // A boolean flag indicating whether the feature associated with the index is an alternate geometry. IsAlt bool // The label for the feature (associated with the index) if it is an alternate geometry. AltLabel string // contains filtered or unexported fields }
RTreeSpatialIndex is a struct representing an RTree based spatial index
func (RTreeSpatialIndex) Bounds ¶
func (sp RTreeSpatialIndex) Bounds() orb.Bound
func (RTreeSpatialIndex) Path ¶ added in v0.0.6
func (sp RTreeSpatialIndex) Path() string
type SQLiteResults ¶
type SQLiteResults struct { spr.StandardPlacesResults `json:",omitempty"` // Places is the list of `whosonfirst/go-whosonfirst-spr.StandardPlacesResult` instances returned for a spatial query. Places []spr.StandardPlacesResult `json:"places"` }
SQLiteResults is a struct that implements the `whosonfirst/go-whosonfirst-spr.StandardPlacesResults` interface for rows matching a spatial query.
func (*SQLiteResults) Results ¶
func (r *SQLiteResults) Results() []spr.StandardPlacesResult
Results returns a `whosonfirst/go-whosonfirst-spr.StandardPlacesResults` instance for rows matching a spatial query.
type SQLiteSpatialDatabase ¶
type SQLiteSpatialDatabase struct { database.SpatialDatabase Logger *log.Logger // contains filtered or unexported fields }
SQLiteSpatialDatabase is a struct that implements the `database.SpatialDatabase` for performing spatial queries on data stored in a SQLite databases from tables defined by the `whosonfirst/go-whosonfirst-sqlite-features/tables` package.
func (*SQLiteSpatialDatabase) Close ¶
func (r *SQLiteSpatialDatabase) Close(ctx context.Context) error
Close implements the whosonfirst/go-writer interface so that the database itself can be used as a writer.Writer instance. This method is a no-op and simply returns `nil`.
func (*SQLiteSpatialDatabase) Disconnect ¶ added in v0.0.28
func (r *SQLiteSpatialDatabase) Disconnect(ctx context.Context) error
Disconnect will close the underlying database connection.
func (*SQLiteSpatialDatabase) Flush ¶ added in v0.5.2
func (r *SQLiteSpatialDatabase) Flush(ctx context.Context) error
Flush implements the whosonfirst/go-writer interface so that the database itself can be used as a writer.Writer instance. This method is a no-op and simply returns `nil`.
func (*SQLiteSpatialDatabase) IndexFeature ¶
func (r *SQLiteSpatialDatabase) IndexFeature(ctx context.Context, body []byte) error
IndexFeature will index a Who's On First GeoJSON Feature record, defined in 'body', in the spatial database.
func (*SQLiteSpatialDatabase) PointInPolygon ¶
func (r *SQLiteSpatialDatabase) PointInPolygon(ctx context.Context, coord *orb.Point, filters ...spatial.Filter) (spr.StandardPlacesResults, error)
PointInPolygon will perform a point in polygon query against the database for records that contain 'coord' and that are inclusive of any filters defined by 'filters'.
func (*SQLiteSpatialDatabase) PointInPolygonCandidates ¶
func (r *SQLiteSpatialDatabase) PointInPolygonCandidates(ctx context.Context, coord *orb.Point, filters ...spatial.Filter) ([]*spatial.PointInPolygonCandidate, error)
PointAndPolygonCandidates will perform a point in polygon query against the database for records that contain 'coord' and that are inclusive of any filters defined by 'filters' returning the list of `spatial.PointInPolygonCandidate` candidate bounding boxes that match an initial RTree-based spatial query.
func (*SQLiteSpatialDatabase) PointInPolygonCandidatesWithChannels ¶
func (r *SQLiteSpatialDatabase) PointInPolygonCandidatesWithChannels(ctx context.Context, rsp_ch chan *spatial.PointInPolygonCandidate, err_ch chan error, done_ch chan bool, coord *orb.Point, filters ...spatial.Filter)
PointAndPolygonCandidatesWithChannels will perform a point in polygon query against the database for records that contain 'coord' and that are inclusive of any filters defined by 'filters' returning the list of `spatial.PointInPolygonCandidate` candidate bounding boxes that match an initial RTree-based spatial query emitting results to 'rsp_ch' (for matches), 'err_ch' (for errors) and 'done_ch' (when the query is completed).
func (*SQLiteSpatialDatabase) PointInPolygonWithChannels ¶
func (r *SQLiteSpatialDatabase) PointInPolygonWithChannels(ctx context.Context, rsp_ch chan spr.StandardPlacesResult, err_ch chan error, done_ch chan bool, coord *orb.Point, filters ...spatial.Filter)
PointInPolygonWithChannels will perform a point in polygon query against the database for records that contain 'coord' and that are inclusive of any filters defined by 'filters' emitting results to 'rsp_ch' (for matches), 'err_ch' (for errors) and 'done_ch' (when the query is completed).
func (*SQLiteSpatialDatabase) Read ¶ added in v0.0.24
func (r *SQLiteSpatialDatabase) Read(ctx context.Context, str_uri string) (io.ReadSeekCloser, error)
Read implements the whosonfirst/go-reader interface so that the database itself can be used as a reader.Reader instance (reading features from the `geojson` table.
func (*SQLiteSpatialDatabase) ReaderURI ¶ added in v0.0.28
func (r *SQLiteSpatialDatabase) ReaderURI(ctx context.Context, str_uri string) string
ReadURI implements the whosonfirst/go-reader interface so that the database itself can be used as a reader.Reader instance
func (*SQLiteSpatialDatabase) RemoveFeature ¶ added in v0.2.0
func (r *SQLiteSpatialDatabase) RemoveFeature(ctx context.Context, str_id string) error
RemoveFeature will remove the database record with ID 'id' from the database.
func (*SQLiteSpatialDatabase) SetLogger ¶ added in v0.5.2
SetLogger implements the whosonfirst/go-writer interface so that the database itself can be used as a writer.Writer instance. This method is a no-op and simply returns `nil`.
func (*SQLiteSpatialDatabase) Write ¶ added in v0.0.28
func (r *SQLiteSpatialDatabase) Write(ctx context.Context, key string, fh io.ReadSeeker) (int64, error)
Write implements the whosonfirst/go-writer interface so that the database itself can be used as a writer.Writer instance (by invoking the `IndexFeature` method).