Skip to content

Commit

Permalink
add properties.AltGeometries method; update vendor deps
Browse files Browse the repository at this point in the history
  • Loading branch information
whosonfirst committed Aug 4, 2022
1 parent 15a39a6 commit e5a8f12
Show file tree
Hide file tree
Showing 14 changed files with 187 additions and 51 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/whosonfirst/go-whosonfirst-feature
go 1.16

require (
github.com/paulmach/orb v0.6.0
github.com/sfomuseum/go-edtf v0.3.1
github.com/paulmach/orb v0.7.1
github.com/sfomuseum/go-edtf v1.1.1
github.com/tidwall/gjson v1.14.1
github.com/whosonfirst/go-whosonfirst-flags v0.4.3
github.com/whosonfirst/go-whosonfirst-flags v0.4.4
)
15 changes: 7 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@ github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce/go.mod h1:YH+1FK
github.com/hashicorp/go-multierror v0.0.0-20171204182908-b7773ae21874/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/paulmach/orb v0.6.0 h1:QqsQkeYM3zzr3ANUHWBoo8zvK1CATO4G9pYmKoCAgnM=
github.com/paulmach/orb v0.6.0/go.mod h1:FWRlTgl88VI1RBx/MkrwWDRhQ96ctqMCh8boXhmqB/A=
github.com/paulmach/orb v0.7.1 h1:Zha++Z5OX/l168sqHK3k4z18LDvr+YAO/VjK0ReQ9rU=
github.com/paulmach/orb v0.7.1/go.mod h1:FWRlTgl88VI1RBx/MkrwWDRhQ96ctqMCh8boXhmqB/A=
github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/sfomuseum/go-edtf v0.2.3/go.mod h1:1rP0EJZ/84j3HO80vGcnG2T9MFBDAFyTNtjrr8cv3T4=
github.com/sfomuseum/go-edtf v0.3.1 h1:22DEXVvGhnpF7PD4dvpgKH0/oD8u9I+a4cXCwy1x2f4=
github.com/sfomuseum/go-edtf v0.3.1/go.mod h1:1rP0EJZ/84j3HO80vGcnG2T9MFBDAFyTNtjrr8cv3T4=
github.com/sfomuseum/go-edtf v1.1.1 h1:R5gElndHGDaK/rGSh2X+ulaLtlcHCdQA1cTzB8e9wv8=
github.com/sfomuseum/go-edtf v1.1.1/go.mod h1:1rP0EJZ/84j3HO80vGcnG2T9MFBDAFyTNtjrr8cv3T4=
github.com/sfomuseum/go-flags v0.7.0/go.mod h1:ML3DTNbF9xnjExSdS/9FtVLjIUhRU5gm/ehzISv+t2w=
github.com/tidwall/gjson v1.14.1 h1:iymTbGkQBhveq21bEvAQ81I0LEBork8BFe1CUZXdyuo=
github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/whosonfirst/go-whosonfirst-flags v0.4.3 h1:ef6IkgvYADL4kc750sl6i5hkReNq0Z6upLcqpK2CHLY=
github.com/whosonfirst/go-whosonfirst-flags v0.4.3/go.mod h1:pL17Ryo60FH8RYaQRgfu5XnxhrNRK3x+rn03TYD6Gc8=
github.com/whosonfirst/go-whosonfirst-flags v0.4.4 h1:pwUnE8btx4Po6N5+uq0IrKVF0WraY5YW3tc3saIDg3A=
github.com/whosonfirst/go-whosonfirst-flags v0.4.4/go.mod h1:C9X7vQvNR/u55AfOHYUT8o7dRACWV++ZV4B0kylnIaY=
github.com/whosonfirst/go-whosonfirst-placetypes v0.3.0/go.mod h1:ez0VFkGFbgT2/z2oi3PIuW6FewsZ2+5glyfDD79XEHk=
github.com/whosonfirst/go-whosonfirst-sources v0.1.0/go.mod h1:EUMHyGzUmqPPxlMmOp+28BFeoBdxxE0HCKRd67lkqGM=
github.com/whosonfirst/go-whosonfirst-uri v1.0.1/go.mod h1:8eaDVcc4v+HHHEDaRbApdmhPwM4/JQllw2PktvZcPVs=
github.com/whosonfirst/go-whosonfirst-uri v1.2.0/go.mod h1:CuVygTCUpMG945MMvqHyqxvc/L5YkDaMrrVpRFr7ZxY=
github.com/whosonfirst/warning v0.1.1/go.mod h1:/unEMzhB9YaMeEwTJpzLN3kM5LiSxdJhKEsf/OQhn6s=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
20 changes: 20 additions & 0 deletions properties/alt_geoms.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package properties

