Search in sources :

Example 11 with Position

use of net.sf.marineapi.nmea.util.Position in project marine-api by ktuukkan.

the class GLLTest method testSetPositionWithNonZeroValues.

/**
	 * Test method for
	 * {@link net.sf.marineapi.nmea.parser.GLLParser#setPosition(Position)}.
	 */
@Test
public void testSetPositionWithNonZeroValues() {
    final double lat = 60 + (11.552 / 60);
    final double lon = 25 + (1.941 / 60);
    Position p2 = new Position(lat, lon);
    instance.setPosition(p2);
    final String s2 = instance.toString();
    final Position p = instance.getPosition();
    assertTrue(s2.contains(",6011.552,N,"));
    assertTrue(s2.contains(",02501.941,E,"));
    assertNotNull(p);
    assertEquals(lat, p.getLatitude(), 0.0000001);
    assertEquals(lon, p.getLongitude(), 0.0000001);
}
Also used : Position(net.sf.marineapi.nmea.util.Position) Test(org.junit.Test)

Example 12 with Position

use of net.sf.marineapi.nmea.util.Position in project marine-api by ktuukkan.

the class GGATest method testSetPosition.

@Test
public void testSetPosition() {
    final double lat = 61 + (1.111 / 60);
    final double lon = 27 + (7.777 / 60);
    final double alt = 11.1;
    Position p = new Position(lat, lon);
    p.setAltitude(alt);
    gga.setPosition(p);
    final String str = gga.toString();
    assertTrue(str.contains(",6101.111,N,"));
    assertTrue(str.contains(",02707.777,E,"));
    Position wp = gga.getPosition();
    assertNotNull(wp);
    assertEquals(lat, wp.getLatitude(), 0.0000001);
    assertEquals(lon, wp.getLongitude(), 0.0000001);
    assertEquals(CompassPoint.NORTH, wp.getLatitudeHemisphere());
    assertEquals(CompassPoint.EAST, wp.getLongitudeHemisphere());
    assertEquals(alt, wp.getAltitude(), 0.01);
}
Also used : Position(net.sf.marineapi.nmea.util.Position) Test(org.junit.Test)

Example 13 with Position

use of net.sf.marineapi.nmea.util.Position in project marine-api by ktuukkan.

the class RMCTest method testGetPosition.

/**
	 * Test method for
	 * {@link net.sf.marineapi.nmea.parser.RMCParser#getPosition()}.
	 */
@Test
public void testGetPosition() {
    final double lat = 60 + (11.552 / 60);
    final double lon = 25 + (1.941 / 60);
    Position p = rmc.getPosition();
    assertNotNull(p);
    assertEquals(lat, p.getLatitude(), 0.0000001);
    assertEquals(lon, p.getLongitude(), 0.0000001);
    assertEquals(CompassPoint.NORTH, p.getLatitudeHemisphere());
    assertEquals(CompassPoint.EAST, p.getLongitudeHemisphere());
}
Also used : Position(net.sf.marineapi.nmea.util.Position) Test(org.junit.Test)

Example 14 with Position

use of net.sf.marineapi.nmea.util.Position in project marine-api by ktuukkan.

the class GNSTest method setPosition.

@Test
public void setPosition() throws Exception {
    final double LAT = 61.23456;
    final double LON = 21.23456;
    empty.setPosition(new Position(LAT, LON));
    Position p = empty.getPosition();
    assertEquals(LAT, p.getLatitude(), 0.00001);
    assertEquals(CompassPoint.NORTH, p.getLatitudeHemisphere());
    assertEquals(LON, p.getLongitude(), 0.00001);
    assertEquals(CompassPoint.EAST, p.getLongitudeHemisphere());
}
Also used : Position(net.sf.marineapi.nmea.util.Position) Test(org.junit.Test)

Example 15 with Position

use of net.sf.marineapi.nmea.util.Position in project marine-api by ktuukkan.

the class GNSTest method getPosition.

@Test
public void getPosition() throws Exception {
    // 4332.69262,S,17235.48549,E
    final double LAT = -(43 + 32.69262 / 60);
    final double LON = 172 + 35.48549 / 60;
    Position p = gns.getPosition();
    assertEquals(LAT, p.getLatitude(), 0.00001);
    assertEquals(CompassPoint.SOUTH, p.getLatitudeHemisphere());
    assertEquals(LON, p.getLongitude(), 0.00001);
    assertEquals(CompassPoint.EAST, p.getLongitudeHemisphere());
}
Also used : Position(net.sf.marineapi.nmea.util.Position) Test(org.junit.Test)

Aggregations

Position (net.sf.marineapi.nmea.util.Position)16 Test (org.junit.Test)11 DataNotAvailableException (net.sf.marineapi.nmea.parser.DataNotAvailableException)1 GGASentence (net.sf.marineapi.nmea.sentence.GGASentence)1 GLLSentence (net.sf.marineapi.nmea.sentence.GLLSentence)1 RMCSentence (net.sf.marineapi.nmea.sentence.RMCSentence)1 Sentence (net.sf.marineapi.nmea.sentence.Sentence)1 VTGSentence (net.sf.marineapi.nmea.sentence.VTGSentence)1 CompassPoint (net.sf.marineapi.nmea.util.CompassPoint)1 Date (net.sf.marineapi.nmea.util.Date)1 FaaMode (net.sf.marineapi.nmea.util.FaaMode)1 GpsFixQuality (net.sf.marineapi.nmea.util.GpsFixQuality)1 Time (net.sf.marineapi.nmea.util.Time)1 PositionEvent (net.sf.marineapi.provider.event.PositionEvent)1