0

I have a .dat file that I know contains binary data of GPS coordinates. My end goal is to do a distance comparison of the locations in there to a set of reference coordinates.

I'm new to accessing .dat files in C but from what I've learned is that you can't just open it and read it to figure out the data structure but you should be able to decipher it if you have some idea of the data that's stored.

I do have some code to start opening and reading through the file but not much more.

What I'm not sure is how to go about it as I need to know what method and what functions are really at play here. My guess would be to set up some kind of basic structure, latitude and longitude. Then I would read a set amount of bytes and populate my latitudes and longitudes until I've read the whole file.

The above sounds easy in principle but I have no idea how much data to read for each entry as I don't know the precision. And how do I turn that binary data into an actual coordinate values if I don't know the the coordinate precision.

Am I thinking in the right direction? If so what would I need to understand next to solve this? If not how should I actually be looking at it?

  • Firstly, do you actually know what the format of the data is or are you saying you are trying to reverse engineer it? Note that "dat" does not denote a standard file format and it can contain anything. It's just a file name that anyone/anything can use but usually denote some binary data. – kaylum Jul 26 '22 at 21:25
  • [HxD](https://mh-nexus.de/en/hxd/) is a freeware file-viewer that can show you what parts of the file look like as IEEE-double, IEEE-single, Signed and Unsigned Ints of various sizes, etc. It can be very handy to help browse through a file and guess what the encoding scheme might be. – abelenky Jul 26 '22 at 21:29
  • `dat` is just a random extension, which is signifying "data" or something. It tells nothing about the nature of the data format in it. You need to know the exact format to be able to decode it. – Eugene Sh. Jul 26 '22 at 21:30
  • ghex or ghex2 can be used on Linux/Gnome – ulix Jul 26 '22 at 21:47
  • I have no idea what the format of the data is. So yes you could say I'm trying to reverse engineer it. If I now for sure that it is gps coordinates in the form of a set of latitudes and longitudes there should be a way to figure it out right? I've downloaded HxD and it is awesome. I especially like the data inspector with it's several configurations. Now I just need to figure out how to decipher the data but I think for the most part my question is answered – PandaBanda Jul 29 '22 at 07:35

0 Answers0