Skip to content

Commit

Permalink
tests pass again; recompile data
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisaaronland committed May 11, 2022
1 parent 642dbab commit 7a353d7
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 25 deletions.
29 changes: 14 additions & 15 deletions cmd/supersede-gallery/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ package main
import (
"context"
"flag"
wof_reader "github.com/whosonfirst/go-whosonfirst-reader"
sfom_writer "github.com/sfomuseum/go-sfomuseum-writer/v2"
"github.com/tidwall/gjson"
"github.com/whosonfirst/go-reader"
"github.com/whosonfirst/go-whosonfirst-export/v2"
"github.com/whosonfirst/go-whosonfirst-id"
"github.com/whosonfirst/go-whosonfirst-id"
wof_reader "github.com/whosonfirst/go-whosonfirst-reader"
"github.com/whosonfirst/go-writer"
"log"

)

func main() {
Expand All @@ -23,13 +22,13 @@ func main() {
architecture_writer_uri := flag.String("architecture-writer-uri", "", "If empty, the value of the -architecture-reader-uri flag will be used.")

gallery_id := flag.Int64("gallery-id", 0, "The SFO Museum gallery ID to supersede")
parent_id := flag.Int64("parent-id", 0, "The SFO Museum parent ID of the new gallery")
parent_id := flag.Int64("parent-id", 0, "The SFO Museum parent ID of the new gallery")

name := flag.String("name", "", "An optional name for the new gallery. If empty the name of the previous gallery will be used.")
map_id := flag.String("map_id", "", "An optional map ID for the new gallery. If empty the name of the previous gallery will be used.")

flag.Parse()

ctx := context.Background()

if *architecture_writer_uri == "" {
Expand All @@ -53,7 +52,7 @@ func main() {
if err != nil {
log.Fatalf("Failed to create ID provider, %v", err)
}

gallery_f, err := wof_reader.LoadBytes(ctx, arch_r, *gallery_id)

if err != nil {
Expand All @@ -73,14 +72,14 @@ func main() {
}

new_updates := map[string]interface{}{
"properties.id": new_id,
"properties.wof:id": new_id,
"properties.wof:parent_id": *parent_id,
"properties.wof:hierarchy": gjson.GetBytes(parent_f, "properties.wof:hierarchy").Value(),
"properties.mz:is_current": gjson.GetBytes(parent_f, "properties.mz:is_current").Value(),
"properties.id": new_id,
"properties.wof:id": new_id,
"properties.wof:parent_id": *parent_id,
"properties.wof:hierarchy": gjson.GetBytes(parent_f, "properties.wof:hierarchy").Value(),
"properties.mz:is_current": gjson.GetBytes(parent_f, "properties.mz:is_current").Value(),
"properties.edtf:inception": gjson.GetBytes(parent_f, "properties.edtf:inception").Value(),
"properties.edtf:cessation": gjson.GetBytes(parent_f, "properties.edtf:cessation").Value(),
"properties.wof:supersedes": []int64{ *gallery_id },
"properties.wof:supersedes": []int64{*gallery_id},
}

if *name != "" {
Expand All @@ -92,7 +91,7 @@ func main() {
}

// Create and record the new gallery

_, new_gallery, err := export.AssignPropertiesIfChanged(ctx, gallery_f, new_updates)

if err != nil {
Expand All @@ -106,11 +105,11 @@ func main() {
}

old_updates := map[string]interface{}{
"properties.wof:superseded_by": []int64{ new_id },
"properties.wof:superseded_by": []int64{new_id},
}

// Now update the previous gallery

_, gallery_f, err = export.AssignPropertiesIfChanged(ctx, gallery_f, old_updates)

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion data/galleries.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/gates.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion galleries/galleries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
func TestFindCurrentGallery(t *testing.T) {

tests := map[string]int64{
"D16": 1745882461,
"2E": 1763594985, // Kadish Gallery
}

ctx := context.Background()
Expand Down
2 changes: 1 addition & 1 deletion galleries/geometry.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/paulmach/orb"
"github.com/paulmach/orb/geojson"
"github.com/paulmach/orb/planar"
wof_reader "github.com/whosonfirst/go-whosonfirst-reader"
"github.com/whosonfirst/go-reader"
wof_reader "github.com/whosonfirst/go-whosonfirst-reader"
)

// Derive a MultiPoint geoemtry for one or more gallery IDs.
Expand Down
18 changes: 13 additions & 5 deletions galleries/lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,20 @@ import (

func TestGalleriesLookup(t *testing.T) {

/*
> ./bin/lookup -lookup-uri galleries://sfomuseum 2D
1729813699#80 2020~-2021-05-25 2D Sky Terrace Platform
1729813701#81 2020~-2021-05-25 2D Sky Terrace Wall
1745882461#81 2021-05-25-2021-11-09 2D Sky Terrace Wall
1745882459#80 2021-05-25-2021-11-09 2D Sky Terrace Platform
1763588491#80 2021-11-09-.. 2D Sky Terrace Platform
1763588495#81 2021-11-09-.. 2D Sky Terrace Wall
*/

wofid_tests := map[string]int64{
"D16": 1745882461,
"2D": 1729813699, // 2020~-2021-05-25 2D Sky Terrace Platform
}

ctx := context.Background()
Expand All @@ -28,10 +40,6 @@ func TestGalleriesLookup(t *testing.T) {
t.Fatalf("Unable to find '%s', %v", code, err)
}

if len(results) != 1 {
t.Fatalf("Invalid results for '%s'", code)
}

a := results[0].(*Gallery)

if a.WhosOnFirstId != wofid {
Expand Down
2 changes: 1 addition & 1 deletion gates/gates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
func TestFindCurrentGate(t *testing.T) {

tests := map[string]int64{
"A9": 1745882385,
"A9": 1763588417,
}

ctx := context.Background()
Expand Down

0 comments on commit 7a353d7

Please sign in to comment.