Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 265 → Rev 266

/trunk/src/org/tela_botanica/client/modeles/InformationCommuneDAO.java
51,36 → 51,42
.parse(response.getText());
 
if (responseValue.isObject() != null) {
EntiteGeographiqueObservation infos;
String idLocalite = "";
String nomCommune = "";
JSONObject resultat = responseValue.isObject();
JSONArray tableauCommune = resultat.get("geonames")
if(resultat != null && resultat.containsKey("geonames")) {
if(resultat.get("geonames").isArray() != null) {
JSONArray tableauCommune = resultat.get("geonames")
.isArray();
JSONObject objetCommune = tableauCommune.get(0)
.isObject();
 
/*String valeurCommune = objetCommune.get("name")
.isString().stringValue();
r.rafraichir(valeurCommune, false);*/
String pays = objetCommune.get("countryName").isString()
.stringValue();
if(!pays.equals("France")){
r.rafraichir("Aucune commune française n'a été trouvée à cet emplacement", false);
return;
if(tableauCommune.get(0) != null) {
if(tableauCommune.get(0).isObject() != null) {
JSONObject objetCommune = tableauCommune.get(0)
.isObject();
if(objetCommune.containsKey("name")) {
if(objetCommune.get("name").isString() != null) {
nomCommune = objetCommune.get(
"name").isString().stringValue();
}
}
if(objetCommune.containsKey("adminCode2")) {
if(objetCommune.get("adminCode2").isString() != null) {
idLocalite = objetCommune.get(
"adminCode2").isString().stringValue();
}
}
}
}
}
}
Double newLng = objetCommune.get("lng").isNumber()
.doubleValue();
Double newLat = objetCommune.get("lat").isNumber()
.doubleValue();
String nomCommune = objetCommune.get(
"name").isString().stringValue();
String idLocalite = objetCommune.get(
"adminCode2").isString().stringValue();
infos = new EntiteGeographiqueObservation(idLocalite, nomCommune, null, null);
infos.setLat(""+lat);
infos.setLon(""+lng);
Object[] infos = { lat, lng, idLocalite, nomCommune, newLat, newLng};
r.rafraichir(infos, false);
}
}
125,30 → 131,61
.parse(response.getText());
 
if (responseValue.isObject() != null) {
EntiteGeographiqueObservation infos;
String idLocalite = "";
String nomCommune = "";
Double lng = 0.0;
Double lat = 0.0;
 
JSONObject resultat = responseValue.isObject();
JSONArray tableauCommune = resultat.get(
"postalCodes").isArray();
 
if (tableauCommune.get(0) != null) {
JSONObject objetCommune = tableauCommune.get(0)
.isObject();
 
Double lng = objetCommune.get("lng").isNumber()
.doubleValue();
Double lat = objetCommune.get("lat").isNumber()
.doubleValue();
String nomCommune = objetCommune.get(
"placeName").isString().stringValue();
String idLocalite = objetCommune.get(
"adminCode2").isString().stringValue();
 
Object[] infos = { lat, lng, idLocalite, nomCommune};
 
 
r.rafraichir(infos, false);
if(resultat != null && resultat.containsKey("postalCodes")) {
if(resultat.get("postalCodes").isArray() != null) {
JSONArray tableauCommune = resultat.get("postalCodes")
.isArray();
if(tableauCommune.get(0) != null) {
if(tableauCommune.get(0).isObject() != null) {
JSONObject objetCommune = tableauCommune.get(0)
.isObject();
if(objetCommune.containsKey("lng")) {
if(objetCommune.get("lng").isNumber() != null) {
lng = objetCommune.get(
"lng").isNumber().doubleValue();
}
}
if(objetCommune.containsKey("lat")) {
if(objetCommune.get("lat").isNumber() != null) {
lat = objetCommune.get(
"lat").isNumber().doubleValue();
}
}
if(objetCommune.containsKey("adminCode2")) {
if(objetCommune.get("adminCode2").isString() != null) {
idLocalite = objetCommune.get(
"adminCode2").isString().stringValue();
}
}
if(objetCommune.containsKey("placeName")) {
if(objetCommune.get("placeName").isString() != null) {
nomCommune = objetCommune.get(
"placeName").isString().stringValue();
}
}
}
}
}
}
infos = new EntiteGeographiqueObservation(idLocalite, nomCommune, null, null);
infos.setLat(""+lat);
infos.setLon(""+lng);
r.rafraichir(infos, false);
}
}
}