Search in sources :

Example 61 with Station

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();
    }
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) Bundle(android.os.Bundle)

Example 62 with Station

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);
    }
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 63 with Station

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;
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) Direction(org.hwyl.sexytopo.model.graph.Direction) JSONException(org.json.JSONException) ParseException(java.text.ParseException)

Example 64 with 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);
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) ArrayList(java.util.ArrayList) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Map(java.util.Map)

Example 65 with Station

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);
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) Leg(org.hwyl.sexytopo.model.survey.Leg)

Aggregations

Station (org.hwyl.sexytopo.model.survey.Station)85 Leg (org.hwyl.sexytopo.model.survey.Leg)32 Survey (org.hwyl.sexytopo.model.survey.Survey)30 Coord2D (org.hwyl.sexytopo.model.graph.Coord2D)20 Test (org.junit.Test)19 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)9 SuppressLint (android.annotation.SuppressLint)8 AlertDialog (android.app.AlertDialog)8 JSONException (org.json.JSONException)7 Line (org.hwyl.sexytopo.model.graph.Line)6 SurveyConnection (org.hwyl.sexytopo.model.survey.SurveyConnection)6 JSONObject (org.json.JSONObject)6 View (android.view.View)5 Set (java.util.Set)5 Direction (org.hwyl.sexytopo.model.graph.Direction)5 Space (org.hwyl.sexytopo.model.graph.Space)5 JSONArray (org.json.JSONArray)5 Context (android.content.Context)4 HashSet (java.util.HashSet)4