Skip to content

Commit

Permalink
snapshot: update to use whosonfirst/go-whosonfirst-feature
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisaaronland committed Sep 30, 2021
1 parent 2588cb6 commit 13a147c
Show file tree
Hide file tree
Showing 25 changed files with 407 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
compile-all:
compile:
@make compile-gates
@make compile-galleries

Expand Down
2 changes: 1 addition & 1 deletion data/galleries.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion data/gates.json

Large diffs are not rendered by default.

28 changes: 19 additions & 9 deletions galleries/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"github.com/tidwall/gjson"
"github.com/whosonfirst/go-whosonfirst-feature/properties"
"github.com/whosonfirst/go-whosonfirst-iterate/emitter"
"github.com/whosonfirst/go-whosonfirst-iterate/iterator"
"github.com/whosonfirst/go-whosonfirst-uri"
Expand Down Expand Up @@ -50,18 +51,26 @@ func CompileGalleriesData(ctx context.Context, iterator_uri string, iterator_sou
return fmt.Errorf("Failed load feature from %s, %w", path, err)
}

name_rsp := gjson.GetBytes(body, "properties.wof:name")
wofid_rsp := gjson.GetBytes(body, "properties.wof:id")
sfomid_rsp := gjson.GetBytes(body, "properties.sfomuseum:gallery_id")
wof_id, err := properties.Id(body)

if err != nil {
return fmt.Errorf("Failed to derive ID for %s, %w", path, err)
}

wof_name, err := properties.Name(body)

