News for hackers. Stuff that matters.
Re:I had to give a wrong answer to get the job (2017) by dmcginty on Monday July 19, 2021 @02:53PM (#27886061)
I was in a job interview several years ago and I was given the following prompt: "You have a database containing locations with their corresponding latitudes and longitudes. We want to be able to input an arbitrary latitude and longitude and have the program return all locations within a radius from that point from the database." My initial reaction was to say "I would use a GIS library/API", but the interviewer wanted me to come up with the algorithm on my own. I had done some GIS work at a previous job, so I started explaining how I'd approach it. I was a bit rusty, but I started explaining what I could remember about the Haversine formula and rhumb lines. The interviewer told me that I was overcomplicating it and explained that I can treat the latitude and longitude as standard Cartesian coordinates. I explained how that wouldn't work as they're spherical coordinates, not planar, and lines of longitude aren't parallel. I believe this is where the problem went from being an issue with technical approach to an issue with expectations. What they really wanted was an algorithm that could find all points a given radius from an arbitrary X,Y coordinate. However, by trying to turn it into a real-world problem with latitudes and longitudes they neglected to consider that they had fundamentally changed the challenge. I'm quite stubborn, and I tried to point out that the question was much more difficult than they intended, but they were equally stubborn and insisted that spherical coordinates could be directly converted to planar coordinates with no issue. Long story short, I didn't get a call back and I'm still frustrated about that interview ~3 years later, but I'm also glad that I stood my ground rather than give an incorrect answer.
Re:I had to give a wrong answer to get the job (2017) by nemanjaboric on Monday July 19, 2021 @05:06PM (#27887259)
There's a sizable portion of people believing that spherical coordinates can be directly converted to planar coordinates :-).
Re:I had to give a wrong answer to get the job (2017) by benrbray on Monday July 19, 2021 @10:33PM (#27889524)
Mathematically speaking, isn't it true you can compute the coordinate transformation (with your choice of map projection, perhaps ignoring the poles)? The real problem is that your metric / notion of distance has changed, so you can't simply compute distance as sqrt((x2-x1)^2 + (y2-y1)^2) and expect it to map neatly to a circle on the globe.
Re:I had to give a wrong answer to get the job (2017) by joemi on Monday July 19, 2021 @03:08PM (#27886195)
I would have just as stubborn about the spherical-to-planar issue. IMO it's easy to illustrate by pointing out an extreme example: two longitude lines can be feet apart near the poles (ignoring the intersection aspect for simplicity) and miles apart at the equator. If someone doesn't understand that... I don't know what to say.
Re:I had to give a wrong answer to get the job (2017) by walshemj on Monday July 19, 2021 @03:25PM (#27886361)
Some times "good enough for jazz" applies I solved a similar problem - find all geo locations within 2 hours driving time of x,y

I basically used the great circle distance (using I think a CPAN module) as an approximation - this was for geotargeting AdWords.

Re:I had to give a wrong answer to get the job (2017) by ahefner on Monday July 19, 2021 @03:16PM (#27886266)
Maybe they were expecting converting to 3 dimensional Cartesian coordinates (X/Y/Z), then check that one point is inside the sphere of given radius from the other point?