File: LoadPhotosWithPointsCmd.java

package info (click to toggle)
gpsprune 26.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,824 kB
  • sloc: java: 52,154; sh: 25; makefile: 21; python: 15
file content (40 lines) | stat: -rw-r--r-- 976 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package tim.prune.cmd;

import tim.prune.data.DataPoint;
import tim.prune.data.MediaObject;
import tim.prune.data.Photo;

import java.util.ArrayList;
import java.util.List;

/**
 * Command to load photos which already have points connected
 */
public class LoadPhotosWithPointsCmd extends CompoundCommand
{
	public LoadPhotosWithPointsCmd(Photo inPhoto) {
		this(List.of(inPhoto));
	}

	public LoadPhotosWithPointsCmd(List<Photo> inPhotos)
	{
		ArrayList<DataPoint> points = new ArrayList<>();
		for (Photo photo : inPhotos)
		{
			if (photo.getDataPoint() != null) {
				points.add(photo.getDataPoint());
			}
		}
		addCommand(new AppendMediaCmd(convertToMediaList(inPhotos)));
		if (!points.isEmpty()) {
			addCommand(new AppendRangeCmd(points));
		}
	}

	/**
	 * Convert a list of photos into a list of media objects
	 */
	private List<MediaObject> convertToMediaList(List<Photo> inPhotos) {
		return new ArrayList<>(inPhotos);
	}
}