Question to new geolocation feature in ExifTool 12.78

Started by herb, March 06, 2024, 01:45:02 PM

Previous topic - Next topic

herb

Hello,

I have a point lat/lon that is inside a city M.
The geolocation feature gives city P as nearest.

I guess this is because the distance to CENTER of city P is less than distance to CENTER of city M.
What must be done to be sure that gelocation gives city M, because my point is inside this city.

This question is only to get a better or correct understanding how the new feature is working.

Thanks for your help in advance.
Best regards
herb

FrankB

Hello Herb,

I think Phil should answer it, but I'm also interested. Can you share the lat/lon values? I would like to verify the working of GUI.

Frank

Phil Harvey

Hi Herb,

Try playing with the API GeolocMinPop setting to set the minimum population for a city so it doesn't pick very small towns.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

FrankB

Quote from: Phil Harvey on March 06, 2024, 03:53:10 PMTry playing with the API GeolocMinPop setting to set the minimum population for a city so it doesn't pick very small towns.

Phil,

If you think the accuracy of the lat/lon values is part of the problem consider this option:

In the DAT file you store lat/lon values as 2 byte integers. To save space, because saving them as double (aka float, real) would require at least 8 bytes.
There is a method to save them as 4 byte integers. It would mean 4 extra bytes for every city, but with a far better accuracy.
I've seen this method used in Garmin navigation software, so that must be accurate enough.

To convert to a 4 byte integer multiple by 2^32 and divide by 360, and then round.
To convert from a 4 byte integer multiply by 360 and divide by 2^32

Pseudo code in Pascal:

// 4294967296 = 2^32   
// double is an 8 byte real
// longint is a 4 byte integer                                                     
                                                                             
function Coord2Float(ACoord: LongInt): double;                               
begin                                                                         
  try                                                                         
    result := ACoord * 360 / 4294967296;                                     
  except                                                                     
    result := 0;                                                             
  end;                                                                       
end;                                                                         
                                                                             
function Float2Coord(ACoord: Double): LongInt;                               
var HCoord: Double;                                                           
begin                                                                         
  try                                                                         
    HCoord := ACoord * 4294967296 / 360;                                     
    result := round(HCoord);                                                 
  except                                                                     
    result := 0;                                                             
  end;                                                                       
end;

Phil Harvey

#4
I could certainly increase the precision as you suggest.   I would just go to using float values if I wanted to use 4 bytes. Edit: No. 4-byte integers as you suggest would be necessary if I wanted to continue using the fast string comparisons when searching in the database.  That would increase the size of the database by 600 kB, but it wouldn't solve the problem.

My technique of using 2 bytes introduces an error of only about 300 m.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

OK.  I'm playing with increasing the precision of each coordinate by 4 bits.  This increases the database size from 332 kB to 347 kB, which is acceptable, and decreases the error to about 20 m.  Processing will take a bit of a hit, but not much, due to the need for some binary gymnastics to unpack the 2 nibbles.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

FrankB

I think that's a good idea. I'm not sure if it's the only problem though. But it can help to verify the results.

Phil Harvey

I think part of the problem was that I was including PPLX entries ("section of a populated place").  I've dropped these now and am including Subregion (admin2) information as well as increasing the GPX coordinate precision.  Hopefully all this will help.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

herb

Hello Phil, hello FrankB,

thanks for all the investigations and tests done for all enhancements of this new feature.

When I opened this thread I expected a short answer about what is inside the geo-database.
Now I have seen that you re-invented the wheel.
Thanks again.

Best regards
herb

Phil Harvey

Hi Herb,

The next release will include the feature codes to allow you to fine-tune the results yourself.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).