use of org.hwyl.sexytopo.model.survey.Trip in project sexytopo by richsmith.
the class SurveyChecker method areEqual.
public static boolean areEqual(Survey one, Survey two) {
List<Station> oneStations = one.getAllStations();
List<Station> twoStations = two.getAllStations();
if (oneStations.size() != twoStations.size()) {
return false;
}
for (Station station : one.getAllStations()) {
Station other = two.getStationByName(station.getName());
if (!areEqual(station, other)) {
return false;
}
}
Trip oneTrip = one.getTrip();
Trip twoTrip = two.getTrip();
if ((oneTrip == null) ^ (twoTrip == null)) {
return false;
}
if (oneTrip != null) {
if (!oneTrip.equalsTripData(twoTrip)) {
return false;
}
}
return true;
}
use of org.hwyl.sexytopo.model.survey.Trip in project sexytopo by richsmith.
the class SurveyJsonTranslater method toSurvey.
public static void toSurvey(Survey survey, JSONObject json) throws JSONException, ParseException {
errors = false;
String name = json.getString(SURVEY_NAME_TAG);
if (!survey.getName().equals(name)) {
Log.e("This is weird; the survey name in the file is different to the filename. " + "Assuming filename is the correct name.");
}
try {
// have to parse trips before stations etc. so trips can be referenced by them
if (json.has(TRIP_TAG)) {
JSONObject tripObject = json.getJSONObject(TRIP_TAG);
Trip trip = toTrip(tripObject);
survey.setTrip(trip);
}
} catch (JSONException exception) {
Log.e("Failed to load trip: " + exception);
// carry on... unfortunate, but not *that* important
}
try {
JSONArray stationsArray = json.getJSONArray(STATIONS_TAG);
loadSurveyData(survey, stationsArray);
} catch (JSONException exception) {
Log.e("Failed to load stations: " + exception);
}
try {
String activeStationName = json.getString(ACTIVE_STATION_TAG);
Station activeStation = survey.getStationByName(activeStationName);
survey.setActiveStation(activeStation);
} catch (Exception ignore) {
// ah, never mind... not mission-critical
}
if (errors) {
String message = "Partial errors encountered; survey load was incomplete";
Toast.makeText(SexyTopo.context, message, Toast.LENGTH_SHORT).show();
}
}
use of org.hwyl.sexytopo.model.survey.Trip in project sexytopo by richsmith.
the class SurveyJsonTranslater method toJson.
public static JSONObject toJson(Trip trip) throws JSONException {
JSONObject json = new JSONObject();
DateFormat dateFormat = new SimpleDateFormat(DATE_PATTERN);
String date = dateFormat.format(trip.getDate());
json.put(TRIP_DATE_TAG, date);
json.put(COMMENT_TAG, trip.getComments());
JSONArray teamArray = new JSONArray();
for (Trip.TeamEntry teamEntry : trip.getTeam()) {
JSONObject teamEntryJson = new JSONObject();
teamEntryJson.put(TEAM_MEMBER_NAME_TAG, teamEntry.name);
JSONArray rolesJson = new JSONArray();
for (Trip.Role role : teamEntry.roles) {
rolesJson.put(role.name());
}
teamEntryJson.put(TEAM_MEMBER_ROLE_TAG, rolesJson);
teamArray.put(teamEntryJson);
}
json.put(TEAM_TAG, teamArray);
return json;
}
use of org.hwyl.sexytopo.model.survey.Trip in project sexytopo by richsmith.
the class PocketTopoTxtExporter method getContent.
public String getContent(Survey survey) {
String text = "TRIP\n";
text += "DATE ";
if (survey.getTrip() != null) {
Trip trip = survey.getTrip();
Date date = trip.getDate();
text += TextTools.toIsoDate(date);
} else {
text += "1970-01-01\n";
}
text += "\n";
text += "DECLINATION\t0.00\n";
text += exportData(survey) + "\n";
text += exportPlan(survey) + "\n";
text += exportExtendedElevation(survey);
return text;
}
use of org.hwyl.sexytopo.model.survey.Trip in project sexytopo by richsmith.
the class ThExporter method getCentreline.
private static String getCentreline(Survey survey) {
GraphToListTranslator graphToListTranslator = new GraphToListTranslator();
StringBuilder builder = new StringBuilder();
Trip trip = survey.getTrip();
if (trip != null) {
builder.append(formatTrip(trip));
}
builder.append("data normal from to length compass clino\n\n");
List<GraphToListTranslator.SurveyListEntry> list = graphToListTranslator.toChronoListOfSurveyListEntries(survey);
for (GraphToListTranslator.SurveyListEntry entry : list) {
SurvexTherionUtil.formatEntry(builder, entry, COMMENT_CHAR);
builder.append("\n");
}
return builder.toString();
}
Aggregations