本文整理汇总了Java中org.geomajas.command.dto.SearchByLocationRequest类的典型用法代码示例。如果您正苦于以下问题:Java SearchByLocationRequest类的具体用法?Java SearchByLocationRequest怎么用?Java SearchByLocationRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SearchByLocationRequest类属于org.geomajas.command.dto包,在下文中一共展示了SearchByLocationRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSearchByLocationRequest
import org.geomajas.command.dto.SearchByLocationRequest; //导入依赖的package包/类
protected SearchByLocationRequest getSearchByLocationRequest(VectorLayer layer) {
if (request instanceof SearchByLocationRequest) {
SearchByLocationRequest req = (SearchByLocationRequest) request;
SearchByLocationRequest clone = new SearchByLocationRequest();
clone.setBuffer(req.getBuffer());
clone.setCrs(req.getCrs());
clone.setFilter(req.getFilter());
clone.setFeatureIncludes(req.getFeatureIncludes());
clone.setLocation(req.getLocation());
clone.setQueryType(req.getQueryType());
clone.setRatio(req.getRatio());
clone.setSearchType(req.getSearchType());
// not bothering to include the other layers, we won't use the
// result anyway
clone.setLayerIds(new String[] { layer.getServerLayerId() });
return clone;
} else {
return null;
}
}
示例2: getSnappingSources
import org.geomajas.command.dto.SearchByLocationRequest; //导入依赖的package包/类
/**
* Get the geometries of all features within the map view bounds.
*/
public void getSnappingSources(final GeometryArrayFunction callback) {
GwtCommand commandRequest = new GwtCommand(SearchByLocationRequest.COMMAND);
SearchByLocationRequest request = new SearchByLocationRequest();
request.addLayerWithFilter(layer.getServerLayerId(), layer.getServerLayerId(), layer.getFilter());
request.setFeatureIncludes(GeomajasConstant.FEATURE_INCLUDE_GEOMETRY);
request.setLocation(boundsAsGeometry());
request.setCrs(layer.getMapModel().getCrs());
request.setQueryType(SearchByLocationRequest.QUERY_INTERSECTS);
request.setSearchType(SearchByLocationRequest.SEARCH_ALL_LAYERS);
commandRequest.setCommandRequest(request);
GwtCommandDispatcher.getInstance().execute(commandRequest,
new AbstractCommandCallback<SearchByLocationResponse>() {
public void execute(SearchByLocationResponse response) {
if (response.getFeatureMap().size() > 0) {
List<Feature> features = response.getFeatureMap().values().iterator().next();
Geometry[] geometries = new Geometry[features.size()];
for (int i = 0; i < features.size(); i++) {
geometries[i] = features.get(i).getGeometry();
}
callback.execute(geometries);
}
}
});
}
示例3: firstLayer
import org.geomajas.command.dto.SearchByLocationRequest; //导入依赖的package包/类
@Test
public void firstLayer() throws Exception {
// prepare command
SearchByLocationRequest request = new SearchByLocationRequest();
request.setCrs("EPSG:4326");
request.setQueryType(SearchByLocationRequest.QUERY_INTERSECTS);
request.setSearchType(SearchByLocationRequest.SEARCH_FIRST_LAYER);
final String region1ResultTag = "countries layer region 1";
final String region2ResultTag = "countries layer region 2";
request.addLayerWithFilter(region1ResultTag, LAYER_ID, "region='Region 1'");
request.addLayerWithFilter(region2ResultTag, LAYER_ID, "region='Region 2'");
request.setLocation(GeometryService.toPolygon(new Bbox(-180, -90, 360, 180)));
// execute
SearchByLocationResponse response = (SearchByLocationResponse) dispatcher.execute(
SearchByLocationRequest.COMMAND, request, null, "en");
// test
Assert.assertFalse(response.isError());
Assert.assertEquals(1, response.getFeatureMap().size());
Assert.assertNotNull(response.getFeatureMap().get(region1ResultTag));
}
示例4: intersect50percentOverlapAlmost
import org.geomajas.command.dto.SearchByLocationRequest; //导入依赖的package包/类
@Test
public void intersect50percentOverlapAlmost() throws Exception {
// prepare command
SearchByLocationRequest request = new SearchByLocationRequest();
request.setCrs("EPSG:4326");
request.setQueryType(SearchByLocationRequest.QUERY_INTERSECTS);
request.setSearchType(SearchByLocationRequest.SEARCH_ALL_LAYERS);
request.setRatio(0.5f);
request.setLayerIds(new String[] {LAYER_ID});
// create a rectangle that overlaps 49 %
GeometryFactory factory = new GeometryFactory();
LinearRing half1 = factory.createLinearRing(new Coordinate[] {new Coordinate(0, 0), new Coordinate(1, 0),
new Coordinate(1, 0.49), new Coordinate(0, 0.49), new Coordinate(0, 0)});
Polygon polygon = factory.createPolygon(half1, null);
request.setLocation(converter.toDto(polygon));
// execute
SearchByLocationResponse response = (SearchByLocationResponse) dispatcher.execute(
SearchByLocationRequest.COMMAND, request, null, "en");
// test
List<Feature> features = response.getFeatureMap().get(LAYER_ID);
Assert.assertNull(features);
}
示例5: searchInBounds
import org.geomajas.command.dto.SearchByLocationRequest; //导入依赖的package包/类
/**
* Search all features within a certain layer that intersect a certain bounding box.
*
* @param layer
* The features supported layer wherein to search.
* @param bbox
* The bounding box wherein to search.
* @param callback
* Call-back method executed on return (when features have been found).
*/
public void searchInBounds(final FeaturesSupported layer, Bbox bbox, final FeatureArrayCallback callback) {
MapModel mapModel = map.getMapWidget().getMapModel();
Layer<?> gwtLayer = mapModel.getLayer(layer.getId());
if (gwtLayer != null && gwtLayer instanceof VectorLayer) {
final VectorLayer vLayer = (VectorLayer) gwtLayer;
SearchByLocationRequest request = new SearchByLocationRequest();
request.addLayerWithFilter(vLayer.getId(), vLayer.getServerLayerId(), layer.getFilter());
GeometryFactory factory = new GeometryFactory(mapModel.getSrid(), GeometryFactory.PARAM_DEFAULT_PRECISION);
org.geomajas.gwt.client.spatial.Bbox box = new org.geomajas.gwt.client.spatial.Bbox(bbox.getX(),
bbox.getY(), bbox.getWidth(), bbox.getHeight());
request.setLocation(GeometryConverter.toDto(factory.createPolygon(box)));
request.setCrs(mapModel.getCrs());
request.setSearchType(SearchByLocationRequest.QUERY_INTERSECTS);
request.setSearchType(SearchByLocationRequest.SEARCH_ALL_LAYERS);
request.setFeatureIncludes(GeomajasConstant.FEATURE_INCLUDE_ALL);
GwtCommand commandRequest = new GwtCommand(SearchByLocationRequest.COMMAND);
commandRequest.setCommandRequest(request);
GwtCommandDispatcher.getInstance().execute(commandRequest,
new AbstractCommandCallback<SearchByLocationResponse>() {
public void execute(SearchByLocationResponse response) {
Map<String, List<org.geomajas.layer.feature.Feature>> featureMap = response.getFeatureMap();
List<org.geomajas.layer.feature.Feature> dtos = featureMap.get(vLayer.getId());
Feature[] features = new Feature[dtos.size()];
for (int i = 0; i < dtos.size(); i++) {
features[i] = new FeatureImpl(dtos.get(i), layer);
}
callback.execute(new FeatureArrayHolder(features));
}
});
}
}
示例6: geometryCriterionToFilters
import org.geomajas.command.dto.SearchByLocationRequest; //导入依赖的package包/类
private static Map<String, String> geometryCriterionToFilters(GeometryCriterion criterion, MapModel mapModel) {
Map<String, String> filters = new LinkedHashMap<String, String>();
org.geomajas.gwt.client.spatial.geometry.Geometry mapGeom = GeometryConverter.toGwt(criterion.getGeometry());
String wktGeom = mapGeom.toWkt();
String method;
switch (criterion.getOperator()) {
case SearchByLocationRequest.QUERY_INTERSECTS:
method = "INTERSECTS";
break;
case SearchByLocationRequest.QUERY_CONTAINS:
method = "CONTAINS";
break;
case SearchByLocationRequest.QUERY_TOUCHES:
method = "TOUCHES";
break;
case SearchByLocationRequest.QUERY_WITHIN:
method = "WITHIN";
break;
default:
return null;
}
for (String serverLayerId : criterion.getServerLayerIds()) {
VectorLayer vl = findVectorLayer(mapModel, serverLayerId);
if (vl != null) {
String geomAttName = vl.getLayerInfo().getFeatureInfo().getGeometryType().getName();
filters.put(serverLayerId, method + "(" + geomAttName + ", " + wktGeom + ")");
}
}
return filters;
}
示例7: setRequest
import org.geomajas.command.dto.SearchByLocationRequest; //导入依赖的package包/类
protected void setRequest(CommandRequest request) {
if (request instanceof SearchFeatureRequest || request instanceof SearchByLocationRequest) {
this.request = request;
} else {
throw new IllegalArgumentException(
"Please provide a request (SearchFeatureRequest or SearchByLocationRequest)");
}
}
示例8: getData
import org.geomajas.command.dto.SearchByLocationRequest; //导入依赖的package包/类
private void getData() {
Point point = mapWidget.getMapModel().getGeometryFactory().createPoint(worldPosition);
final Coordinate coordUsedForRetrieval = worldPosition;
SearchByLocationRequest request = new SearchByLocationRequest();
request.setLocation(GeometryConverter.toDto(point));
request.setCrs(mapWidget.getMapModel().getCrs());
request.setQueryType(SearchByLocationRequest.QUERY_INTERSECTS);
int layersToSearch = SearchByLocationRequest.SEARCH_ALL_LAYERS;
request.setSearchType(layersToSearch);
request.setBuffer(calculateBufferFromPixelTolerance());
request.setFeatureIncludes(GwtCommandDispatcher.getInstance().getLazyFeatureIncludesSelect());
for (Layer<?> layer : mapWidget.getMapModel().getLayers()) {
if (layer.isShowing() && layer instanceof VectorLayer) {
request.addLayerWithFilter(layer.getId(), layer.getServerLayerId(), ((VectorLayer) layer).getFilter());
}
}
GwtCommand commandRequest = new GwtCommand(SearchByLocationRequest.COMMAND);
commandRequest.setCommandRequest(request);
GwtCommandDispatcher.getInstance().execute(commandRequest,
new AbstractCommandCallback<SearchByLocationResponse>() {
public void execute(SearchByLocationResponse commandResponse) {
setTooltipData(coordUsedForRetrieval, commandResponse.getFeatureMap());
}
});
}
示例9: retrieveFeatures
import org.geomajas.command.dto.SearchByLocationRequest; //导入依赖的package包/类
private void retrieveFeatures() {
// setting current bounds before method returns so it isn't called
// multiple times while waiting for result
// (this is adequate for javascript, no real concurrency)
currentBounds = mapModel.getMapView().getBounds();
if (serverLayerIds == null) {
init();
}
Polygon polygon = mapModel.getGeometryFactory().createPolygon(currentBounds);
GwtCommand commandRequest = new GwtCommand(SearchByLocationRequest.COMMAND);
SearchByLocationRequest request = new SearchByLocationRequest();
request.setLayerIds(serverLayerIds);
addFilters(request);
request.setFeatureIncludes(GeomajasConstant.FEATURE_INCLUDE_GEOMETRY);
request.setLocation(GeometryConverter.toDto(polygon));
request.setCrs(mapModel.getCrs());
request.setQueryType(SearchByLocationRequest.QUERY_INTERSECTS);
request.setSearchType(SearchByLocationRequest.SEARCH_ALL_LAYERS);
commandRequest.setCommandRequest(request);
GwtCommandDispatcher.getInstance().execute(commandRequest,
new AbstractCommandCallback<SearchByLocationResponse>() {
public void execute(SearchByLocationResponse response) {
Map<String, List<org.geomajas.layer.feature.Feature>> featureMap = response.getFeatureMap();
featureCache.clear();
for (String serverLayerId : featureMap.keySet()) {
VectorLayer vl = findLayer(serverLayerId);
List<Feature> features = new ArrayList<Feature>();
featureCache.put(vl, features);
for (org.geomajas.layer.feature.Feature dtoFeat : featureMap.get(serverLayerId)) {
features.add(new Feature(dtoFeat, vl));
}
}
}
});
}
示例10: selectRectangle
import org.geomajas.command.dto.SearchByLocationRequest; //导入依赖的package包/类
@Override
protected void selectRectangle(Bbox selectedArea) {
// we can clear here !
if (!shiftOrCtrl) {
MapModel mapModel = mapWidget.getMapModel();
mapModel.clearSelectedFeatures();
}
GwtCommand commandRequest = new GwtCommand(SearchByLocationRequest.COMMAND);
SearchByLocationRequest request = new SearchByLocationRequest();
request.setLayerIds(getSelectionLayerIds());
for (Layer<?> layer : mapWidget.getMapModel().getLayers()) {
if (layer.isShowing() && layer instanceof VectorLayer) {
request.setFilter(layer.getServerLayerId(), ((VectorLayer) layer).getFilter());
}
}
Polygon polygon = mapWidget.getMapModel().getGeometryFactory().createPolygon(selectedArea);
request.setLocation(GeometryConverter.toDto(polygon));
request.setCrs(mapWidget.getMapModel().getCrs());
request.setQueryType(SearchByLocationRequest.QUERY_INTERSECTS);
request.setRatio(coverageRatio);
request.setSearchType(SearchByLocationRequest.SEARCH_ALL_LAYERS);
request.setFeatureIncludes(GwtCommandDispatcher.getInstance().getLazyFeatureIncludesSelect());
commandRequest.setCommandRequest(request);
GwtCommandDispatcher.getInstance().execute(commandRequest,
new AbstractCommandCallback<SearchByLocationResponse>() {
public void execute(SearchByLocationResponse response) {
Map<String, List<org.geomajas.layer.feature.Feature>> featureMap = response.getFeatureMap();
for (String layerId : featureMap.keySet()) {
selectFeatures(layerId, featureMap.get(layerId));
}
}
});
}
示例11: addVisibleLayers
import org.geomajas.command.dto.SearchByLocationRequest; //导入依赖的package包/类
private void addVisibleLayers(SearchByLocationRequest request, MapModel mapModel) {
for (VectorLayer layer : mapModel.getVectorLayers()) {
if (layer.isShowing()) {
request.addLayerWithFilter(layer.getId(), layer.getServerLayerId(), layer.getFilter());
}
}
}
示例12: intersectCountriesOnEquator
import org.geomajas.command.dto.SearchByLocationRequest; //导入依赖的package包/类
@Test
public void intersectCountriesOnEquator() throws Exception {
// prepare command
SearchByLocationRequest request = new SearchByLocationRequest();
request.setCrs("EPSG:4326");
request.setQueryType(SearchByLocationRequest.QUERY_INTERSECTS);
request.setSearchType(SearchByLocationRequest.SEARCH_ALL_LAYERS);
request.setLayerIds(new String[] {LAYER_ID});
GeometryFactory factory = new GeometryFactory();
LineString equator = factory.createLineString(new Coordinate[] {new Coordinate(0, 0),
new Coordinate(-180, 180)});
request.setLocation(converter.toDto(equator));
// execute
SearchByLocationResponse response = (SearchByLocationResponse) dispatcher.execute(
SearchByLocationRequest.COMMAND, request, null, "en");
// test
Assert.assertFalse(response.isError());
List<Feature> features = response.getFeatureMap().get(LAYER_ID);
Assert.assertNotNull(features);
Assert.assertEquals(4, features.size());
List<String> actual = new ArrayList<String>();
for (Feature feature : features) {
actual.add(feature.getLabel());
}
Assert.assertTrue(actual.contains("Country 4"));
Assert.assertTrue(actual.contains("Country 3"));
Assert.assertTrue(actual.contains("Country 2"));
Assert.assertTrue(actual.contains("Country 1"));
}
示例13: intersectCountriesOnEquatorWithFilter
import org.geomajas.command.dto.SearchByLocationRequest; //导入依赖的package包/类
@Test
public void intersectCountriesOnEquatorWithFilter() throws Exception {
// prepare command
SearchByLocationRequest request = new SearchByLocationRequest();
request.setCrs("EPSG:4326");
request.setQueryType(SearchByLocationRequest.QUERY_INTERSECTS);
request.setSearchType(SearchByLocationRequest.SEARCH_ALL_LAYERS);
request.setLayerIds(new String[] {LAYER_ID});
//note that setting a global filter on the SearchByLocationRequest will only work if the filter is applicable
//to all layers! In this test case there is only one layer.
request.setFilter("region='Region 1'");
GeometryFactory factory = new GeometryFactory();
LineString equator = factory.createLineString(new Coordinate[] {new Coordinate(0, 0),
new Coordinate(-180, 180)});
request.setLocation(converter.toDto(equator));
// execute
SearchByLocationResponse response = (SearchByLocationResponse) dispatcher.execute(
SearchByLocationRequest.COMMAND, request, null, "en");
// test
Assert.assertFalse(response.isError());
List<Feature> features = response.getFeatureMap().get(LAYER_ID);
Assert.assertNotNull(features);
Assert.assertEquals(2, features.size());
List<String> actual = new ArrayList<String>();
for (Feature feature : features) {
actual.add(feature.getLabel());
}
Assert.assertTrue(actual.contains("Country 2"));
Assert.assertTrue(actual.contains("Country 1"));
}
示例14: intersectCountriesOnEquatorWithLayerFilter
import org.geomajas.command.dto.SearchByLocationRequest; //导入依赖的package包/类
@Test
public void intersectCountriesOnEquatorWithLayerFilter() throws Exception {
// prepare command
SearchByLocationRequest request = new SearchByLocationRequest();
request.setCrs("EPSG:4326");
request.setQueryType(SearchByLocationRequest.QUERY_INTERSECTS);
request.setSearchType(SearchByLocationRequest.SEARCH_ALL_LAYERS);
request.setLayerIds(new String[] {LAYER_ID});
request.setFilter(LAYER_ID, "region='Region 1'");
GeometryFactory factory = new GeometryFactory();
LineString equator = factory.createLineString(new Coordinate[] {new Coordinate(0, 0),
new Coordinate(-180, 180)});
request.setLocation(converter.toDto(equator));
// execute
SearchByLocationResponse response = (SearchByLocationResponse) dispatcher.execute(
SearchByLocationRequest.COMMAND, request, null, "en");
// test
Assert.assertFalse(response.isError());
List<Feature> features = response.getFeatureMap().get(LAYER_ID);
Assert.assertNotNull(features);
Assert.assertEquals(2, features.size());
List<String> actual = new ArrayList<String>();
for (Feature feature : features) {
actual.add(feature.getLabel());
}
Assert.assertTrue(actual.contains("Country 2"));
Assert.assertTrue(actual.contains("Country 1"));
}
示例15: intersect50percentOverlapExactly
import org.geomajas.command.dto.SearchByLocationRequest; //导入依赖的package包/类
@Test
public void intersect50percentOverlapExactly() throws Exception {
// prepare command
SearchByLocationRequest request = new SearchByLocationRequest();
request.setCrs("EPSG:4326");
request.setQueryType(SearchByLocationRequest.QUERY_INTERSECTS);
request.setSearchType(SearchByLocationRequest.SEARCH_ALL_LAYERS);
request.setRatio(0.5f);
request.setLayerIds(new String[] {LAYER_ID});
// create a rectangle that overlaps 50 %
GeometryFactory factory = new GeometryFactory();
LinearRing half1 = factory.createLinearRing(new Coordinate[] {new Coordinate(0, 0), new Coordinate(1, 0),
new Coordinate(1, 0.5), new Coordinate(0, 0.5), new Coordinate(0, 0)});
Polygon polygon = factory.createPolygon(half1, null);
request.setLocation(converter.toDto(polygon));
// execute
SearchByLocationResponse response = (SearchByLocationResponse) dispatcher.execute(
SearchByLocationRequest.COMMAND, request, null, "en");
// test
Assert.assertFalse(response.isError());
List<Feature> features = response.getFeatureMap().get(LAYER_ID);
Assert.assertNotNull(features);
List<String> actual = new ArrayList<String>();
for (Feature feature : features) {
actual.add(feature.getLabel());
}
List<String> expected = new ArrayList<String>();
expected.add("Country 1");
Assert.assertEquals(expected, actual);
}