diff --git a/plugins-dev/mjpeg/src/java/pt/lsts/neptus/plugins/mjpeg/VideoHudExporter.java b/plugins-dev/mjpeg/src/java/pt/lsts/neptus/plugins/mjpeg/VideoHudExporter.java index f77a96fe65..030061792f 100644 --- a/plugins-dev/mjpeg/src/java/pt/lsts/neptus/plugins/mjpeg/VideoHudExporter.java +++ b/plugins-dev/mjpeg/src/java/pt/lsts/neptus/plugins/mjpeg/VideoHudExporter.java @@ -104,7 +104,11 @@ public class VideoHudExporter implements MRAExporter { public VideoHudExporter(IMraLogGroup source) { - this.positions = new CorrectedPosition(source); + if (source.getCorrectedPosition() != null) { + this.positions = source.getCorrectedPosition(); + } + else { this.positions = new CorrectedPosition(source); } + this.frameDecoder = new FrameDecoderMotionJPEG(); hud = new MraVehiclePosHud(source, 180, 180); } diff --git a/plugins-dev/mjpeg/src/java/pt/lsts/neptus/plugins/mjpeg/VideoToPhotosFilter.java b/plugins-dev/mjpeg/src/java/pt/lsts/neptus/plugins/mjpeg/VideoToPhotosFilter.java index f1994d361a..b54d5652e7 100644 --- a/plugins-dev/mjpeg/src/java/pt/lsts/neptus/plugins/mjpeg/VideoToPhotosFilter.java +++ b/plugins-dev/mjpeg/src/java/pt/lsts/neptus/plugins/mjpeg/VideoToPhotosFilter.java @@ -72,7 +72,11 @@ public class VideoToPhotosFilter implements MRAExporter{ public VideoToPhotosFilter(IMraLogGroup source) { - this.positions = new CorrectedPosition(source); + if (source.getCorrectedPosition() != null) { + this.positions = source.getCorrectedPosition(); + } + else { this.positions = new CorrectedPosition(source); } + this.frameDecoder = new FrameDecoderMotionJPEG(); } diff --git a/plugins-dev/mra-plots/src/java/pt/lsts/neptus/plugins/mraplots/ImagePositionsExporter.java b/plugins-dev/mra-plots/src/java/pt/lsts/neptus/plugins/mraplots/ImagePositionsExporter.java index 6e3e083b8a..929bf99b15 100644 --- a/plugins-dev/mra-plots/src/java/pt/lsts/neptus/plugins/mraplots/ImagePositionsExporter.java +++ b/plugins-dev/mra-plots/src/java/pt/lsts/neptus/plugins/mraplots/ImagePositionsExporter.java @@ -51,8 +51,14 @@ @PluginDescription(name="Export image positions to CSV") public class ImagePositionsExporter implements MRAExporter { private CorrectedPosition positions; + public ImagePositionsExporter(IMraLogGroup source) { - positions = new CorrectedPosition(source); + if (source.getCorrectedPosition() != null) { + this.positions = source.getCorrectedPosition(); + } + else { + this.positions = new CorrectedPosition(source); + } } @Override diff --git a/src/java/pt/lsts/neptus/mra/MRAMenuBar.java b/src/java/pt/lsts/neptus/mra/MRAMenuBar.java index 12428e7258..a40877ef27 100644 --- a/src/java/pt/lsts/neptus/mra/MRAMenuBar.java +++ b/src/java/pt/lsts/neptus/mra/MRAMenuBar.java @@ -40,6 +40,7 @@ import java.lang.reflect.Constructor; import java.net.URI; import java.text.Collator; +import java.util.Arrays; import java.util.Collections; import java.util.LinkedHashMap; import java.util.LinkedHashSet; @@ -76,6 +77,7 @@ import pt.lsts.neptus.gui.PropertiesEditor; import pt.lsts.neptus.gui.WaitPanel; import pt.lsts.neptus.i18n.I18n; +import pt.lsts.neptus.mra.api.CorrectedPosition; import pt.lsts.neptus.mra.exporters.MRAExporter; import pt.lsts.neptus.mra.importers.IMraLogGroup; import pt.lsts.neptus.mra.importers.lsf.ConcatenateLsfLog; @@ -615,12 +617,25 @@ public void setUpExportersMenu(final IMraLogGroup source) { //Vector exporterList = new Vector<>(); + boolean useCP = false; + CorrectedPosition positions; + for (Class clazz : exporterMap.values()) { + + if (!useCP) { + if (Arrays.toString(clazz.getDeclaredFields()).contains("CorrectedPosition")) { + positions = new CorrectedPosition(source); + source.setCorrectedPosition(positions); + useCP = true; + } + } + Constructor[] constructors = clazz.getConstructors(); boolean added = false; for (Constructor c : constructors) { + if (c.getParameterTypes().length == 1 && c.getParameterTypes()[0].equals(IMraLogGroup.class)) { try { exporters.put(PluginUtils.getPluginI18nName(clazz), clazz.getConstructor(IMraLogGroup.class).newInstance(new Object[] { source })); diff --git a/src/java/pt/lsts/neptus/mra/importers/IMraLogGroup.java b/src/java/pt/lsts/neptus/mra/importers/IMraLogGroup.java index d53f19c9e7..9ef5b30e77 100644 --- a/src/java/pt/lsts/neptus/mra/importers/IMraLogGroup.java +++ b/src/java/pt/lsts/neptus/mra/importers/IMraLogGroup.java @@ -38,6 +38,7 @@ import java.util.LinkedHashMap; import pt.lsts.imc.lsf.LsfIndex; +import pt.lsts.neptus.mra.api.CorrectedPosition; /** * This interface is used to represent a logical group of log files. For instance, in a mission several log files are produced. @@ -85,4 +86,7 @@ public interface IMraLogGroup { public Collection getVehicleSources(); public LsfIndex getLsfIndex(); + + public void setCorrectedPosition(CorrectedPosition positions); + public CorrectedPosition getCorrectedPosition(); } diff --git a/src/java/pt/lsts/neptus/util/llf/LsfLogSource.java b/src/java/pt/lsts/neptus/util/llf/LsfLogSource.java index 2649869fb1..7fa8b60f31 100644 --- a/src/java/pt/lsts/neptus/util/llf/LsfLogSource.java +++ b/src/java/pt/lsts/neptus/util/llf/LsfLogSource.java @@ -48,6 +48,7 @@ import pt.lsts.imc.lsf.LsfIndex; import pt.lsts.imc.lsf.LsfIndexListener; import pt.lsts.neptus.NeptusLog; +import pt.lsts.neptus.mra.api.CorrectedPosition; import pt.lsts.neptus.mra.importers.IMraLog; import pt.lsts.neptus.mra.importers.IMraLogGroup; import pt.lsts.neptus.mra.importers.lsf.LsfMraLog; @@ -66,6 +67,7 @@ public class LsfLogSource implements IMraLogGroup { LsfIndexListener listener = null; String[] existingMessages = null; Collection vehicleSources; + CorrectedPosition positions; public LsfLogSource(String filename, LsfIndexListener listener) throws Exception { @@ -278,4 +280,10 @@ public Collection getVehicleSources() { public LsfIndex getLsfIndex() { return index; } + + @Override + public void setCorrectedPosition(CorrectedPosition newPositions) { positions = newPositions; } + + @Override + public CorrectedPosition getCorrectedPosition() { return positions; } }