String format = LogicConstants.get(
"FORMATO_COORDENADAS_MAPA", "UTM");
if (format.equals(LogicConstants.COORD_UTM)) {
UTM u = new UTM(LogicConstants.getInt("ZONA_UTM"));
LatLon ll = u.eastNorth2latlon(new EastNorth(x, y));
view.zoomTo(Main.proj.latlon2eastNorth(ll), view
.getScale());
} else {
// en el latlong la x y la y van al reves
view.zoomTo(Main.proj
.latlon2eastNorth(new LatLon(x, y)), view
.getScale());
}
} else if (centerOptions.getSelectedItem().equals(
i18n.getString("map.street"))) {
Routing r = RoutingConsultas.find(street.getText());
if (r != null && r.getGeometria() != null) {
Point center = r.getGeometria().getCentroid()
.getCentroid();
view
.zoomTo(Main.proj.latlon2eastNorth(new LatLon(
center.getY(), center.getX())), view
.getScale());
}
} else if (centerOptions.getSelectedItem().equals(
i18n.getString("map.incidence"))) {
final Object incidencia = incidences.getSelectedItem();
if (incidencia == null) {
return null;
}
Incidencia i = null;
if (incidencia instanceof Incidencia) {
i = (Incidencia) incidencia;
} else {
i = IncidenciaConsultas.find(incidencia.toString());
}
Geometry geom = i.getGeometria();
if (geom == null) {
return null;
}
Point center = geom.getCentroid();
view.zoomTo(Main.proj.latlon2eastNorth(new LatLon(center
.getY(), center.getX())), view.getScale());
return null;
} else if (centerOptions.getSelectedItem().equals(
i18n.getString("map.resource"))) {
final Object selectedItem = resources.getSelectedItem();
if (selectedItem == null) {
return null;
}
if (selectedItem instanceof Recurso) {
Recurso r = (Recurso) selectedItem;
HistoricoGPS h = null;
if (r.getId() != null) {
h = HistoricoGPSConsultas.lastGPSForRecurso(r);
} else
try {
h = r.getHistoricoGps();
} catch (Throwable t) {
h = null;
}
if (h == null) {
return null;
}
view.zoomTo(Main.proj.latlon2eastNorth(new LatLon(h
.getPosY(), h.getPosX())), view.getScale());
} else if (selectedItem instanceof String) {
String r = (String) selectedItem;
HistoricoGPS h = HistoricoGPSConsultas
.lastGPSForRecurso(r);
if (h == null) {
return null;
}
view.zoomTo(Main.proj.latlon2eastNorth(new LatLon(h
.getPosY(), h.getPosX())), view.getScale());
} else if (selectedItem instanceof GpxLayer) {
MyGpxLayer r = (MyGpxLayer) selectedItem;
if (r == null || r.getLatLon() == null) {
return null;