Skip to content

Instantly share code, notes, and snippets.

@tomcorbett
Last active August 29, 2015 14:02
Show Gist options
  • Save tomcorbett/1968c204d5153646173a to your computer and use it in GitHub Desktop.
Save tomcorbett/1968c204d5153646173a to your computer and use it in GitHub Desktop.
/**
* I took this code out of a controller I am using in Laravel so will have to fill in the blanks, include Neo4J etc.
*/
$client = new Client('localhost', '7474');
echo "<br /><br />Layer Created<br />";
$layer = $client->makeSimplePointLayer('test', 'latitude', 'longitude');
$layerSaved = $layer->save();
echo "<pre>";
var_dump($layer, $layerSaved);
echo "</pre><br /><br />Node Created<br />";
//exit;
$node = $client->makeNode(array(
'name' => 'testing',
'value' => uniqid(),
'longitude' => -50,
'latitude' => 30
));
$nodeSaved = $node->save();
echo "<pre>";
var_dump($node, $nodeSaved);
echo "</pre><br /><br />Point Added To Layer:<br />";
$result = $layer->add($node);
echo "<pre>";
var_dump($result);
echo "</pre><br /><br />Getting within distance<br />";
$nodes = $layer->findNodesWithinDistance(25, -80, 1000000000);
echo "<pre>";
var_dump($nodes, $nodes->count());
echo "</pre><br /><br />Getting within BBox";
$nodes = $layer->findNodesWithinBBox(-90, 90, -180, 180);
echo "<pre>";
var_dump($nodes, $nodes->count());
echo "</pre>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment