Sorry, but why do you think that Morocco is 509km from Gibraltar?! I live in Gibraltar and can see Morocco easily - and I'm pretty short-sighted. It's about 20km across the straits. Please correct.
It’s pretty dumb. The thing I was looking at said that Gibraltar was like 200 miles away from Spain, which doesn’t make any sense. I’m pretty sure it uses the distance to the center of the country or the distance to the capital to the country. When I get back to my computer I’ll manually look up the distance between all of the countries.