use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.
the class GraphActivity method setViewLocation.
private void setViewLocation() {
Bundle bundle = getIntent().getExtras();
if (bundle != null && bundle.getString(SexyTopo.JUMP_TO_STATION) != null) {
String requestedStationName = bundle.getString(SexyTopo.JUMP_TO_STATION);
Station requestedStation = getSurvey().getStationByName(requestedStationName);
graphView.centreViewOnStation(requestedStation);
} else {
graphView.centreViewOnActiveStation();
}
}
use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.
the class SurveyJsonTranslater method createLegs.
public static void createLegs(Map<String, Station> namesToStations, JSONObject json) throws JSONException {
String fromStationName = json.getString(STATION_NAME_TAG);
Station station = namesToStations.get(fromStationName);
JSONArray array = json.getJSONArray(ONWARD_LEGS_TAG);
for (JSONObject object : Util.toList(array)) {
Leg leg = toLeg(namesToStations, object);
station.addOnwardLeg(leg);
}
}
use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.
the class SurveyJsonTranslater method toStation.
public static Station toStation(JSONObject json) throws JSONException {
String name = json.getString(STATION_NAME_TAG);
Station station = new Station(name);
try {
String comment = json.getString(COMMENT_TAG);
station.setComment(comment);
} catch (Exception ignore) {
// not ideal but not the end of the world; we'd probably prefer to have our data
}
try {
Direction direction = Direction.valueOf(json.getString(DIRECTION_TAG).toUpperCase());
station.setExtendedElevationDirection(direction);
} catch (Exception ignore) {
// not ideal but not the end of the world; we'd probably prefer to have our data
}
return station;
}
use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.
the class PocketTopoTxtExporter method exportStationCoords.
public static String exportStationCoords(Space<Coord2D> space) {
List<String> lines = new ArrayList<>();
lines.add("STATIONS");
for (Map.Entry<Station, Coord2D> entry : space.getStationMap().entrySet()) {
Coord2D coords = entry.getValue();
Station station = entry.getKey();
lines.add(coords.x + "\t" + coords.y + "\t" + station.getName());
}
lines.add("SHOTS");
for (Line<Coord2D> line : space.getLegMap().values()) {
Coord2D start = line.getStart();
Coord2D end = line.getEnd();
lines.add(start.x + "\t" + start.y + "\t" + end.x + "\t" + end.y);
}
return TextTools.join("\n", lines);
}
use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.
the class SurvexImporter method addLegToSurvey.
private static void addLegToSurvey(Survey survey, Map<String, Station> nameToStation, String[] fields, String comment) {
String fromName = fields[0];
String toName = fields[1];
float distance = Float.parseFloat(fields[2]);
float azimuth = Float.parseFloat(fields[3]);
float inclination = Float.parseFloat(fields[4]);
if (nameToStation.size() == 0) {
Station origin = new Station(fromName);
survey.setOrigin(origin);
nameToStation.put(origin.getName(), origin);
}
String commentInstructions = extractCommentInstructions(comment);
if (commentInstructions != null) {
comment = comment.replace(commentInstructions, "").trim();
}
Station from = retrieveOrCreateStation(nameToStation, fromName, "");
Station to = retrieveOrCreateStation(nameToStation, toName, comment);
Leg[] promotedFrom = parseAnyPromotedLegs(commentInstructions);
Leg leg = (to == Survey.NULL_STATION) ? new Leg(distance, azimuth, inclination) : new Leg(distance, azimuth, inclination, to, promotedFrom);
from.addOnwardLeg(leg);
// bit of a hack; hopefully the last station processed will be the active one
survey.setActiveStation(from);
}
Aggregations