@Test public void testMissingLocationReference() { LocationReferenceData locationReferenceData = LocationReferenceData.newBuilder() .build(); try { polygonDecoder.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.hasPolygonLocationReference()) { throw new OpenLRProtoException(OpenLRProtoStatusCode.MISSING_LOCATION_REFERENCE); } PolygonLocationReference polygonLocationReference = data.getPolygonLocationReference(); if (polygonLocationReference.getCoordinatesCount() == 0) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_LOCATION_REFERENCE); } List<GeoCoordinates> cornerPoints = new ArrayList<>(); for (Coordinates coordinates : polygonLocationReference.getCoordinatesList()) { GeoCoordinatesProtoImpl cornerPoint = new GeoCoordinatesProtoImpl(coordinates.getLongitude(), coordinates.getLatitude()); cornerPoints.add(cornerPoint); } return new RawPolygonLocRef(id, cornerPoints); }
PolygonDecoder implements LocationReferenceDecoder { @Override public RawLocationReference decode(String id, LocationReferenceData data) throws OpenLRProtoException { if (!data.hasPolygonLocationReference()) { throw new OpenLRProtoException(OpenLRProtoStatusCode.MISSING_LOCATION_REFERENCE); } PolygonLocationReference polygonLocationReference = data.getPolygonLocationReference(); if (polygonLocationReference.getCoordinatesCount() == 0) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_LOCATION_REFERENCE); } List<GeoCoordinates> cornerPoints = new ArrayList<>(); for (Coordinates coordinates : polygonLocationReference.getCoordinatesList()) { GeoCoordinatesProtoImpl cornerPoint = new GeoCoordinatesProtoImpl(coordinates.getLongitude(), coordinates.getLatitude()); cornerPoints.add(cornerPoint); } return new RawPolygonLocRef(id, cornerPoints); } }
PolygonDecoder implements LocationReferenceDecoder { @Override public RawLocationReference decode(String id, LocationReferenceData data) throws OpenLRProtoException { if (!data.hasPolygonLocationReference()) { throw new OpenLRProtoException(OpenLRProtoStatusCode.MISSING_LOCATION_REFERENCE); } PolygonLocationReference polygonLocationReference = data.getPolygonLocationReference(); if (polygonLocationReference.getCoordinatesCount() == 0) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_LOCATION_REFERENCE); } List<GeoCoordinates> cornerPoints = new ArrayList<>(); for (Coordinates coordinates : polygonLocationReference.getCoordinatesList()) { GeoCoordinatesProtoImpl cornerPoint = new GeoCoordinatesProtoImpl(coordinates.getLongitude(), coordinates.getLatitude()); cornerPoints.add(cornerPoint); } return new RawPolygonLocRef(id, cornerPoints); }  }
PolygonDecoder implements LocationReferenceDecoder { @Override public RawLocationReference decode(String id, LocationReferenceData data) throws OpenLRProtoException { if (!data.hasPolygonLocationReference()) { throw new OpenLRProtoException(OpenLRProtoStatusCode.MISSING_LOCATION_REFERENCE); } PolygonLocationReference polygonLocationReference = data.getPolygonLocationReference(); if (polygonLocationReference.getCoordinatesCount() == 0) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_LOCATION_REFERENCE); } List<GeoCoordinates> cornerPoints = new ArrayList<>(); for (Coordinates coordinates : polygonLocationReference.getCoordinatesList()) { GeoCoordinatesProtoImpl cornerPoint = new GeoCoordinatesProtoImpl(coordinates.getLongitude(), coordinates.getLatitude()); cornerPoints.add(cornerPoint); } return new RawPolygonLocRef(id, cornerPoints); }  @Override RawLocationReference decode(String id, LocationReferenceData data); }
PolygonDecoder implements LocationReferenceDecoder { @Override public RawLocationReference decode(String id, LocationReferenceData data) throws OpenLRProtoException { if (!data.hasPolygonLocationReference()) { throw new OpenLRProtoException(OpenLRProtoStatusCode.MISSING_LOCATION_REFERENCE); } PolygonLocationReference polygonLocationReference = data.getPolygonLocationReference(); if (polygonLocationReference.getCoordinatesCount() == 0) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_LOCATION_REFERENCE); } List<GeoCoordinates> cornerPoints = new ArrayList<>(); for (Coordinates coordinates : polygonLocationReference.getCoordinatesList()) { GeoCoordinatesProtoImpl cornerPoint = new GeoCoordinatesProtoImpl(coordinates.getLongitude(), coordinates.getLatitude()); cornerPoints.add(cornerPoint); } return new RawPolygonLocRef(id, cornerPoints); }  @Override RawLocationReference decode(String id, LocationReferenceData data);  }