Location search and geocoding API. To be used in concert with OGC APIs.
This application offers location search and geocoding.
NAME:
gomagpie - Run location search and geocoding API, or use as CLI to support the ETL process for this API.
USAGE:
gomagpie [global options] command [command options]
COMMANDS:
start-service Start service to serve location API
help, h Shows a list of commands or help for one command
etl:
create-search-index Create empty search index in database
import-file Import file into search index
GLOBAL OPTIONS:
--help, -h show help
Example (config-file is mandatory):
docker run -v `pwd`/examples:/examples -p 8080:8080 -it pdok/gomagpie start-service --config-file /examples/config.yaml
Now open http://localhost:8080. See examples for more details.
Create database using the ETL commands.
# First create database to populate
docker run --rm --name postgis -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=test_db -p 5432:5432 postgis/postgis
./gomagpie create-search-index --db-name test_db
./gomagpie import-file --db-name test_db \
--file internal/etl/testdata/addresses-crs84.gpkg \
--feature-table "addresses" \
--config-file internal/etl/testdata/config.yaml \
--collection-id "addresses" \
--substitutions-file internal/etl/testdata/substitutions.csv \
--synonyms-file internal/etl/testdata/synonyms.csv
docker build -t pdok/gomagpie .
Health endpoint is available on /health
.
Besides the main server, Gomagpie can also start a debug server. This server
binds to localhost and a different port which you must specify using the
--debug-port
flag. You shouldn't expose this port publicly but only access it
through a tunnel/port-forward. The debug server exposes /debug
for use by
pprof. For example with --debug-port 9001
:
- Create a tunnel to the debug server e.g. in k8s:
kubectl port-forward gomagpie-75f59d57f4-4nd6q 9001:9001
- Create CPU profile:
go tool pprof http://localhost:9001/debug/pprof/profile?seconds=20
- Start pprof visualization
go tool pprof -http=":8000" pprofbin <path to pb.gz file>
- Open http://localhost:8000 to explore CPU flamegraphs and such.
A similar flow can be used to profile memory issues.
go build -o gomagpie cmd/main.go
./gomagpie
To troubleshoot, review the Dockerfile since compilation also happens there.
Install golangci-lint and run golangci-lint run
from the root.
Either run go test ./...
or go test -short ./...
- Install the Go Template plugin
- Open
Preferences
>Editor
>File Types
selectGo Template files
and add the following file patterns:"*.go.html"
"*.go.json"
"*.go.tilejson"
"*.go.xml"
- Now add template language support by running the setup-jetbrains-gotemplates.sh script.
- Reopen the project (or restart IDE). Now you'll have full IDE support in the gomagpie templates.
Also:
- Set import order in
Preferences
>Editor
>Code Style
>Go
>Imports
togoimports
to align with VSCode and goimports usage in golangci-lint.
- Install the Go Template extension
- Open Extension Settings and add the following file patterns:
"*.go.html"
"*.go.json"
"*.go.tilejson"
"*.go.xml"
- Also add
html
,json
andxml
to the list of Go template languages. - Now you'll have IDE support in the gomagpie templates.
Gomagpie started as a fork of GoKoala.
Make a pull request...
Contacting the maintainers can be done through the issue tracker.