Search in sources :

Example 71 with Station

use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.

the class GraphToListTranslator method createMap.

public static Map<TableCol, Object> createMap(SurveyListEntry entry) {
    Station from = entry.getFrom();
    Leg leg = entry.getLeg();
    Map<TableCol, Object> map = new HashMap<>();
    if (leg.hasDestination() && leg.getDestination().hasComment()) {
        map.put(TableCol.COMMENT, leg.getDestination().getComment());
    }
    if (leg.wasShotBackwards()) {
        map.put(TableCol.FROM, leg.getDestination());
        map.put(TableCol.TO, from);
        leg = leg.asBacksight();
    } else {
        map.put(TableCol.FROM, from);
        map.put(TableCol.TO, leg.getDestination());
    }
    map.put(TableCol.DISTANCE, leg.getDistance());
    map.put(TableCol.AZIMUTH, leg.getAzimuth());
    map.put(TableCol.INCLINATION, leg.getInclination());
    return map;
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) HashMap(java.util.HashMap) TableCol(org.hwyl.sexytopo.model.table.TableCol) Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 72 with Station

use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.

the class LegMover method removeDownstreamStations.

private static void removeDownstreamStations(Leg leg, List<Station> stations) {
    if (!leg.hasDestination()) {
        return;
    }
    Station station = leg.getDestination();
    stations.remove(station);
    for (Leg onwardLeg : station.getConnectedOnwardLegs()) {
        removeDownstreamStations(onwardLeg, stations);
    }
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 73 with Station

use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.

the class SurveyUpdater method upgradeSplayToConnectedLeg.

public static void upgradeSplayToConnectedLeg(Survey survey, Leg leg, InputMode inputMode) {
    Station newStation = new Station(getNextStationName(survey));
    Leg newLeg = Leg.manuallyUpgradeSplayToConnectedLeg(leg, newStation);
    if (inputMode == InputMode.BACKWARD) {
        newLeg = newLeg.reverse();
    }
    editLeg(survey, leg, newLeg);
    survey.setActiveStation(newStation);
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 74 with Station

use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.

the class SurveyUpdater method createNewStationIfBacksight.

private static boolean createNewStationIfBacksight(Survey survey) {
    // Examine splays of the current active station to determine if the previous two were a
    // foreward and backsight; if so, promote to a new named station
    Station activeStation = survey.getActiveStation();
    List<Leg> activeLegs = activeStation.getOnwardLegs();
    if (activeLegs.size() < 2) {
        return false;
    }
    List<Leg> lastPair = survey.getLastNLegs(2);
    if (lastPair.size() < 2) {
        return false;
    }
    for (Leg leg : lastPair) {
        if (!activeLegs.contains(leg)) {
            return false;
        }
    }
    Leg fore = lastPair.get(lastPair.size() - 2);
    // TODO: check for "reverse mode" to see if backsight comes first?
    Leg back = lastPair.get(lastPair.size() - 1);
    if (areLegsBacksights(fore, back)) {
        Station newStation = new Station(getNextStationName(survey));
        newStation.setExtendedElevationDirection(activeStation.getExtendedElevationDirection());
        Leg newLeg = averageBacksights(fore, back);
        newLeg = Leg.manuallyUpgradeSplayToConnectedLeg(newLeg, newStation);
        survey.undoAddLeg();
        survey.undoAddLeg();
        activeStation.getOnwardLegs().add(newLeg);
        survey.addLegRecord(newLeg);
        survey.setActiveStation(newStation);
        return true;
    }
    return false;
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 75 with Station

use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.

the class SurveyUpdater method createNewStationIfTripleShot.

private static boolean createNewStationIfTripleShot(Survey survey, boolean backsightMode) {
    int requiredNumber = SexyTopo.NUM_OF_REPEATS_FOR_NEW_STATION;
    Station activeStation = survey.getActiveStation();
    List<Leg> activeLegs = activeStation.getOnwardLegs();
    if (activeLegs.size() < requiredNumber) {
        return false;
    }
    List<Leg> lastNLegs = survey.getLastNLegs(requiredNumber);
    if (lastNLegs.size() < requiredNumber) {
        return false;
    }
    // check all the last legs are from the active station
    for (Leg leg : lastNLegs) {
        if (!activeLegs.contains(leg)) {
            return false;
        }
    }
    if (areLegsAboutTheSame(lastNLegs)) {
        Station newStation = new Station(getNextStationName(survey));
        newStation.setExtendedElevationDirection(activeStation.getExtendedElevationDirection());
        Leg newLeg = averageLegs(lastNLegs);
        newLeg = Leg.upgradeSplayToConnectedLeg(newLeg, newStation, lastNLegs.toArray(new Leg[] {}));
        if (backsightMode) {
            newLeg = newLeg.reverse();
        }
        for (int i = 0; i < requiredNumber; i++) {
            survey.undoAddLeg();
        }
        activeStation.getOnwardLegs().add(newLeg);
        survey.addLegRecord(newLeg);
        survey.setActiveStation(newStation);
        return true;
    }
    return false;
}
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