Distance, Time and Speed

Most people are familiar with the relationship of distance, time and speed. When you are navigating a boat, you might have to use the formulas to figure out where you are, or you might use them for planning purposes. It’s pretty easy to do with a calculator, or paper and pencil, or just in your head.

The formulas get more complicated when you have to convert between different units, say nautical miles and statute miles. It’s not difficult to do, but there’s always a chance you will make a mistake, especially when you’re doing other things, like driving a boat. I decided to create a special calculator that does all of these things. I call it the DTS calculator.

Background

It started one day, while we were traveling the ICW (Intra-Coastal Waterway) in Questeria. Questeria, like most sailboats is not going to make any speed records, so I have a lot of time to think about things between anchorages, marinas and bridge openings.

We wanted to find an anchorage that we could get to before it got dark in 3 hours and 20 minutes. Our speed, according to our GPS, was 5.4 knots. The distance we can go, in that time, at our current speed is determined by multiplying speed by time (in hours). 20 minutes is 0.333 hours (20 ÷ 60 = 0.333), so my calculation looks like…

5.4 * 3.333 = 17.9982

Since the unit of measurement for speed is knots (nautical miles per hour), the distance is in nautical miles. I’ll round my answer to 18 nautical miles.

Our GPS is set to knots and nautical miles because that is what we learned in piloting and navigation classes.

Knots vs. Miles per Hour

Many sailors prefer knots to miles per hour. Knots is basically nautical miles per hour. One nautical mile is 1.15078 statute miles. (I refer to miles as a statute miles to avoid confusion between statute and nautical miles.) Sailors prefer nautical miles because one nautical mile equals one minute, or 60 degrees, of latitude on a nautical chart.

The term “knots” originates from 17th century sailors, who measured their speed by counting the number of knots in a line that unspooled from a reel of a device called a chip log. (see en.wikipedia.org/wiki/Knot_(unit)). Knots and nautical miles are also preferred by airplane pilots.

Cruising on the ICW

The ICW, or Intra-Coastal Waterway, uses statute miles. Sailors can either change settings on their GPS or convert—we choose to convert. It’s not too difficult. You either multiply or divide by 1.15, depending on which way you are converting. This is another opportunity for making a mistake.

Another thing that makes the ICW different from offshore sailing is that the shortest distance between two points on the ICW is not usually a straight line—the ICW is very curvy. You measure distance on the ICW using mile markers. (Sometimes there are no physical mile markers, but the ICW charts use them anyway.) Guess what? The mile markers are in statute miles.

So, if I want to measure distances on the ICW, I have to use statute miles. But my GPS is set to nautical miles. This means I have to convert nautical miles to statute miles by multiplying by 1.15.

18 * 1.15 = 20.7 

So, while I’m able to this with a simple calculator, I tend to make mistakes and forget formulas and constants, so I created a calculator to help me deal with all of this.

Other Factors

I decided that my calculator had to work on my phone, even when I have no cellular data or Wi-Fi. It also should remember what I entered into it last, so I only have to enter things that have changed.

My thinking was that if I enter one piece of of information, say nautical miles, it will convert that to equivalent units of measurement, like statute miles. If I enter two pieces of information, like nautical miles and knots, it will calculate a third value, like time, and convert everything to other equivalent units of measurement, like statute miles and MPH.

One problem with this is that there are three things; distance, time and speed, and if you change one thing, how to decide which thing stays the same and which thing is recalculated. My solution is to blank-out what you want to be recalculated.

As an American sailor, I usually deal only with nautical and statute miles, knots and MPH. But I realize that in other countries people deal with kilometers and kilometers per hour (KPH). I decided to add that to the calculator. It makes it a little more complicated, but hopefully it adds some value.

Location-Distance-Bearing Calculator

Another calculator on my website, www.questeria.info, is the Location Distance Bearing (LDB) calculator. This calculator also coverts between units and calculates a value from two other values. The common value between the two calculators is distance. The units of measurement for distance in the LDB calculator are nautical miles and feet. You can send distance values between the two calculators.

For example, if you want to convert kilometers to feet you can multiply by 3281, or use the Send to Location Distance Bearing Calculator function.

Another use for this function is to calculate a new location using the distance value from DTS with a bearing (direction) and another location.

History of the DTS Calculator

DTS was the first calculator that I created. The first version was created in early 2014 and was written in the PERL programming language. It ran on the server side and only worked when online. It was not designed to run from a phone’s home screen as a mobile web application and there was no About or Send to Loc Dist Brg Calc buttons. There was a Help button, but it was very basic compared to what is available today.

