46
46
* @author wachu
47
47
* @author pitek
48
48
*/
49
- public class WmsRequestHandler
50
- extends ImageServer
51
- implements ImageServerConstants {
49
+ public class WmsRequestHandler extends ImageServer implements ImageServerConstants {
52
50
53
51
/**
54
52
*/
@@ -72,8 +70,8 @@ public class WmsRequestHandler
72
70
* @throws IOException
73
71
* @throws WMSException
74
72
*/
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 {
77
75
78
76
super (props );
79
77
setProperties (props );
@@ -95,8 +93,8 @@ public WmsRequestHandler(String wmsScheme, String wmsHostName, int wmsPort, Stri
95
93
}
96
94
97
95
// create FeatureInfoResponse from properties.
98
- featureInfoResponse =
99
- ( FeatureInfoResponse ) PropUtils . objectFromProperties ( props , WMSPrefix + FeatureInfoResponseClassNameProperty );
96
+ featureInfoResponse = ( FeatureInfoResponse ) PropUtils . objectFromProperties ( props , WMSPrefix
97
+ + FeatureInfoResponseClassNameProperty );
100
98
if (featureInfoResponse == null ) {
101
99
featureInfoResponse = new DefaultFeatureInfoResponse ();
102
100
}
@@ -189,7 +187,8 @@ protected Layer getTopLayerByName(String wmsName) {
189
187
if (layer instanceof Layer ) {
190
188
return (Layer ) layer ;
191
189
}
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 ());
193
192
}
194
193
195
194
/**
@@ -274,7 +273,8 @@ public byte[] handleGetMapRequest(Properties requestProperties)
274
273
275
274
checkLayersAndStyles (requestProperties , parameters );
276
275
277
- Debug .message ("ms" , "handleGetMapRequest: createImage layers:" + parameters .topLayerNames .toString ());
276
+ Debug .message ("ms" , "handleGetMapRequest: createImage layers:"
277
+ + parameters .topLayerNames .toString ());
278
278
return createImage (projection , parameters .width , parameters .height , parameters .topLayerNames , bgPaint );
279
279
}
280
280
@@ -319,7 +319,8 @@ public byte[] handleGetLegendGraphicRequest(Properties requestProperties)
319
319
* @throws MapRequestFormatException
320
320
* @throws WMSException
321
321
*/
322
- public void handleGetCapabilitiesRequest (Properties requestProperties , IHttpResponse httpResponse )
322
+ public void handleGetCapabilitiesRequest (Properties requestProperties ,
323
+ IHttpResponse httpResponse )
323
324
throws IOException , MapRequestFormatException , WMSException {
324
325
String response = handleGetCapabilitiesRequest (requestProperties );
325
326
httpResponse .writeHttpResponse (HttpConnection .CONTENT_XML , response .getBytes ("UTF-8" ));
@@ -375,7 +376,8 @@ public String handleGetCapabilitiesRequest(Properties requestProperties)
375
376
* @throws MapRequestFormatException
376
377
* @throws WMSException
377
378
*/
378
- public void handleGetLegendGraphicRequest (Properties requestProperties , IHttpResponse httpResponse )
379
+ public void handleGetLegendGraphicRequest (Properties requestProperties ,
380
+ IHttpResponse httpResponse )
379
381
throws IOException , MapRequestFormatException , WMSException {
380
382
byte [] image = handleGetLegendGraphicRequest (requestProperties );
381
383
String contentType = getFormatter ().getContentType ();
@@ -467,8 +469,7 @@ protected byte[] getFormattedImage(ImageFormatter formatter, int scaledWidth, in
467
469
* @param requestProperties
468
470
* @throws WMSException
469
471
*/
470
- private void checkRequest (Properties requestProperties )
471
- throws WMSException {
472
+ private void checkRequest (Properties requestProperties ) throws WMSException {
472
473
String service = requestProperties .getProperty (SERVICE );
473
474
String requestType = requestProperties .getProperty (REQUEST );
474
475
@@ -485,8 +486,8 @@ private void checkRequest(Properties requestProperties)
485
486
* @param parameters
486
487
* @throws WMSException
487
488
*/
488
- private void checkProjectionType (Properties requestProperties , GetMapRequestParameters parameters )
489
- throws WMSException {
489
+ private void checkProjectionType (Properties requestProperties ,
490
+ GetMapRequestParameters parameters ) throws WMSException {
490
491
String strSRS = requestProperties .getProperty (SRS );
491
492
if (strSRS == null ) {
492
493
// wms 1.3.0 uses CRS parameter instead of SRS
@@ -503,7 +504,8 @@ private void checkProjectionType(Properties requestProperties, GetMapRequestPara
503
504
parameters .crs = crs ;
504
505
}
505
506
506
- private void checkWidthAndHeight (Properties requestProperties , WidthAndHeightRequestParameters parameters )
507
+ private void checkWidthAndHeight (Properties requestProperties ,
508
+ WidthAndHeightRequestParameters parameters )
507
509
throws WMSException {
508
510
String strWidth = requestProperties .getProperty (WIDTH );
509
511
if (strWidth == null ) {
@@ -548,8 +550,7 @@ private void checkBoundingBox(Properties requestProperties, GetMapRequestParamet
548
550
}
549
551
String [] arrayBBox = strBBox .split ("," );
550
552
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 );
553
554
}
554
555
555
556
try {
@@ -558,9 +559,16 @@ private void checkBoundingBox(Properties requestProperties, GetMapRequestParamet
558
559
double minY = Double .parseDouble (arrayBBox [1 ]);
559
560
double maxX = Double .parseDouble (arrayBBox [2 ]);
560
561
double maxY = Double .parseDouble (arrayBBox [3 ]);
561
- double medX = ((maxX - minX ) / 2d ) + minX ;
562
562
double medY = ((maxY - minY ) / 2d ) + minY ;
563
563
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
+
564
572
// use CRS to convert BBOX to latlon values
565
573
CoordinateReferenceSystem crs = parameters .crs ;
566
574
parameters .bboxLatLonLowerLeft = crs .inverse (minX , minY , parameters .getVersion ().usesAxisOrder ());
@@ -574,8 +582,8 @@ private void checkBoundingBox(Properties requestProperties, GetMapRequestParamet
574
582
}
575
583
}
576
584
577
- private void checkLayersAndStyles (Properties requestProperties , GetMapRequestParameters parameters )
578
- throws WMSException {
585
+ private void checkLayersAndStyles (Properties requestProperties ,
586
+ GetMapRequestParameters parameters ) throws WMSException {
579
587
String strLayers = requestProperties .getProperty (LAYERS );
580
588
if (strLayers == null ) {
581
589
throw new WMSException ("LAYERS not specified." , WMSException .LAYERNOTDEFINED );
@@ -653,7 +661,8 @@ private void checkLayersAndStyles(Properties requestProperties, GetMapRequestPar
653
661
}
654
662
}
655
663
656
- private void checkLayerAndStyle (Properties requestProperties , GetLegendGraphicRequestParameters parameters )
664
+ private void checkLayerAndStyle (Properties requestProperties ,
665
+ GetLegendGraphicRequestParameters parameters )
657
666
throws WMSException {
658
667
659
668
String layerName = requestProperties .getProperty (LAYER );
@@ -680,8 +689,8 @@ private void checkLayerAndStyle(Properties requestProperties, GetLegendGraphicRe
680
689
}
681
690
}
682
691
683
- private void checkQueryLayers (Properties requestProperties , GetFeatureInfoRequestParameters parameters )
684
- throws WMSException {
692
+ private void checkQueryLayers (Properties requestProperties ,
693
+ GetFeatureInfoRequestParameters parameters ) throws WMSException {
685
694
686
695
String strLayers = requestProperties .getProperty (QUERY_LAYERS );
687
696
if (strLayers == null ) {
@@ -738,7 +747,8 @@ private Proj createProjection(Properties requestProperties, GetMapRequestParamet
738
747
739
748
LatLonPoint llp1 = parameters .bboxLatLonLowerLeft ;
740
749
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 );
742
752
projection .setCenter (parameters .bboxLatLonCenter );
743
753
744
754
int intnewwidth = parameters .width ;
@@ -834,7 +844,8 @@ private void checkExceptions(Properties requestProperties, WmsRequestParameters
834
844
// for image base exceptions
835
845
}
836
846
837
- private void checkFeatureInfoPoint (Properties requestProperties , GetFeatureInfoRequestParameters parameters )
847
+ private void checkFeatureInfoPoint (Properties requestProperties ,
848
+ GetFeatureInfoRequestParameters parameters )
838
849
throws WMSException {
839
850
840
851
parameters .x = -1 ;
@@ -853,8 +864,8 @@ private void checkFeatureInfoPoint(Properties requestProperties, GetFeatureInfoR
853
864
}
854
865
}
855
866
856
- private void checkInfoFormat (Properties requestProperties , GetFeatureInfoRequestParameters parameters )
857
- throws WMSException {
867
+ private void checkInfoFormat (Properties requestProperties ,
868
+ GetFeatureInfoRequestParameters parameters ) throws WMSException {
858
869
859
870
String format = requestProperties .getProperty (INFO_FORMAT );
860
871
0 commit comments