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
Geodistance filter, missing options #200
Comments
Hmmm, I think we should completely rewrite Elastica_Filter_GeoDistance. |
It should also support location as geohash: There is a backward compatibility break in the constructor (PHP is a stupid language). |
Missing options: I think here we can use some constants. Concerning setParam(): Yes, we should to that. I already did it for most of the queries and filters, but not all. Backward compatitbility: Question is, what has first priority. Probably all params in the constructor should be optimal. What would be your suggestion? PHP: Every language has advantages and disadvantages ;-) |
All currently used parameters are mandatory:
Other parameters are optional:
The problem is: in the current constructor, only latitude+longitude is supported, not geohash. |
I agree on that, but what would be the solution to allow both? Because of PHP, we cannot have two different constructors except in the case that we use two different class which inherit from an abstract class ... BTW: I'm currently on holiday, so I'm probably going to respond less frequently ;-) |
We could use func_get_args(), but it's really shitty... Have a great holiday! |
Ugh, I don't like the func_get_args function at all. I agree on breaking BC, but I don't know yet how the new implementation would work? Example? |
public function __construct($key, $location, $distance) $location can be:
|
I quite like this solution. We could add a "deprecated" for the next to releases where we check if there are 4 params and then would convert the old params to the new version bit a function that is deprecated. Like this, people that use the never version should realize. Please make sure to always update changes.txt with your changes because I use this file for the release notes and it makes it easy for people to look up relevant changes. |
Hmmm, there would be 2 constructors :P |
Hm, somehow my e-mail answer did not make it into github. There would be only 1 constructor, be we would use the ugly func_get_args function to check for a fourth param. If we have a fourth param, we call a function (which is deprecated) to remodel the arguments to the new structure. This code will only exist for 1-2 releases, after that we are going to remove it. |
no, there would be an if clause inside the constructor On 26.06.2012, at 00:28, Pierre Durand reply@reply.github.com wrote:
|
It could call the constructor again with 3 arguments :P |
right. even better |
We could also use the "distance_unit" parameters, instead of the (dirty) current format. Currently, the "distance" parameter is a string ("19km"). It is possible to use the "distance" parameters as a number (19), and add the "distance_unit" parameters ("km"). It will be easier to validate public function setDistance($distance) {
// TODO: validate distance?
$this->_distance = $distance;
return $this;
} |
Is it a good idea to have setDistance() / setLatitude() / setLongitude() methods, because these parameters are mandatory in the constructor? |
I just cleaned the geodistance filter: Is it ok? |
Finally, my feedback:
|
It is really difficult to implement raw distance + distance unit & distance, because we have to support the old constructor (for retrocompatibility). It is not easy to have setters for latitude, longitude, or geohash, because they require the "key" parameter. Maybe we could add a setLocation($key, $location) method. What should we do? |
Ah, this strange thing named BC again ;-) A suggestion from my side: We keep the old constructor, but split up the distance and the unit (regexp, ...). We then store it seperate in the object, which also allows the setter. Fro the setLatitude(): I would argue, nothing happens until toArray() is called, where an exception is thrown. Either the geohash or the longitude AND latitude have to be set. I would suggest, that we have a seperate function setKey(...). Perhaps things get simpler, if we do not store latitude / longitude already in an array (even though it is passed in an array) and create the structure for the request in toArray(). Somehow it doesn't feel 100% logical yet, also what I described above :-( |
Do you think we need distance + unit feature? |
I would be nice ;-) |
I have an idea: the last parameter could be a string (distance + unit as string) or an associative array (distance as float, and unit as string) We could also add a setter: setDistance($distance, $unit = null) |
I like both :-) And if only a string is passed to setDistance? Will the function try to split it up? |
No, it will use the parameter as a string. |
Right, forgot that there were two structures. Sorry. |
Any updates here? |
@pierrre As you closed this, I assume this is not needed anymore or already implemented. |
Yes, I closed all my old issues: https://github.com/pierrre?tab=activity |
Ok, thx. Even though I would prefer that you would still use Elastica ;-) |
:-( |
There are missing options:
Do you have any recommendation?
Are class constants required? (arc, plane, memory, indexed, none)
The text was updated successfully, but these errors were encountered: