public URLBuilder(AVList parameters)
            {
                this.layerNames      = parameters.getStringValue(AVKey.LAYER_NAMES);
                this.styleNames      = parameters.getStringValue(AVKey.STYLE_NAMES);
                this.imageFormat     = parameters.getStringValue(AVKey.IMAGE_FORMAT);
                this.backgroundColor = parameters.getStringValue(AVKey.WMS_BACKGROUND_COLOR);
                String version = parameters.getStringValue(AVKey.WMS_VERSION);

                String coordSystemKey;
                String defaultCS;

                if (version == null || WWUtil.compareVersion(version, "1.3.0") >= 0)
                {
                    this.wmsVersion = MAX_VERSION;
                    coordSystemKey  = "&crs=";
                    defaultCS       = "CRS:84"; // would like to do EPSG:4326 but that's incompatible with our old WMS server, see WWJ-474
                }
                else
                {
                    this.wmsVersion = version;
                    coordSystemKey  = "&srs=";
                    defaultCS       = "EPSG:4326";
                }

                String coordinateSystem = parameters.getStringValue(AVKey.COORDINATE_SYSTEM);

                this.crs = coordSystemKey + (coordinateSystem != null ? coordinateSystem : defaultCS);
            }
Beispiel #2
0
            protected URLBuilder(String version, AVList parameters)
            {
                Double d = (Double)parameters.getValue(AVKey.MISSING_DATA_SIGNAL);

                this.layerNames  = parameters.getStringValue(AVKey.LAYER_NAMES);
                this.styleNames  = parameters.getStringValue(AVKey.STYLE_NAMES);
                this.imageFormat = parameters.getStringValue(AVKey.IMAGE_FORMAT);

                String coordSystemKey;
                String defaultCS;

                if (version == null || WWUtil.compareVersion(version, "1.3.0") >= 0) // version 1.3.0 or greater
                {
                    this.wmsVersion = MAX_VERSION;
                    coordSystemKey  = "&crs=";
                    defaultCS       = "CRS:84"; // would like to do EPSG:4326 but that's incompatible with our old WMS server, see WWJ-474
                }
                else
                {
                    this.wmsVersion = version;
                    coordSystemKey  = "&srs=";
                    defaultCS       = "EPSG:4326";
                }

                String coordinateSystem = parameters.getStringValue(AVKey.COORDINATE_SYSTEM);

                this.crs = coordSystemKey + (coordinateSystem != null ? coordinateSystem : defaultCS);
            }
            public URL getURL(Tile tile, String altImageFormat)
            {
                StringBuilder sb;

                if (this.URLTemplate == null)
                {
                    sb = new StringBuilder(WWXML.fixGetMapString(tile.getLevel().getService()));

                    if (!sb.ToString().ToLower().Contains("service=wms"))
                    {
                        sb.Append("service=WMS");
                    }
                    sb.Append("&request=GetMap");
                    sb.Append("&version=").Append(this.wmsVersion);
                    sb.Append(this.crs);
                    sb.Append("&layers=").Append(this.layerNames);
                    sb.Append("&styles=").Append(this.styleNames != null ? this.styleNames : "");
                    sb.Append("&transparent=TRUE");
                    if (this.backgroundColor != null)
                    {
                        sb.Append("&bgcolor=").Append(this.backgroundColor);
                    }

                    this.URLTemplate = sb.ToString();
                }
                else
                {
                    sb = new StringBuilder(this.URLTemplate);
                }

                String format = (altImageFormat != null) ? altImageFormat : this.imageFormat;

                if (null != format)
                {
                    sb.Append("&format=").Append(format);
                }

                sb.Append("&width=").Append(tile.getWidth());
                sb.Append("&height=").Append(tile.getHeight());

                Sector s = tile.getSector();

                sb.Append("&bbox=");
                // The order of the coordinate specification matters, and it changed with WMS 1.3.0.
                if (WWUtil.compareVersion(this.wmsVersion, "1.1.1") <= 0 || this.crs.Contains("CRS:84"))
                {
                    // 1.1.1 and earlier and CRS:84 use lon/lat order
                    sb.Append(s.getMinLongitude().getDegrees());
                    sb.Append(",");
                    sb.Append(s.getMinLatitude().getDegrees());
                    sb.Append(",");
                    sb.Append(s.getMaxLongitude().getDegrees());
                    sb.Append(",");
                    sb.Append(s.getMaxLatitude().getDegrees());
                }
                else
                {
                    // 1.3.0 uses lat/lon ordering
                    sb.Append(s.getMinLatitude().getDegrees());
                    sb.Append(",");
                    sb.Append(s.getMinLongitude().getDegrees());
                    sb.Append(",");
                    sb.Append(s.getMaxLatitude().getDegrees());
                    sb.Append(",");
                    sb.Append(s.getMaxLongitude().getDegrees());
                }

                return(new URL(sb.ToString().Replace(" ", "%20")));
            }