Hello all, I'm having an issue taking geofield data and manipulating it with the geophp library. I originally posted a question over in the geofield queue, but I think it would be more appropriate here.

Basically, I cannot take data I have stored in a geofield and load it with geoPHP:load($data,'wkt'). When I do a manual db query to get the geometry, the data loads but geophp kicks back an error: something about cannot load object of stdClass. I know that is related to the type of variable I'm using to store the query data.

I can also grab the data using node_load, but when I load the geom data into geophp usingt that, I get this error:

Undefined offset: 1
Cannot construct Point. x and y should be numeric in 23 of /modules/geophp/geoPHP/lib/geometry/Point.class.php

SOOOoooo, I guess my question is: is there a preferred way to get data from drupal and load it into geoPHP for manipulation? I'm attempting to write a custom module and geoPHP seems to be exactly what I need, but I just can't get past this roadblock.

Any help or push in the right direction is greatly appreciated. Even a reference to a module that is doing this same thing would be helpful. I've dug into the code of several modules already, but I'm still coming up empty.

Comments

apt94jesse’s picture

Status: Active » Fixed

If anyone is interested, I did solve the issue, although I'm sure there's a geofield function I could have used, too. Code is below in case it can help anyone.

$neighborhoodsselect = "SELECT nid FROM node WHERE type = 'neighborhood'";
$neighborhoodsql = db_query($neighborhoodsselect);

foreach($neighborhoodsql as $record){
		$record = node_load($record->nid);
		$record = geoPHP::load($record->field_neighborhood['und'][0]['geom'], 'wkb');
		var_dump($record);
};
apt94jesse’s picture

If anyone is interested, I did solve the issue, although I'm sure there's a geofield function I could have used, too. Code is below in case it can help anyone.

$neighborhoodsselect = "SELECT nid FROM node WHERE type = 'neighborhood'";
$neighborhoodsql = db_query($neighborhoodsselect);

foreach($neighborhoodsql as $record){
		$record = node_load($record->nid);
		$record = geoPHP::load($record->field_neighborhood['und'][0]['geom'], 'wkb');
		var_dump($record);
};

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.