-
Notifications
You must be signed in to change notification settings - Fork 226
Move projections from extensions. #394
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
Conversation
- Use projections::projection<> as a general projection representation both compile-time and run-time. - Add proj4, epsg, static_proj4, static_epsg parameters passable into projection<> either as ctor parameter or template parameter and defining type of projection and parameters. - Don't require creation of factory or proj4 parameters explicitly in the code. - In the implementation of tmerc projection add specializations of newly added traits for getting compile-time projection implementation from projection tag and SRS model. - Derive dynamic projections from base_v<> type instead of projection<>.
|
Currently Are you ok with this? |
…time EPSG codes. - Add specializations into epsg_traits.hpp file. - Remove specializations from proj/*.hpp files - Add macro simplifying the specialization - Remove Point types and Params template parameters from epsg_traits, take only EPSG. - in epsg_traits define proj4 projection tag and SRS sphere/spheroid tag - in projection<> use these to get the static projection
…oj4 projection<>.
…ion is not created correctly.
…ride what() function.
…and use detail::pj_init_plus() internally.
- Initialize default parameters of 3 projections in both static and dynamic versions. In static version use projection tags in conditions. - Add missing lagrng proj. default and WGS84 ellipsoid default to make it consistent with the original Proj4. - In static version initialize ellipsoid Proj4 params directly from passed object instead of string parameters. - Move proj4, epsg, static_proj4 and static_epsg to parameters.hpp - Remove projections::init() functions.
…w simpler initialization.
|
Great that you picked this up! Thanks! |
|
@barendgehrels Does it mean that you're ok with replacing |
|
@awulkiew I wonder, what issues you have in mind that could lead to objecting such change. Are you afraid of promoting to |
|
@mloskot I'm asking because this is how projections was initially implemented so there might be some rationale behind it which I'm not aware of. At least besides historic reasons since this is how strategies were implemented in the past. Plus there are some issues I could think of (below) but not real problems in practice. Hence I proposed the change, because I think it's good enough. TL;DR Regarding your question about promotion, if anything I was considering that (https://github.com/boostorg/geometry/blob/develop/include/boost/geometry/extensions/gis/projections/proj/aea.hpp#L67) very TL;DR Projection and the corresponding transform strategy works more or less like stateful strategies like area or convex_hull strategies (actually projection is more limited). |
|
@awulkiew Thanks for the explanation. No questions, |
|
@awulkiew Yes, I'm OK with the change to double, thanks for the explanation. |
…ionType tparam. - CalculationType is double by default. - Integral fundamental types and float are promoted to double. - Pass Parameters type into the internals properly - remove default tparam projections::parameters.
|
I've replaced Now I'd like to work on namespace structure, names etc. The first problem I see is that Another thing is that I'd like to make run-time and compile-time semantically as close as possible and separate different kinds of initialization. So I propose to:
After applying the changes mentioned above the interface would look like this: |
|
I think |
|
I suggested Currently we have general EDIT: Or were you thinking about something like this:
Btw, here is the original thread I proposed the change some time ago: |
No, in GIS domain they are synonyms. Sounds good. |
…o srs/ directory.
…geographic strategies.
… the code. The interface: - boost::geometry::projection<> - boost::geometry::proj_exception - boost::geometry::srs::dynamic - boost::geometry::srs::proj4 - boost::geometry::srs::epsg - boost::geometry::srs::static_proj4<> - boost::geometry::srs::static_epsg<> - boost::geoemtry::srs::proj::* - boost::geometry::srs::ellps::*
- Remove string parameter from static_proj4. - Add 2 projection<> ctors taking srs::proj4, disabled by default with ifdef. - Modify and use EPSG, ESRI and IAU2000 traits to use hybrid interface.
|
I moved static parameters to So at this point |
|
@barendgehrels @mloskot @vissarion I think the PR is ready. I'm fairly pleased with the interface. For now projections are not documented. The deadline for merging of major changes is two days from now. I'd like to merge and then do minor fixes if needed and create documentation. I'm aware that this PR is huge so if you were not checking it out periodically then it might be hard for you to catch up and review. So I'd be ok with postponing it in case you needed more time. What do you think? |
| private: | ||
| static std::string msg(std::string const& proj_name) | ||
| { | ||
| return std::string("projection (") + proj_name + ") is not invertable"; |
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.
invertable --> invertible
| { | ||
| double b = 0.0; | ||
| double e = 0.0; | ||
| T b = 0.0; |
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.
why not just 0?
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.
Because T may be double or user-defined type, smaller fundamental types are promoted to double anyway.
|
Indeed this is very long. I sampled the code a bit but I need more time. I agree with the comments and changes discussed above in this thread. For me it is ok to merge now. I can have a look afterwards. One question: what about parts of code related to projections but not from proj4 e.g. Thanks Adam. |
|
Good point about spheroidal gnomonic projection. I don't have a clear answer. The problem is that it's possible to run spherical-only projection with ellipsoid model/data, in this case the major axis is taken as the radius of the sphere. This is the standard proj4 behavior. So everything else than that would be inconsistent with proj4. I'm fine with being inconsistent with proj4 if we agree that it's reasonable. But proj4 is quite established and there are many proj4 parameter strings on the internet. The users probably expect consistent behavior. We could add ellipsoidal/spheroidal gnomonic projection. But I'm not sure if this is what the users would expect because this projection has different properties than the spherical one, i.e. the accuracy decreases with the distance. And as mentioned above, currently major axis is taken if We could go even further and throw an exception if ellipsoid was passed into any spherical projection, i.e. the library would force the user to pass also one of the parameters turning ellipsoid into sphere explicitly (e.g. |
be49bc0 to
7ce15eb
Compare
| int hexbin2(int horizontal, double width, double x, double y, | ||
| template <typename T> | ||
| inline | ||
| int hexbin2(int horizontal, T const& width, T x, T y, |
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.
horizontal parameter is not used
| double sdsq, h, s, fc, sd, sq, d__1; | ||
| template <typename Parameters, typename T> | ||
| inline void | ||
| seraz0(T lam, T const& mult, Parameters& par, par_lsat<T>& proj_parm) |
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.
parameter par is not used
| template <typename Parameters> | ||
| void setup_cc(Parameters& par, par_cc& proj_parm) | ||
| template <typename Parameters, typename T> | ||
| inline void setup_cc(Parameters& par, par_cc<T>& proj_parm) |
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.
proj_parm parameter is not used
vissarion
left a comment
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.
There are some unused parameters in some functions (I commented for some but there are a few more). Apart from this I am ok with merging. Thanks
|
I'm OK with merging, anyway. And let's do it as soon as possible now we are still early in the release. |
Conflicts: include/boost/geometry/geometry.hpp test/Jamfile.v2
|
Thanks. I removed unused parameters. Btw, they are not existing in the recent version of proj4. I'd prefer to agree about the interface now but if you prefer to have the code merged I'm ok with that too. If needed I'll address any remarks after merging. 1.67 is closed for major changes on 28.02 so we have plenty of time. |
The change was applied in PR boostorg#394
The intention of this PR is to move projections from extensions. It is currently in a "work in progress" state. I created this PR at this stage because I'd like to get feedback regarding the direction I'm going into. So my intention is to modify this description to present current state of the implementation and have the history of the conversation and changes below.
The projections and transformations works as follows:
bg::srs::projection<>is general, both compile-time and run-time representation of map projection.bg::srs::transformation<>is general, both compile-time and run-time representation of transformation between space reference systems.bg::srs::proj4passed into the constructor of dynamic projectionbg::srs::static_proj4<>passed as template parametersbg::srs::epsg,bg::srs::esri,bg::srs::iau2000bg::srs::static_epsg<>,bg::srs::static_esri<>,bg::srs::static_iau2000<>This is the interface:
In all cases the projection or transformation of any geometry besides Box can be done like this:
There are 2 strategies for
transform()algorithm:bg::strategy::transform::srs_forward_transformer<>bg::strategy::transform::srs_inverse_transformer<>They both take either
projection<>ortransformation<>as template argument and pass ctor parameters to the constructor ofprojection<>ortransformation<>, so it's possible to initialize strategies the same way, e.g.: