@Test public void testPointAlongLineLocationReference() throws PhysicalFormatException { Coordinates firstCoordinates = Coordinates.newBuilder() .setLongitude(4) .setLatitude(5) .build(); LineAttributes firstLineAttributes = LineAttributes.newBuilder() .setBearing(120) .setFrc(FRC.FRC_3) .setFow(FOW.FOW_SLIPROAD) .build(); PathAttributes firstPathAttributes = PathAttributes.newBuilder() .setDistanceToNext(200) .setLowestFrcAlongPath(FRC.FRC_5) .build(); LocationReferencePoint first = LocationReferencePoint.newBuilder() .setCoordinates(firstCoordinates) .setLineAttributes(firstLineAttributes) .setPathAttributes(firstPathAttributes) .build(); Coordinates lastCoordinates = Coordinates.newBuilder() .setLongitude(4.2) .setLatitude(5.2) .build(); LineAttributes lastLineAttributes = LineAttributes.newBuilder() .setBearing(270) .setFrc(FRC.FRC_1) .setFow(FOW.FOW_MULTIPLE_CARRIAGEWAY) .build(); LocationReferencePoint last = LocationReferencePoint.newBuilder() .setCoordinates(lastCoordinates) .setLineAttributes(lastLineAttributes) .build(); PointAlongLineLocationReference pointAlongLineLocationReference = PointAlongLineLocationReference.newBuilder() .setFirst(first) .setLast(last) .setPositiveOffset(20) .setSideOfRoad(openlr.proto.schema.SideOfRoad.SIDE_OF_ROAD_RIGHT) .setOrientation(openlr.proto.schema.Orientation.ORIENTATION_BOTH) .build(); LocationReferenceData locationReferenceData = LocationReferenceData.newBuilder() .setPointAlongLineLocationReference(pointAlongLineLocationReference) .build(); LocationReference locationReference = new LocationReferenceProtoImpl("3", LocationType.POINT_ALONG_LINE, locationReferenceData); RawLocationReference rawLocationReference = decoder.decodeData(locationReference); assertNotNull(rawLocationReference); assertEquals(rawLocationReference.getID(), "3"); assertEquals(rawLocationReference.getLocationType(), LocationType.POINT_ALONG_LINE); assertTrue(rawLocationReference.isValid()); }
@Override public RawLocationReference decodeData(LocationReference data) throws PhysicalFormatException { LocationType locationType = data.getLocationType(); LocationReferenceDecoder locationReferenceDecoder = locationTypeDecoderRegistry.getDecoder(locationType); if (locationReferenceDecoder == null) { throw new OpenLRProtoException(OpenLRProtoStatusCode.UNSUPPORTED_LOCATION_TYPE); } Object locationReferenceData = data.getLocationReferenceData(); if (!(locationReferenceData instanceof LocationReferenceData)) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_DATA_TYPE); } return locationReferenceDecoder.decode(data.getID(), (LocationReferenceData) locationReferenceData); }
OpenLRProtoDecoder implements PhysicalDecoder { @Override public RawLocationReference decodeData(LocationReference data) throws PhysicalFormatException { LocationType locationType = data.getLocationType(); LocationReferenceDecoder locationReferenceDecoder = locationTypeDecoderRegistry.getDecoder(locationType); if (locationReferenceDecoder == null) { throw new OpenLRProtoException(OpenLRProtoStatusCode.UNSUPPORTED_LOCATION_TYPE); } Object locationReferenceData = data.getLocationReferenceData(); if (!(locationReferenceData instanceof LocationReferenceData)) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_DATA_TYPE); } return locationReferenceDecoder.decode(data.getID(), (LocationReferenceData) locationReferenceData); } }
OpenLRProtoDecoder implements PhysicalDecoder { @Override public RawLocationReference decodeData(LocationReference data) throws PhysicalFormatException { LocationType locationType = data.getLocationType(); LocationReferenceDecoder locationReferenceDecoder = locationTypeDecoderRegistry.getDecoder(locationType); if (locationReferenceDecoder == null) { throw new OpenLRProtoException(OpenLRProtoStatusCode.UNSUPPORTED_LOCATION_TYPE); } Object locationReferenceData = data.getLocationReferenceData(); if (!(locationReferenceData instanceof LocationReferenceData)) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_DATA_TYPE); } return locationReferenceDecoder.decode(data.getID(), (LocationReferenceData) locationReferenceData); }  }
OpenLRProtoDecoder implements PhysicalDecoder { @Override public RawLocationReference decodeData(LocationReference data) throws PhysicalFormatException { LocationType locationType = data.getLocationType(); LocationReferenceDecoder locationReferenceDecoder = locationTypeDecoderRegistry.getDecoder(locationType); if (locationReferenceDecoder == null) { throw new OpenLRProtoException(OpenLRProtoStatusCode.UNSUPPORTED_LOCATION_TYPE); } Object locationReferenceData = data.getLocationReferenceData(); if (!(locationReferenceData instanceof LocationReferenceData)) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_DATA_TYPE); } return locationReferenceDecoder.decode(data.getID(), (LocationReferenceData) locationReferenceData); }  @Override Class<?> getDataClass(); @Override RawLocationReference decodeData(LocationReference data); @Override String getDataFormatIdentifier(); }
OpenLRProtoDecoder implements PhysicalDecoder { @Override public RawLocationReference decodeData(LocationReference data) throws PhysicalFormatException { LocationType locationType = data.getLocationType(); LocationReferenceDecoder locationReferenceDecoder = locationTypeDecoderRegistry.getDecoder(locationType); if (locationReferenceDecoder == null) { throw new OpenLRProtoException(OpenLRProtoStatusCode.UNSUPPORTED_LOCATION_TYPE); } Object locationReferenceData = data.getLocationReferenceData(); if (!(locationReferenceData instanceof LocationReferenceData)) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_DATA_TYPE); } return locationReferenceDecoder.decode(data.getID(), (LocationReferenceData) locationReferenceData); }  @Override Class<?> getDataClass(); @Override RawLocationReference decodeData(LocationReference data); @Override String getDataFormatIdentifier();  }