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 ) ) ; } } ) ; } }
Search all features within a certain layer that intersect a certain bounding box .