[Geoserver-devel] [JIRA] (GEOS-7285) Help with call to custom WPS process

César Augusto Ribeiro created an issue

GeoServer / BugGEOS-7285

Help with call to custom WPS process

Issue Type:

BugBug

Affects Versions:

2.7.2

Assignee:

Unassigned

Attachments:

expected.png, unexpected.png

Components:

WPS

Created:

29/Oct/15 12:14 PM

Environment:

Linux

Priority:

LowLow

Reporter:

César Augusto Ribeiro

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.

Add Comment

Add Comment

This message was sent by Atlassian JIRA (v7.0.0-OD-08-002#70107-sha1:3f098e8)

Atlassian logo