Closed rodo closed 10 years ago
Hey rodo,
Thanks for the great work + test cases!
Precision control is a great idea & I'd love to integrate this library with OSRM, but I'm not satisfied with the design of this solution. The encoder & decoder must be in agreement of precision at all times, and shouldn't be passed as a optional parameter. Here's why
Controlling precision level is a good idea. I'd propose achieving this on a defined application layer, not within the user's run-time configuration. Keep the $number * pow(...)
methods, but replace the local $precision
variable to a late static binding. Also remove the second argument from the parameters.
class Polyline {
static $precision = 5;
// ...
final public static function Encode($points) {
// ...
$number = floor($number * pow(10, static::$precision));
// ... &tc
Anyone who wishes to customize, or use a vendor specific precision can simply extend the class, and overwrite the default level.
class PolylineOSRM extends Polyline {
protected static $precision = 6;
} // done
Now the only challenge would be communicating how to implement precision level.
Sad to see this hasn't had any updates. Interested in what comes of this.
Some tools like OSRM uses the same algorithm but with different precision,; this patch allows to indicate precision on function Decode and Encode.