use of org.activityinfo.geoadmin.model.AdminLevelNode in project activityinfo by bedatadriven.
the class LocationAdminMatcher method scoreName.
/**
* Scores the prospective parent based on name similarity. 1=high, meaning
* that the feature contains an exact match of the parent's name in one of
* its columns.
*
* @param feature
* @param parent
* the prospective parent to evaluate
* @return a score from 0=poor match, 1=perfect match
*/
public double scoreName(ImportFeature feature, AdminEntity parent) {
AdminLevelNode level = tree.getLevelById(parent.getLevelId());
Integer attributeIndex = attributeMap.get(level);
if (attributeIndex == null) {
return 0;
} else {
return PlaceNames.similarity(parent.getName(), feature.getAttributeStringValue(attributeIndex));
}
}
use of org.activityinfo.geoadmin.model.AdminLevelNode in project activityinfo by bedatadriven.
the class LocationAdminMatcher method matchChildren.
private void matchChildren(AdminLevelNode parentLevel, AdminEntity parentEntity, ImportFeature feature, List<AdminEntity> matches) {
for (AdminLevelNode level : parentLevel.getChildLevels()) {
Integer attributeIndex = attributeMap.get(level);
if (attributeIndex != null) {
if (Strings.isNullOrEmpty(feature.getAttributeStringValue(attributeIndex))) {
continue;
}
}
AdminEntity bestMatch = findBestParent(feature, queryEntities(level, parentEntity));
if (bestMatch != null) {
matches.add(bestMatch);
matchChildren(level, bestMatch, feature, matches);
}
}
}
Aggregations