Skip to content

Commit 791fd7e

Browse files
committed
Adding comments and notes pointing out where/why crossing the dateline
isn't supported.
1 parent 5ebeb6e commit 791fd7e

File tree

1 file changed

+39
-28
lines changed

1 file changed

+39
-28
lines changed

src/openmap/com/bbn/openmap/image/wms/WmsRequestHandler.java

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@
4646
* @author wachu
4747
* @author pitek
4848
*/
49-
public class WmsRequestHandler
50-
extends ImageServer
51-
implements ImageServerConstants {
49+
public class WmsRequestHandler extends ImageServer implements ImageServerConstants {
5250

5351
/**
5452
*/
@@ -72,8 +70,8 @@ public class WmsRequestHandler
7270
* @throws IOException
7371
* @throws WMSException
7472
*/
75-
public WmsRequestHandler(String wmsScheme, String wmsHostName, int wmsPort, String wmsUrlPath, Properties props)
76-
throws IOException, WMSException {
73+
public WmsRequestHandler(String wmsScheme, String wmsHostName, int wmsPort, String wmsUrlPath,
74+
Properties props) throws IOException, WMSException {
7775

7876
super(props);
7977
setProperties(props);
@@ -95,8 +93,8 @@ public WmsRequestHandler(String wmsScheme, String wmsHostName, int wmsPort, Stri
9593
}
9694

9795
// create FeatureInfoResponse from properties.
98-
featureInfoResponse =
99-
(FeatureInfoResponse) PropUtils.objectFromProperties(props, WMSPrefix + FeatureInfoResponseClassNameProperty);
96+
featureInfoResponse = (FeatureInfoResponse) PropUtils.objectFromProperties(props, WMSPrefix
97+
+ FeatureInfoResponseClassNameProperty);
10098
if (featureInfoResponse == null) {
10199
featureInfoResponse = new DefaultFeatureInfoResponse();
102100
}
@@ -189,7 +187,8 @@ protected Layer getTopLayerByName(String wmsName) {
189187
if (layer instanceof Layer) {
190188
return (Layer) layer;
191189
}
192-
throw new IllegalStateException("Top layer must be a OpenMap Layer, not " + layer.getClass());
190+
throw new IllegalStateException("Top layer must be a OpenMap Layer, not "
191+
+ layer.getClass());
193192
}
194193

195194
/**
@@ -274,7 +273,8 @@ public byte[] handleGetMapRequest(Properties requestProperties)
274273

275274
checkLayersAndStyles(requestProperties, parameters);
276275

277-
Debug.message("ms", "handleGetMapRequest: createImage layers:" + parameters.topLayerNames.toString());
276+
Debug.message("ms", "handleGetMapRequest: createImage layers:"
277+
+ parameters.topLayerNames.toString());
278278
return createImage(projection, parameters.width, parameters.height, parameters.topLayerNames, bgPaint);
279279
}
280280

@@ -319,7 +319,8 @@ public byte[] handleGetLegendGraphicRequest(Properties requestProperties)
319319
* @throws MapRequestFormatException
320320
* @throws WMSException
321321
*/
322-
public void handleGetCapabilitiesRequest(Properties requestProperties, IHttpResponse httpResponse)
322+
public void handleGetCapabilitiesRequest(Properties requestProperties,
323+
IHttpResponse httpResponse)
323324
throws IOException, MapRequestFormatException, WMSException {
324325
String response = handleGetCapabilitiesRequest(requestProperties);
325326
httpResponse.writeHttpResponse(HttpConnection.CONTENT_XML, response.getBytes("UTF-8"));
@@ -375,7 +376,8 @@ public String handleGetCapabilitiesRequest(Properties requestProperties)
375376
* @throws MapRequestFormatException
376377
* @throws WMSException
377378
*/
378-
public void handleGetLegendGraphicRequest(Properties requestProperties, IHttpResponse httpResponse)
379+
public void handleGetLegendGraphicRequest(Properties requestProperties,
380+
IHttpResponse httpResponse)
379381
throws IOException, MapRequestFormatException, WMSException {
380382
byte[] image = handleGetLegendGraphicRequest(requestProperties);
381383
String contentType = getFormatter().getContentType();
@@ -467,8 +469,7 @@ protected byte[] getFormattedImage(ImageFormatter formatter, int scaledWidth, in
467469
* @param requestProperties
468470
* @throws WMSException
469471
*/
470-
private void checkRequest(Properties requestProperties)
471-
throws WMSException {
472+
private void checkRequest(Properties requestProperties) throws WMSException {
472473
String service = requestProperties.getProperty(SERVICE);
473474
String requestType = requestProperties.getProperty(REQUEST);
474475

@@ -485,8 +486,8 @@ private void checkRequest(Properties requestProperties)
485486
* @param parameters
486487
* @throws WMSException
487488
*/
488-
private void checkProjectionType(Properties requestProperties, GetMapRequestParameters parameters)
489-
throws WMSException {
489+
private void checkProjectionType(Properties requestProperties,
490+
GetMapRequestParameters parameters) throws WMSException {
490491
String strSRS = requestProperties.getProperty(SRS);
491492
if (strSRS == null) {
492493
// wms 1.3.0 uses CRS parameter instead of SRS
@@ -503,7 +504,8 @@ private void checkProjectionType(Properties requestProperties, GetMapRequestPara
503504
parameters.crs = crs;
504505
}
505506

506-
private void checkWidthAndHeight(Properties requestProperties, WidthAndHeightRequestParameters parameters)
507+
private void checkWidthAndHeight(Properties requestProperties,
508+
WidthAndHeightRequestParameters parameters)
507509
throws WMSException {
508510
String strWidth = requestProperties.getProperty(WIDTH);
509511
if (strWidth == null) {
@@ -548,8 +550,7 @@ private void checkBoundingBox(Properties requestProperties, GetMapRequestParamet
548550
}
549551
String[] arrayBBox = strBBox.split(",");
550552
if (arrayBBox.length != 4) {
551-
throw new WMSException("Invalid BBOX parameter. BBOX must contain exactly 4 values separated with comas.",
552-
WMSException.INVALIDDIMENSIONVALUE);
553+
throw new WMSException("Invalid BBOX parameter. BBOX must contain exactly 4 values separated with comas.", WMSException.INVALIDDIMENSIONVALUE);
553554
}
554555

555556
try {
@@ -558,9 +559,16 @@ private void checkBoundingBox(Properties requestProperties, GetMapRequestParamet
558559
double minY = Double.parseDouble(arrayBBox[1]);
559560
double maxX = Double.parseDouble(arrayBBox[2]);
560561
double maxY = Double.parseDouble(arrayBBox[3]);
561-
double medX = ((maxX - minX) / 2d) + minX;
562562
double medY = ((maxY - minY) / 2d) + minY;
563563

564+
// This doesn't work over the dateline
565+
double medX = ((maxX - minX) / 2d) + minX;
566+
567+
// Maybe we need to add a crs capability for figuring out medX if
568+
// the dateline is being crossed. If we had a proper medX it
569+
// wouldn't be a problem, OpenMap can handle creating images that
570+
// cross the dateline.
571+
564572
// use CRS to convert BBOX to latlon values
565573
CoordinateReferenceSystem crs = parameters.crs;
566574
parameters.bboxLatLonLowerLeft = crs.inverse(minX, minY, parameters.getVersion().usesAxisOrder());
@@ -574,8 +582,8 @@ private void checkBoundingBox(Properties requestProperties, GetMapRequestParamet
574582
}
575583
}
576584

577-
private void checkLayersAndStyles(Properties requestProperties, GetMapRequestParameters parameters)
578-
throws WMSException {
585+
private void checkLayersAndStyles(Properties requestProperties,
586+
GetMapRequestParameters parameters) throws WMSException {
579587
String strLayers = requestProperties.getProperty(LAYERS);
580588
if (strLayers == null) {
581589
throw new WMSException("LAYERS not specified.", WMSException.LAYERNOTDEFINED);
@@ -653,7 +661,8 @@ private void checkLayersAndStyles(Properties requestProperties, GetMapRequestPar
653661
}
654662
}
655663

656-
private void checkLayerAndStyle(Properties requestProperties, GetLegendGraphicRequestParameters parameters)
664+
private void checkLayerAndStyle(Properties requestProperties,
665+
GetLegendGraphicRequestParameters parameters)
657666
throws WMSException {
658667

659668
String layerName = requestProperties.getProperty(LAYER);
@@ -680,8 +689,8 @@ private void checkLayerAndStyle(Properties requestProperties, GetLegendGraphicRe
680689
}
681690
}
682691

683-
private void checkQueryLayers(Properties requestProperties, GetFeatureInfoRequestParameters parameters)
684-
throws WMSException {
692+
private void checkQueryLayers(Properties requestProperties,
693+
GetFeatureInfoRequestParameters parameters) throws WMSException {
685694

686695
String strLayers = requestProperties.getProperty(QUERY_LAYERS);
687696
if (strLayers == null) {
@@ -738,7 +747,8 @@ private Proj createProjection(Properties requestProperties, GetMapRequestParamet
738747

739748
LatLonPoint llp1 = parameters.bboxLatLonLowerLeft;
740749
LatLonPoint llp2 = parameters.bboxLatLonUpperRight;
741-
Debug.message("wms", "bbox toLatLon: 1: " + llp1 + ", 2: " + llp2 + ", center: " + parameters.bboxLatLonCenter);
750+
Debug.message("wms", "bbox toLatLon: 1: " + llp1 + ", 2: " + llp2 + ", center: "
751+
+ parameters.bboxLatLonCenter);
742752
projection.setCenter(parameters.bboxLatLonCenter);
743753

744754
int intnewwidth = parameters.width;
@@ -834,7 +844,8 @@ private void checkExceptions(Properties requestProperties, WmsRequestParameters
834844
// for image base exceptions
835845
}
836846

837-
private void checkFeatureInfoPoint(Properties requestProperties, GetFeatureInfoRequestParameters parameters)
847+
private void checkFeatureInfoPoint(Properties requestProperties,
848+
GetFeatureInfoRequestParameters parameters)
838849
throws WMSException {
839850

840851
parameters.x = -1;
@@ -853,8 +864,8 @@ private void checkFeatureInfoPoint(Properties requestProperties, GetFeatureInfoR
853864
}
854865
}
855866

856-
private void checkInfoFormat(Properties requestProperties, GetFeatureInfoRequestParameters parameters)
857-
throws WMSException {
867+
private void checkInfoFormat(Properties requestProperties,
868+
GetFeatureInfoRequestParameters parameters) throws WMSException {
858869

859870
String format = requestProperties.getProperty(INFO_FORMAT);
860871

0 commit comments

Comments
 (0)