Page MenuHomePhabricator

Implement shape simplification
Closed, ResolvedPublic

Description

A great article https://blog.cartodb.com/smaller-faster/ might be a good start for PostGIS-based optimization (thx @Pnorman for suggesting)

Event Timeline

Yurik created this task.Jun 19 2016, 12:03 AM
Restricted Application added a subscriber: Zppix. · View Herald TranscriptJun 19 2016, 12:03 AM

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.

Yurik added a comment.Jun 20 2016, 1:36 AM

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 closed this task as Resolved.Jun 26 2016, 8:19 PM
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.

Kozuch added a subscriber: Kozuch.Mon, Aug 5, 9:09 AM

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

https://en.wikipedia.org/w/index.php?title=Wikipedia:Village_pump_(miscellaneous)&oldid=909413139

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

The new bug is at T155919

Thanks.