def limit_geom_chars(geom, limit=8000000, step=0.0001):
"""Limit chars in geom geojson string by simplification
Default limit for character count is 8000000
(8MB - MongoDB max document size is 16MB)
Default step for simplication is 0.0001
"""
geom = shape(geom)
curr_geom = geom
ix = 0
while len(str(curr_geom)) > limit:
ix = ix + 1
curr_geom = geom.simplify(step * ix)
simplify_tolerance = step * ix
return curr_geom.__geo_interface__, simplify_tolerance
评论列表
文章目录