Skip to content
This repository has been archived by the owner on Dec 13, 2024. It is now read-only.

Commit

Permalink
index-belongs-to docs and tifying up, seems to work
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisaaronland committed Mar 19, 2020
1 parent 2cda2cc commit c279297
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ Go package for indexing Who's On First features in SQLite databases.
### wof-sqlite-index-features

```
./bin/wof-sqlite-index-features -h
Usage of ./bin/wof-sqlite-index-features:
-all
Index all tables (except the 'search' and 'geometries' tables which you need to specify explicitly)
-ancestors
Expand All @@ -23,18 +21,28 @@ Usage of ./bin/wof-sqlite-index-features:
Index the 'geojson' table
-geometries
Index the 'geometries' table (requires that libspatialite already be installed)
-index-alt-files
Index alt geometries
-index-belongs-to
Index the records listed in a feature's 'wof:belongsto' array. Alt files for 'wof:belongsto' are not indexed at this time.
-index-belongs-to-uri string
A valid go-reader.Reader URI from which to read data for a 'wof:belongsto' candidate.
-live-hard-die-fast
Enable various performance-related pragmas at the expense of possible (unlikely) database corruption
Enable various performance-related pragmas at the expense of possible (unlikely) database corruption (default true)
-mode string
The mode to use importing data. Valid modes are: directory,feature,feature-collection,files,geojson-ls,meta,path,repo,sqlite. (default "files")
The mode to use importing data. Valid modes are: directory,featurecollection,file,filelist,geojsonl,metafile,repo,sqlite. (default "files")
-names
Index the 'names' table
-optimize
Attempt to optimize the database before closing connection (default true)
-processes int
The number of concurrent processes to index data with (default 16)
The number of concurrent processes to index data with (default 8)
-search
Index the 'search' table (using SQLite FTS4 full-text indexer)
-spr
Index the 'spr' table
-strict-alt-files
Be strict when indexing alt geometries (default true)
-timings
Display timings during and after indexing
```
Expand Down
8 changes: 4 additions & 4 deletions cmd/wof-sqlite-index-features/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func main() {
alt_files := flag.Bool("index-alt-files", false, "Index alt geometries")
strict_alt_files := flag.Bool("strict-alt-files", true, "Be strict when indexing alt geometries")

index_belongs_to := flag.Bool("index-belongs-to", false, "...")
belongs_to_uri := flag.String("belongs-to-uri", "", "...")
index_belongs_to := flag.Bool("index-belongs-to", false, "Index the records listed in a feature's 'wof:belongsto' array. Alt files for 'wof:belongsto' are not indexed at this time.")
belongs_to_uri := flag.String("index-belongs-to-uri", "", "A valid go-reader.Reader URI from which to read data for a 'wof:belongsto' candidate.")

var procs = flag.Int("processes", (runtime.NumCPU() * 2), "The number of concurrent processes to index data with")

Expand Down Expand Up @@ -217,8 +217,8 @@ func main() {
record_func := index.SQLiteFeaturesLoadRecordFunc(record_opts)

idx_opts := &sql_index.SQLiteIndexerOptions{
DB: db,
Tables: to_index,
DB: db,
Tables: to_index,
LoadRecordFunc: record_func,
}

Expand Down
17 changes: 10 additions & 7 deletions index.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,19 @@ func SQLiteFeaturesIndexBelongsToFunc(r reader.Reader) sql_index.SQLiteIndexerPo
return err
}

if count == 0 {

ancestor, err := wof_reader.LoadFeatureFromID(ctx, r, id)
if count != 0 {
continue
}

if err != nil {
return err
}
ancestor, err := wof_reader.LoadFeatureFromID(ctx, r, id)

to_index = append(to_index, ancestor)
if err != nil {
return err
}

to_index = append(to_index, ancestor)

// TO DO: CHECK WHETHER TO INDEX ALT FILES FOR ANCESTOR(S)
}

for _, record := range to_index {
Expand Down

0 comments on commit c279297

Please sign in to comment.