<?php
/**
 * Script to fetch an open source SVG map of Kenya counties
 * and save it to images/kenya-counties.svg
 */
$url = 'https://raw.githubusercontent.com/deldersveld/topojson/master/countries/kenya/kenya-counties.json';
// Actually topojson isn't an SVG. 
// Let's use Wikipedia's SVG or another source. Wait, downloading and parsing can be error prone.
// Let me write a basic script to get the SVG from wikipedia and re-format it. 
// The Wikimedia SVG for Kenya counties is: https://upload.wikimedia.org/wikipedia/commons/4/41/Kenya_counties.svg
$url = 'https://upload.wikimedia.org/wikipedia/commons/4/41/Kenya_counties.svg';
$svg = file_get_contents($url);

if ($svg) {
    file_put_contents(__DIR__ . '/images/base-kenya.svg', $svg);
    echo "Saved to images/base-kenya.svg\n";
} else {
    echo "Failed to fetch SVG.\n";
}
