3

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
1
  • Did you find what the problem was? I'm seeing the same error message after exporting my database from a production site and importing it in my localhost setup. Weirdly, the maps work fine on the production site, and not at all on localhost (I get this message instead and nothing at all is displayed). – s427 Feb 21 '14 at 16:53
1

i had the same problem and found a quick and dirty solution: 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

  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");
    }

is my dirty fix for this...

regards nicolaj

1
  • remove the replacement for "." - just "str_replace(',', '.', $x)" – Nicolaj Dec 5 '14 at 6:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.