import (
"github.com/tidwall/gjson"
)

func AltGeometries(body []byte) ([]string, error) {

rsp := gjson.GetBytes(body, "properties.src:geom_alt")
possible := rsp.Array()

count := len(possible)
geoms := make([]string, count)

for idx, r := range possible {
geoms[idx] = r.String()
}

return geoms, nil
}
50 changes: 50 additions & 0 deletions properties/alt_geoms_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package properties

import (
"io"
"strings"
"testing"
)

var valid_geoms = strings.NewReader(`{"properties":{"src:geom_alt": ["quattroshapes","debug"] }}`)

var missing_geoms = strings.NewReader(`{"properties":{ }}`)

func TestValidAltGeoms(t *testing.T) {

body, err := io.ReadAll(valid_geoms)

if err != nil {
t.Fatalf("Failed to read data (valid), %v", err)
}

alt_geoms, err := AltGeometries(body)

if err != nil {
t.Fatalf("Expect data (valid) failed")
}

if alt_geoms[0] != "quattroshapes" {
t.Fatal("Invalid alt geometry (valid)")
}

}

func TestMissingGeoms(t *testing.T) {

body, err := io.ReadAll(missing_geoms)

if err != nil {
t.Fatalf("Failed to read data (missing), %v", err)
}

alt_geoms, err := AltGeometries(body)

if err != nil {
t.Fatalf("Expect data (valid) failed")
}

if len(alt_geoms) != 0 {
t.Fatalf("Expect data (missing) to fail")
}
}
26 changes: 26 additions & 0 deletions vendor/github.com/paulmach/orb/CHANGELOG.md

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

42 changes: 42 additions & 0 deletions vendor/github.com/sfomuseum/go-edtf/deprecated.go

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

7 changes: 0 additions & 7 deletions vendor/github.com/whosonfirst/go-whosonfirst-flags/Makefile

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

8 changes: 6 additions & 2 deletions vendor/github.com/whosonfirst/go-whosonfirst-flags/README.md

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/whosonfirst/go-whosonfirst-flags/doc.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.

19 changes: 19 additions & 0 deletions vendor/github.com/whosonfirst/go-whosonfirst-flags/flags.go

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

6 changes: 3 additions & 3 deletions vendor/github.com/whosonfirst/go-whosonfirst-flags/go.mod

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

29 changes: 4 additions & 25 deletions vendor/github.com/whosonfirst/go-whosonfirst-flags/go.sum

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

6 changes: 3 additions & 3 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# github.com/paulmach/orb v0.6.0
# github.com/paulmach/orb v0.7.1
## explicit
github.com/paulmach/orb
github.com/paulmach/orb/geojson
# github.com/sfomuseum/go-edtf v0.3.1
# github.com/sfomuseum/go-edtf v1.1.1
## explicit
github.com/sfomuseum/go-edtf
# github.com/tidwall/gjson v1.14.1
Expand All @@ -12,7 +12,7 @@ github.com/tidwall/gjson
github.com/tidwall/match
# github.com/tidwall/pretty v1.2.0
github.com/tidwall/pretty
# github.com/whosonfirst/go-whosonfirst-flags v0.4.3
# github.com/whosonfirst/go-whosonfirst-flags v0.4.4
## explicit
github.com/whosonfirst/go-whosonfirst-flags
github.com/whosonfirst/go-whosonfirst-flags/existential

0 comments on commit e5a8f12

Please sign in to comment.