I am using Geofield to store point and polygon features. Input works fine with all the different widgets I have tried.
Display formats (GeoJSON, WKT, KML) with Data Options "Use full geometry" and "Use centroid" work fine with either point or polygon geometries. When I use the Data Option " Use bounding box" it does not work with any geometry and get the following error:
Exception: Cannot construct Point. x and y should be numeric in Point->__construct() (line 23 of ....../sites/all/modules/geophp/geoPHP/lib/geometry/Point.class.php).
Is this a known bug? My search did not find any reports. Or is it my configuration?
Drupal 7.20
Geofield 7.x.1.1
geoPHP 7.x.1.7
PHP (MAMP) 5.4.4
Thanks for any advice.
Comments
Maybe non-english "local env"
hey
i posted my quick and dirty solution on stackexchange. a copy here:
in the referenced file Point.class.php the following function throws the error:
public function __construct($x, $y, $z = NULL) {// Basic validation on x and y
if (!is_numeric($x) || !is_numeric($y)) {
throw new Exception("Cannot construct Point. x and y should be numeric");
}
adding "echo $x;" before the "throw" showed me the problem: the numbers for $x and $y where in the wrong "local" format.
e.g. 9,34124 instead 9.34124
replacing "," with "." made it:
public function __construct($x, $y, $z = NULL) {$x = floatval(str_replace(',', '.', str_replace('.', '', $x)));
$y = floatval(str_replace(',', '.', str_replace('.', '', $y)));
// Basic validation on x and y
if (!is_numeric($x) || !is_numeric($y)) {
throw new Exception("Cannot construct Point. x and y should be numeric");
}
regards nicolaj
follow-up
removing the "." (in some locale used to deliminate the 1000) first wasn't very helpful.
if the number was already in the correct format (9.34124) it changed it to 934124...
correct function for my environment:
public function __construct($x, $y, $z = NULL) {$x = floatval(str_replace(',', '.', $x));
$y = floatval(str_replace(',', '.', $y));
// Basic validation on x and y
if (!is_numeric($x) || !is_numeric($y)) {
throw new Exception("Cannot construct Point. x and y should be numeric");
}
hope this helps
nicolaj