diff --git a/lib/classes/record/adapter.php b/lib/classes/record/adapter.php index f924f75a17..dbda9dff04 100644 --- a/lib/classes/record/adapter.php +++ b/lib/classes/record/adapter.php @@ -31,6 +31,7 @@ use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\RecordInterface; use Alchemy\Phrasea\Model\Serializer\CaptionSerializer; use Alchemy\Phrasea\Record\RecordReference; +use Alchemy\Phrasea\SearchEngine\Elastic\Indexer\Record\Hydrator\GpsPosition; use Alchemy\Phrasea\SearchEngine\SearchEngineInterface; use Alchemy\Phrasea\SearchEngine\SearchEngineOptions; use Doctrine\DBAL\Connection; @@ -749,6 +750,40 @@ class record_adapter implements RecordInterface, cache_cacheableInterface 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 * @internal diff --git a/templates/web/prod/actions/edit_default.html.twig b/templates/web/prod/actions/edit_default.html.twig index 640175700f..87fc5d5a69 100644 --- a/templates/web/prod/actions/edit_default.html.twig +++ b/templates/web/prod/actions/edit_default.html.twig @@ -435,6 +435,12 @@ { id: {{ record.get_record_id }}, type: "{{ record.get_type() }}", + {% set position = record.getPositionFromTechnicalInfos %} + technicalInfo: { + isCoordComplete: {{ position.isCoordComplete }}, + latitude: {{ position.latitude }}, + longitude: {{ position.longitude }} + }, {% if record.get_type() == 'video' %} {% set outputFormats = record.getSubdfefByDeviceAndMime(null, ['image/jpeg', 'image/png']) %} {% set previewHtml5 = record.getSubdfefByDeviceAndMime(constant('\\databox_subdef::DEVICE_SCREEN'), ['video/ogg', 'video/mp4', 'video/webm']) %}