Skip to content

Commit a6c914c

Browse files
authored
Merge branch 'sams96:main' into master
2 parents 009897f + d54b863 commit a6c914c

File tree

11 files changed

+127
-109
lines changed

11 files changed

+127
-109
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
name: continuous-integration
2+
23
on:
34
push:
45
branches:
56
- 'master'
67
pull_request:
8+
79
jobs:
810
ubuntu:
911
runs-on: ubuntu-latest
1012
steps:
11-
- name: Set up Go 1.19
13+
- name: Set up Go 1.24
1214
uses: actions/setup-go@v1
1315
with:
14-
go-version: 1.19.x
16+
go-version: 1.24.x
1517
id: go
1618

1719
- name: Check out code into the Go module directory
@@ -38,10 +40,10 @@ jobs:
3840
macOS:
3941
runs-on: macos-latest
4042
steps:
41-
- name: Set up Go 1.19
43+
- name: Set up Go 1.24
4244
uses: actions/setup-go@v1
4345
with:
44-
go-version: 1.19.x
46+
go-version: 1.24.x
4547
id: go
4648

4749
- name: Check out code into the Go module directory
@@ -59,10 +61,10 @@ jobs:
5961
windows:
6062
runs-on: windows-latest
6163
steps:
62-
- name: Set up Go 1.19
64+
- name: Set up Go 1.24
6365
uses: actions/setup-go@v1
6466
with:
65-
go-version: 1.19.x
67+
go-version: 1.24.x
6668
id: go
6769

6870
- name: Check out code into the Go module directory

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
# Output of the go coverage tool, specifically when used with LiteIDE
1212
*.out
1313

14+
# IDEs
15+
.idea/
16+
1417
# Dependency directories (remove the comment below to include it)
1518
# vendor/
1619

