Search in sources :

Example 46 with Leg

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

the class Space3DTransformerTest method testTransform3N3E3S3W.

@Test
public void testTransform3N3E3S3W() {
    Leg n3 = new Leg(3, 0, 0);
    Coord3D result = transformer.transform(Coord3D.ORIGIN, n3);
    Leg e3 = new Leg(3, 90, 0);
    result = transformer.transform(result, e3);
    Leg s3 = new Leg(3, 180, 0);
    result = transformer.transform(result, s3);
    Leg w3 = new Leg(3, 270, 0);
    result = transformer.transform(result, w3);
    assertEquals(Coord3D.ORIGIN, result);
}
Also used : Coord3D(org.hwyl.sexytopo.model.graph.Coord3D) Leg(org.hwyl.sexytopo.model.survey.Leg) Test(org.junit.Test)

Example 47 with Leg

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

the class Space3DTransformerTest method testTransform1MEast.

@Test
public void testTransform1MEast() {
    Leg east1MLeg = new Leg(1, 90, 0);
    Coord3D result = transformer.transform(Coord3D.ORIGIN, east1MLeg);
    Coord3D expected = new Coord3D(1, 0, 0);
    assertEquals(expected, result);
}
Also used : Coord3D(org.hwyl.sexytopo.model.graph.Coord3D) Leg(org.hwyl.sexytopo.model.survey.Leg) Test(org.junit.Test)

Example 48 with Leg

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

the class Space3DTransformerTest method testTransform2MNorth.

@Test
public void testTransform2MNorth() {
    Leg north2MLeg = new Leg(2, 0, 0);
    Coord3D result = transformer.transform(Coord3D.ORIGIN, north2MLeg);
    Coord3D expected = new Coord3D(0, 2, 0);
    assertEquals(expected, result);
}
Also used : Coord3D(org.hwyl.sexytopo.model.graph.Coord3D) Leg(org.hwyl.sexytopo.model.survey.Leg) Test(org.junit.Test)

Example 49 with Leg

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

the class MeasurementProtocol method go.

public void go(DataInputStream inStream, DataOutputStream outStream) throws Exception {
    Log.device(context.getString(R.string.device_log_ready_for_measurements));
    byte[] packet = readPacket(inStream);
    if (packet == null) {
        return;
    }
    acknowledge(outStream, packet);
    if (isDataPacket(packet)) {
        if (arePacketsTheSame(packet, previousPacket)) {
            Log.device("(Duplicated measurement #" + ++duplicateCount + ")");
        } else {
            duplicateCount = 0;
            Log.device(context.getString(R.string.device_log_received));
            Leg leg = parseDataPacket(packet);
            dataManager.updateSurvey(leg);
        }
    }
    previousPacket = packet;
}
Also used : Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 50 with Leg

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

the class PocketTopoTxtImporter method extractOffset.

public static Coord2D extractOffset(Survey survey, String text, Space<Coord2D> projection) {
    String stationsSection = getNamedSubSection(text, "STATIONS");
    String[] lines = TextTools.toArrayOfLines(stationsSection);
    Station guessedAnchorStation = survey.getOrigin();
    Coord2D offset = getOffsetForNamedStation(lines, guessedAnchorStation);
    if (offset == null) {
        if (guessedAnchorStation.getConnectedOnwardLegs().size() > 0) {
            Leg onward = guessedAnchorStation.getConnectedOnwardLegs().get(0);
            guessedAnchorStation = onward.getDestination();
            offset = getOffsetForNamedStation(lines, guessedAnchorStation);
            Coord2D position = projection.getStationMap().get(guessedAnchorStation);
            offset = offset.minus(position.flipVertically());
        }
    }
    if (offset == null) {
        // ¯\_(ツ)_/¯
        offset = Coord2D.ORIGIN;
    }
    return offset;
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) 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