@DescribeResult(name = "bounds", description = "Bounding box of input features") public ReferencedEnvelope execute( @DescribeParameter(name = "features", description = "Input feature collection") FeatureCollection features) { return features.getBounds(); } }
private void addResult(Method method, Map<String, Parameter<?>> result, DescribeResult info) { Class resultType = info.type(); if (Object.class.equals(resultType)) { resultType = method.getReturnType(); } // metadata Map<String, Object> metadata = null; if (info != null && info.meta() != null && info.meta().length > 0) { String[] meta = info.meta(); metadata = new HashMap<String, Object>(); fillParameterMetadata(meta, metadata); } int min = info.primary() ? 0 : 1; Parameter resultParam = new Parameter( info.name(), resultType, new SimpleInternationalString(info.name()), new SimpleInternationalString(info.description()), min > 0, min, 1, null, metadata); result.put(resultParam.key, resultParam); }
if (annotation instanceof DescribeResult) { DescribeResult info = (DescribeResult) annotation; Object resultValue = map.get(info.name()); if (resultValue != null) { addResult(result, resultValue, info); DescribeResults info = (DescribeResults) annotation; for (DescribeResult dr : info.value()) { Object resultValue = map.get(dr.name()); if (resultValue != null) { addResult(result, resultValue, dr); DescribeResult dr = method.getAnnotation(DescribeResult.class); if (dr != null) { result.put(dr.name(), value); } else { result.put("result", value);
if (annotation instanceof DescribeResult) { DescribeResult info = (DescribeResult) annotation; Object resultValue = map.get(info.name()); if(resultValue != null) { addResult(result, resultValue, info); DescribeResults info = (DescribeResults) annotation; for (DescribeResult dr : info.value()) { Object resultValue = map.get(dr.name()); if(resultValue != null) { addResult(result, resultValue, dr); DescribeResult dr = method.getAnnotation(DescribeResult.class); if (dr != null) { result.put(dr.name(), value); } else { result.put("result", value);
@DescribeResult(name = "result", description = "Number of features") public Number execute( @DescribeParameter(name = "features", description = "Input feature collection") SimpleFeatureCollection features) throws Exception { return features.size(); } }
private void addResult(Method method, Map<String, Parameter<?>> result, DescribeResult info) { Class resultType = info.type(); if (Object.class.equals(resultType)) { resultType = method.getReturnType(); } int min = info.primary() ? 0 : 1; Parameter resultParam = new Parameter(info.name(), resultType, new SimpleInternationalString(info.name()), new SimpleInternationalString(info.description()), min > 0, min, 1, null, null); result.put(resultParam.key, resultParam); }
@DescribeProcess( title = "Area", description = "Returns the area of a geometry, in the units of the geometry. Assumes a Cartesian plane, so this process is only recommended for non-geographic CRSes." ) @DescribeResult(description = "Area of the input geometry") public static double area( @DescribeParameter(name = "geom", description = "Input geometry") Geometry geom) { return geom.getArea(); }
@DescribeProcess( title = "Centroid", description = "Returns the geometric centroid of a geometry. Output is a single point. The centroid point may be located outside the geometry." ) @DescribeResult(description = "Centroid of the input geometry") public static Geometry centroid( @DescribeParameter(name = "geom", description = "Input geometry") Geometry geom) { return geom.getCentroid(); }
@DescribeProcess( title = "Closed Test", description = "Tests if the initial vertex equals the final vertex in a linear geometry. Points and polygons always return True." ) @DescribeResult(description = "True if the input is closed") public static boolean isClosed( @DescribeParameter(name = "geom", description = "Input geometry") LineString line) { return line.isClosed(); }
@DescribeProcess( title = "End Point", description = "Returns a point geometry equal to the final vertex of a LineString." ) @DescribeResult(description = "Final vertex as point geometry") public static Point endPoint( @DescribeParameter(name = "geom", description = "Input line") LineString line) { return line.getEndPoint(); }
@DescribeProcess( title = "Interior Ring Count", description = "Returns the total number of interior rings in a polygonal geometry. Points and lines return 0." ) @DescribeResult(description = "Total number of interior rings") public static int numInteriorRing( @DescribeParameter(name = "geom", description = "Input geometry") Polygon polygon) { return polygon.getNumInteriorRing(); }
@DescribeProcess( title = "Empty Test", description = "Tests if a geometry contains no vertices." ) @DescribeResult(description = "True if the input is empty") public static boolean isEmpty( @DescribeParameter(name = "geom", description = "Input geometry") Geometry geom) { return geom.isEmpty(); }
@DescribeProcess( title = "Geometry Type", description = "Returns the name of a geometry's type. Values are one of POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION." ) @DescribeResult(description = "The name of the geometry type") public static String geometryType( @DescribeParameter(name = "geom", description = "Input geometry") Geometry geom) { return geom.getGeometryType(); }
@DescribeProcess( title = "Interior Point", description = "Returns a point that lies inside a geometry if possible, or that lies on its boundary." ) @DescribeResult(description = "Interior point") public static Geometry interiorPoint( @DescribeParameter(name = "geom", description = "Input geometry") Geometry geom) { return geom.getInteriorPoint(); }
@DescribeProcess( title = "Dimension", description = "Returns the largest dimension of a geometry or geometry collection: 0 for point, 1 for line, 2 for polygon." ) @DescribeResult(description = "Dimension of the input geometry") public static int dimension( @DescribeParameter(name = "geom", description = "Input geometry") Geometry geom) { return geom.getDimension(); }
@DescribeProcess( title = "Convex Hull", description = "Returns the smallest convex polygon that contains the entire input geometry." ) @DescribeResult(description = "Convex hull of input geometry") public static Geometry convexHull( @DescribeParameter(name = "geom", description = "Input geometry") Geometry geom) { return geom.convexHull(); }
@DescribeProcess( title = "Length", description = "Returns the total length of all line segments in a geometry. Measurement is given in the source units, so geographic coordinates are not recommended." ) @DescribeResult(description = "Total perimeter of the geometry") public static double length( @DescribeParameter(name = "geom", description = "Input geometry") Geometry geom) { return geom.getLength(); }
@DescribeProcess( title = "Simple Test", description = "Tests if a geometry is topologically simple. Points, polygons, closed line strings, and linear rings are always simple. Other geometries are considered simple if no two points are identical." ) @DescribeResult(description = "True if the input is simple") public static boolean isSimple( @DescribeParameter(name = "geom", description = "Input geometry") Geometry geom) { return geom.isSimple(); }