@Test public void testMissingLocationReference() { LocationReferenceData locationReferenceData = LocationReferenceData.newBuilder() .build(); try { lineDecoder.decode("1", locationReferenceData); fail(); } catch (PhysicalFormatException e) { assertEquals(e.getErrorCode(), OpenLRProtoStatusCode.MISSING_LOCATION_REFERENCE); } }
@Override public RawLocationReference decode(String id, LocationReferenceData data) throws OpenLRProtoException { if (!data.hasLineLocationReference()) { throw new OpenLRProtoException(OpenLRProtoStatusCode.MISSING_LOCATION_REFERENCE); } LineLocationReference lineLocationReference = data.getLineLocationReference(); int lrpCount = lineLocationReference.getLocationReferencePointsCount(); if (lrpCount < 2) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_LOCATION_REFERENCE); } List<LocationReferencePoint> locationReferencePoints = new ArrayList<>(); for (int sequenceNumber = 1; sequenceNumber <= lrpCount; sequenceNumber++) { LocationReferencePoint locationReferencePoint = locationReferencePointDecoder.decode( lineLocationReference.getLocationReferencePoints(sequenceNumber - 1), sequenceNumber, sequenceNumber == lrpCount); locationReferencePoints.add(locationReferencePoint); } Offsets offsets = new OffsetsProtoImpl( lineLocationReference.getPositiveOffset(), lineLocationReference.getNegativeOffset()); return new RawLineLocRef(id, locationReferencePoints, offsets); }
LineDecoder implements LocationReferenceDecoder { @Override public RawLocationReference decode(String id, LocationReferenceData data) throws OpenLRProtoException { if (!data.hasLineLocationReference()) { throw new OpenLRProtoException(OpenLRProtoStatusCode.MISSING_LOCATION_REFERENCE); } LineLocationReference lineLocationReference = data.getLineLocationReference(); int lrpCount = lineLocationReference.getLocationReferencePointsCount(); if (lrpCount < 2) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_LOCATION_REFERENCE); } List<LocationReferencePoint> locationReferencePoints = new ArrayList<>(); for (int sequenceNumber = 1; sequenceNumber <= lrpCount; sequenceNumber++) { LocationReferencePoint locationReferencePoint = locationReferencePointDecoder.decode( lineLocationReference.getLocationReferencePoints(sequenceNumber - 1), sequenceNumber, sequenceNumber == lrpCount); locationReferencePoints.add(locationReferencePoint); } Offsets offsets = new OffsetsProtoImpl( lineLocationReference.getPositiveOffset(), lineLocationReference.getNegativeOffset()); return new RawLineLocRef(id, locationReferencePoints, offsets); } }
LineDecoder implements LocationReferenceDecoder { @Override public RawLocationReference decode(String id, LocationReferenceData data) throws OpenLRProtoException { if (!data.hasLineLocationReference()) { throw new OpenLRProtoException(OpenLRProtoStatusCode.MISSING_LOCATION_REFERENCE); } LineLocationReference lineLocationReference = data.getLineLocationReference(); int lrpCount = lineLocationReference.getLocationReferencePointsCount(); if (lrpCount < 2) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_LOCATION_REFERENCE); } List<LocationReferencePoint> locationReferencePoints = new ArrayList<>(); for (int sequenceNumber = 1; sequenceNumber <= lrpCount; sequenceNumber++) { LocationReferencePoint locationReferencePoint = locationReferencePointDecoder.decode( lineLocationReference.getLocationReferencePoints(sequenceNumber - 1), sequenceNumber, sequenceNumber == lrpCount); locationReferencePoints.add(locationReferencePoint); } Offsets offsets = new OffsetsProtoImpl( lineLocationReference.getPositiveOffset(), lineLocationReference.getNegativeOffset()); return new RawLineLocRef(id, locationReferencePoints, offsets); } LineDecoder(LocationReferencePointDecoder locationReferencePointDecoder); }
LineDecoder implements LocationReferenceDecoder { @Override public RawLocationReference decode(String id, LocationReferenceData data) throws OpenLRProtoException { if (!data.hasLineLocationReference()) { throw new OpenLRProtoException(OpenLRProtoStatusCode.MISSING_LOCATION_REFERENCE); } LineLocationReference lineLocationReference = data.getLineLocationReference(); int lrpCount = lineLocationReference.getLocationReferencePointsCount(); if (lrpCount < 2) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_LOCATION_REFERENCE); } List<LocationReferencePoint> locationReferencePoints = new ArrayList<>(); for (int sequenceNumber = 1; sequenceNumber <= lrpCount; sequenceNumber++) { LocationReferencePoint locationReferencePoint = locationReferencePointDecoder.decode( lineLocationReference.getLocationReferencePoints(sequenceNumber - 1), sequenceNumber, sequenceNumber == lrpCount); locationReferencePoints.add(locationReferencePoint); } Offsets offsets = new OffsetsProtoImpl( lineLocationReference.getPositiveOffset(), lineLocationReference.getNegativeOffset()); return new RawLineLocRef(id, locationReferencePoints, offsets); } LineDecoder(LocationReferencePointDecoder locationReferencePointDecoder); @Override RawLocationReference decode(String id, LocationReferenceData data); }
LineDecoder implements LocationReferenceDecoder { @Override public RawLocationReference decode(String id, LocationReferenceData data) throws OpenLRProtoException { if (!data.hasLineLocationReference()) { throw new OpenLRProtoException(OpenLRProtoStatusCode.MISSING_LOCATION_REFERENCE); } LineLocationReference lineLocationReference = data.getLineLocationReference(); int lrpCount = lineLocationReference.getLocationReferencePointsCount(); if (lrpCount < 2) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_LOCATION_REFERENCE); } List<LocationReferencePoint> locationReferencePoints = new ArrayList<>(); for (int sequenceNumber = 1; sequenceNumber <= lrpCount; sequenceNumber++) { LocationReferencePoint locationReferencePoint = locationReferencePointDecoder.decode( lineLocationReference.getLocationReferencePoints(sequenceNumber - 1), sequenceNumber, sequenceNumber == lrpCount); locationReferencePoints.add(locationReferencePoint); } Offsets offsets = new OffsetsProtoImpl( lineLocationReference.getPositiveOffset(), lineLocationReference.getNegativeOffset()); return new RawLineLocRef(id, locationReferencePoints, offsets); } LineDecoder(LocationReferencePointDecoder locationReferencePointDecoder); @Override RawLocationReference decode(String id, LocationReferenceData data);  }