Subversion Repositories eFlore/Applications.cel

Rev

Rev 751 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 751 Rev 779
Line 1... Line 1...
1
package org.tela_botanica.client.modeles;
1
package org.tela_botanica.client.modeles;
Line 2... Line 2...
2
 
2
 
Line -... Line 3...
-
 
3
import org.tela_botanica.client.interfaces.Rafraichissable;
3
import org.tela_botanica.client.interfaces.Rafraichissable;
4
 
4
 
5
import com.google.gwt.core.client.GWT;
5
import com.google.gwt.http.client.Request;
6
import com.google.gwt.http.client.Request;
6
import com.google.gwt.http.client.RequestBuilder;
7
import com.google.gwt.http.client.RequestBuilder;
7
import com.google.gwt.http.client.RequestCallback;
8
import com.google.gwt.http.client.RequestCallback;
Line 130... Line 131...
130
							infos.setLat("");
131
							infos.setLat("");
131
							infos.setLon("");
132
							infos.setLon("");
Line 132... Line 133...
132
		
133
		
133
							r.rafraichir(infos, false);
134
							r.rafraichir(infos, false);
134
						}
135
						}
135
							
136
													
136
						final JSONValue responseValue = JSONParser
137
						final JSONValue responseValue = JSONParser
137
								.parse(response.getText());
138
								.parse(response.getText());
138
 
139
						
Line 139... Line 140...
139
						if (responseValue.isObject() != null) {
140
						if (responseValue.isObject() != null) {
140
							
141
							
141
							EntiteGeographiqueObservation infos;
142
							EntiteGeographiqueObservation infos;
142
							String idLocalite = "";
143
							String idLocalite = "";
143
							String nomCommune = "";
144
							String nomCommune = "";
144
							Double lng = 0.0;
145
							Double lng = 0.0;
145
							Double lat = 0.0;
146
							Double lat = 0.0;
-
 
147
								
-
 
148
							JSONObject objectRetour = responseValue.isObject();
-
 
149
							
-
 
150
							if(objectRetour.get("nom").isString() != null) {
Line 146... Line -...
146
 
-
 
147
							JSONObject resultat = responseValue.isObject();
-
 
148
							
-
 
149
							if(resultat != null && resultat.containsKey("postalCodes")) {
-
 
150
								if(resultat.get("postalCodes").isArray() != null) {
-
 
151
									JSONArray tableauCommune = resultat.get("postalCodes")
-
 
152
									.isArray();
-
 
153
									if(tableauCommune.get(0) != null) {
-
 
154
										if(tableauCommune.get(0).isObject() != null) {
-
 
155
											JSONObject objetCommune = tableauCommune.get(0)
-
 
156
											.isObject();
-
 
157
											
-
 
158
											if(objetCommune.containsKey("lng")) {
-
 
159
												if(objetCommune.get("lng").isNumber() != null)  {
-
 
160
													lng = objetCommune.get(
-
 
161
													"lng").isNumber().doubleValue();
-
 
162
												}
-
 
163
											}
-
 
164
											
-
 
165
											if(objetCommune.containsKey("lat")) {
-
 
166
												if(objetCommune.get("lat").isNumber() != null)  {
-
 
167
													lat = objetCommune.get(
-
 
168
													"lat").isNumber().doubleValue();
-
 
169
												}
-
 
170
											}
151
								nomCommune = objectRetour.get("nom").isString().stringValue();
171
											
-
 
172
											if(objetCommune.containsKey("adminCode2")) {
-
 
173
												if(objetCommune.get("adminCode2").isString() != null)  {
-
 
174
													idLocalite = objetCommune.get(
-
 
175
													"adminCode2").isString().stringValue();
-
 
176
												}
-
 
177
											}
152
							}
178
											
-
 
179
											if(objetCommune.containsKey("placeName")) {
-
 
180
												if(objetCommune.get("placeName").isString() != null)  {
-
 
181
													nomCommune = objetCommune.get(
-
 
182
													"placeName").isString().stringValue();
-
 
183
												}
-
 
184
											}
-
 
185
										}
153
							
Line -... Line 154...
-
 
154
							if(objectRetour.get("code_insee").isString() != null) {
-
 
155
								idLocalite = objectRetour.get("code_insee").isString().stringValue().substring(0, 2);
-
 
156
							}
-
 
157
							
-
 
158
							if(objectRetour.get("lat").isNumber() != null) {
-
 
159
								lat = objectRetour.get("lat").isNumber().doubleValue();
-
 
160
							}
-
 
161
							
-
 
162
							if(objectRetour.get("lng").isNumber() != null) {
186
									}
163
								lng = objectRetour.get("lng").isNumber().doubleValue();
187
								}
164
							}
188
							}
165
 
189
							
166
							
190
							infos = new EntiteGeographiqueObservation(idLocalite, nomCommune, null, null);
167
							infos = new EntiteGeographiqueObservation(idLocalite, nomCommune, null, null);
191
							infos.setLat(""+lat);
168
							infos.setLat(""+lat);
192
							infos.setLon(""+lng);
169
							infos.setLon(""+lng);
193
		
170
							
194
							r.rafraichir(infos, false);
171
							r.rafraichir(infos, false);