@Override public void setValue( double lowerX, double lowerY, double upperX, double upperY, String crsName ) { setValue( new double[] { lowerX, lowerY }, new double[] { upperX, upperY }, crsName ); }
private static void exportLiteralOutput( XMLStreamWriter writer, LiteralOutputImpl output ) throws XMLStreamException { // "wps:LiteralData" element writer.writeStartElement( WPS_NS, "LiteralData" ); // "dataType" attribute (optional) if ( output.getDataType() != null ) { writer.writeAttribute( "dataType", output.getDataType() ); } // "uom" attribute (optional) if ( output.getRequestedUOM() != null ) { writer.writeAttribute( "uom", output.getRequestedUOM() ); } writer.writeCharacters( output.getValue() ); writer.writeEndElement(); }
private static void exportBoundingBoxOutput( XMLStreamWriter writer, BoundingBoxOutputImpl output ) throws XMLStreamException { // "wps:BoundingBoxData" element writer.writeStartElement( WPS_NS, "BoundingBoxData" ); OWSCommonXMLAdapter.exportBoundingBoxType( writer, output.getValue() ); writer.writeEndElement(); }
Collection<? extends ProcessletOutput> requestedOutputs ) { for ( ProcessletOutput processOutput : requestedOutputs ) { idToOutput.put( processOutput.getIdentifier(), processOutput ); LiteralOutputDefinition literalDef = (LiteralOutputDefinition) outputDef; String uom = literalDef.getDefaultUOM() != null ? literalDef.getDefaultUOM().getValue() : null; output = new LiteralOutputImpl( literalDef, uom, false ); } else if ( outputDef instanceof BoundingBoxOutputDefinition ) { output = new BoundingBoxOutputImpl( (BoundingBoxOutputDefinition) outputDef, false ); } else if ( outputDef instanceof ComplexOutputDefinition ) { output = new ComplexOutputImpl( (ComplexOutputDefinition) outputDef, new OutputStream() { @Override public void write( int b )
private void writeGeometry( ComplexOutput gmlOutput, Geometry geometry ) throws ProcessletException { try { SchemaLocationXMLStreamWriter sw = new SchemaLocationXMLStreamWriter( gmlOutput.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( geometry ); } catch ( Exception e ) { throw new ProcessletException( "Error exporting geometry: " + e.getMessage() ); } }
private static void exportXMLOutput( XMLStreamWriter writer, ComplexOutputImpl output ) throws XMLStreamException { // "wps:ComplexData" element writer.writeStartElement( WPS_NS, "ComplexData" ); String mimeType = output.getRequestedMimeType(); if ( mimeType != null ) { writer.writeAttribute( "mimeType", mimeType ); } String schema = output.getRequestedSchema(); if ( schema != null ) { writer.writeAttribute( "schema", schema ); } // NOTE: Providing the encoding attribute doesn't make any sense for inline XML output (always defined by the // surrounding document) XMLStreamReader reader = output.getStreamReader(); // skip start document event // apadberg: the following line was necessary when Axiom 1.2.8 is used, // it is commented out because of revised behavior in Axiom 1.2.9 if ( reader.getEventType() == XMLStreamConstants.START_DOCUMENT ) { reader.next(); } if ( reader.getEventType() == XMLStreamConstants.START_ELEMENT ) { XMLAdapter.writeElement( writer, reader ); } else { LOG.warn( "No element in XMLOutput found, skipping it in response document." ); } writer.writeEndElement(); }
/** * Creates a {@link ProcessletOutput} parameter object for storing a requested process output value. * * @param outputDef * @return object for storing the corresponding process output value */ private ProcessletOutput createOutputParameter( RequestedOutput outputDef ) throws OWSException { ProcessletOutput processOutput = null; ProcessletOutputDefinition outputType = outputDef.getOutputType(); if ( outputType instanceof BoundingBoxOutputDefinition ) { processOutput = new BoundingBoxOutputImpl( (BoundingBoxOutputDefinition) outputType, true ); } else if ( outputType instanceof LiteralOutputDefinition ) { processOutput = new LiteralOutputImpl( (LiteralOutputDefinition) outputType, outputDef.getUom(), true ); } else if ( outputType instanceof ComplexOutputDefinition ) { try { String requestedMimeType = outputDef.getMimeType(); String requestedEncoding = outputDef.getEncoding(); String requestedSchema = outputDef.getSchemaURL(); processOutput = new ComplexOutputImpl( (ComplexOutputDefinition) outputType, storageManager.newOutputStorage( requestedMimeType ), true, requestedMimeType, requestedSchema, requestedEncoding ); } catch ( Exception e ) { String msg = "Unable to create sink for complex output parameter: " + e.getMessage(); LOG.error( msg, e ); throw new OWSException( msg, NO_APPLICABLE_CODE ); } } return processOutput; }
String mimeType = output.getRequestedMimeType(); if ( mimeType != null ) { writer.writeAttribute( "mimeType", mimeType ); InputStream is = output.getInputStream(); byte[] buffer = new byte[1024]; int bytesRead = 0;
@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 String toString() { return "Output parameter, identifier='" + getIdentifier() + "', title='" + definition.getTitle() + "', abstract='" + definition.getAbstract() + "'"; } }
private static void exportComplexOutput( XMLStreamWriter writer, ComplexOutputImpl output ) throws XMLStreamException { if ( output.getStreamReader() != null ) { exportXMLOutput( writer, output ); } else { exportBinaryOutput( writer, output ); } }
private void writeGeometry( ComplexOutput gmlOutput, Geometry geometry ) throws ProcessletException { try { SchemaLocationXMLStreamWriter sw = new SchemaLocationXMLStreamWriter( gmlOutput.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( geometry ); } catch ( Exception e ) { throw new ProcessletException( "Error exporting geometry: " + e.getMessage() ); } }
@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 setValue( double[] lower, double[] upper, String crsName ) { setValue( geomFac.createEnvelope( lower, upper, CRSManager.getCRSRef( crsName ) ) ); }
private void writeGeometry( ComplexOutput gmlOutput, Geometry geometry ) throws ProcessletException { try { SchemaLocationXMLStreamWriter sw = new SchemaLocationXMLStreamWriter( gmlOutput.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( geometry ); } catch ( Exception e ) { throw new ProcessletException( "Error exporting geometry: " + e.getMessage() ); } }
@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 ) ); }
private void writeGeometry( ComplexOutput gmlOutput, Geometry geometry ) throws ProcessletException { try { SchemaLocationXMLStreamWriter sw = new SchemaLocationXMLStreamWriter( gmlOutput.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( geometry ); } catch ( Exception e ) { throw new ProcessletException( "Error exporting geometry: " + e.getMessage() ); } }
@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 ) ); }
private void writeGeometry( ComplexOutput gmlOutput, Geometry geometry ) throws ProcessletException { try { SchemaLocationXMLStreamWriter sw = new SchemaLocationXMLStreamWriter( gmlOutput.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( geometry ); } catch ( Exception e ) { throw new ProcessletException( "Error exporting geometry: " + e.getMessage() ); } }
@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() ) ); }