svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extGeocoding / src / org / gvsig / geocoding / results / OpGeocoLocation.java @ 27140
History | View | Annotate | Download (3.09 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 |
* 2009 Prodevelop S.L vsanjaime programador
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.geocoding.results; |
29 |
|
30 |
public class OpGeocoLocation implements Comparable { |
31 |
|
32 |
private int weight = 0; |
33 |
private boolean selected = false; |
34 |
private int quality = 0; |
35 |
private int accuracy = 0; |
36 |
private double x; |
37 |
private double y; |
38 |
|
39 |
/**
|
40 |
* Constructor
|
41 |
*/
|
42 |
public OpGeocoLocation() {
|
43 |
|
44 |
} |
45 |
|
46 |
/**
|
47 |
* Constructor
|
48 |
*/
|
49 |
public OpGeocoLocation(int quality, int accuracy, double x, double y) { |
50 |
this.quality = quality;
|
51 |
this.accuracy = accuracy;
|
52 |
this.x = x;
|
53 |
this.y = y;
|
54 |
calculateWeight(); |
55 |
} |
56 |
|
57 |
/**
|
58 |
* @return the selected
|
59 |
*/
|
60 |
public boolean isSelected() { |
61 |
return selected;
|
62 |
} |
63 |
|
64 |
/**
|
65 |
* @param selected
|
66 |
* the selected to set
|
67 |
*/
|
68 |
public void setSelected(boolean selected) { |
69 |
this.selected = selected;
|
70 |
} |
71 |
|
72 |
/**
|
73 |
* @return the quality
|
74 |
*/
|
75 |
public int getQuality() { |
76 |
return quality;
|
77 |
} |
78 |
|
79 |
/**
|
80 |
* @param quality
|
81 |
* the quality to set
|
82 |
*/
|
83 |
public void setQuality(int quality) { |
84 |
this.quality = quality;
|
85 |
calculateWeight(); |
86 |
} |
87 |
|
88 |
/**
|
89 |
* @return the accuracy
|
90 |
*/
|
91 |
public int getAccuracy() { |
92 |
return accuracy;
|
93 |
} |
94 |
|
95 |
/**
|
96 |
* @param accuracy
|
97 |
* the accuracy to set
|
98 |
*/
|
99 |
public void setAccuracy(int accuracy) { |
100 |
this.accuracy = accuracy;
|
101 |
calculateWeight(); |
102 |
} |
103 |
|
104 |
/**
|
105 |
* @return the x
|
106 |
*/
|
107 |
public double getX() { |
108 |
return x;
|
109 |
} |
110 |
|
111 |
/**
|
112 |
* @param x
|
113 |
* the x to set
|
114 |
*/
|
115 |
public void setX(double x) { |
116 |
this.x = x;
|
117 |
} |
118 |
|
119 |
/**
|
120 |
* @return the y
|
121 |
*/
|
122 |
public double getY() { |
123 |
return y;
|
124 |
} |
125 |
|
126 |
/**
|
127 |
* @param y
|
128 |
* the y to set
|
129 |
*/
|
130 |
public void setY(double y) { |
131 |
this.y = y;
|
132 |
} |
133 |
|
134 |
private void calculateWeight() { |
135 |
this.weight = (this.accuracy + this.quality) / 2; |
136 |
} |
137 |
|
138 |
/**
|
139 |
* @return the weight
|
140 |
*/
|
141 |
public int getWeight() { |
142 |
return weight;
|
143 |
} |
144 |
|
145 |
/**
|
146 |
* Compare with other OptionalLocation
|
147 |
*/
|
148 |
public int compareTo(Object obj) { |
149 |
|
150 |
int weight = ((OpGeocoLocation) obj).getWeight();
|
151 |
if (this.getWeight() > weight) { |
152 |
return -1; |
153 |
} else if (this.getWeight() < weight) { |
154 |
return 1; |
155 |
} else
|
156 |
return 0; |
157 |
} |
158 |
|
159 |
} |