Hacker News new | ask | show | jobs
by cybadger 1552 days ago
Hey Adam, it's pretty fun! I agree with some of the other posters that landmarks and businesses could be a good addition.

I did have some trouble understanding how it's calculating distance and drawing the dashed line. It does not always draw the shortest distance from the pin to the polyline for the road. I tried a few rounds with some deliberately wrong guesses and I'm still not sure I know what it's doing. Some examples:

(1) A road that runs from southwest to northeast. I placed the pin to the southeast of the road. Eyeballing it, the shortest distance is roughly northeast. The dashed line was drawn 10-15 degrees east of north. If it's significant, it drew to an intersection (not the nearest, but reasonably close).

(2) A road that runs east-west. I placed the pin north of the road by 50-60 meters. The dashed line was drawn 15-30 degrees west of south. It did not draw to an intersection or other point of interest. It may be drawing a ray from the center of the circle of interest.

(3) A road that runs north-south. I placed the pin east of the road by 40-ish meters, near the north edge of the circle. The dashed line was drawn 15-30 degrees west of south (my guess in #2 about a ray from the center was wrong), to an intersection, giving a 102 meter distance.

(4) A discontinuous street. (Replicated for a different street! 4th St and 5th St in Marion, IA, if it helps.) The street runs north-south but has a quarter-ish-mile gap. I placed the pin not far from the southern section of the street. The dashed line was drawn from the pin, past (and nearly parallel to) the southern section, then connected to the southern tip of the northern section. Interestingly enough, the distance looked like it was pin-to-southern-section.

(5) A north-south road in rural Iowa taking advantage of the 1-mile grid. I placed the pin near the center of the circle, slightly less than one mile from the nearest point of the road. It drew the dashed line northwest and showed a distance of 2002 meters. I would have expected due west, and ~1500 meters.

(6) A road that runs north-south (with a bit of southeast a half mile south of the circle), that happened to just barely peek inside the circle on the far west. I placed the pin near the outer edge of the circle, roughly northwest. It drew the dashed line nearly due south (several miles!) but reported a distance of 281 meters.

Sometimes the distances seem reasonable even if the dashed line is drawn to a different point on the road. Sometimes the distances and the dashed lines both seem to be off. Intersections seem to have something to do with it, but there also seems to be something else going on too.

For testing, if you're interested, the intersection of "White Road" and "North Alburnett Road" in Iowa (between Marion and Alburnett) is great. It's sparse, gives you nice straight roads, with just a few driveways and other points-on-polyline to confuse(?) algorithms. If you get C Ave Extension just barely in the circle on the west, that's #6.

And for what it's worth, I had fun trying to figure this out!

1 comments

I really appreciate you taking the time to look into this! I don't have much more to say right now than what I said to this person: https://news.ycombinator.com/item?id=30742704. I need to dig into it and see. What you've written will help. I might introduce unit tests (with visuals) for this so I can sure it works in a lot of different scenarios.
I've just rewritten this area of the code completely so all of this should be fine now. Thanks again!