 defmodule Enricher.Gazetteer do
+  require Logger
   alias Services.Gazetteer
+  alias Core.Utils
 
   def add_coordinates(change = %{ doc: %{ resource: %{ gazId: gazId, category: "Project" }}}) do
       coordinates = get_coordinates_from_gazetteer(gazId)


  defp get_coordinates_from_gazetteer(gazetteer_id) do
      Gazetteer.get_place(gazetteer_id)
      |> get_coordinates_from_place
  end


  defp get_coordinates_from_place(%{ prefLocation: %{ coordinates: [longitude, latitude] }}) do
      [longitude, latitude]
  end
  defp get_coordinates_from_place(_place) do

    Logger.error "Failed to retrieve coordinates from gazetteer place, coordinates field is missing."
    nil
  end

end
