diff --git a/README.md b/README.md index f7f8d1d3..c2230435 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ $> ./bin/wof-sqlite-index-features \ -geometry \ -properties \ -timings \ - -dsn /usr/local/ca-poly-spr.db \ + -dsn /usr/local/ca-alt.db \ -mode repo:// \ /usr/local/data/whosonfirst-data-admin-ca/ @@ -49,9 +49,30 @@ And then... ``` $> ./bin/query \ - -database-uri 'sqlite://?dsn=/usr/local/data/ca-poly-spr.db' \ + -database-uri 'sqlite://?dsn=/usr/local/data/ca-alt.db' \ -latitude 45.572744 \ -longitude -73.586295 +| jq \ +| grep wof:id + +2020/12/15 15:32:05 Unable to parse placetype (alt) for ID 85874359, because 'Invalid placetype' - skipping placetype filters +2020/12/15 15:32:06 Unable to parse placetype (alt) for ID 85633041, because 'Invalid placetype' - skipping placetype filters +2020/12/15 15:32:06 Unable to parse placetype (alt) for ID 136251273, because 'Invalid placetype' - skipping placetype filters +2020/12/15 15:32:06 Unable to parse placetype (alt) for ID 85633041, because 'Invalid placetype' - skipping placetype filters +2020/12/15 15:32:06 Unable to parse placetype (alt) for ID 136251273, because 'Invalid placetype' - skipping placetype filters +2020/12/15 15:32:06 Unable to parse placetype (alt) for ID 85633041, because 'Invalid placetype' - skipping placetype filters +2020/12/15 15:32:06 Time to point in polygon, 596.579126ms + "wof:id": "1108955735", + "wof:id": "85874359", + "wof:id": "85874359", + "wof:id": "890458661", + "wof:id": "85633041", + "wof:id": "136251273", + "wof:id": "85633041", + "wof:id": "85633041", + "wof:id": "136251273", + "wof:id": "85633041", + "wof:id": "136251273", ``` _TBW: Indexing tables on start-up._ diff --git a/database.go b/database.go index 5983097b..4edd3de4 100644 --- a/database.go +++ b/database.go @@ -2,9 +2,6 @@ package sqlite // https://www.sqlite.org/rtree.html -// There is a bunch of code in here that could/should -// be reconciled with go-whosonfirst-spatial/database/rtree - import ( "context" "encoding/json" @@ -14,9 +11,7 @@ import ( "github.com/paulmach/go.geojson" "github.com/skelterjohn/geom" wof_geojson "github.com/whosonfirst/go-whosonfirst-geojson-v2" - // wof_feature "github.com/whosonfirst/go-whosonfirst-geojson-v2/feature" "github.com/whosonfirst/go-whosonfirst-log" - // "github.com/whosonfirst/go-whosonfirst-spatial/cache" "github.com/whosonfirst/go-whosonfirst-spatial/database" "github.com/whosonfirst/go-whosonfirst-spatial/filter" "github.com/whosonfirst/go-whosonfirst-spatial/geo" @@ -346,14 +341,6 @@ func (r *SQLiteSpatialDatabase) getIntersectsByCoord(ctx context.Context, coord func (r *SQLiteSpatialDatabase) getIntersectsByRect(ctx context.Context, rect *geom.Rect) ([]*RTreeSpatialIndex, error) { - /* - t1 := time.Now() - - defer func() { - golog.Printf("Time to get intersects by rect, %v\n", time.Since(t1)) - }() - */ - conn, err := r.db.Conn() if err != nil { @@ -424,14 +411,6 @@ func (r *SQLiteSpatialDatabase) getIntersectsByRect(ctx context.Context, rect *g func (r *SQLiteSpatialDatabase) inflateResultsWithChannels(ctx context.Context, rsp_ch chan spr.StandardPlacesResult, err_ch chan error, possible []*RTreeSpatialIndex, c *geom.Coord, filters ...filter.Filter) { - /* - t1 := time.Now() - - defer func() { - golog.Printf("Time to inflate results, %v\n", time.Since(t1)) - }() - */ - seen := make(map[string]bool) mu := new(sync.RWMutex) @@ -580,19 +559,9 @@ func (db *SQLiteSpatialDatabase) StandardPlacesResultsToFeatureCollection(ctx co features = append(features, f) } - /* - pg := geojson.Pagination{ - TotalCount: len(features), - Page: 1, - PerPage: len(features), - PageCount: 1, - } - */ - collection := geojson.FeatureCollection{ Type: "FeatureCollection", Features: features, - // Pagination: pg, } return &collection, nil @@ -628,7 +597,7 @@ func (r *SQLiteSpatialDatabase) retrieveSPRCacheItem(ctx context.Context, uri_st // Note to self: I actually tried chunking this out in to separate functions // talking to the database concurrently with channels and stuff and it was // subtly slower than just doing it this way... (20201215/thisisaaronland) - + c, ok := r.gocache.Get(uri_str) if ok { @@ -721,11 +690,11 @@ func (r *SQLiteSpatialDatabase) retrieveSPRCacheItem(ctx context.Context, uri_st } path, err := uri.Id2RelPath(id, uri_args) - + if err != nil { return nil, err } - + s := &SQLiteStandardPlacesResult{ WOFId: spr_id, WOFParentId: parent_id, diff --git a/spr.go b/spr.go index 41f774e9..e011e365 100644 --- a/spr.go +++ b/spr.go @@ -15,7 +15,7 @@ type SQLiteStandardPlacesResult struct { WOFPlacetype string `json:"wof:placetype"` MZLatitude float64 `json:"mz:latitude"` MZLongitude float64 `json:"mz:longitude"` - MZMinLatitude float64 `json:"spr:min_latitude"` + MZMinLatitude float64 `json:"mz:min_latitude"` MZMinLongitude float64 `json:"mz:min_longitude"` MZMaxLatitude float64 `json:"mz:max_latitude"` MZMaxLongitude float64 `json:"mz:max_longitude"`