Geofency is a time and location tracking app for iOS. I’ve been using it for many years to keep track of my whereabouts. At times, this information can come in quite handy.

The app does not track your movements continuously. Instead, it uses Geofencing and iBeacon technology, which uses less battery. The app will note the time and location every time you stop somewhere for a few minutes.

Geofency data exported to CSV
Start Date/Time	End Date/Time	Place	Latitude	Longitude	Number	EntryDate	EntryTime	ExitDate	ExitTime	Hours	hhmmss	Notes	Type	UUID
7/3/2022 17:07	7/3/2022 17:32	I-70 W	39.3301	-101.9159	1	7/3/2022	5:07:47 PM	7/3/2022	5:32:53 PM	0.4183	0:25:05		Frequent	C22A2E25-DB10-4551-9047-65AB64644B05
7/3/2022 17:38	7/3/2022 17:52	59976 US-24	39.33	-102.0499	1	7/3/2022	5:38:37 PM	7/3/2022	5:52:51 PM	0.2374	0:14:14		Frequent	ABE53562-7FA9-4791-A294-027ABCDCE6BD
7/3/2022 19:12	7/3/2022 20:45	2200 Ninth St	39.2715	-103.7069	1	7/3/2022	7:12:46 PM	7/3/2022	8:45:29 PM	1.5452	1:32:42		Frequent	8EACC23C-C26F-47C6-B709-53E9067F2353
7/3/2022 20:47	7/4/2022 9:56	2510 Sixth St	39.2705	-103.7109	1	7/3/2022	8:47:02 PM	7/4/2022	9:56:43 AM	13.1613	13:09:40		Frequent	E30F00DA-6B3D-4A91-9AA7-813099E6F87D
7/4/2022 10:46	7/4/2022 10:52	1600616238 E US Hwy 24	38.9912	-104.5299	1	7/4/2022	10:46:19 AM	7/4/2022	10:52:46 AM	0.1074	0:06:26		Frequent	C1B1D567-3137-4A3F-AED7-2CF0135C1092
7/4/2022 11:10	7/4/2022 11:26	5808 Barnes Rd	38.8944	-104.7177	1	7/4/2022	11:10:17 AM	7/4/2022	11:26:22 AM	0.268	0:16:04		Frequent	4D9C51AF-EB6E-44C6-BFB4-F9AD1A12F278
7/4/2022 11:26	7/4/2022 12:48	5617 Barnes Rd	38.8931	-104.7228	1	7/4/2022	11:26:23 AM	7/4/2022	12:48:49 PM	1.3739	1:22:26		Frequent	90E1B093-EB7E-4B88-86EB-AE934061281F
7/4/2022 15:02	7/4/2022 15:19	42294299 US-50	38.5076	-105.9607	1	7/4/2022	3:02:58 PM	7/4/2022	3:19:44 PM	0.2794	0:16:45		Frequent	8531E16B-967E-4D18-9290-D83EC4BFFAE7
7/4/2022 15:22	7/4/2022 15:41	1046 E Rainbow Blvd	38.5245	-105.99	1	7/4/2022	3:22:24 PM	7/4/2022	3:41:36 PM	0.3199	0:19:11		Frequent	F7982442-3615-4D3A-8585-029E819B0875

After returning from a month-long overlanding trip last year, I couldn’t remember half of the places I visited. So, I exported the data from Geofency (see sample above) and noticed that the location description could use some work. For example, “5617 Barnes Rd” doesn’t tell me much.

The solution was to set up a project on Google Maps, get my API key, and enable billing. Google gives you a $300 credit for a 90-day trial period. I would recommend you do a couple of things. First, check out Privacy.com and create a credit card with a low monthly spending limit. And use that credit card to enable billing for your Google Maps project. Second, restrict your Google Maps API key as much as possible. I only use it from home and have a static IP, so I tied my key to my home IP.

The script (see below and on my GitHub page) will take the Geofency data in CSV format and use Google Maps API to get better location details. Below is a sample output.

Geofency data processed by the script
name,latitude,longitude
"2022-07-04 10:46:19 - 16211 McConnell Ct, Peyton, CO 80831, USA",38.9912,-104.5299
"2022-07-04 11:10:17 - 5808 Barnes Rd, Colorado Springs, CO 80922, USA",38.8944,-104.7177
"2022-07-04 11:26:23 - 5617 Barnes Rd, Colorado Springs, CO 80917, USA",38.8931,-104.7228
"2022-07-04 15:02:58 - 4093-4303 US-50, Salida, CO 81201, USA",38.5076,-105.9607
"2022-07-04 15:22:24 - 1046 E Rainbow Blvd, Salida, CO 81201, USA",38.5245,-105.99
"2022-07-04 15:49:35 - 7010 US Hwy 285, Poncha Springs, CO 81242, USA",38.5213,-106.0806
"2022-07-04 16:58:23 - Forest Rd 202, Salida, CO 81201, USA",38.4262,-106.1447
"2022-07-04 17:32:49 - Forest Rd 202A, Salida, CO 81201, USA",38.4281,-106.1434

Now you can take this output to the GPS Visualizer site and convert it to GPX or KML format. Make sure your data has a header and “comma” is selected as the field separator (see screenshot below).

GPS Visualizer GPX generator

blank

The resulting GPX file can be used to generate a map in various mapping applications, including Google Maps and GPS Visualizer itself. And the fruit of my labor looked something like this:

blank

The script
#!/bin/bash
# Use the output on https://www.gpsvisualizer.com/convert_input?convert_output=gpx
# to generate GPX file that can be loaded as a layer into a Google Map
infile=""
[[ ! -f "${infile}" ]] && exit 1
/bin/cp -pf "${infile}" "${infile}_"
infile="${infile}_"
LANG=C sed -i 's/[\d128-\d255]//g' "${infile}"
awk -F'"' -v OFS='' '{ for (i=2; i<=NF; i+=2) gsub(",", "", $i) } 1' "${infile}" | sponge "${infile}"

export GOOGLE_MAPS_API_KEY="Get your Google Maps API key"
apiurl="https://maps.googleapis.com/maps/api/geocode/json"
${IFS+"false"} && unset oldifs || oldifs="$IFS"
IFS=,
tail -n +2 "${infile}" | while read line
do
  read -r v_start v_end v_place v_lat v_lon v_num v_ent_d v_ent_t v_exit_d v_exit_t v_hours v_hhmmss v_notes v_type v_uuid <<<"${line}"
  v_ent="$(date -d"${v_ent_d} ${v_ent_t}" +'%Y-%m-%d %H:%M:%S')"
  v_exit="$(date -d"${v_exit_d} ${v_exit_t}" +'%Y-%m-%d %H:%M:%S')"
  v_addr="$(curl -s "${apiurl}?latlng=${v_lat},${v_lon}&key=${GOOGLE_MAPS_API_KEY}" | jq -r '.results[].formatted_address' | \
  awk 'length==len {line=line ORS $0}; NR==1 || length>len {len=length; line=$0}; END {print line}' | head -1 | sed -r 's/( )?@( )?/ /g')"
  echo "\"${v_ent} - ${v_addr}\",${v_lat},${v_lon}"
done | (echo "name,latitude,longitude" && cat) | column -s',' -t
${oldifs+"false"} && unset IFS || IFS="$oldifs"
/bin/rm -f "${infile}"