Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4992 check fixwrapper visible #5005

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

import Debrief.GUI.Frames.Application;
import Debrief.ReaderWriter.GeoPDF.AbstractGeoPDFBuilder.GeoPDFConfiguration;
import Debrief.Wrappers.Track.LightweightTrackWrapper;
import Debrief.ReaderWriter.GeoPDF.GeoPDF;
import Debrief.ReaderWriter.GeoPDF.GeoPDFSegmentedBuilder;
import MWC.GUI.Editable;
Expand All @@ -60,7 +61,7 @@ protected void execute() {
try {
final PlainChart theChart = getChart();
final Layers theLayers = theChart.getLayers();
final TimePeriod period = theLayers.getTimePeriod();
final TimePeriod period = calculatePeriod(theLayers);
final GeoPDFConfiguration configuration = new GeoPDFConfiguration();
final IChartBasedEditor editorBasedEditor = getEditor();

Expand Down Expand Up @@ -128,6 +129,38 @@ private static MultiStatus createMultiStatus(String msg, Throwable t) {
childStatuses.toArray(new Status[] {}), t.toString(), t);
return ms;
}

public TimePeriod calculatePeriod(final Layers theLayers) {
TimePeriod ans = null;

/**
* Let's iterate over all the layers to find the Tracks to export
*/
final Enumeration<Editable> enumerationNonInteractive = theLayers.elements();
while (enumerationNonInteractive.hasMoreElements()) {
final Editable currentEditable = enumerationNonInteractive.nextElement();
if (currentEditable instanceof LightweightTrackWrapper) {

final LightweightTrackWrapper currentTrack = (LightweightTrackWrapper) currentEditable;

/**
* Let's draw only visible tracks.
*/
if (currentTrack.getVisible()) {
final TimePeriod currentPeriod = currentTrack.getVisiblePeriod();
if (ans == null) {
ans = currentPeriod;
}else {
ans.extend(currentPeriod.getStartDTG());
ans.extend(currentPeriod.getEndDTG());
}
}
}

}

return ans;
}

public void loadBackgroundLayers(final Layers theLayers, final GeoPDFConfiguration configuration) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,16 @@ protected void createLabelsLayer(final GeoPDFConfiguration configuration, final

final FixWrapper[] fixes = currentTrack.getFixes();
for (int i = 0; i < fixes.length; i++) {
if ((period == null || period.contains(fixes[i].getDTG())) && fixes[i].getLabelShowing()) {
final String vectorName = sanitizeFilename(currentTrack.getName() + "_LABEL_"
+ HiResDateToFileName(fixes[i].getDTG()));
if ((period == null || period.contains(fixes[i].getDTG())) && fixes[i].getLabelShowing()
&& fixes[i].getVisible()) {
final String vectorName = sanitizeFilename(
currentTrack.getName() + "_LABEL_" + HiResDateToFileName(fixes[i].getDTG()));
final SegmentedGeoJSONConfiguration segmentConfiguration = new SegmentedGeoJSONConfiguration(vectorName,
GeometryType.Point);
segmentConfiguration.addProperty("elevation", fixes[i].getLocation().getDepth() + "");
segmentConfiguration.addProperty("longitude", fixes[i].getLocation().getLong() + "");
segmentConfiguration.addProperty("latitude", fixes[i].getLocation().getLat() + "");
segmentConfiguration.addProperty("time",
HiResDateToFileName(fixes[i].getDTG()));
segmentConfiguration.addProperty("time", HiResDateToFileName(fixes[i].getDTG()));
segmentConfiguration.addProperty("course", fixes[i].getCourse() + "");
segmentConfiguration.addProperty("speed", fixes[i].getSpeed() + "");
segmentConfiguration.addProperty("time_str",
Expand Down Expand Up @@ -296,16 +296,16 @@ public void createTicksLayer(final GeoPDFConfiguration configuration, final Arra

final FixWrapper[] fixes = currentTrack.getFixes();
for (int i = 0; i < fixes.length; i++) {
if ((period == null || period.contains(fixes[i].getDTG())) && fixes[i].getSymbolShowing()) {
final String vectorName = sanitizeFilename(currentTrack.getName() + "_TICKS_"
+ HiResDateToFileName(fixes[i].getDTG()));
if ((period == null || period.contains(fixes[i].getDTG())) && fixes[i].getSymbolShowing()
&& fixes[i].getVisible()) {
final String vectorName = sanitizeFilename(
currentTrack.getName() + "_TICKS_" + HiResDateToFileName(fixes[i].getDTG()));
final SegmentedGeoJSONConfiguration segmentConfiguration = new SegmentedGeoJSONConfiguration(vectorName,
GeometryType.Point);
segmentConfiguration.addProperty("elevation", fixes[i].getLocation().getDepth() + "");
segmentConfiguration.addProperty("longitude", fixes[i].getLocation().getLong() + "");
segmentConfiguration.addProperty("latitude", fixes[i].getLocation().getLat() + "");
segmentConfiguration.addProperty("time",
HiResDateToFileName(fixes[i].getDTG()));
segmentConfiguration.addProperty("time", HiResDateToFileName(fixes[i].getDTG()));
segmentConfiguration.addProperty("course", fixes[i].getCourse() + "");
segmentConfiguration.addProperty("speed", fixes[i].getSpeed() + "");
segmentConfiguration.addCoordinate(
Expand Down Expand Up @@ -338,15 +338,13 @@ protected void createTrackLine(final GeoPDFConfiguration configuration, final Ar
throws FileNotFoundException, JsonProcessingException {
final FixWrapper[] fixes = currentTrack.getFixes();
for (int i = 0; i < fixes.length - 1; i++) {
if (period == null || period.contains(fixes[i].getDTG())) {
final String vectorName = sanitizeFilename(currentTrack.getName() + "_LINE_"
+ HiResDateToFileName(fixes[i].getDTG()));
if ((period == null || period.contains(fixes[i].getDTG())) && fixes[i].getVisible()) {
final String vectorName = sanitizeFilename(
currentTrack.getName() + "_LINE_" + HiResDateToFileName(fixes[i].getDTG()));
final SegmentedGeoJSONConfiguration configurationGeojson = new SegmentedGeoJSONConfiguration(vectorName,
GeometryType.MultiLineString);
configurationGeojson.addProperty("begin",
HiResDateToFileName(fixes[i].getDTG()));
configurationGeojson.addProperty("end",
HiResDateToFileName(fixes[i + 1].getDTG()));
configurationGeojson.addProperty("begin", HiResDateToFileName(fixes[i].getDTG()));
configurationGeojson.addProperty("end", HiResDateToFileName(fixes[i + 1].getDTG()));
configurationGeojson.addCoordinate(
new double[] { fixes[i].getLocation().getLong(), fixes[i].getLocation().getLat() });
configurationGeojson.addCoordinate(
Expand Down