Skip to content

Commit

Permalink
Require properties member for geojson features
Browse files Browse the repository at this point in the history
  • Loading branch information
tidwall committed Feb 12, 2019
1 parent fb7259b commit 30f903b
Show file tree
Hide file tree
Showing 21 changed files with 151 additions and 35 deletions.
6 changes: 3 additions & 3 deletions Gopkg.lock

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

5 changes: 4 additions & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
required = [
"github.com/tidwall/lotsa",
"github.com/mmcloughlin/geohash",
"github.com/tidwall/geojson",
"github.com/tidwall/evio"
]

Expand All @@ -35,6 +34,10 @@ required = [
branch = "master"
name = "github.com/tidwall/boxtree"

[[constraint]]
name = "github.com/tidwall/geojson"
version = "1.1.0"

[[constraint]]
name = "github.com/Shopify/sarama"
version = "1.13.0"
Expand Down
5 changes: 5 additions & 0 deletions internal/collection/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ func (s String) JSON() string {
return string(s.AppendJSON(nil))
}

// MarshalJSON ...
func (s String) MarshalJSON() ([]byte, error) {
return s.AppendJSON(nil), nil
}

// Within ...
func (s String) Within(obj geojson.Object) bool {
return false
Expand Down
2 changes: 1 addition & 1 deletion tests/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func json_JSET_geojson_test(mc *mockServer) error {
{"JSET", "mykey", "myid1", "coordinates.1", 44}, {"OK"},
{"JGET", "mykey", "myid1"}, {`{"type":"Point","coordinates":[-115,44]}`},
{"SET", "mykey", "myid1", "OBJECT", `{"type":"Feature","geometry":{"type":"Point","coordinates":[-115,44]}}`}, {"OK"},
{"JGET", "mykey", "myid1"}, {`{"type":"Feature","geometry":{"type":"Point","coordinates":[-115,44]}}`},
{"JGET", "mykey", "myid1"}, {`{"type":"Feature","geometry":{"type":"Point","coordinates":[-115,44]},"properties":{}}`},
{"JGET", "mykey", "myid1", "geometry.type"}, {"Point"},
{"JSET", "mykey", "myid1", "properties.tags.-1", "southwest"}, {"OK"},
{"JSET", "mykey", "myid1", "properties.tags.-1", "united states"}, {"OK"},
Expand Down
2 changes: 1 addition & 1 deletion tests/testcmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func testcmd_INTERSECTS_CLIP_test(mc *mockServer) error {

{"TEST", "OBJECT", poly9, "INTERSECTS", "CLIP", "BOUNDS", 37.732906137107, -122.44126439094543, 37.73421283683962, -122.43980526924135}, {"[1 " + poly9 + "]"},
{"TEST", "OBJECT", poly8, "INTERSECTS", "CLIP", "BOUNDS", 37.733, -122.4408378, 37.7341129, -122.44}, {"[1 " + poly8 + "]"},
{"TEST", "OBJECT", multipoly5, "INTERSECTS", "CLIP", "BOUNDS", 37.73227823422744, -122.44120001792908, 37.73319038868677, -122.43955314159392}, {"[1 " + `{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-122.4408378,37.73319038868677],[-122.4408378,37.733],[-122.44,37.733],[-122.44,37.73319038868677],[-122.4408378,37.73319038868677]]]}},{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-122.44091033935547,37.73227823422744],[-122.43994474411011,37.73227823422744],[-122.43994474411011,37.73254976045042],[-122.44091033935547,37.73254976045042],[-122.44091033935547,37.73227823422744]]]}}]}` + "]"},
{"TEST", "OBJECT", multipoly5, "INTERSECTS", "CLIP", "BOUNDS", 37.73227823422744, -122.44120001792908, 37.73319038868677, -122.43955314159392}, {"[1 " + `{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-122.4408378,37.73319038868677],[-122.4408378,37.733],[-122.44,37.733],[-122.44,37.73319038868677],[-122.4408378,37.73319038868677]]]},"properties":{}},{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-122.44091033935547,37.73227823422744],[-122.43994474411011,37.73227823422744],[-122.43994474411011,37.73254976045042],[-122.44091033935547,37.73254976045042],[-122.44091033935547,37.73227823422744]]]},"properties":{}}]}` + "]"},
{"TEST", "OBJECT", poly101, "INTERSECTS", "CLIP", "BOUNDS", 37.73315644825698, -122.44054287672043, 37.73349585185455, -122.44008690118788}, {"0"},
})
}
2 changes: 2 additions & 0 deletions tests/tests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ func runSubTest(t *testing.T, name string, mc *mockServer, test func(t *testing.
}

func runStep(t *testing.T, mc *mockServer, name string, step func(mc *mockServer) error) {
t.Helper()
t.Run(name, func(t *testing.T) {
t.Helper()
if err := func() error {
// reset the current server
mc.ResetConn()
Expand Down
5 changes: 5 additions & 0 deletions vendor/github.com/tidwall/geojson/circle.go

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

5 changes: 5 additions & 0 deletions vendor/github.com/tidwall/geojson/collection.go

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

7 changes: 6 additions & 1 deletion vendor/github.com/tidwall/geojson/feature.go

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

68 changes: 53 additions & 15 deletions vendor/github.com/tidwall/geojson/feature_test.go

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

7 changes: 6 additions & 1 deletion vendor/github.com/tidwall/geojson/featurecollection.go

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

7 changes: 6 additions & 1 deletion vendor/github.com/tidwall/geojson/geometrycollection.go

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

7 changes: 6 additions & 1 deletion vendor/github.com/tidwall/geojson/linestring.go

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

7 changes: 6 additions & 1 deletion vendor/github.com/tidwall/geojson/multilinestring.go

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

7 changes: 6 additions & 1 deletion vendor/github.com/tidwall/geojson/multipoint.go

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

7 changes: 6 additions & 1 deletion vendor/github.com/tidwall/geojson/multipolygon.go

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

14 changes: 11 additions & 3 deletions vendor/github.com/tidwall/geojson/object.go

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

4 changes: 2 additions & 2 deletions vendor/github.com/tidwall/geojson/object_test.go

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

Loading

0 comments on commit 30f903b

Please sign in to comment.