Search in sources :

Example 11 with Sketch

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;
}
Also used : Sketch(org.hwyl.sexytopo.model.sketch.Sketch) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D)

Example 12 with Sketch

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);
    }
}
Also used : Sketch(org.hwyl.sexytopo.model.sketch.Sketch)

Example 13 with Sketch

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;
}
Also used : Survey(org.hwyl.sexytopo.model.survey.Survey) Sketch(org.hwyl.sexytopo.model.sketch.Sketch) File(java.io.File)

Example 14 with Sketch

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));
}
Also used : Space(org.hwyl.sexytopo.model.graph.Space) Survey(org.hwyl.sexytopo.model.survey.Survey) GraphActivity(org.hwyl.sexytopo.control.activity.GraphActivity) PathDetail(org.hwyl.sexytopo.model.sketch.PathDetail) PlanActivity(org.hwyl.sexytopo.control.activity.PlanActivity) Sketch(org.hwyl.sexytopo.model.sketch.Sketch) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Test(org.junit.Test)

Aggregations

Sketch (org.hwyl.sexytopo.model.sketch.Sketch)14 Coord2D (org.hwyl.sexytopo.model.graph.Coord2D)5 PathDetail (org.hwyl.sexytopo.model.sketch.PathDetail)5 Survey (org.hwyl.sexytopo.model.survey.Survey)5 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1 GraphActivity (org.hwyl.sexytopo.control.activity.GraphActivity)1 PlanActivity (org.hwyl.sexytopo.control.activity.PlanActivity)1 Space (org.hwyl.sexytopo.model.graph.Space)1 CrossSectionDetail (org.hwyl.sexytopo.model.sketch.CrossSectionDetail)1 SymbolDetail (org.hwyl.sexytopo.model.sketch.SymbolDetail)1 TextDetail (org.hwyl.sexytopo.model.sketch.TextDetail)1 Station (org.hwyl.sexytopo.model.survey.Station)1 SurveyConnection (org.hwyl.sexytopo.model.survey.SurveyConnection)1 JSONArray (org.json.JSONArray)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1 Test (org.junit.Test)1