Merge branch 'master' into collection-optz

This commit is contained in:
tidwall 2019-03-14 09:11:55 -07:00
commit 4d5b6571da
10 changed files with 56 additions and 22 deletions

View File

@ -2,6 +2,13 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/). This project adheres to [Semantic Versioning](http://semver.org/).
## [1.16.2] - 2019-03-12
### Fixes
- #432: Ignore SIGHUP signals (@abhit011)
- #433: Fixed nearby inaccuracy with geofence (@stcktrce)
- #429: Memory optimization, recycle AOF buffer
- 95a5556: Added periodic yielding to iterators (@rshura)
## [1.16.1] - 2019-03-01 ## [1.16.1] - 2019-03-01
### Fixes ### Fixes
- #421: Nearby with MATCH is returning invalid results (@nithinkota) - #421: Nearby with MATCH is returning invalid results (@nithinkota)

9
Gopkg.lock generated
View File

@ -250,7 +250,11 @@
version = "v1.0.2" version = "v1.0.2"
[[projects]] [[projects]]
<<<<<<< HEAD
digest = "1:ab5e0d19c706286deed5e6ec63a35ee0f2b92d7b9e97083eb67e5d2d76b4bfdb" digest = "1:ab5e0d19c706286deed5e6ec63a35ee0f2b92d7b9e97083eb67e5d2d76b4bfdb"
=======
digest = "1:cdab3bce90a53a124ac3982719abde77d779e961d9c180e55c23fb74fc62563a"
>>>>>>> master
name = "github.com/tidwall/geojson" name = "github.com/tidwall/geojson"
packages = [ packages = [
".", ".",
@ -258,8 +262,13 @@
"geometry", "geometry",
] ]
pruneopts = "" pruneopts = ""
<<<<<<< HEAD
revision = "f9500c7d3da6ce149bf80530c36b1a784dcd0f2b" revision = "f9500c7d3da6ce149bf80530c36b1a784dcd0f2b"
version = "v1.1.1" version = "v1.1.1"
=======
revision = "eaf6e0a55a79c1e879bbbcc879a3176c720d99cd"
version = "v1.1.3"
>>>>>>> master
[[projects]] [[projects]]
digest = "1:eade4ea6782f5eed4a6b3138a648f9a332900650804fd206e5daaf99cc5613ea" digest = "1:eade4ea6782f5eed4a6b3138a648f9a332900650804fd206e5daaf99cc5613ea"

View File

@ -37,7 +37,7 @@ required = [
[[constraint]] [[constraint]]
name = "github.com/tidwall/geojson" name = "github.com/tidwall/geojson"
version = "1.1.1" version = "1.1.3"
[[constraint]] [[constraint]]
name = "github.com/Shopify/sarama" name = "github.com/Shopify/sarama"

View File

@ -5,7 +5,7 @@
</p> </p>
<p align="center"> <p align="center">
<a href="https://join.slack.com/t/tile38/shared_invite/enQtMzQ0OTEwMDUxMzc5LTc0NTJjZmM3YjFhOGZiZGU2NDNjOWEwM2Q5ZWE3MzFiYWZkZDIyN2U2ZmUzZDBmODU0MjI1ZjQ0N2Y1M2I1NTg"><img src="https://img.shields.io/badge/slack-channel-orange.svg" alt="Slack Channel"></a> <a href="https://join.slack.com/t/tile38/shared_invite/enQtMzQ0OTEwMDUxMzc5LTc0NTJjZmM3YjFhOGZiZGU2NDNjOWEwM2Q5ZWE3MzFiYWZkZDIyN2U2ZmUzZDBmODU0MjI1ZjQ0N2Y1M2I1NTg"><img src="https://img.shields.io/badge/slack-channel-orange.svg" alt="Slack Channel"></a>
<a href="https://github.com/tidwall/tile38/releases"><img src="https://img.shields.io/badge/version-1.16.1-green.svg?" alt="Version"></a> <a href="https://github.com/tidwall/tile38/releases"><img src="https://img.shields.io/badge/version-1.16.2-green.svg?" alt="Version"></a>
<a href="https://travis-ci.org/tidwall/tile38"><img src="https://travis-ci.org/tidwall/tile38.svg?branch=master" alt="Build Status"></a> <a href="https://travis-ci.org/tidwall/tile38"><img src="https://travis-ci.org/tidwall/tile38.svg?branch=master" alt="Build Status"></a>
<a href="https://hub.docker.com/r/tile38/tile38"><img src="https://img.shields.io/badge/docker-ready-blue.svg" alt="Docker Ready"></a> <a href="https://hub.docker.com/r/tile38/tile38"><img src="https://img.shields.io/badge/docker-ready-blue.svg" alt="Docker Ready"></a>
</p> </p>

View File

@ -4,7 +4,7 @@ set -e
cd $(dirname "${BASH_SOURCE[0]}") cd $(dirname "${BASH_SOURCE[0]}")
OD="$(pwd)" OD="$(pwd)"
VERSION=1.16.1 VERSION=1.16.2
PROTECTED_MODE="no" PROTECTED_MODE="no"
# Hardcode some values to the core package # Hardcode some values to the core package

View File

@ -374,23 +374,25 @@ Developer Options:
c := make(chan os.Signal, 1) c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT) signal.Notify(c, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
go func() { go func() {
s := <-c for s := range c {
log.Warnf("signal: %v", s) if s == syscall.SIGHUP {
if pidfile != "" { continue
pidcleanup() }
} log.Warnf("signal: %v", s)
pprofcleanup() if pidfile != "" {
switch { pidcleanup()
default: }
os.Exit(-1) pprofcleanup()
case s == syscall.SIGHUP: switch {
os.Exit(1) default:
case s == syscall.SIGINT: os.Exit(-1)
os.Exit(2) case s == syscall.SIGINT:
case s == syscall.SIGQUIT: os.Exit(2)
os.Exit(3) case s == syscall.SIGQUIT:
case s == syscall.SIGTERM: os.Exit(3)
os.Exit(0xf) case s == syscall.SIGTERM:
os.Exit(0xf)
}
} }
}() }()

View File

@ -99,6 +99,8 @@ func (g *Circle) Contains(obj Object) bool {
switch other := obj.(type) { switch other := obj.(type) {
case *Point: case *Point:
return g.containsPoint(other.Center()) return g.containsPoint(other.Center())
case *SimplePoint:
return g.containsPoint(other.Center())
case *Circle: case *Circle:
return other.Distance(g) < (other.meters + g.meters) return other.Distance(g) < (other.meters + g.meters)
case *LineString: case *LineString:
@ -244,8 +246,8 @@ func makeCircleObject(center geometry.Point, meters float64, steps int) Object {
// generate the // generate the
for th := 0.0; th <= 360.0; th += 360.0 / float64(steps) { for th := 0.0; th <= 360.0; th += 360.0 / float64(steps) {
radians := (math.Pi / 180) * th radians := (math.Pi / 180) * th
x := center.X + lats*math.Cos(radians) x := center.X + lons*math.Cos(radians)
y := center.Y + lons*math.Sin(radians) y := center.Y + lats*math.Sin(radians)
points = append(points, geometry.Point{X: x, Y: y}) points = append(points, geometry.Point{X: x, Y: y})
} }
// add last connecting point, make a total of steps+1 // add last connecting point, make a total of steps+1

View File

@ -171,3 +171,11 @@ func TestCircleIntersects(t *testing.T) {
// } // }
// expect(t, true) // expect(t, true)
//} //}
func TestPointCircle(t *testing.T) {
p := NewPoint(geometry.Point{X: -0.8856761, Y: 52.7563759})
c := NewCircle(geometry.Point{X: -0.8838196, Y: 52.7563395}, 200, 20)
if !p.Within(c) {
t.Fatal("expected true")
}
}

View File

@ -95,6 +95,9 @@ func (g *Point) Contains(obj Object) bool {
// Intersects ... // Intersects ...
func (g *Point) Intersects(obj Object) bool { func (g *Point) Intersects(obj Object) bool {
if obj, ok := obj.(*Circle); ok {
return obj.Contains(g)
}
return obj.Spatial().IntersectsPoint(g.base) return obj.Spatial().IntersectsPoint(g.base)
} }

View File

@ -82,6 +82,9 @@ func (g *SimplePoint) Contains(obj Object) bool {
// Intersects ... // Intersects ...
func (g *SimplePoint) Intersects(obj Object) bool { func (g *SimplePoint) Intersects(obj Object) bool {
if obj, ok := obj.(*Circle); ok {
return obj.Contains(g)
}
return obj.Spatial().IntersectsPoint(g.base) return obj.Spatial().IntersectsPoint(g.base)
} }