Created
January 17, 2019 17:52
-
-
Save dib258/9c18316846c1b91d04d081ff7e645ddf to your computer and use it in GitHub Desktop.
Extract database to script node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
protected function extractMarkerstoJson() { | |
$markersArray = []; | |
foreach($this->markers as $marker) { | |
$markerObject = new stdClass(); | |
$markerObject->id = $marker->id; | |
$markerObject->type = $marker->type; | |
$markerObject->subtype = $marker->subtype; | |
$markerObject->coordinates = []; | |
foreach($marker->coordinates()->get() as $coordinate) { | |
$coordinateArray = [$coordinate->latitude, $coordinate->longitude]; | |
$markerObject->coordinates[] = $coordinateArray; | |
} | |
$markersArray[] = $markerObject; | |
} | |
return json_encode($markersArray); | |
} | |
protected function extractPolygonsToJson() { | |
$polygonsArray = []; | |
foreach($this->polygons as $polygon) { | |
$polygonObject = new stdClass(); | |
$polygonObject->id = $polygon->id; | |
$polygonObject->type = $polygon->type; | |
$polygonObject->subtype = $polygon->subtype; | |
$polygonObject->coordinates = []; | |
foreach($polygon->coordinates()->get() as $coordinate) { | |
$coordinateArray = [$coordinate->latitude, $coordinate->longitude]; | |
$polygonObject->coordinates[] = $coordinateArray; | |
} | |
$polygonsArray[] = $polygonObject; | |
} | |
return json_encode($polygonsArray); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment