Search in sources :

Example 1 with Space

use of org.hwyl.sexytopo.model.graph.Space in project sexytopo by richsmith.

the class Space3DTransformer method transformTo3D.

public Space transformTo3D(Station root) {
    Space space = new Space();
    update(space, root, Coord3D.ORIGIN);
    return space;
}
Also used : Space(org.hwyl.sexytopo.model.graph.Space)

Example 2 with Space

use of org.hwyl.sexytopo.model.graph.Space in project sexytopo by richsmith.

the class ConnectedSurveysTest method testSecondaryConnectedSurveyGetsTranslatedCorrectly.

@Test
public void testSecondaryConnectedSurveyGetsTranslatedCorrectly() throws Exception {
    Survey currentSurvey = getBasicSurvey("current");
    Survey joinedSurvey0 = getBasicSurvey("joined-0");
    Survey joinedSurvey1 = getBasicSurvey("joined-1");
    connectTwoSurveys(currentSurvey, currentSurvey.getActiveStation(), joinedSurvey0, joinedSurvey0.getOrigin());
    connectTwoSurveys(joinedSurvey0, joinedSurvey0.getActiveStation(), joinedSurvey1, joinedSurvey1.getOrigin());
    GraphActivity activity = new PlanActivity();
    Space<Coord2D> planProjection = Projection2D.PLAN.project(currentSurvey);
    Map<Survey, Space<Coord2D>> translated = ConnectedSurveys.getTranslatedConnectedSurveys(activity, currentSurvey, planProjection);
    Assert.assertEquals(translated.size(), 2);
    Survey translatedSurvey = getNamedSurvey(translated, "joined-1");
    Space<Coord2D> projection = translated.get(translatedSurvey);
    assert projection != null;
    Coord2D newStationPoint = getStationPosition(projection, "2");
    Assert.assertEquals(-3.0, newStationPoint.y, SexyTopo.ALLOWED_DOUBLE_DELTA);
}
Also used : Space(org.hwyl.sexytopo.model.graph.Space) Survey(org.hwyl.sexytopo.model.survey.Survey) GraphActivity(org.hwyl.sexytopo.control.activity.GraphActivity) PlanActivity(org.hwyl.sexytopo.control.activity.PlanActivity) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Test(org.junit.Test)

Example 3 with Space

use of org.hwyl.sexytopo.model.graph.Space in project sexytopo by richsmith.

the class ConnectedSurveysTest method testNoConnectedSurveysReturnNoUpdatedSurveys.

@Test
public void testNoConnectedSurveysReturnNoUpdatedSurveys() {
    Survey currentSurvey = getBasicSurvey("not-connected");
    // As of v2 of Mockito the following emits an 'UnnecessaryStubbingException'
    // Sketch fakeSketch = new Sketch();
    // when(mockActivity.getSketch(currentSurvey)).thenReturn(fakeSketch);
    Map<Survey, Space<Coord2D>> translated = ConnectedSurveys.getTranslatedConnectedSurveys(mockActivity, currentSurvey, new Space<>());
    Assert.assertEquals(translated.size(), 0);
}
Also used : Space(org.hwyl.sexytopo.model.graph.Space) Survey(org.hwyl.sexytopo.model.survey.Survey) Test(org.junit.Test)

Example 4 with Space

use of org.hwyl.sexytopo.model.graph.Space in project sexytopo by richsmith.

the class ConnectedSurveysTest method testConnectedSurveyGetsTranslatedCorrectly.

@Test
public void testConnectedSurveyGetsTranslatedCorrectly() throws Exception {
    Survey currentSurvey = getBasicSurvey("current");
    Survey joinedSurvey = getBasicSurvey("joined");
    connectTwoSurveys(currentSurvey, currentSurvey.getActiveStation(), joinedSurvey, joinedSurvey.getOrigin());
    GraphActivity activity = new PlanActivity();
    Space<Coord2D> planProjection = Projection2D.PLAN.project(currentSurvey);
    Map<Survey, Space<Coord2D>> translated = ConnectedSurveys.getTranslatedConnectedSurveys(activity, currentSurvey, planProjection);
    Assert.assertEquals(translated.size(), 1);
    Survey translatedSurvey = getNamedSurvey(translated, "joined");
    Space<Coord2D> projection = translated.get(translatedSurvey);
    assert projection != null;
    Coord2D newStationPoint = getStationPosition(projection, "2");
    Assert.assertEquals(-2.0, newStationPoint.y, SexyTopo.ALLOWED_DOUBLE_DELTA);
}
Also used : Space(org.hwyl.sexytopo.model.graph.Space) Survey(org.hwyl.sexytopo.model.survey.Survey) GraphActivity(org.hwyl.sexytopo.control.activity.GraphActivity) PlanActivity(org.hwyl.sexytopo.control.activity.PlanActivity) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Test(org.junit.Test)

Example 5 with Space

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

Aggregations

Space (org.hwyl.sexytopo.model.graph.Space)9 Coord2D (org.hwyl.sexytopo.model.graph.Coord2D)7 Line (org.hwyl.sexytopo.model.graph.Line)4 Leg (org.hwyl.sexytopo.model.survey.Leg)4 Survey (org.hwyl.sexytopo.model.survey.Survey)4 Test (org.junit.Test)4 GraphActivity (org.hwyl.sexytopo.control.activity.GraphActivity)3 PlanActivity (org.hwyl.sexytopo.control.activity.PlanActivity)3 Station (org.hwyl.sexytopo.model.survey.Station)3 Coord3D (org.hwyl.sexytopo.model.graph.Coord3D)1 PathDetail (org.hwyl.sexytopo.model.sketch.PathDetail)1 Sketch (org.hwyl.sexytopo.model.sketch.Sketch)1