@Test public void testHandleAction3067to4326() throws Exception { Map<String, String> params = new HashMap<>(); params.put(PARAM_LON, "327578.7810839222"); params.put(PARAM_LAT, "6822546.781459001"); params.put(PARAM_SRS, "EPSG:3067"); params.put(handler.TARGET_SRS, "EPSG:4326"); handler.handleAction(createActionParams(params)); assertEquals(PARAM_LAT, 61.4980214, getResponseJSON().getDouble(PARAM_LAT), 0.00001); assertEquals(PARAM_LON, 23.7603118, getResponseJSON().getDouble(PARAM_LON), 0.00001); }
@Override public void handleAction(final ActionParameters params) throws ActionException { final Point point = new Point(params.getRequiredParamDouble(PARAM_LON), params.getRequiredParamDouble(PARAM_LAT)); final String srs = params.getRequiredParam(PARAM_SRS); final String target = params.getRequiredParam(TARGET_SRS); LOG.debug("Params - lon", point.getLon(), "lat", point.getLat(), "in", srs); try { PointTransformer transformer = getTransformer(); Point value = srs.equals(target) ? point : transformer.reproject(point, srs, target); LOG.debug("Reprojected - lon", value.getLon(), "lat", value.getLat(), "in", target); JSONObject response = new JSONObject(); JSONHelper.putValue(response, PARAM_LON, value.getLon()); JSONHelper.putValue(response, PARAM_LAT, value.getLat()); JSONHelper.putValue(response, PARAM_SRS, target); ResponseHelper.writeResponse(params, response); } catch (RuntimeException ex) { throw new ActionParamsException(ex.getMessage()); } }
CoordinatesHandler extends ActionHandler { @Override public void handleAction(final ActionParameters params) throws ActionException { final Point point = new Point(params.getRequiredParamDouble(PARAM_LON), params.getRequiredParamDouble(PARAM_LAT)); final String srs = params.getRequiredParam(PARAM_SRS); final String target = params.getRequiredParam(TARGET_SRS); LOG.debug("Params - lon", point.getLon(), "lat", point.getLat(), "in", srs); try { PointTransformer transformer = getTransformer(); Point value = srs.equals(target) ? point : transformer.reproject(point, srs, target); LOG.debug("Reprojected - lon", value.getLon(), "lat", value.getLat(), "in", target); JSONObject response = new JSONObject(); JSONHelper.putValue(response, PARAM_LON, value.getLon()); JSONHelper.putValue(response, PARAM_LAT, value.getLat()); JSONHelper.putValue(response, PARAM_SRS, target); ResponseHelper.writeResponse(params, response); } catch (RuntimeException ex) { throw new ActionParamsException(ex.getMessage()); } } }
CoordinatesHandler extends ActionHandler { @Override public void handleAction(final ActionParameters params) throws ActionException { final Point point = new Point(params.getRequiredParamDouble(PARAM_LON), params.getRequiredParamDouble(PARAM_LAT)); final String srs = params.getRequiredParam(PARAM_SRS); final String target = params.getRequiredParam(TARGET_SRS); LOG.debug("Params - lon", point.getLon(), "lat", point.getLat(), "in", srs); try { PointTransformer transformer = getTransformer(); Point value = srs.equals(target) ? point : transformer.reproject(point, srs, target); LOG.debug("Reprojected - lon", value.getLon(), "lat", value.getLat(), "in", target); JSONObject response = new JSONObject(); JSONHelper.putValue(response, PARAM_LON, value.getLon()); JSONHelper.putValue(response, PARAM_LAT, value.getLat()); JSONHelper.putValue(response, PARAM_SRS, target); ResponseHelper.writeResponse(params, response); } catch (RuntimeException ex) { throw new ActionParamsException(ex.getMessage()); } }  }
CoordinatesHandler extends ActionHandler { @Override public void handleAction(final ActionParameters params) throws ActionException { final Point point = new Point(params.getRequiredParamDouble(PARAM_LON), params.getRequiredParamDouble(PARAM_LAT)); final String srs = params.getRequiredParam(PARAM_SRS); final String target = params.getRequiredParam(TARGET_SRS); LOG.debug("Params - lon", point.getLon(), "lat", point.getLat(), "in", srs); try { PointTransformer transformer = getTransformer(); Point value = srs.equals(target) ? point : transformer.reproject(point, srs, target); LOG.debug("Reprojected - lon", value.getLon(), "lat", value.getLat(), "in", target); JSONObject response = new JSONObject(); JSONHelper.putValue(response, PARAM_LON, value.getLon()); JSONHelper.putValue(response, PARAM_LAT, value.getLat()); JSONHelper.putValue(response, PARAM_SRS, target); ResponseHelper.writeResponse(params, response); } catch (RuntimeException ex) { throw new ActionParamsException(ex.getMessage()); } }  @Override void init(); @Override void handleAction(final ActionParameters params); }
CoordinatesHandler extends ActionHandler { @Override public void handleAction(final ActionParameters params) throws ActionException { final Point point = new Point(params.getRequiredParamDouble(PARAM_LON), params.getRequiredParamDouble(PARAM_LAT)); final String srs = params.getRequiredParam(PARAM_SRS); final String target = params.getRequiredParam(TARGET_SRS); LOG.debug("Params - lon", point.getLon(), "lat", point.getLat(), "in", srs); try { PointTransformer transformer = getTransformer(); Point value = srs.equals(target) ? point : transformer.reproject(point, srs, target); LOG.debug("Reprojected - lon", value.getLon(), "lat", value.getLat(), "in", target); JSONObject response = new JSONObject(); JSONHelper.putValue(response, PARAM_LON, value.getLon()); JSONHelper.putValue(response, PARAM_LAT, value.getLat()); JSONHelper.putValue(response, PARAM_SRS, target); ResponseHelper.writeResponse(params, response); } catch (RuntimeException ex) { throw new ActionParamsException(ex.getMessage()); } }  @Override void init(); @Override void handleAction(final ActionParameters params);  }