Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2dcf57d
feat: integer polygons with conversion to floating-point
DvBree Jul 8, 2026
8d9ac55
feat: copy pbf encoding functionality from go-spatial
DvBree Jul 8, 2026
6abcd3f
refactor: remove unused parameter in pbf encoding functionality
DvBree Jul 8, 2026
f42a4a6
feat: encode polygon in quadrant
DvBree Jul 8, 2026
e96c81c
fix: prepare geo instead of just translation
DvBree Jul 8, 2026
9004142
feat: primitive detection of relevant tiles
DvBree Jul 8, 2026
a949286
chore: adapt to slippy api change
DvBree Jul 9, 2026
d45a6c6
feat: create tables for encoded features
DvBree Jul 9, 2026
3f72663
fix: encode arbitrary geometries
DvBree Jul 9, 2026
995f82b
fix: QBBox returns slice
DvBree Jul 10, 2026
0b60cd9
refactor: decouple geometry logic, logging and channel logic
DvBree Jul 10, 2026
fd63764
feat: snap meta-results available during processing
DvBree Jul 10, 2026
c2a67cf
fix: create geometry_type field in encodedtable
DvBree Jul 10, 2026
ac8917d
feat: types for encoded data
DvBree Jul 13, 2026
13c1944
feat: encoded geometries to database layer
DvBree Jul 13, 2026
b462c23
feat: write encoded geometries to target geopackage
DvBree Jul 13, 2026
b1057e8
fix: comma in SQL statement
DvBree Jul 13, 2026
f4e807b
fix: wrong mix of initialize and append to slice
DvBree Jul 13, 2026
ad77fc4
fix: SQL statement syntax error
DvBree Jul 13, 2026
8b52d84
fix: serialize int slice for storage
DvBree Jul 14, 2026
e9f1d61
fix: update snap test with new snap return construct
DvBree Jul 14, 2026
29898a2
refactor: moved helper function to geomhelp
DvBree Jul 14, 2026
1dfe343
feat: flag for optional encoding of geometries
DvBree Jul 14, 2026
bb69eac
chore: linter warnings (mainly in copied code)
DvBree Jul 14, 2026
5e4c758
refactor: removed unused code
DvBree Jul 14, 2026
7bb1c18
refactor: remove unused function
DvBree Jul 17, 2026
4e07861
test: add PolygonSliceToGeom unit test
DvBree Jul 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions geomhelp/geomhelp.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,17 @@ func wktMustEncodeTruncated(geom geom.Geometry, width uint) string {
}
return truncate.StringWithTail(wkt.MustEncode(geom), width, "...")
}

func PolygonSliceToGeom(polygons []geom.Polygon) geom.Geometry {
if len(polygons) == 0 {
panic("Multipolygon with zero polygons encountered")
}
if len(polygons) == 1 {
return polygons[0]
}
multipolygon := make(geom.MultiPolygon, len(polygons))
for i, p := range polygons {
multipolygon[i] = p
}
return multipolygon
}
49 changes: 49 additions & 0 deletions geomhelp/geomhelp_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package geomhelp

import (
"testing"

"github.com/go-spatial/geom"
"github.com/stretchr/testify/assert"
)

func TestGeomhelp_PolygonSliceToGeom(t *testing.T) {
tests := []struct {
name string
polygonSlice []geom.Polygon
want geom.Geometry
wantPanic bool
}{
{
name: "Empty polygon slice",
polygonSlice: []geom.Polygon{},
wantPanic: true,
},
{
name: "Single polygon",
polygonSlice: []geom.Polygon{{{{0.0, 0.0}, {1.0, 0.0}, {1.0, 1.0}}}},
want: geom.Polygon{{{0.0, 0.0}, {1.0, 0.0}, {1.0, 1.0}}},
},
{
name: "Two polygons",
polygonSlice: []geom.Polygon{
{{{0.0, 0.0}, {1.0, 0.0}, {1.0, 1.0}}},
{{{10.0, 10.0}, {10.0, 11.0}, {11.0, 11.0}}},
},
want: geom.MultiPolygon{
{{{0.0, 0.0}, {1.0, 0.0}, {1.0, 1.0}}},
{{{10.0, 10.0}, {10.0, 11.0}, {11.0, 11.0}}},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if tt.wantPanic {
assert.Panics(t, func() { PolygonSliceToGeom(tt.polygonSlice) })
return
}
got := PolygonSliceToGeom(tt.polygonSlice)
assert.Equal(t, tt.want, got)
})
}
}
9 changes: 7 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/carlmjohnson/versioninfo v0.22.5
github.com/creasty/defaults v1.8.0
github.com/go-playground/validator/v10 v10.30.3
github.com/go-spatial/geom v0.0.0-20220918193402-3cd2f5a9a082
github.com/go-spatial/geom v0.1.0
github.com/iancoleman/strcase v0.3.0
github.com/muesli/reflow v0.3.0
github.com/perimeterx/marshmallow v1.1.5
Expand All @@ -18,6 +18,7 @@ require (
)

