Search in sources :

Example 1 with AdminLevelNode

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));
    }
}
Also used : AdminLevelNode(org.activityinfo.geoadmin.model.AdminLevelNode)

Example 2 with AdminLevelNode

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);
        }
    }
}
Also used : AdminLevelNode(org.activityinfo.geoadmin.model.AdminLevelNode) AdminEntity(org.activityinfo.geoadmin.model.AdminEntity)

Aggregations

AdminLevelNode (org.activityinfo.geoadmin.model.AdminLevelNode)2 AdminEntity (org.activityinfo.geoadmin.model.AdminEntity)1