本文整理汇总了PHP中Address::getLongitude方法的典型用法代码示例。如果您正苦于以下问题:PHP Address::getLongitude方法的具体用法?PHP Address::getLongitude怎么用?PHP Address::getLongitude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Address
的用法示例。
在下文中一共展示了Address::getLongitude方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addAddress
public function addAddress(Address $address)
{
try {
if ($address != null) {
$latLong = [];
if ($address->getLatitude() == null && $address->getLongitude() == null || $address->getLatitude() == 0.0 && $address->getLongitude() == 0.0) {
$latLong = $this->googleMapService->getLatLong($address);
if (sizeof($latLong) == 2) {
$address->setLatitude($latLong[0]);
$address->setLongitude($latLong[1]);
}
}
if (!parent::getBdd()->inTransaction()) {
parent::getBdd()->beginTransaction();
}
$query = "INSERT INTO ADDRESS VALUES (NULL,:line1, :line2, :zipcode, :city, :lat, :long)";
$request = parent::getBdd()->prepare($query);
$request->bindParam(':line1', $address->getLine1());
$request->bindParam(':line2', $address->getLine2());
$request->bindParam(':zipcode', $address->getZipCode());
$request->bindParam(':city', $address->getCity());
$request->bindParam(':lat', $address->getLatitude());
$request->bindParam(':long', $address->getLongitude());
$request->execute();
$id = parent::getBdd()->lastInsertId();
$request->closeCursor();
parent::getBdd()->commit();
return $id;
}
} catch (Exception $e) {
error_log($e->getMessage());
}
return -1;
}
示例2: testAddressLatitudeAndLongitude
public function testAddressLatitudeAndLongitude()
{
$address = new Address();
$address->latitude = 123.145638;
$this->assertEquals('123.145638', $address->getLatitude());
$address->longitude = 121.176129;
$this->assertEquals('121.176129', $address->getLongitude());
}
示例3: testGetLongitude
/**
* Tests Address->getLongitude()
*/
public function testGetLongitude()
{
$this->assertEquals('LONGITUDE', $this->Address->getLongitude());
}
示例4: distanceToAddress
/**
* @param Address $addressB
* @return float the distance in km
*/
public function distanceToAddress(Address $addressB)
{
$longitudeA = $this->getLongitude();
$latitudeA = $this->getLatitude();
$longitudeB = $addressB->getLongitude();
$latitudeB = $addressB->getLatitude();
return $this->calculateDistanceInKm($longitudeA, $latitudeA, $longitudeB, $latitudeB);
}
示例5: testSetLongitude
/**
* Tests Address->setLongitude()
*/
public function testSetLongitude()
{
$this->Address->setLongitude('longitude');
$this->assertEquals('longitude', $this->Address->getLongitude());
}