Search in sources :

Example 36 with Leg

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

the class SpaceFlipper method flipVertically.

@SuppressWarnings("ConstantConditions")
public static Space<Coord2D> flipVertically(Space<Coord2D> space) {
    Space<Coord2D> flippedSpace = new Space<>();
    Map<Station, Coord2D> stationMap = space.getStationMap();
    for (Station station : stationMap.keySet()) {
        Coord2D point = stationMap.get(station);
        flippedSpace.addStation(station, point.flipVertically());
    }
    Map<Leg, Line<Coord2D>> legMap = space.getLegMap();
    for (Leg leg : legMap.keySet()) {
        Line<Coord2D> line = legMap.get(leg);
        Coord2D start = line.getStart();
        Coord2D end = line.getEnd();
        Line<Coord2D> flippedLine = new Line<>(start.flipVertically(), end.flipVertically());
        flippedSpace.addLeg(leg, flippedLine);
    }
    return flippedSpace;
}
Also used : Space(org.hwyl.sexytopo.model.graph.Space) Station(org.hwyl.sexytopo.model.survey.Station) Line(org.hwyl.sexytopo.model.graph.Line) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 37 with Leg

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

the class GraphToListTranslator method createListOfEntriesFromStation.

private List<SurveyListEntry> createListOfEntriesFromStation(Station from) {
    List<SurveyListEntry> list = new ArrayList<>();
    for (Leg leg : from.getUnconnectedOnwardLegs()) {
        SurveyListEntry entry = new SurveyListEntry(from, leg);
        list.add(entry);
    }
    for (Leg leg : from.getConnectedOnwardLegs()) {
        SurveyListEntry entry = new SurveyListEntry(from, leg);
        list.add(entry);
        list.addAll(createListOfEntriesFromStation(leg.getDestination()));
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 38 with Leg

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

the class SpaceMover method move.

@SuppressWarnings("ConstantConditions")
public static Space<Coord2D> move(Space<Coord2D> space, Coord2D delta) {
    Space<Coord2D> moved = new Space<>();
    Map<Station, Coord2D> stationMap = space.getStationMap();
    for (Station station : stationMap.keySet()) {
        Coord2D point = stationMap.get(station);
        moved.addStation(station, point.plus(delta));
    }
    Map<Leg, Line<Coord2D>> legMap = space.getLegMap();
    for (Leg leg : legMap.keySet()) {
        Line<Coord2D> line = space.getLegMap().get(leg);
        Line<Coord2D> shiftedLine = new Line<>(line.getStart().plus(delta), line.getEnd().plus(delta));
        moved.addLeg(leg, shiftedLine);
    }
    return moved;
}
Also used : Space(org.hwyl.sexytopo.model.graph.Space) Station(org.hwyl.sexytopo.model.survey.Station) Line(org.hwyl.sexytopo.model.graph.Line) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 39 with Leg

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

the class SurveyTools method traverseIterator.

@SuppressWarnings("WhileLoopReplaceableByForEach")
public static boolean traverseIterator(Station station, SurveyLegTraversalCallback callback) {
    // use an iterator because the callback might mutate the list of legs
    Iterator<Leg> i = station.getOnwardLegs().iterator();
    while (i.hasNext()) {
        Leg leg = i.next();
        boolean isFinished = callback.call(station, leg);
        if (isFinished) {
            return isFinished;
        } else if (leg.hasDestination()) {
            return traverseLegs(leg.getDestination(), callback);
        }
    }
    return false;
}
Also used : Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 40 with Leg

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

the class TestSurveyCreator method createBranch.

public static void createBranch(Survey survey, int numStations) {
    for (int i = 0; i < numStations; i++) {
        float distance = 5 + random.nextInt(10);
        float azimuth = 40 + random.nextInt(100);
        float inclination = -20 + random.nextInt(40);
        Leg leg = new Leg(distance, azimuth, inclination);
        SurveyUpdater.updateWithNewStation(survey, leg);
        Station newStation = survey.getMostRecentLeg().getDestination();
        createLruds(survey, newStation);
    }
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) Leg(org.hwyl.sexytopo.model.survey.Leg)

Aggregations

Leg (org.hwyl.sexytopo.model.survey.Leg)94 Station (org.hwyl.sexytopo.model.survey.Station)30 Test (org.junit.Test)30 Survey (org.hwyl.sexytopo.model.survey.Survey)23 Coord3D (org.hwyl.sexytopo.model.graph.Coord3D)17 Line (org.hwyl.sexytopo.model.graph.Line)8 ArrayList (java.util.ArrayList)7 Coord2D (org.hwyl.sexytopo.model.graph.Coord2D)7 JSONArray (org.json.JSONArray)6 JSONObject (org.json.JSONObject)6 Space (org.hwyl.sexytopo.model.graph.Space)4 TextView (android.widget.TextView)3 GraphToListTranslator (org.hwyl.sexytopo.control.util.GraphToListTranslator)3 TableCol (org.hwyl.sexytopo.model.table.TableCol)3 JSONException (org.json.JSONException)3 AlertDialog (android.app.AlertDialog)2 ParseException (java.text.ParseException)2 HashMap (java.util.HashMap)2 LRUD (org.hwyl.sexytopo.model.table.LRUD)2 SuppressLint (android.annotation.SuppressLint)1