Skip to content

Commit

Permalink
update to reflect changes in whosonfirst/go-whosonfirst-spatial v0.0.…
Browse files Browse the repository at this point in the history
…50; remove properties reader interface code
  • Loading branch information
thisisaaronland committed Mar 25, 2021
1 parent 33b9a4f commit 8d34c56
Show file tree
Hide file tree
Showing 15 changed files with 121 additions and 370 deletions.
52 changes: 14 additions & 38 deletions cmd/query/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import (
"encoding/json"
"fmt"
"github.com/sfomuseum/go-flags/flagset"
"github.com/sfomuseum/go-flags/lookup"
"github.com/sfomuseum/go-flags/lookup"
_ "github.com/whosonfirst/go-whosonfirst-spatial-sqlite"
"github.com/whosonfirst/go-whosonfirst-spatial/api"
"github.com/whosonfirst/go-whosonfirst-spatial/database"
"github.com/whosonfirst/go-whosonfirst-spatial/flags"
"github.com/whosonfirst/go-whosonfirst-spatial/geo"
"github.com/whosonfirst/go-whosonfirst-spatial/properties"
"github.com/whosonfirst/go-whosonfirst-spr/v2"
"log"
)

Expand Down Expand Up @@ -45,7 +43,6 @@ func main() {
}

database_uri, _ := lookup.StringVar(fs, flags.SPATIAL_DATABASE_URI)
properties_uri, _ := lookup.StringVar(fs, flags.PROPERTIES_READER_URI)

ctx := context.Background()
db, err := database.NewSpatialDatabase(ctx, database_uri)
Expand All @@ -68,54 +65,33 @@ func main() {
return nil, err
}

var rsp interface{}

r, err := db.PointInPolygon(ctx, c, f)

if err != nil {
return nil, fmt.Errorf("Failed to query database with coord %v, %v", c, err)
}

rsp = r

if len(req.Properties) > 0 {

pr, err := properties.NewPropertiesReader(ctx, properties_uri)

if err != nil {
return nil, fmt.Errorf("Failed to create properties reader, %v", err)
}

r, err := pr.PropertiesResponseResultsWithStandardPlacesResults(ctx, rsp.(spr.StandardPlacesResults), req.Properties)

if err != nil {
return nil, fmt.Errorf("Failed to generate properties response, %v", err)
}

rsp = r
}

return r, nil
}

req, err := api.NewPointInPolygonRequestFromFlagSet(fs)
req, err := api.NewPointInPolygonRequestFromFlagSet(fs)

if err != nil {
log.Fatalf("Failed to create SPR filter, %v", err)
}
if err != nil {
log.Fatalf("Failed to create SPR filter, %v", err)
}

rsp, err := query(ctx, req)
rsp, err := query(ctx, req)

if err != nil {
log.Fatalf("Failed to query, %v", err)
}
if err != nil {
log.Fatalf("Failed to query, %v", err)
}

enc, err := json.Marshal(rsp)
enc, err := json.Marshal(rsp)

if err != nil {
log.Fatalf("Failed to marshal results, %v", err)
}
if err != nil {
log.Fatalf("Failed to marshal results, %v", err)
}

