org.geotools.filter.text.cql2.CQLException Java Examples
The following examples show how to use
org.geotools.filter.text.cql2.CQLException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 7 votes |
@Test public void testGeoShapeIntersectsFilter() throws CQLException { Intersects filter = (Intersects) ECQL.toFilter("INTERSECTS(\"geom\", LINESTRING(0 0,1.1 1.1))"); List<List<Double>> coords = new ArrayList<>(); coords.add(ImmutableList.of(0.,0.)); coords.add(ImmutableList.of(1.1,1.1)); Map<String,Object> expected = ImmutableMap.of("bool", ImmutableMap.of("must", MATCH_ALL, "filter", ImmutableMap.of("geo_shape", ImmutableMap.of("geom", ImmutableMap.of("shape", ImmutableMap.of("coordinates", coords, "type", "LineString"), "relation", "INTERSECTS"))))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); // TODO: Why doesn't equality check on objects work here assertEquals(expected.toString(), builder.getQueryBuilder().toString()); }
Example #2
Source File: ExtractGeometryFilterVisitorTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testIntesectAndBBox() throws CQLException, TransformException, ParseException { // BBOX geometry is completely contained within Intersects geometry // we are testing to see if we are able to combine simple geometric // relations with similar predicates // into a single query geometry/predicate final Filter filter = CQL.toFilter( String.format( "INTERSECTS(%s, POLYGON((0 0, 0 50, 20 50, 20 0, 0 0))) AND BBOX(%s, 0, 0, 10, 25)", geomAttributeName, geomAttributeName)); final Query query = new Query("type", filter); final ExtractGeometryFilterVisitorResult result = (ExtractGeometryFilterVisitorResult) query.getFilter().accept(visitorWithDescriptor, null); final Envelope bounds = new Envelope(0, 10, 0, 25); final Geometry bbox = new GeometryFactory().toGeometry(bounds); assertTrue(bbox.equalsTopo(result.getGeometry())); assertTrue(result.getCompareOp() == CompareOperation.INTERSECTS); }
Example #3
Source File: SpatialTemporalQueryIT.java From geowave with Apache License 2.0 | 6 votes |
private void testQueryMultipleBinsGivenDateRange( final VectorQueryBuilder bldr, final String name, final int minExpectedResult, final int maxExpectedResult, final Date startOfQuery, final Date endOfQuery) throws CQLException, IOException { final Set<String> fidExpectedResults = new HashSet<>((maxExpectedResult - minExpectedResult) + 1); for (int i = minExpectedResult; i <= maxExpectedResult; i++) { fidExpectedResults.add(name + ":" + i); } testQueryGivenDateRange( bldr, name, fidExpectedResults, startOfQuery, endOfQuery, timeStampAdapter.getTypeName(), "timestamp", "timestamp"); }
Example #4
Source File: GeoWaveGTQueryTest.java From rya with Apache License 2.0 | 6 votes |
@Test public void executeCQLQueryTest() throws IOException, CQLException { System.out.println("Executing query, expecting to match two points..."); final Filter cqlFilter = ECQL.toFilter("BBOX(geometry,-77.6167,38.6833,-76.6,38.9200) and locationName like 'W%'"); final QueryOptions queryOptions = new QueryOptions(ADAPTER, INDEX); final CQLQuery cqlQuery = new CQLQuery(null, cqlFilter, ADAPTER); try (final CloseableIterator<SimpleFeature> iterator = dataStore.query(queryOptions, cqlQuery)) { int count = 0; while (iterator.hasNext()) { System.out.println("Query match: " + iterator.next().getID()); count++; } System.out.println("executeCQLQueryTest count: " + count); // Should match "Washington Monument" and "White House" assertEquals(2, count); } }
Example #5
Source File: GeoWaveFeatureReaderTest.java From rya with Apache License 2.0 | 6 votes |
@Test public void testLike() throws IllegalArgumentException, NoSuchElementException, IOException, CQLException { final Query query = new Query( "GeoWaveFeatureReaderTest", ECQL.toFilter("pid like '" + pids.get( 0).substring( 0, 1) + "%'"), new String[] { "geometry", "pid" }); final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT); int count = 0; while (reader.hasNext()) { final SimpleFeature feature = reader.next(); assertTrue(fids.contains(feature.getID())); count++; } assertEquals(1, count); }
Example #6
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testGeoShapeIntersectsFilterReversed() throws CQLException { Intersects filter = (Intersects) ECQL.toFilter("INTERSECTS(LINESTRING(0 0,1.1 1.1), \"geom\")"); List<List<Double>> coords = new ArrayList<>(); coords.add(ImmutableList.of(0.,0.)); coords.add(ImmutableList.of(1.1,1.1)); Map<String,Object> expected = ImmutableMap.of("bool", ImmutableMap.of("must", MATCH_ALL, "filter", ImmutableMap.of("geo_shape", ImmutableMap.of("geom", ImmutableMap.of("shape", ImmutableMap.of("coordinates", coords, "type", "LineString"), "relation", "INTERSECTS"))))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected.toString(), builder.getQueryBuilder().toString()); }
Example #7
Source File: WFSTemporalQueryTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testTemporal() throws CQLException, IOException, ParseException { populate(); final Transaction transaction2 = new DefaultTransaction(); final Query query = new Query( "geostuff", CQL.toFilter( "BBOX(geometry,44,27,42,30) and start during 2005-05-16T20:32:56Z/2005-05-20T21:32:56Z and end during 2005-05-18T20:32:56Z/2005-05-22T21:32:56Z"), new String[] {"geometry", "start", "end", "pid"}); final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query, transaction2); int c = 0; while (reader.hasNext()) { reader.next(); c++; } reader.close(); transaction2.commit(); transaction2.close(); assertEquals(2, c); }
Example #8
Source File: GeoWaveFeatureReaderTest.java From rya with Apache License 2.0 | 6 votes |
@Test public void testPidFilterQuery() throws IllegalArgumentException, NoSuchElementException, IOException, CQLException { // Filter it so that it only queries for everything but the first pid. // There's only 2 pids total so it should just return the second one. final String pidsString = pids.subList(1, pids.size()).stream().collect(Collectors.joining("','", "'", "'")); final Filter filter = ECQL.toFilter("pid IN (" + pidsString + ")"); final Query query = new Query( "GeoWaveFeatureReaderTest", filter, new String[] { "geometry", "pid" }); final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT); int count = 0; while (reader.hasNext()) { final SimpleFeature feature = reader.next(); assertTrue(fids.contains(feature.getID())); count++; } assertTrue(count == pids.size() - 1); }
Example #9
Source File: GeoWaveFeatureReaderTest.java From rya with Apache License 2.0 | 6 votes |
@Test public void testFidFilterQuery() throws IllegalArgumentException, NoSuchElementException, IOException, CQLException { final String fidsString = fids.stream().collect(Collectors.joining("','", "'", "'")); final Filter filter = ECQL.toFilter("IN (" + fidsString + ")"); final Query query = new Query( "GeoWaveFeatureReaderTest", filter, new String[] { "geometry", "pid" }); final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT); int count = 0; while (reader.hasNext()) { final SimpleFeature feature = reader.next(); assertTrue(fids.contains(feature.getID())); count++; } assertTrue(count == fids.size()); }
Example #10
Source File: OmsVectorReshaper.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
private List<Expression> createExpressionList( String expressionString ) { List<Expression> list = new ArrayList<Expression>(); String definition = expressionString.replaceAll("\r", "\n").replaceAll("[\n\r][\n\r]", "\n"); for( String line : definition.split("\n") ) { int mark = line.indexOf("="); if (mark != -1) { String expressionDefinition = line.substring(mark + 1).trim(); Expression expression; try { expression = CQL.toExpression(expressionDefinition); } catch (CQLException e) { throw new ModelsRuntimeException(e.toString(), this); } list.add(expression); } } return list; }
Example #11
Source File: GeoToolsAttributesSubsetTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testSubsetAttributes() throws CQLException, IOException { final Query query = new Query( typeName, CQL.toFilter(cqlPredicate), new String[] {geometry_attribute, string_attribute}); final FeatureReader<SimpleFeatureType, SimpleFeature> reader = geotoolsDataStore.getFeatureReader(query, Transaction.AUTO_COMMIT); int count = 0; while (reader.hasNext()) { final SimpleFeature feature = reader.next(); count++; Assert.assertTrue(feature.getAttribute(geometry_attribute) != null); Assert.assertTrue(feature.getAttribute(long_attribute) == null); Assert.assertTrue(feature.getAttribute(string_attribute) != null); } Assert.assertTrue(count == 3); }
Example #12
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testGeoPolygonFilter() throws CQLException { Intersects filter = (Intersects) ECQL.toFilter("INTERSECTS(\"geo_point\", POLYGON((0 0, 0 1.1, 1.1 1.1, 1.1 0, 0 0)))"); List<List<Double>> points = ImmutableList.of( ImmutableList.of(0.,0.), ImmutableList.of(0.,1.1), ImmutableList.of(1.1,1.1), ImmutableList.of(1.1,0.), ImmutableList.of(0.,0.)); Map<String,Object> expected = ImmutableMap.of("bool", ImmutableMap.of("must", MATCH_ALL, "filter", ImmutableMap.of("geo_polygon", ImmutableMap.of("geo_point", ImmutableMap.of("points", points))))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #13
Source File: FilterUtilities.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
/** * Create a bounding box filter from the bounds coordinates. * * @param attribute the geometry attribute or null in the case of default "the_geom". * @param west western bound coordinate. * @param east eastern bound coordinate. * @param south southern bound coordinate. * @param north northern bound coordinate. * @return the filter. * @throws CQLException */ public static Filter getBboxFilter( String attribute, double west, double east, double south, double north ) throws CQLException { if (attribute == null) { attribute = "the_geom"; } StringBuilder sB = new StringBuilder(); sB.append("BBOX("); sB.append(attribute); sB.append(","); sB.append(west); sB.append(","); sB.append(south); sB.append(","); sB.append(east); sB.append(","); sB.append(north); sB.append(")"); Filter bboxFilter = CQL.toFilter(sB.toString()); return bboxFilter; }
Example #14
Source File: GeoWaveFeatureSourceTest.java From geowave with Apache License 2.0 | 6 votes |
public void testPartial(final Populater populater, final String ext) throws CQLException, Exception { final String typeName = "GeoWaveFeatureSourceTest_p" + ext; final SimpleFeatureType type = DataUtilities.createType( typeName, "geometry:Geometry:srid=4326,pop:java.lang.Long,pid:String,when:Date"); final DataStore dataStore = createDataStore(); populater.populate(type, dataStore); final SimpleFeatureSource source = dataStore.getFeatureSource(typeName); final Query query = new Query( typeName, CQL.toFilter( "BBOX(geometry,42,28,44,30) and when during 2005-05-01T20:32:56Z/2005-05-29T21:32:56Z"), new String[] {"geometry", "when", "pid"}); final ReferencedEnvelope env = source.getBounds(query); assertEquals(43.454, env.getMaxX(), 0.0001); assertEquals(28.232, env.getMinY(), 0.0001); assertEquals(28.242, env.getMaxY(), 0.0001); assertEquals(2, source.getCount(query)); }
Example #15
Source File: GeoWaveFeatureReaderTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testLike() throws IllegalArgumentException, NoSuchElementException, IOException, CQLException { System.out.println(pids); final Query query = new Query( "GeoWaveFeatureReaderTest", ECQL.toFilter("pid like '" + pids.get(0).substring(0, 1) + "%'"), new String[] {"geometry", "pid"}); final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT); int count = 0; while (reader.hasNext()) { final SimpleFeature feature = reader.next(); assertTrue(fids.contains(feature.getID())); count++; } assertEquals(1, count); }
Example #16
Source File: ExtractTimeFilterVisitorTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testDuringOrAfter() throws CQLException, ParseException { final ExtractTimeFilterVisitor visitor = new ExtractTimeFilterVisitor(); final Date stime = new Date(DateUtilities.parseISO("2005-05-19T20:32:56Z").getTime() + 1); final Filter filter = CQL.toFilter("when DURING OR AFTER 2005-05-19T20:32:56Z/2005-05-19T21:32:56Z"); final Query query = new Query("type", filter); TemporalConstraintsSet rangeSet = (TemporalConstraintsSet) query.getFilter().accept(visitor, null); assertNotNull(rangeSet); assertEquals(stime, rangeSet.getConstraintsFor("when").getStartRange().getStartTime()); assertEquals( TemporalRange.END_TIME, rangeSet.getConstraintsFor("when").getEndRange().getEndTime()); rangeSet = (TemporalConstraintsSet) query.getFilter().accept(visitorWithDescriptor, null); assertNotNull(rangeSet); assertEquals(stime, rangeSet.getConstraintsFor("when").getStartRange().getStartTime()); assertEquals( TemporalRange.END_TIME, rangeSet.getConstraintsFor("when").getEndRange().getEndTime()); }
Example #17
Source File: ExtractTimeFilterVisitorTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testBeforeOrDuring() throws CQLException, ParseException { final ExtractTimeFilterVisitor visitor = new ExtractTimeFilterVisitor(); final Date stime = new Date(DateUtilities.parseISO("2005-05-19T21:32:56Z").getTime() - 1); final Filter filter = CQL.toFilter("when BEFORE OR DURING 2005-05-19T20:32:56Z/2005-05-19T21:32:56Z"); final Query query = new Query("type", filter); TemporalConstraintsSet rangeSet = (TemporalConstraintsSet) query.getFilter().accept(visitor, null); assertNotNull(rangeSet); assertEquals( TemporalRange.START_TIME, rangeSet.getConstraintsFor("when").getStartRange().getStartTime()); assertEquals(stime, rangeSet.getConstraintsFor("when").getEndRange().getEndTime()); rangeSet = (TemporalConstraintsSet) query.getFilter().accept(visitorWithDescriptor, null); assertNotNull(rangeSet); assertEquals( TemporalRange.START_TIME, rangeSet.getConstraintsFor("when").getStartRange().getStartTime()); assertEquals(stime, rangeSet.getConstraintsFor("when").getEndRange().getEndTime()); }
Example #18
Source File: CQLFilterOptionProvider.java From geowave with Apache License 2.0 | 6 votes |
@Override public FilterParameter convert(String value) { Filter convertedFilter = null; if (value != null) { try { convertedFilter = asFilter(value); } // HP Fortify "Log Forging" false positive // What Fortify considers "user input" comes only // from users with OS-level access anyway catch (final CQLException e) { LOGGER.error("Cannot parse CQL expression '" + value + "'", e); // value = null; // convertedFilter = null; throw new ParameterException("Cannot parse CQL expression '" + value + "'", e); } } else { value = null; } return new FilterParameter(value, convertedFilter); }
Example #19
Source File: CQLQueryTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testGeoAndTemporalWithMatchingIndex() throws CQLException { final ExplicitCQLQuery query = (ExplicitCQLQuery) OptimalCQLQuery.createOptimalQuery( "BBOX(geometry,27.20,41.30,27.30,41.20) and when during 2005-05-19T20:32:56Z/2005-05-19T21:32:56Z", adapter, null, null); final List<MultiDimensionalNumericData> constraints = query.getIndexConstraints(SPATIAL_TEMPORAL_INDEX); assertTrue( Arrays.equals( constraints.get(0).getMinValuesPerDimension(), new double[] {27.2, 41.2, 1.116534776001E12})); assertTrue( Arrays.equals( constraints.get(0).getMaxValuesPerDimension(), new double[] {27.3, 41.3, 1.116538375999E12})); }
Example #20
Source File: JsonDefinitionColumnVisibilityManagementTest.java From geowave with Apache License 2.0 | 6 votes |
@Before public void setup() throws SchemaException, CQLException { type = DataUtilities.createType( "geostuff", "geometry:Geometry:srid=4326,vis:java.lang.String,pop:java.lang.Long,pid:String"); descriptors = type.getAttributeDescriptors(); defaults = new Object[descriptors.size()]; int p = 0; for (final AttributeDescriptor descriptor : descriptors) { defaults[p++] = descriptor.getDefaultValue(); } newFeature = SimpleFeatureBuilder.build(type, defaults, UUID.randomUUID().toString()); newFeature.setAttribute("pop", Long.valueOf(100)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("vis", "{\"pid\":\"TS\", \"geo.*\":\"S\"}"); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(43.454, 128.232))); }
Example #21
Source File: ExtractGeometryFilterVisitorTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testDWithin() throws CQLException, TransformException, ParseException { final Filter filter = CQL.toFilter( String.format( "DWITHIN(%s, POINT(-122.7668 0.4979), 233.7, meters)", geomAttributeName)); final Query query = new Query("type", filter); final ExtractGeometryFilterVisitorResult result = (ExtractGeometryFilterVisitorResult) query.getFilter().accept(visitorWithDescriptor, null); final Geometry geometry = result.getGeometry(); assertNotNull(geometry); for (final Coordinate coord : geometry.getCoordinates()) { assertEquals( 233.7, JTS.orthodromicDistance( coord, new Coordinate(-122.7668, 0.4979), GeometryUtils.getDefaultCRS()), 2); } }
Example #22
Source File: ExtractGeometryFilterVisitorTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testDWithinDateLine() throws CQLException, TransformException, ParseException { final Filter filter = CQL.toFilter( String.format( "DWITHIN(%s, POINT(179.9998 0.79), 13.7, kilometers)", geomAttributeName)); final Query query = new Query("type", filter); final ExtractGeometryFilterVisitorResult result = (ExtractGeometryFilterVisitorResult) query.getFilter().accept(visitorWithDescriptor, null); final Geometry geometry = result.getGeometry(); assertNotNull(geometry); for (final Coordinate coord : geometry.getCoordinates()) { assertEquals( 13707.1, JTS.orthodromicDistance( coord, new Coordinate(179.9999, 0.79), GeometryUtils.getDefaultCRS()), 2000); } }
Example #23
Source File: ExtractGeometryFilterVisitorTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testOverlaps() throws CQLException, TransformException, ParseException { final Filter filter = CQL.toFilter( String.format( "OVERLAPS(%s, POLYGON((0 0, 0 25, 10 25, 10 0, 0 0)))", geomAttributeName)); final Query query = new Query("type", filter); final ExtractGeometryFilterVisitorResult result = (ExtractGeometryFilterVisitorResult) query.getFilter().accept(visitorWithDescriptor, null); final Envelope bounds = new Envelope(0, 10, 0, 25); final Geometry bbox = new GeometryFactory().toGeometry(bounds); assertTrue(bbox.equalsTopo(result.getGeometry())); assertTrue(result.getCompareOp() == CompareOperation.OVERLAPS); }
Example #24
Source File: ExtractGeometryFilterVisitorTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testEquals() throws CQLException, TransformException, ParseException { final Filter filter = CQL.toFilter( String.format( "EQUALS(geom, POLYGON((0 0, 0 25, 10 25, 10 0, 0 0)))", geomAttributeName)); final Query query = new Query("type", filter); final ExtractGeometryFilterVisitorResult result = (ExtractGeometryFilterVisitorResult) query.getFilter().accept(visitorWithDescriptor, null); final Envelope bounds = new Envelope(0, 10, 0, 25); final Geometry bbox = new GeometryFactory().toGeometry(bounds); assertTrue(bbox.equalsTopo(result.getGeometry())); assertTrue(result.getCompareOp() == CompareOperation.EQUALS); }
Example #25
Source File: ExtractGeometryFilterVisitorTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testIntesectAndCrossesAndLike() throws CQLException, TransformException, ParseException { // we are testing to see if we are able to combine dissimilar geometric // relations correctly // to extract query geometry. Note, that returned predicate is null // since we can't represent // CQL expression fully into single query geometry and predicate final Filter filter = CQL.toFilter( String.format( "CROSSES(%s, POLYGON((0 0, 0 25, 10 25, 10 0, 0 0))) AND location == 'abc'", geomAttributeName)); final Query query = new Query("type", filter); final ExtractGeometryFilterVisitorResult result = (ExtractGeometryFilterVisitorResult) query.getFilter().accept(visitorWithDescriptor, null); final Envelope bounds = new Envelope(0, 10, 0, 25); final Geometry bbox = new GeometryFactory().toGeometry(bounds); assertTrue(bbox.equalsTopo(result.getGeometry())); assertTrue(result.getCompareOp() == null); }
Example #26
Source File: ExtractGeometryFilterVisitorTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testTouches() throws CQLException, TransformException, ParseException { final Filter filter = CQL.toFilter( String.format( "TOUCHES(%s, POLYGON((0 0, 0 25, 10 25, 10 0, 0 0)))", geomAttributeName)); final Query query = new Query("type", filter); final ExtractGeometryFilterVisitorResult result = (ExtractGeometryFilterVisitorResult) query.getFilter().accept(visitorWithDescriptor, null); final Envelope bounds = new Envelope(0, 10, 0, 25); final Geometry bbox = new GeometryFactory().toGeometry(bounds); assertTrue(bbox.equalsTopo(result.getGeometry())); assertTrue(result.getCompareOp() == CompareOperation.TOUCHES); }
Example #27
Source File: ExtractGeometryFilterVisitorTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testDisjoint() throws CQLException, TransformException, ParseException { final Filter filter = CQL.toFilter( String.format( "DISJOINT(%s, POLYGON((0 0, 0 25, 10 25, 10 0, 0 0)))", geomAttributeName)); final Query query = new Query("type", filter); final ExtractGeometryFilterVisitorResult result = (ExtractGeometryFilterVisitorResult) query.getFilter().accept(visitorWithDescriptor, null); // for non-inclusive filters we can't extract query geometry and // predicate // assertTrue(Double.isNaN(result.getGeometry().getArea())); assertTrue(result.getCompareOp() == null); }
Example #28
Source File: WFSSpatialTest.java From geowave with Apache License 2.0 | 6 votes |
@Before public void setup() throws SchemaException, CQLException, IOException, GeoWavePluginException { dataStore = createDataStore(); type = DataUtilities.createType( "geostuff", "geometry:Geometry:srid=4326,pop:java.lang.Long,when:Date,pid:String"); dataStore.createSchema(type); query = new Query( "geostuff", CQL.toFilter( "BBOX(geometry,27.20,41.30,27.30,41.20) and when during 2005-05-19T20:32:56Z/2005-05-19T21:32:56Z"), new String[] {"geometry", "pid"}); }
Example #29
Source File: ExtractTimeFilterVisitorTest.java From geowave with Apache License 2.0 | 5 votes |
@Test public void testAfter() throws CQLException, ParseException { final ExtractTimeFilterVisitor visitor = new ExtractTimeFilterVisitor(); final Date time = DateUtilities.parseISO("2005-05-19T20:32:56Z"); final Filter filter = CQL.toFilter("when after 2005-05-19T20:32:56Z"); final Query query = new Query("type", filter); TemporalConstraints range = (TemporalConstraints) query.getFilter().accept(visitor, null); assertNotNull(range); assertEquals(new Date(time.getTime() + 1), range.getStartRange().getStartTime()); range = (TemporalConstraints) query.getFilter().accept(visitorWithDescriptor, null); assertNotNull(range); assertEquals(new Date(time.getTime() + 1), range.getStartRange().getStartTime()); assertEquals("when", range.getName()); }
Example #30
Source File: WFSTemporalQueryTest.java From geowave with Apache License 2.0 | 5 votes |
public void populate() throws IOException, CQLException, ParseException { final Transaction transaction1 = new DefaultTransaction(); final FeatureWriter<SimpleFeatureType, SimpleFeature> writer = dataStore.getFeatureWriter(type.getTypeName(), transaction1); assertFalse(writer.hasNext()); SimpleFeature newFeature = writer.next(); newFeature.setAttribute("pop", Long.valueOf(100)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("start", DateUtilities.parseISO("2005-05-17T20:32:56Z")); newFeature.setAttribute("end", DateUtilities.parseISO("2005-05-19T20:32:56Z")); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(43.454, 28.232))); writer.write(); newFeature = writer.next(); newFeature.setAttribute("pop", Long.valueOf(100)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("start", DateUtilities.parseISO("2005-05-18T20:32:56Z")); newFeature.setAttribute("end", DateUtilities.parseISO("2005-05-20T20:32:56Z")); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(43.454, 27.232))); writer.write(); newFeature = writer.next(); newFeature.setAttribute("pop", Long.valueOf(100)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("start", DateUtilities.parseISO("2005-05-21T20:32:56Z")); newFeature.setAttribute("end", DateUtilities.parseISO("2005-05-22T20:32:56Z")); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(43.454, 28.232))); writer.write(); writer.close(); transaction1.commit(); transaction1.close(); }