Twenty-three years ago, during my daily trips to the university campus, I had the exact same idea. However, I became distracted by calculating the position of the sun and delved into astronomical algorithms, which led me to never complete it. Kudos to you, that's really impressive!
The hard part was obtaining information such as solar azimuth, altitude, declination, hour angle, etc without using external APIs. Spent around 5 days implementing backend.
Way too late now, but to help others this fancy Excel sheet provided by NOAA is awesome! It implements all of these equations in Excel and is pretty easily portable to your programming language of choice. https://gml.noaa.gov/grad/solcalc/calcdetails.html
P.S. Using this has made it clear to me how bad most sunrise/sunset calculators actually are.
> P.S. Using this has made it clear to me how bad most sunrise/sunset calculators actually are.
That may just be a function of how you define "sunrise" and "sunset". It is never as simple as "when the sun hits the horizon", but something about some number of arc minutes from something something.
Dependent on the refractive index, which depends on air density and temperature and humidity too; and we have to integrate over the region between the horizon and the upper atmosphere (diagonally, of course)…
To be clear I was complaining that basically everyone calculates “sunrise” and “sunset” differently. If you check half a dozen different “sunset” calculators you will get a surprisingly wide variation in the times they provide. At least where I live the error seems to average 5-10 minutes.
I'm not sure what you mean by external APIs but is there a reason you're not using SunCalc[1] on the client to process the route after it's returned from the routing engine?
I don't always manage to adhere to my own advise here. But talking to "customers" really solves this.
Half these customers can't be bothered by the edge cases that I've been poring over for nights. The other half puts forward edge cases that I've never been aware of. Some of which are critical to their work-flow. Many are implemented in mere minutes. "Wow. That saves us 30 minutes typing over prices, every day!".
As an engineer I love to find solutions. But as an entrepeneur I really must understand the problem and scope. that 0.1% edge cases is hardly ever part of the success.
Thanks for posting this, honestly the 0.1% scare me sometimes on technical project. I think you're right, just gotta talk to my customers directly if they even care about it.
You could probably make it in a few minutes - the direction of the sun is, to a first approximation, 15 degrees times the number of hours it is after midnight. This leads to a trick for using an analog watch as a compass:
> The equation of time describes the discrepancy between two kinds of solar time. The word equation is used in the medieval sense of "reconciliation of a difference". The two times that differ are the apparent solar time, which directly tracks the diurnal motion of the Sun, and mean solar time, which tracks a theoretical mean Sun with uniform motion along the celestial equator. Apparent solar time can be obtained by measurement of the current position (hour angle) of the Sun, as indicated (with limited accuracy) by a sundial. Mean solar time, for the same place, would be the time indicated by a steady clock set so that over the year its differences from apparent solar time would have a mean of zero.
The equation of time would be in there! But the largest that gets is about 16 minutes, corresponding to a 4-degree error in position, and there are much bigger sources of error. But thanks for the link to the Clock of the Long Now!
You should team up with the people who wrote zonopjebakkes/seatsinthesun, which is used for finding bars and cafes that have terraces that are still in the sun, mostly useful in late summer afternoons as the evenings are getting shorter and cooler.
Thanks for this link - I'm amazed to see it even has an approximation for my city based on buildings (Detroit.)
This is really useful tool for photography. On Android, I also use Sun Surveyor to determine when the sun is hitting the right side of a building, but it doesn't show the shadows cast by other buildings!
I recently took a bus over the Andes and was congratulating myself on choosing a seat on the shady side. Then I realized that in the southern hemisphere the sun is in the north and I had outsmarted myself.
> Then I realized that in the southern hemisphere the sun is in the north
That's not exactly true.
South of the tropic of capricorn, the sun is in the north at noon.
Between the equator and the tropic of capricorn the sun could be slightly towards the north or south or directly overhead at noon depending on the season.
As for sunrise and sunset the sun could be just about anywhere if you go south enough and the season is right.
At the south pole in summer, the sun just runs 360 degrees around, floating slightly above the horizon, and daylight is 24 hours long. If you are standing 1km from the south pole, you will see the sun in the south direction at midnight and in the north direction at noon.
And if you go just further from the south pole, e.g. to Patagonia in summer (i.e. now) the sun rises and sets close to the south and goes around to the north at mid-day. Daylight is close to 20 hours long. It's similar to the south pole situation except when the sun gets close to exact south it dips below the horizon for a few hours and you have a short-lived few hours of darkness. But you do see the sun in the southeast at sunrise and southwest at sunset.
Yep, my bedroom has windows to the south and east, which means here in New Zealand I should not expect any afternoon & evening sun that room. However, currently in summer when the sun is close to setting I get a few minutes of evening sun through the southern window, due to sun setting slightly southwest.
South in French is sud, while noon is indeed midi. However, the two words are the same in Latin (meridies, lit. midday, as in p.m. = post meridiem, etc.), so probably in some of the other Romance languages they do match?
Yes. There are is mnemonic phrase in german to tell where the sun is in morning/noon/evening which contains "sun is never seen in the north" - which just not work on the southern hemisphere.
Interesting because the sun rises and sets from the north (NE, NW) during the summer in the northern hemisphere. The effect is more pronounced the farther north of the equator you are and Germany is quite far north.
More and more, I really appreciate great efforts that make a small but meaningful improvement in some under-noticed aspect of living. It seems zen-like.
Shady side is comfy but remember that 120 min of daily indirect or direct exposure to UVB can protect your eyesight health.
Just 120 min a day under a tree during childhood.
Dolgin, Elie. 2015. The myopia boom. Nature 519: 276.
Williams, Katie M., & al. 2017. Association Between Myopia, Ultraviolet B Radiation Exposure, Serum Vitamin D Concentrations, and Genetic Polymorphisms in Vitamin D Metabolic Pathways in a Multicountry European Study. JAMA Ophthalmology 135: 47-53. doi: 10.1001/jamaophthalmol.2016.4752. https://doi.org/10.1001/jamaophthalmol.2016.4752
We need a little UVB everyday to maintain melanin (skin pigment) and skin thickness. If you work inside M-F and then go hard on the weekends outdoors, you will receive disproportionate damage from sunlight.
Works. Beautiful. Also works internationally. Good job!
It would be splendid if you used 24 hour format per default instead of AM/PM or at least let me choose. You correctly figured out I am at UTC+01:00, but we don't use AM/PM here.
I'm not perfectly happy with the colors in the final map. You use blue to represent right, yellowish for left and dark gray for "no sun". Your suggestion on top for preferred seating uses red.
To me the preferred seating color should correspond with the left/right colors.
> A popular folk etymology holds that the term is an acronym for "port out, starboard home",[4] describing the cooler, north-facing cabins taken by the most aristocratic or rich passengers travelling from Britain to India and back. However, there is no evidence for this claim
Would be great to offer this as an option, even if we would have to fill in our own API key. The train tracks in my country differ quite somewhat from the roads when I try it out. Also. busses take defined routes and not the shortest path. Google Maps provides all these routes.
Would you get significantly different results? I'd expect this would work OK even if you assumed travel in a completely straight line - unless you're tacking like a sailboat, you're going to spend most of your time travelling close to the overall direction of travel.
At least i do. Tried my regular commute, but it has a bridge witch is dedicated for buses and emergency cars. So would be a nice addition, but the added complexity of using something like travel api in google maps, witch would cost more.
Really liked the idea, and usually seems to work ok.
In a related vane, has there ever been a map/routing app that included weather forecasts visually on the map? Like, a storm cloud on route ahead that is based on the forecast for that position at the estimated time you'll reach it.
I feel like routing apps have completely stagnated basically since the Waze acquisition by Google.
I entirely expect your motives to be non-commercial but I reckon there will be bus or train ticket sites who would pay for this. Which would also allow more people to benefit from it. Well done on a great job
This is brilliant, one thing I would say is making the “Preferred Side” value red leads my eye to believe red = negative/not good/don't so I was searching for something else without thinking. Probably better to make the affirmative/do this/sit here colour green not red.
This is amazing! My kids get sick on train rides and I think a lot has to do with the sun strobing through the trees. I’ll try this next time to at least not be on the sunny side.
What a cool idea! Well done! One feature suggestion: it would be cool if it asked you if you prefer the shade or the sun. I’m in Canada, and during winters I love to sit on the sunny side of the bus.
This is working well! My only feedback is that I was checking a location far outside my timezone (-12 hours). This means I have to look up the timezone for that location. I would prefer to always use the "local" timezone, from the starting location.
Another use case: seating in stadiums for outdoor sports. (Whether you want to be in the sun or not will depend on the time of year.) You'd need data on how stadiums are oriented though.
I'm not sure exactly what's going on, even if you provide a US address in the middle of the country it will only ever give you directions for the European side. If you replace Heathrow with a different continent, like Africa or Asia, it correctly says it can't find a route. My best guess is that the algorithm sees there is a water crossing, but then finds the ferry from France to England and says "ah ok all good". Maybe there is a special case to handle Europe to UK that is causing the problem? If you put in JFK to Dublin it will find two ferries, France to England and England to Ireland, but still nothing on the North American side.
Edit: No nothing to do with the ferries, I think Europe just has some special status. For example, try Brazil -> Morocco vs. Brazil -> Spain.
I think you used standard bus route search with JFK and Heathrow. OpenStreetMap suggests Lisbon since the departure and destination are on different continents, providing a route in close proximity to the destination with access to the sea.
If you prefer the flight path, you can visit dev.sitinshade.com/flight [beta].
This is the kind of tool I like. Not sure what kind of edge case I've hit though. Trip from Perth to Exmouth in Western Australia, leaving 1:13pm UTC+1000, ends up suggesting the wrong side.
Preferred Seating : Left Side
1250 km / 776.41 miles :14h 40m 33s
Sun Exposure Data
Left Side: 49.62%
Right Side: 7.94%
No Sun: 42.44%
Great work! Two questions on this related to extended trips that I can't find obvious answers to, even after using: [answered] does it calculate exposure for points on trip moving, or is exposure for all points calculated for same time? (Moving south-north for two hours before noon would be exposure on right/east for first half, on left/west for second half in northern hemisphere).
Secondly, does this have any difficulty with trips that encompass certain times that often serve as "reset" markers? Such as trips that include midnight, or multiday trips?
[edit: example for nothern hemisphere clarification]
[second edit: looks like it does for first question, ref Oklahoma City to Wichita KS starting an hour before noon]
I'm trying a trip from the north of France (Paris) to the south (Lyon) in the morning while the sun rises. So the sun is mainly on the East (so left of the bus) and the app tells me to sit on the left side of the bus.
At this time of year, during daylight, the sun is mostly in the south in France. The journey is south-easterly and takes 5 hours, so the right side is sunny for most of the journey!
I tested with London to Paris — if it's easy with your routing system, you should add the Channel Tunnel as a fake road. I'm not sure why it chose a ferry so far off the shortest route.
The site could probably charge extra for better quality results.
Perhaps they could split it into a free version using open street data, and a paid version with actual transit routes and other relevant data (tunnels could be marked as 0% sun coverage if they are able to find a data source for it)
The routing takes the Portsmouth-Cherbourg ferry, which is not the way any bus would go. They take either the Channel Tunnel, or one of the shortest ferries like Dover-Calais.
I'm surprised that so many posts are people saying they want this. I've never felt a strong preference for shady seats while traveling. Why do (many) people prefer them?
Well, last year I was doing a 1hr commute on a bus in Italy with 35 degrees outside and with broken AC :) It's not fun to have the sun pointing at you for 10 minutes straight I can tell you that
It looks great! I had the same problem while traveling by train during my time at university, so I created an app for that, including features for trains, buses, and even car trips.
It seems they route along roads between bus stops, so you won't get train routes that follow the tracks. But in principle the solution should be very similar.
If the routing is done with an internal database (rather than some roads-only API) it might be straightforward to use the railway lines from Open Street Map [1]. Or even the public transport routes recorded in OSM [2].
I need this for flights, not for the sun, but I somehow always have fomo when having to choose between left and right side of the plane on the seat selection screen
It would have to predict the model numbers of the planes though: some newer ones I have been to (A350s) seem to have automagic dimming windows. Getting on flights with such windows is better even if you have to sit in the sun!
Boeings 787 also have this. There isn't even a lid to close/open the window. And in some situations you can't "undim" it. Kind of annoying when it's midnight and you want to take a look at the moon and stars.
I hate those windows, when fully dimmed they let through a lot of blue light, and blue light is bad for sleep.
On the other hand though I detest window seat passengers who insist on having the windows closed for take-off and landing. I'd like to know when to expect a thud, thanks. The electric shades are nice in that aspect because they are never fully opaque.
I don't know, it would make sense for the US FAA to require that but I don't have the authority to ask that of the window seat passenger, and most flight attendants don't care.
They're more concerned that my seat back is not pushed back by the 3mm that they move.
Is it much more complicated than to prefer the predominantly northwest side in the morning and northeast side in the afternoon (for northern hemisphere)?
Here is my strategy for boarding the bus: try to figure out how not to be toppled by a bus driver who's eager to hit the accelerator as soon as my fare is validated. As a result, I am usually collapsing into the first available seat that isn't completely soaked in urine or vomit. The Sun's position is usually the last thing on my mind at this point.
When I was a kid I used to take a bus from East to West coast of Italy in Summer. Despite my best efforts to calculate the side with minimum sun exposure, I always ended up on the sunny side. This also happened when doing the opposite of my predictions. An app like this would have helped me a lot, but it would be nice to have the possibility customize the route.
Oh man, I had this idea a long time ago when I was still commuting to work during sweltering hot summers in trams with no AC. Glad to see someone implemented it.
If you want to take it to the next level, use GIS information to account for building shadows and waiting times in stations and at traffic lights.
I never got the idea because our busses had a sort of plastic bar tied to some plastic fabric that you could pull down over the windows. Worked pretty well for blocking the sun. Ofcourse this was way before internet became popular so I guess the ancient knowledge has been lost to humanity by now. The long distance busses also had some sort of air cooling function that they sometimes started up if it was a very warm day.
Todays busses don't even have heating in the winter. If I can't bike, I'm taking the car nowadays. Can't sit in a bus when it's -20 C outdoors and -18 indoors.
> Todays busses don't even have heating in the winter
Reminder that not all busses are the same, and your experience is extremely localised to you - even different bus companies (or bus models used by a single company) in the same city can be completely different, yet alone different parts of the country, yet alone different countries.
Near me, for example, pretty much all busses have heating for the winter, and maybe half (random estimate) have AC for during hot weather while the other half just have windows/vents to open or shut.
Yes, they have heating. Does it work? Yes, seldom. It's even on the news now and then. This area is known for being very cold in winter and working heating never was a problem when I was in school. Now however it seems to be a big problem.
Whats the technology behind this? Is it spatial SQL or some other python-based spatial analysis? I suppose the map is either open layers or leaflet, but the other part is more interesting. Sorry, didn't find it on the page or here, please take excuse if already answered. Thanks
Backend: Node.js
Calculations are performed based on the azimuth of the sun and the bus, taking into account the movement of the bus and change in time.
Also try to sit towards the middle of the bus too, so that you don't get sun exposure from the front or back windows.
When I read the title, I was expecting the site to give you an optimal "seat" (13A), but I suppose for this would need to know the exact bus make and model.
I wish it would let me select some other cities the bus passes through, since as another commenter said it just uses the quickest way by car - though I guess that would not impact the seat selection too much, since the general direction of travel is still the same!
This is a great idea! I see others have mentioned ferries, however when I put my route in (Bainbridge Island to Seattle, WA) it chose roads not the ferry. Any way to force it to use my ferry route rather than the 3 hour road trip it chose?
Found a bug on the first search I ran, where the right side is preferred, despite having more sun (10.55%) vs. the left side (6.64%). Not sure how. All other searches gave more expected results.
When I travel, Before I pick a seat, I will think about the direction of the bus or plane to decide which side(left or right) seat I should select. Sometimes I like the sun while traveling, sometimes I'm not. The method is simple, it needs three factors,
1. The direction of this transportation tool way to your destination;
2. The time range;
3. The direction of the sun in the time range.
So if I create this site, I need these variables first:
1. Tell me where are you going(such as From, To). I can confirm the direction of the transportation tool on Google Maps.
2. Tell me the time, I can calculate the direction of the sun based on the time range.
After that, I can know which side seat you should choose.
I need this combined with Alltrails or some other trail map data! My 4mo old absolutely hates direct sunlight which makes finding good walks/hikes in a carrier very challenging.
There are quite a few bus routes that wind back and forth, especially in urban and mountainous areas potentially offering a lot of shade from buildings and cliff edges for parts of the route anyway.
Whether these journeys involve long enough in direct sun to matter is another question.
Yes, but I believe that the diff of sun(RIGHT_SIDE) and sun(LEFT_SIDE) is the same, no?
Like the bus cannot get to the same destination by taking a route where the sun shines on the other side more. (Ignoring some fringe theoretical routes where you do a massive detour over equator.)
edit: I was too fast with my reply to read yours properly. Sorry.
> a lot of shade from buildings and cliff edges for parts of the route
I don't believe sitinshade.com handles those anyway.
Back in the 1980s when doing this we used a Naval Almanac - the US Navy navigation | star position formulas and data are all open source (as products of the US Government).
These days you can tease similar information from Celestia, Stellarium, and other astro projects.
Sun angle wrt a smooth perfect ellipsoid is one thing .. actual sun angle + shadows in the presence of mountains, valleys, forests, tall buildings, etc is a whole other ball of fun.
Love the idea + really nice website!
Fun fact:
There are some trains from Berlin to Munich which go through Leipzig, where they come out of the train station the same way they go in there, so both your ride direction and window side switches, which can be very annoying. ("luckily" there isn't much sunshine in this area most time of the year, haha)
Suppose when you live in Iceland or other similar latitudes, and the sun starts to appear on the horizon, the preferred seating is the sun side to see hours long sunrise / sunset
That's a big assumption that the sun can even be seen lol it's always cloudy here in SE Canada it seems. It's nearly 8am the sun supposedly is up but the clouds are so thick it may as well be 5am.
Oh I know Iceland is about the same as northern Labrador or even south east Nunavut. But here in SE Canada especially Newfoundland the warm Gulfstream and Labrador current both meet here so it can be quite foggy. Plus it seems we are like the tailpipe of North America every weather system seems to end up here even hurricanes.
I get the same result[1], and I'd have expected that if I still live in the Arctic, but I'm a lot further south and see the sun out the window right now.
Your comment comes across as arrogant and (embarrassingly for you) you’re wrong. There are more variables - the direction the roads go in. The changing position of the sun during the journey. The date and time. It’s nothing like as clear cut as you make out.
Try “London to Edinburgh” at this time of year and you’ll see what I mean - there’s only 10% difference in sun exposure between the two sides of the bus.
The sun doesn't rise in the East and set in the West though. And a random short route I put in had about 30 turns and all kinds of angles. Not everywhere is a US grid city :-).