Rusian,
I have an example of WMS here for you. I am not sure if this is exactly
what you are looking for though.
When trying to use the WMSPlugin I was plagued by errors and null
strings. I decided to just forgo that experience and use the plugin as a
fancy data storage class.
The following code will connect and retrieve a Global Mosaic from Nasa's
JPL WMS server. It is not optimized, I leave that up to you ;)
I also have to give credit to one of the previous mailing list users. I
do not recall which user, but some of this code is taken directly from a
previous example on this list.
Good Luck to you!
Chris Franklin
public void buildWMS(){
wmsList.clear();
WMSPlugIn wms = new WMSPlugIn();
wms.setWmsServer("wms.cgi");
wms.setImageFormat("image/jpeg");
wms.setLayers("global_mosaic");
wms.setWmsVersion("1.1.1");
wms.setStyles("visual");
wms.setVendorSpecificNames("EPSG");
wms.setVendorSpecificValues("4326");
wms.setQueryHeader("
http://wms.jpl.nasa.gov/wms.cgi");
Projection p = bean.getProjection();
String bbox = "undefined";
String height = "undefined";
String width = "undefined";
if (p != null) {
bbox = Double.toString(p.getUpperLeft().getLongitude()) + ","
+ Double.toString(p.getLowerRight().getLatitude()) + ","
+ Double.toString(p.getLowerRight().getLongitude())
+ ","
+ Double.toString(p.getUpperLeft().getLatitude());
height = Integer.toString(p.getHeight());
width = Integer.toString(p.getWidth());
}
String queryString = wms.getQueryHeader() + "?"+ "wms_server="+
wms.getServerName() + "&layers=" + wms.getLayers() + "&service=OGC:WMS" +
"&format=image/jpeg" + "&width="+ width +"&height="+
height+"&bbox="+ bbox + "&request=GetMap&srs=EPSG:4326&styles=visual";
System.out.println(wms.createQueryString(bean.getProjection()));
System.out.println(queryString);
java.net.URL url = null;
try {
System.out.println("Inside URL code");
url = new java.net.URL(queryString);
java.net.HttpURLConnection urlc =
(java.net.HttpURLConnection)url.openConnection();
urlc.setRequestProperty("User-Agent", "Mozilla/5.0 (X11; U;
Linux i686; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14");
System.out.println("Using Proxy: " + urlc.usingProxy());
urlc.setDoInput(true);
urlc.setDoOutput(true);
urlc.setRequestMethod("GET");
System.out.println(urlc.getContentType());
// text
if ( urlc.getContentType().startsWith("text")) {
System.out.println("Inside URL code: Text");
java.io.BufferedReader bin = new java.io.BufferedReader(
new java.io.InputStreamReader(urlc.getInputStream())
);
String st;
String message = "";
while ((st=bin.readLine()) != null) {
message += st;
}
// image
} else if ( urlc.getContentType().startsWith("image")) {
System.out.println("Inside URL code: Image");
urlc.disconnect();
ImageIcon ii = new ImageIcon(url);
OMRaster image = new OMRaster(0, 0, ii);
wmsList.add(image);
} // end if image
} catch (java.net.MalformedURLException murle) {
System.out.println("Bad URL!");
} catch (java.io.IOException ioe) {
System.out.println("IO Exception");
}
wmsList.generate(p);
wmsLayer.setList(wmsList);
}
п═я┐я│п╩п╟п╫ п║п╬я─п╬п╨п╦п╫ wrote:
>
> Hello Openmap users and team,
>
> Can somebody give a working example of parameter settings for WMS
> Plugin (Preferably for WMS Global Mosaic, pan sharpened layer
> (http://www.cubewerx.com/demo/cubexplor/))?
> <http://www.cubewerx.com/demo/cubexplor/%29%29?>
> Thanx in advance.
>
> Sincerely,
>
> Ruslan Sorokin
> sorokin_at_oogis.ru <mailto:sorokin_at_oogis.ru>
>
>
>
>
--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Fri Aug 01 2008 - 09:50:59 EDT