geopackage-optimizer-go

command module
v0.0.0-...-624974a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2026 License: EUPL-1.2 Imports: 10 Imported by: 0

README

geopackage-optimizer

GitHub license GitHub release Go Report Card Docker Pulls

Optimizes GeoPackage so that it can be used as datasource for (PDOK) OGC services and APIs.

Build

docker build pdok/geopackage-optimizer-go .

Run

Usage of /optimizer:
  -config string
        optional JSON config for additional optimizations
  -s string
        source geopackage (default "empty")
  -service-type string
        service type to optimize geopackage for (default "ows")
TL;DR

Run from the root of this repo (note modifies testdata/original.gpkg):

docker run \
  -v testdata:/testdata \
  pdok/geopackage-optimizer-go:latest "/testdata/original.gpkg"

Optimizations

OGC webservices

With flag -service-type ows:

  • create index PUUID using UUID4
  • create index FUUID using [tablename].[PUUID]
  • can add (unique) indices on specified columns

This ensures that there are randomly generated UUID's usable as index, which has a couple of advantages:

  • having an index is good for performance
  • having a UUID instead of an incremental ID prevents crawling
  • having a UUID prevents users from creating applications that assumes that id has meaning and will not change in the future
docker run -v `pwd`/testdata:/testdata pdok/geopackage-optimizer-go 
    /testdata/original.gpkg 
    -service-type ows 
    -config '{"indices":[{"name": "my_index", "table": "mytable", "unique": false, "columns": ["mycolumn1", "mycolumn2"]}]}'
OGC API Features

With flag -service-type oaf:

  • create BTree equivalent of an RTree spatial index
  • create index for temporal columns
  • create indexed column with an "external feature id" (external_fid). This external FID is a UUID v5 based on one or more given columns that are functionally unique across time.

Above optimizations primarily target OGC API Features served through GoKoala.

Example:

docker run -v `pwd`/testdata:/testdata pdok/geopackage-optimizer-go 
    /testdata/original.gpkg 
    -service-type oaf 
    -config '{"layers":{"mytable":{"external-fid-columns":["fid"]}}}'
Relations

Optionally, one can add relations between features using this tool. This is in support of OAF Part 5 Feature References.

Relations are only supported when external-fid-columns are defined. Use a config like:

docker run -v `pwd`/testdata:/testdata pdok/geopackage-optimizer-go 
    /testdata/somepkg.gpkg 
    -service-type oaf 
    -config '{"layers":{"table1":{"external-fid-columns":["foo","bar"]},"table2":{"external-fid-columns":["foo","bar","bazz"],"relations":[{"table":"table1","columns":{"keys":[{"fk":"foo","pk":"foo"},{"fk":"bar","pk":"bar"}]}}]}}}'

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL