当前位置: 首页>>代码示例>>Java>>正文


Java FilterFactory2.bbox方法代码示例

本文整理汇总了Java中org.opengis.filter.FilterFactory2.bbox方法的典型用法代码示例。如果您正苦于以下问题:Java FilterFactory2.bbox方法的具体用法?Java FilterFactory2.bbox怎么用?Java FilterFactory2.bbox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.opengis.filter.FilterFactory2的用法示例。


在下文中一共展示了FilterFactory2.bbox方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAlternateGeometry

import org.opengis.filter.FilterFactory2; //导入方法依赖的package包/类
@Test
public void testAlternateGeometry() throws Exception {
    init("active", "geo2");
    SimpleFeatureType schema = featureSource.getSchema();
    GeometryDescriptor gd = schema.getGeometryDescriptor();
    assertNotNull(gd);
    assertEquals("geo2", gd.getLocalName());

    FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory();
    BBOX bbox = ff.bbox("geo2", 6.5, 23.5, 7.5, 24.5, "EPSG:4326");
    SimpleFeatureCollection features = featureSource.getFeatures(bbox);
    assertEquals(1, features.size());
    SimpleFeatureIterator fsi = features.features();
    assertTrue(fsi.hasNext());
    assertEquals(fsi.next().getID(), "active.09");
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:17,代码来源:ElasticGeometryFilterIT.java

示例2: testOgrStyleGeoPoint

import org.opengis.filter.FilterFactory2; //导入方法依赖的package包/类
@Test
public void testOgrStyleGeoPoint() throws Exception {
    init("not-active","geo4.coordinates");
    FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory();
    BBOX bbox = ff.bbox("geo4.coordinates", 0, 0, 5, 5, "EPSG:4326");
    assertNotNull(featureSource.getSchema().getDescriptor("geo4.coordinates"));
    assertNull(featureSource.getSchema().getDescriptor("geo4.type"));

    SimpleFeatureCollection features = featureSource.getFeatures(bbox);
    assertEquals(1, features.size());
    SimpleFeatureIterator fsi = features.features();
    assertTrue(fsi.hasNext());
    SimpleFeature feature = fsi.next();
    assertEquals(feature.getID(), "active.13");
    assertNotNull(feature.getDefaultGeometry());
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:17,代码来源:ElasticGeometryFilterIT.java

示例3: grabFeaturesInBoundingBox

import org.opengis.filter.FilterFactory2; //导入方法依赖的package包/类
/**
 * What features on in this bounding Box?
 * 
 * You can make a bounding box query as shown below:
 * 
 * @param x1
 * @param y1
 * @param x2
 * @param y2
 * @return
 * @throws Exception
 */
// grabFeaturesInBoundingBox start
SimpleFeatureCollection grabFeaturesInBoundingBox(double x1, double y1, double x2, double y2)
        throws Exception {
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
    FeatureType schema = featureSource.getSchema();
    
    // usually "THE_GEOM" for shapefiles
    String geometryPropertyName = schema.getGeometryDescriptor().getLocalName();
    CoordinateReferenceSystem targetCRS = schema.getGeometryDescriptor()
            .getCoordinateReferenceSystem();
    
    ReferencedEnvelope bbox = new ReferencedEnvelope(x1, y1, x2, y2, targetCRS);
    
    Filter filter = ff.bbox(ff.property(geometryPropertyName), bbox);
    return featureSource.getFeatures(filter);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:29,代码来源:FilterExamples.java

示例4: click1

import org.opengis.filter.FilterFactory2; //导入方法依赖的package包/类
SimpleFeatureCollection click1(MapMouseEvent ev) throws Exception {
    // Construct a 3x3 pixel rectangle centred on the mouse click position
    java.awt.Point screenPos = ev.getPoint();
    
    Rectangle screenRect = new Rectangle(screenPos.x - 1, screenPos.y - 1, 3, 3);
    CoordinateReferenceSystem worldCRS = mapFrame.getMapContent().getCoordinateReferenceSystem();
    // Transform the screen rectangle into a bounding box in the 
    // coordinate reference system of our map content.
    AffineTransform screenToWorld = mapFrame.getMapPane().getScreenToWorldTransform();
    Rectangle2D worldRect = screenToWorld.createTransformedShape(screenRect).getBounds2D();
    ReferencedEnvelope worldBBox = new ReferencedEnvelope(worldRect, worldCRS);
    
    // transform from world to target CRS
    SimpleFeatureType schema = featureSource.getSchema();
    CoordinateReferenceSystem targetCRS = schema.getCoordinateReferenceSystem();
    String geometryAttributeName = schema.getGeometryDescriptor().getLocalName();
    
    ReferencedEnvelope bbox = worldBBox.transform(targetCRS, true, 10);
    
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();

    // Option 1 BBOX
    Filter filter = ff.bbox(ff.property(geometryAttributeName), bbox);
    
    // Option 2 Intersects
    // Filter filter = ff.intersects(ff.property(geometryAttributeName), ff.literal(bbox));
    
    return featureSource.getFeatures(filter);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:30,代码来源:FilterExamples.java

示例5: createBaseFilter

import org.opengis.filter.FilterFactory2; //导入方法依赖的package包/类
/**
 * Creates a base filter that will return a small subset of our results. This can be tweaked to
 * return different results if desired. Currently it should return 16 results.
 *
 * @return
 *
 * @throws org.geotools.filter.text.cql2.CQLException
 * @throws java.io.IOException
 */
static Filter createBaseFilter()
        throws CQLException, IOException {

    // Get a FilterFactory2 to build up our query
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();

    // We are going to query for events in Ukraine during the
    // civil unrest.

    // We'll start by looking at a particular time frame
    Filter timeFilter =
            ff.between(ff.property(Attributes.SQLDATE.getName()),
                       ff.literal("2013-01-01T05:00:00.000Z"),
                       ff.literal("2014-04-30T23:00:00.000Z"));

    // We'll bound our query spatially to Ukraine
    Filter spatialFilter =
            ff.bbox(Attributes.geom.getName(),
                    31.6, 44, 37.4, 47.75,
                    "EPSG:4326");

    // we'll also restrict our query to only articles about the US, UK or UN
    Filter attributeFilter = ff.like(ff.property(Attributes.Actor1Name.getName()), "UNITED%");

    // Now we can combine our filters using a boolean AND operator
    Filter conjunction = ff.and(Arrays.asList(timeFilter, spatialFilter, attributeFilter));

    return conjunction;
}
 
开发者ID:geomesa,项目名称:geomesa-tutorials,代码行数:39,代码来源:GeoServerAuthorizationsTutorial.java

示例6: queryGdelt

import org.opengis.filter.FilterFactory2; //导入方法依赖的package包/类
public static void queryGdelt(String[] args) throws Exception {
    CommandLineParser parser = new BasicParser();
    Options options = GDELTIngest.getCommonRequiredOptions();

    CommandLine cmd = parser.parse( options, args);
    Map<String, String> dsConf = GDELTIngest.getAccumuloDataStoreConf(cmd);

    String featureName = cmd.getOptionValue(GDELTIngest.FEATURE_NAME);

    // First, we get a handle to the data store and feature source
    DataStore ds = DataStoreFinder.getDataStore(dsConf);
    SimpleFeatureSource fs = ds.getFeatureSource(featureName);

    // Next, we form a query.  We need a FilterFactory2 to build
    // up our query
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();

    // We want to query for events in Ukraine during the
    // civil unrest.  We'll start by looking at January and February
    // of 2014
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    Date start = df.parse("2014-01-01");
    Date end = df.parse("2014-02-28");
    Filter timeFilter = ff.between(ff.property("SQLDATE"), ff.literal(start), ff.literal(end));

    // We need to bound our query spatially to Ukraine
    Filter spatialFilter = ff.bbox("geom", 22.1371589, 44.386463, 40.228581, 52.379581, "EPSG:4326");

    // Now we can combine our time filter and our spatial filter using a boolean and operator
    Filter conjunction = ff.and(timeFilter, spatialFilter);

    // Let's constrain the results to just the date/time, location, and Actor names
    Query query = new Query("gdelt", conjunction, new String[]{ "SQLDATE", "geom", "Actor1Name", "Actor2Name" });

    // Finally, we submit our query to GeoMesa
    SimpleFeatureCollection results = fs.getFeatures(query);

    System.out.println("Number of results = " + results.size());

    // We can add an attribute filter
    Filter actor1Protest = ff.like(ff.property("Actor1Name"), "PROTEST%");
    Filter spatialTemporalAttribute = ff.and(conjunction, actor1Protest);
    Query query2 = new Query("gdelt", spatialTemporalAttribute, new String[]{ "SQLDATE", "geom", "Actor1Name", "Actor2Name" });
    SimpleFeatureCollection results2 = fs.getFeatures(query2);

    System.out.println("Number of results = " + results2.size());

    Filter eventRootCodeThreaten =  ff.equal(ff.property("EventRootCode"), ff.literal(13), false);
    Filter spatialTemporalAttribute2 = ff.and(conjunction, eventRootCodeThreaten);
    Query query3 = new Query("gdelt", spatialTemporalAttribute2, new String[]{ "SQLDATE", "geom", "Actor1Name", "Actor2Name", "EventRootCode", "EventBaseCode" });
    SimpleFeatureCollection results3 = fs.getFeatures(query3);

    System.out.println("Number of results = " + results3.size());
}
 
开发者ID:geomesa,项目名称:geomesa-tutorials,代码行数:55,代码来源:GDELTQuery.java

示例7: createBaseFilter

import org.opengis.filter.FilterFactory2; //导入方法依赖的package包/类
/**
     * Creates a base filter that will return a small subset of our results. This can be tweaked to
     * return different results if desired. Currently it should return 16 results.
     *
     * @return
     *
     * @throws CQLException
     * @throws IOException
     */
    static Filter createBaseFilter()
            throws CQLException, IOException {

        // Get a FilterFactory2 to build up our query
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();

        // We are going to query for events in Ukraine during the
        // civil unrest.

        // We'll start by looking at a particular day in February of 2014
        Calendar calendar = Calendar.getInstance();
        calendar.clear();
        calendar.set(Calendar.YEAR, 2013);
        calendar.set(Calendar.MONTH, Calendar.JANUARY);
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        Date start = calendar.getTime();

        calendar.set(Calendar.YEAR, 2014);
        calendar.set(Calendar.MONTH, Calendar.APRIL);
        calendar.set(Calendar.DAY_OF_MONTH, 30);
        calendar.set(Calendar.HOUR_OF_DAY, 23);
        Date end = calendar.getTime();
//        2013-01-01T00:00:00.000Z/2014-04-30T23:00:00.000Z
        Filter timeFilter =
                ff.between(ff.property(GdeltFeature.Attributes.SQLDATE.getName()),
                           ff.literal(start),
                           ff.literal(end));

        // We'll bound our query spatially to Ukraine
        Filter spatialFilter =
                ff.bbox(GdeltFeature.Attributes.geom.getName(),
                        31.6, 44, 37.4, 47.75,
                        "EPSG:4326");

        // we'll also restrict our query to only articles about the US, UK or UN
        Filter attributeFilter = ff.like(ff.property(GdeltFeature.Attributes.Actor1Name.getName()),
                                         "UNITED%");

        // Now we can combine our filters using a boolean AND operator
        Filter conjunction = ff.and(Arrays.asList(timeFilter, spatialFilter, attributeFilter));

        return conjunction;
    }
 
开发者ID:geomesa,项目名称:geomesa-tutorials,代码行数:54,代码来源:AuthorizationsTutorial.java

示例8: createBaseFilter

import org.opengis.filter.FilterFactory2; //导入方法依赖的package包/类
/**
 * Creates a base filter that will return a small subset of our results. This can be tweaked to
 * return different results if desired. Currently it should return 16 results.
 *
 * @return
 *
 * @throws CQLException
 * @throws IOException
 */
static Filter createBaseFilter()
        throws CQLException, IOException {

    // Get a FilterFactory2 to build up our query
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();

    // We are going to query for events in Ukraine during the
    // civil unrest.

    // We'll start by looking at a particular day in February of 2014
    Calendar calendar = Calendar.getInstance();
    calendar.clear();
    calendar.set(Calendar.YEAR, 2014);
    calendar.set(Calendar.MONTH, Calendar.FEBRUARY);
    calendar.set(Calendar.DAY_OF_MONTH, 2);
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    Date start = calendar.getTime();

    calendar.set(Calendar.HOUR_OF_DAY, 23);
    Date end = calendar.getTime();

    Filter timeFilter =
            ff.between(ff.property(GdeltFeature.Attributes.SQLDATE.getName()),
                       ff.literal(start),
                       ff.literal(end));

    // We'll bound our query spatially to Ukraine
    Filter spatialFilter =
            ff.bbox(GdeltFeature.Attributes.geom.getName(),
                    22.1371589,
                    44.386463,
                    40.228581,
                    52.379581,
                    "EPSG:4326");

    // we'll also restrict our query to only articles about the US, UK or UN
    Filter attributeFilter = ff.like(ff.property(GdeltFeature.Attributes.Actor1Name.getName()),
                                     "UNITED%");

    // Now we can combine our filters using a boolean AND operator
    Filter conjunction = ff.and(Arrays.asList(timeFilter, spatialFilter, attributeFilter));

    return conjunction;
}
 
开发者ID:geomesa,项目名称:geomesa-tutorials,代码行数:54,代码来源:QueryTutorial.java


注:本文中的org.opengis.filter.FilterFactory2.bbox方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。