mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 02:13:15 +00:00
PHRAS-1809_Geoinfos-in-index
Add a "location" field in records (type="geo_point"), populated with same values as "Longitude" and "Latitude" technical fields.
This commit is contained in:
@@ -26,13 +26,14 @@ class FieldMapping
|
|||||||
const TYPE_COMPLETION = 'completion';
|
const TYPE_COMPLETION = 'completion';
|
||||||
|
|
||||||
// Number core types
|
// Number core types
|
||||||
const TYPE_FLOAT = 'float';
|
const TYPE_FLOAT = 'float';
|
||||||
const TYPE_DOUBLE = 'double';
|
const TYPE_DOUBLE = 'double';
|
||||||
const TYPE_INTEGER = 'integer';
|
const TYPE_INTEGER = 'integer';
|
||||||
const TYPE_LONG = 'long';
|
const TYPE_LONG = 'long';
|
||||||
const TYPE_SHORT = 'short';
|
const TYPE_SHORT = 'short';
|
||||||
const TYPE_BYTE = 'byte';
|
const TYPE_BYTE = 'byte';
|
||||||
const TYPE_IP = 'ip';
|
const TYPE_IP = 'ip';
|
||||||
|
const TYPE_GEO_POINT = 'geo_point';
|
||||||
|
|
||||||
// Compound types
|
// Compound types
|
||||||
const TYPE_OBJECT = 'object';
|
const TYPE_OBJECT = 'object';
|
||||||
@@ -48,6 +49,7 @@ class FieldMapping
|
|||||||
self::TYPE_SHORT,
|
self::TYPE_SHORT,
|
||||||
self::TYPE_BYTE,
|
self::TYPE_BYTE,
|
||||||
self::TYPE_IP,
|
self::TYPE_IP,
|
||||||
|
self::TYPE_GEO_POINT,
|
||||||
self::TYPE_OBJECT,
|
self::TYPE_OBJECT,
|
||||||
self::TYPE_COMPLETION
|
self::TYPE_COMPLETION
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -156,8 +156,17 @@ SQL;
|
|||||||
$position->set($tag_name, $value);
|
$position->set($tag_name, $value);
|
||||||
// Try to output complete position
|
// Try to output complete position
|
||||||
if ($position->isComplete()) {
|
if ($position->isComplete()) {
|
||||||
$records[$id]['metadata_tags']['Longitude'] = $position->getSignedLongitude();
|
$lon = $position->getSignedLongitude();
|
||||||
$records[$id]['metadata_tags']['Latitude'] = $position->getSignedLatitude();
|
$lat = $position->getSignedLatitude();
|
||||||
|
|
||||||
|
$records[$id]['metadata_tags']['Longitude'] = $lon;
|
||||||
|
$records[$id]['metadata_tags']['Latitude'] = $lat;
|
||||||
|
|
||||||
|
$records[$id]["location"] = [
|
||||||
|
"lat" => $lat,
|
||||||
|
"lon" => $lon
|
||||||
|
];
|
||||||
|
|
||||||
unset($this->gps_position_buffer[$id]);
|
unset($this->gps_position_buffer[$id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ class RecordIndex implements MappingProvider
|
|||||||
$mapping->addIntegerField('height')->disableIndexing();
|
$mapping->addIntegerField('height')->disableIndexing();
|
||||||
$mapping->addIntegerField('size')->disableIndexing();
|
$mapping->addIntegerField('size')->disableIndexing();
|
||||||
|
|
||||||
|
$mapping->addGeoPointField('location')->disableIndexing();
|
||||||
|
|
||||||
$mapping->addDateField('created_on', FieldMapping::DATE_FORMAT_MYSQL_OR_CAPTION);
|
$mapping->addDateField('created_on', FieldMapping::DATE_FORMAT_MYSQL_OR_CAPTION);
|
||||||
$mapping->addDateField('updated_on', FieldMapping::DATE_FORMAT_MYSQL_OR_CAPTION);
|
$mapping->addDateField('updated_on', FieldMapping::DATE_FORMAT_MYSQL_OR_CAPTION);
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,15 @@ class MappingBuilder
|
|||||||
return $this->mapping->addField(new FieldMapping($name, FieldMapping::TYPE_INTEGER));
|
return $this->mapping->addField(new FieldMapping($name, FieldMapping::TYPE_INTEGER));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @return FieldMapping
|
||||||
|
*/
|
||||||
|
public function addGeoPointField($name)
|
||||||
|
{
|
||||||
|
return $this->mapping->addField(new FieldMapping($name, FieldMapping::TYPE_GEO_POINT));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return FieldMapping
|
* @return FieldMapping
|
||||||
|
|||||||
Reference in New Issue
Block a user