Search in sources :

Example 1 with Sketch

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

the class ConnectedSurveys method updateTranslatedConnectedSurveys.

private static void updateTranslatedConnectedSurveys(GraphActivity activity, Survey original, Map<Survey, Space<Coord2D>> translated, Survey survey, Space<Coord2D> projection) {
    Map<Station, Set<SurveyConnection>> connections = survey.getConnectedSurveys();
    for (Station connectingStation : connections.keySet()) {
        Coord2D connectingStationLocation = projection.getStationMap().get(connectingStation);
        for (SurveyConnection connection : connections.get(connectingStation)) {
            Station otherConnectingStation = connection.stationInOtherSurvey;
            Survey otherSurvey = connection.otherSurvey;
            if (haveWeAlreadyDoneThisSurvey(translated, otherSurvey, original)) {
                continue;
            }
            // create a new copy of the survey so we can edit the associated sketch
            // (this might seem a bit messy but it's reasonably elegant, honest!)
            Survey lightweightSurveyCopy = new Survey(otherSurvey.getName());
            lightweightSurveyCopy.setOrigin(otherSurvey.getOrigin());
            Space<Coord2D> otherProjection = SpaceFlipper.flipVertically(activity.getProjection(connection.otherSurvey));
            Coord2D otherConnectingStationLocation = otherProjection.getStationMap().get(otherConnectingStation);
            Coord2D transformation = connectingStationLocation.minus(otherConnectingStationLocation);
            Sketch translatedPlan = otherSurvey.getPlanSketch().getTranslatedCopy(transformation);
            lightweightSurveyCopy.setPlanSketch(translatedPlan);
            Sketch translatedElevation = otherSurvey.getElevationSketch().getTranslatedCopy(transformation);
            lightweightSurveyCopy.setElevationSketch(translatedElevation);
            otherProjection = Space2DUtils.transform(otherProjection, transformation);
            translated.put(lightweightSurveyCopy, otherProjection);
            updateTranslatedConnectedSurveys(activity, original, translated, otherSurvey, otherProjection);
        }
    }
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) Survey(org.hwyl.sexytopo.model.survey.Survey) Set(java.util.Set) SurveyConnection(org.hwyl.sexytopo.model.survey.SurveyConnection) Sketch(org.hwyl.sexytopo.model.sketch.Sketch) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D)

Example 2 with Sketch

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

the class PocketTopoTxtImporter method parseSketch.

private static Sketch parseSketch(String text) {
    Sketch sketch = new Sketch();
    Set<PathDetail> pathDetails = parsePolylines(text);
    sketch.setPathDetails(pathDetails);
    return sketch;
}
Also used : PathDetail(org.hwyl.sexytopo.model.sketch.PathDetail) Sketch(org.hwyl.sexytopo.model.sketch.Sketch)

Example 3 with Sketch

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

the class PocketTopoTxtImporter method getElevation.

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

Example 4 with Sketch

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

the class PocketTopoTxtImporter method toSurvey.

public Survey toSurvey(File file) {
    String text = Loader.slurpFile(file.getAbsolutePath());
    // FIXME we're ignoring the metadata for now
    Survey survey = new Survey(getDefaultName(file));
    parseDataAndUpdateSurvey(survey, text);
    Sketch elevation = getElevation(text);
    survey.setElevationSketch(elevation);
    Sketch plan = getPlan(text);
    survey.setPlanSketch(plan);
    survey.setSaved(true);
    return survey;
}
Also used : Survey(org.hwyl.sexytopo.model.survey.Survey) Sketch(org.hwyl.sexytopo.model.sketch.Sketch)

Example 5 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;
    Set<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)

Aggregations

Sketch (org.hwyl.sexytopo.model.sketch.Sketch)12 Survey (org.hwyl.sexytopo.model.survey.Survey)6 PathDetail (org.hwyl.sexytopo.model.sketch.PathDetail)4 Coord2D (org.hwyl.sexytopo.model.graph.Coord2D)3 Space (org.hwyl.sexytopo.model.graph.Space)2 Test (org.junit.Test)2 File (java.io.File)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 GraphActivity (org.hwyl.sexytopo.control.activity.GraphActivity)1 PlanActivity (org.hwyl.sexytopo.control.activity.PlanActivity)1 CrossSectionDetail (org.hwyl.sexytopo.model.sketch.CrossSectionDetail)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