@Test public void testMakeWmsGetLayerRequestDpiMapServerSet() throws Exception { WmsLayerParam wmsLayerParams = new WmsLayerParam(); wmsLayerParams.layers = new String[]{"layer1", "layer2", "layer3", "layer4", "layer5"}; wmsLayerParams.imageFormat = "image/png"; wmsLayerParams.version = "1.1.1"; wmsLayerParams.serverType = ServerType.MAPSERVER; wmsLayerParams.customParams = new PJsonObject(new JSONObject("{\"map_resolution\":254}"), "customParams"); URI commonURI = new URI("http: Dimension imageSize = new Dimension(200, 300); ReferencedEnvelope env = new ReferencedEnvelope(0, 10, 40, 50, CRS.decode("EPSG:4326")); final URI wmsURI = WmsUtilities.makeWmsGetLayerRequest( wmsLayerParams, commonURI, imageSize, 300.0, 0.0, env); final Multimap<String, String> finalParams = URIUtils.getParameters(wmsURI); assertFalse(finalParams.containsKey("MAP_RESOLUTION")); final String mapResolution = finalParams.get("map_resolution").iterator().next(); assertEquals("254", mapResolution); }
public static URI makeWmsGetLayerRequest( final WmsLayerParam wmsLayerParam, final URI commonURI, final Dimension imageSize, final double dpi, final double angle, final ReferencedEnvelope bounds) throws FactoryException, URISyntaxException, IOException { if (commonURI == null || commonURI.getAuthority() == null) { throw new RuntimeException("Invalid WMS URI: " + commonURI); } String[] authority = commonURI.getAuthority().split(":"); URL url; if (authority.length == 2) { url = new URL( commonURI.getScheme(), authority[0], Integer.parseInt(authority[1]), commonURI.getPath() ); } else { url = new URL( commonURI.getScheme(), authority[0], commonURI.getPath() ); } final GetMapRequest getMapRequest = WmsVersion.lookup(wmsLayerParam.version). getGetMapRequest(url); getMapRequest.setBBox(bounds); getMapRequest.setDimensions(imageSize.width, imageSize.height); getMapRequest.setFormat(wmsLayerParam.imageFormat); getMapRequest.setSRS(CRS.lookupIdentifier(bounds.getCoordinateReferenceSystem(), false)); for (int i = wmsLayerParam.layers.length - 1; i > -1; i--) { String layer = wmsLayerParam.layers[i]; String style = ""; if (wmsLayerParam.styles != null) { style = wmsLayerParam.styles[i]; } getMapRequest.addLayer(layer, style); } final URI getMapUri = getMapRequest.getFinalURL().toURI(); Multimap<String, String> extraParams = HashMultimap.create(); if (commonURI.getQuery() != null) { for (NameValuePair pair: URLEncodedUtils.parse(commonURI, Charset.forName("UTF-8"))) { extraParams.put(pair.getName(), pair.getValue()); } } extraParams.putAll(wmsLayerParam.getMergeableParams()); extraParams.putAll(wmsLayerParam.getCustomParams()); if (wmsLayerParam.serverType != null) { addDpiParam(extraParams, (int) Math.round(dpi), wmsLayerParam.serverType); if (wmsLayerParam.useNativeAngle && angle != 0.0) { addAngleParam(extraParams, angle, wmsLayerParam.serverType); } } return URIUtils.addParams(getMapUri, extraParams, Collections.emptySet()); }
WmsUtilities { public static URI makeWmsGetLayerRequest( final WmsLayerParam wmsLayerParam, final URI commonURI, final Dimension imageSize, final double dpi, final double angle, final ReferencedEnvelope bounds) throws FactoryException, URISyntaxException, IOException { if (commonURI == null || commonURI.getAuthority() == null) { throw new RuntimeException("Invalid WMS URI: " + commonURI); } String[] authority = commonURI.getAuthority().split(":"); URL url; if (authority.length == 2) { url = new URL( commonURI.getScheme(), authority[0], Integer.parseInt(authority[1]), commonURI.getPath() ); } else { url = new URL( commonURI.getScheme(), authority[0], commonURI.getPath() ); } final GetMapRequest getMapRequest = WmsVersion.lookup(wmsLayerParam.version). getGetMapRequest(url); getMapRequest.setBBox(bounds); getMapRequest.setDimensions(imageSize.width, imageSize.height); getMapRequest.setFormat(wmsLayerParam.imageFormat); getMapRequest.setSRS(CRS.lookupIdentifier(bounds.getCoordinateReferenceSystem(), false)); for (int i = wmsLayerParam.layers.length - 1; i > -1; i--) { String layer = wmsLayerParam.layers[i]; String style = ""; if (wmsLayerParam.styles != null) { style = wmsLayerParam.styles[i]; } getMapRequest.addLayer(layer, style); } final URI getMapUri = getMapRequest.getFinalURL().toURI(); Multimap<String, String> extraParams = HashMultimap.create(); if (commonURI.getQuery() != null) { for (NameValuePair pair: URLEncodedUtils.parse(commonURI, Charset.forName("UTF-8"))) { extraParams.put(pair.getName(), pair.getValue()); } } extraParams.putAll(wmsLayerParam.getMergeableParams()); extraParams.putAll(wmsLayerParam.getCustomParams()); if (wmsLayerParam.serverType != null) { addDpiParam(extraParams, (int) Math.round(dpi), wmsLayerParam.serverType); if (wmsLayerParam.useNativeAngle && angle != 0.0) { addAngleParam(extraParams, angle, wmsLayerParam.serverType); } } return URIUtils.addParams(getMapUri, extraParams, Collections.emptySet()); } }
WmsUtilities { public static URI makeWmsGetLayerRequest( final WmsLayerParam wmsLayerParam, final URI commonURI, final Dimension imageSize, final double dpi, final double angle, final ReferencedEnvelope bounds) throws FactoryException, URISyntaxException, IOException { if (commonURI == null || commonURI.getAuthority() == null) { throw new RuntimeException("Invalid WMS URI: " + commonURI); } String[] authority = commonURI.getAuthority().split(":"); URL url; if (authority.length == 2) { url = new URL( commonURI.getScheme(), authority[0], Integer.parseInt(authority[1]), commonURI.getPath() ); } else { url = new URL( commonURI.getScheme(), authority[0], commonURI.getPath() ); } final GetMapRequest getMapRequest = WmsVersion.lookup(wmsLayerParam.version). getGetMapRequest(url); getMapRequest.setBBox(bounds); getMapRequest.setDimensions(imageSize.width, imageSize.height); getMapRequest.setFormat(wmsLayerParam.imageFormat); getMapRequest.setSRS(CRS.lookupIdentifier(bounds.getCoordinateReferenceSystem(), false)); for (int i = wmsLayerParam.layers.length - 1; i > -1; i--) { String layer = wmsLayerParam.layers[i]; String style = ""; if (wmsLayerParam.styles != null) { style = wmsLayerParam.styles[i]; } getMapRequest.addLayer(layer, style); } final URI getMapUri = getMapRequest.getFinalURL().toURI(); Multimap<String, String> extraParams = HashMultimap.create(); if (commonURI.getQuery() != null) { for (NameValuePair pair: URLEncodedUtils.parse(commonURI, Charset.forName("UTF-8"))) { extraParams.put(pair.getName(), pair.getValue()); } } extraParams.putAll(wmsLayerParam.getMergeableParams()); extraParams.putAll(wmsLayerParam.getCustomParams()); if (wmsLayerParam.serverType != null) { addDpiParam(extraParams, (int) Math.round(dpi), wmsLayerParam.serverType); if (wmsLayerParam.useNativeAngle && angle != 0.0) { addAngleParam(extraParams, angle, wmsLayerParam.serverType); } } return URIUtils.addParams(getMapUri, extraParams, Collections.emptySet()); } private  WmsUtilities(); }
WmsUtilities { public static URI makeWmsGetLayerRequest( final WmsLayerParam wmsLayerParam, final URI commonURI, final Dimension imageSize, final double dpi, final double angle, final ReferencedEnvelope bounds) throws FactoryException, URISyntaxException, IOException { if (commonURI == null || commonURI.getAuthority() == null) { throw new RuntimeException("Invalid WMS URI: " + commonURI); } String[] authority = commonURI.getAuthority().split(":"); URL url; if (authority.length == 2) { url = new URL( commonURI.getScheme(), authority[0], Integer.parseInt(authority[1]), commonURI.getPath() ); } else { url = new URL( commonURI.getScheme(), authority[0], commonURI.getPath() ); } final GetMapRequest getMapRequest = WmsVersion.lookup(wmsLayerParam.version). getGetMapRequest(url); getMapRequest.setBBox(bounds); getMapRequest.setDimensions(imageSize.width, imageSize.height); getMapRequest.setFormat(wmsLayerParam.imageFormat); getMapRequest.setSRS(CRS.lookupIdentifier(bounds.getCoordinateReferenceSystem(), false)); for (int i = wmsLayerParam.layers.length - 1; i > -1; i--) { String layer = wmsLayerParam.layers[i]; String style = ""; if (wmsLayerParam.styles != null) { style = wmsLayerParam.styles[i]; } getMapRequest.addLayer(layer, style); } final URI getMapUri = getMapRequest.getFinalURL().toURI(); Multimap<String, String> extraParams = HashMultimap.create(); if (commonURI.getQuery() != null) { for (NameValuePair pair: URLEncodedUtils.parse(commonURI, Charset.forName("UTF-8"))) { extraParams.put(pair.getName(), pair.getValue()); } } extraParams.putAll(wmsLayerParam.getMergeableParams()); extraParams.putAll(wmsLayerParam.getCustomParams()); if (wmsLayerParam.serverType != null) { addDpiParam(extraParams, (int) Math.round(dpi), wmsLayerParam.serverType); if (wmsLayerParam.useNativeAngle && angle != 0.0) { addAngleParam(extraParams, angle, wmsLayerParam.serverType); } } return URIUtils.addParams(getMapUri, extraParams, Collections.emptySet()); } private  WmsUtilities(); static URI makeWmsGetLayerRequest(
            final WmsLayerParam wmsLayerParam,
            final URI commonURI,
            final Dimension imageSize,
            final double dpi,
            final double angle,
            final ReferencedEnvelope bounds); static ClientHttpRequest createWmsRequest(
            final MfClientHttpRequestFactory httpRequestFactory, final URI uri,
            final HttpMethod method); }
WmsUtilities { public static URI makeWmsGetLayerRequest( final WmsLayerParam wmsLayerParam, final URI commonURI, final Dimension imageSize, final double dpi, final double angle, final ReferencedEnvelope bounds) throws FactoryException, URISyntaxException, IOException { if (commonURI == null || commonURI.getAuthority() == null) { throw new RuntimeException("Invalid WMS URI: " + commonURI); } String[] authority = commonURI.getAuthority().split(":"); URL url; if (authority.length == 2) { url = new URL( commonURI.getScheme(), authority[0], Integer.parseInt(authority[1]), commonURI.getPath() ); } else { url = new URL( commonURI.getScheme(), authority[0], commonURI.getPath() ); } final GetMapRequest getMapRequest = WmsVersion.lookup(wmsLayerParam.version). getGetMapRequest(url); getMapRequest.setBBox(bounds); getMapRequest.setDimensions(imageSize.width, imageSize.height); getMapRequest.setFormat(wmsLayerParam.imageFormat); getMapRequest.setSRS(CRS.lookupIdentifier(bounds.getCoordinateReferenceSystem(), false)); for (int i = wmsLayerParam.layers.length - 1; i > -1; i--) { String layer = wmsLayerParam.layers[i]; String style = ""; if (wmsLayerParam.styles != null) { style = wmsLayerParam.styles[i]; } getMapRequest.addLayer(layer, style); } final URI getMapUri = getMapRequest.getFinalURL().toURI(); Multimap<String, String> extraParams = HashMultimap.create(); if (commonURI.getQuery() != null) { for (NameValuePair pair: URLEncodedUtils.parse(commonURI, Charset.forName("UTF-8"))) { extraParams.put(pair.getName(), pair.getValue()); } } extraParams.putAll(wmsLayerParam.getMergeableParams()); extraParams.putAll(wmsLayerParam.getCustomParams()); if (wmsLayerParam.serverType != null) { addDpiParam(extraParams, (int) Math.round(dpi), wmsLayerParam.serverType); if (wmsLayerParam.useNativeAngle && angle != 0.0) { addAngleParam(extraParams, angle, wmsLayerParam.serverType); } } return URIUtils.addParams(getMapUri, extraParams, Collections.emptySet()); } private  WmsUtilities(); static URI makeWmsGetLayerRequest(
            final WmsLayerParam wmsLayerParam,
            final URI commonURI,
            final Dimension imageSize,
            final double dpi,
            final double angle,
            final ReferencedEnvelope bounds); static ClientHttpRequest createWmsRequest(
            final MfClientHttpRequestFactory httpRequestFactory, final URI uri,
            final HttpMethod method);  }