use composite position

This commit is contained in:
aina-esokia
2018-05-03 17:25:37 +04:00
parent 81b3e75d3d
commit c905ca303f
4 changed files with 61 additions and 10 deletions

View File

@@ -81,6 +81,30 @@ class GpsPosition
&& $this->latitude_ref !== null;
}
public function isCompleteComposite()
{
return $this->longitude !== null
&& $this->latitude !== null;
}
public function getCompositeLongitude()
{
if ($this->longitude === null) {
return null;
}
return $this->longitude ;
}
public function getCompositeLatitude()
{
if ($this->latitude === null) {
return null;
}
return $this->latitude;
}
public function getSignedLongitude()
{
if ($this->longitude === null) {

View File

@@ -155,9 +155,9 @@ SQL;
// Push this tag into object
$position->set($tag_name, $value);
// Try to output complete position
if ($position->isComplete()) {
$lon = $position->getSignedLongitude();
$lat = $position->getSignedLatitude();
if ($position->isCompleteComposite()) {
$lon = $position->getCompositeLongitude();
$lat = $position->getCompositeLatitude();
$records[$id]['metadata_tags']['Longitude'] = $lon;
$records[$id]['metadata_tags']['Latitude'] = $lat;

View File

@@ -758,26 +758,24 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
public function getPositionFromTechnicalInfos()
{
$positionTechnicalField = [
media_subdef::TC_DATA_LATITUDE_REF,
media_subdef::TC_DATA_LATITUDE,
media_subdef::TC_DATA_LONGITUDE_REF,
media_subdef::TC_DATA_LONGITUDE
];
$position = new GpsPosition();
$position = [];
foreach($positionTechnicalField as $field){
$fieldData = $this->get_technical_infos($field);
if($fieldData){
$position->set($field, $fieldData->getValue());
$position[$field] = $fieldData->getValue();
}
}
if($position->isComplete()){
if(count($position) == 2){
return [
'isCoordComplete' => 1,
'latitude' => $position->getSignedLatitude(),
'longitude' => $position->getSignedLongitude()
'latitude' => $position[media_subdef::TC_DATA_LATITUDE],
'longitude' => $position[media_subdef::TC_DATA_LONGITUDE]
];
}