test_class.declarator: lineEncoder = new LineEncoder(new LocationReferencePointEncoder())
test_class.original_string: LineEncoder lineEncoder = new LineEncoder(new LocationReferencePointEncoder());
test_class.type: LineEncoder
test_class.var_name: lineEncoder
test_class.file: proto/src/test/java/openlr/proto/encoder/LineEncoderTest.java
test_class.identifier: LineEncoderTest
test_case.body: @Test
      public void testEncodeLine() throws OpenLRProtoException {
          List<LocationReferencePoint> locationReferencePoints = new ArrayList<>();
  
          LocationReferencePointProtoImpl first = new LocationReferencePointProtoImpl(
                  1,
                  5.7,
                  53.5,
                  15.5,
                  FunctionalRoadClass.FRC_3,
                  FormOfWay.MULTIPLE_CARRIAGEWAY,
                  200,
                  FunctionalRoadClass.FRC_4);
  
          LocationReferencePointProtoImpl second = new LocationReferencePointProtoImpl(
                  1,
                  5.8,
                  53.6,
                  20,
                  FunctionalRoadClass.FRC_3,
                  FormOfWay.MULTIPLE_CARRIAGEWAY,
                  100,
                  FunctionalRoadClass.FRC_4);
  
          LocationReferencePointProtoImpl last = new LocationReferencePointProtoImpl(
                  2,
                  5.6,
                  53.6,
                  165,
                  FunctionalRoadClass.FRC_4,
                  FormOfWay.MULTIPLE_CARRIAGEWAY);
  
          locationReferencePoints.add(first);
          locationReferencePoints.add(second);
          locationReferencePoints.add(last);
  
          Offsets offsets = new OffsetsProtoImpl(20, 10);
  
          RawLineLocRef rawLocationReference = new RawLineLocRef("1", locationReferencePoints, offsets);
  
          LocationReference locationReference = lineEncoder.encode(rawLocationReference);
  
          assertNotNull(locationReference);
          assertEquals(locationReference.getID(), "1");
          assertEquals(locationReference.getLocationType(), LocationType.LINE_LOCATION);
          assertTrue(locationReference.isValid());
          assertEquals(locationReference.getDataClass(), LocationReferenceData.class);
  
          Object locationReferenceData = locationReference.getLocationReferenceData();
  
          assertNotNull(locationReferenceData);
          assertTrue(locationReferenceData instanceof LocationReferenceData);
  
          LocationReferenceData data = (LocationReferenceData) locationReferenceData;
  
          assertTrue(data.hasLineLocationReference());
  
          LineLocationReference lineLocationReference = data.getLineLocationReference();
  
          assertEquals(lineLocationReference.getLocationReferencePointsCount(), 3);
  
          openlr.proto.schema.LocationReferencePoint firstLrp = lineLocationReference.getLocationReferencePoints(0);
  
          assertTrue(firstLrp.hasCoordinates());
  
          Coordinates firstCoordinates = firstLrp.getCoordinates();
          assertEquals(firstCoordinates.getLongitude(),5.7);
          assertEquals(firstCoordinates.getLatitude(), 53.5);
  
          assertTrue(firstLrp.hasLineAttributes());
  
          LineAttributes firstLineAttributes = firstLrp.getLineAttributes();
          assertEquals(firstLineAttributes.getBearing(), 15);
          assertEquals(firstLineAttributes.getFrc(), FRC.FRC_3);
          assertEquals(firstLineAttributes.getFow(), FOW.FOW_MULTIPLE_CARRIAGEWAY);
  
          assertTrue(firstLrp.hasPathAttributes());
  
          PathAttributes firstPathAttributes = firstLrp.getPathAttributes();
          assertEquals(firstPathAttributes.getDistanceToNext(), 200);
          assertEquals(firstPathAttributes.getLowestFrcAlongPath(), FRC.FRC_4);
  
          openlr.proto.schema.LocationReferencePoint secondLrp = lineLocationReference.getLocationReferencePoints(1);
  
          assertTrue(secondLrp.hasCoordinates());
  
          Coordinates secondCoordinates = secondLrp.getCoordinates();
          assertEquals(secondCoordinates.getLongitude(),5.8);
          assertEquals(secondCoordinates.getLatitude(), 53.6);
  
          assertTrue(secondLrp.hasLineAttributes());
  
          LineAttributes secondLineAttributes = secondLrp.getLineAttributes();
          assertEquals(secondLineAttributes.getBearing(), 20);
          assertEquals(secondLineAttributes.getFrc(), FRC.FRC_3);
          assertEquals(secondLineAttributes.getFow(), FOW.FOW_MULTIPLE_CARRIAGEWAY);
  
          assertTrue(secondLrp.hasPathAttributes());
  
          PathAttributes secondPathAttributes = secondLrp.getPathAttributes();
          assertEquals(secondPathAttributes.getDistanceToNext(), 100);
          assertEquals(secondPathAttributes.getLowestFrcAlongPath(), FRC.FRC_4);
  
          openlr.proto.schema.LocationReferencePoint lastLrp = lineLocationReference.getLocationReferencePoints(2);
  
          assertTrue(lastLrp.hasCoordinates());
  
          Coordinates lastCoordinates = lastLrp.getCoordinates();
          assertEquals(lastCoordinates.getLongitude(),5.6);
          assertEquals(lastCoordinates.getLatitude(), 53.6);
  
          assertTrue(lastLrp.hasLineAttributes());
  
          LineAttributes lastLineAttributes = lastLrp.getLineAttributes();
          assertEquals(lastLineAttributes.getBearing(), 165);
          assertEquals(lastLineAttributes.getFrc(), FRC.FRC_4);
          assertEquals(lastLineAttributes.getFow(), FOW.FOW_MULTIPLE_CARRIAGEWAY);
  
          assertFalse(lastLrp.hasPathAttributes());
  
          assertEquals(lineLocationReference.getPositiveOffset(), 20);
          assertEquals(lineLocationReference.getNegativeOffset(), 10);
      }
