Search in sources :

Example 41 with Station

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

the class SurveyStats method calcHeightRangeArray.

public static float[] calcHeightRangeArray(Survey survey) {
    Space3DTransformer transformer = new Space3DTransformer();
    Space<Coord3D> space = transformer.transformTo3D(survey);
    Map<Station, Coord3D> stationsToCoords = space.getStationMap();
    if (stationsToCoords.size() <= 1) {
        return new float[] { 0, 0 };
    }
    float min = Float.MAX_VALUE, max = Float.MIN_VALUE;
    for (Coord3D point : space.getStationMap().values()) {
        max = Math.max(max, point.z);
        min = Math.min(min, point.z);
    }
    return new float[] { min, max };
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) Coord3D(org.hwyl.sexytopo.model.graph.Coord3D)

Example 42 with Station

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

the class LegMover method getValidDestinations.

public static List<Station> getValidDestinations(Survey survey, Leg leg) {
    List<Station> stations = survey.getAllStations();
    Station originatingStation = survey.getOriginatingStation(leg);
    stations.remove(originatingStation);
    removeDownstreamStations(leg, stations);
    return stations;
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station)

Example 43 with Station

use of org.hwyl.sexytopo.model.survey.Station 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 44 with Station

use of org.hwyl.sexytopo.model.survey.Station 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)

Example 45 with Station

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

the class SurveyUpdater method updateWithNewStation.

public static void updateWithNewStation(Survey survey, Leg leg) {
    Station activeStation = survey.getActiveStation();
    if (!leg.hasDestination()) {
        Station newStation = new Station(StationNamer.generateNextStationName(survey, activeStation));
        leg = Leg.manuallyUpgradeSplayToConnectedLeg(leg, newStation);
    }
    // FIXME; could the below be moved into Survey? And from elsewhere in this file?
    activeStation.getOnwardLegs().add(leg);
    survey.setSaved(false);
    survey.addLegRecord(leg);
    survey.setActiveStation(leg.getDestination());
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station)

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