Simplify id creation for full text

Create id only from begin position of the text
This commit is contained in:
Beatrycze Volk 2021-10-05 12:00:10 +02:00
parent 2140b88aa8
commit edb21792d6
4 changed files with 10 additions and 58 deletions

View File

@ -71,22 +71,6 @@ class Highlight
*/
private $yEndPosition;
/**
* The width of found highlight
*
* @var int
* @access private
*/
private $width;
/**
* The height of found highlight
*
* @var int
* @access private
*/
private $height;
/**
* The constructor for highlight.
*
@ -103,9 +87,7 @@ class Highlight
$this->xEndPosition = $highlight['lrx'];
$this->yBeginPosition = $highlight['uly'];
$this->yEndPosition = $highlight['lry'];
$this->width = $highlight['lrx'] - $highlight['ulx'];
$this->height = $highlight['lry'] - $highlight['uly'];
$this->id = $this->width . '_' . $this->height . '_' . $this->xBeginPosition . '_' . $this->yBeginPosition;
$this->id = $this->xBeginPosition . '_' . $this->yBeginPosition;
}
/**
@ -167,28 +149,4 @@ class Highlight
{
return $this->yEndPosition;
}
/**
* Get the highlight's width.
*
* @access public
*
* @return int The highlight's width
*/
public function getWidth()
{
return $this->width;
}
/**
* Get the highlight's height.
*
* @access public
*
* @return int The highlight's height
*/
public function getHeight()
{
return $this->height;
}
}

View File

@ -43,15 +43,12 @@ var dlfAltoParser = function(opt_imageObj, opt_width, opt_height, opt_offset) {
};
/**
* @param {number} width
* @param {number} height
* @param {number} hpos
* @param {number} vpos
* @private
*/
dlfAltoParser.prototype.generateId_ = function(width, height, hpos, vpos) {
var heigt_ = isNaN(height) ? '0' : height;
return '' + width + '_' + heigt_ + '_' + hpos + '_' + vpos;
dlfAltoParser.prototype.generateId_ = function(hpos, vpos) {
return '' + hpos + '_' + vpos;
};
/**
@ -194,7 +191,7 @@ dlfAltoParser.prototype.parseFeatureWithGeometry_ = function(node) {
hpos = parseInt(node.getAttribute("HPOS")),
vpos = parseInt(node.getAttribute("VPOS")),
type = node.nodeName.toLowerCase(),
id = this.generateId_(width, height, hpos, vpos),
id = this.generateId_(hpos, vpos),
feature = new ol.Feature(geometry);
feature.setId(id);

View File

@ -334,15 +334,12 @@ dlfViewerFullTextControl.prototype.removeHighlightEffect = function(activeHoverT
*/
dlfViewerFullTextControl.prototype.addHighlightEffect = function(textlineFeature, hoverSourceTextline_) {
if (textlineFeature) {
var idParts = textlineFeature.getId().split("_");
if (idParts.length === 4) {
var targetElements = $("span[id$='_" + idParts[2] + "_" + idParts[3] + "']");
var targetElem = $('#' + textlineFeature.getId());
if (targetElements === 1 && targetElements[0].length > 0 && !targetElements[0].hasClass('highlight')) {
targetElements[0].addClass('highlight');
setTimeout(this.scrollToText, 1000, targetElements[0], this.fullTextScrollElement);
hoverSourceTextline_.addFeature(textlineFeature);
}
if (targetElem.length > 0 && !targetElem.hasClass('highlight')) {
targetElem.addClass('highlight');
setTimeout(this.scrollToText, 1000, targetElem, this.fullTextScrollElement);
hoverSourceTextline_.addFeature(textlineFeature);
}
}
};

View File

@ -874,7 +874,7 @@ dlfUtils.searchFeatureCollectionForCoordinates = function (featureCollection, co
var features = [];
featureCollection.forEach(function (ft) {
if (ft.get('fulltext') !== undefined) {
if (coordinates.indexOf('_' + ft.get('hpos') + '_' + ft.get('vpos')) !== -1) {
if (ft.getId() === coordinates) {
features.push(ft);
}
}