From b213cbb9e7da7fc80f6479a327d6a42305ecd5f2 Mon Sep 17 00:00:00 2001 From: sfomuseumbot Date: Fri, 16 Dec 2022 18:15:57 -0800 Subject: [PATCH] update to use whosonfirst/go-whosonfirst-spatial v0.5.4 --- go.mod | 4 +- go.sum | 8 +- .../go-whosonfirst-spatial/README.md | 124 ++++++++++-------- .../go-whosonfirst-spatial/flags/common.go | 22 ++-- .../go-whosonfirst-spatial/flags/flags.go | 86 +++++++++--- .../go-whosonfirst-spatial/flags/iterator.go | 6 +- .../go-whosonfirst-spatial/flags/query.go | 76 +++++------ vendor/modules.txt | 4 +- 8 files changed, 188 insertions(+), 142 deletions(-) diff --git a/go.mod b/go.mod index 393cd6e..48defd1 100644 --- a/go.mod +++ b/go.mod @@ -6,8 +6,8 @@ require ( github.com/paulmach/orb v0.7.1 github.com/sfomuseum/go-flags v0.10.0 github.com/whosonfirst/go-whosonfirst-flags v0.4.4 - github.com/whosonfirst/go-whosonfirst-spatial v0.5.3 - github.com/whosonfirst/go-whosonfirst-spatial-pip v0.3.1 + github.com/whosonfirst/go-whosonfirst-spatial v0.5.4 + github.com/whosonfirst/go-whosonfirst-spatial-pip v0.3.2 github.com/whosonfirst/go-whosonfirst-spr/v2 v2.3.3 google.golang.org/grpc v1.51.0 google.golang.org/protobuf v1.28.1 diff --git a/go.sum b/go.sum index 8288bac..2441c3d 100644 --- a/go.sum +++ b/go.sum @@ -85,10 +85,10 @@ github.com/whosonfirst/go-whosonfirst-placetypes v0.4.2 h1:Sye3ySdkTy5+PPdSLCaZO github.com/whosonfirst/go-whosonfirst-placetypes v0.4.2/go.mod h1:HjxisIp+iZOXoThM9XyvC+GCmnupynE73GD3JxhH3fY= 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-spatial v0.5.3 h1:QLmgDJx3O/8e2h2j/uqA+lb5NJHIhgITRm6fkx2BcKc= -github.com/whosonfirst/go-whosonfirst-spatial v0.5.3/go.mod h1:Q8SCUVV0mcGZpMB3Lq9GiBXkm6ZVS/kor4GuPQGvaCA= -github.com/whosonfirst/go-whosonfirst-spatial-pip v0.3.1 h1:j2QhDx8t4z0s3RJqvm+Ll4t2zG4c195NZx2XRFRCAtY= -github.com/whosonfirst/go-whosonfirst-spatial-pip v0.3.1/go.mod h1:klRSLQeAVdFZd84f0xfKjSmVj1L8JCF8GPdGUiVOqnA= +github.com/whosonfirst/go-whosonfirst-spatial v0.5.4 h1:JJO2K+xLyciyWVPmpQ/VKZqXAswYm0O4yaXohFCBp/c= +github.com/whosonfirst/go-whosonfirst-spatial v0.5.4/go.mod h1:Q8SCUVV0mcGZpMB3Lq9GiBXkm6ZVS/kor4GuPQGvaCA= +github.com/whosonfirst/go-whosonfirst-spatial-pip v0.3.2 h1:WHBQiSTC7/pWyaqWrpHqaq1yN7YsJU+Y5kCXYNntSnc= +github.com/whosonfirst/go-whosonfirst-spatial-pip v0.3.2/go.mod h1:Nxk/JAeLMgcPd6xEfmUKWCHBGWTrxwfnDqEcWYpng70= github.com/whosonfirst/go-whosonfirst-spr/v2 v2.3.3 h1:dc7BdkGrSKtGyIEO8jW4h6xS0DMdKANwMHFRc1+WcnM= github.com/whosonfirst/go-whosonfirst-spr/v2 v2.3.3/go.mod h1:3Sym68fXOfIAcdJiRkJC+8FO+JuSGZ2NuDpRFzWMDi0= github.com/whosonfirst/go-whosonfirst-uri v1.2.0 h1:lhmRsIhcpTr5HAo+kXKRGsSt76HTh3Ko/oTR2jpCm/o= diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-spatial/README.md b/vendor/github.com/whosonfirst/go-whosonfirst-spatial/README.md index 8c66bfb..98ddfc0 100644 --- a/vendor/github.com/whosonfirst/go-whosonfirst-spatial/README.md +++ b/vendor/github.com/whosonfirst/go-whosonfirst-spatial/README.md @@ -1,19 +1,22 @@ # go-whosonfirst-spatial +Go package defining interfaces for Who's On First specific spatial operations. + ## Documentation Documentation, particularly proper Go documentation, is incomplete at this time. ## Motivation -`go-whosonfirst-spatial` is an attempt to de-couple the various components that make up the [go-whosonfirst-pip-v2](https://github.com/whosonfirst/go-whosonfirst-pip-v2) package – indexing, storage, querying and serving – in to separate packages in order to allow for more flexibility. +The goal of the `go-whosonfirst-spatial` package is to de-couple the various components that made up the now-deprecated [go-whosonfirst-pip-v2](https://github.com/whosonfirst/go-whosonfirst-pip-v2) package – indexing, storage, querying and serving – in to separate packages in order to allow for more flexibility. It is the "base" package that defines provider-agnostic, but WOF-specific, interfaces for a limited set of spatial queries and reading properties. -These interfaces are then implemented in full or in part by provider-specific classes. For example, an in-memory RTree index or SQLite: +These interfaces are then implemented in full or in part by provider-specific classes. For example, an in-memory RTree index or a SQLite database or even a Protomaps database: * https://github.com/whosonfirst/go-whosonfirst-spatial-rtree * https://github.com/whosonfirst/go-whosonfirst-spatial-sqlite +* https://github.com/whosonfirst/go-whosonfirst-spatial-pmtiles Building on that there are equivalent base packages for "server" implementations, like: @@ -30,92 +33,97 @@ import ( Here is a concrete example, implementing a point-in-polygon service over HTTP using a SQLite backend: +* https://github.com/whosonfirst/go-whosonfirst-spatial-www/blob/main/application/server * https://github.com/whosonfirst/go-whosonfirst-spatial-www-sqlite/blob/main/cmd/server/main.go It is part of the overall goal of: * Staying out people's database or delivery choices (or needs) * Supporting as many databases (and delivery (and indexing) choices) as possible -* Not making database B a dependency (in the Go code) in order to use database A, as in not bundling everything in a single mono-repo that becomes bigger and has more requirements over time. - -That's the goal, anyway. I am still working through the implementation details. - -Functionally the `go-whosonfirst-spatial-` packages should be equivalent to `go-whosonfirst-pip-v2` as in there won't be any functionality _removed_. - -## Example - -``` -import ( - "context" - "encoding/json" - "fmt" - "github.com/whosonfirst/go-whosonfirst-spatial/app" - "github.com/whosonfirst/go-whosonfirst-spatial/filter" - "github.com/whosonfirst/go-whosonfirst-spatial/flags" - "github.com/whosonfirst/go-whosonfirst-spatial/geo" - _ "github.com/whosonfirst/go-whosonfirst-spatial-rtree" -) - -func main() { - - fl, _ := flags.CommonFlags() - flags.Parse(fl) - - flags.ValidateCommonFlags(fl) +* Not making database `B` a dependency (in the Go code) in order to use database `A`, as in not bundling everything in a single mono-repo that becomes bigger and has more requirements over time. - paths := fl.Args() - - ctx := context.Background() +Importantly this package does not implement any actual spatial functionality. It defines the interfaces that are implemented by other packages which allows code to function without the need to consider the underlying mechanics of how spatial operations are being performed. - spatial_app, _ := app.NewSpatialApplicationWithFlagSet(ctx, fl) - spatial_app.IndexPaths(ctx, paths...) +The layout of this package remains in flux and is likely to change. Things have almost settled but not quite yet. - c, _ := geo.NewCoordinate(-122.395229, 37.794906) - f, _ := filter.NewSPRFilter() +## Interfaces - spatial_db := spatial_app.SpatialDatabase - spatial_results, _ := spatial_db.PointInPolygon(ctx, c, f) +### SpatialIndex - body, _ := json.Marshal(spatial_results) - fmt.Println(string(body)) +``` +type SpatialIndex interface { + IndexFeature(context.Context, []byte) error + RemoveFeature(context.Context, string) error + PointInPolygon(context.Context, *orb.Point, ...Filter) (spr.StandardPlacesResults, error) + PointInPolygonCandidates(context.Context, *orb.Point, ...Filter) ([]*PointInPolygonCandidate, error) + PointInPolygonWithChannels(context.Context, chan spr.StandardPlacesResult, chan error, chan bool, *orb.Point, ...Filter) + PointInPolygonCandidatesWithChannels(context.Context, chan *PointInPolygonCandidate, chan error, chan bool, *orb.Point, ...Filter) + Disconnect(context.Context) error } ``` -_Error handling omitted for brevity._ - -## Concepts - -### Applications +_Where `orb.*` and `spr.*` refer to the [paulmach/orb](https://github.com/paulmach/orb) and [whosonfirst/go-whosonfirst-flags](https://github.com/whosonfirst/go-whosonfirst-flags) packages respectively._ -_Please write me_ +### SpatialDatabase -### Database - -_Please write me_ - -### Filters - -_Please write me_ +``` +type SpatialDatabase interface { + reader.Reader + writer.Writer + spatial.SpatialIndex +} +``` -### Indices +_Where `reader.Reader` and `writer.Writer` are the [whosonfirst/go-reader](https://pkg.go.dev/github.com/whosonfirst/go-reader#Reader) and [whosonfirst/go-writer](https://pkg.go.dev/github.com/whosonfirst/go-writer#Writer) interfaces, respectively._ -_Please write me_ +### Filter -### Standard Places Response (SPR) +``` +type Filter interface { + HasPlacetypes(flags.PlacetypeFlag) bool + MatchesInception(flags.DateFlag) bool + MatchesCessation(flags.DateFlag) bool + IsCurrent(flags.ExistentialFlag) bool + IsDeprecated(flags.ExistentialFlag) bool + IsCeased(flags.ExistentialFlag) bool + IsSuperseded(flags.ExistentialFlag) bool + IsSuperseding(flags.ExistentialFlag) bool + IsAlternateGeometry(flags.AlternateGeometryFlag) bool + HasAlternateGeometry(flags.AlternateGeometryFlag) bool +} +``` -_Please write me_ +_Where `flags.*` refers to the [whosonfirst/go-whosonfirst-flags](https://github.com/whosonfirst/go-whosonfirst-flags) package._ ## Implementations * https://github.com/whosonfirst/go-whosonfirst-spatial-rtree * https://github.com/whosonfirst/go-whosonfirst-spatial-sqlite +* https://github.com/whosonfirst/go-whosonfirst-spatial-pmtiles ## Servers and clients +### WWW + * https://github.com/whosonfirst/go-whosonfirst-spatial-www +* https://github.com/whosonfirst/go-whosonfirst-spatial-www-sqlite +* https://github.com/whosonfirst/go-whosonfirst-spatial-www-pmtiles + +### gRPC + * https://github.com/whosonfirst/go-whosonfirst-spatial-grpc +* https://github.com/whosonfirst/go-whosonfirst-spatial-grpc-sqlite +* https://github.com/whosonfirst/go-whosonfirst-spatial-grpc-pmtiles -## Services +## Services and Operations * https://github.com/whosonfirst/go-whosonfirst-spatial-pip -* https://github.com/whosonfirst/go-whosonfirst-spatial-hierarchy \ No newline at end of file +* https://github.com/whosonfirst/go-whosonfirst-spatial-hierarchy + +## See also + +* https://github.com/whosonfirst/go-whosonfirst-spr +* https://github.com/whosonfirst/go-whosonfirst-flags +* https://github.com/whosonfirst/go-reader +* https://github.com/whosonfirst/go-writer +* https://github.com/paulmach/orb \ No newline at end of file diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-spatial/flags/common.go b/vendor/github.com/whosonfirst/go-whosonfirst-spatial/flags/common.go index b8ab42d..52b7213 100644 --- a/vendor/github.com/whosonfirst/go-whosonfirst-spatial/flags/common.go +++ b/vendor/github.com/whosonfirst/go-whosonfirst-spatial/flags/common.go @@ -16,7 +16,7 @@ func CommonFlags() (*flag.FlagSet, error) { err := AppendCommonFlags(fs) if err != nil { - return nil, err + return nil, fmt.Errorf("Failed to append common application flags, %w", err) } return fs, nil @@ -29,44 +29,44 @@ func AppendCommonFlags(fs *flag.FlagSet) error { available_databases := database.Schemes() desc_databases := fmt.Sprintf("A valid whosonfirst/go-whosonfirst-spatial/data.SpatialDatabase URI. options are: %s", available_databases) - fs.String(SPATIAL_DATABASE_URI, "", desc_databases) + fs.String(SpatialDatabaseURIFlag, "", desc_databases) available_readers := reader.Schemes() desc_readers := fmt.Sprintf("A valid whosonfirst/go-reader.Reader URI. Available options are: %s", available_readers) - fs.String(PROPERTIES_READER_URI, "", fmt.Sprintf("%s. If the value is {spatial-database-uri} then the value of the '-spatial-database-uri' implements the reader.Reader interface and will be used.", desc_readers)) + fs.String(PropertiesReaderURIFlag, "", fmt.Sprintf("%s. If the value is {spatial-database-uri} then the value of the '-spatial-database-uri' implements the reader.Reader interface and will be used.", desc_readers)) fs.Bool(IS_WOF, true, "Input data is WOF-flavoured GeoJSON. (Pass a value of '0' or 'false' if you need to index non-WOF documents.") - fs.Bool(ENABLE_CUSTOM_PLACETYPES, false, "Enable wof:placetype values that are not explicitly defined in the whosonfirst/go-whosonfirst-placetypes repository.") + fs.Bool(EnableCustomPlacetypesFlag, false, "Enable wof:placetype values that are not explicitly defined in the whosonfirst/go-whosonfirst-placetypes repository.") // Pending changes in the app/placetypes.go package to support // alternate sources (20210324/thisisaaronland) // fs.String(CUSTOM_PLACETYPES_SOURCE, "", "...") - fs.String(CUSTOM_PLACETYPES, "", "A JSON-encoded string containing custom placetypes defined using the syntax described in the whosonfirst/go-whosonfirst-placetypes repository.") + fs.String(CustomPlacetypesFlag, "", "A JSON-encoded string containing custom placetypes defined using the syntax described in the whosonfirst/go-whosonfirst-placetypes repository.") - fs.Bool(VERBOSE, false, "Be chatty.") + fs.Bool(VerboseFlag, false, "Be chatty.") return nil } func ValidateCommonFlags(fs *flag.FlagSet) error { - spatial_database_uri, err := lookup.StringVar(fs, SPATIAL_DATABASE_URI) + spatial_database_uri, err := lookup.StringVar(fs, SpatialDatabaseURIFlag) if err != nil { - return err + return fmt.Errorf("Failed to lookup %s flag, %w", SpatialDatabaseURIFlag, err) } if spatial_database_uri == "" { - return fmt.Errorf("Invalid or missing -%s flag", SPATIAL_DATABASE_URI) + return fmt.Errorf("Invalid or missing -%s flag", SpatialDatabaseURIFlag) } - _, err = lookup.StringVar(fs, PROPERTIES_READER_URI) + _, err = lookup.StringVar(fs, PropertiesReaderURIFlag) if err != nil { - return err + return fmt.Errorf("Failed to lookup %s flag, %w", PropertiesReaderURIFlag, err) } return nil diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-spatial/flags/flags.go b/vendor/github.com/whosonfirst/go-whosonfirst-spatial/flags/flags.go index c74d057..13eb6a3 100644 --- a/vendor/github.com/whosonfirst/go-whosonfirst-spatial/flags/flags.go +++ b/vendor/github.com/whosonfirst/go-whosonfirst-spatial/flags/flags.go @@ -1,45 +1,89 @@ package flags -const ALTERNATE_GEOMETRIES string = "alternate-geometry" +const AlternateGeometriesFlag string = "alternate-geometry" -const CESSATION_DATE string = "cessation-date" +const CessationDateFlag string = "cessation-date" -const CUSTOM_PLACETYPES string = "custom-placetypes" +const CustomPlacetypesFlag string = "custom-placetypes" -const CUSTOM_PLACETYPES_SOURCE string = "custom-placetypes-source" +const CustomPlacetypesSourceFlag string = "custom-placetypes-source" -const ENABLE_CUSTOM_PLACETYPES string = "enable-custom-placetypes" +const EnableCustomPlacetypesFlag string = "enable-custom-placetypes" -const GEOMETRIES string = "geometries" +const GeometriesFlag string = "geometries" -const INCEPTION_DATE string = "inception-date" +const InceptionDateFlag string = "inception-date" -const IS_CEASED string = "is-ceased" +const IsCeasedFlag string = "is-ceased" -const IS_CURRENT string = "is-current" +const IsCurrentFlag string = "is-current" -const IS_DEPRECATED string = "is-deprecated" +const IsDeprecatedFlag string = "is-deprecated" -const IS_SUPERSEDED string = "is-superseded" +const IsSupersededFlag string = "is-superseded" -const IS_SUPERSEDING string = "is-superseding" +const IsSupersedingFlag string = "is-superseding" -const ITERATOR_URI string = "iterator-uri" +const IteratorURIFlag string = "iterator-uri" -const LATITUDE string = "latitude" +const LatitudeFlag string = "latitude" -const LONGITUDE string = "longitude" +const LongitudeFlag string = "longitude" -const PLACETYPES string = "placetype" +const PlacetypeFlag string = "placetype" -const PROPERTIES string = "property" +const PropertyFlag string = "property" -const SPATIAL_DATABASE_URI string = "spatial-database-uri" +const SpatialDatabaseURIFlag string = "spatial-database-uri" -const PROPERTIES_READER_URI string = "properties-reader-uri" +const PropertiesReaderURIFlag string = "properties-reader-uri" -const VERBOSE string = "verbose" +const VerboseFlag string = "verbose" + +const SortURIFlag string = "sort-uri" + +// Deprecated. These will be removed once this package reaches v1.0.0 + +const ALTERNATE_GEOMETRIES string = AlternateGeometriesFlag + +const CESSATION_DATE string = CessationDateFlag + +const CUSTOM_PLACETYPES string = CustomPlacetypesFlag + +const CUSTOM_PLACETYPES_SOURCE string = CustomPlacetypesSourceFlag + +const ENABLE_CUSTOM_PLACETYPES string = EnableCustomPlacetypesFlag + +const GEOMETRIES string = GeometriesFlag + +const INCEPTION_DATE string = InceptionDateFlag + +const IS_CEASED string = IsCeasedFlag + +const IS_CURRENT string = IsCurrentFlag + +const IS_DEPRECATED string = IsDeprecatedFlag + +const IS_SUPERSEDED string = IsSupersededFlag + +const IS_SUPERSEDING string = IsSupersedingFlag + +const ITERATOR_URI string = IteratorURIFlag + +const LATITUDE string = LatitudeFlag + +const LONGITUDE string = LongitudeFlag + +const PLACETYPES string = PlacetypeFlag + +const PROPERTIES string = PropertyFlag + +const SPATIAL_DATABASE_URI string = SpatialDatabaseURIFlag + +const PROPERTIES_READER_URI string = PropertiesReaderURIFlag + +const VERBOSE string = VerboseFlag const IS_WOF string = "is-wof" -const SORT string = "sort-uri" +const SORT string = SortURIFlag diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-spatial/flags/iterator.go b/vendor/github.com/whosonfirst/go-whosonfirst-spatial/flags/iterator.go index 5cd5da9..03d80da 100644 --- a/vendor/github.com/whosonfirst/go-whosonfirst-spatial/flags/iterator.go +++ b/vendor/github.com/whosonfirst/go-whosonfirst-spatial/flags/iterator.go @@ -17,17 +17,17 @@ func AppendIndexingFlags(fs *flag.FlagSet) error { valid_modes := strings.Join(modes, ", ") desc_modes := fmt.Sprintf("A valid whosonfirst/go-whosonfirst-iterate/v2 URI. Supported schemes are: %s.", valid_modes) - fs.String(ITERATOR_URI, "repo://", desc_modes) + fs.String(IteratorURIFlag, "repo://", desc_modes) return nil } func ValidateIndexingFlags(fs *flag.FlagSet) error { - _, err := lookup.StringVar(fs, ITERATOR_URI) + _, err := lookup.StringVar(fs, IteratorURIFlag) if err != nil { - return err + return fmt.Errorf("Failed to lookup %s flag, %w", IteratorURIFlag, err) } return nil diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-spatial/flags/query.go b/vendor/github.com/whosonfirst/go-whosonfirst-spatial/flags/query.go index 0c4f38a..dacd37c 100644 --- a/vendor/github.com/whosonfirst/go-whosonfirst-spatial/flags/query.go +++ b/vendor/github.com/whosonfirst/go-whosonfirst-spatial/flags/query.go @@ -1,8 +1,8 @@ package flags import ( - "errors" "flag" + "fmt" "github.com/sfomuseum/go-flags/lookup" "github.com/sfomuseum/go-flags/multi" "github.com/whosonfirst/go-whosonfirst-spatial/geo" @@ -10,112 +10,106 @@ import ( func AppendQueryFlags(fs *flag.FlagSet) error { - fs.Float64(LATITUDE, 0.0, "A valid latitude.") - fs.Float64(LONGITUDE, 0.0, "A valid longitude.") + fs.Float64(LatitudeFlag, 0.0, "A valid latitude.") + fs.Float64(LongitudeFlag, 0.0, "A valid longitude.") - fs.String(GEOMETRIES, "all", "Valid options are: all, alt, default.") + fs.String(GeometriesFlag, "all", "Valid options are: all, alt, default.") - fs.String(INCEPTION_DATE, "", "A valid EDTF date string.") - fs.String(CESSATION_DATE, "", "A valid EDTF date string.") + fs.String(InceptionDateFlag, "", "A valid EDTF date string.") + fs.String(CessationDateFlag, "", "A valid EDTF date string.") var props multi.MultiString - fs.Var(&props, PROPERTIES, "One or more Who's On First properties to append to each result.") + fs.Var(&props, PropertyFlag, "One or more Who's On First properties to append to each result.") var placetypes multi.MultiString - fs.Var(&placetypes, PLACETYPES, "One or more place types to filter results by.") + fs.Var(&placetypes, PlacetypeFlag, "One or more place types to filter results by.") var alt_geoms multi.MultiString - fs.Var(&alt_geoms, ALTERNATE_GEOMETRIES, "One or more alternate geometry labels (wof:alt_label) values to filter results by.") + fs.Var(&alt_geoms, AlternateGeometriesFlag, "One or more alternate geometry labels (wof:alt_label) values to filter results by.") var is_current multi.MultiInt64 - fs.Var(&is_current, IS_CURRENT, "One or more existential flags (-1, 0, 1) to filter results by.") + fs.Var(&is_current, IsCurrentFlag, "One or more existential flags (-1, 0, 1) to filter results by.") var is_ceased multi.MultiInt64 - fs.Var(&is_ceased, IS_CEASED, "One or more existential flags (-1, 0, 1) to filter results by.") + fs.Var(&is_ceased, IsCeasedFlag, "One or more existential flags (-1, 0, 1) to filter results by.") var is_deprecated multi.MultiInt64 - fs.Var(&is_deprecated, IS_DEPRECATED, "One or more existential flags (-1, 0, 1) to filter results by.") + fs.Var(&is_deprecated, IsDeprecatedFlag, "One or more existential flags (-1, 0, 1) to filter results by.") var is_superseded multi.MultiInt64 - fs.Var(&is_superseded, IS_SUPERSEDED, "One or more existential flags (-1, 0, 1) to filter results by.") + fs.Var(&is_superseded, IsSupersededFlag, "One or more existential flags (-1, 0, 1) to filter results by.") var is_superseding multi.MultiInt64 - fs.Var(&is_superseding, IS_SUPERSEDING, "One or more existential flags (-1, 0, 1) to filter results by.") + fs.Var(&is_superseding, IsSupersedingFlag, "One or more existential flags (-1, 0, 1) to filter results by.") var sort multi.MultiString - fs.Var(&sort, SORT, "Zero or more whosonfirst/go-whosonfirst-spr/sort URIs.") + fs.Var(&sort, SortURIFlag, "Zero or more whosonfirst/go-whosonfirst-spr/sort URIs.") return nil } func ValidateQueryFlags(fs *flag.FlagSet) error { - lat, err := lookup.Float64Var(fs, LATITUDE) + lat, err := lookup.Float64Var(fs, LatitudeFlag) if err != nil { - return err + return fmt.Errorf("Failed to lookup %s flag, %w", LatitudeFlag, err) } - lon, err := lookup.Float64Var(fs, LONGITUDE) + lon, err := lookup.Float64Var(fs, LongitudeFlag) if err != nil { - return err + return fmt.Errorf("Failed to lookup %s flag, %w", LongitudeFlag, err) } if !geo.IsValidLatitude(lat) { - return errors.New("Invalid latitude") + return fmt.Errorf("Invalid latitude") } if !geo.IsValidLongitude(lon) { - return errors.New("Invalid longitude") + return fmt.Errorf("Invalid longitude") } - _, err = lookup.StringVar(fs, GEOMETRIES) + _, err = lookup.StringVar(fs, GeometriesFlag) if err != nil { - return err + return fmt.Errorf("Failed to lookup %s flag, %w", GeometriesFlag, err) } - _, err = lookup.MultiStringVar(fs, ALTERNATE_GEOMETRIES) + _, err = lookup.MultiStringVar(fs, AlternateGeometriesFlag) if err != nil { - return err + return fmt.Errorf("Failed to lookup %s flag, %w", AlternateGeometriesFlag, err) } - _, err = lookup.MultiInt64Var(fs, IS_CURRENT) + _, err = lookup.MultiInt64Var(fs, IsCurrentFlag) if err != nil { - return err + return fmt.Errorf("Failed to lookup %s flag, %w", IsCurrentFlag, err) } - _, err = lookup.MultiInt64Var(fs, IS_CEASED) + _, err = lookup.MultiInt64Var(fs, IsCeasedFlag) if err != nil { - return err + return fmt.Errorf("Failed to lookup %s flag, %w", IsCeasedFlag, err) } - _, err = lookup.MultiInt64Var(fs, IS_DEPRECATED) + _, err = lookup.MultiInt64Var(fs, IsDeprecatedFlag) if err != nil { - return err + return fmt.Errorf("Failed to lookup %s flag, %w", IsDeprecatedFlag, err) } - _, err = lookup.MultiInt64Var(fs, IS_DEPRECATED) + _, err = lookup.MultiInt64Var(fs, IsSupersededFlag) if err != nil { - return err + return fmt.Errorf("Failed to lookup %s flag, %w", IsSupersededFlag, err) } - _, err = lookup.MultiInt64Var(fs, IS_SUPERSEDED) + _, err = lookup.MultiInt64Var(fs, IsSupersedingFlag) if err != nil { - return err - } - - _, err = lookup.MultiInt64Var(fs, IS_SUPERSEDING) - - if err != nil { - return err + return fmt.Errorf("Failed to lookup %s flag, %w", IsSupersedingFlag, err) } return nil diff --git a/vendor/modules.txt b/vendor/modules.txt index a8c95fc..6917412 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -98,7 +98,7 @@ github.com/whosonfirst/go-whosonfirst-placetypes ## explicit; go 1.12 github.com/whosonfirst/go-whosonfirst-sources github.com/whosonfirst/go-whosonfirst-sources/sources -# github.com/whosonfirst/go-whosonfirst-spatial v0.5.3 +# github.com/whosonfirst/go-whosonfirst-spatial v0.5.4 ## explicit; go 1.18 github.com/whosonfirst/go-whosonfirst-spatial github.com/whosonfirst/go-whosonfirst-spatial/app @@ -106,7 +106,7 @@ github.com/whosonfirst/go-whosonfirst-spatial/database github.com/whosonfirst/go-whosonfirst-spatial/filter github.com/whosonfirst/go-whosonfirst-spatial/flags github.com/whosonfirst/go-whosonfirst-spatial/geo -# github.com/whosonfirst/go-whosonfirst-spatial-pip v0.3.1 +# github.com/whosonfirst/go-whosonfirst-spatial-pip v0.3.2 ## explicit; go 1.18 github.com/whosonfirst/go-whosonfirst-spatial-pip # github.com/whosonfirst/go-whosonfirst-spr/v2 v2.3.3