smartchicago / chicagoworksforyou

A citywide dashboard with ward-by-ward views of service delivery in Chicago. Includes complete API. Built using Chicago Open311 data.
http://www.chicagoworksforyou.com
MIT License
17 stars 6 forks source link

Optimize the ward boundary data. #197

Closed santheo closed 11 years ago

santheo commented 11 years ago

New scripts.js is 37kb. Here's the script I used to convert the old wardPaths:

var newPoint = function (pt) { 
  var minlat = 41.644553;
  var minlng = -87.525162;

  return [
    Math.round((pt.lat - minlat) * 1000000),  
    Math.round((pt.lng - minlng) * -1000000)
  ];
};

simpleWardPaths = _.map(wardPaths,function(ward){ return _.map(ward, function (point) { return newPt(point); }); })

I got those minlat & minlng by flattening wardPaths and finding the mins.

santheo commented 11 years ago

Whoops, this pull request is set to go into development. If you merge it, you can delete your 'simplify_boundaries' branch, since this is a branch of that branch.

santheo commented 11 years ago

Closes #201.

Meanwhile, I'm working on further byte-lightening by encoding each normalized number as a set of unicode chars. I've got it working on the encoding side. I haven't done the decoding part yet. Here's what it looks like. The weight of the encoded data is roughly 57% of the normalized data.

screen shot 2013-08-14 at 10 52 41 am