From fe7c013b05d23ad3493023898593767895839ecc Mon Sep 17 00:00:00 2001 From: thisisaaronland Date: Wed, 29 Sep 2021 19:04:13 -0700 Subject: [PATCH] update vendor deps --- go.mod | 2 - go.sum | 2 + lookup.go | 8 - .../mmcloughlin/geohash/.travis.yml | 12 +- .../github.com/mmcloughlin/geohash/README.md | 26 +- .../mmcloughlin/geohash/README.tmpl | 2 +- .../github.com/mmcloughlin/geohash/base32.go | 10 +- .../github.com/mmcloughlin/geohash/geohash.go | 33 -- .../sfomuseum/go-edtf/calendar/calendar.go | 74 --- .../sfomuseum/go-edtf/common/common.go | 2 - .../sfomuseum/go-edtf/common/exponential.go | 26 - .../sfomuseum/go-edtf/common/range.go | 538 ------------------ .../sfomuseum/go-edtf/common/span.go | 284 --------- .../sfomuseum/go-edtf/common/time.go | 56 -- .../sfomuseum/go-edtf/common/year.go | 13 - .../sfomuseum/go-edtf/common/ymd.go | 157 ----- .../sfomuseum/go-edtf/level0/date.go | 47 -- .../sfomuseum/go-edtf/level0/date_and_time.go | 104 ---- .../sfomuseum/go-edtf/level0/level0.go | 50 -- .../sfomuseum/go-edtf/level0/tests.go | 128 ----- .../sfomuseum/go-edtf/level0/time_interval.go | 49 -- .../go-edtf/level1/extended_interval.go | 141 ----- .../level1/letter_prefixed_calendar_year.go | 69 --- .../sfomuseum/go-edtf/level1/level1.go | 86 --- .../go-edtf/level1/negative_calendar_year.go | 44 -- .../go-edtf/level1/qualified_date.go | 46 -- .../sfomuseum/go-edtf/level1/season.go | 193 ------- .../sfomuseum/go-edtf/level1/tests.go | 205 ------- .../go-edtf/level1/unspecified_digits.go | 53 -- .../go-edtf/level2/exponential_year.go | 67 --- .../sfomuseum/go-edtf/level2/interval.go | 55 -- .../sfomuseum/go-edtf/level2/level2.go | 95 ---- .../sfomuseum/go-edtf/level2/qualification.go | 103 ---- .../go-edtf/level2/set_representation.go | 243 -------- .../go-edtf/level2/significant_digits.go | 138 ----- .../go-edtf/level2/sub_year_grouping.go | 204 ------- .../sfomuseum/go-edtf/level2/tests.go | 230 -------- .../go-edtf/level2/unspecified_digit.go | 67 --- .../sfomuseum/go-edtf/parser/parser.go | 119 ---- .../sfomuseum/go-edtf/parser/tests.go | 25 - .../github.com/sfomuseum/go-edtf/re/common.go | 22 - .../github.com/sfomuseum/go-edtf/re/level0.go | 29 - .../github.com/sfomuseum/go-edtf/re/level1.go | 44 -- .../github.com/sfomuseum/go-edtf/re/level2.go | 49 -- vendor/github.com/sfomuseum/go-edtf/re/re.go | 69 --- .../sfomuseum/go-edtf/tests/tests.go | 438 -------------- .../go-whosonfirst-geojson-v2/feature/edtf.go | 41 -- .../feature/geojson.go | 15 +- .../feature/whosonfirst.go | 75 +-- .../feature/whosonfirst_alt.go | 15 +- .../go-whosonfirst-geojson-v2/geojson.go | 2 +- .../geometry/polygon.go | 4 +- .../go-whosonfirst-geojson-v2/go.mod | 13 +- .../go-whosonfirst-geojson-v2/go.sum | 25 - .../properties/whosonfirst/whosonfirst.go | 67 +-- .../go-whosonfirst-spr/{v2 => }/.gitignore | 0 .../go-whosonfirst-spr/{v2 => }/LICENSE | 0 .../go-whosonfirst-spr/{v2 => }/Makefile | 0 .../whosonfirst/go-whosonfirst-spr/README.md | 53 ++ .../whosonfirst/go-whosonfirst-spr/go.mod | 5 + .../go-whosonfirst-spr/{v2 => }/go.sum | 10 - .../go-whosonfirst-spr/{v2 => }/spr.go | 4 - .../go-whosonfirst-spr/v2/README.md | 71 --- .../whosonfirst/go-whosonfirst-spr/v2/go.mod | 8 - vendor/modules.txt | 20 +- 65 files changed, 103 insertions(+), 4782 deletions(-) delete mode 100644 vendor/github.com/sfomuseum/go-edtf/calendar/calendar.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/common/common.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/common/exponential.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/common/range.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/common/span.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/common/time.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/common/year.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/common/ymd.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/level0/date.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/level0/date_and_time.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/level0/level0.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/level0/tests.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/level0/time_interval.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/level1/extended_interval.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/level1/letter_prefixed_calendar_year.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/level1/level1.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/level1/negative_calendar_year.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/level1/qualified_date.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/level1/season.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/level1/tests.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/level1/unspecified_digits.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/level2/exponential_year.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/level2/interval.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/level2/level2.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/level2/qualification.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/level2/set_representation.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/level2/significant_digits.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/level2/sub_year_grouping.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/level2/tests.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/level2/unspecified_digit.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/parser/parser.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/parser/tests.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/re/common.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/re/level0.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/re/level1.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/re/level2.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/re/re.go delete mode 100644 vendor/github.com/sfomuseum/go-edtf/tests/tests.go delete mode 100644 vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/feature/edtf.go rename vendor/github.com/whosonfirst/go-whosonfirst-spr/{v2 => }/.gitignore (100%) rename vendor/github.com/whosonfirst/go-whosonfirst-spr/{v2 => }/LICENSE (100%) rename vendor/github.com/whosonfirst/go-whosonfirst-spr/{v2 => }/Makefile (100%) create mode 100644 vendor/github.com/whosonfirst/go-whosonfirst-spr/README.md create mode 100644 vendor/github.com/whosonfirst/go-whosonfirst-spr/go.mod rename vendor/github.com/whosonfirst/go-whosonfirst-spr/{v2 => }/go.sum (66%) rename vendor/github.com/whosonfirst/go-whosonfirst-spr/{v2 => }/spr.go (88%) delete mode 100644 vendor/github.com/whosonfirst/go-whosonfirst-spr/v2/README.md delete mode 100644 vendor/github.com/whosonfirst/go-whosonfirst-spr/v2/go.mod diff --git a/go.mod b/go.mod index a0465db..97bd283 100644 --- a/go.mod +++ b/go.mod @@ -5,12 +5,10 @@ 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 // 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-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 ) diff --git a/go.sum b/go.sum index a7ae7d3..f2bd3ed 100644 --- a/go.sum +++ b/go.sum @@ -14,6 +14,7 @@ github.com/hashicorp/go-multierror v0.0.0-20171204182908-b7773ae21874/go.mod h1: github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= 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/mmcloughlin/geohash v0.9.0 h1:FihR004p/aE1Sju6gcVq5OLDqGcMnpBY+8moBqIsVOs= github.com/mmcloughlin/geohash v0.9.0/go.mod h1:oNZxQo5yWJh0eMQEP/8hwQuVx9Z9tjwFUqcTB1SmG0c= github.com/mmcloughlin/geohash v0.10.0 h1:9w1HchfDfdeLc+jFEf/04D27KP7E2QmpDu52wPbJWRE= github.com/mmcloughlin/geohash v0.10.0/go.mod h1:oNZxQo5yWJh0eMQEP/8hwQuVx9Z9tjwFUqcTB1SmG0c= @@ -70,6 +71,7 @@ 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-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-geojson-v2 v0.14.1 h1:Bp5gwvIZXkfGhS4Kv1Cs8R5PNo1EipISPOsDDPSrKQQ= github.com/whosonfirst/go-whosonfirst-geojson-v2 v0.14.1/go.mod h1:UkzipFE8gZC9NU1PLIE4DUwjFHOlafkoNxd2Ng0ZIjc= github.com/whosonfirst/go-whosonfirst-geojson-v2 v0.16.3 h1:EaLfTJqWj7q3bVCNil+F9QtVylxiyWNlo09ZEUDtf+E= github.com/whosonfirst/go-whosonfirst-geojson-v2 v0.16.3/go.mod h1:R3GximAGJWLCITU2eh3I5Vtyze/usjOl5LTGQCDI89Y= diff --git a/lookup.go b/lookup.go index d58a0c7..9812659 100644 --- a/lookup.go +++ b/lookup.go @@ -11,14 +11,6 @@ type Lookup interface { Append(context.Context, interface{}) error } -// TBD... -type LookupResponse interface { - WhosOnFirstId() int64 - SFOMuseumId() int64 - String() string - Raw() interface{} -} - var lookup_roster roster.Roster type LookupInitializationFunc func(ctx context.Context, uri string) (Lookup, error) diff --git a/vendor/github.com/mmcloughlin/geohash/.travis.yml b/vendor/github.com/mmcloughlin/geohash/.travis.yml index 20e9c48..0332114 100644 --- a/vendor/github.com/mmcloughlin/geohash/.travis.yml +++ b/vendor/github.com/mmcloughlin/geohash/.travis.yml @@ -1,9 +1,15 @@ language: go go: -- 1.3.x -- 1.12.x -- 1.13.x - 1.x +- 1.3.x +- 1.4.x +- 1.5.x +- 1.6.x +- 1.7.x +- 1.8.x +- 1.9.x +- 1.10.x +- 1.11.x before_install: - go get github.com/axw/gocov/gocov - go get github.com/mattn/goveralls diff --git a/vendor/github.com/mmcloughlin/geohash/README.md b/vendor/github.com/mmcloughlin/geohash/README.md index 05d7cc6..0a34e3e 100644 --- a/vendor/github.com/mmcloughlin/geohash/README.md +++ b/vendor/github.com/mmcloughlin/geohash/README.md @@ -3,7 +3,7 @@ Go [geohash](https://en.wikipedia.org/wiki/Geohash) library offering encoding and decoding for string and integer geohashes. -[![go.dev Reference](https://img.shields.io/badge/doc-reference-007d9b?logo=go&style=flat-square)](https://pkg.go.dev/github.com/mmcloughlin/geohash) +[![GoDoc Reference](http://img.shields.io/badge/godoc-reference-5272B4.svg?style=flat-square)](http://godoc.org/github.com/mmcloughlin/geohash) [![Build status](https://img.shields.io/travis/mmcloughlin/geohash.svg?style=flat-square)](https://travis-ci.org/mmcloughlin/geohash) [![Coverage](https://img.shields.io/coveralls/mmcloughlin/geohash.svg?style=flat-square)](https://coveralls.io/r/mmcloughlin/geohash) [![Go Report Card](https://goreportcard.com/badge/github.com/mmcloughlin/geohash?style=flat-square)](https://goreportcard.com/report/github.com/mmcloughlin/geohash) @@ -24,23 +24,6 @@ import "github.com/mmcloughlin/geohash" ## Usage -#### func ConvertIntToString - -```go -func ConvertIntToString(hash uint64, chars uint) string -``` -ConvertIntToString converts an integer geohash to the equivalent string geohash -with chars characters. The provided integer geohash is interpreted to have -5*chars bits of precision. - -#### func ConvertStringToInt - -```go -func ConvertStringToInt(hash string) (uint64, uint) -``` -ConvertStringToInt converts a string geohash to the equivalent integer geohash. -Returns the integer hash and its precision. - #### func Decode ```go @@ -150,13 +133,6 @@ func NeighborsIntWithPrecision(hash uint64, bits uint) []uint64 NeighborsIntWithPrecision returns a slice of uint64s that correspond to the provided hash's neighbors at the given precision. -#### func Validate - -```go -func Validate(hash string) error -``` -Validate the string geohash. - #### type Box ```go diff --git a/vendor/github.com/mmcloughlin/geohash/README.tmpl b/vendor/github.com/mmcloughlin/geohash/README.tmpl index de4204d..6f0fe4b 100644 --- a/vendor/github.com/mmcloughlin/geohash/README.tmpl +++ b/vendor/github.com/mmcloughlin/geohash/README.tmpl @@ -3,7 +3,7 @@ Go [geohash](https://en.wikipedia.org/wiki/Geohash) library offering encoding and decoding for string and integer geohashes. -[![go.dev Reference](https://img.shields.io/badge/doc-reference-007d9b?logo=go&style=flat-square)](https://pkg.go.dev/github.com/mmcloughlin/geohash) +[![GoDoc Reference](http://img.shields.io/badge/godoc-reference-5272B4.svg?style=flat-square)](http://godoc.org/github.com/mmcloughlin/geohash) [![Build status](https://img.shields.io/travis/mmcloughlin/geohash.svg?style=flat-square)](https://travis-ci.org/mmcloughlin/geohash) [![Coverage](https://img.shields.io/coveralls/mmcloughlin/geohash.svg?style=flat-square)](https://coveralls.io/r/mmcloughlin/geohash) [![Go Report Card](https://goreportcard.com/badge/github.com/mmcloughlin/geohash?style=flat-square)](https://goreportcard.com/report/github.com/mmcloughlin/geohash) diff --git a/vendor/github.com/mmcloughlin/geohash/base32.go b/vendor/github.com/mmcloughlin/geohash/base32.go index af2fd94..916b272 100644 --- a/vendor/github.com/mmcloughlin/geohash/base32.go +++ b/vendor/github.com/mmcloughlin/geohash/base32.go @@ -1,8 +1,5 @@ package geohash -// invalid is a placeholder for invalid character decodings. -const invalid = 0xff - // encoding encapsulates an encoding defined by a given base32 alphabet. type encoding struct { encode string @@ -15,7 +12,7 @@ func newEncoding(encoder string) *encoding { e := new(encoding) e.encode = encoder for i := 0; i < len(e.decode); i++ { - e.decode[i] = invalid + e.decode[i] = 0xff } for i := 0; i < len(encoder); i++ { e.decode[encoder[i]] = byte(i) @@ -23,11 +20,6 @@ func newEncoding(encoder string) *encoding { return e } -// ValidByte reports whether b is part of the encoding. -func (e *encoding) ValidByte(b byte) bool { - return e.decode[b] != invalid -} - // Decode string into bits of a 64-bit word. The string s may be at most 12 // characters. func (e *encoding) Decode(s string) uint64 { diff --git a/vendor/github.com/mmcloughlin/geohash/geohash.go b/vendor/github.com/mmcloughlin/geohash/geohash.go index 314fd4b..8563304 100644 --- a/vendor/github.com/mmcloughlin/geohash/geohash.go +++ b/vendor/github.com/mmcloughlin/geohash/geohash.go @@ -3,8 +3,6 @@ package geohash import ( - "errors" - "fmt" "math" ) @@ -138,23 +136,6 @@ func BoundingBoxInt(hash uint64) Box { return BoundingBoxIntWithPrecision(hash, 64) } -// Validate the string geohash. -func Validate(hash string) error { - // Check length. - if 5*len(hash) > 64 { - return errors.New("too long") - } - - // Check characters. - for i := 0; i < len(hash); i++ { - if !base32encoding.ValidByte(hash[i]) { - return fmt.Errorf("invalid character %q", hash[i]) - } - } - - return nil -} - // Decode the string geohash to a (lat, lng) point. func Decode(hash string) (lat, lng float64) { box := BoundingBox(hash) @@ -179,20 +160,6 @@ func DecodeInt(hash uint64) (lat, lng float64) { return DecodeIntWithPrecision(hash, 64) } -// ConvertStringToInt converts a string geohash to the equivalent integer -// geohash. Returns the integer hash and its precision. -func ConvertStringToInt(hash string) (uint64, uint) { - return base32encoding.Decode(hash), uint(5 * len(hash)) -} - -// ConvertIntToString converts an integer geohash to the equivalent string -// geohash with chars characters. The provided integer geohash is interpreted -// to have 5*chars bits of precision. -func ConvertIntToString(hash uint64, chars uint) string { - enc := base32encoding.Encode(hash) - return enc[12-chars:] -} - // Neighbors returns a slice of geohash strings that correspond to the provided // geohash's neighbors. func Neighbors(hash string) []string { diff --git a/vendor/github.com/sfomuseum/go-edtf/calendar/calendar.go b/vendor/github.com/sfomuseum/go-edtf/calendar/calendar.go deleted file mode 100644 index 75d3866..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/calendar/calendar.go +++ /dev/null @@ -1,74 +0,0 @@ -// package calendar provides common date and calendar methods. -package calendar - -import ( - "errors" - "fmt" - "strconv" - "strings" - "time" -) - -// Calculate the number of days in a month for a 'YYYYMM' formatted string. -func DaysInMonthWithString(yyyymm string) (int, error) { - - ym := strings.Split(yyyymm, "-") - - var str_yyyy string - var str_mm string - - switch len(ym) { - case 3: - str_yyyy = fmt.Sprintf("-%s", ym[1]) - str_mm = ym[2] - case 2: - str_yyyy = ym[0] - str_mm = ym[1] - default: - return 0, errors.New("Invalid YYYYMM string") - } - - yyyy, err := strconv.Atoi(str_yyyy) - - if err != nil { - return 0, err - } - - mm, err := strconv.Atoi(str_mm) - - if err != nil { - return 0, err - } - - return DaysInMonth(yyyy, mm) -} - -// Calculate the number of days in a month given a year and month in numeric form. -func DaysInMonth(yyyy int, mm int) (int, error) { - - // Because Go can't parse dates < 0... - - if yyyy < 0 { - yyyy = yyyy - (yyyy * 2) - } - - next_yyyy := yyyy - next_mm := mm + 1 - - if mm >= 12 { - next_mm = yyyy + 1 - next_mm = 1 - } - - next_ymd := fmt.Sprintf("%04d-%02d-01", next_yyyy, next_mm) - next_t, err := time.Parse("2006-01-02", next_ymd) - - if err != nil { - return 0, err - } - - mm_t := next_t.AddDate(0, 0, -1) - dd := mm_t.Day() - - return dd, nil -} diff --git a/vendor/github.com/sfomuseum/go-edtf/common/common.go b/vendor/github.com/sfomuseum/go-edtf/common/common.go deleted file mode 100644 index 3b6fdbb..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/common/common.go +++ /dev/null @@ -1,2 +0,0 @@ -// package common provide common methods across EDTF level definitions. -package common diff --git a/vendor/github.com/sfomuseum/go-edtf/common/exponential.go b/vendor/github.com/sfomuseum/go-edtf/common/exponential.go deleted file mode 100644 index 0acaab7..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/common/exponential.go +++ /dev/null @@ -1,26 +0,0 @@ -package common - -import ( - "github.com/sfomuseum/go-edtf" - "math/big" -) - -// Parse a string in exponential notation in to a year value in numeric form. -func ParseExponentialNotation(notation string) (int, error) { - - flt, _, err := big.ParseFloat(notation, 10, 0, big.ToNearestEven) - - if err != nil { - return 0, err - } - - var i = new(big.Int) - yyyy, _ := flt.Int(i) - - if yyyy.Int64() > int64(edtf.MAX_YEARS) || yyyy.Int64() < int64(0-edtf.MAX_YEARS) { - return 0, edtf.Unsupported("exponential notation", notation) - } - - yyyy_i := int(yyyy.Int64()) - return yyyy_i, nil -} diff --git a/vendor/github.com/sfomuseum/go-edtf/common/range.go b/vendor/github.com/sfomuseum/go-edtf/common/range.go deleted file mode 100644 index 14de55f..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/common/range.go +++ /dev/null @@ -1,538 +0,0 @@ -package common - -import ( - "fmt" - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/calendar" - "github.com/sfomuseum/go-edtf/re" - "strconv" - "strings" -) - -type Qualifier struct { - Value string - Type string -} - -func (q *Qualifier) String() string { - return fmt.Sprintf("[%T] Value: '%s' Type: '%s'", q, q.Value, q.Type) -} - -// StringWhatever is a bad naming convention - please make me better -// (20210105/thisisaaronland) - -type StringDate struct { - Year string - Month string - Day string -} - -func (d *StringDate) String() string { - return fmt.Sprintf("[[%T] Y: '%s' M: '%s' D: '%s']", d, d.Year, d.Month, d.Day) -} - -func (d *StringDate) Equals(other_d *StringDate) bool { - - if d.Year != other_d.Year { - return false - } - - if d.Month != other_d.Month { - return false - } - - if d.Day != other_d.Day { - return false - } - - return true -} - -type StringRange struct { - Start *StringDate - End *StringDate - Precision edtf.Precision - Uncertain edtf.Precision - Approximate edtf.Precision - EDTF string -} - -func (r *StringRange) String() string { - return fmt.Sprintf("[[%T] Start: '%s' End: '%s']", r, r.Start, r.End) -} - -func StringRangeFromYMD(edtf_str string) (*StringRange, error) { - - precision := edtf.NONE - uncertain := edtf.NONE - approximate := edtf.NONE - - parts := re.YMD.FindStringSubmatch(edtf_str) - count := len(parts) - - if count != 4 { - return nil, edtf.Invalid("date", edtf_str) - } - - yyyy := parts[1] - mm := parts[2] - dd := parts[3] - - // fmt.Printf("DATE Y: '%s' M: '%s' D: '%s'\n", yyyy, mm, dd) - - if yyyy != "" && mm != "" && dd != "" { - precision.AddFlag(edtf.DAY) - } else if yyyy != "" && mm != "" { - precision.AddFlag(edtf.MONTH) - } else if yyyy != "" { - precision.AddFlag(edtf.YEAR) - } - - // fmt.Println("PRECISION -", edtf_str, precision) - - var yyyy_q *Qualifier - var mm_q *Qualifier - var dd_q *Qualifier - - if yyyy != "" { - - y, q, err := parseYMDComponent(yyyy) - - if err != nil { - return nil, err - } - - yyyy = y - yyyy_q = q - } - - if mm != "" { - - m, q, err := parseYMDComponent(mm) - - if err != nil { - return nil, err - } - - mm = m - mm_q = q - } - - if dd != "" { - - d, q, err := parseYMDComponent(dd) - - if err != nil { - return nil, err - } - - dd = d - dd_q = q - } - - // fmt.Println("YYYY", yyyy_q) - // fmt.Println("MM", mm_q) - // fmt.Println("DD", dd_q) - - if dd_q != nil && dd_q.Type == "Group" { - - // precision.AddFlag(edtf.YEAR) - // precision.AddFlag(edtf.MONTH) - // precision.AddFlag(edtf.DAY) - - switch dd_q.Value { - case edtf.UNCERTAIN: - uncertain.AddFlag(edtf.YEAR) - uncertain.AddFlag(edtf.MONTH) - uncertain.AddFlag(edtf.DAY) - case edtf.APPROXIMATE: - approximate.AddFlag(edtf.YEAR) - approximate.AddFlag(edtf.MONTH) - approximate.AddFlag(edtf.DAY) - case edtf.UNCERTAIN_AND_APPROXIMATE: - uncertain.AddFlag(edtf.YEAR) - uncertain.AddFlag(edtf.MONTH) - uncertain.AddFlag(edtf.DAY) - approximate.AddFlag(edtf.YEAR) - approximate.AddFlag(edtf.MONTH) - approximate.AddFlag(edtf.DAY) - default: - // pass - } - - } - - if mm_q != nil && mm_q.Type == "Group" { - - // precision.AddFlag(edtf.YEAR) - // precision.AddFlag(edtf.MONTH) - - switch mm_q.Value { - case edtf.UNCERTAIN: - uncertain.AddFlag(edtf.YEAR) - uncertain.AddFlag(edtf.MONTH) - case edtf.APPROXIMATE: - approximate.AddFlag(edtf.YEAR) - approximate.AddFlag(edtf.MONTH) - case edtf.UNCERTAIN_AND_APPROXIMATE: - uncertain.AddFlag(edtf.YEAR) - uncertain.AddFlag(edtf.MONTH) - approximate.AddFlag(edtf.YEAR) - approximate.AddFlag(edtf.MONTH) - default: - // pass - } - - } - - if yyyy_q != nil && yyyy_q.Type == "Group" { - - // precision.AddFlag(edtf.YEAR) - - switch yyyy_q.Value { - case edtf.UNCERTAIN: - uncertain.AddFlag(edtf.YEAR) - case edtf.APPROXIMATE: - approximate.AddFlag(edtf.YEAR) - case edtf.UNCERTAIN_AND_APPROXIMATE: - uncertain.AddFlag(edtf.YEAR) - approximate.AddFlag(edtf.YEAR) - default: - // pass - } - - } - - if yyyy_q != nil && yyyy_q.Type == "Individual" { - - switch yyyy_q.Value { - case edtf.UNCERTAIN: - uncertain.AddFlag(edtf.YEAR) - case edtf.APPROXIMATE: - approximate.AddFlag(edtf.YEAR) - case edtf.UNCERTAIN_AND_APPROXIMATE: - uncertain.AddFlag(edtf.YEAR) - approximate.AddFlag(edtf.YEAR) - default: - // pass - } - } - - if mm_q != nil && mm_q.Type == "Individual" { - - switch mm_q.Value { - case edtf.UNCERTAIN: - uncertain.AddFlag(edtf.MONTH) - case edtf.APPROXIMATE: - approximate.AddFlag(edtf.MONTH) - case edtf.UNCERTAIN_AND_APPROXIMATE: - uncertain.AddFlag(edtf.MONTH) - approximate.AddFlag(edtf.MONTH) - default: - // pass - } - } - - if dd_q != nil && dd_q.Type == "Individual" { - - switch dd_q.Value { - case edtf.UNCERTAIN: - uncertain.AddFlag(edtf.DAY) - case edtf.APPROXIMATE: - approximate.AddFlag(edtf.DAY) - case edtf.UNCERTAIN_AND_APPROXIMATE: - uncertain.AddFlag(edtf.DAY) - approximate.AddFlag(edtf.DAY) - default: - // pass - } - } - - start_yyyy := yyyy - start_mm := mm - start_dd := dd - - end_yyyy := start_yyyy - end_mm := start_mm - end_dd := start_dd - - // fmt.Println("PRECISION 0", edtf_str, precision) - - if !strings.HasSuffix(yyyy, "X") { - - precision = edtf.NONE - precision.AddFlag(edtf.YEAR) - - } else { - - start_m := int64(0) - end_m := int64(0) - - start_c := int64(0) - end_c := int64(900) - - start_d := int64(0) - end_d := int64(90) - - start_y := int64(0) - end_y := int64(9) - - if string(yyyy[0]) == "X" { - return nil, edtf.NotImplemented("date", edtf_str) - } else { - - m, err := strconv.ParseInt(string(yyyy[0]), 10, 32) - - if err != nil { - return nil, err - } - - start_m = m * 1000 - end_m = start_m - - precision = edtf.NONE - precision.AddFlag(edtf.MILLENIUM) - } - - if string(yyyy[1]) != "X" { - - c, err := strconv.ParseInt(string(yyyy[1]), 10, 32) - - if err != nil { - return nil, err - } - - start_c = c * 100 - end_c = start_c - - precision = edtf.NONE - precision.AddFlag(edtf.CENTURY) - } - - if string(yyyy[2]) != "X" { - - d, err := strconv.ParseInt(string(yyyy[2]), 10, 32) - - if err != nil { - return nil, err - } - - start_d = d * 10 - end_d = start_d - - precision = edtf.NONE - precision.AddFlag(edtf.DECADE) - } - - if string(yyyy[3]) != "X" { - - y, err := strconv.ParseInt(string(yyyy[3]), 10, 32) - - if err != nil { - return nil, err - } - - start_y = y * 1 - end_y = start_y - - precision = edtf.NONE - precision.AddFlag(edtf.YEAR) - } - - start_ymd := start_m + start_c + start_d + start_y - end_ymd := end_m + end_c + end_d + end_y - - // fmt.Printf("OMG '%s' '%d' '%d' '%d' '%d' '%d'\n", yyyy, start_m, start_c, start_d, start_y, start_ymd) - // fmt.Printf("WTF '%s' '%d' '%d' '%d' '%d' '%d'\n", yyyy, end_m, end_c, end_d, end_y, end_ymd) - - start_yyyy = strconv.FormatInt(start_ymd, 10) - end_yyyy = strconv.FormatInt(end_ymd, 10) - - } - - // fmt.Println("PRECISION 1", edtf_str, precision) - - if !strings.HasSuffix(mm, "X") { - - if mm != "" && precision == edtf.NONE { - precision = edtf.NONE - precision.AddFlag(edtf.MONTH) - } - - } else { - - // this does not account for 1985-24, etc. - - if strings.HasPrefix(mm, "X") { - start_mm = "01" - end_mm = "12" - - } else { - start_mm = "10" - end_mm = "12" - - precision = edtf.NONE - precision.AddFlag(edtf.MONTH) - } - } - - // fmt.Println("PRECISION 2", edtf_str, precision) - - if !strings.HasSuffix(dd, "X") { - - if dd != "" && precision == edtf.NONE { - precision = edtf.NONE - precision.AddFlag(edtf.DAY) - } - - } else { - - switch string(dd[0]) { - case "X": - start_dd = "01" - end_dd = "" - case "1": - start_dd = "10" - end_dd = "19" - case "2": - start_dd = "20" - end_dd = "29" - case "3": - start_dd = "30" - end_dd = "" - default: - return nil, edtf.Invalid("date", edtf_str) - } - } - - // the fact that I need to do this tells me that all of the precision - // logic around significant digits needs to be refactored but this will - // do for now... (20210106/thisisaaronland) - - if dd == "XX" && mm == "XX" { - precision = edtf.NONE - precision.AddFlag(edtf.YEAR) - } else if dd == "XX" { - precision = edtf.NONE - precision.AddFlag(edtf.MONTH) - } else { - } - - // fmt.Println("PRECISION 3", edtf_str, precision) - - if start_mm == "" { - start_mm = "01" - } - - if start_dd == "" { - start_dd = "01" - } - - if end_mm == "" { - end_mm = "12" - } - - if end_dd == "" { - - yyyymm := fmt.Sprintf("%s-%s", end_yyyy, end_mm) - - dd, err := calendar.DaysInMonthWithString(yyyymm) - - if err != nil { - return nil, err - } - - end_dd = strconv.Itoa(int(dd)) - } - - start := &StringDate{ - Year: start_yyyy, - Month: start_mm, - Day: start_dd, - } - - end := &StringDate{ - Year: end_yyyy, - Month: end_mm, - Day: end_dd, - } - - r := &StringRange{ - Start: start, - End: end, - Precision: precision, - Uncertain: uncertain, - Approximate: approximate, - EDTF: edtf_str, - } - - return r, nil -} - -func EmptyDateRange() *edtf.DateRange { - - lower_d := &edtf.Date{} - upper_d := &edtf.Date{} - - dt := &edtf.DateRange{ - Lower: lower_d, - Upper: upper_d, - } - - return dt -} - -func UnknownDateRange() *edtf.DateRange { - - dr := EmptyDateRange() - dr.Lower.Unknown = true - dr.Upper.Unknown = true - return dr -} - -func OpenDateRange() *edtf.DateRange { - - dr := EmptyDateRange() - dr.Lower.Open = true - dr.Upper.Open = true - return dr -} - -func parseYMDComponent(date string) (string, *Qualifier, error) { - - m := re.QualifiedIndividual.FindStringSubmatch(date) - - if len(m) == 3 { - - var q *Qualifier - - if m[1] != "" { - - q = &Qualifier{ - Type: "Individual", - Value: m[1], - } - } - - return m[2], q, nil - } - - m = re.QualifiedGroup.FindStringSubmatch(date) - - if len(m) == 3 { - - var q *Qualifier - - if m[2] != "" { - - q = &Qualifier{ - Type: "Group", - Value: m[2], - } - } - - return m[1], q, nil - } - - return "", nil, edtf.Invalid("date", date) -} diff --git a/vendor/github.com/sfomuseum/go-edtf/common/span.go b/vendor/github.com/sfomuseum/go-edtf/common/span.go deleted file mode 100644 index 89b2957..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/common/span.go +++ /dev/null @@ -1,284 +0,0 @@ -package common - -import ( - "github.com/sfomuseum/go-edtf" - "strings" - "time" -) - -func DateSpanFromEDTF(edtf_str string) (*edtf.DateSpan, error) { - - parts := strings.Split(edtf_str, "/") - count := len(parts) - - is_multi := false - - var left_edtf string - var right_edtf string - - switch count { - case 2: - left_edtf = parts[0] - right_edtf = parts[1] - is_multi = true - case 1: - left_edtf = parts[0] - default: - return nil, edtf.Invalid("date span", edtf_str) - } - - if !is_multi { - return dateSpanFromYMD(left_edtf) - } - - left_span, err := dateSpanFromEDTF(left_edtf) - - if err != nil { - return nil, err - } - - right_span, err := dateSpanFromEDTF(right_edtf) - - if err != nil { - return nil, err - } - - left_span.Start.Upper = left_span.End.Upper - - right_span.End.Lower = right_span.Start.Lower - - left_span.End = right_span.End - - return left_span, nil -} - -// specifically from one half of a FOO/BAR string - -func dateSpanFromEDTF(edtf_str string) (*edtf.DateSpan, error) { - - var span *edtf.DateSpan - - switch edtf_str { - case edtf.UNKNOWN: - - span = UnknownDateSpan() - - span.Start.EDTF = edtf_str - span.End.EDTF = edtf_str - - case edtf.OPEN: - - span = OpenDateSpan() - - span.Start.EDTF = edtf_str - span.End.EDTF = edtf_str - - default: - - ds, err := dateSpanFromYMD(edtf_str) - - if err != nil { - return nil, err - } - - span = ds - } - - return span, nil -} - -func dateSpanFromYMD(edtf_str string) (*edtf.DateSpan, error) { - - str_range, err := StringRangeFromYMD(edtf_str) - - if err != nil { - return nil, err - } - - start := str_range.Start - end := str_range.End - - start_ymd, err := YMDFromStringDate(start) - - if err != nil { - return nil, err - } - - end_ymd, err := YMDFromStringDate(end) - - if err != nil { - return nil, err - } - - var start_lower_t *time.Time - var start_upper_t *time.Time - - var end_lower_t *time.Time - var end_upper_t *time.Time - - // fmt.Println("START", start) - // fmt.Println("END", end) - - if end.Equals(start) { - - st, err := TimeWithYMD(start_ymd, edtf.HMS_LOWER) - - if err != nil { - return nil, err - } - - et, err := TimeWithYMD(end_ymd, edtf.HMS_UPPER) - - if err != nil { - return nil, err - } - - start_lower_t = st - start_upper_t = st - - end_lower_t = et - end_upper_t = et - - } else { - - sl, err := TimeWithYMD(start_ymd, edtf.HMS_LOWER) - - if err != nil { - return nil, err - } - - su, err := TimeWithYMD(start_ymd, edtf.HMS_UPPER) - - if err != nil { - return nil, err - } - - el, err := TimeWithYMD(end_ymd, edtf.HMS_LOWER) - - if err != nil { - return nil, err - } - - eu, err := TimeWithYMD(end_ymd, edtf.HMS_UPPER) - - if err != nil { - return nil, err - } - - start_lower_t = sl - start_upper_t = su - end_lower_t = el - end_upper_t = eu - - /* - fmt.Printf("START LOWER %v\n", sl) - fmt.Printf("START UPPER %v\n", su) - fmt.Printf("END LOWER %v\n", el) - fmt.Printf("END UPPER %v\n", eu) - */ - } - - // - - start_lower := &edtf.Date{ - YMD: start_ymd, - Uncertain: str_range.Uncertain, - Approximate: str_range.Approximate, - Precision: str_range.Precision, - } - - start_upper := &edtf.Date{ - YMD: start_ymd, - Uncertain: str_range.Uncertain, - Approximate: str_range.Approximate, - Precision: str_range.Precision, - } - - end_lower := &edtf.Date{ - YMD: end_ymd, - Uncertain: str_range.Uncertain, - Approximate: str_range.Approximate, - Precision: str_range.Precision, - } - - end_upper := &edtf.Date{ - YMD: end_ymd, - Uncertain: str_range.Uncertain, - Approximate: str_range.Approximate, - Precision: str_range.Precision, - } - - if start_lower_t != nil { - start_lower.SetTime(start_lower_t) - } - - if start_upper_t != nil { - start_upper.SetTime(start_upper_t) - } - - if end_lower_t != nil { - end_lower.SetTime(end_lower_t) - } - - if end_upper_t != nil { - end_upper.SetTime(end_upper_t) - } - - start_range := &edtf.DateRange{ - EDTF: edtf_str, - Lower: start_lower, - Upper: start_upper, - } - - end_range := &edtf.DateRange{ - EDTF: edtf_str, - Lower: end_lower, - Upper: end_upper, - } - - sp := &edtf.DateSpan{ - Start: start_range, - End: end_range, - } - - return sp, nil -} - -func EmptyDateSpan() *edtf.DateSpan { - - start := EmptyDateRange() - end := EmptyDateRange() - - sp := &edtf.DateSpan{ - Start: start, - End: end, - } - - return sp -} - -func UnknownDateSpan() *edtf.DateSpan { - - start := UnknownDateRange() - end := UnknownDateRange() - - sp := &edtf.DateSpan{ - Start: start, - End: end, - } - - return sp -} - -func OpenDateSpan() *edtf.DateSpan { - - start := OpenDateRange() - end := OpenDateRange() - - sp := &edtf.DateSpan{ - Start: start, - End: end, - } - - return sp -} diff --git a/vendor/github.com/sfomuseum/go-edtf/common/time.go b/vendor/github.com/sfomuseum/go-edtf/common/time.go deleted file mode 100644 index 6ea7c9c..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/common/time.go +++ /dev/null @@ -1,56 +0,0 @@ -package common - -import ( - "fmt" - "github.com/sfomuseum/go-edtf" - "time" -) - -func TimeWithYMDString(str_yyyy string, str_mm string, str_dd string, hms string) (*time.Time, error) { - - ymd, err := YMDFromStrings(str_yyyy, str_mm, str_dd) - - if err != nil { - return nil, err - } - - return TimeWithYMD(ymd, hms) -} - -func TimeWithYMD(ymd *edtf.YMD, hms string) (*time.Time, error) { - - // See this? If yyyy < 0 then we are dealing with a BCE year - // which can't be parsed by the time.Parse() function so we're - // going to set a flag and convert yyyy to a positive number. - // After we've created time.Time instances below, we'll check to see - // whether the flag is set and if it is then we'll update the - // year to be BCE again. One possible gotcha in this approach is - // that the calendar.DaysInMonth method may return wonky results - // since it will calculating things on a CE year rather than a BCE - // year. (20201230/thisisaaronland) - - yyyy := ymd.Year - mm := ymd.Month - dd := ymd.Day - - is_bce := false - - if yyyy < 0 { - is_bce = true - yyyy = FlipYear(yyyy) - } - - t_str := fmt.Sprintf("%04d-%02d-%02dT%s", yyyy, mm, dd, hms) - - t, err := time.Parse("2006-01-02T15:04:05", t_str) - - if err != nil { - return nil, err - } - - if is_bce { - t = TimeToBCE(t) - } - - return &t, nil -} diff --git a/vendor/github.com/sfomuseum/go-edtf/common/year.go b/vendor/github.com/sfomuseum/go-edtf/common/year.go deleted file mode 100644 index 16e8463..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/common/year.go +++ /dev/null @@ -1,13 +0,0 @@ -package common - -import ( - "time" -) - -func FlipYear(yyyy int) int { - return yyyy - (yyyy * 2) -} - -func TimeToBCE(t time.Time) time.Time { - return t.AddDate(-2*t.Year(), 0, 0) -} diff --git a/vendor/github.com/sfomuseum/go-edtf/common/ymd.go b/vendor/github.com/sfomuseum/go-edtf/common/ymd.go deleted file mode 100644 index 69480f5..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/common/ymd.go +++ /dev/null @@ -1,157 +0,0 @@ -package common - -import ( - "errors" - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/calendar" - "strconv" - "strings" -) - -func YMDFromStringDate(d *StringDate) (*edtf.YMD, error) { - return YMDFromStrings(d.Year, d.Month, d.Day) -} - -func YMDFromString(str_ymd string) (*edtf.YMD, error) { - - yyyy := "" - mm := "" - dd := "" - - parts := strings.Split(str_ymd, "-") - - switch len(parts) { - case 4: - yyyy = "-" + parts[1] - mm = parts[2] - dd = parts[3] - case 3: - yyyy = parts[0] - mm = parts[1] - dd = parts[2] - case 2: - yyyy = parts[0] - mm = parts[1] - case 1: - yyyy = parts[0] - default: - return nil, errors.New("Invalid YMD string") - } - - return YMDFromStrings(yyyy, mm, dd) -} - -func YMDFromStrings(str_yyyy string, str_mm string, str_dd string) (*edtf.YMD, error) { - - if str_yyyy == "" { - return nil, errors.New("Missing year") - } - - if str_mm == "" && str_dd != "" { - return nil, errors.New("Missing month") - } - - yyyy, err := strconv.Atoi(str_yyyy) - - if err != nil { - return nil, err - } - - // See this? If yyyy < 0 then we are dealing with a BCE year - // which can't be parsed by the time.Parse() function so we're - // going to set a flag and convert yyyy to a positive number. - // After we've created time.Time instances below, we'll check to see - // whether the flag is set and if it is then we'll update the - // year to be BCE again. One possible gotcha in this approach is - // that the calendar.DaysInMonth method may return wonky results - // since it will calculating things on a CE year rather than a BCE - // year. (20201230/thisisaaronland) - - is_bce := false - - if yyyy < 0 { - is_bce = true - yyyy = FlipYear(yyyy) - } - - mm := 0 - dd := 0 - - if str_mm != "" { - - m, err := strconv.Atoi(str_mm) - - if err != nil { - return nil, err - } - - mm = m - } - - if str_dd != "" { - - d, err := strconv.Atoi(str_dd) - - if err != nil { - return nil, err - } - - dd = d - } - - if yyyy == 0 { - return nil, errors.New("Missing year") - } - - if yyyy > edtf.MAX_YEARS { - return nil, edtf.Unsupported("year", strconv.Itoa(yyyy)) - } - - if mm == 0 && dd != 0 { - return nil, errors.New("Missing month") - } - - if mm == 0 { - mm = 1 - } else { - - if mm > 12 { - return nil, errors.New("Invalid month") - } - } - - if dd == 0 { - - days, err := calendar.DaysInMonth(yyyy, mm) - - if err != nil { - return nil, err - } - - dd = int(days) - - } else { - - days, err := calendar.DaysInMonth(yyyy, mm) - - if err != nil { - return nil, err - } - - if dd > days { - return nil, errors.New("Invalid days for month") - } - } - - if is_bce { - yyyy = FlipYear(yyyy) - } - - ymd := &edtf.YMD{ - Year: yyyy, - Month: mm, - Day: dd, - } - - return ymd, nil -} diff --git a/vendor/github.com/sfomuseum/go-edtf/level0/date.go b/vendor/github.com/sfomuseum/go-edtf/level0/date.go deleted file mode 100644 index a8c9493..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/level0/date.go +++ /dev/null @@ -1,47 +0,0 @@ -package level0 - -import ( - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/common" - "github.com/sfomuseum/go-edtf/re" -) - -/* - -Date - - complete representation: [year][“-”][month][“-”][day] - Example 1 ‘1985-04-12’ refers to the calendar date 1985 April 12th with day precision. - reduced precision for year and month: [year][“-”][month] - Example 2 ‘1985-04’ refers to the calendar month 1985 April with month precision. - reduced precision for year: [year] - Example 3 ‘1985’ refers to the calendar year 1985 with year precision. - -*/ - -func IsDate(edtf_str string) bool { - return re.Date.MatchString(edtf_str) -} - -func ParseDate(edtf_str string) (*edtf.EDTFDate, error) { - - if !re.Date.MatchString(edtf_str) { - return nil, edtf.Invalid(DATE, edtf_str) - } - - sp, err := common.DateSpanFromEDTF(edtf_str) - - if err != nil { - return nil, err - } - - d := &edtf.EDTFDate{ - Start: sp.Start, - End: sp.End, - EDTF: edtf_str, - Level: LEVEL, - Feature: DATE, - } - - return d, nil -} diff --git a/vendor/github.com/sfomuseum/go-edtf/level0/date_and_time.go b/vendor/github.com/sfomuseum/go-edtf/level0/date_and_time.go deleted file mode 100644 index 2fc5227..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/level0/date_and_time.go +++ /dev/null @@ -1,104 +0,0 @@ -package level0 - -import ( - "fmt" - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/common" - "github.com/sfomuseum/go-edtf/re" - "strings" - "time" -) - -/* - -Date and Time - - [date][“T”][time] - Complete representations for calendar date and (local) time of day - Example 1 ‘1985-04-12T23:20:30’ refers to the date 1985 April 12th at 23:20:30 local time. - [dateI][“T”][time][“Z”] - Complete representations for calendar date and UTC time of day - Example 2 ‘1985-04-12T23:20:30Z’ refers to the date 1985 April 12th at 23:20:30 UTC time. - [dateI][“T”][time][shiftHour] - Date and time with timeshift in hours (only) - Example 3 ‘1985-04-12T23:20:30-04’ refers to the date 1985 April 12th time of day 23:20:30 with time shift of 4 hours behind UTC. - [dateI][“T”][time][shiftHourMinute] - Date and time with timeshift in hours and minutes - Example 4 ‘1985-04-12T23:20:30+04:30’ refers to the date 1985 April 12th, time of day 23:20:30 with time shift of 4 hours and 30 minutes ahead of UTC. - -*/ - -func IsDateAndTime(edtf_str string) bool { - return re.DateAndTime.MatchString(edtf_str) -} - -func ParseDateAndTime(edtf_str string) (*edtf.EDTFDate, error) { - - m := re.DateAndTime.FindStringSubmatch(edtf_str) - - if len(m) != 12 { - return nil, edtf.Invalid(DATE_AND_TIME, edtf_str) - } - - t_fmt := "2006-01-02T15:04:05" - - if m[7] == "Z" { - t_fmt = "2006-01-02T15:04:05Z" - } - - if m[8] == "-" || m[8] == "+" { - - if strings.HasPrefix(m[10], ":") { - t_fmt = "2006-01-02T15:04:05-07:00" - } else { - t_fmt = "2006-01-02T15:04:05-07" - } - } - - is_bce := false - - if strings.HasPrefix(edtf_str, "-") { - is_bce = true - - t_fmt = fmt.Sprintf("-%s", t_fmt) - } - - t, err := time.Parse(t_fmt, edtf_str) - - if err != nil { - return nil, err - } - - t = t.UTC() - - if is_bce { - t = common.TimeToBCE(t) - } - - upper_date := &edtf.Date{} - - lower_date := &edtf.Date{} - - upper_date.SetTime(&t) - lower_date.SetTime(&t) - - start := &edtf.DateRange{ - Lower: lower_date, - Upper: lower_date, - } - - end := &edtf.DateRange{ - Lower: upper_date, - Upper: upper_date, - } - - d := &edtf.EDTFDate{ - Start: start, - End: end, - EDTF: edtf_str, - Level: LEVEL, - Feature: DATE_AND_TIME, - } - - return d, nil -} diff --git a/vendor/github.com/sfomuseum/go-edtf/level0/level0.go b/vendor/github.com/sfomuseum/go-edtf/level0/level0.go deleted file mode 100644 index dc3f867..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/level0/level0.go +++ /dev/null @@ -1,50 +0,0 @@ -package level0 - -import ( - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/re" -) - -const LEVEL int = 0 - -const DATE string = "Date" -const DATE_AND_TIME string = "Date and Time" -const TIME_INTERVAL string = "Time Interval" - -func IsLevel0(edtf_str string) bool { - return re.Level0.MatchString(edtf_str) -} - -func Matches(edtf_str string) (string, error) { - - if IsDate(edtf_str) { - return DATE, nil - } - - if IsDateAndTime(edtf_str) { - return DATE_AND_TIME, nil - } - - if IsTimeInterval(edtf_str) { - return TIME_INTERVAL, nil - } - - return "", edtf.Invalid("Invalid Level 0 string", edtf_str) -} - -func ParseString(edtf_str string) (*edtf.EDTFDate, error) { - - if IsDate(edtf_str) { - return ParseDate(edtf_str) - } - - if IsDateAndTime(edtf_str) { - return ParseDateAndTime(edtf_str) - } - - if IsTimeInterval(edtf_str) { - return ParseTimeInterval(edtf_str) - } - - return nil, edtf.Invalid("Invalid Level 0 string", edtf_str) -} diff --git a/vendor/github.com/sfomuseum/go-edtf/level0/tests.go b/vendor/github.com/sfomuseum/go-edtf/level0/tests.go deleted file mode 100644 index 1715b04..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/level0/tests.go +++ /dev/null @@ -1,128 +0,0 @@ -package level0 - -import ( - "github.com/sfomuseum/go-edtf/tests" -) - -var Tests map[string]map[string]*tests.TestResult = map[string]map[string]*tests.TestResult{ - DATE: map[string]*tests.TestResult{ - "1985-04-12": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1985-04-12T00:00:00Z", - StartUpperTimeRFC3339: "1985-04-12T00:00:00Z", - EndLowerTimeRFC3339: "1985-04-12T23:59:59Z", - EndUpperTimeRFC3339: "1985-04-12T23:59:59Z", - }), - "1985-04": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1985-04-01T00:00:00Z", - StartUpperTimeRFC3339: "1985-04-01T23:59:59Z", - EndLowerTimeRFC3339: "1985-04-30T00:00:00Z", - EndUpperTimeRFC3339: "1985-04-30T23:59:59Z", - }), - "1985": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1985-01-01T00:00:00Z", - StartUpperTimeRFC3339: "1985-01-01T23:59:59Z", - EndLowerTimeRFC3339: "1985-12-31T00:00:00Z", - EndUpperTimeRFC3339: "1985-12-31T23:59:59Z", - }), - "-0400": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "-0400-01-01T00:00:00Z", - StartUpperTimeRFC3339: "-0400-01-01T23:59:59Z", - EndLowerTimeRFC3339: "-0400-12-31T00:00:00Z", - EndUpperTimeRFC3339: "-0400-12-31T23:59:59Z", - }), - "-1200-06": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "-1200-06-01T00:00:00Z", - StartUpperTimeRFC3339: "-1200-06-01T23:59:59Z", - EndLowerTimeRFC3339: "-1200-06-30T00:00:00Z", - EndUpperTimeRFC3339: "-1200-06-30T23:59:59Z", - }), - }, - DATE_AND_TIME: map[string]*tests.TestResult{ - "1985-04-12T23:20:30": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1985-04-12T23:20:30Z", - StartUpperTimeRFC3339: "1985-04-12T23:20:30Z", - EndLowerTimeRFC3339: "1985-04-12T23:20:30Z", - EndUpperTimeRFC3339: "1985-04-12T23:20:30Z", - }), - "2021-09-20T21:14:00Z": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2021-09-20T21:14:00Z", - StartUpperTimeRFC3339: "2021-09-20T21:14:00Z", - EndLowerTimeRFC3339: "2021-09-20T21:14:00Z", - EndUpperTimeRFC3339: "2021-09-20T21:14:00Z", - }), - "1985-04-12T23:20:30Z": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1985-04-12T23:20:30Z", - StartUpperTimeRFC3339: "1985-04-12T23:20:30Z", - EndLowerTimeRFC3339: "1985-04-12T23:20:30Z", - EndUpperTimeRFC3339: "1985-04-12T23:20:30Z", - }), - "1985-04-12T23:20:30-04": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1985-04-13T03:20:30Z", - StartUpperTimeRFC3339: "1985-04-13T03:20:30Z", - EndLowerTimeRFC3339: "1985-04-13T03:20:30Z", - EndUpperTimeRFC3339: "1985-04-13T03:20:30Z", - }), - "1985-04-12T23:20:30+04:30": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1985-04-12T18:50:30Z", - StartUpperTimeRFC3339: "1985-04-12T18:50:30Z", - EndLowerTimeRFC3339: "1985-04-12T18:50:30Z", - EndUpperTimeRFC3339: "1985-04-12T18:50:30Z", - }), - "-1972-04-12T23:20:28": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "-1972-04-12T23:20:28Z", - StartUpperTimeRFC3339: "-1972-04-12T23:20:28Z", - EndLowerTimeRFC3339: "-1972-04-12T23:20:28Z", - EndUpperTimeRFC3339: "-1972-04-12T23:20:28Z", - }), - }, - TIME_INTERVAL: map[string]*tests.TestResult{ - "1964/2008": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1964-01-01T00:00:00Z", - StartUpperTimeRFC3339: "1964-12-31T23:59:59Z", - EndLowerTimeRFC3339: "2008-01-01T00:00:00Z", - EndUpperTimeRFC3339: "2008-12-31T23:59:59Z", - }), - "2004-06/2006-08": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2004-06-01T00:00:00Z", - StartUpperTimeRFC3339: "2004-06-30T23:59:59Z", - EndLowerTimeRFC3339: "2006-08-01T00:00:00Z", - EndUpperTimeRFC3339: "2006-08-31T23:59:59Z", - }), - "2004-02-01/2005-02-08": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2004-02-01T00:00:00Z", - StartUpperTimeRFC3339: "2004-02-01T23:59:59Z", - EndLowerTimeRFC3339: "2005-02-08T00:00:00Z", - EndUpperTimeRFC3339: "2005-02-08T23:59:59Z", - }), - "2004-02-01/2005-02": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2004-02-01T00:00:00Z", - StartUpperTimeRFC3339: "2004-02-01T23:59:59Z", - EndLowerTimeRFC3339: "2005-02-01T00:00:00Z", - EndUpperTimeRFC3339: "2005-02-28T23:59:59Z", - }), - "2004-02-01/2005": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2004-02-01T00:00:00Z", - StartUpperTimeRFC3339: "2004-02-01T23:59:59Z", - EndLowerTimeRFC3339: "2005-01-01T00:00:00Z", - EndUpperTimeRFC3339: "2005-12-31T23:59:59Z", - }), - "2005/2020-02": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2005-01-01T00:00:00Z", - StartUpperTimeRFC3339: "2005-12-31T23:59:59Z", - EndLowerTimeRFC3339: "2020-02-01T00:00:00Z", - EndUpperTimeRFC3339: "2020-02-29T23:59:59Z", // leap year - }), - "-0200/0200": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "-0200-01-01T00:00:00Z", - StartUpperTimeRFC3339: "-0200-12-31T23:59:59Z", - EndLowerTimeRFC3339: "0200-01-01T00:00:00Z", - EndUpperTimeRFC3339: "0200-12-31T23:59:59Z", - }), - "-1200-06/0200-05-02": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "-1200-06-01T00:00:00Z", - StartUpperTimeRFC3339: "-1200-06-30T23:59:59Z", - EndLowerTimeRFC3339: "0200-05-02T00:00:00Z", - EndUpperTimeRFC3339: "0200-05-02T23:59:59Z", - }), - }, -} diff --git a/vendor/github.com/sfomuseum/go-edtf/level0/time_interval.go b/vendor/github.com/sfomuseum/go-edtf/level0/time_interval.go deleted file mode 100644 index b8d0a13..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/level0/time_interval.go +++ /dev/null @@ -1,49 +0,0 @@ -package level0 - -import ( - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/common" - "github.com/sfomuseum/go-edtf/re" -) - -/* - -Time Interval - -EDTF Level 0 adopts representations of a time interval where both the start and end are dates: start and end date only; that is, both start and duration, and duration and end, are excluded. Time of day is excluded. - - Example 1 ‘1964/2008’ is a time interval with calendar year precision, beginning sometime in 1964 and ending sometime in 2008. - Example 2 ‘2004-06/2006-08’ is a time interval with calendar month precision, beginning sometime in June 2004 and ending sometime in August of 2006. - Example 3 ‘2004-02-01/2005-02-08’ is a time interval with calendar day precision, beginning sometime on February 1, 2004 and ending sometime on February 8, 2005. - Example 4 ‘2004-02-01/2005-02’ is a time interval beginning sometime on February 1, 2004 and ending sometime in February 2005. Since the start endpoint precision (day) is different than that of the end endpoint (month) the precision of the time interval at large is undefined. - Example 5 ‘2004-02-01/2005’ is a time interval beginning sometime on February 1, 2004 and ending sometime in 2005. The start endpoint has calendar day precision and the end endpoint has calendar year precision. Similar to the previous example, the precision of the time interval at large is undefined. - Example 6 ‘2005/2006-02’ is a time interval beginning sometime in 2005 and ending sometime in February 2006. - -*/ - -func IsTimeInterval(edtf_str string) bool { - return re.TimeInterval.MatchString(edtf_str) -} - -func ParseTimeInterval(edtf_str string) (*edtf.EDTFDate, error) { - - if !re.TimeInterval.MatchString(edtf_str) { - return nil, edtf.Invalid(TIME_INTERVAL, edtf_str) - } - - sp, err := common.DateSpanFromEDTF(edtf_str) - - if err != nil { - return nil, err - } - - d := &edtf.EDTFDate{ - Start: sp.Start, - End: sp.End, - EDTF: edtf_str, - Level: LEVEL, - Feature: TIME_INTERVAL, - } - - return d, nil -} diff --git a/vendor/github.com/sfomuseum/go-edtf/level1/extended_interval.go b/vendor/github.com/sfomuseum/go-edtf/level1/extended_interval.go deleted file mode 100644 index a80e971..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/level1/extended_interval.go +++ /dev/null @@ -1,141 +0,0 @@ -package level1 - -import ( - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/common" - "github.com/sfomuseum/go-edtf/re" -) - -/* - -Extended Interval (L1) - - A null string may be used for the start or end date when it is unknown. - Double-dot (“..”) may be used when either the start or end date is not specified, either because there is none or for any other reason. - A modifier may appear at the end of the date to indicate "uncertain" and/or "approximate" - -Open end time interval - - Example 1 ‘1985-04-12/..’ - interval starting at 1985 April 12th with day precision; end open - Example 2 ‘1985-04/..’ - interval starting at 1985 April with month precision; end open - Example 3 ‘1985/..’ - interval starting at year 1985 with year precision; end open - -Open start time interval - - Example 4 ‘../1985-04-12’ - interval with open start; ending 1985 April 12th with day precision - Example 5 ‘../1985-04’ - interval with open start; ending 1985 April with month precision - Example 6 ‘../1985’ - interval with open start; ending at year 1985 with year precision - -Time interval with unknown end - - Example 7 ‘1985-04-12/’ - interval starting 1985 April 12th with day precision; end unknown - Example 8 ‘1985-04/’ - interval starting 1985 April with month precision; end unknown - Example 9 ‘1985/’ - interval starting year 1985 with year precision; end unknown - -Time interval with unknown start - - Example 10 ‘/1985-04-12’ - interval with unknown start; ending 1985 April 12th with day precision - Example 11 ‘/1985-04’ - interval with unknown start; ending 1985 April with month precision - Example 12 ‘/1985’ - interval with unknown start; ending year 1985 with year precision - -*/ - -func IsExtendedInterval(edtf_str string) bool { - - if re.IntervalEnd.MatchString(edtf_str) { - return true - } - - if re.IntervalStart.MatchString(edtf_str) { - return true - } - - return true -} - -func ParseExtendedInterval(edtf_str string) (*edtf.EDTFDate, error) { - - if re.IntervalStart.MatchString(edtf_str) { - return ParseExtendedIntervalStart(edtf_str) - } - - if re.IntervalEnd.MatchString(edtf_str) { - return ParseExtendedIntervalEnd(edtf_str) - } - - return nil, edtf.Invalid(EXTENDED_INTERVAL, edtf_str) -} - -func ParseExtendedIntervalStart(edtf_str string) (*edtf.EDTFDate, error) { - - /* - - START 5 ../1985-04-12,..,1985,04,12 - START 5 ../1985-04,..,1985,04, - START 5 ../1985,..,1985,, - START 5 /1985-04-12,,1985,04,12 - START 5 /1985-04,,1985,04, - START 5 /1985,,1985,, - - */ - - if !re.IntervalStart.MatchString(edtf_str) { - return nil, edtf.Invalid(EXTENDED_INTERVAL_START, edtf_str) - } - - sp, err := common.DateSpanFromEDTF(edtf_str) - - if err != nil { - return nil, err - } - - d := &edtf.EDTFDate{ - Start: sp.Start, - End: sp.End, - EDTF: edtf_str, - Level: LEVEL, - Feature: EXTENDED_INTERVAL_START, - } - - return d, nil -} - -func ParseExtendedIntervalEnd(edtf_str string) (*edtf.EDTFDate, error) { - - /* - END 5 1985/..,1985,,,.. - END 5 1985/,1985,,, - */ - - if !re.IntervalEnd.MatchString(edtf_str) { - return nil, edtf.Invalid(EXTENDED_INTERVAL_END, edtf_str) - } - - sp, err := common.DateSpanFromEDTF(edtf_str) - - if err != nil { - return nil, err - } - - d := &edtf.EDTFDate{ - Start: sp.Start, - End: sp.End, - EDTF: edtf_str, - Level: LEVEL, - Feature: EXTENDED_INTERVAL_END, - } - - return d, nil -} diff --git a/vendor/github.com/sfomuseum/go-edtf/level1/letter_prefixed_calendar_year.go b/vendor/github.com/sfomuseum/go-edtf/level1/letter_prefixed_calendar_year.go deleted file mode 100644 index 8677768..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/level1/letter_prefixed_calendar_year.go +++ /dev/null @@ -1,69 +0,0 @@ -package level1 - -import ( - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/common" - "github.com/sfomuseum/go-edtf/re" - "strings" -) - -/* - -'Y' may be used at the beginning of the date string to signify that the date is a year, when (and only when) the year exceeds four digits, i.e. for years later than 9999 or earlier than -9999. - - Example 1 'Y170000002' is the year 170000002 - Example 2 'Y-170000002' is the year -170000002 - -*/ - -func IsLetterPrefixedCalendarYear(edtf_str string) bool { - return re.LetterPrefixedCalendarYear.MatchString(edtf_str) -} - -func ParseLetterPrefixedCalendarYear(edtf_str string) (*edtf.EDTFDate, error) { - - m := re.LetterPrefixedCalendarYear.FindStringSubmatch(edtf_str) - - if len(m) != 2 { - return nil, edtf.Invalid(LETTER_PREFIXED_CALENDAR_YEAR, edtf_str) - } - - // Years must be in the range 0000..9999. - // https://golang.org/pkg/time/#Parse - - // sigh.... - // fmt.Printf("DEBUG %v\n", start.Add(time.Hour * 8760 * 1000)) - // ./prog.go:21:54: constant 31536000000000000000 overflows time.Duration - - // common.DateSpanFromEDTF needs to be updated to simply assign a valid - // *edtf.YMD element and leave *time.Time blank when creating *edtf.Date - // instances (20210105/thisisaaronland) - - yyyy := m[1] - - max_length := 4 - - if strings.HasPrefix(yyyy, "-") { - max_length = 5 - } - - if len(yyyy) > max_length { - return nil, edtf.Unsupported(LETTER_PREFIXED_CALENDAR_YEAR, edtf_str) - } - - sp, err := common.DateSpanFromEDTF(yyyy) - - if err != nil { - return nil, err - } - - d := &edtf.EDTFDate{ - Start: sp.Start, - End: sp.End, - EDTF: edtf_str, - Level: LEVEL, - Feature: LETTER_PREFIXED_CALENDAR_YEAR, - } - - return d, nil -} diff --git a/vendor/github.com/sfomuseum/go-edtf/level1/level1.go b/vendor/github.com/sfomuseum/go-edtf/level1/level1.go deleted file mode 100644 index d85c82e..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/level1/level1.go +++ /dev/null @@ -1,86 +0,0 @@ -package level1 - -import ( - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/re" -) - -const LEVEL int = 1 - -const LETTER_PREFIXED_CALENDAR_YEAR string = "Letter-prefixed calendar year" -const SEASON string = "Seasons" -const QUALIFIED_DATE string = "Qualification of a date (complete)" -const UNSPECIFIED_DIGITS string = "Unspecified digit(s) from the right" -const EXTENDED_INTERVAL string = "Extended Interval" -const EXTENDED_INTERVAL_START string = "Extended Interval (Start)" -const EXTENDED_INTERVAL_END string = "Extended Interval (End)" -const NEGATIVE_CALENDAR_YEAR string = "Negative calendar year" - -func IsLevel1(edtf_str string) bool { - return re.Level1.MatchString(edtf_str) -} - -func Matches(edtf_str string) (string, error) { - - if IsLetterPrefixedCalendarYear(edtf_str) { - return LETTER_PREFIXED_CALENDAR_YEAR, nil - } - - if IsSeason(edtf_str) { - return SEASON, nil - } - - if IsQualifiedDate(edtf_str) { - return QUALIFIED_DATE, nil - } - - if IsUnspecifiedDigits(edtf_str) { - return UNSPECIFIED_DIGITS, nil - } - - if IsNegativeCalendarYear(edtf_str) { - return NEGATIVE_CALENDAR_YEAR, nil - } - - if IsExtendedInterval(edtf_str) { - - if re.IntervalStart.MatchString(edtf_str) { - return EXTENDED_INTERVAL_START, nil - } - - if re.IntervalEnd.MatchString(edtf_str) { - return EXTENDED_INTERVAL_END, nil - } - } - - return "", edtf.Invalid("Invalid Level 1 string", edtf_str) -} - -func ParseString(edtf_str string) (*edtf.EDTFDate, error) { - - if IsLetterPrefixedCalendarYear(edtf_str) { - return ParseLetterPrefixedCalendarYear(edtf_str) - } - - if IsSeason(edtf_str) { - return ParseSeason(edtf_str) - } - - if IsQualifiedDate(edtf_str) { - return ParseQualifiedDate(edtf_str) - } - - if IsUnspecifiedDigits(edtf_str) { - return ParseUnspecifiedDigits(edtf_str) - } - - if IsNegativeCalendarYear(edtf_str) { - return ParseNegativeCalendarYear(edtf_str) - } - - if IsExtendedInterval(edtf_str) { - return ParseExtendedInterval(edtf_str) - } - - return nil, edtf.Invalid("Invalid or unsupported Level 1 EDTF string", edtf_str) -} diff --git a/vendor/github.com/sfomuseum/go-edtf/level1/negative_calendar_year.go b/vendor/github.com/sfomuseum/go-edtf/level1/negative_calendar_year.go deleted file mode 100644 index c3e9c4d..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/level1/negative_calendar_year.go +++ /dev/null @@ -1,44 +0,0 @@ -package level1 - -import ( - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/common" - "github.com/sfomuseum/go-edtf/re" -) - -/* - - Negative calendar year - - Example 1 ‘-1985’ - -Note: ISO 8601 Part 1 does not support negative year. - -*/ - -func IsNegativeCalendarYear(edtf_str string) bool { - return re.NegativeYear.MatchString(edtf_str) -} - -func ParseNegativeCalendarYear(edtf_str string) (*edtf.EDTFDate, error) { - - if !re.NegativeYear.MatchString(edtf_str) { - return nil, edtf.Invalid(NEGATIVE_CALENDAR_YEAR, edtf_str) - } - - sp, err := common.DateSpanFromEDTF(edtf_str) - - if err != nil { - return nil, err - } - - d := &edtf.EDTFDate{ - Start: sp.Start, - End: sp.End, - EDTF: edtf_str, - Level: LEVEL, - Feature: NEGATIVE_CALENDAR_YEAR, - } - - return d, nil -} diff --git a/vendor/github.com/sfomuseum/go-edtf/level1/qualified_date.go b/vendor/github.com/sfomuseum/go-edtf/level1/qualified_date.go deleted file mode 100644 index d02ccf7..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/level1/qualified_date.go +++ /dev/null @@ -1,46 +0,0 @@ -package level1 - -import ( - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/common" - "github.com/sfomuseum/go-edtf/re" -) - -/* - -Qualification of a date (complete) - -The characters '?', '~' and '%' are used to mean "uncertain", "approximate", and "uncertain" as well as "approximate", respectively. These characters may occur only at the end of the date string and apply to the entire date. - - Example 1 '1984?' year uncertain (possibly the year 1984, but not definitely) - Example 2 '2004-06~'' year-month approximate - Example 3 '2004-06-11%' entire date (year-month-day) uncertain and approximate - -*/ - -func IsQualifiedDate(edtf_str string) bool { - return re.QualifiedDate.MatchString(edtf_str) -} - -func ParseQualifiedDate(edtf_str string) (*edtf.EDTFDate, error) { - - if !re.QualifiedDate.MatchString(edtf_str) { - return nil, edtf.Invalid(QUALIFIED_DATE, edtf_str) - } - - sp, err := common.DateSpanFromEDTF(edtf_str) - - if err != nil { - return nil, err - } - - d := &edtf.EDTFDate{ - Start: sp.Start, - End: sp.End, - EDTF: edtf_str, - Level: LEVEL, - Feature: QUALIFIED_DATE, - } - - return d, nil -} diff --git a/vendor/github.com/sfomuseum/go-edtf/level1/season.go b/vendor/github.com/sfomuseum/go-edtf/level1/season.go deleted file mode 100644 index e8b3cf7..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/level1/season.go +++ /dev/null @@ -1,193 +0,0 @@ -package level1 - -import ( - "fmt" - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/calendar" - "github.com/sfomuseum/go-edtf/common" - "github.com/sfomuseum/go-edtf/re" - "strconv" - "strings" -) - -/* - -Seasons - -The values 21, 22, 23, 24 may be used used to signify ' Spring', 'Summer', 'Autumn', 'Winter', respectively, in place of a month value (01 through 12) for a year-and-month format string. - - Example 2001-21 Spring, 2001 - -*/ - -func IsSeason(edtf_str string) bool { - return re.Season.MatchString(edtf_str) -} - -func ParseSeason(edtf_str string) (*edtf.EDTFDate, error) { - - /* - SEASON 5 [2001-01 2001 01 ] - SEASON 5 [2001-24 2001 24 ] - SEASON 5 [Spring, 2002 Spring 2002] - SEASON 5 [winter, 2002 winter 2002] - */ - - m := re.Season.FindStringSubmatch(edtf_str) - - if len(m) != 5 { - return nil, edtf.Invalid(SEASON, edtf_str) - } - - var start_yyyy int - var start_mm int - var start_dd int - - var end_yyyy int - var end_mm int - var end_dd int - - if m[1] == "" { - - season := m[3] - str_yyyy := m[4] - - yyyy, err := strconv.Atoi(str_yyyy) - - if err != nil { - return nil, err - } - - switch strings.ToUpper(season) { - case "WINTER": - - start_yyyy = yyyy - start_mm = 12 - start_dd = 1 - - end_yyyy = yyyy + 1 - end_mm = 2 - - case "SPRING": - - start_yyyy = yyyy - start_mm = 3 - start_dd = 1 - - end_yyyy = yyyy - end_mm = 5 - - case "SUMMER": - - start_yyyy = yyyy - start_mm = 6 - start_dd = 1 - - end_yyyy = yyyy - end_mm = 8 - - case "FALL": - - start_yyyy = yyyy - start_mm = 9 - start_dd = 1 - - end_yyyy = yyyy - end_mm = 11 - - default: - return nil, edtf.Invalid(SEASON, edtf_str) - } - - } else { - - str_yyyy := m[1] - str_mm := m[2] - - yyyy, err := strconv.Atoi(str_yyyy) - - if err != nil { - return nil, err - } - - mm, err := strconv.Atoi(str_mm) - - if err != nil { - return nil, err - } - - switch mm { - case 21: // spring - - start_yyyy = yyyy - start_mm = 3 - start_dd = 1 - - end_yyyy = yyyy - end_mm = 5 - - case 22: // summer - - start_yyyy = yyyy - start_mm = 6 - start_dd = 1 - - end_yyyy = yyyy - end_mm = 8 - - case 23: // autumn - - start_yyyy = yyyy - start_mm = 9 - start_dd = 1 - - end_yyyy = yyyy - end_mm = 11 - - case 24: // winter - - start_yyyy = yyyy - start_mm = 12 - start_dd = 1 - - end_yyyy = yyyy + 1 - end_mm = 2 - - default: - - start_yyyy = yyyy - start_mm = mm - start_dd = 1 - - end_yyyy = yyyy - end_mm = mm - } - - } - - dm, err := calendar.DaysInMonth(end_yyyy, end_mm) - - if err != nil { - return nil, err - } - - end_dd = dm - - _str := fmt.Sprintf("%04d-%02d-%02d/%04d-%02d-%02d", start_yyyy, start_mm, start_dd, end_yyyy, end_mm, end_dd) - - sp, err := common.DateSpanFromEDTF(_str) - - if err != nil { - return nil, err - } - - d := &edtf.EDTFDate{ - Start: sp.Start, - End: sp.End, - EDTF: edtf_str, - Level: LEVEL, - Feature: SEASON, - } - - return d, nil -} diff --git a/vendor/github.com/sfomuseum/go-edtf/level1/tests.go b/vendor/github.com/sfomuseum/go-edtf/level1/tests.go deleted file mode 100644 index 23e8172..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/level1/tests.go +++ /dev/null @@ -1,205 +0,0 @@ -package level1 - -import ( - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/tests" -) - -var Tests map[string]map[string]*tests.TestResult = map[string]map[string]*tests.TestResult{ - LETTER_PREFIXED_CALENDAR_YEAR: map[string]*tests.TestResult{ - "Y170000002": tests.NewTestResult(tests.TestResultOptions{}), // TO DO - "Y-17000002": tests.NewTestResult(tests.TestResultOptions{}), // TO DO - "Y1700": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1700-01-01T00:00:00Z", - StartUpperTimeRFC3339: "1700-01-01T23:59:59Z", - EndLowerTimeRFC3339: "1700-12-31T00:00:00Z", - EndUpperTimeRFC3339: "1700-12-31T23:59:59Z", - }), - "Y-1200": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "-1200-01-01T00:00:00Z", - StartUpperTimeRFC3339: "-1200-01-01T23:59:59Z", - EndLowerTimeRFC3339: "-1200-12-31T00:00:00Z", - EndUpperTimeRFC3339: "-1200-12-31T23:59:59Z", - }), - }, - SEASON: map[string]*tests.TestResult{ - "2001-01": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2001-01-01T00:00:00Z", - StartUpperTimeRFC3339: "2001-01-01T23:59:59Z", - EndLowerTimeRFC3339: "2001-01-31T00:00:00Z", - EndUpperTimeRFC3339: "2001-01-31T23:59:59Z", - }), - "2019-24": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2019-12-01T00:00:00Z", - StartUpperTimeRFC3339: "2019-12-01T23:59:59Z", - EndLowerTimeRFC3339: "2020-02-29T00:00:00Z", - EndUpperTimeRFC3339: "2020-02-29T23:59:59Z", // leap year - }), - "Spring, 2002": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2002-03-01T00:00:00Z", - StartUpperTimeRFC3339: "2002-03-01T23:59:59Z", - EndLowerTimeRFC3339: "2002-05-31T00:00:00Z", - EndUpperTimeRFC3339: "2002-05-31T23:59:59Z", - }), - "winter, 2002": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2002-12-01T00:00:00Z", - StartUpperTimeRFC3339: "2002-12-01T23:59:59Z", - EndLowerTimeRFC3339: "2003-02-28T00:00:00Z", - EndUpperTimeRFC3339: "2003-02-28T23:59:59Z", - }), - /* - "Summer, -1980": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "-1980-06-01T00:00:00Z", - StartUpperTimeRFC3339: "-1980-06-01T23:59:59Z", - EndLowerTimeRFC3339: "-1980-08-31T00:00:00Z", - EndUpperTimeRFC3339: "-1980-08-31T23:59:59Z", - }), - */ - }, - QUALIFIED_DATE: map[string]*tests.TestResult{ - "1984?": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1984-01-01T00:00:00Z", - StartUpperTimeRFC3339: "1984-01-01T23:59:59Z", - EndLowerTimeRFC3339: "1984-12-31T00:00:00Z", - EndUpperTimeRFC3339: "1984-12-31T23:59:59Z", - StartUpperUncertain: edtf.YEAR, - }), - "2004-06~": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2004-06-01T00:00:00Z", - StartUpperTimeRFC3339: "2004-06-01T23:59:59Z", - EndLowerTimeRFC3339: "2004-06-30T00:00:00Z", - EndUpperTimeRFC3339: "2004-06-30T23:59:59Z", - EndLowerApproximate: edtf.MONTH, - }), - "2004-06-11%": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2004-06-11T00:00:00Z", - StartUpperTimeRFC3339: "2004-06-11T00:00:00Z", - EndLowerTimeRFC3339: "2004-06-11T23:59:59Z", - EndUpperTimeRFC3339: "2004-06-11T23:59:59Z", - EndLowerUncertain: edtf.DAY, - EndLowerApproximate: edtf.DAY, - }), - }, - UNSPECIFIED_DIGITS: map[string]*tests.TestResult{ - "201X": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2010-01-01T00:00:00Z", - StartUpperTimeRFC3339: "2010-01-01T23:59:59Z", - EndLowerTimeRFC3339: "2019-12-31T00:00:00Z", - EndUpperTimeRFC3339: "2019-12-31T23:59:59Z", - StartUpperPrecision: edtf.DECADE, - }), - "20XX": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2000-01-01T00:00:00Z", - StartUpperTimeRFC3339: "2000-01-01T23:59:59Z", - EndLowerTimeRFC3339: "2099-12-31T00:00:00Z", - EndUpperTimeRFC3339: "2099-12-31T23:59:59Z", - StartUpperPrecision: edtf.CENTURY, - }), - "2004-XX": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2004-01-01T00:00:00Z", - StartUpperTimeRFC3339: "2004-01-01T23:59:59Z", - EndLowerTimeRFC3339: "2004-12-31T00:00:00Z", - EndUpperTimeRFC3339: "2004-12-31T23:59:59Z", - StartUpperPrecision: edtf.YEAR, - }), - "1985-04-XX": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1985-04-01T00:00:00Z", - StartUpperTimeRFC3339: "1985-04-01T23:59:59Z", - EndLowerTimeRFC3339: "1985-04-30T00:00:00Z", - EndUpperTimeRFC3339: "1985-04-30T23:59:59Z", - StartUpperPrecision: edtf.MONTH, - }), - "1985-XX-XX": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1985-01-01T00:00:00Z", - StartUpperTimeRFC3339: "1985-01-01T23:59:59Z", - EndLowerTimeRFC3339: "1985-12-31T00:00:00Z", - EndUpperTimeRFC3339: "1985-12-31T23:59:59Z", - StartUpperPrecision: edtf.YEAR, - }), - }, - EXTENDED_INTERVAL_START: map[string]*tests.TestResult{ - "../1985-04-12": tests.NewTestResult(tests.TestResultOptions{ - StartLowerIsOpen: true, - StartUpperIsOpen: true, - EndLowerTimeRFC3339: "1985-04-12T00:00:00Z", - EndUpperTimeRFC3339: "1985-04-12T23:59:59Z", - }), - - "../1985-04": tests.NewTestResult(tests.TestResultOptions{ - StartLowerIsOpen: true, - StartUpperIsOpen: true, - EndLowerTimeRFC3339: "1985-04-01T00:00:00Z", - EndUpperTimeRFC3339: "1985-04-30T23:59:59Z", - }), - "../1985": tests.NewTestResult(tests.TestResultOptions{ - StartLowerIsOpen: true, - StartUpperIsOpen: true, - EndLowerTimeRFC3339: "1985-01-01T00:00:00Z", - EndUpperTimeRFC3339: "1985-12-31T23:59:59Z", - }), - "/1985-04-12": tests.NewTestResult(tests.TestResultOptions{ - StartLowerIsUnknown: true, - StartUpperIsUnknown: true, - EndLowerTimeRFC3339: "1985-04-12T00:00:00Z", - EndUpperTimeRFC3339: "1985-04-12T23:59:59Z", - }), - "/1985-04": tests.NewTestResult(tests.TestResultOptions{ - StartLowerIsUnknown: true, - StartUpperIsUnknown: true, - EndLowerTimeRFC3339: "1985-04-01T00:00:00Z", - EndUpperTimeRFC3339: "1985-04-30T23:59:59Z", - }), - "/1985": tests.NewTestResult(tests.TestResultOptions{ - StartLowerIsUnknown: true, - StartUpperIsUnknown: true, - EndLowerTimeRFC3339: "1985-01-01T00:00:00Z", - EndUpperTimeRFC3339: "1985-12-31T23:59:59Z", - }), - }, - EXTENDED_INTERVAL_END: map[string]*tests.TestResult{ - "1985-04-12/..": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1985-04-12T00:00:00Z", - StartUpperTimeRFC3339: "1985-04-12T23:59:59Z", - EndLowerIsOpen: true, - EndUpperIsOpen: true, - }), - "1985-04/..": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1985-04-01T00:00:00Z", - StartUpperTimeRFC3339: "1985-04-30T23:59:59Z", - EndLowerIsOpen: true, - EndUpperIsOpen: true, - }), - "1985/..": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1985-01-01T00:00:00Z", - StartUpperTimeRFC3339: "1985-12-31T23:59:59Z", - EndLowerIsOpen: true, - EndUpperIsOpen: true, - }), - "1985-04-12/": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1985-04-12T00:00:00Z", - StartUpperTimeRFC3339: "1985-04-12T23:59:59Z", - EndLowerIsUnknown: true, - EndUpperIsUnknown: true, - }), - "1985-04/": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1985-04-01T00:00:00Z", - StartUpperTimeRFC3339: "1985-04-30T23:59:59Z", - EndLowerIsUnknown: true, - EndUpperIsUnknown: true, - }), - "1985/": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1985-01-01T00:00:00Z", - StartUpperTimeRFC3339: "1985-12-31T23:59:59Z", - EndLowerIsUnknown: true, - EndUpperIsUnknown: true, - }), - }, - NEGATIVE_CALENDAR_YEAR: map[string]*tests.TestResult{ - "-1985": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "-1985-01-01T00:00:00Z", - StartUpperTimeRFC3339: "-1985-01-01T23:59:59Z", - EndLowerTimeRFC3339: "-1985-12-31T00:00:00Z", - EndUpperTimeRFC3339: "-1985-12-31T23:59:59Z", - }), - }, -} diff --git a/vendor/github.com/sfomuseum/go-edtf/level1/unspecified_digits.go b/vendor/github.com/sfomuseum/go-edtf/level1/unspecified_digits.go deleted file mode 100644 index 88c8c35..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/level1/unspecified_digits.go +++ /dev/null @@ -1,53 +0,0 @@ -package level1 - -import ( - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/common" - "github.com/sfomuseum/go-edtf/re" -) - -/* - -Unspecified digit(s) from the right - -The character 'X' may be used in place of one or more rightmost digits to indicate that the value of that digit is unspecified, for the following cases: - - A year with one or two (rightmost) unspecified digits in a year-only expression (year precision) - Example 1 ‘201X’ - Example 2 ‘20XX’ - Year specified, month unspecified in a year-month expression (month precision) - Example 3 ‘2004-XX’ - Year and month specified, day unspecified in a year-month-day expression (day precision) - Example 4 ‘1985-04-XX’ - Year specified, day and month unspecified in a year-month-day expression (day precision) - Example 5 ‘1985-XX-XX’ - - -*/ - -func IsUnspecifiedDigits(edtf_str string) bool { - return re.UnspecifiedDigits.MatchString(edtf_str) -} - -func ParseUnspecifiedDigits(edtf_str string) (*edtf.EDTFDate, error) { - - if !re.UnspecifiedDigits.MatchString(edtf_str) { - return nil, edtf.Invalid(UNSPECIFIED_DIGITS, edtf_str) - } - - sp, err := common.DateSpanFromEDTF(edtf_str) - - if err != nil { - return nil, err - } - - d := &edtf.EDTFDate{ - Start: sp.Start, - End: sp.End, - EDTF: edtf_str, - Level: LEVEL, - Feature: UNSPECIFIED_DIGITS, - } - - return d, nil -} diff --git a/vendor/github.com/sfomuseum/go-edtf/level2/exponential_year.go b/vendor/github.com/sfomuseum/go-edtf/level2/exponential_year.go deleted file mode 100644 index ea90b09..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/level2/exponential_year.go +++ /dev/null @@ -1,67 +0,0 @@ -package level2 - -import ( - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/common" - "github.com/sfomuseum/go-edtf/re" - "strconv" -) - -/* - -Exponential year - -'Y' at the beginning of the string (which indicates "year", as in level 1) may be followed by an integer, followed by 'E' followed by a positive integer. This signifies "times 10 to the power of". Thus 17E8 means "17 times 10 to the eighth power". - - Example ‘Y-17E7’ - the calendar year -17*10 to the seventh power= -170000000 - -*/ - -func IsExponentialYear(edtf_str string) bool { - return re.ExponentialYear.MatchString(edtf_str) -} - -func ParseExponentialYear(edtf_str string) (*edtf.EDTFDate, error) { - - /* - EXP 5 Y-17E7,-17E7,-,17,7 - EXP 5 Y10E7,10E7,,10,7 - */ - - if !re.ExponentialYear.MatchString(edtf_str) { - return nil, edtf.Invalid(EXPONENTIAL_YEAR, edtf_str) - } - - m := re.ExponentialYear.FindStringSubmatch(edtf_str) - - if len(m) != 2 { - return nil, edtf.Invalid(EXPONENTIAL_YEAR, edtf_str) - } - - notation := m[1] - - yyyy, err := common.ParseExponentialNotation(notation) - - if err != nil { - return nil, err - } - - str_yyyy := strconv.Itoa(yyyy) - - sp, err := common.DateSpanFromEDTF(str_yyyy) - - if err != nil { - return nil, err - } - - d := &edtf.EDTFDate{ - Start: sp.Start, - End: sp.End, - EDTF: edtf_str, - Level: LEVEL, - Feature: EXPONENTIAL_YEAR, - } - - return d, nil -} diff --git a/vendor/github.com/sfomuseum/go-edtf/level2/interval.go b/vendor/github.com/sfomuseum/go-edtf/level2/interval.go deleted file mode 100644 index d5b94bf..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/level2/interval.go +++ /dev/null @@ -1,55 +0,0 @@ -package level2 - -import ( - // "fmt" - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/common" - "github.com/sfomuseum/go-edtf/re" - //"strings" -) - -/* - -For Level 2 portions of a date within an interval may be designated as approximate, uncertain, or unspecified. - - Example 1 ‘2004-06-~01/2004-06-~20’ - An interval in June 2004 beginning approximately the first and ending approximately the 20th - Example 2 ‘2004-06-XX/2004-07-03’ - An interval beginning on an unspecified day in June 2004 and ending July 3. - - -*/ - -func IsInterval(edtf_str string) bool { - return re.Interval.MatchString(edtf_str) -} - -func ParseInterval(edtf_str string) (*edtf.EDTFDate, error) { - - /* - - INTERVAL 2004-06-~01/2004-06-~20 13 2004-06-~01/2004-06-~20,,2004,,06,~,01,,2004,,06,~,20 - INTERVAL 2004-06-XX/2004-07-03 13 2004-06-XX/2004-07-03,,2004,,06,,XX,,2004,,07,,03 - - */ - - if !re.Interval.MatchString(edtf_str) { - return nil, edtf.Invalid(INTERVAL, edtf_str) - } - - sp, err := common.DateSpanFromEDTF(edtf_str) - - if err != nil { - return nil, err - } - - d := &edtf.EDTFDate{ - Start: sp.Start, - End: sp.End, - EDTF: edtf_str, - Level: LEVEL, - Feature: INTERVAL, - } - - return d, nil -} diff --git a/vendor/github.com/sfomuseum/go-edtf/level2/level2.go b/vendor/github.com/sfomuseum/go-edtf/level2/level2.go deleted file mode 100644 index e265bee..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/level2/level2.go +++ /dev/null @@ -1,95 +0,0 @@ -package level2 - -import ( - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/re" -) - -const LEVEL int = 2 - -const EXPONENTIAL_YEAR string = "Exponential year" -const SIGNIFICANT_DIGITS string = "Significant digits" -const SUB_YEAR_GROUPINGS string = "Sub-year groupings" -const SET_REPRESENTATIONS string = "Set representation" -const GROUP_QUALIFICATION string = "Qualification (Group)" -const INDIVIDUAL_QUALIFICATION string = "Qualification (Individual)" -const UNSPECIFIED_DIGIT string = "Unspecified Digit" -const INTERVAL string = "Interval" - -func IsLevel2(edtf_str string) bool { - return re.Level2.MatchString(edtf_str) -} - -func Matches(edtf_str string) (string, error) { - - if IsExponentialYear(edtf_str) { - return EXPONENTIAL_YEAR, nil - } - - if IsSignificantDigits(edtf_str) { - return SIGNIFICANT_DIGITS, nil - } - - if IsSubYearGrouping(edtf_str) { - return SUB_YEAR_GROUPINGS, nil - } - - if IsSetRepresentation(edtf_str) { - return SET_REPRESENTATIONS, nil - } - - if IsGroupQualification(edtf_str) { - return GROUP_QUALIFICATION, nil - } - - if IsIndividualQualification(edtf_str) { - return INDIVIDUAL_QUALIFICATION, nil - } - - if IsUnspecifiedDigit(edtf_str) { - return UNSPECIFIED_DIGIT, nil - } - - if IsInterval(edtf_str) { - return INTERVAL, nil - } - - return "", edtf.Invalid("Invalid or unsupported Level 2 string", edtf_str) -} - -func ParseString(edtf_str string) (*edtf.EDTFDate, error) { - - if IsExponentialYear(edtf_str) { - return ParseExponentialYear(edtf_str) - } - - if IsSignificantDigits(edtf_str) { - return ParseSignificantDigits(edtf_str) - } - - if IsSubYearGrouping(edtf_str) { - return ParseSubYearGroupings(edtf_str) - } - - if IsSetRepresentation(edtf_str) { - return ParseSetRepresentations(edtf_str) - } - - if IsGroupQualification(edtf_str) { - return ParseGroupQualification(edtf_str) - } - - if IsIndividualQualification(edtf_str) { - return ParseIndividualQualification(edtf_str) - } - - if IsUnspecifiedDigit(edtf_str) { - return ParseUnspecifiedDigit(edtf_str) - } - - if IsInterval(edtf_str) { - return ParseInterval(edtf_str) - } - - return nil, edtf.Invalid("Invalid or unsupported Level 2 string", edtf_str) -} diff --git a/vendor/github.com/sfomuseum/go-edtf/level2/qualification.go b/vendor/github.com/sfomuseum/go-edtf/level2/qualification.go deleted file mode 100644 index bfd31c2..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/level2/qualification.go +++ /dev/null @@ -1,103 +0,0 @@ -package level2 - -import ( - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/common" - "github.com/sfomuseum/go-edtf/re" -) - -/* - -Group Qualification - -A qualification character to the immediate right of a component applies to that component as well as to all components to the left. - - Example 1 ‘2004-06-11%’ - year, month, and day uncertain and approximate - Example 2 ‘2004-06~-11’ - year and month approximate - Example 3 ‘2004?-06-11’ - year uncertain -*/ - -func IsGroupQualification(edtf_str string) bool { - return re.GroupQualification.MatchString(edtf_str) -} - -func ParseGroupQualification(edtf_str string) (*edtf.EDTFDate, error) { - - /* - - GROUP 2004-06-11% 7 2004-06-11%,2004,,06,,11,% - GROUP 2004-06~-11 7 2004-06~-11,2004,,06,~,11, - GROUP 2004?-06-11 7 2004?-06-11,2004,?,06,,11, - - */ - - if !re.GroupQualification.MatchString(edtf_str) { - return nil, edtf.Invalid(GROUP_QUALIFICATION, edtf_str) - } - - sp, err := common.DateSpanFromEDTF(edtf_str) - - if err != nil { - return nil, err - } - - d := &edtf.EDTFDate{ - Start: sp.Start, - End: sp.End, - EDTF: edtf_str, - Level: LEVEL, - Feature: GROUP_QUALIFICATION, - } - - return d, nil -} - -/* - -Qualification of Individual Component - -A qualification character to the immediate left of a component applies to that component only. - - Example 4 ‘?2004-06-~11’ - year uncertain; month known; day approximate - Example 5 ‘2004-%06-11’ - month uncertain and approximate; year and day known - -*/ - -func IsIndividualQualification(edtf_str string) bool { - return re.IndividualQualification.MatchString(edtf_str) -} - -func ParseIndividualQualification(edtf_str string) (*edtf.EDTFDate, error) { - - /* - - INDIVIDUAL ?2004-06-~11 7 ?2004-06-~11,?,2004,,06,~,11 - INDIVIDUAL 2004-%06-11 7 2004-%06-11,,2004,%,06,,11 - - */ - - if !re.IndividualQualification.MatchString(edtf_str) { - return nil, edtf.Invalid(INDIVIDUAL_QUALIFICATION, edtf_str) - } - - sp, err := common.DateSpanFromEDTF(edtf_str) - - if err != nil { - return nil, err - } - - d := &edtf.EDTFDate{ - Start: sp.Start, - End: sp.End, - EDTF: edtf_str, - Level: LEVEL, - Feature: INDIVIDUAL_QUALIFICATION, - } - - return d, nil -} diff --git a/vendor/github.com/sfomuseum/go-edtf/level2/set_representation.go b/vendor/github.com/sfomuseum/go-edtf/level2/set_representation.go deleted file mode 100644 index 9702342..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/level2/set_representation.go +++ /dev/null @@ -1,243 +0,0 @@ -package level2 - -import ( - "fmt" - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/common" - "github.com/sfomuseum/go-edtf/re" - "sort" - "strings" -) - -/* - -Set representation - - Square brackets wrap a single-choice list (select one member). - Curly brackets wrap an inclusive list (all members included). - Members of the set are separated by commas. - No spaces are allowed, anywhere within the expression. - Double-dots indicates all the values between the two values it separates, inclusive. - Double-dot at the beginning or end of the list means "on or before" or "on or after" respectively. - Elements immediately preceeding and/or following as well as the elements represented by a double-dot, all have the same precision. Otherwise, different elements may have different precisions - -One of a set - - Example 1 [1667,1668,1670..1672] - One of the years 1667, 1668, 1670, 1671, 1672 - Example 2 [..1760-12-03] - December 3, 1760; or some earlier date - Example 3 [1760-12..] - December 1760, or some later month - Example 4 [1760-01,1760-02,1760-12..] - January or February of 1760 or December 1760 or some later month - Example 5 [1667,1760-12] - Either the year 1667 or the month December of 1760. - Example 6 [..1984] - The year 1984 or an earlier year - -All Members - - Example 7 {1667,1668,1670..1672} - All of the years 1667, 1668, 1670, 1671, 1672 - Example 8 {1960,1961-12} - The year 1960 and the month December of 1961. - Example 9 {..1984} - The year 1984 and all earlier years - -*/ - -func IsSetRepresentation(edtf_str string) bool { - return re.SetRepresentations.MatchString(edtf_str) -} - -func ParseSetRepresentations(edtf_str string) (*edtf.EDTFDate, error) { - - /* - - SET [1667,1668,1670..1672] 9 [1667,1668,1670..1672],[,,1672,,,..,,] - SET [..1760-12-03] 9 [..1760-12-03],[,..,1760,12,03,,,] - SET [1760-12..] 9 [1760-12..],[,,1760,12,,..,,] - SET [1760-01,1760-02,1760-12..] 9 [1760-01,1760-02,1760-12..],[,,1760,12,,..,,] - SET [1667,1760-12] 9 [1667,1760-12],[,,1760,12,,,,,] - SET [..1984] 9 [..1984],[,..,1984,,,,,] - SET {1667,1668,1670..1672} 9 {1667,1668,1670..1672},{,,1672,,,..,,} - SET {1960,1961-12} 9 {1960,1961-12},{,,1961,12,,,,,} - SET {..1984} 9 {..1984},{,..,1984,,,,,} - - */ - - m := re.SetRepresentations.FindStringSubmatch(edtf_str) - - if len(m) != 6 { - return nil, edtf.Invalid(SET_REPRESENTATIONS, edtf_str) - } - - class := m[1] - candidates := m[2] - - start_ymd := "" - end_ymd := "" - - start_open := false - end_open := false - - inclusivity := edtf.NONE - - switch class { - case "[": - inclusivity = edtf.ANY - case "{": - inclusivity = edtf.ALL - default: - return nil, edtf.Invalid(SET_REPRESENTATIONS, edtf_str) - } - - // this should be moved in to a separate method for getting - // the list of all possible dates - we only care about the - // bookends right now (20201231/thisisaaronland) - - possible := make([]string, 0) - - for _, date := range strings.Split(candidates, ",") { - - parts := strings.Split(date, "..") - count := len(parts) - - switch count { - case 1: - possible = append(possible, date) - continue - case 2: - - if parts[0] != "" && parts[1] != "" { // YYYY..YYYY - - // get everything in between parts[0] and parts[1] - // need to determine what to get (days, months, years) - - possible = append(possible, parts[0]) - possible = append(possible, parts[1]) - - } else if parts[0] == "" { // ..YYYY - - // parts[1] is end (max) date - // start (min) date is "open" or "unknown" - - possible = append(possible, parts[1]) - start_open = true - - } else { // YYYY.. - - // parts[0] is start (min) date - // end (max) date is "open" or "unknown" - - possible = append(possible, parts[0]) - end_open = true - } - - default: - return nil, edtf.Invalid(SET_REPRESENTATIONS, edtf_str) - } - } - - sort.Strings(possible) - count := len(possible) - - switch count { - case 0: - return nil, edtf.Invalid(SET_REPRESENTATIONS, edtf_str) - case 1: - start_ymd = possible[0] - end_ymd = start_ymd - default: - start_ymd = possible[0] - end_ymd = possible[count-1] - } - - _str := start_ymd - - if start_open { - - _str = fmt.Sprintf("../%s", start_ymd) - - } else if end_open { - - _str = fmt.Sprintf("%s/..", start_ymd) - - } else if start_ymd != end_ymd { - - _str = fmt.Sprintf("%s/%s", start_ymd, end_ymd) - } - - /* - - Imagine we have a string like this: - '[1760-01,1760-02,1760-12..]' - - Which needs to be interpreted as: - - start lower: 1760-01 - start upper: 1760-12 - - end lower/upper: .. - - But since we can't parse '1760-01/1760-12/...' - since that would be gibberish we parse '1760-01/1760-1' - and set the 'open_post_facto' flag to update the results of - common.DateSpanFromEDTF after the fact - (20210106/thisisaaronland) - - */ - - open_post_facto := false - - if start_open || end_open { - - if len(possible) > 1 { - _str = fmt.Sprintf("%s/%s", start_ymd, end_ymd) - open_post_facto = true - } - } - - sp, err := common.DateSpanFromEDTF(_str) - - if err != nil { - return nil, err - } - - if open_post_facto { - - open_range := common.OpenDateRange() - - if start_open { - sp.End.Lower = sp.Start.Lower - sp.Start = open_range - } - - if end_open { - - sp.Start.Upper = sp.End.Upper - sp.End = open_range - } - } - - if !start_open { - sp.Start.Lower.Inclusivity = inclusivity - sp.Start.Upper.Inclusivity = inclusivity - } - - if !end_open { - sp.End.Lower.Inclusivity = inclusivity - sp.End.Upper.Inclusivity = inclusivity - } - - d := &edtf.EDTFDate{ - Start: sp.Start, - End: sp.End, - EDTF: edtf_str, - Level: LEVEL, - Feature: SET_REPRESENTATIONS, - } - - return d, nil -} diff --git a/vendor/github.com/sfomuseum/go-edtf/level2/significant_digits.go b/vendor/github.com/sfomuseum/go-edtf/level2/significant_digits.go deleted file mode 100644 index 925d1ea..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/level2/significant_digits.go +++ /dev/null @@ -1,138 +0,0 @@ -package level2 - -import ( - "fmt" - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/common" - "github.com/sfomuseum/go-edtf/re" - "strconv" - "strings" -) - -/* - -Significant digits - -A year (expressed in any of the three allowable forms: four-digit, 'Y' prefix, or exponential) may be followed by 'S', followed by a positive integer indicating the number of significant digits. - - Example 1 ‘1950S2’ - some year between 1900 and 1999, estimated to be 1950 - Example 2 ‘Y171010000S3’ - some year between 171010000 and 171010999, estimated to be 171010000 - Example 3 ‘Y3388E2S3’ - some year between 338000 and 338999, estimated to be 338800. - -*/ - -func IsSignificantDigits(edtf_str string) bool { - return re.SignificantDigits.MatchString(edtf_str) -} - -func ParseSignificantDigits(edtf_str string) (*edtf.EDTFDate, error) { - - /* - - SIGN 5 1950S2,1950,,,2 - SIGN 5 Y171010000S3,,171010000,,3 - SIGN 5 Y-20E2S3,,,-20E2,3 - SIGN 5 Y3388E2S3,,,3388E2,3 - SIGN 5 Y-20E2S3,,,-20E2,3 - - */ - - m := re.SignificantDigits.FindStringSubmatch(edtf_str) - - if len(m) != 5 { - return nil, edtf.Invalid(SIGNIFICANT_DIGITS, edtf_str) - } - - str_yyyy := m[1] - str_year := m[2] - notation := m[3] - str_digits := m[4] - - var yyyy int - - if str_yyyy != "" { - - y, err := strconv.Atoi(str_yyyy) - - if err != nil { - return nil, edtf.Invalid(SIGNIFICANT_DIGITS, edtf_str) - } - - yyyy = y - - } else if str_year != "" { - - if len(str_year) > 4 { - return nil, edtf.Unsupported(SIGNIFICANT_DIGITS, edtf_str) - } - - y, err := strconv.Atoi(str_year) - - if err != nil { - return nil, edtf.Invalid(SIGNIFICANT_DIGITS, edtf_str) - } - - yyyy = y - - } else if notation != "" { - - y, err := common.ParseExponentialNotation(notation) - - if err != nil { - return nil, err - } - - yyyy = y - - } else { - return nil, edtf.Invalid(SIGNIFICANT_DIGITS, edtf_str) - } - - if yyyy > edtf.MAX_YEARS { - return nil, edtf.Unsupported(SIGNIFICANT_DIGITS, edtf_str) - } - - digits, err := strconv.Atoi(str_digits) - - if err != nil { - return nil, edtf.Invalid(SIGNIFICANT_DIGITS, edtf_str) - } - - if len(strconv.Itoa(digits)) > len(strconv.Itoa(yyyy)) { - return nil, edtf.Invalid(SIGNIFICANT_DIGITS, edtf_str) - } - - str_yyyy = strconv.Itoa(yyyy) - prefix_yyyy := str_yyyy[0 : len(str_yyyy)-digits] - - first := strings.Repeat("0", digits) - last := strings.Repeat("9", digits) - - start_yyyy := prefix_yyyy + first - end_yyyy := prefix_yyyy + last - - _str := fmt.Sprintf("%s/%s", start_yyyy, end_yyyy) - - if strings.HasPrefix(start_yyyy, "-") && strings.HasPrefix(end_yyyy, "-") { - _str = fmt.Sprintf("%s/%s", end_yyyy, start_yyyy) - } - - sp, err := common.DateSpanFromEDTF(_str) - - if err != nil { - return nil, err - } - - d := &edtf.EDTFDate{ - Start: sp.Start, - End: sp.End, - EDTF: edtf_str, - Level: LEVEL, - Feature: SIGNIFICANT_DIGITS, - } - - return d, nil -} diff --git a/vendor/github.com/sfomuseum/go-edtf/level2/sub_year_grouping.go b/vendor/github.com/sfomuseum/go-edtf/level2/sub_year_grouping.go deleted file mode 100644 index b96888f..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/level2/sub_year_grouping.go +++ /dev/null @@ -1,204 +0,0 @@ -package level2 - -import ( - "fmt" - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/common" - "github.com/sfomuseum/go-edtf/re" - "strconv" -) - -/* - -Level 2 extends the season feature of Level 1 to include the following sub-year groupings. - -21 Spring (independent of location) -22 Summer (independent of location) -23 Autumn (independent of location) -24 Winter (independent of location) -25 Spring - Northern Hemisphere -26 Summer - Northern Hemisphere -27 Autumn - Northern Hemisphere -28 Winter - Northern Hemisphere -29 Spring - Southern Hemisphere -30 Summer - Southern Hemisphere -31 Autumn - Southern Hemisphere -32 Winter - Southern Hemisphere -33 Quarter 1 (3 months in duration) -34 Quarter 2 (3 months in duration) -35 Quarter 3 (3 months in duration) -36 Quarter 4 (3 months in duration) -37 Quadrimester 1 (4 months in duration) -38 Quadrimester 2 (4 months in duration) -39 Quadrimester 3 (4 months in duration) -40 Semestral 1 (6 months in duration) -41 Semestral 2 (6 months in duration) - - Example ‘2001-34’ - second quarter of 2001 - -*/ - -func IsSubYearGrouping(edtf_str string) bool { - return re.SubYearGrouping.MatchString(edtf_str) -} - -func ParseSubYearGroupings(edtf_str string) (*edtf.EDTFDate, error) { - - /* - - SUB 3 2001-34,2001,34 - - */ - - m := re.SubYearGrouping.FindStringSubmatch(edtf_str) - - if len(m) != 3 { - return nil, edtf.Invalid(SUB_YEAR_GROUPINGS, edtf_str) - } - - year := m[1] - grouping := m[2] - - start_yyyy := year - start_mm := "" - start_dd := "" - - end_yyyy := year - end_mm := "" - end_dd := "" - - switch grouping { - case "21", "25": // Spring (independent of location, Northern Hemisphere) - start_mm = "03" - start_dd = "01" - end_mm = "05" - end_dd = "31" - case "22", "26": // Summer (independent of location, Northern Hemisphere) - start_mm = "06" - start_dd = "01" - end_mm = "08" - end_dd = "31" - case "23", "27": // Autumn (independent of location, Northern Hemisphere) - start_mm = "09" - start_dd = "01" - end_mm = "11" - end_dd = "30" - case "24", "28": // Winter (independent of location, Northern Hemisphere) - start_mm = "12" - start_dd = "01" - end_mm = "02" - end_dd = "" // leave blank to make the code look up daysforyear(year) - - y, err := strconv.Atoi(end_yyyy) - - if err != nil { - return nil, err - } - - end_yyyy = strconv.Itoa(y + 1) - - case "29": // Spring - Southern Hemisphere - start_mm = "09" - start_dd = "01" - end_mm = "11" - end_dd = "30" - case "30": // Summer - Southern Hemisphere - start_mm = "12" - start_dd = "01" - - end_mm = "02" - end_dd = "" // leave blank to make the code look up daysforyear(year) - - y, err := strconv.Atoi(end_yyyy) - - if err != nil { - return nil, err - } - - end_yyyy = strconv.Itoa(y + 1) - - case "31": // Autumn - Southern Hemisphere - start_mm = "03" - start_dd = "01" - end_mm = "05" - end_dd = "31" - case "32": // Winter - Southern Hemisphere - start_mm = "06" - start_dd = "01" - end_mm = "08" - end_dd = "31" - case "33": // Quarter 1 (3 months in duration) - start_mm = "01" - start_dd = "01" - end_mm = "03" - end_dd = "31" - case "34": // Quarter 2 (3 months in duration) - start_mm = "04" - start_dd = "01" - end_mm = "06" - end_dd = "30" - case "35": // Quarter 3 (3 months in duration) - start_mm = "07" - start_dd = "01" - end_mm = "09" - end_dd = "30" - case "36": // Quarter 4 (3 months in duration) - start_mm = "10" - start_dd = "01" - end_mm = "12" - end_dd = "31" - case "37": // Quadrimester 1 (4 months in duration) - start_mm = "01" - start_dd = "01" - end_mm = "04" - end_dd = "30" - case "38": // Quadrimester 2 (4 months in duration) - start_mm = "05" - start_dd = "01" - end_mm = "08" - end_dd = "31" - case "39": // Quadrimester 3 (4 months in duration) - start_mm = "09" - start_dd = "01" - end_mm = "12" - end_dd = "31" - case "40": // Semestral 1 (6 months in duration) - start_mm = "01" - start_dd = "01" - end_mm = "06" - end_dd = "30" - case "41": // Semestral 2 (6 months in duration) - start_mm = "07" - start_dd = "01" - end_mm = "12" - end_dd = "31" - default: - return nil, edtf.Invalid(SUB_YEAR_GROUPINGS, edtf_str) - } - - start := fmt.Sprintf("%s-%s-%s", start_yyyy, start_mm, start_dd) - end := fmt.Sprintf("%s-%s", end_yyyy, end_mm) - - if end_dd != "" { - end = fmt.Sprintf("%s-%s", end, end_dd) - } - - _str := fmt.Sprintf("%s/%s", start, end) - - sp, err := common.DateSpanFromEDTF(_str) - - if err != nil { - return nil, err - } - - d := &edtf.EDTFDate{ - Start: sp.Start, - End: sp.End, - EDTF: edtf_str, - Level: LEVEL, - Feature: SUB_YEAR_GROUPINGS, - } - - return d, nil -} diff --git a/vendor/github.com/sfomuseum/go-edtf/level2/tests.go b/vendor/github.com/sfomuseum/go-edtf/level2/tests.go deleted file mode 100644 index 5d31340..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/level2/tests.go +++ /dev/null @@ -1,230 +0,0 @@ -package level2 - -import ( - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/tests" -) - -var Tests map[string]map[string]*tests.TestResult = map[string]map[string]*tests.TestResult{ - EXPONENTIAL_YEAR: map[string]*tests.TestResult{ - "Y-17E7": tests.NewTestResult(tests.TestResultOptions{}), // TO DO - https://github.com/sfomuseum/go-edtf/issues/5 - "Y10E7": tests.NewTestResult(tests.TestResultOptions{}), // TO DO - "Y20E2": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2000-01-01T00:00:00Z", - StartUpperTimeRFC3339: "2000-01-01T23:59:59Z", - EndLowerTimeRFC3339: "2000-12-31T00:00:00Z", - EndUpperTimeRFC3339: "2000-12-31T23:59:59Z", - }), - }, - SIGNIFICANT_DIGITS: map[string]*tests.TestResult{ - "1950S2": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1900-01-01T00:00:00Z", - StartUpperTimeRFC3339: "1900-12-31T23:59:59Z", - EndLowerTimeRFC3339: "1999-01-01T00:00:00Z", - EndUpperTimeRFC3339: "1999-12-31T23:59:59Z", - }), - "Y171010000S3": tests.NewTestResult(tests.TestResultOptions{}), - "Y-20E2S3": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "-2999-01-01T00:00:00Z", - StartUpperTimeRFC3339: "-2999-12-31T23:59:59Z", - EndLowerTimeRFC3339: "-2000-01-01T00:00:00Z", - EndUpperTimeRFC3339: "-2000-12-31T23:59:59Z", - }), - "Y3388E2S3": tests.NewTestResult(tests.TestResultOptions{}), - }, - SUB_YEAR_GROUPINGS: map[string]*tests.TestResult{ - "2001-34": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2001-04-01T00:00:00Z", - StartUpperTimeRFC3339: "2001-04-01T23:59:59Z", - EndLowerTimeRFC3339: "2001-06-30T00:00:00Z", - EndUpperTimeRFC3339: "2001-06-30T23:59:59Z", - }), - "2019-28": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2019-12-01T00:00:00Z", - StartUpperTimeRFC3339: "2019-12-01T23:59:59Z", - EndLowerTimeRFC3339: "2020-02-01T00:00:00Z", - EndUpperTimeRFC3339: "2020-02-29T23:59:59Z", - }), - // "second quarter of 2001": tests.NewTestResult(tests.TestResultOptions{}), // TO DO - }, - SET_REPRESENTATIONS: map[string]*tests.TestResult{ - "[1760-01,1760-02,1760-12..]": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1760-01-01T00:00:00Z", - StartUpperTimeRFC3339: "1760-12-31T23:59:59Z", - EndLowerIsOpen: true, - EndUpperIsOpen: true, - StartLowerInclusivity: edtf.ANY, - }), - "[1667,1668,1670..1672]": tests.NewTestResult(tests.TestResultOptions{ - // THIS FEELS WRONG...LIKE IT'S BACKWARDS - StartLowerTimeRFC3339: "1667-01-01T00:00:00Z", - StartUpperTimeRFC3339: "1667-12-31T23:59:59Z", - EndLowerTimeRFC3339: "1672-01-01T00:00:00Z", - EndUpperTimeRFC3339: "1672-12-31T23:59:59Z", - StartLowerInclusivity: edtf.ANY, - EndUpperInclusivity: edtf.ANY, - }), - "[..1760-12-03]": tests.NewTestResult(tests.TestResultOptions{ - EndLowerTimeRFC3339: "1760-12-03T00:00:00Z", - EndUpperTimeRFC3339: "1760-12-03T23:59:59Z", - StartLowerIsOpen: true, - StartUpperIsOpen: true, - EndUpperInclusivity: edtf.ANY, - }), - "[1760-12..]": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1760-12-01T00:00:00Z", - StartUpperTimeRFC3339: "1760-12-31T23:59:59Z", - EndLowerIsOpen: true, - EndUpperIsOpen: true, - StartUpperInclusivity: edtf.ANY, - }), - "[1667,1760-12]": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1667-01-01T00:00:00Z", - StartUpperTimeRFC3339: "1667-12-31T23:59:59Z", - EndLowerTimeRFC3339: "1760-12-01T00:00:00Z", - EndUpperTimeRFC3339: "1760-12-31T23:59:59Z", - StartUpperInclusivity: edtf.ANY, - EndLowerInclusivity: edtf.ANY, - }), - - "[..1984]": tests.NewTestResult(tests.TestResultOptions{ - StartLowerIsOpen: true, - StartUpperIsOpen: true, - EndLowerTimeRFC3339: "1984-01-01T00:00:00Z", - EndUpperTimeRFC3339: "1984-12-31T23:59:59Z", - EndLowerInclusivity: edtf.ANY, - }), - "{1667,1668,1670..1672}": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1667-01-01T00:00:00Z", - StartUpperTimeRFC3339: "1667-12-31T23:59:59Z", - EndLowerTimeRFC3339: "1672-01-01T00:00:00Z", - EndUpperTimeRFC3339: "1672-12-31T23:59:59Z", - StartUpperInclusivity: edtf.ALL, - EndLowerInclusivity: edtf.ALL, - }), - "{1960,1961-12}": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1960-01-01T00:00:00Z", - StartUpperTimeRFC3339: "1960-12-31T23:59:59Z", - EndLowerTimeRFC3339: "1961-12-01T00:00:00Z", - EndUpperTimeRFC3339: "1961-12-31T23:59:59Z", - StartUpperInclusivity: edtf.ALL, - EndLowerInclusivity: edtf.ALL, - }), - "{..1984}": tests.NewTestResult(tests.TestResultOptions{ - StartLowerIsOpen: true, - StartUpperIsOpen: true, - EndLowerTimeRFC3339: "1984-01-01T00:00:00Z", - EndUpperTimeRFC3339: "1984-12-31T23:59:59Z", - EndLowerInclusivity: edtf.ALL, - }), - }, - GROUP_QUALIFICATION: map[string]*tests.TestResult{ - "2004-06-11%": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2004-06-11T00:00:00Z", - StartUpperTimeRFC3339: "2004-06-11T00:00:00Z", - EndLowerTimeRFC3339: "2004-06-11T23:59:59Z", - EndUpperTimeRFC3339: "2004-06-11T23:59:59Z", - StartUpperUncertain: edtf.DAY, - StartUpperApproximate: edtf.DAY, - EndLowerApproximate: edtf.YEAR, - EndLowerUncertain: edtf.MONTH, - }), - "2004-06~-11": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2004-06-11T00:00:00Z", - StartUpperTimeRFC3339: "2004-06-11T00:00:00Z", - EndLowerTimeRFC3339: "2004-06-11T23:59:59Z", - EndUpperTimeRFC3339: "2004-06-11T23:59:59Z", - EndUpperApproximate: edtf.MONTH, - EndLowerApproximate: edtf.YEAR, - }), - "2004?-06-11": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2004-06-11T00:00:00Z", - StartUpperTimeRFC3339: "2004-06-11T00:00:00Z", - EndLowerTimeRFC3339: "2004-06-11T23:59:59Z", - EndUpperTimeRFC3339: "2004-06-11T23:59:59Z", - EndLowerUncertain: edtf.YEAR, - }), - }, - INDIVIDUAL_QUALIFICATION: map[string]*tests.TestResult{ - "?2004-06-~11": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2004-06-11T00:00:00Z", - StartUpperTimeRFC3339: "2004-06-11T00:00:00Z", - EndLowerTimeRFC3339: "2004-06-11T23:59:59Z", - EndUpperTimeRFC3339: "2004-06-11T23:59:59Z", - EndUpperApproximate: edtf.DAY, - }), - "2004-%06-11": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2004-06-11T00:00:00Z", - StartUpperTimeRFC3339: "2004-06-11T00:00:00Z", - EndLowerTimeRFC3339: "2004-06-11T23:59:59Z", - EndUpperTimeRFC3339: "2004-06-11T23:59:59Z", - EndUpperApproximate: edtf.MONTH, - EndUpperUncertain: edtf.MONTH, - }), - }, - UNSPECIFIED_DIGIT: map[string]*tests.TestResult{ - "156X-12-25": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1560-12-25T00:00:00Z", - StartUpperTimeRFC3339: "1560-12-25T23:59:59Z", - EndLowerTimeRFC3339: "1569-12-25T00:00:00Z", - EndUpperTimeRFC3339: "1569-12-25T23:59:59Z", - StartUpperPrecision: edtf.DECADE, - }), - "15XX-12-25": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1500-12-25T00:00:00Z", - StartUpperTimeRFC3339: "1500-12-25T23:59:59Z", - EndLowerTimeRFC3339: "1599-12-25T00:00:00Z", - EndUpperTimeRFC3339: "1599-12-25T23:59:59Z", - StartUpperPrecision: edtf.CENTURY, - }), - // "XXXX-12-XX": tests.NewTestResult(tests.TestResultOptions{}), // TO DO - "1XXX-XX": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1000-01-01T00:00:00Z", - StartUpperTimeRFC3339: "1000-01-01T23:59:59Z", - EndLowerTimeRFC3339: "1999-12-31T00:00:00Z", - EndUpperTimeRFC3339: "1999-12-31T23:59:59Z", - StartUpperPrecision: edtf.MILLENIUM, - }), - "1XXX-12": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1000-12-01T00:00:00Z", - StartUpperTimeRFC3339: "1000-12-01T23:59:59Z", - EndLowerTimeRFC3339: "1999-12-31T00:00:00Z", - EndUpperTimeRFC3339: "1999-12-31T23:59:59Z", - StartUpperPrecision: edtf.MILLENIUM, - }), - "1984-1X": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "1984-10-01T00:00:00Z", - StartUpperTimeRFC3339: "1984-10-01T23:59:59Z", - EndLowerTimeRFC3339: "1984-12-31T00:00:00Z", - EndUpperTimeRFC3339: "1984-12-31T23:59:59Z", - StartUpperPrecision: edtf.MONTH, - }), - }, - INTERVAL: map[string]*tests.TestResult{ - "2004-06-~01/2004-06-~20": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2004-06-01T00:00:00Z", - StartUpperTimeRFC3339: "2004-06-01T23:59:59Z", - EndLowerTimeRFC3339: "2004-06-20T00:00:00Z", - EndUpperTimeRFC3339: "2004-06-20T23:59:59Z", - EndUpperApproximate: edtf.DAY, - }), - "2004-06-XX/2004-07-03": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "2004-06-01T00:00:00Z", - StartUpperTimeRFC3339: "2004-06-30T23:59:59Z", - EndLowerTimeRFC3339: "2004-07-03T00:00:00Z", - EndUpperTimeRFC3339: "2004-07-03T23:59:59Z", - }), - "~-0100/~2020": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "-0100-01-01T00:00:00Z", - StartUpperTimeRFC3339: "-0100-12-31T23:59:59Z", - EndLowerTimeRFC3339: "2020-01-01T00:00:00Z", - EndUpperTimeRFC3339: "2020-12-31T23:59:59Z", - }), - "~-0100/~-0010": tests.NewTestResult(tests.TestResultOptions{ - StartLowerTimeRFC3339: "-0100-01-01T00:00:00Z", - StartUpperTimeRFC3339: "-0100-12-31T23:59:59Z", - EndLowerTimeRFC3339: "-0010-01-01T00:00:00Z", - EndUpperTimeRFC3339: "-0010-12-31T23:59:59Z", - }), - }, -} diff --git a/vendor/github.com/sfomuseum/go-edtf/level2/unspecified_digit.go b/vendor/github.com/sfomuseum/go-edtf/level2/unspecified_digit.go deleted file mode 100644 index b8db019..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/level2/unspecified_digit.go +++ /dev/null @@ -1,67 +0,0 @@ -package level2 - -import ( - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/common" - "github.com/sfomuseum/go-edtf/re" - // "strconv" - // "strings" -) - -/* - -Unspecified Digit - -For level 2 the unspecified digit, 'X', may occur anywhere within a component. - - Example 1 ‘156X-12-25’ - December 25 sometime during the 1560s - Example 2 ‘15XX-12-25’ - December 25 sometime during the 1500s - Example 3 ‘XXXX-12-XX’ - Some day in December in some year - Example 4 '1XXX-XX’ - Some month during the 1000s - Example 5 ‘1XXX-12’ - Some December during the 1000s - Example 6 ‘1984-1X’ - October, November, or December 1984 - -*/ - -func IsUnspecifiedDigit(edtf_str string) bool { - return re.UnspecifiedDigit.MatchString(edtf_str) -} - -func ParseUnspecifiedDigit(edtf_str string) (*edtf.EDTFDate, error) { - - /* - - UNSPEC 156X-12-25 4 156X-12-25,156X,12,25 - UNSPEC 15XX-12-25 4 15XX-12-25,15XX,12,25 - UNSPEC 1XXX-XX 4 1XXX-XX,1XXX,XX, - UNSPEC 1XXX-12 4 1XXX-12,1XXX,12, - UNSPEC 1984-1X 4 1984-1X,1984,1X, - - */ - - if !re.UnspecifiedDigit.MatchString(edtf_str) { - return nil, edtf.Invalid(UNSPECIFIED_DIGIT, edtf_str) - } - - sp, err := common.DateSpanFromEDTF(edtf_str) - - if err != nil { - return nil, err - } - - d := &edtf.EDTFDate{ - Start: sp.Start, - End: sp.End, - EDTF: edtf_str, - Level: LEVEL, - Feature: UNSPECIFIED_DIGIT, - } - - return d, nil -} diff --git a/vendor/github.com/sfomuseum/go-edtf/parser/parser.go b/vendor/github.com/sfomuseum/go-edtf/parser/parser.go deleted file mode 100644 index 2271327..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/parser/parser.go +++ /dev/null @@ -1,119 +0,0 @@ -// package parser provides methods for parsing and validating EDTF strings. -package parser - -import ( - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/common" - "github.com/sfomuseum/go-edtf/level0" - "github.com/sfomuseum/go-edtf/level1" - "github.com/sfomuseum/go-edtf/level2" -) - -// Return a boolean value indicating whether a string is a valid EDTF date. -func IsValid(edtf_str string) bool { - - if level0.IsLevel0(edtf_str) { - return true - } - - if level1.IsLevel1(edtf_str) { - return true - } - - if level2.IsLevel2(edtf_str) { - return true - } - - switch edtf_str { - case edtf.OPEN, edtf.UNKNOWN: - return true - default: - return false - } -} - -// Parse a string in to an edtf.EDTFDate instance. -func ParseString(edtf_str string) (*edtf.EDTFDate, error) { - - if level0.IsLevel0(edtf_str) { - return level0.ParseString(edtf_str) - } - - if level1.IsLevel1(edtf_str) { - return level1.ParseString(edtf_str) - } - - if level2.IsLevel2(edtf_str) { - return level2.ParseString(edtf_str) - } - - if edtf_str == edtf.OPEN { - sp := common.OpenDateSpan() - - d := &edtf.EDTFDate{ - Start: sp.Start, - End: sp.End, - EDTF: edtf_str, - Level: -1, - Feature: "Open", - } - - return d, nil - } - - if edtf_str == edtf.UNKNOWN { - - sp := common.UnknownDateSpan() - - d := &edtf.EDTFDate{ - Start: sp.Start, - End: sp.End, - EDTF: edtf_str, - Level: -1, - Feature: "Unknown", - } - - return d, nil - } - - return nil, edtf.Unrecognized("Invalid or unsupported EDTF string", edtf_str) -} - -// Determine which EDTF level and corresponding EDTF feature a string matches. -func Matches(edtf_str string) (int, string, error) { - - if level0.IsLevel0(edtf_str) { - - feature, err := level0.Matches(edtf_str) - - if err != nil { - return -1, "", err - } - - return level0.LEVEL, feature, nil - } - - if level1.IsLevel1(edtf_str) { - - feature, err := level1.Matches(edtf_str) - - if err != nil { - return -1, "", err - } - - return level1.LEVEL, feature, nil - } - - if level2.IsLevel2(edtf_str) { - - feature, err := level2.Matches(edtf_str) - - if err != nil { - return -1, "", err - } - - return level2.LEVEL, feature, nil - } - - return -1, "", edtf.Unrecognized("Invalid or unsupported EDTF string", edtf_str) -} diff --git a/vendor/github.com/sfomuseum/go-edtf/parser/tests.go b/vendor/github.com/sfomuseum/go-edtf/parser/tests.go deleted file mode 100644 index b6cd053..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/parser/tests.go +++ /dev/null @@ -1,25 +0,0 @@ -package parser - -import ( - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/tests" -) - -var Tests map[string]map[string]*tests.TestResult = map[string]map[string]*tests.TestResult{ - "Unknown": map[string]*tests.TestResult{ - edtf.UNKNOWN: tests.NewTestResult(tests.TestResultOptions{ - StartLowerIsUnknown: true, - StartUpperIsUnknown: true, - EndLowerIsUnknown: true, - EndUpperIsUnknown: true, - }), - }, - "Open": map[string]*tests.TestResult{ - edtf.OPEN: tests.NewTestResult(tests.TestResultOptions{ - StartLowerIsOpen: true, - StartUpperIsOpen: true, - EndLowerIsOpen: true, - EndUpperIsOpen: true, - }), - }, -} diff --git a/vendor/github.com/sfomuseum/go-edtf/re/common.go b/vendor/github.com/sfomuseum/go-edtf/re/common.go deleted file mode 100644 index 10ccb36..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/re/common.go +++ /dev/null @@ -1,22 +0,0 @@ -package re - -import ( - "regexp" -) - -var Year *regexp.Regexp - -var YMD *regexp.Regexp - -var QualifiedIndividual *regexp.Regexp -var QualifiedGroup *regexp.Regexp - -func init() { - Year = regexp.MustCompile(`^` + PATTERN_YEAR + `$`) - - YMD = regexp.MustCompile(`^` + PATTERN_YMD_X + `$`) - - QualifiedIndividual = regexp.MustCompile(`^(` + PATTERN_QUALIFIER + `)?` + PATTERN_DATE_X + `$`) - - QualifiedGroup = regexp.MustCompile(`^` + PATTERN_DATE_X + `(` + PATTERN_QUALIFIER + `)?$`) -} diff --git a/vendor/github.com/sfomuseum/go-edtf/re/level0.go b/vendor/github.com/sfomuseum/go-edtf/re/level0.go deleted file mode 100644 index 8ef3f3c..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/re/level0.go +++ /dev/null @@ -1,29 +0,0 @@ -package re - -import ( - "regexp" - "strings" -) - -var Date *regexp.Regexp -var DateAndTime *regexp.Regexp -var TimeInterval *regexp.Regexp - -var Level0 *regexp.Regexp - -func init() { - - Date = regexp.MustCompile(`^` + PATTERN_DATE + `$`) - - DateAndTime = regexp.MustCompile(`^` + PATTERN_DATE_AND_TIME + `$`) - - TimeInterval = regexp.MustCompile(`^` + PATTERN_TIME_INTERVAL + `$`) - - level0_patterns := []string{ - PATTERN_DATE, - PATTERN_DATE_AND_TIME, - PATTERN_TIME_INTERVAL, - } - - Level0 = regexp.MustCompile(`^(` + strings.Join(level0_patterns, "|") + `)$`) -} diff --git a/vendor/github.com/sfomuseum/go-edtf/re/level1.go b/vendor/github.com/sfomuseum/go-edtf/re/level1.go deleted file mode 100644 index 7471745..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/re/level1.go +++ /dev/null @@ -1,44 +0,0 @@ -package re - -import ( - "regexp" - "strings" -) - -var LetterPrefixedCalendarYear *regexp.Regexp -var Season *regexp.Regexp -var QualifiedDate *regexp.Regexp -var UnspecifiedDigits *regexp.Regexp -var IntervalEnd *regexp.Regexp -var IntervalStart *regexp.Regexp -var NegativeYear *regexp.Regexp -var Level1 *regexp.Regexp - -func init() { - - LetterPrefixedCalendarYear = regexp.MustCompile(`^` + PATTERN_LETTER_PREFIXED_CALENDAR_YEAR + `$`) - - Season = regexp.MustCompile(`^` + PATTERN_SEASON + `$`) - - QualifiedDate = regexp.MustCompile(`^` + PATTERN_QUALIFIED_DATE + `$`) - - UnspecifiedDigits = regexp.MustCompile(`^` + PATTERN_UNSPECIFIED_DIGITS + `$`) - - IntervalStart = regexp.MustCompile(`^` + PATTERN_INTERVAL_START + `$`) - - IntervalEnd = regexp.MustCompile(`^` + PATTERN_INTERVAL_END + `$`) - - NegativeYear = regexp.MustCompile(`^` + PATTERN_NEGATIVE_YEAR + `$`) - - level1_patterns := []string{ - PATTERN_LETTER_PREFIXED_CALENDAR_YEAR, - PATTERN_SEASON, - PATTERN_QUALIFIED_DATE, - PATTERN_UNSPECIFIED_DIGITS, - PATTERN_INTERVAL_START, - PATTERN_INTERVAL_END, - PATTERN_NEGATIVE_YEAR, - } - - Level1 = regexp.MustCompile(`^(` + strings.Join(level1_patterns, "|") + `)$`) -} diff --git a/vendor/github.com/sfomuseum/go-edtf/re/level2.go b/vendor/github.com/sfomuseum/go-edtf/re/level2.go deleted file mode 100644 index 5a6e561..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/re/level2.go +++ /dev/null @@ -1,49 +0,0 @@ -package re - -import ( - "regexp" - "strings" -) - -var ExponentialYear *regexp.Regexp - -var SignificantDigits *regexp.Regexp -var SubYearGrouping *regexp.Regexp -var SetRepresentations *regexp.Regexp -var GroupQualification *regexp.Regexp -var IndividualQualification *regexp.Regexp -var UnspecifiedDigit *regexp.Regexp -var Interval *regexp.Regexp -var Level2 *regexp.Regexp - -func init() { - - ExponentialYear = regexp.MustCompile(`^` + PATTERN_EXPONENTIAL_YEAR + `$`) - - SignificantDigits = regexp.MustCompile(`^` + PATTERN_SIGNIFICANT_DIGITS + `$`) - - SubYearGrouping = regexp.MustCompile(`^` + PATTERN_SUB_YEAR_GROUPING + `$`) - - SetRepresentations = regexp.MustCompile(`^` + PATTERN_SET_REPRESENTATIONS + `$`) - - GroupQualification = regexp.MustCompile(`^` + PATTERN_GROUP_QUALIFICATION + `$`) - - IndividualQualification = regexp.MustCompile(`^` + PATTERN_INDIVIDUAL_QUALIFICATION + `$`) - - UnspecifiedDigit = regexp.MustCompile(`^` + PATTERN_UNSPECIFIED_DIGIT + `$`) - - Interval = regexp.MustCompile(`^` + PATTERN_INTERVAL + `$`) - - level2_patterns := []string{ - PATTERN_EXPONENTIAL_YEAR, - PATTERN_SIGNIFICANT_DIGITS, - PATTERN_SUB_YEAR_GROUPING, - PATTERN_SET_REPRESENTATIONS, - PATTERN_GROUP_QUALIFICATION, - PATTERN_INDIVIDUAL_QUALIFICATION, - PATTERN_UNSPECIFIED_DIGIT, - PATTERN_INTERVAL, - } - - Level2 = regexp.MustCompile(`^` + `(` + strings.Join(level2_patterns, "|") + `)`) -} diff --git a/vendor/github.com/sfomuseum/go-edtf/re/re.go b/vendor/github.com/sfomuseum/go-edtf/re/re.go deleted file mode 100644 index d377452..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/re/re.go +++ /dev/null @@ -1,69 +0,0 @@ -package re - -import ( - "github.com/sfomuseum/go-edtf" -) - -// Common - -const PATTERN_YEAR string = `(\-?\d{4})` - -// these are used by common.DateRangeWithString - -const PATTERN_QUALIFIER string = `[\` + edtf.UNCERTAIN + edtf.APPROXIMATE + edtf.UNCERTAIN_AND_APPROXIMATE + `]` - -const PATTERN_YEAR_X string = `\-?[0-9X]{4}` -const PATTERN_MONTH_X string = `(?:[0X][1-9X]|[1X][0-2X])` -const PATTERN_DAY_X string = `(?:[012X][0-9X]|[3X][01X])` - -const PATTERN_YYYY string = `(` + PATTERN_QUALIFIER + `?` + PATTERN_YEAR_X + `|` + PATTERN_YEAR_X + PATTERN_QUALIFIER + `?)` -const PATTERN_MM string = `(` + PATTERN_QUALIFIER + `?` + PATTERN_MONTH_X + `|` + PATTERN_MONTH_X + PATTERN_QUALIFIER + `?)` -const PATTERN_DD string = `(` + PATTERN_QUALIFIER + `?` + PATTERN_DAY_X + `|` + PATTERN_DAY_X + PATTERN_QUALIFIER + `?)` - -const PATTERN_YMD_X string = `^` + PATTERN_YYYY + `(?:\-` + PATTERN_MM + `(?:\-` + PATTERN_DD + `)?` + `)?$` - -const PATTERN_DATE_X string = `(` + PATTERN_YEAR_X + `|(?:` + PATTERN_MONTH_X + `)|(?:` + PATTERN_DAY_X + `))` - -// Level 0 - -const PATTERN_DATE string = `(\-?\d{4})(?:-([0][1-9]|1[0-2])(?:-(0[1-9]|[12][0-9]|3[01]))?)?` - -const PATTERN_DATE_AND_TIME string = PATTERN_DATE + `T(\d{2}):(\d{2}):(\d{2})(Z|(\+|-)(\d{2})(\:(\d{2}))?)?` - -const PATTERN_TIME_INTERVAL string = PATTERN_DATE + `/` + PATTERN_DATE - -// Level 1 - -const PATTERN_LETTER_PREFIXED_CALENDAR_YEAR string = `Y(\-?\d+)` - -const PATTERN_SEASON string = PATTERN_YEAR + `\-(0[1-9]|1[0-2]|2[1-4])|(?i)(spring|summer|fall|winter)\s*,\s*(\d{4})` - -const PATTERN_QUALIFIED_DATE string = PATTERN_DATE + `(\?|~|%)` - -const PATTERN_UNSPECIFIED_DIGITS string = `(?:([0-9X]{4})(?:-([0X][1-9X]|[1X][0-2X])(?:-([012X][1-9X]|[3X][01X]))?)?)` - -const PATTERN_INTERVAL_START = `(\.\.)?\/` + PATTERN_DATE - -const PATTERN_INTERVAL_END = PATTERN_DATE + `\/(\.\.)?` - -const PATTERN_NEGATIVE_YEAR = `\-` + PATTERN_YEAR - -// Level 2 - -const PATTERN_EXPONENTIAL_YEAR string = `(?i)Y(\-?\d+E\d+)` - -const PATTERN_SIGNIFICANT_DIGITS string = `(?:` + PATTERN_YEAR + `|` + PATTERN_LETTER_PREFIXED_CALENDAR_YEAR + `|` + PATTERN_EXPONENTIAL_YEAR + `)S(\d+)` - -const PATTERN_SUB_YEAR_GROUPING string = `(\d{4})\-(1[0-2]|2[1-9]|3[0-9]|4[0-1])` - -// PLEASE FIX ME TO ENSURE CLOSING EL IS THE SAME AS OPENING EL : {}, (), [] - -const PATTERN_SET_REPRESENTATIONS string = `(\[|\{)((?:\.\.)?(?:(?:` + PATTERN_DATE + `(?:,|\.\.)?)+(?:\.\.)?))[\}\]]` - -const PATTERN_GROUP_QUALIFICATION string = `(?:(\d{4})(%|~|\?)?(?:-(\d{2})(%|~|\?)?(?:-(\d{2})(%|~|\?)?)?)?)` - -const PATTERN_INDIVIDUAL_QUALIFICATION string = `(?:(%|~|\?)?(\d{4})(?:-(%|~|\?)?(\d{2})(?:-(%|~|\?)?(\d{2}))?)?)` - -const PATTERN_UNSPECIFIED_DIGIT string = `([0-9X]{4})(?:-([0-9X]{2})(?:-([0-9X]{2}))?)?` - -const PATTERN_INTERVAL string = `(%|~|\?)?(\-?[0-9X]{4})(?:-(%|~|\?)?([0-9X]{2})(?:-(%|~|\?)?([0-9X]{2}))?)?\/(%|~|\?)?(\-?[0-9X]{4})(?:-(%|~|\?)?([0-9X]{2})(?:-(%|~|\?)?([0-9X]{2}))?)?` diff --git a/vendor/github.com/sfomuseum/go-edtf/tests/tests.go b/vendor/github.com/sfomuseum/go-edtf/tests/tests.go deleted file mode 100644 index 9aaae9d..0000000 --- a/vendor/github.com/sfomuseum/go-edtf/tests/tests.go +++ /dev/null @@ -1,438 +0,0 @@ -package tests - -import ( - "fmt" - "github.com/sfomuseum/go-edtf" - "time" -) - -type TestResult struct { - options TestResultOptions -} - -type TestResultOptions struct { - StartLowerTimeRFC3339 string - StartUpperTimeRFC3339 string - EndLowerTimeRFC3339 string - EndUpperTimeRFC3339 string - EndLowerTimeUnix int64 - StartUpperTimeUnix int64 - StartLowerTimeUnix int64 - EndUpperTimeUnix int64 - StartLowerUncertain edtf.Precision - StartUpperUncertain edtf.Precision - EndLowerUncertain edtf.Precision - EndUpperUncertain edtf.Precision - StartLowerApproximate edtf.Precision - StartUpperApproximate edtf.Precision - EndLowerApproximate edtf.Precision - EndUpperApproximate edtf.Precision - StartLowerPrecision edtf.Precision - StartUpperPrecision edtf.Precision - EndLowerPrecision edtf.Precision - EndUpperPrecision edtf.Precision - StartLowerIsOpen bool - StartUpperIsOpen bool - EndLowerIsOpen bool - EndUpperIsOpen bool - StartLowerIsUnknown bool - StartUpperIsUnknown bool - EndLowerIsUnknown bool - EndUpperIsUnknown bool - StartLowerInclusivity edtf.Precision - StartUpperInclusivity edtf.Precision - EndLowerInclusivity edtf.Precision - EndUpperInclusivity edtf.Precision -} - -func NewTestResult(opts TestResultOptions) *TestResult { - - r := &TestResult{ - options: opts, - } - - return r -} - -func (r *TestResult) TestDate(d *edtf.EDTFDate) error { - - /* - - if d.Start.Lower.Time != nil { - fmt.Printf("[%s][start.lower] %s %d\n", d.String(), d.Start.Lower.Time.Format(time.RFC3339), d.Start.Lower.Time.Unix()) - } - - if d.Start.Upper.Time != nil { - fmt.Printf("[%s][start.upper] %s %d\n", d.String(), d.Start.Lower.Time.Format(time.RFC3339), d.Start.Lower.Time.Unix()) - } - - if d.End.Lower.Time != nil { - fmt.Printf("[%s][end.lower] %s %d\n", d.String(), d.End.Lower.Time.Format(time.RFC3339), d.End.Lower.Time.Unix()) - } - - if d.End.Upper.Time != nil { - fmt.Printf("[%s][end.upper] %s %d\n", d.String(), d.End.Lower.Time.Format(time.RFC3339), d.End.Lower.Time.Unix()) - } - - */ - - err := r.testRFC3339All(d) - - if err != nil { - return err - } - - err = r.testUnixAll(d) - - if err != nil { - return err - } - - err = r.testPrecisionAll(d) - - if err != nil { - return err - } - - err = r.testUncertainAll(d) - - if err != nil { - return err - } - - err = r.testApproximateAll(d) - - if err != nil { - return err - } - - err = r.testIsOpenAll(d) - - if err != nil { - return err - } - - err = r.testIsUnknownAll(d) - - if err != nil { - return err - } - - err = r.testInclusivityAll(d) - - if err != nil { - return err - } - - return nil -} - -func (r *TestResult) testIsOpenAll(d *edtf.EDTFDate) error { - - err := r.testBoolean(d.Start.Lower.Open, r.options.StartLowerIsOpen) - - if err != nil { - return fmt.Errorf("Invalid StartLowerIsOpen flag, %v", err) - } - - err = r.testBoolean(d.Start.Upper.Open, r.options.StartUpperIsOpen) - - if err != nil { - return fmt.Errorf("Invalid StartUpperIsOpen flag, %v", err) - } - - err = r.testBoolean(d.End.Lower.Open, r.options.EndLowerIsOpen) - - if err != nil { - return fmt.Errorf("Invalid EndLowerIsOpen flag, %v", err) - } - - err = r.testBoolean(d.End.Upper.Open, r.options.EndUpperIsOpen) - - if err != nil { - return fmt.Errorf("Invalid EndUpperIsOpen flag, %v", err) - } - - return nil -} - -func (r *TestResult) testIsUnknownAll(d *edtf.EDTFDate) error { - - err := r.testBoolean(d.Start.Lower.Unknown, r.options.StartLowerIsUnknown) - - if err != nil { - return fmt.Errorf("Invalid StartLowerIsUnknown flag, %v", err) - } - - err = r.testBoolean(d.Start.Upper.Unknown, r.options.StartUpperIsUnknown) - - if err != nil { - return fmt.Errorf("Invalid StartUpperIsUnknown flag, %v", err) - } - - err = r.testBoolean(d.End.Lower.Unknown, r.options.EndLowerIsUnknown) - - if err != nil { - return fmt.Errorf("Invalid EndLowerIsUnknown flag, %v", err) - } - - err = r.testBoolean(d.End.Upper.Unknown, r.options.EndUpperIsUnknown) - - if err != nil { - return fmt.Errorf("Invalid EndUpperIsUnknown flag, %v", err) - } - - return nil -} - -func (r *TestResult) testBoolean(candidate bool, expected bool) error { - - if candidate != expected { - return fmt.Errorf("Boolean test failed, expected '%t' but got '%t'", expected, candidate) - } - - return nil -} - -func (r *TestResult) testInclusivityAll(d *edtf.EDTFDate) error { - - err := r.testPrecision(d.Start.Lower.Inclusivity, r.options.StartLowerInclusivity) - - if err != nil { - return fmt.Errorf("Invalid StartLowerInclusivity flag, %v", err) - } - - err = r.testPrecision(d.Start.Upper.Inclusivity, r.options.StartUpperInclusivity) - - if err != nil { - return fmt.Errorf("Invalid StartUpperInclusivity flag, %v", err) - } - - err = r.testPrecision(d.End.Lower.Inclusivity, r.options.EndLowerInclusivity) - - if err != nil { - return fmt.Errorf("Invalid EndLowerInclusivity flag, %v", err) - } - - err = r.testPrecision(d.End.Upper.Inclusivity, r.options.EndUpperInclusivity) - - if err != nil { - return fmt.Errorf("Invalid EndUpperInclusivity flag, %v", err) - } - - return nil -} - -func (r *TestResult) testPrecisionAll(d *edtf.EDTFDate) error { - - err := r.testPrecision(d.Start.Lower.Precision, r.options.StartLowerPrecision) - - if err != nil { - return fmt.Errorf("Invalid StartLowerPrecision flag, %v", err) - } - - err = r.testPrecision(d.Start.Upper.Precision, r.options.StartUpperPrecision) - - if err != nil { - return fmt.Errorf("Invalid StartUpperPrecision flag, %v", err) - } - - err = r.testPrecision(d.End.Lower.Precision, r.options.EndLowerPrecision) - - if err != nil { - return fmt.Errorf("Invalid EndLowerPrecision flag, %v", err) - } - - err = r.testPrecision(d.End.Upper.Precision, r.options.EndUpperPrecision) - - if err != nil { - return fmt.Errorf("Invalid EndUpperPrecision flag, %v", err) - } - - return nil -} - -func (r *TestResult) testUncertainAll(d *edtf.EDTFDate) error { - - err := r.testPrecision(d.Start.Lower.Uncertain, r.options.StartLowerUncertain) - - if err != nil { - return fmt.Errorf("Invalid StartLowerUncertain flag, %v", err) - } - - err = r.testPrecision(d.Start.Upper.Uncertain, r.options.StartUpperUncertain) - - if err != nil { - return fmt.Errorf("Invalid StartUpperUncertain flag, %v", err) - } - - err = r.testPrecision(d.End.Lower.Uncertain, r.options.EndLowerUncertain) - - if err != nil { - return fmt.Errorf("Invalid EndLowerUncertain flag, %v", err) - } - - err = r.testPrecision(d.End.Upper.Uncertain, r.options.EndUpperUncertain) - - if err != nil { - return fmt.Errorf("Invalid EndUpperUncertain flag, %v", err) - } - - return nil -} - -func (r *TestResult) testApproximateAll(d *edtf.EDTFDate) error { - - err := r.testPrecision(d.Start.Lower.Approximate, r.options.StartLowerApproximate) - - if err != nil { - return fmt.Errorf("Invalid StartLowerApproximate flag, %v", err) - } - - err = r.testPrecision(d.Start.Upper.Approximate, r.options.StartUpperApproximate) - - if err != nil { - return fmt.Errorf("Invalid StartUpperApproximate flag, %v", err) - } - - err = r.testPrecision(d.End.Lower.Approximate, r.options.EndLowerApproximate) - - if err != nil { - return fmt.Errorf("Invalid EndLowerApproximate flag, %v", err) - } - - err = r.testPrecision(d.End.Upper.Approximate, r.options.EndUpperApproximate) - - if err != nil { - return fmt.Errorf("Invalid EndUpperApproximate flag, %v", err) - } - - return nil -} - -func (r *TestResult) testPrecision(flags edtf.Precision, expected edtf.Precision) error { - - if expected == edtf.NONE { - return nil - } - - if !flags.HasFlag(expected) { - return fmt.Errorf("Missing flag %v", expected) - } - - return nil -} - -func (r *TestResult) testRFC3339All(d *edtf.EDTFDate) error { - - if r.options.StartLowerTimeRFC3339 != "" { - - err := r.testRFC3339(r.options.StartLowerTimeRFC3339, d.Start.Lower.Timestamp) - - if err != nil { - return fmt.Errorf("Failed StartLowerTimeRFC3339 test, %v", err) - } - } - - if r.options.StartUpperTimeRFC3339 != "" { - - err := r.testRFC3339(r.options.StartUpperTimeRFC3339, d.Start.Upper.Timestamp) - - if err != nil { - return fmt.Errorf("Failed StartUpperTimeRFC3339 test, %v", err) - } - } - - if r.options.EndLowerTimeRFC3339 != "" { - - err := r.testRFC3339(r.options.EndLowerTimeRFC3339, d.End.Lower.Timestamp) - - if err != nil { - return fmt.Errorf("Failed EndLowerTimeRFC3339 test, %v", err) - } - } - - if r.options.EndUpperTimeRFC3339 != "" { - - err := r.testRFC3339(r.options.EndUpperTimeRFC3339, d.End.Upper.Timestamp) - - if err != nil { - return fmt.Errorf("Failed EndUpperTimeRFC3339 test, %v", err) - } - } - - return nil -} - -func (r *TestResult) testRFC3339(expected string, ts *edtf.Timestamp) error { - - if ts == nil { - return fmt.Errorf("Missing edtf.Timestamp instance") - } - - t := ts.Time() - - t_str := t.Format(time.RFC3339) - - if t_str != expected { - return fmt.Errorf("Invalid RFC3339 time, expected '%s' but got '%s'", expected, t_str) - } - - return nil -} - -func (r *TestResult) testUnixAll(d *edtf.EDTFDate) error { - - if r.options.StartLowerTimeUnix != 0 { - - err := r.testUnix(r.options.StartLowerTimeUnix, d.Start.Lower.Timestamp) - - if err != nil { - return fmt.Errorf("Failed StartLowerTimeUnix test, %v", err) - } - } - - if r.options.StartUpperTimeUnix != 0 { - - err := r.testUnix(r.options.StartUpperTimeUnix, d.Start.Upper.Timestamp) - - if err != nil { - return fmt.Errorf("Failed StartUpperTimeUnix test, %v", err) - } - } - - if r.options.EndLowerTimeUnix != 0 { - - err := r.testUnix(r.options.EndLowerTimeUnix, d.End.Lower.Timestamp) - - if err != nil { - return fmt.Errorf("Failed EndLowerTimeUnix test, %v", err) - } - } - - if r.options.EndUpperTimeUnix != 0 { - - err := r.testUnix(r.options.EndUpperTimeUnix, d.End.Upper.Timestamp) - - if err != nil { - return fmt.Errorf("Failed EndUpperTimeUnix test, %v", err) - } - } - - return nil -} - -func (r *TestResult) testUnix(expected int64, ts *edtf.Timestamp) error { - - if ts == nil { - return fmt.Errorf("Missing edtf.Timestamp instance") - } - - ts_unix := ts.Unix() - - if ts_unix != expected { - return fmt.Errorf("Invalid Unix time, expected '%d' but got '%d'", expected, ts_unix) - } - - return nil -} diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/feature/edtf.go b/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/feature/edtf.go deleted file mode 100644 index 4e35319..0000000 --- a/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/feature/edtf.go +++ /dev/null @@ -1,41 +0,0 @@ -package feature - -import ( - "fmt" - "github.com/sfomuseum/go-edtf" -) - -var deprecated map[string]string - -func init() { - - deprecated = map[string]string{ - edtf.OPEN_2012: edtf.OPEN, - edtf.UNSPECIFIED_2012: edtf.UNSPECIFIED, - } - -} - -func isDeprecatedEDTF(edtf_str string) bool { - - for test, _ := range deprecated { - - if edtf_str == test { - return true - } - } - - return false -} - -func replaceDeprecatedEDTF(old string) (string, error) { - - new, ok := deprecated[old] - - if !ok { - err := fmt.Errorf("Unknown or unsupported EDTF string '%s' : %v", old, deprecated) - return "", err - } - - return new, nil -} diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/feature/geojson.go b/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/feature/geojson.go index c6e4801..6f724b6 100644 --- a/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/feature/geojson.go +++ b/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/feature/geojson.go @@ -2,14 +2,13 @@ package feature import ( "encoding/json" - "github.com/sfomuseum/go-edtf" "github.com/skelterjohn/geom" "github.com/whosonfirst/go-whosonfirst-flags" "github.com/whosonfirst/go-whosonfirst-geojson-v2" "github.com/whosonfirst/go-whosonfirst-geojson-v2/geometry" props_geom "github.com/whosonfirst/go-whosonfirst-geojson-v2/properties/geometry" "github.com/whosonfirst/go-whosonfirst-geojson-v2/utils" - "github.com/whosonfirst/go-whosonfirst-spr/v2" + "github.com/whosonfirst/go-whosonfirst-spr" "strings" ) @@ -178,14 +177,6 @@ func (spr *GeoJSONStandardPlacesResult) Placetype() string { return spr.SPRPlacetype } -func (spr *GeoJSONStandardPlacesResult) Inception() *edtf.EDTFDate { - return nil -} - -func (spr *GeoJSONStandardPlacesResult) Cessation() *edtf.EDTFDate { - return nil -} - func (spr *GeoJSONStandardPlacesResult) Country() string { return "XX" } @@ -254,10 +245,6 @@ func (spr *GeoJSONStandardPlacesResult) Supersedes() []int64 { return []int64{} } -func (spr *GeoJSONStandardPlacesResult) BelongsTo() []int64 { - return []int64{} -} - func (spr *GeoJSONStandardPlacesResult) LastModified() int64 { return -1 } diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/feature/whosonfirst.go b/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/feature/whosonfirst.go index fb676e5..cb48168 100644 --- a/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/feature/whosonfirst.go +++ b/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/feature/whosonfirst.go @@ -3,8 +3,6 @@ package feature import ( "encoding/json" _ "errors" - "github.com/sfomuseum/go-edtf" - "github.com/sfomuseum/go-edtf/parser" "github.com/skelterjohn/geom" "github.com/whosonfirst/go-whosonfirst-flags" "github.com/whosonfirst/go-whosonfirst-flags/existential" @@ -13,7 +11,7 @@ import ( "github.com/whosonfirst/go-whosonfirst-geojson-v2/properties/whosonfirst" "github.com/whosonfirst/go-whosonfirst-geojson-v2/utils" "github.com/whosonfirst/go-whosonfirst-placetypes" - "github.com/whosonfirst/go-whosonfirst-spr/v2" + "github.com/whosonfirst/go-whosonfirst-spr" "github.com/whosonfirst/go-whosonfirst-uri" "github.com/whosonfirst/warning" "strconv" @@ -26,8 +24,6 @@ type WOFFeature struct { type WOFStandardPlacesResult struct { spr.StandardPlacesResult `json:",omitempty"` - EDTFInception string `json:"edtf:inception"` - EDTFCessation string `json:"edtf:cessation"` WOFId int64 `json:"wof:id"` WOFParentId int64 `json:"wof:parent_id"` WOFName string `json:"wof:name"` @@ -37,7 +33,6 @@ type WOFStandardPlacesResult struct { WOFPath string `json:"wof:path"` WOFSupersededBy []int64 `json:"wof:superseded_by"` WOFSupersedes []int64 `json:"wof:supersedes"` - WOFBelongsTo []int64 `json:"wof:belongsto"` MZURI string `json:"mz:uri"` MZLatitude float64 `json:"mz:latitude"` MZLongitude float64 `json:"mz:longitude"` @@ -196,47 +191,6 @@ func (f *WOFFeature) SPR() (spr.StandardPlacesResult, error) { country := whosonfirst.Country(f) repo := whosonfirst.Repo(f) - inception := whosonfirst.Inception(f) - cessation := whosonfirst.Cessation(f) - - // See this: We're accounting for all the pre-2019 EDTF spec - // inception but mostly cessation strings by silently swapping - // them out (20210321/straup) - - _, err := parser.ParseString(inception) - - if err != nil { - - if !isDeprecatedEDTF(inception) { - return nil, err - } - - replacement, err := replaceDeprecatedEDTF(inception) - - if err != nil { - return nil, err - } - - inception = replacement - } - - _, err = parser.ParseString(cessation) - - if err != nil { - - if !isDeprecatedEDTF(cessation) { - return nil, err - } - - replacement, err := replaceDeprecatedEDTF(cessation) - - if err != nil { - return nil, err - } - - cessation = replacement - } - path, err := uri.Id2RelPath(id) if err != nil { @@ -296,7 +250,6 @@ func (f *WOFFeature) SPR() (spr.StandardPlacesResult, error) { superseded_by := whosonfirst.SupersededBy(f) supersedes := whosonfirst.Supersedes(f) - belongsto := whosonfirst.BelongsTo(f) lastmod := whosonfirst.LastModified(f) @@ -310,9 +263,6 @@ func (f *WOFFeature) SPR() (spr.StandardPlacesResult, error) { WOFPath: path, WOFSupersedes: supersedes, WOFSupersededBy: superseded_by, - WOFBelongsTo: belongsto, - EDTFInception: inception, - EDTFCessation: cessation, MZURI: uri, MZLatitude: coord.Y, MZLongitude: coord.X, @@ -343,25 +293,6 @@ func (spr *WOFStandardPlacesResult) Name() string { return spr.WOFName } -func (spr *WOFStandardPlacesResult) Inception() *edtf.EDTFDate { - return spr.edtfDate(spr.EDTFInception) -} - -func (spr *WOFStandardPlacesResult) Cessation() *edtf.EDTFDate { - return spr.edtfDate(spr.EDTFCessation) -} - -func (spr *WOFStandardPlacesResult) edtfDate(edtf_str string) *edtf.EDTFDate { - - d, err := parser.ParseString(edtf_str) - - if err != nil { - return nil - } - - return d -} - func (spr *WOFStandardPlacesResult) Placetype() string { return spr.WOFPlacetype } @@ -434,10 +365,6 @@ func (spr *WOFStandardPlacesResult) Supersedes() []int64 { return spr.WOFSupersedes } -func (spr *WOFStandardPlacesResult) BelongsTo() []int64 { - return spr.WOFBelongsTo -} - func (spr *WOFStandardPlacesResult) LastModified() int64 { return spr.WOFLastModified } diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/feature/whosonfirst_alt.go b/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/feature/whosonfirst_alt.go index 39ce922..05034e7 100644 --- a/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/feature/whosonfirst_alt.go +++ b/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/feature/whosonfirst_alt.go @@ -4,14 +4,13 @@ import ( "encoding/json" "errors" "fmt" - "github.com/sfomuseum/go-edtf" "github.com/skelterjohn/geom" "github.com/whosonfirst/go-whosonfirst-flags" "github.com/whosonfirst/go-whosonfirst-geojson-v2" "github.com/whosonfirst/go-whosonfirst-geojson-v2/geometry" props_wof "github.com/whosonfirst/go-whosonfirst-geojson-v2/properties/whosonfirst" "github.com/whosonfirst/go-whosonfirst-geojson-v2/utils" - "github.com/whosonfirst/go-whosonfirst-spr/v2" + "github.com/whosonfirst/go-whosonfirst-spr" "github.com/whosonfirst/go-whosonfirst-uri" "github.com/whosonfirst/warning" "strconv" @@ -244,14 +243,6 @@ func (spr *WOFAltStandardPlacesResult) MaxLongitude() float64 { return spr.MZMaxLongitude } -func (spr *WOFAltStandardPlacesResult) Inception() *edtf.EDTFDate { - return nil -} - -func (spr *WOFAltStandardPlacesResult) Cessation() *edtf.EDTFDate { - return nil -} - func (spr *WOFAltStandardPlacesResult) IsCurrent() flags.ExistentialFlag { return existentialFlag(-1) } @@ -280,10 +271,6 @@ func (spr *WOFAltStandardPlacesResult) Supersedes() []int64 { return []int64{} } -func (spr *WOFAltStandardPlacesResult) BelongsTo() []int64 { - return []int64{} -} - func (spr *WOFAltStandardPlacesResult) LastModified() int64 { return -1 } diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/geojson.go b/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/geojson.go index 7c71ea1..741a5e9 100644 --- a/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/geojson.go +++ b/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/geojson.go @@ -2,7 +2,7 @@ package geojson import ( "github.com/skelterjohn/geom" - "github.com/whosonfirst/go-whosonfirst-spr/v2" + "github.com/whosonfirst/go-whosonfirst-spr" ) type Feature interface { diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/geometry/polygon.go b/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/geometry/polygon.go index 9380a21..ce3a499 100644 --- a/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/geometry/polygon.go +++ b/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/geometry/polygon.go @@ -34,7 +34,7 @@ func (p Polygon) ContainsCoord(c geom.Coord) bool { } for _, int := range p.InteriorRings() { - + if int.ContainsCoord(c) { return false } @@ -151,7 +151,7 @@ func newPolygon(rings [][][]float64) Polygon { if len(rings) > 1 { - for _, coords := range rings[1:] { + for _, coords := range rings { interior = append(interior, newRing(coords)) } } diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/go.mod b/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/go.mod index 989e5b6..29a9816 100644 --- a/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/go.mod +++ b/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/go.mod @@ -3,15 +3,14 @@ module github.com/whosonfirst/go-whosonfirst-geojson-v2 go 1.12 require ( - github.com/mmcloughlin/geohash v0.10.0 + github.com/mmcloughlin/geohash v0.9.0 github.com/paulmach/go.geojson v1.4.0 - github.com/sfomuseum/go-edtf v0.2.3 github.com/skelterjohn/geom v0.0.0-20180103142417-96f3e8a219c5 - github.com/tidwall/gjson v1.6.8 - github.com/whosonfirst/go-whosonfirst-flags v0.4.2 + github.com/tidwall/gjson v1.6.0 + github.com/whosonfirst/go-whosonfirst-flags v0.1.0 github.com/whosonfirst/go-whosonfirst-hash v0.1.0 - github.com/whosonfirst/go-whosonfirst-placetypes v0.3.0 - github.com/whosonfirst/go-whosonfirst-spr/v2 v2.0.0 + github.com/whosonfirst/go-whosonfirst-placetypes v0.1.0 + github.com/whosonfirst/go-whosonfirst-spr v0.1.0 github.com/whosonfirst/go-whosonfirst-uri v0.2.0 - github.com/whosonfirst/warning v0.1.1 + github.com/whosonfirst/warning v0.1.0 ) diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/go.sum b/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/go.sum index 66aa561..c326b61 100644 --- a/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/go.sum +++ b/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/go.sum @@ -10,19 +10,12 @@ github.com/hashicorp/go-multierror v0.0.0-20171204182908-b7773ae21874/go.mod h1: github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/mmcloughlin/geohash v0.9.0 h1:FihR004p/aE1Sju6gcVq5OLDqGcMnpBY+8moBqIsVOs= github.com/mmcloughlin/geohash v0.9.0/go.mod h1:oNZxQo5yWJh0eMQEP/8hwQuVx9Z9tjwFUqcTB1SmG0c= -github.com/mmcloughlin/geohash v0.10.0 h1:9w1HchfDfdeLc+jFEf/04D27KP7E2QmpDu52wPbJWRE= -github.com/mmcloughlin/geohash v0.10.0/go.mod h1:oNZxQo5yWJh0eMQEP/8hwQuVx9Z9tjwFUqcTB1SmG0c= github.com/paulmach/go.geojson v1.4.0 h1:5x5moCkCtDo5x8af62P9IOAYGQcYHtxz2QJ3x1DoCgY= github.com/paulmach/go.geojson v1.4.0/go.mod h1:YaKx1hKpWF+T2oj2lFJPsW/t1Q5e1jQI61eoQSTwpIs= github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -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.7.0/go.mod h1:ML3DTNbF9xnjExSdS/9FtVLjIUhRU5gm/ehzISv+t2w= github.com/skelterjohn/geom v0.0.0-20180103000000-96f3e8a219c5f4276b0dda3568d80c4e02a50116 h1:3viuBF2tRGd2HlEs/uL4LLmdjOj8kAO6Y2c8Ii4H0oI= github.com/skelterjohn/geom v0.0.0-20180103000000-96f3e8a219c5f4276b0dda3568d80c4e02a50116/go.mod h1:w8cQIijHlvvZM7afYlixPThHAdD+AkRFw3Mb9yQ2Y+I= github.com/skelterjohn/geom v0.0.0-20180103142417-96f3e8a219c5 h1:qQF/q/+xaKD4CAVz3zfuvpij8U4ihSGIhHfOROI4NFc= @@ -40,48 +33,30 @@ github.com/tidwall/gjson v1.3.4 h1:On5waDnyKKk3SWE4EthbjjirAWXp43xx5cKCUZY1eZw= github.com/tidwall/gjson v1.3.4/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls= github.com/tidwall/gjson v1.6.0 h1:9VEQWz6LLMUsUl6PueE49ir4Ka6CzLymOAZDxpFsTDc= github.com/tidwall/gjson v1.6.0/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls= -github.com/tidwall/gjson v1.6.8 h1:CTmXMClGYPAmln7652e69B7OLXfTi5ABcPPwjIWUv7w= -github.com/tidwall/gjson v1.6.8/go.mod h1:zeFuBCIqD4sN/gmqBzZ4j7Jd6UcA2Fc56x7QFsv+8fI= github.com/tidwall/match v1.0.1 h1:PnKP62LPNxHKTwvHHZZzdOAOCtsJTjo6dZLCwpKm5xc= github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E= -github.com/tidwall/match v1.0.3 h1:FQUVvBImDutD8wJLN6c5eMzWtjgONK9MwIBCOrUJKeE= -github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v0.0.0-20190325153808-1166b9ac2b65 h1:rQ229MBgvW68s1/g6f1/63TgYwYxfF4E+bi/KC19P8g= github.com/tidwall/pretty v0.0.0-20190325153808-1166b9ac2b65/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= -github.com/tidwall/pretty v1.0.2 h1:Z7S3cePv9Jwm1KwS0513MRaoUe3S01WPbLNV40pwWZU= -github.com/tidwall/pretty v1.0.2/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/whosonfirst/go-whosonfirst-cli v0.1.0 h1:Wwj9z0R/ryHmPmpVm5jCbXdG4agJzKMWXDtPVReN/KA= github.com/whosonfirst/go-whosonfirst-cli v0.1.0/go.mod h1:Edy+amD+fMq1QS1yxB3u8maA8I93q/LG7JRNh+fsdfc= github.com/whosonfirst/go-whosonfirst-flags v0.1.0 h1:llb2wtsI2y+gHZCmWaamMCx4YDRE8ZXQRRYqC7qB4so= 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.0 h1:3qEz1v7rALk+TqVstW9DKQOWrMqUIIFInmOiLvsKBZY= -github.com/whosonfirst/go-whosonfirst-flags v0.4.0/go.mod h1:kewFjxBiE00SqjjIanm5DPI81SYvx93wVb3ogwV/PMk= -github.com/whosonfirst/go-whosonfirst-flags v0.4.2 h1:HWjy/0MfAQMdCj4M9hi3LAITgK/D+cuDWGHP37mFeZo= -github.com/whosonfirst/go-whosonfirst-flags v0.4.2/go.mod h1:kewFjxBiE00SqjjIanm5DPI81SYvx93wVb3ogwV/PMk= 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-placetypes v0.1.0 h1:zuSk8eqeEkg42sIZ4EF71IMtphdTbG80qJsXhuZXXbM= github.com/whosonfirst/go-whosonfirst-placetypes v0.1.0/go.mod h1:Jdmug2QQLbrmg+UcYGz8k575GnrOEg63vZVS46e5fMs= -github.com/whosonfirst/go-whosonfirst-placetypes v0.2.4/go.mod h1:yl0zZ5tfK80C0kl34pJcPB3mZC5XXR7ybQJ5OJyEcDU= -github.com/whosonfirst/go-whosonfirst-placetypes v0.3.0 h1:68kuizK8FXjfEIOKlqWemhs7gyMBIgpLJDbCZF8+8Ok= -github.com/whosonfirst/go-whosonfirst-placetypes v0.3.0/go.mod h1:ez0VFkGFbgT2/z2oi3PIuW6FewsZ2+5glyfDD79XEHk= github.com/whosonfirst/go-whosonfirst-sources v0.1.0 h1:JuKLa6KWke22jBfJ1pM9WQHoz1/3pbDv2C+aR+THPPQ= github.com/whosonfirst/go-whosonfirst-sources v0.1.0/go.mod h1:EUMHyGzUmqPPxlMmOp+28BFeoBdxxE0HCKRd67lkqGM= github.com/whosonfirst/go-whosonfirst-spr v0.1.0 h1:5qE629nCiucF2upy5NjPOEl9cFatsljykYY0l2JKgAk= github.com/whosonfirst/go-whosonfirst-spr v0.1.0/go.mod h1:R8GtEVz1GVSnwwOjzcoVUd172ZK26Q7hQSLI6SGG7lM= -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-uri v0.1.0 h1:JMlpam0x1hVrFBMTAPY3edIHz7azfMK8lLI2kM9BgbI= github.com/whosonfirst/go-whosonfirst-uri v0.1.0/go.mod h1:8eaDVcc4v+HHHEDaRbApdmhPwM4/JQllw2PktvZcPVs= github.com/whosonfirst/go-whosonfirst-uri v0.2.0 h1:iODHdyvW+8IXqHZTixZ/9GEZy1dVKGj6dMRg7fn0d2M= github.com/whosonfirst/go-whosonfirst-uri v0.2.0/go.mod h1:8eaDVcc4v+HHHEDaRbApdmhPwM4/JQllw2PktvZcPVs= github.com/whosonfirst/warning v0.1.0 h1:NgMa6a6Xv7FdDNgpqK5j/FDo6qrcFzFtidAExDqPfC0= github.com/whosonfirst/warning v0.1.0/go.mod h1:cAez7FpC/UEUrbiOXZO15v2JM8eijtFHQlN93AGFy1k= -github.com/whosonfirst/warning v0.1.1 h1:h29zL3VNL9VUHztkAAndzblhrDHyik9z47OuUR2Vovw= -github.com/whosonfirst/warning v0.1.1/go.mod h1:/unEMzhB9YaMeEwTJpzLN3kM5LiSxdJhKEsf/OQhn6s= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/properties/whosonfirst/whosonfirst.go b/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/properties/whosonfirst/whosonfirst.go index b1014bf..475587c 100644 --- a/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/properties/whosonfirst/whosonfirst.go +++ b/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/properties/whosonfirst/whosonfirst.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "fmt" - "github.com/sfomuseum/go-edtf" "github.com/skelterjohn/geom" "github.com/tidwall/gjson" "github.com/whosonfirst/go-whosonfirst-flags" @@ -183,9 +182,9 @@ func LabelOrDerived(f geojson.Feature) string { inc := Inception(f) ces := Cessation(f) - if inc == edtf.UNKNOWN && ces == edtf.UNKNOWN { + if inc == "uuuu" && ces == "uuuu" { label = name - } else if ces == "open" || ces == edtf.UNKNOWN { + } else if ces == "open" || ces == "uuuu" { label = fmt.Sprintf("%s (%s)", name, inc) } else { label = fmt.Sprintf("%s (%s - %s)", name, inc, ces) @@ -196,25 +195,25 @@ func LabelOrDerived(f geojson.Feature) string { } func Inception(f geojson.Feature) string { - return utils.StringProperty(f.Bytes(), []string{"properties.edtf:inception"}, edtf.UNKNOWN) + return utils.StringProperty(f.Bytes(), []string{"properties.edtf:inception"}, "uuuu") } func Cessation(f geojson.Feature) string { - return utils.StringProperty(f.Bytes(), []string{"properties.edtf:cessation"}, edtf.UNKNOWN) + return utils.StringProperty(f.Bytes(), []string{"properties.edtf:cessation"}, "uuuu") } func DateSpan(f geojson.Feature) string { - lower := utils.StringProperty(f.Bytes(), []string{"properties.date:inception_lower"}, edtf.UNKNOWN) - upper := utils.StringProperty(f.Bytes(), []string{"properties.date:cessation_upper"}, edtf.UNKNOWN) + lower := utils.StringProperty(f.Bytes(), []string{"properties.date:inception_lower"}, "uuuu") + upper := utils.StringProperty(f.Bytes(), []string{"properties.date:cessation_upper"}, "uuuu") /* - if lower == edtf.UNKNOWN { - lower = utils.StringProperty(f.Bytes(), []string{"properties.edtf:inception"}, edtf.UNKNOWN) + if lower == "uuuu" { + lower = utils.StringProperty(f.Bytes(), []string{"properties.edtf:inception"}, "uuuu") } - if upper == edtf.UNKNOWN { - upper = utils.StringProperty(f.Bytes(), []string{"properties.edtf:cessation"}, edtf.UNKNOWN) + if upper == "uuuu" { + upper = utils.StringProperty(f.Bytes(), []string{"properties.edtf:cessation"}, "uuuu") } */ @@ -223,8 +222,8 @@ func DateSpan(f geojson.Feature) string { func DateRange(f geojson.Feature) (*time.Time, *time.Time, error) { - str_lower := utils.StringProperty(f.Bytes(), []string{"properties.date:inception_lower"}, edtf.UNKNOWN) - str_upper := utils.StringProperty(f.Bytes(), []string{"properties.date:cessation_upper"}, edtf.UNKNOWN) + str_lower := utils.StringProperty(f.Bytes(), []string{"properties.date:inception_lower"}, "uuuu") + str_upper := utils.StringProperty(f.Bytes(), []string{"properties.date:cessation_upper"}, "uuuu") ymd := "2006-01-02" @@ -365,27 +364,8 @@ func IsDeprecated(f geojson.Feature) (flags.ExistentialFlag, error) { "properties.edtf:deprecated", } - // "-" is not part of the EDTF spec it's just a default - // string that we define for use in the switch statements - // below (20210209/thisisaaronland) - v := utils.StringProperty(f.Bytes(), possible, "-") - // 2019 EDTF spec (ISO-8601:1/2) - - switch v { - case "-": - return existential.NewKnownUnknownFlag(0) - case edtf.UNKNOWN: - return existential.NewKnownUnknownFlag(-1) - default: - // pass - } - - // 2012 EDTF spec - annoyingly the semantics of "" - // changed between the two (was meant to signal open - // and now signals unknown) - switch v { case "-": return existential.NewKnownUnknownFlag(0) @@ -394,10 +374,8 @@ func IsDeprecated(f geojson.Feature) (flags.ExistentialFlag, error) { case "uuuu": return existential.NewKnownUnknownFlag(-1) default: - // + return existential.NewKnownUnknownFlag(1) } - - return existential.NewKnownUnknownFlag(1) } func IsCeased(f geojson.Feature) (flags.ExistentialFlag, error) { @@ -408,21 +386,6 @@ func IsCeased(f geojson.Feature) (flags.ExistentialFlag, error) { v := utils.StringProperty(f.Bytes(), possible, "uuuu") - // 2019 EDTF spec (ISO-8601:1/2) - - switch v { - case edtf.OPEN: - return existential.NewKnownUnknownFlag(0) - case edtf.UNKNOWN: - return existential.NewKnownUnknownFlag(-1) - default: - // pass - } - - // 2012 EDTF spec - annoyingly the semantics of "" - // changed between the two (was meant to signal open - // and now signals unknown) - switch v { case "": return existential.NewKnownUnknownFlag(0) @@ -431,10 +394,8 @@ func IsCeased(f geojson.Feature) (flags.ExistentialFlag, error) { case "uuuu": return existential.NewKnownUnknownFlag(-1) default: - // pass + return existential.NewKnownUnknownFlag(1) } - - return existential.NewKnownUnknownFlag(1) } func IsSuperseded(f geojson.Feature) (flags.ExistentialFlag, error) { diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-spr/v2/.gitignore b/vendor/github.com/whosonfirst/go-whosonfirst-spr/.gitignore similarity index 100% rename from vendor/github.com/whosonfirst/go-whosonfirst-spr/v2/.gitignore rename to vendor/github.com/whosonfirst/go-whosonfirst-spr/.gitignore diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-spr/v2/LICENSE b/vendor/github.com/whosonfirst/go-whosonfirst-spr/LICENSE similarity index 100% rename from vendor/github.com/whosonfirst/go-whosonfirst-spr/v2/LICENSE rename to vendor/github.com/whosonfirst/go-whosonfirst-spr/LICENSE diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-spr/v2/Makefile b/vendor/github.com/whosonfirst/go-whosonfirst-spr/Makefile similarity index 100% rename from vendor/github.com/whosonfirst/go-whosonfirst-spr/v2/Makefile rename to vendor/github.com/whosonfirst/go-whosonfirst-spr/Makefile diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-spr/README.md b/vendor/github.com/whosonfirst/go-whosonfirst-spr/README.md new file mode 100644 index 0000000..be16bab --- /dev/null +++ b/vendor/github.com/whosonfirst/go-whosonfirst-spr/README.md @@ -0,0 +1,53 @@ +# go-whosonfirst-spr + +Go tools for working Who's On First "standard places responses" (SPR) + +## Install + +You will need to have both `Go` (specifically [version 1.12](https://golang.org/dl/) or higher because we're using [Go modules](https://github.com/golang/go/wiki/Modules)) and the `make` programs installed on your computer. Assuming you do just type: + +All of this package's dependencies are bundled with the code in the `vendor` directory. + +## Interface + +_Please finish writing me..._ + +``` +type StandardPlacesResult interface { + Id() string + ParentId() string + Name() string + Placetype() string + Country() string + Repo() string + Path() string + URI() string + Latitude() float64 + Longitude() float64 + MinLatitude() float64 + MinLongitude() float64 + MaxLatitude() float64 + MaxLongitude() float64 + IsCurrent() flags.ExistentialFlag + IsCeased() flags.ExistentialFlag + IsDeprecated() flags.ExistentialFlag + IsSuperseded() flags.ExistentialFlag + IsSuperseding() flags.ExistentialFlag + SupersededBy() []int64 + Supersedes() []int64 +} +``` + +Flags are defined in the [go-whosonfirst-flags](https://github.com/whosonfirst/go-whosonfirst-flags) package. + +## Background + +_Please write me..._ + +* https://code.flickr.net/2008/08/19/standard-photos-response-apis-for-civilized-age/ +* https://code.flickr.net/2008/08/25/api-responses-as-feeds/ + +## See also + +* https://github.com/whosonfirst/go-whosonfirst-geojson-v2 +* https://github.com/whosonfirst/go-whosonfirst-flags diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-spr/go.mod b/vendor/github.com/whosonfirst/go-whosonfirst-spr/go.mod new file mode 100644 index 0000000..c25c885 --- /dev/null +++ b/vendor/github.com/whosonfirst/go-whosonfirst-spr/go.mod @@ -0,0 +1,5 @@ +module github.com/whosonfirst/go-whosonfirst-spr + +require github.com/whosonfirst/go-whosonfirst-flags v0.1.0 + +go 1.12 diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-spr/v2/go.sum b/vendor/github.com/whosonfirst/go-whosonfirst-spr/go.sum similarity index 66% rename from vendor/github.com/whosonfirst/go-whosonfirst-spr/v2/go.sum rename to vendor/github.com/whosonfirst/go-whosonfirst-spr/go.sum index 5fa5d1c..a6657e7 100644 --- a/vendor/github.com/whosonfirst/go-whosonfirst-spr/v2/go.sum +++ b/vendor/github.com/whosonfirst/go-whosonfirst-spr/go.sum @@ -4,23 +4,13 @@ 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/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -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/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/whosonfirst/go-whosonfirst-cli v0.1.0/go.mod h1:Edy+amD+fMq1QS1yxB3u8maA8I93q/LG7JRNh+fsdfc= github.com/whosonfirst/go-whosonfirst-flags v0.1.0 h1:llb2wtsI2y+gHZCmWaamMCx4YDRE8ZXQRRYqC7qB4so= github.com/whosonfirst/go-whosonfirst-flags v0.1.0/go.mod h1:bovMiQphaVhqemXFmNVf9Ts0tqnWtzHRFMUSKX+zTE8= -github.com/whosonfirst/go-whosonfirst-flags v0.2.0 h1:zia/L+rhKSQ5iruITPnwU9lqsd1SavvF+HYRubEARSs= -github.com/whosonfirst/go-whosonfirst-flags v0.2.0/go.mod h1:ECd0AJJZIlybmjTGB9z+CPz9pSiMTwxur7fPKmDnoqI= github.com/whosonfirst/go-whosonfirst-placetypes v0.1.0/go.mod h1:Jdmug2QQLbrmg+UcYGz8k575GnrOEg63vZVS46e5fMs= -github.com/whosonfirst/go-whosonfirst-placetypes v0.2.4/go.mod h1:yl0zZ5tfK80C0kl34pJcPB3mZC5XXR7ybQJ5OJyEcDU= -github.com/whosonfirst/go-whosonfirst-sources v0.1.0/go.mod h1:EUMHyGzUmqPPxlMmOp+28BFeoBdxxE0HCKRd67lkqGM= -github.com/whosonfirst/go-whosonfirst-spr v0.1.0 h1:5qE629nCiucF2upy5NjPOEl9cFatsljykYY0l2JKgAk= -github.com/whosonfirst/go-whosonfirst-spr v0.1.0/go.mod h1:R8GtEVz1GVSnwwOjzcoVUd172ZK26Q7hQSLI6SGG7lM= -github.com/whosonfirst/go-whosonfirst-uri v0.2.0/go.mod h1:8eaDVcc4v+HHHEDaRbApdmhPwM4/JQllw2PktvZcPVs= github.com/whosonfirst/warning v0.1.0/go.mod h1:cAez7FpC/UEUrbiOXZO15v2JM8eijtFHQlN93AGFy1k= -github.com/whosonfirst/warning v0.1.1/go.mod h1:/unEMzhB9YaMeEwTJpzLN3kM5LiSxdJhKEsf/OQhn6s= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-spr/v2/spr.go b/vendor/github.com/whosonfirst/go-whosonfirst-spr/spr.go similarity index 88% rename from vendor/github.com/whosonfirst/go-whosonfirst-spr/v2/spr.go rename to vendor/github.com/whosonfirst/go-whosonfirst-spr/spr.go index a675bed..7c66cea 100644 --- a/vendor/github.com/whosonfirst/go-whosonfirst-spr/v2/spr.go +++ b/vendor/github.com/whosonfirst/go-whosonfirst-spr/spr.go @@ -2,7 +2,6 @@ package spr import ( "github.com/whosonfirst/go-whosonfirst-flags" - "github.com/sfomuseum/go-edtf" ) type StandardPlacesResult interface { @@ -14,8 +13,6 @@ type StandardPlacesResult interface { Repo() string Path() string URI() string - Inception() *edtf.EDTFDate - Cessation() *edtf.EDTFDate Latitude() float64 Longitude() float64 MinLatitude() float64 @@ -29,7 +26,6 @@ type StandardPlacesResult interface { IsSuperseding() flags.ExistentialFlag SupersededBy() []int64 Supersedes() []int64 - BelongsTo() []int64 LastModified() int64 } diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-spr/v2/README.md b/vendor/github.com/whosonfirst/go-whosonfirst-spr/v2/README.md deleted file mode 100644 index 0b4a354..0000000 --- a/vendor/github.com/whosonfirst/go-whosonfirst-spr/v2/README.md +++ /dev/null @@ -1,71 +0,0 @@ -# go-whosonfirst-spr - -Go package for the Who's On First "standard places responses" (SPR) interface. - -## Description - -The `StandardPlacesResult` (SPR) interface defines the _minimum_ set of methods that a system working with a collection of Who's On First (WOF) must implement for any given record. Not all records are the same so the SPR interface is meant to serve as a baseline for common data that describes every record. - -The `StandardPlacesResults` takes the Flickr [standard photo response](https://code.flickr.net/2008/08/19/standard-photos-response-apis-for-civilized-age) as its inspiration which was designed to be the minimum amount of information about a Flickr photo necessary to display that photo with proper attribution and a link back to the photo page itself. The `StandardPlacesResults` aims to achieve the same thing for WOF records. - -Being a [Go language interface type](https://www.alexedwards.net/blog/interfaces-explained) the SPR is _not_ designed as a data exchange method. Any given implementation of the SPR _may_ allow its internal data to be exported or serialized (for example, as JSON) but this is not a requirement. - -For a concrete example of a package that implements the `SPR` have a look at the [go-whosonfirst-sqlite-spr](https://github.com/whosonfirst/go-whosonfirst-sqlite-spr) package. - -## Usage - -``` -import "github.com/whosonfirst/go-whosonfirst-spr/v2" -``` - -## Interface - -``` -type StandardPlacesResult interface { - Id() string - ParentId() string - Name() string - Placetype() string - Country() string - Repo() string - Path() string - URI() string - Inception() *edtf.EDTFDate - Cessation() *edtf.EDTFDate - Latitude() float64 - Longitude() float64 - MinLatitude() float64 - MinLongitude() float64 - MaxLatitude() float64 - MaxLongitude() float64 - IsCurrent() flags.ExistentialFlag - IsCeased() flags.ExistentialFlag - IsDeprecated() flags.ExistentialFlag - IsSuperseded() flags.ExistentialFlag - IsSuperseding() flags.ExistentialFlag - SupersededBy() []int64 - Supersedes() []int64 - BelongsTo() []int64 - LastModified() int64 -} -``` - -### Notes - -* The `Id()` and `ParentId()` methods return `string` (rather than `int64`) values to account for non-WOF GeoJSON documents that are consumed by the `whosonfirst/go-whosonfirst-geojson-v2` package. - -* Flags are defined in the [go-whosonfirst-flags](https://github.com/whosonfirst/go-whosonfirst-flags) package. - -* The `Path()` method is expected to return a relative URI. The `URI` method is expected to return a fully-qualified URI. These two methods are confusing and that confusion should be addressed. - -## See also - -* https://github.com/whosonfirst/go-whosonfirst-geojson-v2 -* https://github.com/whosonfirst/go-whosonfirst-flags -* https://github.com/whosonfirst/go-whosonfirst-sqlite-spr -* https://github.com/sfomuseum/go-edtf - -### Related - -* https://code.flickr.net/2008/08/19/standard-photos-response-apis-for-civilized-age/ -* https://code.flickr.net/2008/08/25/api-responses-as-feeds/ diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-spr/v2/go.mod b/vendor/github.com/whosonfirst/go-whosonfirst-spr/v2/go.mod deleted file mode 100644 index e8aad89..0000000 --- a/vendor/github.com/whosonfirst/go-whosonfirst-spr/v2/go.mod +++ /dev/null @@ -1,8 +0,0 @@ -module github.com/whosonfirst/go-whosonfirst-spr/v2 - -go 1.12 - -require ( - github.com/sfomuseum/go-edtf v0.2.2 - github.com/whosonfirst/go-whosonfirst-flags v0.2.0 -) diff --git a/vendor/modules.txt b/vendor/modules.txt index 2146bfb..397ad76 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,7 +7,7 @@ github.com/aaronland/go-roster github.com/hashicorp/errwrap # github.com/hashicorp/go-multierror v0.0.0-20171204182908-b7773ae21874 github.com/hashicorp/go-multierror -# github.com/mmcloughlin/geohash v0.10.0 +# github.com/mmcloughlin/geohash v0.9.0 github.com/mmcloughlin/geohash # github.com/paulmach/go.geojson v1.4.0 github.com/paulmach/go.geojson @@ -19,16 +19,7 @@ github.com/paulmach/orb/internal/length github.com/paulmach/orb/planar # github.com/sfomuseum/go-edtf v0.3.0 github.com/sfomuseum/go-edtf -github.com/sfomuseum/go-edtf/calendar -github.com/sfomuseum/go-edtf/common -github.com/sfomuseum/go-edtf/level0 -github.com/sfomuseum/go-edtf/level1 -github.com/sfomuseum/go-edtf/level2 -github.com/sfomuseum/go-edtf/parser -github.com/sfomuseum/go-edtf/re -github.com/sfomuseum/go-edtf/tests -# github.com/sfomuseum/go-sfomuseum-geojson v0.1.3 -## explicit +# github.com/sfomuseum/go-sfomuseum-geojson v0.1.2 github.com/sfomuseum/go-sfomuseum-geojson/feature # github.com/sfomuseum/go-sfomuseum-reader v0.0.1 ## explicit @@ -55,8 +46,7 @@ github.com/whosonfirst/go-whosonfirst-feature/properties # github.com/whosonfirst/go-whosonfirst-flags v0.4.3 github.com/whosonfirst/go-whosonfirst-flags github.com/whosonfirst/go-whosonfirst-flags/existential -# github.com/whosonfirst/go-whosonfirst-geojson-v2 v0.16.3 -## explicit +# github.com/whosonfirst/go-whosonfirst-geojson-v2 v0.14.1 github.com/whosonfirst/go-whosonfirst-geojson-v2 github.com/whosonfirst/go-whosonfirst-geojson-v2/feature github.com/whosonfirst/go-whosonfirst-geojson-v2/geometry @@ -76,8 +66,8 @@ github.com/whosonfirst/go-whosonfirst-placetypes/placetypes # github.com/whosonfirst/go-whosonfirst-sources v0.1.0 github.com/whosonfirst/go-whosonfirst-sources github.com/whosonfirst/go-whosonfirst-sources/sources -# github.com/whosonfirst/go-whosonfirst-spr/v2 v2.0.0 -github.com/whosonfirst/go-whosonfirst-spr/v2 +# github.com/whosonfirst/go-whosonfirst-spr v0.1.0 +github.com/whosonfirst/go-whosonfirst-spr # github.com/whosonfirst/go-whosonfirst-uri v1.1.0 ## explicit github.com/whosonfirst/go-whosonfirst-uri