OCaml Infra Map
Mark Elvers
1 min read

Categories

  • OCaml

Tags

  • tunbury.org

Yesterday, we were talking about extending the current infrastructure database to incorporate other information to provide prompts to return machines to the pool of resources after they have completed their current role/loan, etc. There is also a wider requirement to bring these services back to Cambridge from Equinix/Scaleway, which will be the subject of a follow-up post. However, the idea of extending the database made me think that it would be amusing to overlay the machine’s positions onto Google Maps.

I added positioning data in the Jekyll Collection _machines\*.md for each machine. e.g. ainia.md

---
name: ainia
...
latitude: 52.2109
longitude: 0.0917
---

Then Jekyll’s Liquid templating engine can create a JavaScript array for us


  // Define machines data array from Jekyll collection
  const machinesData = [
    {% for machine in site.machines %}
      {% if machine.latitude and machine.longitude %}
      {
        name: "{{ machine.name }}",
        lat: {{ machine.latitude }},
        lng: {{ machine.longitude }},
        {% if machine.description %}
        description: "{{ machine.description | escape }}",
        {% endif %}
        // Add any other properties you need
      },
      {% endif %}
    {% endfor %}
  ];

This array can be converted into an array of map markers. Google have an API for clustering the markers into a count of machines. I added a random offset to each location to avoid all the markers piling up on a single spot.

The interactive map can be seen at machines.html