Skip to content

Commit

Permalink
Backporting GetFeatureInfo fixes
Browse files Browse the repository at this point in the history
git-svn-id: http://geowebcache.org/svn/tags/1.2.2b@1174 e7b91dd5-889a-44ae-8e97-0abfc27e49b2
  • Loading branch information
Arne Kepp committed Aug 12, 2010
1 parent 9d9f038 commit 3a94a8a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,9 @@ public boolean initialize(GridSetBroker gridSetBroker) {
return true;
}

public byte[] getFeatureInfo(ConveyorTile convTile, int x, int y)
public byte[] getFeatureInfo(ConveyorTile convTile, BoundingBox bbox, int height, int width, int x, int y)
throws GeoWebCacheException {
return sourceHelper.makeFeatureInfoRequest(convTile,x,y);
return sourceHelper.makeFeatureInfoRequest(convTile,bbox,height, width, x,y);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public byte[] makeRequest(ConveyorTile tile) throws GeoWebCacheException {
}


public byte[] makeFeatureInfoRequest(ConveyorTile tile, int x, int y)
public byte[] makeFeatureInfoRequest(ConveyorTile tile, BoundingBox bbox, int height, int width, int x, int y)
throws GeoWebCacheException {
WMSLayer layer = (WMSLayer) tile.getLayer();

Expand All @@ -84,10 +84,8 @@ public byte[] makeFeatureInfoRequest(ConveyorTile tile, int x, int y)
strBuilder.append("&INFO_FORMAT=").append(tile.getMimeType().getFormat());
strBuilder.append("&FORMAT=").append(tile.getMimeType().getFormat());
strBuilder.append("&SRS=").append(layer.backendSRSOverride(gridSubset.getSRS()));
strBuilder.append("&HEIGHT=").append(gridSubset.getTileHeight());
strBuilder.append("&WIDTH=").append(gridSubset.getTileWidth());

BoundingBox bbox = gridSubset.boundsFromIndex(tile.getTileIndex());
strBuilder.append("&HEIGHT=").append(height);
strBuilder.append("&WIDTH=").append(width);

strBuilder.append("&BBOX=").append(bbox);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private void handleGetFeatureInfo(ConveyorTile tile)
+ " is not served by a WMS backend.");
}

String[] keys = { "x","y","srs","info_format","bbox" };
String[] keys = { "x","y","srs","info_format","bbox","height","width" };
String[] values = ServletUtils.selectedStringsFromMap(
tile.servletReq.getParameterMap(), tile.servletReq.getCharacterEncoding(), keys);

Expand All @@ -251,21 +251,37 @@ private void handleGetFeatureInfo(ConveyorTile tile)
throw new ServiceException("The bounding box parameter ("+values[2]+") is missing or not sane");
}

long[] tileIndex = gridSubset.closestIndex(bbox);
//long[] tileIndex = gridSubset.closestIndex(bbox);

MimeType mimeType = MimeType.createFromFormat(values[3]);

ConveyorTile gfiConv = new ConveyorTile(
sb, tl.getName(), gridSubset.getName(), tileIndex, mimeType,
sb, tl.getName(), gridSubset.getName(), null, mimeType,
null, null, tile.servletReq, tile.servletResp);
gfiConv.setTileLayer(tl);

WMSSourceHelper srcHelper = layer.getSourceHelper();

int x,y;
try {
x = Integer.parseInt(values[0]);
y = Integer.parseInt(values[1]);
} catch (NumberFormatException nfe) {
throw new GeoWebCacheException(
"The parameters for x and y must both be positive integers.");
}

byte[] data = srcHelper.makeFeatureInfoRequest(gfiConv,
Integer.parseInt(values[0]),
Integer.parseInt(values[1]));
int height, width;
try {
height = Integer.parseInt(values[5]);
width = Integer.parseInt(values[6]);
} catch (NumberFormatException nfe) {
throw new GeoWebCacheException(
"The parameters for height and width must both be positive integers.");
}

byte[] data = srcHelper.makeFeatureInfoRequest(gfiConv, bbox, height, width, x, y);

try {
tile.servletResp.setContentType(mimeType.getMimeType());
tile.servletResp.getOutputStream().write(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.geowebcache.GeoWebCacheException;
import org.geowebcache.conveyor.ConveyorTile;
import org.geowebcache.conveyor.Conveyor.CacheResult;
import org.geowebcache.grid.BoundingBox;
import org.geowebcache.grid.GridSet;
import org.geowebcache.layer.TileLayer;
import org.geowebcache.layer.wms.WMSLayer;
Expand Down Expand Up @@ -73,7 +74,12 @@ protected void writeResponse(RuntimeStats stats) throws OWSException {

byte[] data = null;
try {
data = wmsLayer.getFeatureInfo(convTile, i, j);
BoundingBox bbox = convTile.getGridSubset().boundsFromIndex(convTile.getTileIndex());
data = wmsLayer.getFeatureInfo(
convTile,bbox,
convTile.getGridSubset().getTileHeight(),
convTile.getGridSubset().getTileWidth(),
i, j);
} catch (GeoWebCacheException e) {
throw new OWSException(500, "NoApplicableCode", "", e.getMessage());
}
Expand Down

0 comments on commit 3a94a8a

Please sign in to comment.