1720
*.geojson
18-
datagen/datagen
21+
datagen/datagen

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,26 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.3.0] - 2025-03-08
9+
10+
### Added
11+
- New `Build` method, see below
12+
13+
### Changed
14+
- Make `ReverseGeocode` thread safe, thanks to @mologie (#34)
15+
- This makes the first call to `ReverseGeocode` much slower. This can be
16+
mitigated by calling `Build` first.
17+
- Optimizations: Only link used datasets, avoid copies, avoid pkg/errors
18+
dependency, thanks to @mologie (#26)
19+
- Update natural earth data to v5.1.2, thanks to @SaTae66
20+
- Bump dependency versions, thanks to @dependabot
21+
822
## [1.2.0] - 2023-01-03
923

1024
It's been a while since the last release, so all of the dependencies have been
1125
updated, but this is mostly about the first user contribution.
1226

13-
## Changed
27+
### Changed
1428
- Moved to using Go embed for the data files, thanks to @benjojo (#18)
1529
- Updated to Go 1.19
1630
- Updated other dependencies

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ the data beforehand (links to which are in the files). If you want to use your
1616
own dataset, check out
1717
[datagen](https://github.com/sams96/rgeo/tree/master/datagen).
1818

19+
## Current status
20+
21+
Rgeo is not being activly developed. I will try to keep dependencies up to date
22+
but no new features will be added. You can read more
23+
[here](https://sams96.github.io/rgeo-5-years-on) if you are interested. If you
24+
are looking for an alternative, I recommend:
25+
- [smilyorg/tinygpkg](https://github.com/smilyorg/tinygpkg) - Very nice package
26+
inspired by Rgeo. It uses a different approach to vastly reduce startup time at
27+
the cost of slightly slower queries.
28+
- [authenticvision/rgeo](https://github.com/authenticvision/rgeo) - The most
29+
active fork of Rgeo, and most of the contributions I’ve had have come from
30+
these guys.
31+
Otherwise it should be fine to keep using Rgeo with its existing features.
32+
1933
## Key Features
2034

2135
- **Fast** - So I haven't _actually_ benchmarked other reverse geocoding tools
@@ -143,9 +157,4 @@ fmt.Printf("%s\n", loc.SubRegion)
143157

144158
## Contributing
145159

146-
Contributions are welcome, I haven't got any guidelines or anything so maybe
147-
just make an issue first.
148-
149-
## Projects using rgeo
150-
151-
- [rgeoSrv](https://github.com/sams96/rgeoSrv) - rgeo as a microservice
160+
I'm not accepting new features for the time being, see above.

data/Provinces10.gz

-3.31 MB
Binary file not shown.

datagen/datagen.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,13 @@ func main() {
102102
}
103103

104104
f, _ := os.Create(fmt.Sprintf("%s.gz", *outFileName))
105-
io.Copy(f, &buf)
105+
_, err = io.Copy(f, &buf)
106+
if err != nil {
107+
log.Fatal(err)
108+
}
106109

107110
fReadme, _ := os.Create(fmt.Sprintf("%s.txt", *outFileName))
108-
fReadme.WriteString(fmt.Sprintf("%s %s", strings.TrimSuffix(*outFileName, ".go"), "uses data from "+printSlice(prefixSlice(pre, files))))
111+
fmt.Fprintf(fReadme, "%s %s", strings.TrimSuffix(*outFileName, ".go"), "uses data from "+printSlice(prefixSlice(pre, files)))
109112
}
110113

111114
func readInputs(in []string, mergeFileName string) (*geojson.FeatureCollection, error) {

embed.go

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,32 @@
11
package rgeo
22

3-
import (
4-
"embed"
5-
"fmt"
6-
"io"
7-
)
3+
// embedding files individually here to allow the linker to strip out unused ones
4+
import _ "embed"
85

9-
//go:embed data/*
10-
var dataDir embed.FS
6+
//go:embed data/Cities10.gz
7+
var cities10 []byte
118

129
func Cities10() []byte {
13-
return readEmbedFile("Cities10.gz")
10+
return cities10
1411
}
1512

13+
//go:embed data/Countries10.gz
14+
var countries10 []byte
15+
1616
func Countries10() []byte {
17-
return readEmbedFile("Countries10.gz")
17+
return countries10
1818
}
1919

20-
func Countries110() []byte {
21-
return readEmbedFile("Countries110.gz")
22-
}
20+
//go:embed data/Countries110.gz
21+
var countries110 []byte
2322

24-
func Provinces10() []byte {
25-
return readEmbedFile("Provinces10.gz")
23+
func Countries110() []byte {
24+
return countries110
2625
}
2726

28-
func readEmbedFile(name string) []byte {
29-
f, err := dataDir.Open(fmt.Sprintf("data/%s", name))
30-
if err != nil {
31-
panic(fmt.Sprintf("internal embedded geojson open error %v", err))
32-
}
27+
//go:embed data/Provinces10.gz
28+
var provinces10 []byte
3329

34-
b, _ := io.ReadAll(f)
35-
return b
30+
func Provinces10() []byte {
31+
return provinces10
3632
}

go.mod

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
module github.com/swift-nav/rgeo
22

3-
go 1.19
3+
go 1.22
4+
5+
toolchain go1.24.1
46

57
require (
6-
github.com/go-test/deep v1.1.0
7-
github.com/golang/geo v0.0.0-20200730024412-e86565bf3f35
8-
github.com/pkg/errors v0.9.1
9-
github.com/twpayne/go-geom v1.4.4
8+
github.com/go-test/deep v1.1.1
9+
github.com/golang/geo v0.0.0-20230421003525-6adc56603217
10+
github.com/twpayne/go-geom v1.6.0
1011
)

go.sum

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2-
github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg=
3-
github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
4-
github.com/golang/geo v0.0.0-20200730024412-e86565bf3f35 h1:enTowfyfjtomBQhxX9mhUD+0tZhpe4rIzStO4aNlou8=
5-
github.com/golang/geo v0.0.0-20200730024412-e86565bf3f35/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
6-
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
7-
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
8-
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
9-
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
10-
github.com/twpayne/go-geom v1.4.4 h1:bcCPAvvNSzjmpUqR0Uqh39ClCKtPx6kZVR7EakQaVJI=
11-
github.com/twpayne/go-geom v1.4.4/go.mod h1:Kz4sX4LtdesDQgkhsMERazLlH/NiCg90s6FPaNr0KNI=
12-
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
1+
github.com/alecthomas/assert/v2 v2.10.0 h1:jjRCHsj6hBJhkmhznrCzoNpbA3zqy0fYiUcYZP/GkPY=
2+
github.com/alecthomas/assert/v2 v2.10.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
3+
github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
4+
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
5+
github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U=
6+
github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
7+
github.com/golang/geo v0.0.0-20230421003525-6adc56603217 h1:HKlyj6in2JV6wVkmQ4XmG/EIm+SCYlPZ+V4GWit7Z+I=
8+
github.com/golang/geo v0.0.0-20230421003525-6adc56603217/go.mod h1:8wI0hitZ3a1IxZfeH3/5I97CI8i5cLGsYe7xNhQGs9U=
9+
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
10+
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
11+
github.com/twpayne/go-geom v1.6.0 h1:WPOJLCdd8OdcnHvKQepLKwOZrn5BzVlNxtQB59IDHRE=
12+
github.com/twpayne/go-geom v1.6.0/go.mod h1:Kr+Nly6BswFsKM5sd31YaoWS5PeDDH2NftJTK7Gd028=

0 commit comments

Comments
 (0)