The second major version of the DTS calculator came after I created my four other calculators; LDB, AW, TW and WS. (See post Calculators on questeria.info.) This version was written in the JavaScript programming language, could run when offline and was designed to be able to be added to your phone’s home screen as a mobile web application. The Help button in this this version was also significantly improved.

Application Cache

The mechanism used for being able to run offline is called Manifest-Based Application Cache. The application files (html, css, js, etc.) are saved on the users’ device. The manifest file that specifies what is cached is named dts.appcache, and looks as follows:

CACHE MANIFEST
# 2021-07-25 V3.2.2

index.html
help.html
favicon.ico
dts.png
dts_72x72.png
dts_114x114.png
css/questeria.css
css/ipad.css
css/tablet.css
css/phone.css
js/init.js
js/dts.js
js/screen.js

This works well most of the time. But sometimes I want to make a change to the calculator. When something changes, I want to reload the changes into my application cache. To do this I must change the dts.appcache file.

The second line of the file starts with “#” and is ignored by the browser. When making any changes, I change the date and version in this line. I added the About button to the calculator so I know if I am running the right version.

Cookies

Early versions of the DTS calculator didn’t remember the values from previous invocations. The later versions accomplish this using cookies.

Sometimes cookies get a bad rap, but they are simply pieces data stored in your device’s browser. (See en.wikipedia.org/wiki/HTTP_cookie.) The DTS calculator uses 11 cookies, one for each field on the screen and two for the send to LDB function.

When you open the calculator, it reads all the cookies and fills in the nine fields with the values. When you press the Submit button or press enter, the calculator looks to see what fields have changed. Once the conversions and calculations are done, the cookies are updated with the new values.

When you do a Send to Location Distance Bearing Calculator, the cookie for the nautical miles value in the LDB calculator is updated and another cookie named send is set to true. Then the LDB application is started. It reads the value saved by the DTS calculator.

Mobile Web Application Capable

The DTS calculator is a standalone website. All you need to run it is a standard web browser, such as Chrome or Safari. One difference between DTS and a normal website is that the DTS calculator is Mobile Web Application Capable. In other words, it looks more like an app than a webpage when it’s running on a phone or tablet.

Web browsers show things like a URL bar, refresh button, back button, settings, etc. These things are not shown when running as a mobile web application.

Another thing that makes it more like an application is having an icon. The icon for the DTS calculator is a tan box with blue letters “DTS”. When you add the webpage to your phone’s home screen, you will see the DTS icon. I have all my calculators from www.questeria.info in a folder named Calculators, and I can easily see what is what from the icons.

Kilometers and KPH

I’ve been thinking of adding Kilometers and KPH for a while. I finally did it. It made the screen more complicated, but hopefully it will make it more useful.

An added benefit of this exercise was that I found, and fixed quite a few problems with the previous version.

Service Worker

A web developer’s work is never finished. What I mean by this is that things are always changing, and things that used to work, may stop working, or work incorrectly. This is the case with the manifest-based application cache that all my calculators use to work offline.

The function of the manifest file was replaced with something called a Service Worker. A service worker is basically a program running in the background. Service workers can perform many functions, but one is the ability to cache the application like manifest-based application cache.

I have known for a while that manifest-based application cache was deprecated and would be going away. But my last change to the DTS calculator showed error messages.

I changed the DTS calculator to use a service worker. It no longer shows any errors, and seems to work as intended.

