Permalink
Browse files

Merge pull request #83 from jiwalker-usgs/master

Getting back into the swing of things with some cleanup
  • Loading branch information...
2 parents cee48f0 + 790a3c1 commit ddea73da11b8a0148daef368d9079431ce45b727 @jiwalker-usgs committed Feb 19, 2014
@@ -1,7 +1,3 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
package gov.usgs.cida.gdp.coreprocessing.analysis;
import com.google.common.base.Preconditions;
@@ -17,21 +13,15 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
-import java.io.FileWriter;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
-import java.util.Formatter;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.TimeZone;
-import org.geotools.data.FeatureSource;
-import org.geotools.data.FileDataStore;
-import org.geotools.data.FileDataStoreFinder;
import org.geotools.data.crs.ReprojectFeatureResults;
import org.geotools.feature.FeatureCollection;
import org.geotools.feature.FeatureIterator;
@@ -43,10 +33,6 @@
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.operation.TransformException;
import ucar.nc2.VariableSimpleIF;
-import ucar.nc2.constants.FeatureType;
-import ucar.nc2.ft.FeatureDataset;
-import ucar.nc2.ft.FeatureDatasetFactoryManager;
-import ucar.nc2.ft.FeatureDatasetPoint;
import ucar.nc2.ft.PointFeature;
import ucar.nc2.ft.PointFeatureIterator;
import ucar.nc2.ft.StationTimeSeriesFeature;
@@ -366,5 +352,5 @@ public void finish() {
nextTimeMillis = -1;
}
}
-
-}
+
+}
@@ -27,6 +27,9 @@
import ucar.nc2.ft.StationTimeSeriesFeatureCollection;
import ucar.nc2.units.DateRange;
+/**
+ * @deprecated I don't think this is used, but will just deprecate it for now
+ */
public class DelimitedWriter {
private static org.slf4j.Logger log = LoggerFactory.getLogger(DelimitedWriter.class);
public static boolean station(
@@ -37,8 +40,10 @@ public static boolean station(
throws FactoryException, SchemaException,
org.opengis.coverage.grid.InvalidRangeException,
TransformException, IOException {
- String outputFilePath = new File(System.getProperty("applicationWorkDir"),outputFile).getPath();
- log.debug(new StringBuilder("Attempting to write output to ").append(outputFilePath).toString());
+
+ boolean result = false;
+ String outputFilePath = new File(System.getProperty("applicationWorkDir"),outputFile).getPath();
+ log.debug(new StringBuilder("Attempting to write output to ").append(outputFilePath).toString());
FeatureDatasetPoint fdp = (FeatureDatasetPoint) featureDataset;
List<ucar.nc2.ft.FeatureCollection> fcl = fdp.getPointFeatureCollectionList();
if (fcl != null && fcl.size() == 1) {
@@ -78,22 +83,22 @@ public static boolean station(
if (writer != null) {
try {
writer.close();
- return true;
+ result = true;
} catch (IOException e) {
- return true;
+ result = true;
}
}
}
} else {
log.debug(new StringBuilder("Failed to write output to ").append(outputFilePath).toString());
- return false;
+ result = false;
}
} else {
log.debug(new StringBuilder("Failed to write output to ").append(outputFilePath).toString());
- return false;
+ result = false;
}
- log.debug(new StringBuilder("Successfully wrote output to ").append(outputFilePath).toString());
- return true;
+ log.debug(new StringBuilder("Successfully wrote output to ").append(outputFilePath).toString());
+ return result;
}
}
@@ -42,9 +42,8 @@
* - Others may work
*
* WMS 1.3.0 definitely does not work, do not proxy these
- * @param capabiltiesRoot GetCapabilities document or root element node
+ * @param rootDocumentNode
* @return Set of endpoints found
- * @throws XPathExpressionException
*/
public static Set<Endpoint> getOperationEndpoints(Node rootDocumentNode) {
Set<Endpoint> endpointSet = new HashSet<Endpoint>();
@@ -59,15 +58,19 @@
Endpoint end = new Endpoint(n.getNodeValue());
endpointSet.add(end);
}
- return endpointSet;
}
catch (XPathExpressionException xpee) {
+ // just return an empty set here
}
- finally {
- return endpointSet;
- }
+ return endpointSet;
}
+ /**
+ * Tests endpoint to decide whether it is an OWS service
+ *
+ * @param owsEndpoint URL wrapper Endpoint to test
+ * @return true if valid OWS endpoint
+ */
public static boolean isOWSEndpoint(Endpoint owsEndpoint) {
if (owsEndpoint.getType() != Endpoint.EndpointType.UNKNOWN) {
Document doc = getCapabilitiesDocument(owsEndpoint);
@@ -100,6 +103,12 @@ public static boolean isOWSEndpoint(Endpoint owsEndpoint) {
return false;
}
+ /**
+ * Call get capabilities and return the XML document
+ *
+ * @param endpoint ows endpoint to get document from
+ * @return Document with the get capabilities response
+ */
public static Document getCapabilitiesDocument(Endpoint endpoint) {
Document doc = null;
InputStream inputStream = null;
@@ -122,7 +131,7 @@ public static Document getCapabilitiesDocument(Endpoint endpoint) {
}
finally {
IOUtils.closeQuietly(inputStream);
- return doc;
}
+ return doc;
}
}

0 comments on commit ddea73d

Please sign in to comment.