League\Geotools\Coordinate\Coordinate::setLatitude PHP Method

setLatitude() public method

{@inheritDoc}
public setLatitude ( $latitude )
    public function setLatitude($latitude)
    {
        $this->latitude = $this->normalizeLatitude($latitude);
    }

Usage Example

Example #1
0
}
$IsNotRefactored = true;
/**
 * Overview for data
 */
$Routes = $PDO->query('SELECT id, lats, lngs, startpoint_lat, startpoint_lng, endpoint_lat, endpoint_lng, min_lat, min_lng, max_lat, max_lng FROM ' . PREFIX . 'route WHERE `refactored`=0 LIMIT ' . LIMIT);
$InsertGeohash = $PDO->prepare('UPDATE ' . PREFIX . 'route SET `refactored`=1, `geohashes`=:geohash, `startpoint`=:startpoint, `endpoint`=:endpoint, `min`=:min, `max`=:max WHERE `id` = :id');
while ($Route = $Routes->fetch()) {
    $lats = explode("|", $Route['lats']);
    $lngs = explode("|", $Route['lngs']);
    $quantity = count($lats);
    $geohashArray = array();
    $Coordinate = new Coordinate(array(0, 0));
    for ($i = 0; $i < $quantity; $i++) {
        // TODO: use a persisent Geohash object as soon as that's possible, see https://github.com/thephpleague/geotools/issues/73
        $Coordinate->setLatitude((double) $lats[$i]);
        $Coordinate->setLongitude((double) $lngs[$i]);
        $geohashArray[] = (new Geohash())->encode($Coordinate, 12)->getGeohash();
    }
    $InsertGeohash->execute(array(':geohash' => implode("|", $geohashArray), ':id' => $Route['id'], ':startpoint' => (new Geohash())->encode(new Coordinate(array((double) $Route['startpoint_lat'], (double) $Route['startpoint_lng'])), 10)->getGeohash(), ':endpoint' => (new Geohash())->encode(new Coordinate(array((double) $Route['endpoint_lat'], (double) $Route['endpoint_lng'])), 10)->getGeohash(), ':min' => (new Geohash())->encode(new Coordinate(array((double) $Route['min_lat'], (double) $Route['min_lng'])), 10)->getGeohash(), ':max' => (new Geohash())->encode(new Coordinate(array((double) $Route['max_lat'], (double) $Route['max_lng'])), 10)->getGeohash()));
    if (CLI) {
        echo "";
        $diff = count($Route['id']);
        echo str_pad($Route['id'], 7 - $diff, ' ', STR_PAD_LEFT);
    } else {
        echo ".";
    }
}
if (CLI) {
    echo NL . NL;
}