/** * Common logic for creating {@link DeviceLocation} from * {@link IDeviceLocationCreateRequest}. * * @param assignment * @param request * @return * @throws SiteWhereException */ public static DeviceLocation deviceLocationCreateLogic(IDeviceAssignment assignment, IDeviceLocationCreateRequest request) throws SiteWhereException { DeviceLocation location = new DeviceLocation(); deviceEventCreateLogic(request, assignment, location); location.setLatitude(request.getLatitude()); location.setLongitude(request.getLongitude()); location.setElevation(request.getElevation()); return location; }
/** * Common logic for creating {@link DeviceLocation} from * {@link IDeviceLocationCreateRequest}. * * @param assignment * @param request * @return * @throws SiteWhereException */ public static DeviceLocation deviceLocationCreateLogic(IDeviceAssignment assignment, IDeviceLocationCreateRequest request) throws SiteWhereException { DeviceLocation location = new DeviceLocation(); deviceEventCreateLogic(request, assignment, location); location.setLatitude(request.getLatitude()); location.setLongitude(request.getLongitude()); location.setElevation(request.getElevation()); return location; }
/** * Convert device location create request from API to GRPC. * * @param api * @return * @throws SiteWhereException */ public static GDeviceLocationCreateRequest asGrpcDeviceLocationCreateRequest(IDeviceLocationCreateRequest api) throws SiteWhereException { GDeviceLocationCreateRequest.Builder grpc = GDeviceLocationCreateRequest.newBuilder(); if (api.getLatitude() != null) { grpc.setLatitude(GOptionalDouble.newBuilder().setValue(api.getLatitude()).build()); } if (api.getLongitude() != null) { grpc.setLongitude(GOptionalDouble.newBuilder().setValue(api.getLongitude()).build()); } if (api.getElevation() != null) { grpc.setElevation(GOptionalDouble.newBuilder().setValue(api.getElevation()).build()); } grpc.setEvent(EventModelConverter.createGrpcDeviceEventCreateRequest(api)); return grpc.build(); }
payloadBuilder.setLatitude(GOptionalDouble.newBuilder().setValue(location.getLatitude())); payloadBuilder.setLongitude(GOptionalDouble.newBuilder().setValue(location.getLongitude())); payloadBuilder.setElevation(GOptionalDouble.newBuilder().setValue(location.getElevation()));
mb.setHardwareId(event.getHardwareId()); mb.setEventDate(location.getEventDate().getTime()); mb.setLatitude(location.getLatitude()); mb.setLongitude(location.getLongitude()); mb.setElevation(location.getElevation());