viewer3d.js
15194行
/**
* 修改2019-8-6 加入perfectMatch关键字,
* perfectMatch为true时为完全匹配,为false时为包含
*
*/
Model.prototype.search = function (text, onSuccessCallback, onErrorCallback, attributeNames,perfectMatch)
{
var pdb = this.getPropertyDb();
if (!pdb) {
onErrorCallback && onErrorCallback();
return;
}
pdb.searchProperties(text, attributeNames, onSuccessCallback, onErrorCallback,perfectMatch);
};
19173行
/**
* 修改2019-8-6 加入perfectMatch关键字,
* perfectMatch为true时为完全匹配,为false时为包含
*
*/
Viewer3D.prototype.search = function (text, onSuccessCallback, onErrorCallback, attributeNames,perfectMatch)
{
this.searchText = text;
if (this.model) {
this.model.search(text, onSuccessCallback, onErrorCallback, attributeNames,perfectMatch);
} else
{
if (onErrorCallback)
onErrorCallback(_file_loaders_net_ErrorCodes__WEBPACK_IMPORTED_MODULE_6__["ErrorCodes"].BAD_DATA, "Search failed since model does not exist");
}
};
38881行
/**
* 修改2019-8-6 加入perfectMatch关键字,
* perfectMatch为true时为完全匹配,为false时为包含
*
*/
PropDbLoader.prototype.searchProperties = function (searchText, attributeNames, onSuccess, onError,perfectMatch) {
this.asyncPropertyOperation(
{
"operation": WORKER_SEARCH_PROPERTIES,
"searchText": searchText,
"attributeNames": attributeNames,
"perfectMatch":perfectMatch
},
onSuccess, onError);
};
lmvworker.js
35941行
/**
* 修改2019-8-6 加入perfectMatch关键字,
* perfectMatch为true时为完全匹配,为false时为包含
* @param loadContext
*/
function doPropertySearch(loadContext) {
var _this = loadContext.worker;
// 添加
var perfectMatch = loadContext.perfectMatch;
var cacheEntry = _this.pdbCache && _this.pdbCache[loadContext.dbPath];
if (cacheEntry && cacheEntry.pdb) {
var searchText = loadContext.searchText;
var result = cacheEntry.pdb.bruteForceSearch(searchText, loadContext.attributeNames,perfectMatch);
_this.postMessage({ cbId: loadContext.cbId, result: result });
}
}
22754行
/**
* Searches the property database for a string.
* 修改2019-8-6 加入perfectMatch关键字,
* perfectMatch为true时为完全匹配,为false时为包含
*
*
* @returns Array of ids.
*/
this.bruteForceSearch = function (searchText, attributeNames,perfectMatch) {
var searchList = this.getSearchTerms(searchText);
if (searchList.length === 0)
return [];
//For each search word, find matching IDs
var results = [];
for (var k = 0; k < searchList.length; k++) {
var result = [];
//Find all values that match the search text
var matching_vals = [];
for (var i = 0, iEnd = _valuesOffsets.length; i < iEnd; i++) {
var val = this.getValueAt(i);
if (val === null)
continue;
// 原方法
// if (val.toString().toLowerCase().indexOf(searchList[k]) !== -1){
//
// matching_vals.push(i);
// }
//此处修改
if(perfectMatch){
if (val.toString().toLowerCase() === searchList[k] ){
matching_vals.push(i);
}
}else{
if (val.toString().toLowerCase().indexOf(searchList[k]) !== -1){
matching_vals.push(i);
}
}
}
if (matching_vals.length === 0) {
results.push(result);
continue;
}
// values should be sorted at this point, but it doesn't hurt making sure they are.
matching_vals.sort(function (a, b) {
return a - b;
});
this.enumObjects(function (id) {
_this.enumObjectProperties(id, function (attrId, valId) {
// skip hidden attributes
var isHidden = _this.attributeHidden(attrId);
if (isHidden) {
return;
}
var iFound = Object(_common_SearchUtils__WEBPACK_IMPORTED_MODULE_1__["binarySearch"])(matching_vals, valId);
if (iFound !== -1) {
//Check attribute name in case a restriction is passed in
if (attributeNames && attributeNames.length && attributeNames.indexOf(_attrs[attrId][0]) === -1)
return;
result.push(id);
return true;
}
});
});
results.push(result);
}
if (results.length === 1) {
return results[0];
}
//If each search term resulted in hits, compute the intersection of the sets
var map = {};
var hits = results[0];
for (var i = 0; i < hits.length; i++) {
map[hits[i]] = 1;}
for (var j = 1; j < results.length; j++) {
hits = results[j];
var mapint = {};
for (var i = 0; i < hits.length; i++) {
if (map[hits[i]] === 1)
mapint[hits[i]] = 1;
}
map = mapint;
}
var result = [];
for (var k in map) {
result.push(parseInt(k));
}
return result;
};
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。