| 227 | | |
| 228 | | |
| 229 | | /** |
| 230 | | * GeoServer fails the entire tile if it crosses the max extents, dateline boundary. |
| 231 | | * |
| 232 | | * This reduces the bounding box slightly, to accomodate for this. |
| 233 | | * |
| 234 | | * This is a bad hack, but a necessary one. |
| 235 | | * |
| 236 | | * @param srs |
| 237 | | * @throws BBOXException |
| 238 | | */ |
| 239 | | public void adjustForGeoServer(SRS srs) throws BBOXException { |
| 240 | | double minX = 0; |
| 241 | | double minY = 0; |
| 242 | | double maxX = 0; |
| 243 | | double maxY = 0; |
| 244 | | |
| 245 | | if(srs.getNumber() == 900913) { |
| 246 | | minX = -20037508.34 * 0.995; |
| 247 | | minY = -20037508.34 * 0.995; |
| 248 | | maxX = 20037508.34 * 0.995; |
| 249 | | maxY = 20037508.34 * 0.995; |
| 250 | | |
| 251 | | } else if(srs.getNumber() == 4326) { |
| 252 | | minX = -180.0 * 0.995; |
| 253 | | minY = -90.0 * 0.995; |
| 254 | | maxX = 180.0 * 0.995; |
| 255 | | maxY = 90.0 * 0.995; |
| 256 | | } else { |
| 257 | | return; |
| 258 | | } |
| 259 | | |
| 260 | | if(this.coords[0] < minX) { |
| 261 | | this.coords[0] = minX; |
| 262 | | log.trace("Limited minX bounds "+Double.toString(minX)+" to avoid GeoServer problems"); |
| 263 | | } |
| 264 | | if(this.coords[1] < minY) { |
| 265 | | this.coords[1] = minY; |
| 266 | | log.trace("Limited minY bounds "+Double.toString(minY)+" to avoid GeoServer problems"); |
| 267 | | } |
| 268 | | if(this.coords[2] > maxX) { |
| 269 | | this.coords[2] = maxX; |
| 270 | | log.trace("Limited maxX bounds "+Double.toString(maxX)+" to avoid GeoServer problems"); |
| 271 | | } |
| 272 | | if(this.coords[3] > maxY) { |
| 273 | | this.coords[3] = maxY; |
| 274 | | log.trace("Limited maxY bounds "+Double.toString(maxY)+" to avoid GeoServer problems"); |
| 275 | | } |
| 276 | | |
| 277 | | // Need to do another sanity check at this point |
| 278 | | if(! this.isSane()) { |
| 279 | | throw new BBOXException("Adjusted BBOX " + this.toString() + " is no longer sane."); |
| 280 | | } |
| 281 | | } |