@Override public void onClick(View v) { Button b = (Button) v; // TopoDroidLog.Log( TopoDroidLog.LOG_INPUT, "LongLatAltDialog onClick() button " + // b.getText().toString() ); boolean north = mBtnNS.getText().toString().equals("N"); boolean east = mBtnEW.getText().toString().equals("E"); if (b == mBtnNS) { mBtnNS.setText(north ? "S" : "N"); return; } else if (b == mBtnEW) { mBtnEW.setText(east ? "W" : "E"); return; } else if (b == mBtnOK) { String longit = mEditLong.getText().toString(); // TODO convert string to dec-degrees if (longit == null || longit.length() == 0) { mEditLong.setError(mContext.getResources().getString(R.string.error_long_required)); return; } String latit = mEditLat.getText().toString(); if (latit == null || latit.length() == 0) { mEditLat.setError(mContext.getResources().getString(R.string.error_lat_required)); return; } String altit = mEditAlt.getText().toString(); if (altit == null || altit.length() == 0) { mEditAlt.setError(mContext.getResources().getString(R.string.error_alt_required)); return; } double lng = FixedInfo.string2double(longit); if (lng < -1000) { mEditLong.setError(mContext.getResources().getString(R.string.error_long_required)); return; } double lat = FixedInfo.string2double(latit); if (lat < -1000) { mEditLat.setError(mContext.getResources().getString(R.string.error_lat_required)); return; } double alt = -1000.0; double asl = -1000.0; altit = altit.replace(",", "."); try { if (!mWGS84.isChecked()) { asl = Double.parseDouble(altit); // if ( TopoDroidSetting.mAltimetricLookup ) { Toast.makeText(mContext, R.string.lookup_wait, Toast.LENGTH_LONG).show(); double gh = GeodeticHeight.geodeticHeight(latit, longit); if (gh > -999) { alt = asl + gh; } else { Toast.makeText(mContext, R.string.lookup_fail, Toast.LENGTH_SHORT).show(); } } } else { alt = Double.parseDouble(altit); } } catch (NumberFormatException e) { mEditAlt.setError(mContext.getResources().getString(R.string.error_invalid_number)); return; } // if ( TopoDroidSetting.mAltimetricLookup ) { // Toast.makeText( mContext, R.string.lookup_wait, Toast.LENGTH_LONG ).show(); // if ( alt < -999 ) { // alt = asl + GeodeticHeight.geodeticHeight( latit, longit ); // } else if ( asl < -999 ) { // asl = alt - GeodeticHeight.geodeticHeight( latit, longit ); // } // } else { // use same value for both altitudes // if ( alt < -999 ) alt = 0; // if ( asl < -999 ) asl = 0; // } if (!north) lat = -lat; if (!east) lng = -lng; // Log.v("DistoX", "Long-Lat dialog add LNG " + lng + " LAT " + lat + " ALT " + alt + " " + // asl ); mParent.addFixedPoint(lng, lat, alt, asl); } onBackPressed(); }