Search in sources :

Example 36 with Coord2D

use of org.hwyl.sexytopo.model.graph.Coord2D in project sexytopo by richsmith.

the class PocketTopoTxtExporter method exportStationCoords.

public static String exportStationCoords(Space<Coord2D> space) {
    List<String> lines = new ArrayList<>();
    lines.add("STATIONS");
    for (Map.Entry<Station, Coord2D> entry : space.getStationMap().entrySet()) {
        Coord2D coords = entry.getValue();
        Station station = entry.getKey();
        lines.add(coords.getX() + "\t" + coords.getY() + "\t" + station.getName());
    }
    lines.add("SHOTS");
    for (Line<Coord2D> line : space.getLegMap().values()) {
        Coord2D start = line.getStart();
        Coord2D end = line.getEnd();
        lines.add(start.getX() + "\t" + start.getY() + "\t" + end.getX() + "\t" + end.getY());
    }
    return TextTools.join("\n", lines);
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) ArrayList(java.util.ArrayList) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Map(java.util.Map)

Example 37 with Coord2D

use of org.hwyl.sexytopo.model.graph.Coord2D in project sexytopo by richsmith.

the class XviExporter method getSketchLineText.

private static String getSketchLineText(PathDetail pathDetail, double scale) {
    List<Object> fields = new LinkedList<>();
    fields.add(pathDetail.getColour().toString());
    for (Coord2D coord2D : pathDetail.getPath()) {
        String x = TextTools.formatTo2dp(coord2D.getX() * scale);
        // +0.0 to avoid -0.0
        String y = TextTools.formatTo2dp((-coord2D.getY() + 0.0) * scale);
        fields.add(x);
        fields.add(y);
    }
    return field("\t", TextTools.join(" ", fields));
}
Also used : Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) LinkedList(java.util.LinkedList)

Example 38 with Coord2D

use of org.hwyl.sexytopo.model.graph.Coord2D in project sexytopo by richsmith.

the class Space2DUtils method transform.

public static Space<Coord2D> transform(Space<Coord2D> space, Coord2D point) {
    Space<Coord2D> newSpace = new Space<>();
    Map<Station, Coord2D> stations = space.getStationMap();
    for (Station station : stations.keySet()) {
        Coord2D coord = stations.get(station);
        Coord2D newCoord = coord.plus(point);
        newSpace.addStation(station, newCoord);
    }
    Map<Leg, Line<Coord2D>> legs = space.getLegMap();
    for (Leg leg : legs.keySet()) {
        Line<Coord2D> line = legs.get(leg);
        Line<Coord2D> newLine = transformLine(line, point);
        newSpace.addLeg(leg, newLine);
    }
    return newSpace;
}
Also used : Space(org.hwyl.sexytopo.model.graph.Space) Station(org.hwyl.sexytopo.model.survey.Station) Line(org.hwyl.sexytopo.model.graph.Line) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 39 with Coord2D

use of org.hwyl.sexytopo.model.graph.Coord2D 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, 2), 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)

Example 40 with Coord2D

use of org.hwyl.sexytopo.model.graph.Coord2D in project sexytopo by richsmith.

the class BasicTestSketchCreator method drawOneHorizontalLine.

public static void drawOneHorizontalLine(Sketch sketch) {
    sketch.startNewPath(new Coord2D(5, 0));
    sketch.getActivePath().lineTo(new Coord2D(10, 0));
    sketch.finishPath();
}
Also used : Coord2D(org.hwyl.sexytopo.model.graph.Coord2D)

Aggregations

Coord2D (org.hwyl.sexytopo.model.graph.Coord2D)40 Station (org.hwyl.sexytopo.model.survey.Station)10 Space (org.hwyl.sexytopo.model.graph.Space)8 Line (org.hwyl.sexytopo.model.graph.Line)6 PathDetail (org.hwyl.sexytopo.model.sketch.PathDetail)6 Survey (org.hwyl.sexytopo.model.survey.Survey)6 Test (org.junit.Test)6 Leg (org.hwyl.sexytopo.model.survey.Leg)5 Colour (org.hwyl.sexytopo.model.sketch.Colour)4 ArrayList (java.util.ArrayList)3 GraphActivity (org.hwyl.sexytopo.control.activity.GraphActivity)3 PlanActivity (org.hwyl.sexytopo.control.activity.PlanActivity)3 Sketch (org.hwyl.sexytopo.model.sketch.Sketch)3 Paint (android.graphics.Paint)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2 CrossSection (org.hwyl.sexytopo.model.sketch.CrossSection)2 CrossSectionDetail (org.hwyl.sexytopo.model.sketch.CrossSectionDetail)2 TextDetail (org.hwyl.sexytopo.model.sketch.TextDetail)2 JSONArray (org.json.JSONArray)2