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

General discussions about Log4OM features
Locked
KU3V
Novice Class
Posts: 7
Joined: 27 Jun 2013, 00:41

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

Post 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-)
User avatar
IW3HMH
Site Admin
Posts: 2925
Joined: 21 Jan 2013, 14:20
Location: Quarto d'Altino - Venezia (ITA)
Contact:

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

Post 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
                    {
                    }
Daniele Pistollato - IW3HMH
User avatar
G4POP
Log4OM Alpha Team
Posts: 10752
Joined: 21 Jan 2013, 14:55
Location: Burnham on Crouch, Essex UK

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

Post 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
73 Terry G4POP
User avatar
IW3HMH
Site Admin
Posts: 2925
Joined: 21 Jan 2013, 14:20
Location: Quarto d'Altino - Venezia (ITA)
Contact:

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

Post by IW3HMH »

pfff Terry... it's too easy! :mrgreen:
Daniele Pistollato - IW3HMH
User avatar
G4POP
Log4OM Alpha Team
Posts: 10752
Joined: 21 Jan 2013, 14:55
Location: Burnham on Crouch, Essex UK

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

Post by G4POP »

IW3HMH wrote:pfff Terry... it's too easy! :mrgreen:

Child's play :D
73 Terry G4POP
KU3V
Novice Class
Posts: 7
Joined: 27 Jun 2013, 00:41

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

Post by KU3V »

Thanks! It worked. You are all helping to reduce my ignorance. Great program. :D
73
KU3V
Bill
Locked