Page 1 of 1

How to convert a large database with distance in mi to km?

Posted: 02 Jul 2013, 02:20
by KU3V
How can I convert all the distance data listed in miles to km?
Would I use a SQL query to convert it? What does everyone recommend?
73
KU3V 8-)

Re: How to convert a large database with distance in mi to k

Posted: 02 Jul 2013, 10:57
by IW3HMH
ADIF protocol stores data in KM. Log4OM provides a feature to show Miles instead of KM making a runtime conversion of the displayed data.

NOW, if you have data stored in MILES into the database you may want to convert them to KM (very strange but could happens...)

if you're able to work with SQL log4om provides a direct SQL input command to update your database directly:

Code: Select all

update log set distance = distance * <conversion factor>
This is useful if you're sure all distances are in Miles and you want to change them to KM.

The command is in the "QSO ARCHIVE" -> "FIELD UPDATE" in the box "Execute custom update query".
It works on the WHOLE database without regard of previous filters.

Another way:

If you want to make a full update of all SELECTED RECORDS (in the QSO Archive, before pressing "Field Update" button) you can use the massive update function [FIELD UPDATE in QSO Archive] (the same where you can type sql query directly in) and set the flag on "update QSO distance/bearing" then EXECUTE CHECKS button.

*MAKE A BACKUP of your data, as usually, before massive updates*

Here the code that will be executed (if you're interested in what program does with your data)

Code: Select all

                    try
                    {
                        string myGrid = qso.MyGridsquare;
                        string targetGrid = qso.Gridsquare;

                        if (string.IsNullOrEmpty(myGrid))
                        {
                            myGrid = Storage.TheUserConfiguration.My_gridsquare;
                        }
                        if (string.IsNullOrEmpty(targetGrid))
                        {
                            Country tempCountry = Storage.TheCountries.GetByDxcc(qso.Dxcc);
                            targetGrid = MaidenheadLocator.ObtainLocatorFromCountry(tempCountry);
                        }

                        if (string.IsNullOrEmpty(myGrid) == false && string.IsNullOrEmpty(targetGrid) == false)
                        {
                            qso.Distance = (int)MaidenheadLocator.Distance(myGrid, targetGrid);
                            qso.AntAz = (int)MaidenheadLocator.Azimuth(myGrid, targetGrid);
                            qso.Action = QsoAction.Update;
                            qso.Dirty = true;
                        }
                    }
                    catch
                    {
                    }

Re: How to convert a large database with distance in mi to k

Posted: 02 Jul 2013, 14:28
by G4POP
KU3V wrote:How can I convert all the distance data listed in miles to km?
Would I use a SQL query to convert it? What does everyone recommend?
73
KU3V 8-)
Actually its easy

1. In the QSO archive manager highlight the QSO's which are in miles
2. In the field to update screen select "Update QSO distance and bearing"
3. Click on 'Execute checks'
4. Click OK
5. Close the update window

Job done

Re: How to convert a large database with distance in mi to k

Posted: 02 Jul 2013, 16:19
by IW3HMH
pfff Terry... it's too easy! :mrgreen:

Re: How to convert a large database with distance in mi to k

Posted: 02 Jul 2013, 16:56
by G4POP
IW3HMH wrote:pfff Terry... it's too easy! :mrgreen:

Child's play :D

Re: How to convert a large database with distance in mi to k

Posted: 02 Jul 2013, 22:51
by KU3V
Thanks! It worked. You are all helping to reduce my ignorance. Great program. :D
73
KU3V
Bill