use of org.hwyl.sexytopo.model.survey.Leg in project sexytopo by richsmith.
the class SurveyJsonTranslater method toJson.
public static JSONObject toJson(Station station, List<Leg> chronoList) throws JSONException {
JSONObject json = new JSONObject();
json.put(STATION_NAME_TAG, station.getName());
json.put(DIRECTION_TAG, station.getExtendedElevationDirection().toString().toLowerCase());
json.put(COMMENT_TAG, station.getComment());
JSONArray onwardLegsArray = new JSONArray();
for (Leg leg : station.getOnwardLegs()) {
int index = chronoList.indexOf(leg);
onwardLegsArray.put(toJson(leg, index));
}
json.put(ONWARD_LEGS_TAG, onwardLegsArray);
return json;
}
use of org.hwyl.sexytopo.model.survey.Leg in project sexytopo by richsmith.
the class ManualEntry method editLeg.
public static void editLeg(final TableActivity tableActivity, final Survey survey, final Leg toEdit) {
AlertDialog dialog = createDialog(R.layout.leg_edit_dialog, tableActivity, (edited, ignore) -> {
if (toEdit.hasDestination()) {
edited = new Leg(edited.getDistance(), edited.getAzimuth(), edited.getInclination(), toEdit.getDestination(), new Leg[] {});
}
if (toEdit.wasShotBackwards()) {
edited = edited.reverse();
}
SurveyUpdater.editLeg(survey, toEdit, edited);
tableActivity.getSurveyManager().broadcastSurveyUpdated();
tableActivity.syncTableWithSurvey();
});
dialog.setTitle(R.string.manual_edit_leg_title);
Leg editData = toEdit.wasShotBackwards() ? toEdit.reverse() : toEdit;
((TextView) (dialog.findViewById(R.id.editDistance))).setText(Float.toString(editData.getDistance()));
((TextView) (dialog.findViewById(R.id.editAzimuth))).setText(Float.toString(editData.getAzimuth()));
((TextView) (dialog.findViewById(R.id.editInclination))).setText(Float.toString(editData.getInclination()));
}
use of org.hwyl.sexytopo.model.survey.Leg in project sexytopo by richsmith.
the class ManualEntry method createDialog.
private static AlertDialog createDialog(int layoutId, final TableActivity tableActivity, final EditCallback editCallback) {
AlertDialog.Builder builder = new AlertDialog.Builder(tableActivity);
LayoutInflater inflater = tableActivity.getLayoutInflater();
final View dialogView = inflater.inflate(layoutId, null);
if (tableActivity.getBooleanPreference("pref_key_deg_mins_secs")) {
dialogView.findViewById(R.id.azimuth_standard).setVisibility(View.GONE);
dialogView.findViewById(R.id.azimuth_deg_mins_secs).setVisibility(View.VISIBLE);
}
builder.setView(dialogView).setTitle(R.string.manual_add_station_title).setPositiveButton("Save", (dialog, buttonId) -> {
/* Do nothing */
}).setNegativeButton("Cancel", (dialog, buttonId) -> {
/* Do nothing */
});
final AlertDialog dialog = builder.create();
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
dialog.show();
dialog.setButton(DialogInterface.BUTTON_POSITIVE, "Save", (dialogInterface, buttonId) -> {
Float distance = getFieldValue(dialog, R.id.editDistance);
Float inclination = getFieldValue(dialog, R.id.editInclination);
Float azimuth;
if (tableActivity.getBooleanPreference("pref_key_deg_mins_secs")) {
Float degrees = getFieldValue(dialog, R.id.editAzimuthDegrees);
Float minutes = getFieldValue(dialog, R.id.editAzimuthMinutes);
Float seconds = getFieldValue(dialog, R.id.editAzimuthSeconds);
if (degrees == null || minutes == null || seconds == null) {
azimuth = null;
} else {
azimuth = degrees + (minutes * (1.0f / 60.0f)) + (seconds * (1.0f / 60.0f) * (1.0f / 60.0f));
}
} else {
azimuth = getFieldValue(dialog, R.id.editAzimuth);
}
if (distance == null || !Leg.isDistanceLegal(distance)) {
TextView editDistance = dialogView.findViewById(R.id.editDistance);
editDistance.setError("Bad distance");
tableActivity.showSimpleToast("Bad distance");
} else if (azimuth == null || !Leg.isAzimuthLegal(azimuth)) {
TextView editAzimuth = dialogView.findViewById(R.id.editAzimuth);
tableActivity.showSimpleToast("Bad azimuth");
editAzimuth.setError("Bad azimuth");
} else if (inclination == null || !Leg.isInclinationLegal(inclination)) {
TextView editInclination = dialogView.findViewById(R.id.editInclination);
editInclination.setError("Bad inclination");
tableActivity.showSimpleToast("Bad inclination " + inclination);
} else {
dialogInterface.dismiss();
Leg leg = new Leg(distance, azimuth, inclination);
editCallback.submit(leg, dialog);
}
});
return dialog;
}
use of org.hwyl.sexytopo.model.survey.Leg in project sexytopo by richsmith.
the class Space3DTransformerForElevation method updateLeg.
protected void updateLeg(Space<Coord3D> space, Leg leg, Coord3D start) {
Leg adjustedLeg;
if (leg.getDestination().getExtendedElevationDirection() == Direction.LEFT) {
adjustedLeg = leg.adjustAzimuth(180);
} else {
adjustedLeg = leg.adjustAzimuth(0);
}
float delta = adjustedLeg.getAzimuth() - leg.getAzimuth();
Coord3D end = Space3DUtils.toCartesian(start, adjustedLeg);
Line<Coord3D> line = new Line<>(start, end);
space.addLeg(leg, line);
if (leg.hasDestination()) {
update(space, leg.getDestination(), end, delta);
}
}
use of org.hwyl.sexytopo.model.survey.Leg in project sexytopo by richsmith.
the class Space3DTransformerForElevation method updateSplay.
protected void updateSplay(Space<Coord3D> space, Leg leg, Coord3D start, float rotation) {
Leg adjustedLeg = leg.rotate(rotation);
Coord3D end = Space3DUtils.toCartesian(start, adjustedLeg);
Line<Coord3D> line = new Line<>(start, end);
space.addLeg(leg, line);
}
Aggregations