root / trunk / libraries / libTopology / src / com / vividsolutions / jcs / conflate / polygonmatch / ThresholdFilter.java @ 22873
History | View | Annotate | Download (2.31 KB)
1 |
|
---|---|
2 |
|
3 |
/*
|
4 |
* The JCS Conflation Suite (JCS) is a library of Java classes that
|
5 |
* can be used to build automated or semi-automated conflation solutions.
|
6 |
*
|
7 |
* Copyright (C) 2003 Vivid Solutions
|
8 |
*
|
9 |
* This program is free software; you can redistribute it and/or
|
10 |
* modify it under the terms of the GNU General Public License
|
11 |
* as published by the Free Software Foundation; either version 2
|
12 |
* of the License, or (at your option) any later version.
|
13 |
*
|
14 |
* This program is distributed in the hope that it will be useful,
|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
* GNU General Public License for more details.
|
18 |
*
|
19 |
* You should have received a copy of the GNU General Public License
|
20 |
* along with this program; if not, write to the Free Software
|
21 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
22 |
*
|
23 |
* For more information, contact:
|
24 |
*
|
25 |
* Vivid Solutions
|
26 |
* Suite #1A
|
27 |
* 2328 Government Street
|
28 |
* Victoria BC V8T 5G5
|
29 |
* Canada
|
30 |
*
|
31 |
* (250)385-6040
|
32 |
* www.vividsolutions.com
|
33 |
*/
|
34 |
|
35 |
package com.vividsolutions.jcs.conflate.polygonmatch; |
36 |
|
37 |
import com.vividsolutions.jump.feature.Feature; |
38 |
import com.vividsolutions.jump.feature.FeatureCollection; |
39 |
|
40 |
/**
|
41 |
* Filters out shapes with a score below a given value.
|
42 |
*/
|
43 |
public class ThresholdFilter implements FeatureMatcher { |
44 |
|
45 |
/**
|
46 |
* Creates a ThresholdFilter with the given minimum score.
|
47 |
* @param minScore the score below which shapes will be filtered out
|
48 |
*/
|
49 |
public ThresholdFilter(double minScore) { |
50 |
this.minScore = minScore;
|
51 |
} |
52 |
|
53 |
private double minScore; |
54 |
|
55 |
/**
|
56 |
* Filters out shapes with a score below the minimum score threshold.
|
57 |
* @param target ignored
|
58 |
* @param candidates a Matches object created by another FeatureMatcher
|
59 |
* @return the candidates having a score greater than or equal to the
|
60 |
* threshold score. The scores are preserved from the original Matches
|
61 |
* object.
|
62 |
*/
|
63 |
public Matches match(Feature target, FeatureCollection candidates) {
|
64 |
Matches survivors = new Matches(candidates.getFeatureSchema());
|
65 |
Matches allMatches = (Matches) candidates; |
66 |
for (int i = 0; i < allMatches.size(); i++) { |
67 |
if (allMatches.getScore(i) >= minScore) {
|
68 |
survivors.add(allMatches.getFeature(i), allMatches.getScore(i)); |
69 |
} |
70 |
} |
71 |
return survivors;
|
72 |
} |
73 |
} |