From 3f2257adab4fca5786638fad5a1404f520e01add Mon Sep 17 00:00:00 2001 From: Roel Arents Date: Mon, 2 May 2022 14:06:20 +0200 Subject: [PATCH 1/2] add dont_clean option --- atlas/layer.go | 3 +++ atlas/map.go | 10 +++++++--- cmd/internal/register/maps.go | 1 + config/config.go | 3 +++ config/config_test.go | 4 +++- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/atlas/layer.go b/atlas/layer.go index 9145f1044..0459870b1 100644 --- a/atlas/layer.go +++ b/atlas/layer.go @@ -23,6 +23,9 @@ type Layer struct { // DontClip indicates wheather feature clipping should be applied. // We use a negative in the name so the default is to clip DontClip bool + // DontClean indicates wheather feature cleaning (e.g. make valid) should be applied. + // We use a negative in the name so the default is to clean + DontClean bool } // MVTName will return the value that will be encoded in the Name field when the layer is encoded as MVT diff --git a/atlas/map.go b/atlas/map.go index 728b99205..abb109190 100644 --- a/atlas/map.go +++ b/atlas/map.go @@ -300,9 +300,13 @@ func (m Map) encodeMVTTile(ctx context.Context, tile *slippy.Tile) ([]byte, erro return err } - tegolaGeo, err = validate.CleanGeometry(ctx, sg, clipRegion) - if err != nil { - return fmt.Errorf("err making geometry valid: %w", err) + if !l.DontClean { + tegolaGeo, err = validate.CleanGeometry(ctx, sg, clipRegion) + if err != nil { + return fmt.Errorf("err making geometry valid: %w", err) + } + } else { + tegolaGeo = sg } geo, err = convert.ToGeom(tegolaGeo) diff --git a/cmd/internal/register/maps.go b/cmd/internal/register/maps.go index 878ccb48a..1344b9978 100644 --- a/cmd/internal/register/maps.go +++ b/cmd/internal/register/maps.go @@ -88,6 +88,7 @@ func atlasLayerFromConfigLayer(cfg *config.MapLayer, mapName string, layerProvid layer.ProviderLayerName = layerName layer.DontSimplify = bool(cfg.DontSimplify) layer.DontClip = bool(cfg.DontClip) + layer.DontClean = bool(cfg.DontClean) if cfg.MinZoom != nil { layer.MinZoom = uint(*cfg.MinZoom) diff --git a/config/config.go b/config/config.go index 656ccfee0..2e8bd6961 100644 --- a/config/config.go +++ b/config/config.go @@ -75,6 +75,9 @@ type MapLayer struct { // DontClip indicates wheather feature clipping should be applied. // We use a negative in the name so the default is to clipping DontClip env.Bool `toml:"dont_clip"` + // DontClip indicates wheather feature cleaning (e.g. make valid) should be applied. + // We use a negative in the name so the default is to clean + DontClean env.Bool `toml:"dont_clean"` } // ProviderLayerName returns the names of the layer and provider or an error diff --git a/config/config_test.go b/config/config_test.go index 3c6e57678..13f3467b4 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -139,7 +139,8 @@ func TestParse(t *testing.T) { min_zoom = 10 max_zoom = 20 dont_simplify = true - dont_clip = true`, + dont_clip = true + dont_clean = true`, expected: config.Config{ TileBuffer: env.IntPtr(env.Int(12)), LocationName: "", @@ -188,6 +189,7 @@ func TestParse(t *testing.T) { MaxZoom: env.UintPtr(20), DontSimplify: true, DontClip: true, + DontClean: true, }, }, }, From 1c87f22bf422b634923970e84d30972cd9e8e1c8 Mon Sep 17 00:00:00 2001 From: Roel Arents Date: Mon, 2 May 2022 14:08:56 +0200 Subject: [PATCH 2/2] typos --- atlas/layer.go | 6 +++--- config/config.go | 6 +++--- maths/validate/validate.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/atlas/layer.go b/atlas/layer.go index 0459870b1..3337dcf01 100644 --- a/atlas/layer.go +++ b/atlas/layer.go @@ -17,13 +17,13 @@ type Layer struct { // default tags to include when encoding the layer. provider tags take precedence DefaultTags map[string]interface{} GeomType geom.Geometry - // DontSimplify indicates wheather feature simplification should be applied. + // DontSimplify indicates whether feature simplification should be applied. // We use a negative in the name so the default is to simplify DontSimplify bool - // DontClip indicates wheather feature clipping should be applied. + // DontClip indicates whether feature clipping should be applied. // We use a negative in the name so the default is to clip DontClip bool - // DontClean indicates wheather feature cleaning (e.g. make valid) should be applied. + // DontClean indicates whether feature cleaning (e.g. make valid) should be applied. // We use a negative in the name so the default is to clean DontClean bool } diff --git a/config/config.go b/config/config.go index 2e8bd6961..c7e9f5e1b 100644 --- a/config/config.go +++ b/config/config.go @@ -69,13 +69,13 @@ type MapLayer struct { MinZoom *env.Uint `toml:"min_zoom"` MaxZoom *env.Uint `toml:"max_zoom"` DefaultTags interface{} `toml:"default_tags"` - // DontSimplify indicates wheather feature simplification should be applied. + // DontSimplify indicates whether feature simplification should be applied. // We use a negative in the name so the default is to simplify DontSimplify env.Bool `toml:"dont_simplify"` - // DontClip indicates wheather feature clipping should be applied. + // DontClip indicates whether feature clipping should be applied. // We use a negative in the name so the default is to clipping DontClip env.Bool `toml:"dont_clip"` - // DontClip indicates wheather feature cleaning (e.g. make valid) should be applied. + // DontClip indicates whether feature cleaning (e.g. make valid) should be applied. // We use a negative in the name so the default is to clean DontClean env.Bool `toml:"dont_clean"` } diff --git a/maths/validate/validate.go b/maths/validate/validate.go index 706588186..f2d9d3bfa 100644 --- a/maths/validate/validate.go +++ b/maths/validate/validate.go @@ -98,7 +98,7 @@ func scaleMultiPolygon(p tegola.MultiPolygon, factor float64) (bmp basic.MultiPo return bmp } -// CleanGeometry will apply various geoprocessing algorithems to the provided geometry. +// CleanGeometry will apply various geoprocessing algorithms to the provided geometry. // the extent will be used as a clipping region. if no clipping is desired, pass in a nil extent. func CleanGeometry(ctx context.Context, g tegola.Geometry, extent *geom.Extent) (geo tegola.Geometry, err error) { if g == nil {