Showing results for 
Search instead for 
Did you mean: 
Login & Join the DevCentral Connects Group to watch the Recorded LiveStream (May 12) on Basic iControl Security - show notes included.
Historic F5 Account

Problem this snippet solves:

The whereis command returns latitude and longitude as strings instead of floating points to save room in the geolation database. If you need degrees, you need to divide by 10000 to get them. This simple proc does the work for you..

How to use this snippet:

Add the proc to your specific rule or to your library rule of procs, then "call" it as appropriate.

Code :

### proc to convert integers to lat/lon degrees ###
proc geoloc_mod {latitude longitude} {
  return [list [expr {$latitude / 10000.}] [expr {$longitude / 10000.}]]

### example iRule taking advantage of the proc ###
  set lat [whereis [IP::client_addr] latitude]
  set lon [whereis [IP::client_addr] longitude]
  if { [string is integer $lat] && [string is integer $lon] } {
    #use proc to convert geolocation from strings to degrees, store in a list
    set geoloc_deg [call geoloc_mod $lat $lon]
  log local0. "Latitude: [lindex $geoloc_deg 0], Longititude: [lindex $geoloc_deg 1]"

Tested this on version:


@jason Why do you check this? string is integer $lat


Because if it’s false, geoloc_deg won’t be assigned value... which will lead to tcl error.


Community Manager
Community Manager

I migrated a bunch of codeshare stuff from wiki to this module a while back, so it has my name attached to it. But I will punt on responsibility here! If it were me, I'd move all that logic to the proc instead of splitting it between the event and the proc.


Version history
Last update:
‎21-May-2015 08:15
Updated by: