Actions

Merge overlays

From Dragon Eye Atlas

Revision as of 10:07, 27 November 2019 by Tom (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This script combines the various overlay layers (realms, religions, etc.) into one for use in Mapbox:

<source>

<?php

/*

   (C)2019 by Tom Vogt <tom@lemuria.org>
   This merges the various overlay layers into one
   intended to be used as described in my video tutorials on my patreon page:
   https://www.patreon.com/notveryprofessional
  • /


$json = json_decode(file_get_contents("realms.geojson")); $realms = updata_dataset($json, 1000, 'realm', 'State');

$json = json_decode(file_get_contents("cultures.geojson")); $cultures = updata_dataset($json, 2000, 'culture', 'Culture');

$json = json_decode(file_get_contents("religions.geojson")); $religions = updata_dataset($json, 3000, 'religion', 'Religion');

$json = json_decode(file_get_contents("provinces.geojson")); $provinces = updata_dataset($json, 3000, 'province', 'Province');


function updata_dataset($data, $id, $class, $namefield) {

   foreach ($data->features as &$feature) {
       $feature->properties->id = $id++;
       $feature->properties->class = $class;
       $feature->properties->name = $feature->properties->$namefield;
   }
   return $data->features;

}

$output = json_decode('{"type": "FeatureCollection", "name": "overlays", "features": []}');

$output->features = array_merge($realms, $cultures, $religions, $provinces);

echo json_encode($output);


?>

</source>