Hello,
Following the Implementing a WPS Process manual, I’ve created a custom process that implements GeoServerProcess to call my own geocoding stuff.
After reading Accepting or returning raw data of the same manual, my goal was to have, at least, the possibility to choose the output type as json or xml in a dropdown (something like attachment expected.png) of WPS request builder (or REST call), but what I have is as attachment unexpected.png.
Is it possible to achieve what I want?
Here’s my code:
GeocoderCodLogr.java
@DescribeProcess(title = "geocoderCodLogr", description = "Geocoder em cima do Eixo de Logradouros, por código")
public class GeocoderCodLogr implements GeoServerProcess {
@DescribeResult(name = "result", description = "Ponto como String", meta = { "mimeType=application/json,text/xml",
"chosenMimeType=outputMimeType" })
public RawData execute(@DescribeParameter(name = "código", description = "Código do logradouro") String codigo,
@DescribeParameter(name = "número", description = "Número predial") Integer numero,
@DescribeParameter(name = "outputMimeType", min = 0) final String outputMimeType) {
String url = "jdbc:postgresql://lpostdes:5432/gispmpa?user=gispmpa";
Connection conn = null;
try {
conn = DriverManager.getConnection(url);
PreparedStatement stmt = conn.prepareStatement("select st_astext(geocode_codlogr(?, ?))");
stmt.setInt(1, numero);
stmt.setString(2, codigo);
ResultSet rs = stmt.executeQuery();
String ponto = null;
while (rs.next()) {
ponto = rs.getString(1);
}
return new StringRawData(ponto, outputMimeType);
} catch (Exception e) {
// TODO Auto-generated catch block
return new StringRawData(e.getMessage(), outputMimeType);
}
}
}
PS: I’ve ommited some connection string info.
Thanks in advance
–
Atenciosamente,
César Augusto R. Ribeiro