Page MenuHomePhabricator

Implement shape simplification
Closed, ResolvedPublic


A great article might be a good start for PostGIS-based optimization (thx @Pnorman for suggesting)

Event Timeline

Moved from T134085#2391825: Simplification notes from @Pnorman (thx!)

don't simplify in 4326, do it in a non-geodetic projection. the appropriate simplification should probably be some factor times something from geometry. maybe st_length, or geometric mean of x and y of bboxes in the collection, maybe something else
try different things out. basing it on just bounding box values avoids needing to do as many calculations. a mercator system would work fine for simplification since the mercator distortion will cancel out

<yurik> Are you saying I should do something like ST_Envelope(ST_Transform(way, mercator)), and get the range between the min/maxes, use the biggest one (X or Y), and then experiment what multiplier I need to get the best tolerance?

maybe st_transform(st_simplify(st_transform(geom,M), N*sqrt(st_area(st_transform(st_envelope(geom),M))), true),st_srid(geom))
or maybe use the biggest one.

I implemented a number of different simplifications (some might not work outright) to try them out. The code is here.
Simplifications can be accessed via parameters, e.g. /shape?q=Q656&sql=simplify&tolerance=100

Yurik claimed this task.
Yurik moved this task from All map-related tasks to Kartotherian on the Maps board.

Closing because we now have this, and to optimize it to better defaults would be a different task.

Can someone please revert or re-implement this so that the simplification is not so aggressive - it starts to prevent Wimimedia Maps from being used for example on English Wikipedia. The maps can not be used for example to show country borders. See relevant discussion at

in section OpenStreetMap. Multiple people complain about over-simplified features.

The new bug is at T155919