Omaha #3975 add right click export to GeoJSON
Change-Id: I78ad08bae1742c83145662a05d9a4064d9b6cb78 Former-commit-id: 6aeb14c3f04033d37cabcbb564a413bffd9868a9
This commit is contained in:
parent
baaabc6ebb
commit
f0290fb053
6 changed files with 114 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
||||||
Manifest-Version: 1.0
|
Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: Damage Path
|
Bundle-Name: Damage Path
|
||||||
Bundle-SymbolicName: com.raytheon.uf.viz.damagepath
|
Bundle-SymbolicName: com.raytheon.uf.viz.damagepath;singleton:=true
|
||||||
Bundle-Version: 1.15.0.qualifier
|
Bundle-Version: 1.15.0.qualifier
|
||||||
Bundle-Vendor: RAYTHEON
|
Bundle-Vendor: RAYTHEON
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||||
|
@ -10,5 +10,6 @@ Require-Bundle: com.raytheon.uf.viz.core;bundle-version="1.14.6",
|
||||||
com.raytheon.uf.common.time;bundle-version="1.14.0",
|
com.raytheon.uf.common.time;bundle-version="1.14.0",
|
||||||
com.raytheon.uf.common.geospatial;bundle-version="1.14.2",
|
com.raytheon.uf.common.geospatial;bundle-version="1.14.2",
|
||||||
com.raytheon.uf.common.json;bundle-version="1.0.0",
|
com.raytheon.uf.common.json;bundle-version="1.0.0",
|
||||||
org.eclipse.core.runtime;bundle-version="3.8.0"
|
org.eclipse.core.runtime;bundle-version="3.8.0",
|
||||||
|
com.raytheon.viz.ui;bundle-version="1.14.1"
|
||||||
Export-Package: com.raytheon.uf.viz.damagepath
|
Export-Package: com.raytheon.uf.viz.damagepath
|
||||||
|
|
|
@ -2,4 +2,5 @@ source.. = src/
|
||||||
output.. = bin/
|
output.. = bin/
|
||||||
bin.includes = META-INF/,\
|
bin.includes = META-INF/,\
|
||||||
.,\
|
.,\
|
||||||
localization/
|
localization/,\
|
||||||
|
plugin.xml
|
||||||
|
|
13
cave/com.raytheon.uf.viz.damagepath/plugin.xml
Normal file
13
cave/com.raytheon.uf.viz.damagepath/plugin.xml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<?eclipse version="3.4"?>
|
||||||
|
<plugin>
|
||||||
|
<extension
|
||||||
|
point="com.raytheon.viz.ui.contextualMenu">
|
||||||
|
<contextualMenu
|
||||||
|
actionClass="com.raytheon.uf.viz.damagepath.ExportDamagePathAction"
|
||||||
|
capabilityClass="com.raytheon.uf.viz.damagepath.DamagePathLayer"
|
||||||
|
name="Export GeoJSON"
|
||||||
|
sortID="3">
|
||||||
|
</contextualMenu>
|
||||||
|
</extension>
|
||||||
|
</plugin>
|
|
@ -185,7 +185,7 @@ public class DamagePathLayer<T extends DamagePathResourceData> extends
|
||||||
|
|
||||||
private LocalizationContext getUserContext() {
|
private LocalizationContext getUserContext() {
|
||||||
return PathManagerFactory.getPathManager().getContext(
|
return PathManagerFactory.getPathManager().getContext(
|
||||||
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
LocalizationType.COMMON_STATIC, LocalizationLevel.USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected LocalizationFile getDamagePathFile() {
|
protected LocalizationFile getDamagePathFile() {
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
/**
|
||||||
|
* This software was developed and / or modified by Raytheon Company,
|
||||||
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||||
|
*
|
||||||
|
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||||
|
* This software product contains export-restricted data whose
|
||||||
|
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||||
|
* to non-U.S. persons whether in the United States or abroad requires
|
||||||
|
* an export license or other authorization.
|
||||||
|
*
|
||||||
|
* Contractor Name: Raytheon Company
|
||||||
|
* Contractor Address: 6825 Pine Street, Suite 340
|
||||||
|
* Mail Stop B8
|
||||||
|
* Omaha, NE 68106
|
||||||
|
* 402.291.0100
|
||||||
|
*
|
||||||
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
|
* further licensing information.
|
||||||
|
**/
|
||||||
|
package com.raytheon.uf.viz.damagepath;
|
||||||
|
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.widgets.FileDialog;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
import com.raytheon.uf.common.json.geo.GeoJsonUtil;
|
||||||
|
import com.raytheon.uf.common.json.geo.GeoJsonUtilSimpleImpl;
|
||||||
|
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
|
import com.raytheon.uf.viz.core.VizApp;
|
||||||
|
import com.raytheon.viz.ui.VizWorkbenchManager;
|
||||||
|
import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action to export a damage path as GeoJSON to a file specified by the user.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Feb 9, 2015 3975 njensen Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author njensen
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ExportDamagePathAction extends AbstractRightClickAction {
|
||||||
|
|
||||||
|
protected static final transient IUFStatusHandler statusHandler = UFStatus
|
||||||
|
.getHandler(ExportDamagePathAction.class);
|
||||||
|
|
||||||
|
protected static final String[] EXTENSIONS = new String[] { "*.json" };
|
||||||
|
|
||||||
|
public ExportDamagePathAction() {
|
||||||
|
super("Export GeoJSON");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
VizApp.runSync(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Shell shell = VizWorkbenchManager.getInstance()
|
||||||
|
.getCurrentWindow().getShell();
|
||||||
|
FileDialog fd = new FileDialog(shell, SWT.SAVE);
|
||||||
|
fd.setFilterExtensions(EXTENSIONS);
|
||||||
|
String filename = fd.open();
|
||||||
|
|
||||||
|
if (filename != null) {
|
||||||
|
DamagePathLayer<?> layer = (DamagePathLayer<?>) getSelectedRsc();
|
||||||
|
try (FileOutputStream fos = new FileOutputStream(filename)) {
|
||||||
|
GeoJsonUtil json = new GeoJsonUtilSimpleImpl();
|
||||||
|
json.serialize(layer.getPolygon(), fos);
|
||||||
|
} catch (Exception e) {
|
||||||
|
statusHandler.error(
|
||||||
|
"Error exporting damage path file to "
|
||||||
|
+ filename, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -322,4 +322,9 @@ public class PolygonInputAdapter extends RscInputAdapter<PolygonLayer<?>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean availableForInput() {
|
||||||
|
return rsc != null && rsc.polygon != null && super.availableForInput();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue