Search in sources :

Example 6 with Sketch

use of org.hwyl.sexytopo.model.sketch.Sketch in project sexytopo by richsmith.

the class PocketTopoTxtImporter method parseSketch.

private static Sketch parseSketch(Survey survey, String text, Space<Coord2D> projection) {
    Sketch sketch = new Sketch();
    Coord2D offset = extractOffset(survey, text, projection);
    List<PathDetail> pathDetails = parsePolylines(text, offset);
    sketch.setPathDetails(pathDetails);
    return sketch;
}
Also used : PathDetail(org.hwyl.sexytopo.model.sketch.PathDetail) Sketch(org.hwyl.sexytopo.model.sketch.Sketch) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D)

Example 7 with Sketch

use of org.hwyl.sexytopo.model.sketch.Sketch in project sexytopo by richsmith.

the class XviImporter method toSurvey.

public Survey toSurvey(File file) throws Exception {
    Survey survey = new Survey(file.getName());
    Sketch sketch = getSketch(file);
    survey.setPlanSketch(sketch);
    return survey;
}
Also used : Survey(org.hwyl.sexytopo.model.survey.Survey) Sketch(org.hwyl.sexytopo.model.sketch.Sketch)

Example 8 with Sketch

use of org.hwyl.sexytopo.model.sketch.Sketch in project sexytopo by richsmith.

the class XviImporter method getSketch.

public static Sketch getSketch(File file) throws Exception {
    Sketch sketch = new Sketch();
    String contents = Loader.slurpFile(file);
    Grid grid = instance.parseGrid(contents);
    double scale = grid.dy;
    List<PathDetail> pathDetails = parseSketchlineBlock(scale, contents);
    sketch.setPathDetails(pathDetails);
    return sketch;
}
Also used : PathDetail(org.hwyl.sexytopo.model.sketch.PathDetail) Sketch(org.hwyl.sexytopo.model.sketch.Sketch)

Example 9 with Sketch

use of org.hwyl.sexytopo.model.sketch.Sketch in project sexytopo by richsmith.

the class PocketTopoTxtImporter method getPlan.

private static Sketch getPlan(String fullText) {
    String text = getSection(fullText, "PLAN");
    Sketch plan = parseSketch(text);
    return plan;
}
Also used : Sketch(org.hwyl.sexytopo.model.sketch.Sketch)

Example 10 with Sketch

use of org.hwyl.sexytopo.model.sketch.Sketch in project sexytopo by richsmith.

the class SketchJsonTranslater method toSketch.

public static Sketch toSketch(Survey survey, JSONObject json) {
    Sketch sketch = new Sketch();
    try {
        JSONArray pathsArray = json.getJSONArray(PATHS_TAG);
        List<PathDetail> pathDetails = new ArrayList<>();
        for (JSONObject object : Util.toList(pathsArray)) {
            pathDetails.add(toPathDetail(object));
        }
        sketch.setPathDetails(pathDetails);
    } catch (JSONException e) {
        Log.e("Failed to load sketch paths: " + e);
    }
    try {
        JSONArray symbolsArray = json.getJSONArray(SYMBOLS_TAG);
        List<SymbolDetail> symbolDetails = new ArrayList<>();
        for (JSONObject object : Util.toList(symbolsArray)) {
            symbolDetails.add(toSymbolDetail(object));
        }
        sketch.setSymbolDetails(symbolDetails);
    } catch (JSONException e) {
        Log.e("Failed to load symbols: " + e);
    }
    try {
        JSONArray labelsArray = json.getJSONArray(LABELS_TAG);
        List<TextDetail> textDetails = new ArrayList<>();
        for (JSONObject object : Util.toList(labelsArray)) {
            textDetails.add(toTextDetail(object));
        }
        sketch.setTextDetails(textDetails);
    } catch (JSONException e) {
        Log.e("Failed to load sketch labels: " + e);
    }
    try {
        JSONArray crossSectionsArray = json.getJSONArray(CROSS_SECTIONS_TAG);
        List<CrossSectionDetail> crossSectionDetails = new ArrayList<>();
        for (JSONObject object : Util.toList(crossSectionsArray)) {
            crossSectionDetails.add(toCrossSectionDetail(survey, object));
        }
        sketch.setCrossSectionDetails(crossSectionDetails);
    } catch (JSONException e) {
        Log.e("Failed to load cross-sections: " + e);
    }
    return sketch;
}
Also used : JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) CrossSectionDetail(org.hwyl.sexytopo.model.sketch.CrossSectionDetail) JSONException(org.json.JSONException) SymbolDetail(org.hwyl.sexytopo.model.sketch.SymbolDetail) JSONObject(org.json.JSONObject) PathDetail(org.hwyl.sexytopo.model.sketch.PathDetail) Sketch(org.hwyl.sexytopo.model.sketch.Sketch) TextDetail(org.hwyl.sexytopo.model.sketch.TextDetail)

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