View Javadoc
1   /*******************************************************************************
2    *   Gisgraphy Project 
3    * 
4    *   This library is free software; you can redistribute it and/or
5    *   modify it under the terms of the GNU Lesser General Public
6    *   License as published by the Free Software Foundation; either
7    *   version 2.1 of the License, or (at your option) any later version.
8    * 
9    *   This library is distributed in the hope that it will be useful,
10   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   *   Lesser General Public License for more details.
13   * 
14   *   You should have received a copy of the GNU Lesser General Public
15   *   License along with this library; if not, write to the Free Software
16   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
17   * 
18   *  Copyright 2008  Gisgraphy project 
19   *  David Masclet <davidmasclet@gisgraphy.com>
20   *  
21   *  
22   *******************************************************************************/
23  
24  package com.gisgraphy.importer.dto;
25  
26  import com.vividsolutions.jts.geom.Point;
27  
28  
29  /**
30   * Represents a house number with an associated street in the Karlsruhe schema.
31   * 
32   * @author <a href="mailto:david.masclet@gisgraphy.com">David Masclet</a>
33   */
34  public class InterpolationMember implements Comparable<InterpolationMember>{
35  	
36  	
37  
38  	/**
39  	 * id of the node
40  	 */
41  	private String id;
42  	/**
43  	 * the ordered sequence of nodes
44  	 */
45  	private int sequenceId;
46  	/**
47  	 * the gis location of the member (middle point or location )
48  	 */
49  	private Point location;
50  
51  	/**
52  	 * the number of the house. It is a string because of latin that is can have bis ter or a letter (3c)
53  	 */
54  	private String houseNumber;
55  	
56  	/**
57  	 * the name of the street 
58  	 */
59  	private String streetname;
60  
61  	public InterpolationMember(String id, int sequenceId, Point location, String houseNumber, String streetname) {
62  		super();
63  		this.id = id;
64  		this.sequenceId = sequenceId;
65  		this.location = location;
66  		this.houseNumber = houseNumber;
67  		this.streetname = streetname;
68  	}
69  
70  	public InterpolationMember() {
71  	}
72  	
73  	/**
74  	 * @return the id
75  	 */
76  	public String getId() {
77  		return id;
78  	}
79  
80  	/**
81  	 * @param id the id to set
82  	 */
83  	public void setId(String id) {
84  		this.id = id;
85  	}
86  
87  	/**
88  	 * @return the sequenceId
89  	 */
90  	public int getSequenceId() {
91  		return sequenceId;
92  	}
93  
94  	/**
95  	 * @param sequenceId the sequenceId to set
96  	 */
97  	public void setSequenceId(int sequenceId) {
98  		this.sequenceId = sequenceId;
99  	}
100 
101 	/**
102 	 * @return the location
103 	 */
104 	public Point getLocation() {
105 		return location;
106 	}
107 
108 	/**
109 	 * @param location the location to set
110 	 */
111 	public void setLocation(Point location) {
112 		this.location = location;
113 	}
114 
115 	/**
116 	 * @return the streetname
117 	 */
118 	public String getStreetname() {
119 		return streetname;
120 	}
121 
122 	/**
123 	 * @param streetname the streetname to set
124 	 */
125 	public void setStreetname(String streetname) {
126 		this.streetname = streetname;
127 	}
128 
129 	/**
130 	 * @return the houseNumber
131 	 */
132 	public String getHouseNumber() {
133 		return houseNumber;
134 	}
135 
136 	/**
137 	 * @param houseNumber the houseNumber to set
138 	 */
139 	public void setHouseNumber(String houseNumber) {
140 		this.houseNumber = houseNumber;
141 	}
142 
143 	/* (non-Javadoc)
144 	 * @see java.lang.Object#hashCode()
145 	 */
146 	@Override
147 	public int hashCode() {
148 		final int prime = 31;
149 		int result = 1;
150 		result = prime * result + ((houseNumber == null) ? 0 : houseNumber.hashCode());
151 		result = prime * result + ((id == null) ? 0 : id.hashCode());
152 		result = prime * result + ((location == null) ? 0 : location.hashCode());
153 		result = prime * result + sequenceId;
154 		result = prime * result + ((streetname == null) ? 0 : streetname.hashCode());
155 		return result;
156 	}
157 
158 	/* (non-Javadoc)
159 	 * @see java.lang.Object#equals(java.lang.Object)
160 	 */
161 	@Override
162 	public boolean equals(Object obj) {
163 		if (this == obj)
164 			return true;
165 		if (obj == null)
166 			return false;
167 		if (getClass() != obj.getClass())
168 			return false;
169 		InterpolationMember other = (InterpolationMember) obj;
170 		if (houseNumber == null) {
171 			if (other.houseNumber != null)
172 				return false;
173 		} else if (!houseNumber.equals(other.houseNumber))
174 			return false;
175 		if (id == null) {
176 			if (other.id != null)
177 				return false;
178 		} else if (!id.equals(other.id))
179 			return false;
180 		if (location == null) {
181 			if (other.location != null)
182 				return false;
183 		} else if (!location.equals(other.location))
184 			return false;
185 		if (sequenceId != other.sequenceId)
186 			return false;
187 		if (streetname == null) {
188 			if (other.streetname != null)
189 				return false;
190 		} else if (!streetname.equals(other.streetname))
191 			return false;
192 		return true;
193 	}
194 
195 	/* (non-Javadoc)
196 	 * @see java.lang.Object#toString()
197 	 */
198 	@Override
199 	public String toString() {
200 		StringBuilder builder = new StringBuilder();
201 		builder.append("InterpolationMember [");
202 		if (id != null) {
203 			builder.append("id=");
204 			builder.append(id);
205 			builder.append(", ");
206 		}
207 		builder.append("sequenceId=");
208 		builder.append(sequenceId);
209 		builder.append(", ");
210 		if (location != null) {
211 			builder.append("location=");
212 			builder.append(location);
213 			builder.append(", ");
214 		}
215 		if (houseNumber != null) {
216 			builder.append("houseNumber=");
217 			builder.append(houseNumber);
218 			builder.append(", ");
219 		}
220 		if (streetname != null) {
221 			builder.append("streetname=");
222 			builder.append(streetname);
223 		}
224 		builder.append("]");
225 		return builder.toString();
226 	}
227 
228 	public int compareTo(InterpolationMember o) {
229 		return sequenceId - o.sequenceId;
230 	}
231 	
232 	
233 
234 }