There are some new quirks with this version. Service workers will not run if the unsecure URL is used (http:// versus https://). Most browsers will warn you if you are using the unsecure version of the website. Also, the service worker doesn’t always start right away until you refresh the page.

The About button tells you what version of the service worker you have. If you don’t have a service worker, it gives you a shorter version number—4.1 instead of 4.1.6, for example.

It took me awhile to get everything working, but now that I have DTS using a service worker, the other calculators should be easy.

Ad Free

I provide the DTS calculator on my website for anyone—free of charge. I used to try and recoup some of my expenses for the website by having ads by Google. I decided to remove all the ads. They were not generating much revenue for me, and they were slowing down pages.

In their place, I put a link to PayPal so that people donate money. Refer to post No More Ads for more information.

If you find the DTS calculator useful, please consider a small donation.

Installing DTS on an iPhone Home Screen

You can run the DTS calculator on anything with a web browser, but it is really meant to be run on a mobile phone. I will describe how to install it on an iPhone because that is what I have. Installing it on an other smart phones or tablets is not much different.

The first thing to do is open the website https://questeria.info/dts/ on your phone. Make sure you are using the secure version, with “https”. The non-secure version (http) may seem to work, but the service worker caching will not work.

When you go to that URL on an iPhone, you will see a screen like this.

The action of Peripheral neuropathy involves the nerves that control sildenafil generic canada erection, which is commonly seen in men with diabetes. In spite of being silent, you should communicate with each other by choosing a private viagra online buy place and enough time. There are a lot of medicines in the market for repairing cartilages generic cialis canada http://robertrobb.com/throwing-more-money-at-a-shutdown-economy-wont-accomplish-much/ and reducing swellings. Mohammad Shahzad, the attacking wicket-keeper viagra ordination batsman and Mohammad Nabi have been added a great value in its popularity.

To add it to your home screen, press the “share” button. That’s the icon of the box with an arrow coming out of the top at the bottom of the screen. You’ll get a screen with lots of option for sharing. Scroll down until you see “Add to Home Screen”.

Pressing this will take you to the following screen.

Press “Add” in the upper right corner. The DTS icon will be added somewhere on your phone’s Home Screen.

To move it to a folder or another place on your Home Screen, press the icon until all the icons are jiggling and have a “-” in the upper-left corner.

Now you can drag the icon anywhere you want. You can drag it into a folder, and then to the place in the folder that you want. To create a folder, drag it onto another icon.

This is what my “Calculators” folder looks like.

Examples of Using DTS Calculator

I made up an example cruise to illustrate the DTS calculator. It is a southbound cruise on the Atlantic ICW, going through parts of North Carolina in a sailboat. The cruise isn’t real, but the places are real. All of these scenarios assume an average speed of 5.5 knots. The start date is October 14, 2021.

When cruising in this manner, we usually start at sunrise and end before sunset. Sunrise is at 07:11 and sunset is at 18:34 local time. I like to use 24-hour format when I’m cruising because it’s easier to add and subtract times without worrying about AM and PM.

Mile Hammock Bay Anchorage

We want to anchor in Mile Hammock Bay anchorage, at statute mile 244.5. There is one draw bridge between us and the anchorage that must be opened. It is the Onslow Beach Bridge at statute mile 240.7. This bridge opens on the hour and half-hour.

At 13:40 (1:40PM), we go under the Emerald Isle Bridge. We know that this bridge is at statute mile 226, so we have 14.7 statute miles to go before we get to the Onslow Beach Bridge. I plug 14.7 into Statute Miles of my DTS calculator and 5.5 into Knots.

The calculated time is 2 hours, 19 minutes, and 21 seconds.

I add this to the current time, and see that we will get to the bridge at 15:59:21. This is pushing it pretty close, because the bridge won’t open for us if we are not there on the hour. Then we will have to wait another 30 minutes for the next opening.

I’ll see what happens if I increase our speed to 6 knots. I put 6 into the Knots field and blank-out the HH field to recalculate my time.

This will get us to the bridge at in 2 hours, 7 minutes, and 42 seconds, or 15:47:42.

We get to the bridge in time, and wait for the 16:00 opening. The anchorage is another 3.8 statute miles. We’ll slow back down to 5.5 knots and plug in the 3.8 Statute Miles. It looks like we will get to the anchorage in about 36 minutes.

We anchor with plenty of time to plan out the next day.

Southport Marina

We want to go to the Southport Marina tomorrow and I want to estimate what time we will get there. The location of the marina is 33°55.013’N, 078°01.718’W. We are currently at 34°33.098’N, 077°19.505’W, which comes to about 51.7 nautical miles, or about 59.5 statute miles. I’ve already mentioned that you cannot use a straight lines on the ICW, so I must subtract the mile markers.

The marina is at statute mile 309, and we are at statute mile 244.5, so we have 64.5 statute miles to go. The curves of the ICW adds five statute miles, or about 47 minutes, to our journey.

Traveling 64.5 statute miles at 5.5 knots should take us over 10 hours and 11 minutes, getting us there at 17:22. But there are other factors which will affect our timing. There are two bridges which must be opened. The first bridge is the Figure Eight Bridge at statute mile 278.1. This bridge opens on demand, so it won’t cause much of a delay. The next bridge is the Wrightsville Beach Bridge. It only opens on the hour. This bridge is at statute mile 283.1, and we are at statue mile 244.5, so I will see how long it takes to go 38.6 statute miles at 5.5 knots.

It will take 6 hours, 5 minutes and 55 seconds. If we leave at 07:11, we will get there at 13:17. This means a 47 minute wait unless there are other delays along the way. We will plan on continuing at 14:00 after the bridge opens.

Another factor to consider are the currents after the bridge. If I look at my GPS, there six current prediction stations between Wrightsville Beach and Southport. They are named; Myrtle Sound, Snows Cut, Upper Midnight Channel, Reaves Point, Horseshoe Shoal and Southport.

My GPS doesn’t show statute miles for the current prediction stations, but I can measure the distance from the closest statute mile marker on my chart. The first station, Myrtle Sound, is before mile marker 195. So I’ll measure the distance and subtract.

I measure it to be about 1.07 nautical miles, so I will convert that to statute miles.

That comes to approximately 1.2 statute miles. I subtract that from 195 and note the Myrtle Sound statute mile marker as 193.8. This is 10.7 statue miles from the Wrightsville Beach bridge. I’ll repeat this for the other five current prediction stations.

The next step is to determine what time we will be at each station to see how the ever changing currents will effect our speed. I put 10.7, the distance between Wrightsville Beach bridge and Myrtle Sound into Statute Miles, 5.5 into Knots and blank-out HH to calculate time.

The result is 1 hour, 41 minutes and 26 seconds. I add this to 14:00, the time we leave Wrightsville Beach bridge, and see we will be there at about 15:42. Now I can open the Myrtle Sound current prediction station and see what the current will be for that date and time.

It shows to be 0.87 knots at 15:42 on October 15, 2021. The direction of the current is in same direction that we will be traveling, so we will add it to our default speed of 5.5 knots to be 6.37 knots.

The next current prediction station is Snows Cut. It’s 2.0 statute miles from Myrtle Sound. To calculate the time to get there, I enter 2.0 in the Statute Miles field and 6.37 into the Knots field.

The time calculates as 16 minutes and 22 seconds. (Note: the DTS calculator rounds Knots to 6.4 after calculating time.) I see that we will be at Snows Cut at about 15:59. I put this information into a table, as shown.

PlaceMMSM@SpeedTimeCurr.
Myrtle Sound293.810.7@ 5.5kt15:42+0.87kt
Snows Cut295.82.0@ 6.37kt15:59
Upper Mid. Ch.299.23.4@
Reaves Point300.21.0@
Horseshoe Sh.303.02.8@
Southport308.05.0@
Distance, Speed and Time Adjusted for Current

I’ll go through the five remaining stations in a similar manner and fill out this table.

When completed, the table looks like this.

PlaceMMSM@SpeedTimeCurr.
Myrtle Sound293.810.7@ 5.5kt15:42+0.87kt
Snows Cut295.82.0@ 6.37kt15:59+0.57kt
Upper Mid. Ch.299.23.4@ 6.07kt16:29-1.32kt
Reaves Point300.21.0@ 4.18kt16:42-1.05kt
Horseshoe Sh.303.02.8@ 4.45kt17:15-1.06kt
Southport308.05.0@ 4.44kt18:14-0.31kt
Distance, Speed and Time Adjusted for Current

The Southport Marina is at statute mile 309 so the final calculation is 1 statute mile at a speed of 5.19 knots.

The result is 10 minutes and 3 seconds, so we should be at the marina at about 18:24. Bridges and currents add over an hour to our trip.

In Conclusion

The example is made-up, but it’s based on real life. One time, I missed the Wrightsville Beach Bridge opening because, I was blindly following another vessel who said on the radio that he slowed-down so he wouldn’t have to wait long. Another time, we were speeding along through Myrtle Sound on Questeria, and decided to pass the Carolina Beach anchorage and go to Southport, only to slow way down once we got into the Cape Fear river.

We’ve never actually used to the current prediction information to plan our time, but it should give us a rough idea of the currents. By the way, I used the Garmin ActiveCaptain app on my phone for two of the screenshots, but my GPS and other route-planning tools have the same capability. For more information see my post Planning Multi-Day Cruises—ActiveCaptain.

I couldn’t think of any realistic examples to show the usefulness of Kilometers and KPH while cruising in North Carolina, but I’m sure that somewhere it will be useful.

I hope you can see the value of this calculator when cruising and load it on our phone or tablet.