fmt.Println(string(enc))
fmt.Println(string(enc))

}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ require (
github.com/sfomuseum/go-flags v0.8.1
github.com/skelterjohn/geom v0.0.0-20180103142417-96f3e8a219c5
github.com/whosonfirst/go-ioutil v0.0.1
github.com/whosonfirst/go-whosonfirst-geojson-v2 v0.16.0
github.com/whosonfirst/go-whosonfirst-geojson-v2 v0.16.1
github.com/whosonfirst/go-whosonfirst-log v0.1.0
github.com/whosonfirst/go-whosonfirst-spatial v0.0.44
github.com/whosonfirst/go-whosonfirst-spatial v0.0.50
github.com/whosonfirst/go-whosonfirst-spr/v2 v2.0.0
github.com/whosonfirst/go-whosonfirst-sqlite v0.1.7
github.com/whosonfirst/go-whosonfirst-sqlite-features v0.7.0
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sfomuseum/go-edtf v0.2.2 h1:8n1UekTCU6fkgAf3bWqG5RyQxOd9hRhy4lg91aQ3kMk=
github.com/sfomuseum/go-edtf v0.2.2/go.mod h1:1rP0EJZ/84j3HO80vGcnG2T9MFBDAFyTNtjrr8cv3T4=
github.com/sfomuseum/go-edtf v0.2.3 h1:wpcpwl1RD9W/sXFDi4zpoIpQcIwIk8em9CGwa7YWv4g=
github.com/sfomuseum/go-edtf v0.2.3/go.mod h1:1rP0EJZ/84j3HO80vGcnG2T9MFBDAFyTNtjrr8cv3T4=
github.com/sfomuseum/go-flags v0.4.2 h1:sDSvp0c4QZKf3pNUcpfIwshAu9U6sjsNEopmPfC329U=
github.com/sfomuseum/go-flags v0.4.2/go.mod h1:54KCZIGmvZkIOrSCHSNMvgSTKH2gJRJyISH+AiI+55w=
github.com/sfomuseum/go-flags v0.5.0 h1:tbJ88KdBRqhtJo+IoWBJnVpetAYA26fS1WNT6eGWCQ8=
Expand Down Expand Up @@ -136,6 +138,8 @@ github.com/whosonfirst/go-whosonfirst-flags v0.4.2 h1:HWjy/0MfAQMdCj4M9hi3LAITgK
github.com/whosonfirst/go-whosonfirst-flags v0.4.2/go.mod h1:kewFjxBiE00SqjjIanm5DPI81SYvx93wVb3ogwV/PMk=
github.com/whosonfirst/go-whosonfirst-geojson-v2 v0.16.0 h1:o+Q4noTqXYKeDD+dMrf4lb1yFvly5PDAcF4ASKwHwpc=
github.com/whosonfirst/go-whosonfirst-geojson-v2 v0.16.0/go.mod h1:cWVV68R2xgKtmOcAsQmWYsdv8QhIhT4k9DmqRbqrt/4=
github.com/whosonfirst/go-whosonfirst-geojson-v2 v0.16.1 h1:zUJoEVZzmstNybujlUkLXMbJ4ucKIfLS9IgIX0XE/Sk=
github.com/whosonfirst/go-whosonfirst-geojson-v2 v0.16.1/go.mod h1:R3GximAGJWLCITU2eh3I5Vtyze/usjOl5LTGQCDI89Y=
github.com/whosonfirst/go-whosonfirst-hash v0.1.0 h1:FpnclPIb+8M1uhSXfl3z8nYcG/3O59vgfkdV+m0hQpA=
github.com/whosonfirst/go-whosonfirst-hash v0.1.0/go.mod h1:1ZdCFZTnQt5bwnsj2daB9yHilKOKToVh+Tyj/Z8TbUk=
github.com/whosonfirst/go-whosonfirst-iterate v1.1.0 h1:mirgJrwyMS7Qdle3DpHCt9go1AG8lSP+tf0R/nxlmSQ=
Expand All @@ -151,6 +155,8 @@ github.com/whosonfirst/go-whosonfirst-sources v0.1.0 h1:JuKLa6KWke22jBfJ1pM9WQHo
github.com/whosonfirst/go-whosonfirst-sources v0.1.0/go.mod h1:EUMHyGzUmqPPxlMmOp+28BFeoBdxxE0HCKRd67lkqGM=
github.com/whosonfirst/go-whosonfirst-spatial v0.0.44 h1:UeAdtnQ1DIn7jzKeLvKa1lV42QmuQlvuWFZrxyHnxzI=
github.com/whosonfirst/go-whosonfirst-spatial v0.0.44/go.mod h1:9NCCg5+gl3rOiCDc1uU6ekQQr2nHG3s7lrb22EHwfvg=
github.com/whosonfirst/go-whosonfirst-spatial v0.0.50 h1:bINDPg2RqimW2YY3vjyRjW3EFsxjMZg6wyILgNDoGW0=
github.com/whosonfirst/go-whosonfirst-spatial v0.0.50/go.mod h1:n838yr+AOlrgpUG6qldO50ehiFzHJi/7fcFnf2aFq2o=
github.com/whosonfirst/go-whosonfirst-spr/v2 v2.0.0 h1:UQ1n/uODS50mckZpXYe5GKm8XwoUUC1jRcNN8oiW2uc=
github.com/whosonfirst/go-whosonfirst-spr/v2 v2.0.0/go.mod h1:tveSSFDn8XoiCeAMarSCn769lA6e3Y0/Qi8S19Jz7Gw=
github.com/whosonfirst/go-whosonfirst-sqlite v0.1.7 h1:WZOGRgD2UmQWYOITWNpTWcccd+gbDW0oKRYDax43f6E=
Expand Down
149 changes: 0 additions & 149 deletions properties.go

This file was deleted.

7 changes: 6 additions & 1 deletion vendor/github.com/sfomuseum/go-edtf/edtf.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8d34c56

Please sign in to comment.