test_case.class_method_signature: LineEncoderTest.testEncodeLine()
test_case.full_signature: @Test public void testEncodeLine()
test_case.identifier: testEncodeLine
test_case.invocations: add add add encode assertNotNull assertEquals getID assertEquals getLocationType assertTrue isValid assertEquals getDataClass getLocationReferenceData assertNotNull assertTrue assertTrue hasLineLocationReference getLineLocationReference assertEquals getLocationReferencePointsCount getLocationReferencePoints assertTrue hasCoordinates getCoordinates assertEquals getLongitude assertEquals getLatitude assertTrue hasLineAttributes getLineAttributes assertEquals getBearing assertEquals getFrc assertEquals getFow assertTrue hasPathAttributes getPathAttributes assertEquals getDistanceToNext assertEquals getLowestFrcAlongPath getLocationReferencePoints assertTrue hasCoordinates getCoordinates assertEquals getLongitude assertEquals getLatitude assertTrue hasLineAttributes getLineAttributes assertEquals getBearing assertEquals getFrc assertEquals getFow assertTrue hasPathAttributes getPathAttributes assertEquals getDistanceToNext assertEquals getLowestFrcAlongPath getLocationReferencePoints assertTrue hasCoordinates getCoordinates assertEquals getLongitude assertEquals getLatitude assertTrue hasLineAttributes getLineAttributes assertEquals getBearing assertEquals getFrc assertEquals getFow assertFalse hasPathAttributes assertEquals getPositiveOffset assertEquals getNegativeOffset
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testEncodeLine()
focal_class.declarator: locationReferencePointEncoder
focal_class.modifier: private final
focal_class.original_string: private final LocationReferencePointEncoder locationReferencePointEncoder;
focal_class.type: LocationReferencePointEncoder
focal_class.var_name: locationReferencePointEncoder
focal_class.file: proto/src/main/java/openlr/proto/encoder/LineEncoder.java
focal_class.identifier: LineEncoder
focal_class.interfaces: implements LocationReferenceEncoder
focal_class.class_method_signature: LineEncoder.LineEncoder(LocationReferencePointEncoder locationReferencePointEncoder)
focal_class.full_signature:   LineEncoder(LocationReferencePointEncoder locationReferencePointEncoder)
focal_class.identifier: LineEncoder
focal_class.parameters: (LocationReferencePointEncoder locationReferencePointEncoder)
focal_class.signature:  LineEncoder(LocationReferencePointEncoder locationReferencePointEncoder)
focal_class.class_method_signature: LineEncoder.encode(RawLocationReference rawLocationReference)
focal_class.full_signature: @Override public LocationReference encode(RawLocationReference rawLocationReference)
focal_class.identifier: encode
focal_class.modifiers: @Override public
focal_class.parameters: (RawLocationReference rawLocationReference)
focal_class.return: LocationReference
focal_class.signature: LocationReference encode(RawLocationReference rawLocationReference)
focal_method.body: @Override
      public LocationReference encode(RawLocationReference rawLocationReference) throws OpenLRProtoException {
          if (rawLocationReference.getLocationType() != LocationType.LINE_LOCATION) {
              throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_LOCATION_REFERENCE);
          }
  
          List<LocationReferencePoint> locationReferencePoints = rawLocationReference.getLocationReferencePoints();
  
          if (locationReferencePoints.size() < 2) {
              throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_LOCATION_REFERENCE);
          }
  
          List<openlr.proto.schema.LocationReferencePoint> lrps = new ArrayList<>();
  
          for (LocationReferencePoint locationReferencePoint : locationReferencePoints) {
              openlr.proto.schema.LocationReferencePoint lrp = locationReferencePointEncoder.encode(locationReferencePoint);
              lrps.add(lrp);
          }
  
          Offsets offsets = rawLocationReference.getOffsets();
  
          int positiveLength = locationReferencePoints.get(0).getDistanceToNext();
          int positiveOffset = offsets.getPositiveOffset(positiveLength);
  
          int negativeLength = locationReferencePoints.get(locationReferencePoints.size() - 2).getDistanceToNext();
          int negativeOffset = offsets.getNegativeOffset(negativeLength);
  
          LineLocationReference lineLocationReference = LineLocationReference.newBuilder()
                  .addAllLocationReferencePoints(lrps)
                  .setPositiveOffset(positiveOffset)
                  .setNegativeOffset(negativeOffset)
                  .build();
  
          LocationReferenceData locationReferenceData = LocationReferenceData.newBuilder()
                  .setLineLocationReference(lineLocationReference)
                  .build();
  
          return new LocationReferenceProtoImpl(rawLocationReference.getID(), LocationType.LINE_LOCATION, locationReferenceData);
      }
focal_method.class_method_signature: LineEncoder.encode(RawLocationReference rawLocationReference)
focal_method.full_signature: @Override public LocationReference encode(RawLocationReference rawLocationReference)
focal_method.identifier: encode
focal_method.invocations: getLocationType getLocationReferencePoints size encode add getOffsets getDistanceToNext get getPositiveOffset getDistanceToNext get size getNegativeOffset build setNegativeOffset setPositiveOffset addAllLocationReferencePoints newBuilder build setLineLocationReference newBuilder getID
focal_method.modifiers: @Override public
focal_method.parameters: (RawLocationReference rawLocationReference)
focal_method.return: LocationReference
focal_method.signature: LocationReference encode(RawLocationReference rawLocationReference)