require (
github.com/arolek/p v0.0.0-20191103215535-df3c295ed582 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
Expand All @@ -26,17 +27,21 @@ require (
github.com/gdey/errors v0.0.0-20190426172550-8ebd5bc891fb // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-spatial/proj v0.3.0 // indirect
github.com/go-test/deep v1.1.1 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-runewidth v0.0.12 // indirect
github.com/mattn/go-sqlite3 v1.14.17 // indirect
github.com/mattn/go-sqlite3 v1.14.22 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
golang.org/x/crypto v0.52.0 // indirect
golang.org/x/sys v0.45.0 // indirect
golang.org/x/text v0.37.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
44 changes: 20 additions & 24 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
github.com/arolek/p v0.0.0-20191103215535-df3c295ed582 h1:DugKk4B3PpqfZ1QunDSPqNZDAErQmdCgwurloi1Axaw=
github.com/arolek/p v0.0.0-20191103215535-df3c295ed582/go.mod h1:JPNItmi3yb44Q5QWM+Kh5n9oeRhfcJzPNS90mbLo25U=
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
Expand All @@ -9,7 +10,6 @@ github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3
github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/creasty/defaults v1.8.0 h1:z27FJxCAa0JKt3utc0sCImAEb+spPucmKoOdLHvHYKk=
github.com/creasty/defaults v1.8.0/go.mod h1:iGzKe6pbEHnpMPtfDXZEr0NVxWnPTjb1bbDy08fPzYM=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9Ufpk2AcUM=
Expand All @@ -24,14 +24,18 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.30.3 h1:4MU6YkEwx7GbcPJOZxrtbu+QfF3pJLJuaYTeAH0DYy8=
github.com/go-playground/validator/v10 v10.30.3/go.mod h1:4Axh7oCNGcoGkqLoE4YWt6n20mcEIsPRlB7vPk3lpyc=
github.com/go-spatial/geom v0.0.0-20220918193402-3cd2f5a9a082 h1:3+Swhq7I1stScm1DE4PUWKjGJRbi+VPvisj6tFz0prs=
github.com/go-spatial/geom v0.0.0-20220918193402-3cd2f5a9a082/go.mod h1:YU06tBGGstQCUX7vMuyF44RRneTdjGxOrp8OJHu4t9Q=
github.com/go-spatial/proj v0.2.0 h1:sii5Now3GFEyR9hV2SBJFWFz95s4xSaZmP0aYDk1K6c=
github.com/go-spatial/proj v0.2.0/go.mod h1:ePHHp7ITVc4eIVW5sgG/0Eu9RMAGOQUgM/D1ZkccY+0=
github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM=
github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/go-spatial/geom v0.1.0 h1:IZ6LVz0Kkgd8+U83MmI0J4L4TBDzk5I8xiYe9Ci+aHk=
github.com/go-spatial/geom v0.1.0/go.mod h1:yNr22dnkQyFEwq2MJVmmiReiFesQpXKlosAG+qUSPus=
github.com/go-spatial/proj v0.3.0 h1:2IRb4elpnmVy1tUKRGBR68uiyZU4Pmny8yZC7TEUdSg=
github.com/go-spatial/proj v0.3.0/go.mod h1:wF0V0A60cTD5uzXeg+P52E1GtMY40PIiyYNJVvHXm6k=
github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U=
github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
Expand All @@ -42,13 +46,10 @@ github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mattn/go-runewidth v0.0.12 h1:Y41i/hVW3Pgwr8gV+J23B9YEY0zxjptBuCWEaxmAOow=
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-sqlite3 v1.12.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM=
github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/mattn/goveralls v0.0.3-0.20180319021929-1c14a4061c1c/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw=
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s=
github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand All @@ -58,8 +59,6 @@ github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tobshub/go-sortedmap v1.0.3 h1:oUhj/5tqzjTX4bhWqB1ZFTDtMULJ1ZYUnS8WAugSfjY=
Expand All @@ -72,23 +71,20 @@ github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.52.0 h1:RMs7fP2rXdep0CftQlK8Uf+kibLm7qkCcradZWYz988=
golang.org/x/crypto v0.52.0/go.mod h1:1QgfPxDqh0T2M/elOJtp9RvuR95kVjir0e6/BvEmGbc=
golang.org/x/exp v0.0.0-20260611194520-c48552f49976 h1:X8Hz2ImujgbmetVuW+w2YkyZChE3cBpZi2P158rTG9M=
golang.org/x/exp v0.0.0-20260611194520-c48552f49976/go.mod h1:vnf4pv9iKZXY58sQE1L86zmNWJ4159e1RkcWiLCkeEY=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc=
golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38=
golang.org/x/tools v0.0.0-20191114222411-4191b8cbba09/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
32 changes: 22 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@ import (
"github.com/urfave/cli/v2"
)

const SOURCE string = `sourceGpkg`
const TARGET string = `targetGpkg`
const OVERWRITE string = `overwrite`
const TILEMATRIXSET string = `tilematrixset`
const TILEMATRICES string = `tilematrices`
const PAGESIZE string = `pagesize`
const KEEPPOINTSANDLINES string = `keeppointsandlines`
const IGNOREOUTSIDEGRID string = `ignoreoutsidegrid`
const REVERSEWINDINGORDER string = `reversewindingorder`
const (
SOURCE string = `sourceGpkg`
TARGET string = `targetGpkg`
OVERWRITE string = `overwrite`
TILEMATRIXSET string = `tilematrixset`
TILEMATRICES string = `tilematrices`
PAGESIZE string = `pagesize`
KEEPPOINTSANDLINES string = `keeppointsandlines`
IGNOREOUTSIDEGRID string = `ignoreoutsidegrid`
REVERSEWINDINGORDER string = `reversewindingorder`
ENCODETILES string = `encodetiles`
)

//nolint:funlen
func main() {
Expand Down Expand Up @@ -111,6 +114,14 @@ func main() {
Required: false,
EnvVars: []string{strcase.ToScreamingSnake(REVERSEWINDINGORDER)},
},
&cli.BoolFlag{
Name: ENCODETILES,
Aliases: []string{"enc"},
Usage: "Add tables with mapbox-encoded geometries.",
Value: false,
Required: false,
EnvVars: []string{strcase.ToScreamingSnake(ENCODETILES)},
},
}

app.Action = func(c *cli.Context) error {
Expand Down Expand Up @@ -145,6 +156,7 @@ func main() {
KeepPointsAndLines: c.Bool(KEEPPOINTSANDLINES),
IgnoreOutsideGrid: c.Bool(IGNOREOUTSIDEGRID),
ReverseWindingOrder: c.Bool(REVERSEWINDINGORDER),
EncodeTiles: c.Bool(ENCODETILES),
}
for _, tmID := range tileMatrixIDs {
gpkgTargets[tmID] = initGPKGTarget(targetPathFmt, tmID, overwrite, pagesize)
Expand Down Expand Up @@ -223,7 +235,7 @@ func injectSuffixIntoPath(p string) string {
}

func processBySnapping(source processing.Source, targets map[tms20.TMID]processing.Target, tileMatrixSet tms20.TileMatrixSet, snapConfig snap.Config) {
processing.ProcessFeatures(source, targets, func(p geom.Polygon, tmIDs []tms20.TMID) map[tms20.TMID][]geom.Polygon {
processing.ProcessFeatures(source, targets, func(p geom.Polygon, tmIDs []tms20.TMID) map[tms20.TMID]processing.SnapResult {
return snap.SnapPolygon(p, tileMatrixSet, tmIDs, snapConfig)
})
}
46 changes: 44 additions & 2 deletions pointindex/pointindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ type Quadrant struct {
intCentroid intgeom.Point
}

func (q *Quadrant) Extent() geom.Extent {
return q.intExtent.ToGeomExtent()
}

func (q *Quadrant) Coords() (uint, uint) {
return morton.FromZ(q.z)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*morten

}

// PointIndex is a pointcloud annex quadtree to enable snapping lines to a grid accounting for those points.
// Quadrants:
//
Expand Down Expand Up @@ -73,8 +81,10 @@ type PointIndex struct {
hitMultiple map[Level]map[intgeom.Point][]int
}

type Level = uint
type Q = int // quadrant index (0, 1, 2 or 3)
type (
Level = uint
Q = int // quadrant index (0, 1, 2 or 3)
)

func FromTileMatrixSet(tileMatrixSet tms20.TileMatrixSet, deepestTMID tms20.TMID) (*PointIndex, error) {
// assuming IsQuadTree was tested before
Expand Down Expand Up @@ -108,6 +118,38 @@ func FromTileMatrixSet(tileMatrixSet tms20.TileMatrixSet, deepestTMID tms20.TMID
return &ix, nil
}

// Temporary function: primitively marks quadrants as relevant for tiling
func (ix *PointIndex) GetPrimitiveQBBox(l Level) []Quadrant {
quadrants := ix.quadrants[l]

minX := ^uint(0)
maxX := uint(0)
minY := ^uint(0)
maxY := uint(0)

for z := range quadrants {
x, y := morton.FromZ(z)
minX = min(x, minX)
maxX = max(x, maxX)
minY = min(y, minY)
maxY = max(y, maxY)
}

quadrantSlice := make([]Quadrant, (maxY-minY)*(maxX-minX))
for i := range maxX - minX {
for j := range maxY - minY {
extent, centroid := ix.getQuadrantExtentAndCentroid(l, minX+i, minY+j, ix.intExtent)
newQuadrant := Quadrant{
z: morton.MustToZ(minX+i, minY+j),
intExtent: extent,
intCentroid: centroid,
}
quadrantSlice[i*(maxY-minY)+j] = newQuadrant
}
}
return quadrantSlice
}

// InsertPolygon inserts all points from a Polygon
func (ix *PointIndex) InsertPolygon(polygon geom.Polygon) error {
// initialize the quadrants map
Expand Down
Loading
Loading