use of org.hwyl.sexytopo.model.survey.Survey in project sexytopo by richsmith.
the class ConnectedSurveysTest method testConnectedSurveySketchGetsTranslatedCorrectly.
@Test
public void testConnectedSurveySketchGetsTranslatedCorrectly() {
Survey currentSurvey = getBasicSurvey("current");
Survey joinedSurvey = getBasicSurvey("joined");
Sketch sketch = joinedSurvey.getPlanSketch();
PathDetail pathDetail = sketch.startNewPath(new Coord2D(0, 0));
pathDetail.lineTo(new Coord2D(0, 1));
sketch.finishPath();
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);
Sketch translatedSketch = translated.keySet().iterator().next().getPlanSketch();
PathDetail translatedPathDetail = translatedSketch.getPathDetails().toArray(new PathDetail[] {})[0];
List<Coord2D> coords = translatedPathDetail.getPath();
Assert.assertEquals(new Coord2D(0, -1), coords.get(0));
Assert.assertEquals(new Coord2D(0, 0), coords.get(1));
}
use of org.hwyl.sexytopo.model.survey.Survey in project sexytopo by richsmith.
the class MetadataTranslaterTest method testJsonIsTranslatedToSurveyWithActiveStation.
@Test
public void testJsonIsTranslatedToSurveyWithActiveStation() throws Exception {
String json = "{\"active-station\":\"1\",\"connections\":{}}";
Survey testSurvey = BasicTestSurveyCreator.createStraightNorth();
testSurvey.setActiveStation(testSurvey.getStationByName("2"));
MetadataTranslater.translateAndUpdate(null, testSurvey, json);
Assert.assertEquals("1", testSurvey.getActiveStation().getName());
Assert.assertEquals(0, testSurvey.getConnectedSurveys().size());
}
use of org.hwyl.sexytopo.model.survey.Survey in project sexytopo by richsmith.
the class MetadataTranslaterTest method testConnectedSurveyIsTranslatedToJson.
@Test
public void testConnectedSurveyIsTranslatedToJson() throws Exception {
Survey survey = new Survey("first");
Survey connectedSurvey = new Survey("connected");
connectTwoSurveys(survey, survey.getOrigin(), connectedSurvey, connectedSurvey.getOrigin());
String translated = MetadataTranslater.translate(survey);
Assert.assertEquals("{\"active-station\":\"1\",\"connections\":{\"1\":[[\"connected\",\"1\"]]}}", translated.replaceAll("\\s", ""));
}
use of org.hwyl.sexytopo.model.survey.Survey in project sexytopo by richsmith.
the class MetadataTranslaterTest method testConnectedSurveyJsonIsTranslatedToConnectedSurvey.
@Test
public void testConnectedSurveyJsonIsTranslatedToConnectedSurvey() throws Exception {
String json = "{\"active-station\":\"1\",\"connections\":{\"1\":[[\"connected\",\"1\"]]}}";
Survey survey = new Survey("test");
Survey connected = new Survey("connected");
PowerMockito.mockStatic(Loader.class);
Mockito.when(Loader.loadSurvey((Context) any(), anyString(), anySet(), anyBoolean())).thenReturn(connected);
MetadataTranslater.translateAndUpdate(null, survey, json);
Assert.assertEquals(1, survey.getConnectedSurveys().size());
}
use of org.hwyl.sexytopo.model.survey.Survey in project sexytopo by richsmith.
the class SurvexImporterTest method testBasicImportHandlesComments.
@Test
public void testBasicImportHandlesComments() throws Exception {
final String testContent = "1\t2\t5.0\t0.0\t0.0\t; {from: 5.0 0.0 0.0, 5.0 0.0 0.0, 5.0 0.0 0.0} testComment";
Survey survey = new Survey("Test");
SurvexImporter.parse(testContent, survey);
Station created = survey.getStationByName("2");
Assert.assertEquals(created.getComment(), "testComment");
}
Aggregations