Search in sources :

Example 21 with Coord2D

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

the class Sketch method findEligibleSnapPointWithin.

public Coord2D findEligibleSnapPointWithin(Coord2D point, double delta) {
    Coord2D closest = null;
    double minDistance = Double.MAX_VALUE;
    for (PathDetail path : pathDetails) {
        if (activePath == path) {
            continue;
        }
        Coord2D start = path.getPath().get(0);
        Coord2D end = path.getPath().get(path.getPath().size() - 1);
        for (Coord2D coord2D : new Coord2D[] { start, end }) {
            double distance = Space2DUtils.getDistance(point, coord2D);
            if (distance < delta && distance < minDistance) {
                closest = coord2D;
                minDistance = distance;
            }
        }
    }
    return closest;
}
Also used : Coord2D(org.hwyl.sexytopo.model.graph.Coord2D)

Example 22 with Coord2D

use of org.hwyl.sexytopo.model.graph.Coord2D 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 = SpaceFlipper.flipVertically(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);
    Coord2D newStationPoint = getStationPosition(projection, "2");
    Assert.assertEquals(-3.0, newStationPoint.getY(), SexyTopo.ALLOWED_DOUBLE_DELTA_FOR_TESTS);
}
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 23 with Coord2D

use of org.hwyl.sexytopo.model.graph.Coord2D 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 = SpaceFlipper.flipVertically(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);
    Coord2D newStationPoint = getStationPosition(projection, "2");
    Assert.assertEquals(-2.0, newStationPoint.getY(), SexyTopo.ALLOWED_DOUBLE_DELTA_FOR_TESTS);
}
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 24 with Coord2D

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

the class ConnectedSurveysTest method testNoConnectedSurveysReturnNoUpdatedSurveys.

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

Example 25 with Coord2D

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

the class XviImporterTest method testParseSketchEntryParsesSecondEntry.

@Test
public void testParseSketchEntryParsesSecondEntry() throws Exception {
    String simpleText = "blue 0 0 1 0";
    PathDetail pathDetail = XviImporter.parseSketchEntry(1, simpleText);
    Assert.assertEquals(new Coord2D(1, 0), pathDetail.getPath().get(1));
    Assert.assertEquals(2, pathDetail.getPath().size());
}
Also used : PathDetail(org.hwyl.sexytopo.model.sketch.PathDetail) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Test(org.junit.Test)

Aggregations

Coord2D (org.hwyl.sexytopo.model.graph.Coord2D)40 Station (org.hwyl.sexytopo.model.survey.Station)10 Space (org.hwyl.sexytopo.model.graph.Space)8 Line (org.hwyl.sexytopo.model.graph.Line)6 PathDetail (org.hwyl.sexytopo.model.sketch.PathDetail)6 Survey (org.hwyl.sexytopo.model.survey.Survey)6 Test (org.junit.Test)6 Leg (org.hwyl.sexytopo.model.survey.Leg)5 Colour (org.hwyl.sexytopo.model.sketch.Colour)4 ArrayList (java.util.ArrayList)3 GraphActivity (org.hwyl.sexytopo.control.activity.GraphActivity)3 PlanActivity (org.hwyl.sexytopo.control.activity.PlanActivity)3 Sketch (org.hwyl.sexytopo.model.sketch.Sketch)3 Paint (android.graphics.Paint)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2 CrossSection (org.hwyl.sexytopo.model.sketch.CrossSection)2 CrossSectionDetail (org.hwyl.sexytopo.model.sketch.CrossSectionDetail)2 TextDetail (org.hwyl.sexytopo.model.sketch.TextDetail)2 JSONArray (org.json.JSONArray)2