build/ESRI_Census_Based_2013_NZTM.zip:
	mkdir -p $(dir $@)
	curl -o $@ http://www3.stats.govt.nz/digitalboundaries/census/$(notdir $@)

build/ESRI_Census_Based_2013_NZTM.shp: build/ESRI_Census_Based_2013_NZTM.zip
	unzip -od $(dir $@) $<
	touch $@

build/wards.geojson: build/ESRI\ shapefile\ Output/2013\ Digital\ Boundaries\ Generalised\ Clipped/WARD2013_GV_Clipped.shp
	ogr2ogr -f GeoJSON build/wards.geojson build/ESRI\ shapefile\ Output/2013\ Digital\ Boundaries\ Generalised\ Clipped/WARD2013_GV_Clipped.shp -s_srs EPSG:2193 -t_srs EPSG:2193

build/wards.json: build/wards.geojson
	node_modules/topojson/node_modules/topojson-server/bin/geo2topo \
		-o $@ \
		wards=$<

build/wards-simple-topo.json: build/wards.json
	node_modules/topojson/node_modules/topojson-client/bin/topoquantize 1e4 \
		< $< \
		> build/wards-simple-topo.json
