if (clearSelection) {
mapWidget.getMapModel().clearSelectedFeatures();
}
MapModel mapModel = mapWidget.getMapModel();
Coordinate worldPosition = mapModel.getMapView().getWorldViewTransformer().viewToWorld(coordinate);
GwtCommand commandRequest = new GwtCommand(SearchByLocationRequest.COMMAND);
SearchByLocationRequest request = new SearchByLocationRequest();
Layer<?> layer = mapModel.getSelectedLayer();
if (priorityToSelectedLayer && layer != null && layer instanceof VectorLayer) {
if (!layer.isShowing()) {
return;
}
request.setLayerIds(new String[] { layer.getServerLayerId() });
request.setFilter(layer.getServerLayerId(), ((VectorLayer) layer).getFilter());
} else {
request.setLayerIds(getVisibleServerLayerIds(mapModel));
}
Point point = mapModel.getGeometryFactory().createPoint(worldPosition);
request.setLocation(GeometryConverter.toDto(point));
request.setCrs(mapWidget.getMapModel().getCrs());
request.setQueryType(SearchByLocationRequest.QUERY_INTERSECTS);
request.setSearchType(SearchByLocationRequest.SEARCH_ALL_LAYERS);
request.setBuffer(calculateBufferFromPixelTolerance());
request.setFeatureIncludes(GwtCommandDispatcher.getInstance().getLazyFeatureIncludesSelect());
commandRequest.setCommandRequest(request);
GwtCommandDispatcher.getInstance().execute(commandRequest, new CommandCallback<CommandResponse>() {
public void execute(CommandResponse commandResponse) {
if (commandResponse instanceof SearchByLocationResponse) {
SearchByLocationResponse response = (SearchByLocationResponse) commandResponse;
Map<String, List<Feature>> featureMap = response.getFeatureMap();