-
Notifications
You must be signed in to change notification settings - Fork 0
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
few improvements - performance, flexibility of usage #1
Comments
Good suggestion. Probably, there will be some more things for optimization. If necessary, do pull request, please. |
Well I have created a brief implementation here: https://github.com/slepic/geo-problems The point structure works on radians and converting from degrees is rather responsibility of the consumer of the library, although I have added static named constructors on the class as well for convenience. But I'd prefer not to have any static methods anyway... Unlike you, I didnt take care of converting data types like int or string to float, that is also responsibility of the consumer of the library. There is a simple unit test that runs over random data. It first runs the direct problem then the inverse problem on the output of the direct problem, and check if it was able to get back where it started from. I have also replaced the Earth radius constant wth a private variable of the solver class, making it possible to work on other geo structures as well. EDIT: I have also added an experimental formatter for the positions, so it gets more convenint to display those coordinates in whatever format you want instead of just radians. EDIT2:
|
Great! Thank you for your feedback, we will take note in future releases. |
Your implementation is kinda inefficient.
I have a few suggestions to improve it.
I know it might not be an issue, if one needs to calculate just a single line or maybe a few.
But if one want to calculate bulk of lines, it may become noticable.
So my suggestions are here:
$ time php -r 'for ($i=0; $i<100000000; ++$i) deg2rad(45);'
real 0m1,302s
user 0m1,302s
sys 0m0,000s
$ time php -r 'for ($i=0; $i<100000000; ++$i) (45*M_PI/180.0);'
real 0m0,384s
user 0m0,372s
sys 0m0,012s
for example it'd be much more flexible to use
then point only implement methods I would expect from a point:
Point::getLattitude()
Point::getLogitude()
and line (might need renaming)
Line::getDistance()
Line::getBearing()
...plus constructors ofc...
I dont know how about you but i would not expect a point to tell me anything more than this. Putting those methods on the Point a Line classes couples them together with this specific algorithms, although a point is just a point. And you can run dozens of different algorithms over point structures and none of them will need these specific methods....
The text was updated successfully, but these errors were encountered: