svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libGeocoding / src / org / gvsig / geocoding / result / impl / DefaultScoredFeature.java @ 28375
History | View | Annotate | Download (2.78 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2008 Prodevelop S.L. main development
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.geocoding.result.impl; |
29 |
|
30 |
import org.gvsig.fmap.dal.exception.DataException; |
31 |
import org.gvsig.fmap.dal.feature.Feature; |
32 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
33 |
import org.gvsig.geocoding.result.ScoredFeature; |
34 |
|
35 |
/**
|
36 |
* Feature with a new attribute named score. the score define the score of the
|
37 |
* feature in the search proces.
|
38 |
*
|
39 |
* @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a>
|
40 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a>
|
41 |
*/
|
42 |
|
43 |
public class DefaultScoredFeature implements ScoredFeature { |
44 |
|
45 |
private double score; |
46 |
private FeatureReference reference;
|
47 |
|
48 |
/**
|
49 |
* Get score of search
|
50 |
*
|
51 |
* @return
|
52 |
*/
|
53 |
public double getScore() { |
54 |
return score;
|
55 |
} |
56 |
|
57 |
/**
|
58 |
* Set score of search
|
59 |
*
|
60 |
* @param score
|
61 |
*/
|
62 |
public void setScore(double score) { |
63 |
this.score = score;
|
64 |
} |
65 |
|
66 |
/**
|
67 |
* Get Feature reference
|
68 |
*
|
69 |
* @return
|
70 |
*/
|
71 |
public FeatureReference getReference() {
|
72 |
return reference;
|
73 |
} |
74 |
|
75 |
/**
|
76 |
* Set feature reference
|
77 |
*
|
78 |
* @param reference
|
79 |
*/
|
80 |
public void setReference(FeatureReference reference) { |
81 |
this.reference = reference;
|
82 |
} |
83 |
|
84 |
/**
|
85 |
* get feature
|
86 |
*
|
87 |
* @return
|
88 |
* @throws DataException
|
89 |
*/
|
90 |
public Feature getFeature() throws DataException { |
91 |
return this.getReference().getFeature(); |
92 |
} |
93 |
|
94 |
/**
|
95 |
* Compare with other ScoredFeature
|
96 |
*
|
97 |
* @param feat
|
98 |
*/
|
99 |
public int compareTo(ScoredFeature feat) { |
100 |
|
101 |
double score = feat.getScore();
|
102 |
if (this.getScore() > score) { |
103 |
return -1; |
104 |
} else if (this.getScore() < score) { |
105 |
return 1; |
106 |
} else
|
107 |
return 0; |
108 |
} |
109 |
|
110 |
/**
|
111 |
* Set feature and store reference
|
112 |
*
|
113 |
* @param fea
|
114 |
*/
|
115 |
public void setFeature(Feature fea) { |
116 |
this.setReference(fea.getReference());
|
117 |
|
118 |
} |
119 |
|
120 |
} |