private static void exportProcessOutputs( XMLStreamWriter writer, ProcessletOutputs outputs, List<RequestedOutput> requestedOutputs ) throws XMLStreamException { LOG.debug( "Exporting process outputs" ); // "wps:ProcessOutputs" element writer.writeStartElement( WPS_NS, "ProcessOutputs" ); for ( RequestedOutput requestedOutput : requestedOutputs ) { LOG.debug( "- exporting " + requestedOutput.getIdentifier() ); ProcessletOutput output = outputs.getParameter( requestedOutput.getIdentifier() ); exportOutput( writer, (ProcessletOutputImpl) output, requestedOutput ); } writer.writeEndElement(); }
@Override public void process( ProcessletInputs in, ProcessletOutputs out, ProcessletExecutionInfo info ) throws ProcessletException { ComplexInput gmlInput = (ComplexInput) in.getParameter( "GMLInput" ); Geometry geometry = readGeometry( gmlInput ); Point centroid = geometry.getCentroid(); ComplexOutput centroidOutput = (ComplexOutput) out.getParameter( "Centroid" ); writeGeometry( centroidOutput, centroid ); }
@Override public void process( ProcessletInputs in, ProcessletOutputs out, ProcessletExecutionInfo info ) throws ProcessletException { ComplexInput gmlInput = (ComplexInput) in.getParameter( "GMLInput" ); Geometry geometry = readGeometry( gmlInput ); Geometry hulledGeometry = geometry.getConvexHull(); ComplexOutput hullOutput = (ComplexOutput) out.getParameter( "ConvexHull" ); writeGeometry( hullOutput, hulledGeometry ); }
@Override public void process( ProcessletInputs in, ProcessletOutputs out, ProcessletExecutionInfo info ) throws ProcessletException { ComplexInput gmlInput1 = (ComplexInput) in.getParameter( "GMLInput1" ); ComplexInput gmlInput2 = (ComplexInput) in.getParameter( "GMLInput2" ); Geometry geometry1 = readGeometry( gmlInput1 ); Geometry geometry2 = readGeometry( gmlInput2 ); boolean crosses = geometry1.crosses( geometry2 ); LiteralOutput crossesOutput = (LiteralOutput) out.getParameter( "Crosses" ); crossesOutput.setValue( String.valueOf( crosses ) ); }
@Override public void process( ProcessletInputs in, ProcessletOutputs out, ProcessletExecutionInfo info ) throws ProcessletException { ComplexInput gmlInput1 = (ComplexInput) in.getParameter( "GMLInput1" ); ComplexInput gmlInput2 = (ComplexInput) in.getParameter( "GMLInput2" ); Geometry geometry1 = readGeometry( gmlInput1 ); Geometry geometry2 = readGeometry( gmlInput2 ); boolean contains = geometry1.contains( geometry2 ); LiteralOutput containsOutput = (LiteralOutput) out.getParameter( "Contains" ); containsOutput.setValue( String.valueOf( contains ) ); }
@Override public void process( ProcessletInputs in, ProcessletOutputs out, ProcessletExecutionInfo info ) throws ProcessletException { ComplexInput gmlInput1 = (ComplexInput) in.getParameter( "GMLInput1" ); ComplexInput gmlInput2 = (ComplexInput) in.getParameter( "GMLInput2" ); Geometry geometry1 = readGeometry( gmlInput1 ); Geometry geometry2 = readGeometry( gmlInput2 ); boolean touches = geometry1.touches( geometry2 ); LiteralOutput touchesOutput = (LiteralOutput) out.getParameter( "Touches" ); touchesOutput.setValue( String.valueOf( touches ) ); }
@Override public void process( ProcessletInputs in, ProcessletOutputs out, ProcessletExecutionInfo info ) throws ProcessletException { ComplexInput gmlInput1 = (ComplexInput) in.getParameter( "GMLInput1" ); ComplexInput gmlInput2 = (ComplexInput) in.getParameter( "GMLInput2" ); Geometry geometry1 = readGeometry( gmlInput1 ); Geometry geometry2 = readGeometry( gmlInput2 ); boolean equals = geometry1.equals( geometry2 ); LiteralOutput equalsOutput = (LiteralOutput) out.getParameter( "Equals" ); equalsOutput.setValue( String.valueOf( equals ) ); }
@Override public void process( ProcessletInputs in, ProcessletOutputs out, ProcessletExecutionInfo info ) throws ProcessletException { ComplexInput gmlInput1 = (ComplexInput) in.getParameter( "GMLInput1" ); ComplexInput gmlInput2 = (ComplexInput) in.getParameter( "GMLInput2" ); Geometry geometry1 = readGeometry( gmlInput1 ); Geometry geometry2 = readGeometry( gmlInput2 ); Measure distance = geometry1.getDistance( geometry2, null ); LiteralOutput distanceOutput = (LiteralOutput) out.getParameter( "Distance" ); distanceOutput.setValue( String.valueOf( distance.getValueAsDouble() ) ); }
LiteralOutput literalOutput = (LiteralOutput) out.getParameter( "LiteralOutput" ); LOG.debug( "Setting literal output (requested=" + literalOutput.isRequested() + ")" ); BoundingBoxOutput bboxOutput = (BoundingBoxOutput) out.getParameter( "BBOXOutput" ); LOG.debug( "Setting bbox output (requested=" + bboxOutput.isRequested() + ")" ); ComplexOutput xmlOutput = (ComplexOutput) out.getParameter( "XMLOutput" ); LOG.debug( "Setting XML output (requested=" + xmlOutput.isRequested() + ")" ); ComplexOutput binaryOutput = (ComplexOutput) out.getParameter( "BinaryOutput" ); LOG.debug( "Setting binary output (requested=" + binaryOutput.isRequested() + ")" );
g.dispose(); ComplexOutput output = (ComplexOutput) out.getParameter( OUT_PARAM_ID ); OutputStream os = output.getBinaryOutputStream(); PNGEncodeParam encodeParam = PNGEncodeParam.getDefaultEncodeParam( img );
@Override public void process( ProcessletInputs in, ProcessletOutputs out, ProcessletExecutionInfo info ) throws ProcessletException { ComplexInput gmlInput1 = (ComplexInput) in.getParameter( "GMLInput1" ); ComplexInput gmlInput2 = (ComplexInput) in.getParameter( "GMLInput2" ); Geometry geometry1 = readGeometry( gmlInput1 ); Geometry geometry2 = readGeometry( gmlInput2 ); Geometry difference = geometry1.getDifference( geometry2 ); ComplexOutput differenceOutput = (ComplexOutput) out.getParameter( "Difference" ); writeGeometry( differenceOutput, difference ); }
ComplexOutput xmlOutput = (ComplexOutput) out.getParameter( OUT_DATA ); String outMime = xmlOutput.getRequestedMimeType(); if ( outMime != null && !outMime.equals( mime ) ) {
@Override public void process( ProcessletInputs in, ProcessletOutputs out, ProcessletExecutionInfo info ) throws ProcessletException { ComplexInput gmlInput1 = (ComplexInput) in.getParameter( "GMLInput1" ); ComplexInput gmlInput2 = (ComplexInput) in.getParameter( "GMLInput2" ); Geometry geometry1 = readGeometry( gmlInput1 ); Geometry geometry2 = readGeometry( gmlInput2 ); Geometry union = geometry1.getUnion( geometry2 ); ComplexOutput unionOutput = (ComplexOutput) out.getParameter( "Union" ); writeGeometry( unionOutput, union ); }
@Override public void process( ProcessletInputs in, ProcessletOutputs out, ProcessletExecutionInfo info ) throws ProcessletException { ComplexInput gmlInput1 = (ComplexInput) in.getParameter( "GMLInput1" ); ComplexInput gmlInput2 = (ComplexInput) in.getParameter( "GMLInput2" ); Geometry geometry1 = readGeometry( gmlInput1 ); Geometry geometry2 = readGeometry( gmlInput2 ); Geometry intersection = geometry1.getIntersection( geometry2 ); ComplexOutput intersectionOutput = (ComplexOutput) out.getParameter( "Intersection" ); writeGeometry( intersectionOutput, intersection ); }
@Override public void process( ProcessletInputs in, ProcessletOutputs out, ProcessletExecutionInfo info ) throws ProcessletException { double bufferDistance = Double.parseDouble( ( (LiteralInput) in.getParameter( "BufferDistance" ) ).getValue() ); ComplexInput gmlInputGeometry = (ComplexInput) in.getParameter( "GMLInput" ); Geometry geom = null; Geometry bufferedGeom = null; try { XMLStreamReader xmlReader = gmlInputGeometry.getValueAsXMLStream(); GMLStreamReader gmlReader = GMLInputFactory.createGMLStreamReader( GML_31, xmlReader ); geom = gmlReader.readGeometry(); bufferedGeom = geom.getBuffer( new Measure( new BigDecimal( bufferDistance ), "unity" ) ); } catch ( Exception e ) { throw new ProcessletException( "Error parsing parameter " + gmlInputGeometry.getIdentifier() + ": " + e.getMessage() ); } ComplexOutput gmlOutputGeometry = (ComplexOutput) out.getParameter( "BufferedGeometry" ); try { SchemaLocationXMLStreamWriter sw = new SchemaLocationXMLStreamWriter( gmlOutputGeometry.getXMLStreamWriter(), "http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/base/geometryAggregates.xsd" ); sw.setPrefix( "gml", GMLNS ); GMLStreamWriter gmlWriter = GMLOutputFactory.createGMLStreamWriter( GML_31, sw ); gmlWriter.write( bufferedGeom ); } catch ( Exception e ) { throw new ProcessletException( "Error exporting geometry: " + e.getMessage() ); } }