Package org.geoserver.wps

Examples of org.geoserver.wps.WPSException


       
        if(ioParams.size() == 0) {
            return response;
        }
        if(ioParams.size() > 1) {
            throw new WPSException("There can be only one RawDataOutput");
        }
       
        response.setRawDataOutput(parseOutputDefinitionType(resultInfo, factory, ioParams.get(0), false));
       
        return response;
View Full Code Here


                    builder.add(stats.getAverage());
                    builder.add(stats.getStandardDeviation());
                }
                return builder.buildFeature(zone.getID());
            } catch (Exception e) {
                throw new WPSException("Failed to compute statistics on feature " + zone, e);
            }
        }
View Full Code Here

            @DescribeParameter(name = "second feature collection", description = "Second feature collection") SimpleFeatureCollection secondFeatures) {
        if (!(firstFeatures.features().next().getDefaultGeometry() instanceof MultiPolygon)
                && !(firstFeatures.features().next().getDefaultGeometry() instanceof Polygon)
                && !(firstFeatures.features().next().getDefaultGeometry() instanceof MultiLineString)
                && !(firstFeatures.features().next().getDefaultGeometry() instanceof LineString)) {
            throw new WPSException("First feature collection must be polygonal or linear");
        } else {
            return new IntersectedFeatureCollection(firstFeatures, secondFeatures);
        }
    }
View Full Code Here

            CoordinateReferenceSystem epsg4326;
            try {
                epsg4326 = CRS.decode("EPSG:4326");
            } catch (Exception e) {
                throw new WPSException("Unknown CRS code: EPSG:4326", e);
            }
            MathTransform crsTransform = CRS.findMathTransform(crs, epsg4326);

            FeatureCollection results = FeatureCollections.newCollection();
            FeatureType targetFeatureType = createTargetFeatureType(featureCollection.getSchema());
            Unit fromUnit = SI.METER;
            Unit toUnit = Unit.valueOf("mi");
            UnitConverter unitConvert = fromUnit.getConverterTo(toUnit);
            Feature nearestFeature = null;
            double nearestDistance = 9e9;
            double nearestBearing = 0;
            Iterator featureIterator = null;
            double[] nearestPoint = new double[2];
            try {
                featureIterator = featureCollection.iterator();
                while (featureIterator.hasNext()) {
                    SimpleFeature f = (SimpleFeature) featureIterator.next();
                    if (f.getDefaultGeometryProperty().getValue() == null)
                        continue;
                    DistanceOp op = new DistanceOp(point, (Geometry) f.getDefaultGeometryProperty()
                            .getValue());
                    Coordinate[] co = op.closestPoints();
                    double[] co0 = new double[] { co[0].x, co[0].y, };
                    double[] co1 = new double[] { co[1].x, co[1].y, };
                    double[] geo0 = new double[2];
                    double[] geo1 = new double[2];
                    crsTransform.transform(co0, 0, geo0, 0, 1);
                    crsTransform.transform(co1, 0, geo1, 0, 1);

                    // get distance
                    Measure m = DefaultGeographicCRS.WGS84.distance(geo0, geo1);
                    if (m.doubleValue() > nearestDistance)
                        continue;
                    nearestFeature = f;
                    nearestDistance = m.doubleValue();
                    nearestBearing = calcBearing(co);
                    nearestPoint[0] = geo1[0];
                    nearestPoint[1] = geo1[1];
                }
            } finally {
                if (featureIterator != null)
                    featureCollection.close(featureIterator);
            }
            if (nearestFeature != null) {
                nearestDistance = unitConvert.convert(nearestDistance);
                results.add(createTargetFeature(nearestFeature,
                        (SimpleFeatureType) targetFeatureType, nearestPoint, nearestDistance,
                        nearestBearing));
            }
            return results;
        } catch (WPSException e) {
            throw e;
        } catch (Throwable e) {
            LOGGER.warning("Error executing method: " + e);
            throw new WPSException("Error executing method: " + e, e);
        }
    }
View Full Code Here

            typeBuilder
                    .setDefaultGeometry(sourceFeatureType.getGeometryDescriptor().getLocalName());
            return typeBuilder.buildFeatureType();
        } catch (Exception e) {
            LOGGER.warning("Error creating type: " + e);
            throw new WPSException("Error creating type: " + e, e);
        }
    }
