use of org.hwyl.sexytopo.model.survey.Survey in project sexytopo by richsmith.
the class StationRenameTest method testRenameStation.
@Test
public void testRenameStation() {
Survey testSurvey = BasicTestSurveyCreator.createStraightNorth();
Station s2 = testSurvey.getStationByName("2");
SurveyUpdater.renameStation(testSurvey, s2, "ShinyNewName");
Station shinyNewStation = testSurvey.getStationByName("ShinyNewName");
Assert.assertEquals("ShinyNewName", shinyNewStation.getName());
}
use of org.hwyl.sexytopo.model.survey.Survey in project sexytopo by richsmith.
the class StationRenameTest method testGetStationByNameGetsExistingStation.
@Test
public void testGetStationByNameGetsExistingStation() {
Survey testSurvey = BasicTestSurveyCreator.createStraightNorth();
Station s1 = testSurvey.getStationByName("1");
Assert.assertEquals("1", s1.getName());
}
use of org.hwyl.sexytopo.model.survey.Survey in project sexytopo by richsmith.
the class SurveyUpdaterTest method testUpdateWithOneLegAddsOneLegToSurvey.
@Test
public void testUpdateWithOneLegAddsOneLegToSurvey() {
Leg leg = new Leg(5, 0, 0);
Survey survey = new Survey("Test Survey");
SurveyUpdater.update(survey, leg);
Assert.assertEquals(survey.getAllLegs().size(), 1);
}
use of org.hwyl.sexytopo.model.survey.Survey 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(survey, text);
survey.setElevationSketch(elevation);
Sketch plan = getPlan(survey, text);
survey.setPlanSketch(plan);
survey.setSaved(true);
return survey;
}
use of org.hwyl.sexytopo.model.survey.Survey in project sexytopo by richsmith.
the class MetadataTranslater method translateAndUpdateConnections.
@SuppressWarnings("UnnecessaryContinue")
private static void translateAndUpdateConnections(Context context, Survey survey, JSONObject json, Set<String> surveyNamesNotToLoad) throws Exception {
try {
JSONObject connectionsObject = json.getJSONObject(CONNECTIONS_TAG);
Map<String, JSONArray> outerMap = Util.toMap(connectionsObject);
for (String stationName : outerMap.keySet()) {
Station station = survey.getStationByName(stationName);
JSONArray setArray = outerMap.get(stationName);
for (JSONArray connectionPair : toListOfArrays(setArray)) {
assert connectionPair.length() == 2;
String connectedSurveyName = connectionPair.get(0).toString();
String connectionPointName = connectionPair.get(1).toString();
if (surveyNamesNotToLoad.contains(connectedSurveyName)) {
// if this survey is already loaded, don't do the whole infinite loop thing
continue;
} else {
// we *really* want to avoid infinite loops :)
// this should be added on load, but just as a precaution..
surveyNamesNotToLoad.add(connectedSurveyName);
try {
Survey connectedSurvey = Loader.loadSurvey(context, connectedSurveyName, surveyNamesNotToLoad, false);
Station connectionPoint = connectedSurvey.getStationByName(connectionPointName);
if (connectionPoint == null) {
Log.e("Connection point not found: " + connectionPoint.getName());
throw new Exception("Connection point not found");
}
survey.connect(station, connectedSurvey, connectionPoint);
} catch (Exception exception) {
// the linked survey or connecting station has probably been deleted;
// not much we can do...
Log.e("Could not load connected survey " + connectedSurveyName);
continue;
}
}
}
}
} catch (JSONException exception) {
Log.e(exception.toString());
throw new Exception("Error loading connected surveys");
}
}
Aggregations