GE Lua Documentation

Press F to search!

gasStationCenterRadius

Definition


-- @/lua/ge/extensions/freeroam/gasStations.lua:29

local function gasStationCenterRadius(f)
  local center, count = vec3(0,0,0), 0
  for _, pair in ipairs(f.pumps or {}) do
    local obj = scenetree.findObject(pair[1])
    if obj then
      center = center + obj:getPosition()
      count = count + 1
    end
  end
  center = center / count

  local maxDistSqr = 0
  for _, pair in ipairs(f.pumps or {}) do
    local obj = scenetree.findObject(pair[1])
    if obj then
      maxDistSqr = math.max(maxDistSqr, (obj:getPosition()-center):squaredLength())
    end
  end

  return center, math.sqrt(maxDistSqr)
end

Callers

@/lua/ge/extensions/freeroam/gasStations.lua
local function formatGasStationPoi(gasStation)
  local center, radius = gasStationCenterRadius(gasStation)
  local isElectric = tableValuesAsLookupDict(gasStation.energyTypes or {"any"}).electricEnergy