if !name_rsp.Exists() {
return fmt.Errorf("Missing wof:name property (%s)", path)
if err != nil {
return fmt.Errorf("Failed to derive name for %s, %w", path, err)
}

if !wofid_rsp.Exists() {
return fmt.Errorf("Missing wof:id property (%s)", path)
fl, err := properties.IsCurrent(body)

if err != nil {
return fmt.Errorf("Failed to determine is current for %s, %v", path, err)
}

sfomid_rsp := gjson.GetBytes(body, "properties.sfomuseum:gallery_id")

if !sfomid_rsp.Exists() {
return fmt.Errorf("Missing sfomuseum:gallery_id property (%s)", path)
}
Expand All @@ -71,12 +80,13 @@ func CompileGalleriesData(ctx context.Context, iterator_uri string, iterator_sou
cessation_rsp := gjson.GetBytes(body, "properties.edtf:cessation")

g := &Gallery{
WhosOnFirstId: wofid_rsp.Int(),
WhosOnFirstId: wof_id,
SFOMuseumId: sfomid_rsp.Int(),
MapId: mapid_rsp.String(),
Name: name_rsp.String(),
Name: wof_name,
Inception: inception_rsp.String(),
Cessation: cessation_rsp.String(),
IsCurrent: fl.Flag(),
}

mu.Lock()
Expand Down
2 changes: 1 addition & 1 deletion galleries/galleries.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Gallery struct {
// The (EDTF) cessation date for the gallery
Cessation string `json:"edtf:cessation"`
// A Who's On First "existential" (`KnownUnknownFlag`) flag signaling the gate's status
// IsCurrent string `json:"mz:is_current"`
IsCurrent int64 `json:"mz:is_current"`
}

// String() will return the name of the gallery.
Expand Down
28 changes: 18 additions & 10 deletions gates/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package gates
import (
"context"
"fmt"
"github.com/sfomuseum/go-sfomuseum-geojson/feature"
"github.com/whosonfirst/go-whosonfirst-geojson-v2/properties/whosonfirst"
"github.com/whosonfirst/go-whosonfirst-feature/properties"
"github.com/whosonfirst/go-whosonfirst-iterate/emitter"
"github.com/whosonfirst/go-whosonfirst-iterate/iterator"
"github.com/whosonfirst/go-whosonfirst-uri"
Expand Down Expand Up @@ -45,25 +44,34 @@ func CompileGatesData(ctx context.Context, iterator_uri string, iterator_sources
return nil
}

f, err := feature.LoadFeatureFromReader(fh)
body, err := io.ReadAll(fh)

if err != nil {
return fmt.Errorf("Failed load feature from %s, %w", path, err)
return fmt.Errorf("Failed to read %s, %w", path, err)
}

wof_id := whosonfirst.Id(f)
name := whosonfirst.Name(f)
wof_id, err := properties.Id(body)

fl, err := whosonfirst.IsCurrent(f)
if err != nil {
return fmt.Errorf("Failed to derive ID for %s, %w", path, err)
}

wof_name, err := properties.Name(body)

if err != nil {
return fmt.Errorf("Failed to derive name for %s, %w", path, err)
}

fl, err := properties.IsCurrent(body)

if err != nil {
return fmt.Errorf("Failed to derive is current status for %s, %v", path, err)
return fmt.Errorf("Failed to determine is current for %s, %v", path, err)
}

g := &Gate{
WhosOnFirstId: wof_id,
Name: name,
IsCurrent: fl.StringFlag(),
Name: wof_name,
IsCurrent: fl.Flag(),
}

mu.Lock()
Expand Down
4 changes: 2 additions & 2 deletions gates/gates.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ type Gate struct {
// The name of this gate.
Name string `json:"wof:name"`
// A Who's On First "existential" (`KnownUnknownFlag`) flag signaling the gate's status
IsCurrent string `json:"mz:is_current"`
IsCurrent int64 `json:"mz:is_current"`
}

// String() will return the name of the gate.
func (g *Gate) String() string {
return fmt.Sprintf("%d %s (%s)", g.WhosOnFirstId, g.Name, g.IsCurrent)
return fmt.Sprintf("%d %s (%d)", g.WhosOnFirstId, g.Name, g.IsCurrent)
}
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ go 1.16
require (
github.com/aaronland/go-roster v0.0.2
github.com/paulmach/orb v0.2.2
github.com/sfomuseum/go-sfomuseum-geojson v0.1.3
github.com/sfomuseum/go-sfomuseum-geojson v0.1.3 // indirect
github.com/sfomuseum/go-sfomuseum-reader v0.0.1
github.com/tidwall/gjson v1.9.1
github.com/whosonfirst/go-reader v0.9.0
github.com/whosonfirst/go-whosonfirst-geojson-v2 v0.16.3
github.com/whosonfirst/go-whosonfirst-feature v0.0.3
github.com/whosonfirst/go-whosonfirst-geojson-v2 v0.16.3 // indirect
github.com/whosonfirst/go-whosonfirst-iterate v1.2.0
github.com/whosonfirst/go-whosonfirst-uri v1.1.0
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
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-edtf v0.3.0 h1:D9YI8FUR9mGge2aVFLIJE1IF+6KDKZddXCftPjUPnSo=
github.com/sfomuseum/go-edtf v0.3.0/go.mod h1:1rP0EJZ/84j3HO80vGcnG2T9MFBDAFyTNtjrr8cv3T4=
github.com/sfomuseum/go-flags v0.7.0/go.mod h1:ML3DTNbF9xnjExSdS/9FtVLjIUhRU5gm/ehzISv+t2w=
github.com/sfomuseum/go-sfomuseum-geojson v0.1.2 h1:rZM4b1+LrdP3Yzrsoed7Ror33gThictCpgqLmhESfdA=
github.com/sfomuseum/go-sfomuseum-geojson v0.1.2/go.mod h1:khGRObq7bqsMqr4VWrw0NmZQmTyV82YEYK90w7SF9mk=
Expand Down Expand Up @@ -60,6 +62,8 @@ github.com/whosonfirst/go-reader v0.9.0/go.mod h1:6byB+UfZFNLYFqgsC/EKxTnKY8ahNg
github.com/whosonfirst/go-whosonfirst-cli v0.1.0/go.mod h1:Edy+amD+fMq1QS1yxB3u8maA8I93q/LG7JRNh+fsdfc=
github.com/whosonfirst/go-whosonfirst-crawl v0.2.1 h1:nNG7r7/4MaII/NM8Df2oqgfgVNBDoIKlseleoX1vw1Q=
github.com/whosonfirst/go-whosonfirst-crawl v0.2.1/go.mod h1:MTD1TCgAkXlAtysPU98ylrz9Y5+ZCfRrsrBnRyiH/t8=
github.com/whosonfirst/go-whosonfirst-feature v0.0.3 h1:WfwLjlOxbLdIxGF4RoeVCByHn8tRDnMFqr+UOnVOTmo=
github.com/whosonfirst/go-whosonfirst-feature v0.0.3/go.mod h1:7ezV1UK9GwPInW7s4Mf16qxZsvKuzCYOa4oiw/ksNLo=
github.com/whosonfirst/go-whosonfirst-flags v0.1.0/go.mod h1:bovMiQphaVhqemXFmNVf9Ts0tqnWtzHRFMUSKX+zTE8=
github.com/whosonfirst/go-whosonfirst-flags v0.2.0/go.mod h1:ECd0AJJZIlybmjTGB9z+CPz9pSiMTwxur7fPKmDnoqI=
github.com/whosonfirst/go-whosonfirst-flags v0.4.2 h1:HWjy/0MfAQMdCj4M9hi3LAITgK/D+cuDWGHP37mFeZo=
Expand Down
4 changes: 4 additions & 0 deletions vendor/github.com/sfomuseum/go-edtf/README.md

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

3 changes: 3 additions & 0 deletions vendor/github.com/sfomuseum/go-edtf/calendar/calendar.go

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

2 changes: 2 additions & 0 deletions vendor/github.com/sfomuseum/go-edtf/common/common.go

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

1 change: 1 addition & 0 deletions vendor/github.com/sfomuseum/go-edtf/common/exponential.go

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

2 changes: 2 additions & 0 deletions vendor/github.com/sfomuseum/go-edtf/doc.go

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

86 changes: 86 additions & 0 deletions 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.

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

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

4 changes: 4 additions & 0 deletions vendor/github.com/sfomuseum/go-edtf/parser/parser.go

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

2 changes: 1 addition & 1 deletion vendor/github.com/sfomuseum/go-edtf/re/re.go

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

Loading

0 comments on commit 13a147c

Please sign in to comment.