View Full Code Here

            }
            return SimpleFeatureBuilder.build(targetFeatureType, attributes, feature
                    .getIdentifier().getID());
        } catch (Exception e) {
            LOGGER.warning("Error creating feature: " + e);
            throw new WPSException("Error creating feature: " + e, e);
        }
    }
View Full Code Here

            CoordinateReferenceSystem epsg4326;
            try {
                epsg4326 = CRS.decode("EPSG:4326");
            } catch (Exception e) {
                throw new WPSException("Unknown CRS code: EPSG:4326", e);
            }
            MathTransform crsTransform = CRS.findMathTransform(crs, epsg4326);

            FeatureCollection results = FeatureCollections.newCollection();
            FeatureType targetFeatureType = createTargetFeatureType(featureCollection.getSchema());
            Unit fromUnit = SI.METER;
            Unit toUnit = Unit.valueOf("mi");
            UnitConverter unitConvert = fromUnit.getConverterTo(toUnit);
            Feature nearestFeature = null;
            double nearestDistance = 9e9;
            double nearestBearing = 0;
            Iterator featureIterator = null;
            try {
                featureIterator = featureCollection.iterator();
                while (featureIterator.hasNext()) {
                    SimpleFeature f = (SimpleFeature) featureIterator.next();
                    if (f.getDefaultGeometryProperty().getValue() == null)
                        continue;
                    DistanceOp op = new DistanceOp(point, (Geometry) f.getDefaultGeometryProperty()
                            .getValue());
                    Coordinate[] co = op.closestPoints();
                    double[] co0 = new double[] { co[0].x, co[0].y, };
                    double[] co1 = new double[] { co[1].x, co[1].y, };
                    double[] geo0 = new double[2];
                    double[] geo1 = new double[2];
                    crsTransform.transform(co0, 0, geo0, 0, 1);
                    crsTransform.transform(co1, 0, geo1, 0, 1);

                    // get distance
                    Measure m = DefaultGeographicCRS.WGS84.distance(geo0, geo1);
                    if (m.doubleValue() > nearestDistance)
                        continue;
                    nearestFeature = f;
                    nearestDistance = m.doubleValue();
                    nearestBearing = calcBearing(co);
                }
            } finally {
                if (featureIterator != null)
                    featureCollection.close(featureIterator);
            }
            if (nearestFeature != null) {
                nearestDistance = unitConvert.convert(nearestDistance);
                results.add(createTargetFeature(nearestFeature,
                        (SimpleFeatureType) targetFeatureType, nearestDistance, nearestBearing));
            }
            return results;
        } catch (WPSException e) {
            throw e;
        } catch (Throwable e) {
            LOGGER.warning("Error executing method: " + e);
            throw new WPSException("Error executing method: " + e, e);
        }
    }
View Full Code Here

            typeBuilder
                    .setDefaultGeometry(sourceFeatureType.getGeometryDescriptor().getLocalName());
            return typeBuilder.buildFeatureType();
        } catch (Exception e) {
            LOGGER.warning("Error creating type: " + e);
            throw new WPSException("Error creating type: " + e, e);
        }
    }
View Full Code Here

            }
            return SimpleFeatureBuilder.build(targetFeatureType, attributes, feature
                    .getIdentifier().getID());
        } catch (Exception e) {
            LOGGER.warning("Error creating feature: " + e);
            throw new WPSException("Error creating feature: " + e, e);
        }
    }
View Full Code Here

            @DescribeParameter(name = "feature collection", description = "Feature collection") SimpleFeatureCollection features,
            @DescribeParameter(name = "width of the buffer", description = "The width of the buffer") Double distance,
            @DescribeParameter(name = "name of the layer attribute containing the width of the buffer", description = "Name of the layer attribute") String attribute) {

        if (distance == null && (attribute == null || attribute == "")) {
            throw new WPSException("Buffer distance was not specified");
        }

        if(attribute != null && !"".equals(attribute)) {
            if(features.getSchema().getDescriptor(attribute) == null) {
                boolean found = false;
                // case insensitive search
                for (AttributeDescriptor ad : features.getSchema().getAttributeDescriptors()) {
                    if(ad.getLocalName().equals(attribute)) {
                        attribute = ad.getLocalName();
                        found = true;
                        break;
                    }
                }
                if(!found) {
                    throw new WPSException("Attribute not found among the source collection ones: " + attribute);
                }
            }
        } else {
            attribute = null;
        }
View Full Code Here

TOP

Related Classes of org.geoserver.wps.WPSException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.