position technical data to positive negative value

This commit is contained in:
aina-esokia
2018-04-12 09:48:09 +04:00
parent ab42397196
commit e8f9e9a883
2 changed files with 41 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\RecordInterface; use Alchemy\Phrasea\Model\RecordInterface;
use Alchemy\Phrasea\Model\Serializer\CaptionSerializer; use Alchemy\Phrasea\Model\Serializer\CaptionSerializer;
use Alchemy\Phrasea\Record\RecordReference; use Alchemy\Phrasea\Record\RecordReference;
use Alchemy\Phrasea\SearchEngine\Elastic\Indexer\Record\Hydrator\GpsPosition;
use Alchemy\Phrasea\SearchEngine\SearchEngineInterface; use Alchemy\Phrasea\SearchEngine\SearchEngineInterface;
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions; use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
@@ -749,6 +750,40 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
return $this->technical_data; return $this->technical_data;
} }
/**
* Return an array containing GPSPosition
*
* @return array
*/
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();
foreach($positionTechnicalField as $field){
$fieldData = $this->get_technical_infos($field);
if($fieldData){
$position->set($field, $fieldData->getValue());
}
}
if($position->isComplete()){
return [
'isCoordComplete' => 1,
'latitude' => $position->getSignedLatitude(),
'longitude' => $position->getSignedLongitude()
];
}
return ['isCoordComplete' => 0, 'latitude' => 0, 'longitude' => 0];
}
/** /**
* @param TechnicalDataSet $dataSet * @param TechnicalDataSet $dataSet
* @internal * @internal

View File

@@ -435,6 +435,12 @@
{ {
id: {{ record.get_record_id }}, id: {{ record.get_record_id }},
type: "{{ record.get_type() }}", type: "{{ record.get_type() }}",
{% set position = record.getPositionFromTechnicalInfos %}
technicalInfo: {
isCoordComplete: {{ position.isCoordComplete }},
latitude: {{ position.latitude }},
longitude: {{ position.longitude }}
},
{% if record.get_type() == 'video' %} {% if record.get_type() == 'video' %}
{% set outputFormats = record.getSubdfefByDeviceAndMime(null, ['image/jpeg', 'image/png']) %} {% set outputFormats = record.getSubdfefByDeviceAndMime(null, ['image/jpeg', 'image/png']) %}
{% set previewHtml5 = record.getSubdfefByDeviceAndMime(constant('\\databox_subdef::DEVICE_SCREEN'), ['video/ogg', 'video/mp4', 'video/webm']) %} {% set previewHtml5 = record.getSubdfefByDeviceAndMime(constant('\\databox_subdef::DEVICE_SCREEN'), ['video/ogg', 'video/mp4', 'video/webm']) %}