Search in sources :

Example 1 with DescribeResult

use of org.geotools.process.factory.DescribeResult in project coastal-hazards by USGS-CIDA.

the class FetchAndUnzipProcess method execute.

@DescribeResult(name = "filePath", description = "path to the unzipped file")
public String execute(@DescribeParameter(name = "zipUrl", min = 1, max = 1, description = "URL to the zipped file to retrieve") String zipUrl, @DescribeParameter(name = "token", min = 1, max = 1, description = "Token for authorizing the upload") String token) {
    String unzippedPath = null;
    File unzippedFile = null;
    if (zipUrl.isEmpty() || token.isEmpty()) {
        LOGGER.info("Missing zipUrl or token in the FetchAndUnzipProcess.");
    } else {
        LOGGER.info("In FetchAndUnzipProcess on Geoserver with zip url and token:" + zipUrl);
    }
    if (isAuthorized(token)) {
        ZipInputStream zipStream = getZipFromUrl(zipUrl, getHttpClient());
        unzippedFile = unzipToDir(zipStream, getNewZipDestination());
        unzippedPath = unzippedFile.getAbsolutePath();
    } else {
        throw new ProcessException(new SecurityException("Not Authorized."));
    }
    return unzippedPath;
}
Also used : ZipInputStream(java.util.zip.ZipInputStream) ProcessException(org.geotools.process.ProcessException) File(java.io.File) DescribeResult(org.geotools.process.factory.DescribeResult)

Example 2 with DescribeResult

use of org.geotools.process.factory.DescribeResult in project coastal-hazards by USGS-CIDA.

the class RibboningProcess method execute.

@DescribeResult(name = "result", description = "Layer with ribboned clones")
public SimpleFeatureCollection execute(// geometry + attributes come from the SLD, may be static in SLD or parameters that come directly from standard WMS, can look at the geoserver rendering transforms to see what is going on here
@DescribeParameter(name = "features", min = 1, max = 1) SimpleFeatureCollection features, @DescribeParameter(name = "bbox", min = 0, max = 1) ReferencedEnvelope bbox, @DescribeParameter(name = "width", min = 1, max = 1) Integer width, @DescribeParameter(name = "height", min = 1, max = 1) Integer height, @DescribeParameter(name = "invert-side", min = 0, max = 1) Boolean invertSide, @DescribeParameter(name = "calcAngles", min = 0, max = 1) Boolean calcAngles, // which ribbon it is in the set, to be ribboned correctly, all child items in an aggregate ribboned parent must share the same bbox, if they do not, the ribboning process starts over and you'll get overlapping ribbons
@DescribeParameter(name = "ribbon-count", min = 0, max = 1) Integer ribbonCount, // how many pixels is the offset, maybe set in the sld
@DescribeParameter(name = "offset", min = 0, max = 1) Integer offset, // this is the bug ticket we have; given the feature collection it should order first N-S, the attribute it's using might be incorrect, because they're not in the right order, everything is defaulting to 45 degrees at certain zoom levels?
@DescribeParameter(name = "sort-attribute", min = 0, max = 1) String sortAttribute, // which zoom level we're at, m/pixel
@DescribeParameter(name = "scale", min = 0, max = 1) Double scale) throws Exception {
    // whether or not the ribbons should be inverted, set to default false if not passed in
    if (null == invertSide) {
        invertSide = Boolean.FALSE;
    }
    // whether or not the angles are calculated, set to default false if not passed in
    if (null == calcAngles) {
        calcAngles = Boolean.FALSE;
    }
    // which ribbon currently we're working on, if not provided, defaults to 1
    if (null == ribbonCount) {
        ribbonCount = 1;
    }
    // how many pixels the offset between the ribbons is, defaults to 5 if not provided
    if (null == offset) {
        offset = 5;
    }
    // which zoom level we're at to know what constants to use in calculations
    if (null == scale) {
        scale = Double.MAX_VALUE;
    }
    SimpleFeatureCollection featuresToProcess = features;
    // the attribute to sort the features by, if it's not null
    if (null != sortAttribute) {
        featuresToProcess = sortFeatures(sortAttribute, features);
    }
    CoordinateReferenceSystem bboxCRS = bbox.getCoordinateReferenceSystem();
    CoordinateReferenceSystem featureCRS = CRSUtils.getCRSFromFeatureCollection(featuresToProcess);
    // calculate the offset of the ribbon based on the bbox, coordinate systems, window size, offset and scale
    double[] xyOffset = getXYOffset(bbox, bboxCRS, featureCRS, width, height, offset, scale);
    return new Process(featuresToProcess, invertSide, sortAttribute, calcAngles, ribbonCount, xyOffset).execute();
}
Also used : GeoServerProcess(org.geoserver.wps.gs.GeoServerProcess) DescribeProcess(org.geotools.process.factory.DescribeProcess) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) SortedSimpleFeatureCollection(org.geotools.feature.collection.SortedSimpleFeatureCollection) SimpleFeatureCollection(org.geotools.data.simple.SimpleFeatureCollection) DescribeResult(org.geotools.process.factory.DescribeResult)

Aggregations

DescribeResult (org.geotools.process.factory.DescribeResult)2 File (java.io.File)1 ZipInputStream (java.util.zip.ZipInputStream)1 GeoServerProcess (org.geoserver.wps.gs.GeoServerProcess)1 SimpleFeatureCollection (org.geotools.data.simple.SimpleFeatureCollection)1 SortedSimpleFeatureCollection (org.geotools.feature.collection.SortedSimpleFeatureCollection)1 ProcessException (org.geotools.process.ProcessException)1 DescribeProcess (org.geotools.process.factory.DescribeProcess)1 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)1