Advertisement
Guest User

Untitled

a guest
Sep 11th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. public byte[] setWatermark(byte[] bytes, Long locationPosition, Long timePosition, Map<String, Object> properties) {
  2. String longitude = null;
  3. String latitude = null;
  4. LocalDateTime time = null;
  5.  
  6. if (locationPosition != 0 && longitude != null && latitude != null) {
  7. bytes = createLocationWatermark(bytes, locationPosition, longitude, latitude);
  8. }
  9. if (timePosition != 0 && time != null) {
  10. bytes = createTimeWatermark(bytes, timePosition, time);
  11. }
  12. return bytes;
  13. }
  14.  
  15. public Map<String, Object> extractPropertiesFromDocument(Document document) {
  16. Map<String, Object> properties = new HashMap<>();
  17.  
  18. for (Property property : document.getProperties()) {
  19. if (property.getValue() != null) {
  20. if (property.getDisplayName().equals("Longitude")) {
  21. String longitude = property.getValue().toString();
  22. properties.put(longitude, longitude);
  23. }
  24. if (property.getDisplayName().equals("Latitude")) {
  25. String latitude = property.getValue().toString();
  26. properties.put(latitude, latitude);
  27. }
  28. if (property.getDisplayName().equals("Date and Time")) {
  29. LocalDateTime time = ((GregorianCalendar) property.getValue()).getTime().toInstant()
  30. .atZone(ZoneId.systemDefault()).toLocalDateTime();
  31. properties.put("time", time);
  32. }
  33. }
  34. }
  35. return properties;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement