Skip to content

Wcs handle errors #150

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

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Changes from all 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
2 changes: 2 additions & 0 deletions src/gov/nasa/worldwind/data/BasicRasterServer.java
Original file line number Diff line number Diff line change
@@ -140,6 +140,8 @@ protected void init(Object o)
String message = Logging.getMessage("generic.DataSetLimitedAvailability", this.getDataSetName() );
Logging.logger().severe(message);
}

config.dispose();
}

protected String getDataSetName()
10 changes: 10 additions & 0 deletions src/gov/nasa/worldwind/data/RasterServerConfiguration.java
Original file line number Diff line number Diff line change
@@ -143,6 +143,16 @@ public RasterServerConfiguration(Object docSource)

this.initialize();
}

public void dispose() {
try {
eventReader.close();
} catch (XMLStreamException e) {
e.printStackTrace();
}
WWXML.closeEventReader(eventReader, "RasterServerConfiguration");
freeResources();
}

protected void initialize()
{
1 change: 1 addition & 0 deletions src/gov/nasa/worldwind/terrain/BasicElevationModel.java
Original file line number Diff line number Diff line change
@@ -385,6 +385,7 @@ protected ElevationTile createTile(TileKey key)
Angle minLongitude = ElevationTile.computeColumnLongitude(key.getColumn(), dLon, lonOrigin);

Sector tileSector = new Sector(minLatitude, minLatitude.add(dLat), minLongitude, minLongitude.add(dLon));
tileSector = levels.getSector().intersection(tileSector);

return new ElevationTile(tileSector, level, key.getRow(), key.getColumn());
}
14 changes: 12 additions & 2 deletions src/gov/nasa/worldwind/util/DataConfigurationUtils.java
Original file line number Diff line number Diff line change
@@ -753,8 +753,9 @@ public static AVList getWMSLayerConfigParams(WMSCapabilities caps, String[] form
WMSLayerCapabilities layerCaps = caps.getLayerByName(name);
if (layerCaps == null)
{
Logging.logger().warning(Logging.getMessage("WMS.LayerNameMissing", name));
continue;
String msg = Logging.getMessage("WMS.LayerNameMissing", name);
Logging.logger().warning(msg);
throw new WWRuntimeException(msg);
}

if (layerCaps.hasCoordinateSystem("EPSG:4326"))
@@ -903,6 +904,13 @@ public static AVList getWCSConfigParameters(WCS100Capabilities caps, WCS100Descr
throw new IllegalArgumentException(message);
}

if (coverage.getCoverageOfferings().size() == 0)
{
String message = Logging.getMessage("AbsentResourceList.WCSDescribeCoverage");
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}

if (params == null)
{
String message = Logging.getMessage("nullValue.ParametersIsNull");
@@ -1135,6 +1143,8 @@ protected static String makeTitle(WMSCapabilities caps, String layerNames, Strin

String layerName = lNames[i];
WMSLayerCapabilities layer = caps.getLayerByName(layerName);
if (layer == null) continue; // layer not found

String layerTitle = layer.getTitle();
sb.append(layerTitle != null ? layerTitle : layerName);

1 change: 1 addition & 0 deletions src/gov/nasa/worldwind/util/MessageStrings.properties
Original file line number Diff line number Diff line change
@@ -743,6 +743,7 @@ AbsentResourceList.MaxTriesLessThanOne=The specified maximum number of tries is
AbsentResourceList.CheckIntervalLessThanZero=The specified check interval is less than 0
AbsentResourceList.RetryIntervalLessThanZero=The specified retry interval is less than 0
AbsentResourceList.MaximumListSizeLessThanOne=The requested maximum list size is less than 1
AbsentResourceList.WCSDescribeCoverage=No coverage offering from WCS

AVAAccessibleImpl.AttributeValueForKeyIsNotAString=Attribute value for key is not a String. Key {0}

33 changes: 24 additions & 9 deletions src/gov/nasa/worldwind/util/WWXML.java
Original file line number Diff line number Diff line change
@@ -39,6 +39,8 @@ public class WWXML
{
public static final String XLINK_URI = "http://www.w3.org/1999/xlink";

private static Map<XMLEventReader, InputStream> inputSources = new HashMap<XMLEventReader, InputStream>();

/**
* Create a DOM builder.
*
@@ -170,9 +172,12 @@ public static Document openDocumentFile(String filePath, Class c)
throw new IllegalArgumentException(message);
}

InputStream inputStream = WWIO.openFileOrResourceStream(filePath, c);

return inputStream != null ? openDocumentStream(inputStream) : null;
try (InputStream inputStream = WWIO.openFileOrResourceStream(filePath, c)) {
return inputStream != null ? openDocumentStream(inputStream) : null;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}

/**
@@ -273,10 +278,7 @@ public static void saveDocumentToFile(Document doc, String filePath)
throw new IllegalArgumentException(message);
}

try
{
java.io.FileOutputStream outputStream = new java.io.FileOutputStream(filePath);

try (java.io.FileOutputStream outputStream = new java.io.FileOutputStream(filePath)) {
saveDocumentToStream(doc, outputStream);
}
catch (IOException e)
@@ -356,7 +358,9 @@ public static XMLEventReader openEventReaderStream(InputStream inputStream, bool

try
{
return inputFactory.createXMLEventReader(inputStream);
XMLEventReader reader = inputFactory.createXMLEventReader(inputStream);
inputSources.put(reader, inputStream);
return reader;
}
catch (XMLStreamException e)
{
@@ -440,7 +444,9 @@ public static XMLEventReader openEventReaderURL(URL url, boolean isNamespaceAwar
try
{
InputStream inputStream = url.openStream();
return openEventReaderStream(inputStream, isNamespaceAware);
XMLEventReader reader = openEventReaderStream(inputStream, isNamespaceAware);
inputSources.put(reader, inputStream);
return reader;
}
catch (IOException e)
{
@@ -531,6 +537,15 @@ public static void closeEventReader(XMLEventReader eventReader, String name)
try
{
eventReader.close();
InputStream is = inputSources.get(eventReader);
if (is != null) {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
inputSources.remove(eventReader);
}
}
catch (XMLStreamException e)
{
6 changes: 3 additions & 3 deletions src/gov/nasa/worldwindx/examples/dataimport/InstallDTED.java
Original file line number Diff line number Diff line change
@@ -148,9 +148,9 @@ protected void findDTEDFiles(File directory, ArrayList<File> files)
{
this.findDTEDFiles(file, files);
}
else if (file.getName().endsWith("dt0")
|| file.getName().endsWith("dt1")
|| file.getName().endsWith("dt2"))
else if (file.getName().toLowerCase().endsWith("dt0")
|| file.getName().toLowerCase().endsWith("dt1")
|| file.getName().toLowerCase().endsWith("dt2"))
{
files.add(file);
}
Original file line number Diff line number Diff line change
@@ -127,6 +127,7 @@ protected boolean isUpToDate(WorldWindow wwd)

if (!(wwd.getModel().getGlobe().getElevationModel() instanceof CompoundElevationModel))
{
if (this.modelPanels.size() == 0) return false;
return this.modelPanels.get(0).getElevationModel() == wwd.getModel().getGlobe().getElevationModel();
}

22 changes: 18 additions & 4 deletions src/gov/nasa/worldwindx/examples/util/WCSCoveragePanel.java
Original file line number Diff line number Diff line change
@@ -100,7 +100,9 @@ protected void load()
{
e.printStackTrace();
Container c = WCSCoveragePanel.this.getParent();
c.remove(WCSCoveragePanel.this);
if (c != null)
c.remove(WCSCoveragePanel.this);

JOptionPane.showMessageDialog((Component) wwd, "Unable to connect to server " + serverURI.toString(),
"Server Error", JOptionPane.ERROR_MESSAGE);
return;
@@ -192,8 +194,10 @@ public void actionPerformed(ActionEvent actionEvent)
// If the coverage is selected, add it to the WorldWindow's current model, else remove it from the model.
if (((JCheckBox) actionEvent.getSource()).isSelected())
{
if (this.component == null)
if (this.component == null) {
this.component = createComponent(coverageInfo.caps, coverageInfo);
if (this.component == null) return;
}

updateComponent(this.component, true);
}
@@ -224,8 +228,18 @@ protected CoverageInfo createCoverageInfo(WCS100Capabilities caps, WCS100Coverag
protected void updateComponent(Object component, boolean enable)
{
ElevationModel model = (ElevationModel) component;
CompoundElevationModel compoundModel =
(CompoundElevationModel) this.wwd.getModel().getGlobe().getElevationModel();
CompoundElevationModel compoundModel;

// Guarantee that we have a compound elevation model, so additional elevation models can be added.
ElevationModel em = this.wwd.getModel().getGlobe().getElevationModel();

if (!(em instanceof CompoundElevationModel)) {
compoundModel = new CompoundElevationModel();
compoundModel.addElevationModel(em);
this.wwd.getModel().getGlobe().setElevationModel(compoundModel);
} else {
compoundModel = (CompoundElevationModel) em;
}

if (enable)
{