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

Commit 744932f

Browse files
author
thisisaaronland
committed
remove whosonfirst/go-whosonfirst-reader; ignore placetype warning when loading features; add a previously seen lookup table when indexing relations
1 parent 21f57d1 commit 744932f

File tree

9 files changed

+32
-236
lines changed

9 files changed

+32
-236
lines changed

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ require (
1111
github.com/whosonfirst/go-whosonfirst-index-csv v0.0.0-20191002171239-c6712fe20972
1212
github.com/whosonfirst/go-whosonfirst-index-sqlite v0.0.3
1313
github.com/whosonfirst/go-whosonfirst-log v0.1.0
14-
github.com/whosonfirst/go-whosonfirst-reader v0.0.2
14+
github.com/whosonfirst/go-whosonfirst-reader v0.0.2 // indirect
1515
github.com/whosonfirst/go-whosonfirst-sqlite v0.1.6
1616
github.com/whosonfirst/go-whosonfirst-sqlite-features v0.6.4
1717
github.com/whosonfirst/go-whosonfirst-sqlite-index v0.2.0
18+
github.com/whosonfirst/go-whosonfirst-uri v0.2.0
1819
github.com/whosonfirst/warning v0.1.1
1920
)

index.go

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ import (
99
"github.com/whosonfirst/go-whosonfirst-geojson-v2"
1010
"github.com/whosonfirst/go-whosonfirst-geojson-v2/feature"
1111
wof_index "github.com/whosonfirst/go-whosonfirst-index"
12-
wof_reader "github.com/whosonfirst/go-whosonfirst-reader"
1312
"github.com/whosonfirst/go-whosonfirst-sqlite"
13+
"github.com/whosonfirst/go-whosonfirst-uri"
1414
wof_tables "github.com/whosonfirst/go-whosonfirst-sqlite-features/tables"
1515
sql_index "github.com/whosonfirst/go-whosonfirst-sqlite-index"
1616
"github.com/whosonfirst/warning"
1717
"io"
1818
"io/ioutil"
1919
"log"
20+
"sync"
2021
)
2122

2223
type SQLiteFeaturesLoadRecordFuncOptions struct {
@@ -81,6 +82,8 @@ func SQLiteFeaturesLoadRecordFunc(opts *SQLiteFeaturesLoadRecordFuncOptions) sql
8182

8283
func SQLiteFeaturesIndexRelationsFunc(r reader.Reader) sql_index.SQLiteIndexerPostIndexFunc {
8384

85+
seen := new(sync.Map)
86+
8487
cb := func(ctx context.Context, db sqlite.Database, tables []sqlite.Table, record interface{}) error {
8588

8689
geojson_t, err := wof_tables.NewGeoJSONTable()
@@ -127,6 +130,14 @@ func SQLiteFeaturesIndexRelationsFunc(r reader.Reader) sql_index.SQLiteIndexerPo
127130

128131
for id, _ := range relations {
129132

133+
_, ok := seen.Load(id)
134+
135+
if ok {
136+
continue
137+
}
138+
139+
seen.Store(id, true)
140+
130141
sql := fmt.Sprintf("SELECT COUNT(id) FROM %s WHERE id=?", geojson_t.Name())
131142
row := conn.QueryRow(sql, id)
132143

@@ -141,12 +152,29 @@ func SQLiteFeaturesIndexRelationsFunc(r reader.Reader) sql_index.SQLiteIndexerPo
141152
continue
142153
}
143154

144-
ancestor, err := wof_reader.LoadFeatureFromID(ctx, r, id)
155+
rel_path, err := uri.Id2RelPath(id)
145156

146157
if err != nil {
147158
return err
148159
}
149160

161+
fh, err := r.Read(ctx, rel_path)
162+
163+
if err != nil{
164+
return err
165+
}
166+
167+
defer fh.Close()
168+
169+
ancestor, err := feature.LoadFeatureFromReader(fh)
170+
171+
// check for warnings in case this record has a non-standard
172+
// placetype (20201224/thisisaaronland)
173+
174+
if err != nil && !warning.IsWarning(err){
175+
return err
176+
}
177+
150178
to_index = append(to_index, ancestor)
151179

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

vendor/github.com/whosonfirst/go-whosonfirst-reader/.gitignore

Lines changed: 0 additions & 8 deletions
This file was deleted.

vendor/github.com/whosonfirst/go-whosonfirst-reader/LICENSE

Lines changed: 0 additions & 27 deletions
This file was deleted.

vendor/github.com/whosonfirst/go-whosonfirst-reader/README.md

Lines changed: 0 additions & 81 deletions
This file was deleted.

vendor/github.com/whosonfirst/go-whosonfirst-reader/go.mod

Lines changed: 0 additions & 9 deletions
This file was deleted.

vendor/github.com/whosonfirst/go-whosonfirst-reader/go.sum

Lines changed: 0 additions & 58 deletions
This file was deleted.

vendor/github.com/whosonfirst/go-whosonfirst-reader/reader.go

Lines changed: 0 additions & 48 deletions
This file was deleted.

vendor/modules.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ github.com/whosonfirst/go-whosonfirst-names/tags
6161
# github.com/whosonfirst/go-whosonfirst-placetypes v0.1.0
6262
github.com/whosonfirst/go-whosonfirst-placetypes
6363
github.com/whosonfirst/go-whosonfirst-placetypes/placetypes
64-
# github.com/whosonfirst/go-whosonfirst-reader v0.0.2
65-
github.com/whosonfirst/go-whosonfirst-reader
6664
# github.com/whosonfirst/go-whosonfirst-sources v0.1.0
6765
github.com/whosonfirst/go-whosonfirst-sources
6866
github.com/whosonfirst/go-whosonfirst-sources/sources

0 commit comments

Comments
 (0)