geolocation
1 TopicConvert Geolocation Data From String to Degrees
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 ### when HTTP_REQUEST { 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: 11.6378Views0likes2Comments