use of org.hwyl.sexytopo.model.sketch.Sketch in project sexytopo by richsmith.
the class PocketTopoTxtImporter method getPlan.
private static Sketch getPlan(Survey survey, String fullText) {
String text = getSection(fullText, "PLAN");
Space<Coord2D> projection = Projection2D.PLAN.project(survey);
Sketch plan = parseSketch(survey, text, projection);
return plan;
}
use of org.hwyl.sexytopo.model.sketch.Sketch in project sexytopo by richsmith.
the class Loader method loadSketches.
private static void loadSketches(Context context, Survey survey, boolean restoreAutosave) throws JSONException {
String planPath = Util.getPathForSurveyFile(context, survey.getName(), getExtension(SexyTopo.PLAN_SKETCH_EXTENSION, restoreAutosave));
if (Util.doesFileExist(planPath)) {
String planText = slurpFile(planPath);
Sketch plan = SketchJsonTranslater.translate(survey, planText);
survey.setPlanSketch(plan);
}
String elevationPath = Util.getPathForSurveyFile(context, survey.getName(), getExtension(SexyTopo.EXT_ELEVATION_SKETCH_EXTENSION, restoreAutosave));
if (Util.doesFileExist(elevationPath)) {
String elevationText = slurpFile(elevationPath);
Sketch elevation = SketchJsonTranslater.translate(survey, elevationText);
survey.setElevationSketch(elevation);
}
}
use of org.hwyl.sexytopo.model.sketch.Sketch in project sexytopo by richsmith.
the class TherionImporter method toSurvey.
public Survey toSurvey(File directory) throws Exception {
Survey survey = null;
for (File file : directory.listFiles()) {
if (file.getName().endsWith("th")) {
survey = parseTh(file);
} else if (file.getName().endsWith("xvi")) {
String filenameNoExtension = FilenameUtils.removeExtension(file.getName());
if (filenameNoExtension.endsWith(SexyTopo.PLAN_SUFFIX)) {
Sketch sketch = XviImporter.getSketch(file);
survey.setPlanSketch(sketch);
} else if (filenameNoExtension.endsWith(SexyTopo.EE_SUFFIX)) {
Sketch sketch = XviImporter.getSketch(file);
survey.setElevationSketch(sketch);
}
}
}
return survey;
}
use of org.hwyl.sexytopo.model.sketch.Sketch 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));
}
Aggregations