Added 2 helper functions lonlat and latlon, added documentation for each - #282
Conversation
KostyaEsmukov
left a comment
There was a problem hiding this comment.
First of all, thank you very much for this! Some changes are definitely required, and, TBH, I'm not quite sure how should this look in the end. I left a suggestion on removing latlon function, because it fully replicates Point constructor.
Also I've noticed that these functions are not referenced in the docs. Could you do that please? I think that these should go right after module doc, before geodesic (docs/index.rst file). See CONTRIBUTING.md for how-to on building and viewing docs locally.
PS I know how hard this is to write good docs, especially on a foreign language. I'm still learning here too! Just want to let you know that I appreciate your efforts.
| >>> _, pa = g.geocode('Palo Alto, CA') | ||
| >>> print((d(ne, cl) + d(cl, wa) + d(wa, pa)).miles) | ||
| 3277.30439191 | ||
|
|
There was a problem hiding this comment.
Could you please revert this change?
| >>> newport_ri = (41.49008, -71.312796) | ||
| >>> cleveland_oh = (41.499498, -81.695391) | ||
| >>> print(distance(latlon(*newport_ri), latlon(*cleveland_oh)).miles) | ||
| 538.3904453677203 |
There was a problem hiding this comment.
Parameters (below) must be separated from description (above) with one empty line:
"""
... description ...
<-- empty newline
:param ...
"""
| def latlon(y, x, z=0): | ||
| """ | ||
| Helper function that can be used for more explicit and obvious calling of the distance methods | ||
| >>> from geopy.distance import latlon, distance |
There was a problem hiding this comment.
I believe that code examples must be indented to be rendered correctly, though I'm not sure. Anyway, all the examples in this file are indented, so could you please do that there too?
| Helper function that can be used for more explicit and obvious calling of the distance methods | ||
| >>> from geopy.distance import latlon, distance | ||
| >>> newport_ri = (41.49008, -71.312796) | ||
| >>> cleveland_oh = (41.499498, -81.695391) |
There was a problem hiding this comment.
IMO it might be not easy to comprehend that this is an y-x order, but this is crucial for understanding the intent of this function. Maybe a more explanatory variable name would help?
newport_ri_yx = (41.49008, -71.312796)
|
|
||
| def lonlat(x, y, z=0): | ||
| """ | ||
| Helper function that can be used for more explicit and obvious calling of the distance methods |
There was a problem hiding this comment.
I don't think that obvious is a proper term for documentation :-)
This description should introduce the reader to the problem: distance accepts coordinates in (y, x)/(lat, lon) order, while some other libraries/systems might use (x, y)/(lon, lat) instead.
And then suggest a solution: using this function, which accepts coordinates in (x, y, [z]) order and returns a Point instance for the distance.
|
|
||
| def latlon(y, x, z=0): | ||
| """ | ||
| Helper function that can be used for more explicit and obvious calling of the distance methods |
There was a problem hiding this comment.
This function is very different from the previous one, so should be the description. I believe it will be confusing to the reader to see a function which transforms (y, x, [z]) to the same (y, x, [z]).
Actually I'm starting to think that instead of introducing this function, it would probably be better to simply encourage the use of the Point constructor instead. What do you think?
|
Hey, it's been a while, I'm verry sorry. I got sick and then a lot of work appeared suddenly. |
No problem, this can wait.
Yup, I think that would be better.
Click on the red cross near a commit to see the build status #374139588. There's a single failing job #374139594, which is, apparently, caused by a random failure due to the tests relying on the network, which might fail (in this case there was a timeout). The failed tests in this job are surely unrelated to your changes, so all that was needed was to trigger the build one more time. That last merge of yours did it. You could've also amended the commit and force-pushed it. |
| def lonlat(x, y, z=0): | ||
| """ | ||
| Helper function that can be used for more explicit and obvious calling of the distance methods | ||
| distance accepts coordinates in (y, x)/(lat, lon) order, while some other libraries/systems might use |
There was a problem hiding this comment.
- A sentence should start with a capital letter :). But in this case
distanceis a term (a class reference, more specifically), not a plain word. See the docs around for examples on howdistanceis formatted there. - Please try to keep the line lengths close to 80-ish.
- Coordinate pairs should also be formatted as terms (with backticks, I guess), otherwise they might be split by word-wrapping.
| distance accepts coordinates in (y, x)/(lat, lon) order, while some other libraries/systems might use | ||
| (x, y)/(lon, lat). | ||
| This helper function introduced here for solving this problem. It accepts coordinates in a form of (x, y)/(lon, lat) | ||
| and returns Point that is safe to use with distance |
There was a problem hiding this comment.
-
A sentence should end with a dot (or some other relevant punctuation mark).
-
It seems to me that these two sentences are intended to be in their own paragraph. Paragraphs should be separated with one empty line, which is missing there.
-
These two sentences don't sound natural to me. Let me propose the following phrasing:
This function provides a convenient way to convert coordinates of the ``(x, y)/(lon, lat)`` format to a :class:`geopy.point.Point` instance. Example::
|
Hey again, thanks for positive feedback, I am doing my best, but it's actually pretty hard to write meaningful docs, so thank you very much for your guidance and patience! |
KostyaEsmukov
left a comment
There was a problem hiding this comment.
Just a few notes, otherwise it looks good. Thank you for your efforts!
| >>> print((d(ne, cl) + d(cl, wa) + d(wa, pa)).miles) | ||
| 3277.30439191 | ||
|
|
||
There was a problem hiding this comment.
This change should be reverted
|
|
||
| :param x: longitude | ||
| :param y: latitude | ||
| :param z: altitude |
There was a problem hiding this comment.
:param z: (optional) altitude
|
|
||
| Example:: | ||
|
|
||
| >>> from geopy.distance import lonlat, distance |
There was a problem hiding this comment.
Code blocks should be indented.
Like this: https://github.com/svalee/geopy/blob/f4d0b509dccc1f8a937e1ae2416066bcf611f08b/geopy/distance.py#L289
| Example:: | ||
|
|
||
| >>> from geopy.distance import lonlat, distance | ||
| >>> newport_ri = (-71.312796, 41.49008) |
There was a problem hiding this comment.
newport_ri_xy and cleveland_oh_xy
|
We seem to have forgotten about the tests! Added in fdfaac7. Also the import in the docs was incorrect: it was ... which yielded an error when building the docs, because lonlat is not exported from geopy. It should've been this: I guess it was just a typo. |
this commit fixes #202