Example usage for org.springframework.web.bind ServletRequestUtils getRequiredDoubleParameter

List of usage examples for org.springframework.web.bind ServletRequestUtils getRequiredDoubleParameter

Introduction

In this page you can find the example usage for org.springframework.web.bind ServletRequestUtils getRequiredDoubleParameter.

Prototype

public static double getRequiredDoubleParameter(ServletRequest request, String name)
        throws ServletRequestBindingException 

Source Link

Document

Get a double parameter, throwing an exception if it isn't found or isn't a number.

Usage

From source file:com.hmsinc.epicenter.webapp.map.StyleParameters.java

/**
 * @param request//from w ww. j  ava  2 s.  com
 * @param params
 * @param dto
 * @param user
 */
StyleParameters(HttpServletRequest request, AnalysisParameters params, final AnalysisParametersDTO queryParams,
        EpiCenterUser user) throws ServletRequestBindingException {

    this.parameters = params;

    // Workaround for http://jira.codehaus.org/browse/GEOS-1872
    try {
        this.algorithmName = codec.decode(queryParams.getAlgorithmName());
    } catch (DecoderException e) {
        throw new ServletRequestBindingException(e.getMessage());
    }

    this.algorithmProperties = queryParams.getAlgorithmProperties();

    this.parameters.setSecondaryFilter(
            SpatialSecurity.isGlobalAdministrator(user) ? null : user.getVisibleRegion().getGeometry());

    // If we're analyzing by facility, we need to strip out AGGREGATE_ONLY regions
    if (AnalysisLocation.FACILITY.equals(params.getLocation())) {
        for (Organization org : user.getOrganizations()) {
            for (AuthorizedRegion ar : org.getAuthorizedRegions()) {
                if (Visibility.AGGREGATE_ONLY.equals(SpatialSecurity.getVisibility(user, ar.getGeography()))) {
                    this.parameters.setSecondaryFilter(
                            this.parameters.getSecondaryFilter().difference(ar.getGeography().getGeometry()));
                }
            }
        }
    }
    double minLng = ServletRequestUtils.getRequiredDoubleParameter(request, "min_lng");
    double minLat = ServletRequestUtils.getRequiredDoubleParameter(request, "min_lat");
    double maxLng = ServletRequestUtils.getRequiredDoubleParameter(request, "max_lng");
    double maxLat = ServletRequestUtils.getRequiredDoubleParameter(request, "max_lat");

    this.geographyClass = GeographyType
            .valueOf(ServletRequestUtils.getRequiredStringParameter(request, "feature").toUpperCase())
            .getGeoClass();

    this.parameters.setFilter(new Envelope(minLng, maxLng, minLat, maxLat));

    this.labelFeatures = ServletRequestUtils.getBooleanParameter(request, "labelFeatures", false);
}