Package org.geomajas.command.dto

Examples of org.geomajas.command.dto.SearchByLocationRequest


  private DtoConverterService converter;

  @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");
View Full Code Here


  }

  @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");
View Full Code Here

  }

  @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");
View Full Code Here

  }

  @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");
View Full Code Here

  }

  @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
View Full Code Here

  // ----------------------------------------------------------

  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;
    }
  }
View Full Code Here

   */
  public void onMouseUp(MouseUpEvent event) {
    Coordinate worldPosition = getWorldPosition(event);
    Point point = mapWidget.getMapModel().getGeometryFactory().createPoint(worldPosition);

    SearchByLocationRequest request = new SearchByLocationRequest();
    request.setLocation(GeometryConverter.toDto(point));
    request.setCrs(mapWidget.getMapModel().getCrs());
    request.setQueryType(SearchByLocationRequest.QUERY_INTERSECTS);
    request.setSearchType(SearchByLocationRequest.SEARCH_FIRST_LAYER);
    request.setBuffer(calculateBufferFromPixelTolerance());
    request.setFeatureIncludes(GwtCommandDispatcher.getInstance().getLazyFeatureIncludesSelect());
    request.setLayerIds(getServerLayerIds(mapWidget.getMapModel()));
    for (Layer<?> layer : mapWidget.getMapModel().getLayers()) {
      if (layer.isShowing() && layer instanceof VectorLayer) {
        request.setFilter(layer.getServerLayerId(), ((VectorLayer) layer).getFilter());
      }
    }

    GwtCommand commandRequest = new GwtCommand(SearchByLocationRequest.COMMAND);
    commandRequest.setCommandRequest(request);
View Full Code Here

      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 CommandCallback() {
      public void execute(CommandResponse commandResponse) {
        if (commandResponse instanceof SearchByLocationResponse) {
          SearchByLocationResponse response = (SearchByLocationResponse) commandResponse;
View Full Code 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 CommandCallback<CommandResponse>() {

      public void execute(CommandResponse commandResponse) {
        if (commandResponse instanceof SearchByLocationResponse) {
View Full Code Here

      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;
View Full Code Here

TOP

Related Classes of org.geomajas.command.dto.SearchByLocationRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.