Skip to content

Commit

Permalink
Commit for first release, utilize snappy and gob to cache the model a…
Browse files Browse the repository at this point in the history
…nd load it.
  • Loading branch information
catmullet committed May 12, 2021
1 parent a3bb25a commit 3d625be
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions geojson.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,17 +254,18 @@ func (fc TimeZoneCollection) Location(lat, lon float64) (loc *time.Location, err

func (c Coordinates) contains(point Point) bool {
const tolerance = 5
var polyLen = len(c.Polygon)
var polygon = c.Polygon
var polyLen = len(polygon)
if polyLen < 3 {
return false
}

start := polyLen - tolerance
end := 0

contains := rayCast(point, c.Polygon[start], c.Polygon[end])
for i, j := tolerance, tolerance; i < polyLen; i, j = i+tolerance, i {
if rayCast(point, c.Polygon[j], c.Polygon[i]) {
contains := rayCast(point, polygon[start], polygon[end])
for i, j := tolerance, 0; i < polyLen; i, j = i+tolerance, i {
if rayCast(point, polygon[j], polygon[i]) {
contains = !contains
}
}
Expand All @@ -273,7 +274,6 @@ func (c Coordinates) contains(point Point) bool {

func rayCast(point, start, end Point) bool {
var pLat, pLon, startLat, startLon, endLat, endLon = point.Lat, point.Lon, start.Lat, start.Lon, end.Lat, end.Lon

if startLat > endLat {
startLat, startLon, endLat, endLon = endLat, endLon, startLat, startLon
}
Expand Down

0 comments on commit 3d625be

Please sign in to comment.