-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consistent circle transform. #2696
Consistent circle transform. #2696
Conversation
Please comment so that we can move on. |
It is indeed strange that a subclass overrides an implemented method of a superclass with an abstract method. So I tend to think that this change makes sense. However, since there is a unit test that checks for the exception being thrown because of the abstract method, there must be a reason. Maybe the same transform that's used on the superclass does the wrong thing for the circle? |
I am using it and it is working correctly. |
Looking at http://openlayers.org/en/master/examples/tissot.html, I would think that when you want to transform a circle, you would use `ol.geom.Polygon.circular´ to create a circle - and it is indeed absurd to project a circle that is only defined by radius and center. |
It is not really about "projecting a circle". It is about transforming/re-projecting a circle (which already includes projected coordinates). Internally, for a circle, we store its center, and the point to the right of the center. So if the center is … until we want to transform/re-project the circle. For example, a circle whose center is What this means is that re-projecting a circle does not result in a circle. In the case of ol.geom.Circle we do not want So two options: (1) we do not permit transforming a circle, or (2) we're lenient and just transform the |
I think it should be sufficient to document properly that transforming a circle geometry might give the user unexpected results (i.e. a circle), and that ol.geom.Polygon.circular should be used when circles need to be properly transformed. So @gberaudo's patch should be fine, with only a bit of documentation to add. |
Agree. Regarding ol.geom.Polygon.circular, can it be used with any coordinate system? I know it's a somewhat different subject, but I'm wondering. |
81f29bd
to
c24deb6
Compare
@ahocevar , I updated the documentation, adding the following text: I also added a |
@@ -18,6 +19,7 @@ goog.require('ol.geom.flat.deflate'); | |||
* @param {number=} opt_radius Radius. | |||
* @param {ol.geom.GeometryLayout=} opt_layout Layout. | |||
* @api | |||
* @see {ol.geom.Polygon.circular} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry but I think that a link with no context doesn't provide much value here. I'd rather not add it here.
3104c99
to
8e57a36
Compare
Thank you for all comments, I hope it is ready for merging now. |
8e57a36
to
5e34606
Compare
* `[cx + r, cy]`. This `transform` function just transforms these two points. | ||
* So the resulting geometry is also a circle, and that circle does not | ||
* correspond to the shape that would be obtained by transforming every point | ||
* of the original circle. It is the same for the other geometries. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the docs for circle. Why are you talking about "other geometries" here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way we formutate this we really give the impression that Circle is
special and obey special rules.
I want to clarify this point, maybe there is a better formulation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way we formutate this we really give the impression that Circle is special and obey special rules.
Which is true. If you reproject every point of a point, line or polygon the transformed geometry is still a point, line, polygon, respectively. If you reproject every point of a polygon whose shape is "circular" the shape of the transformed may not be circular.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are confusing Circle and Polygon.
A 'circular' polygon is not a circle.
The reprojection of an ol.geom.Polygon, be it circular or not, is a polygon.
The reprojection of an ol.geom.Circle is a circle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reprojection of an ol.geom.Circle is a circle.
Depends on whether you are talking about a circle on a sphere or a circle geometry. But I don't think this discussion takes us any further. I think we have agreed already that this pull request is fine, and we can improve documentation later if we see that users run into issues.
Sorry I still have comments. Although I agree that documentation-related review comments are often subjective. Please address my comments if you agree with them. Squashing the commits into one might make sense as well. (I'm not a big fan of "Address @elemoine comments" type commits.) Once done I'll merge. Thanks! |
* then use this function on the clone. | ||
* | ||
* Internally a circle is currently represented by two points: the center of | ||
* the circle `[cx, cy]`, and the point to the left of the circle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left -> right
d9ba151
to
9663c43
Compare
Depending on compilation flags, applying a transform used to either: - work; - fail throwing an abstract method not implemented message; - fail silently. Now it should consistently work, like the other geometries. Adding a polygon factory method creating an approximation of a circle on a plane would be useful for users wanting the circle to be deformed. It would be similar to the `circular` function which creates an approximation of a circle on a sphere.
9663c43
to
d67cefd
Compare
Consistent circle transform.
Depending on compilation flags, applying a transform used to either:
Now it should consistently work, like the other geometries.
Fix #2680