use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.
the class SketchJsonTranslater method toCrossSectionDetail.
public static CrossSectionDetail toCrossSectionDetail(Survey survey, JSONObject json) throws JSONException {
Coord2D position = toCoord2D(json.getJSONObject(POSITION_TAG));
float angle = (float) json.getDouble(ANGLE_TAG);
String stationdId = json.getString(STATION_ID_TAG);
Station station = survey.getStationByName(stationdId);
CrossSectionDetail crossSectionDetail = new CrossSectionDetail(new CrossSection(station, angle), position);
return crossSectionDetail;
}
use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.
the class PocketTopoTxtImporter method extractOffset.
public static Coord2D extractOffset(Survey survey, String text, Space<Coord2D> projection) {
String stationsSection = getNamedSubSection(text, "STATIONS");
String[] lines = TextTools.toArrayOfLines(stationsSection);
Station guessedAnchorStation = survey.getOrigin();
Coord2D offset = getOffsetForNamedStation(lines, guessedAnchorStation);
if (offset == null) {
if (guessedAnchorStation.getConnectedOnwardLegs().size() > 0) {
Leg onward = guessedAnchorStation.getConnectedOnwardLegs().get(0);
guessedAnchorStation = onward.getDestination();
offset = getOffsetForNamedStation(lines, guessedAnchorStation);
Coord2D position = projection.getStationMap().get(guessedAnchorStation);
offset = offset.minus(position.flipVertically());
}
}
if (offset == null) {
// ¯\_(ツ)_/¯
offset = Coord2D.ORIGIN;
}
return offset;
}
use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.
the class PocketTopoTxtImporter method parseDataAndUpdateSurvey.
private static void parseDataAndUpdateSurvey(Survey survey, String fullText) {
String text = getSection(fullText, "DATA");
boolean firstStation = true;
for (String line : TextTools.toArrayOfLines(text)) {
String[] fields = line.split("\\t");
if (fields.length < 3) {
continue;
}
String fromStationName = fields[0];
String toStationName = fields[1];
float azimuth = Float.parseFloat(fields[2]);
float inclination = Float.parseFloat(fields[3]);
float distance = Float.parseFloat(fields[4]);
if (firstStation) {
survey.getOrigin().setName(fromStationName);
firstStation = false;
}
Station fromStation = survey.getStationByName(fromStationName);
survey.setActiveStation(fromStation);
if (toStationName.equals("")) {
Leg leg = new Leg(distance, azimuth, inclination);
SurveyUpdater.update(survey, leg);
} else {
Station toStation = new Station(toStationName);
Leg leg = new Leg(distance, azimuth, inclination, toStation, new Leg[] {});
SurveyUpdater.updateWithNewStation(survey, leg);
}
}
}
use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.
the class MetadataTranslater method translateAndUpdateActiveStation.
private static void translateAndUpdateActiveStation(Survey survey, JSONObject json) throws Exception {
try {
String activeStationName = json.getString(ACTIVE_STATION_TAG);
Station activeStation = survey.getStationByName(activeStationName);
survey.setActiveStation(activeStation);
} catch (JSONException exception) {
Log.e("Could not load active station: " + exception.toString());
throw new Exception("Error loading active station");
}
}
use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.
the class TableActivity method syncTableWithSurvey.
public void syncTableWithSurvey() {
Survey survey = getSurvey();
stationsToTableIndex.clear();
List<GraphToListTranslator.SurveyListEntry> tableEntries = graphToListTranslator.toChronoListOfSurveyListEntries(survey);
if (tableEntries.size() == 0) {
Toast.makeText(getApplicationContext(), R.string.no_data, Toast.LENGTH_SHORT).show();
}
final TableLayout tableLayout = findViewById(R.id.BodyTable);
tableLayout.removeAllViews();
for (GraphToListTranslator.SurveyListEntry entry : tableEntries) {
TableRow tableRow = (TableRow) LayoutInflater.from(this).inflate(R.layout.table_row, null);
final Map<TableCol, Object> map = GraphToListTranslator.createMap(entry);
for (TableCol col : TableCol.values()) {
if (col == TableCol.COMMENT) {
continue;
}
String display = map.containsKey(col) ? col.format(map.get(col)) : "?";
int id = TABLE_COL_BY_ANDROID_ID.get(col);
TextView textView = tableRow.findViewById(id);
textView.setText(display);
if (isActiveStation(map.get(col))) {
textView.setBackgroundColor(GraphView.HIGHLIGHT_COLOUR.intValue);
}
if (entry.getLeg().hasDestination()) {
textView.setTypeface(textView.getTypeface(), Typeface.BOLD);
} else {
textView.setTypeface(textView.getTypeface(), Typeface.NORMAL);
}
fieldToSurveyEntry.put(textView, entry);
fieldToTableCol.put(textView, col);
textView.setOnLongClickListener(this);
}
int rowCount = tableLayout.getChildCount();
tableLayout.addView(tableRow, rowCount);
if (entry.getLeg().hasDestination()) {
Station to = entry.getLeg().getDestination();
stationsToTableIndex.put(to, rowCount);
}
}
tableLayout.requestLayout();
}
Aggregations