source: osm/applications/editors/josm/plugins/conflation/src/com/vividsolutions/jcs/conflate/polygonmatch/DisambiguationMatch.java@ 28163

Last change on this file since 28163 was 28163, checked in by joshdoe, 12 years ago

conflation: now uses Java Conflation Suite and depends on JTS plugin

Currently depends on a few JUMP classes and the JCS files are directly included, this will change in the future.

File size: 2.1 KB
Line 
1package com.vividsolutions.jcs.conflate.polygonmatch;
2
3import com.vividsolutions.jts.util.Assert;
4import com.vividsolutions.jump.feature.Feature;
5import com.vividsolutions.jump.task.TaskMonitor;
6import java.util.Iterator;
7import java.util.Map;
8import java.util.SortedSet;
9import java.util.TreeSet;
10
11class DisambiguationMatch implements Comparable {
12 private Feature target;
13 private Feature candidate;
14 private double score;
15 public double getScore() {
16 return score;
17 }
18
19 public Feature getCandidate() {
20 return candidate;
21 }
22
23 public Feature getTarget() {
24 return target;
25 }
26
27 public DisambiguationMatch(Feature target, Feature candidate, double score) {
28 this.target = target;
29 this.candidate = candidate;
30 this.score = score;
31 }
32 @Override
33 public int compareTo(Object o) {
34 DisambiguationMatch other = (DisambiguationMatch) o;
35 //Highest scores first. [Jon Aquino]
36 if (score > other.score) { return -1; }
37 if (score < other.score) { return 1; }
38 if (target.compareTo(other.target) != 0) { return target.compareTo(other.target); }
39 if (candidate.compareTo(other.candidate) != 0) { return candidate.compareTo(other.candidate); }
40 Assert.shouldNeverReachHere("Unexpected duplicate match?");
41 return -1;
42 }
43 public static SortedSet createDisambiguationMatches(Map targetToMatchesMap, TaskMonitor monitor) {
44 TreeSet set = new TreeSet();
45 monitor.report("Sorting scores");
46 int k = 0;
47 for (Iterator i = targetToMatchesMap.keySet().iterator(); i.hasNext();) {
48 Feature target = (Feature) i.next();
49 Matches matches = (Matches) targetToMatchesMap.get(target);
50 monitor.report(++k, targetToMatchesMap.keySet().size(), "features");
51 for (int j = 0; j < matches.size(); j++) {
52 set.add(new DisambiguationMatch(target, matches.getFeature(j), matches.getScore(j)));
53 }
54 }
55 return set;
56 }
57}
Note: See TracBrowser for help on using the repository browser.