Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a dont_clean option #847

Merged
merged 2 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 5 additions & 2 deletions atlas/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ 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 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
}

// MVTName will return the value that will be encoded in the Name field when the layer is encoded as MVT
Expand Down
10 changes: 7 additions & 3 deletions atlas/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions cmd/internal/register/maps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,15 @@ 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 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"`
}

// ProviderLayerName returns the names of the layer and provider or an error
Expand Down
4 changes: 3 additions & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: "",
Expand Down Expand Up @@ -188,6 +189,7 @@ func TestParse(t *testing.T) {
MaxZoom: env.UintPtr(20),
DontSimplify: true,
DontClip: true,
DontClean: true,
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion maths/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down