Search in sources :

Example 6 with Station

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

the class SurvexImporter method parse.

public static void parse(String text, Survey survey) {
    Map<String, Station> nameToStation = new HashMap<>();
    Station origin = survey.getOrigin();
    nameToStation.put(origin.getName(), origin);
    String[] lines = text.split("\n");
    for (String line : lines) {
        if (line.trim().equals("")) {
            continue;
        }
        String comment = "";
        if (line.contains(";")) {
            comment = line.substring(line.indexOf(";") + 1).trim();
        }
        String[] fields = line.trim().split("\t");
        addLegToSurvey(survey, nameToStation, fields, comment);
    }
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) HashMap(java.util.HashMap)

Example 7 with Station

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

the class SurveyStats method calcHeightRange.

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

Example 8 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) {
    Station newStation = new Station(getNextStationName(survey));
    Leg newLeg = Leg.upgradeSplayToConnectedLeg(leg, newStation);
    editLeg(survey, leg, newLeg);
    survey.setActiveStation(newStation);
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 9 with Station

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

the class GraphView method findNearestStationWithinDelta.

private static Station findNearestStationWithinDelta(Space<Coord2D> space, Coord2D target, float delta) {
    float shortest = Float.MAX_VALUE;
    Station best = null;
    for (Station station : space.getStationMap().keySet()) {
        Coord2D point = space.getStationMap().get(station);
        // noinspection ConstantConditions
        float distance = Space2DUtils.getDistance(point, target);
        if (distance > delta) {
            continue;
        }
        if (best == null || (distance < shortest)) {
            best = station;
            shortest = distance;
        }
    }
    return best;
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D)

Example 10 with Station

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

the class GraphView method checkForStation.

private Station checkForStation(Coord2D touchPointOnView) {
    float selectionTolerance = SELECTION_SENSITIVITY_IN_PIXELS / surveyToViewScale;
    Coord2D touchPointOnSurvey = viewCoordsToSurveyCoords(touchPointOnView);
    Station newSelectedStation = findNearestStationWithinDelta(projection, touchPointOnSurvey, selectionTolerance);
    // this could be null if nothing is near
    return newSelectedStation;
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D)

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