Live data from Hacker News

How to Make Maps Using Leaflet.js, PostGIS and Chicago Open Data

samc1213.github.io

21–23 of 23 posts

Re: How to Make Maps Using Leaflet.js, PostGIS and Chicago Open Data

#21
post #14

Earlier quoted context omitted.

Reduce the precision, 15 decimal places are useful for picometers, not a web map. Try 5-6.

It never seems worth the effort in my testing, as you have to come up with your own loop to do the truncating, and the benefit is marginal. In this case he’d have 1.2gb file, I doubt that fixes the problem.

for what it's worth, ST_AsGeoJSON lets you specify decimal precision as an optional argument, so you at least don't have to write a truncating loop.

Another good option with many polygon geometries is Base64 encoding the output of ST_AsGeobuf -- it is many times smaller than GeoJSON and still pretty easy to handle from Javascript. (Needs libprotobuf-c on the PostGIS side and geobuf.js+pbf.js on the JS side)

Re: How to Make Maps Using Leaflet.js, PostGIS and Chicago Open Data

#22
post #21

Earlier quoted context omitted.

It never seems worth the effort in my testing, as you have to come up with your own loop to do the truncating, and the benefit is marginal. In this case he’d have 1.2gb file, I doubt that fixes the problem.

for what it's worth, ST_AsGeoJSON lets you specify decimal precision as an optional argument, so you at least don't have to write a truncating loop. Another good option with many polygon geometries is Base64 encoding the output of ST_AsGeobuf -- it is many times smaller than GeoJSON and still pretty easy to handle from Javascript. (Needs libprotobuf-c on the PostGIS side and geobuf.js+pbf.js on the JS side)

Thats cool, I should try AsGeobuf as a soft upgrade to one of the older tile GeoJSON site :)
Post reply on HN