org.geotools.temporal.object.DefaultInstant Java Examples
The following examples show how to use
org.geotools.temporal.object.DefaultInstant.
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: TestFilterPanelv2.java From sldeditor with GNU General Public License v3.0 | 6 votes |
@Test public void testBinaryTemporal() { TestFilterPanelv2Dialog testPanel = new TestFilterPanelv2Dialog(null); testPanel.configure("test", String.class, false); DateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); Date date1 = null; try { date1 = FORMAT.parse("2001-07-05T12:08:56.235-0700"); } catch (ParseException e) { e.printStackTrace(); } Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1)); // Simple check if property is after provided temporal instant Filter filter = ff.after(ff.property("date"), ff.literal(temporalInstant)); String expected = filter.toString(); testPanel.filterDialog(String.class, filter); String actual = testPanel.getFilterString(); assertEquals(expected, actual); }
Example #2
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testTContains() throws ParseException { Date date1 = dateFormat.parse("1970-07-19T01:02:03.456Z"); Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1)); Date date2 = dateFormat.parse("1970-07-19T07:08:09.101Z"); Instant temporalInstant2 = new DefaultInstant(new DefaultPosition(date2)); Period period = new DefaultPeriod(temporalInstant, temporalInstant2); TContains filter = ff.tcontains(ff.literal(period), ff.property("dateAttr")); Map<String,Object> expected = ImmutableMap.of("range", ImmutableMap.of("dateAttr", ImmutableMap.of("gt", "1970-07-19T01:02:03.456Z", "lt", "1970-07-19T07:08:09.101Z"))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #3
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testEndedBy() throws ParseException { Date date1 = dateFormat.parse("1970-07-19T01:02:03.456Z"); Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1)); Date date2 = dateFormat.parse("1970-07-19T07:08:09.101Z"); Instant temporalInstant2 = new DefaultInstant(new DefaultPosition(date2)); Period period = new DefaultPeriod(temporalInstant, temporalInstant2); EndedBy filter = ff.endedBy(ff.literal(period), ff.property("dateAttr")); Map<String,Object> expected = ImmutableMap.of("term", ImmutableMap.of("dateAttr", "1970-07-19T07:08:09.101Z")); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #4
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testEnds() throws ParseException { Date date1 = dateFormat.parse("1970-07-19T01:02:03.456Z"); Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1)); Date date2 = dateFormat.parse("1970-07-19T07:08:09.101Z"); Instant temporalInstant2 = new DefaultInstant(new DefaultPosition(date2)); Period period = new DefaultPeriod(temporalInstant, temporalInstant2); Ends filter = ff.ends(ff.property("dateAttr"), ff.literal(period)); Map<String,Object> expected = ImmutableMap.of("term", ImmutableMap.of("dateAttr", "1970-07-19T07:08:09.101Z")); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #5
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testDuring() throws ParseException { Date date1 = dateFormat.parse("1970-07-19T01:02:03.456Z"); Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1)); Date date2 = dateFormat.parse("1970-07-19T07:08:09.101Z"); Instant temporalInstant2 = new DefaultInstant(new DefaultPosition(date2)); Period period = new DefaultPeriod(temporalInstant, temporalInstant2); During filter = ff.during(ff.property("dateAttr"), ff.literal(period)); Map<String,Object> expected = ImmutableMap.of("range", ImmutableMap.of("dateAttr", ImmutableMap.of("gt", "1970-07-19T01:02:03.456Z", "lt", "1970-07-19T07:08:09.101Z"))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #6
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testBegunBy() throws ParseException { Date date1 = dateFormat.parse("1970-07-19T01:02:03.456Z"); Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1)); Date date2 = dateFormat.parse("1970-07-19T07:08:09.101Z"); Instant temporalInstant2 = new DefaultInstant(new DefaultPosition(date2)); Period period = new DefaultPeriod(temporalInstant, temporalInstant2); BegunBy filter = ff.begunBy(ff.literal(period), ff.property("dateAttr")); Map<String,Object> expected = ImmutableMap.of("term", ImmutableMap.of("dateAttr", "1970-07-19T01:02:03.456Z")); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #7
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testBeforeFilterPeriod() throws ParseException { Date date1 = dateFormat.parse("1970-07-19T01:02:03.456Z"); Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1)); Date date2 = dateFormat.parse("1970-07-19T07:08:09.101Z"); Instant temporalInstant2 = new DefaultInstant(new DefaultPosition(date2)); Period period = new DefaultPeriod(temporalInstant, temporalInstant2); org.opengis.filter.temporal.Before filter = ff.before(ff.property("dateAttr"), ff.literal(period)); Map<String,Object> expected = ImmutableMap.of("range", ImmutableMap.of("dateAttr", ImmutableMap.of("lt", "1970-07-19T01:02:03.456Z"))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #8
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testBeforeFilterPeriodSwapped() throws ParseException { Date date1 = dateFormat.parse("1970-07-19T01:02:03.456Z"); Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1)); Date date2 = dateFormat.parse("1970-07-19T07:08:09.101Z"); Instant temporalInstant2 = new DefaultInstant(new DefaultPosition(date2)); Period period = new DefaultPeriod(temporalInstant, temporalInstant2); org.opengis.filter.temporal.Before filter = ff.before(ff.literal(period), ff.property("dateAttr")); Map<String,Object> expected = ImmutableMap.of("range", ImmutableMap.of("dateAttr", ImmutableMap.of("gt", "1970-07-19T07:08:09.101Z"))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #9
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testBegins() throws ParseException { Date date1 = dateFormat.parse("1970-07-19T01:02:03.456Z"); Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1)); Date date2 = dateFormat.parse("1970-07-19T07:08:09.101Z"); Instant temporalInstant2 = new DefaultInstant(new DefaultPosition(date2)); Period period = new DefaultPeriod(temporalInstant, temporalInstant2); Begins filter = ff.begins(ff.property("dateAttr"), ff.literal(period)); Map<String,Object> expected = ImmutableMap.of("term", ImmutableMap.of("dateAttr", "1970-07-19T01:02:03.456Z")); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #10
Source File: TimeUtils.java From geowave with Apache License 2.0 | 5 votes |
/** * @param startTimeMillis start time (inclusive) * @param endTimeMillis end time (exclusive) * @param singleTimeField * @return the during filter */ public static Filter toDuringFilter( final long startTimeMillis, final long endTimeMillis, final String singleTimeField) { final FilterFactory2 factory = CommonFactoryFinder.getFilterFactory2(); final Position ip1 = new DefaultPosition(new Date(startTimeMillis - 1)); final Position ip2 = new DefaultPosition(new Date(endTimeMillis)); final Period period = new DefaultPeriod(new DefaultInstant(ip1), new DefaultInstant(ip2)); return factory.during(factory.property(singleTimeField), factory.literal(period)); }
Example #11
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test(expected=IllegalArgumentException.class) public void testTEqualsWithPeriod() throws ParseException { Date date1 = dateFormat.parse("1970-07-19T01:02:03.456Z"); Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1)); Date date2 = dateFormat.parse("1970-07-19T07:08:09.101Z"); Instant temporalInstant2 = new DefaultInstant(new DefaultPosition(date2)); Period period = new DefaultPeriod(temporalInstant, temporalInstant2); TEquals filter = ff.tequals(ff.property("dateAttr"), ff.literal(period)); builder.visit(filter, null); }
Example #12
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testTEqualsFilter() throws ParseException { Date date1 = dateFormat.parse("1970-07-19T01:02:03.456Z"); Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1)); TEquals filter = ff.tequals(ff.property("dateAttr"), ff.literal(temporalInstant)); Map<String,Object> expected = ImmutableMap.of("term", ImmutableMap.of("dateAttr", "1970-07-19T01:02:03.456Z")); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #13
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test(expected=IllegalArgumentException.class) public void testBeginsWithSwap() throws ParseException { Date date1 = dateFormat.parse("1970-07-19T01:02:03.456Z"); Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1)); Date date2 = dateFormat.parse("1970-07-19T07:08:09.101Z"); Instant temporalInstant2 = new DefaultInstant(new DefaultPosition(date2)); Period period = new DefaultPeriod(temporalInstant, temporalInstant2); Begins filter = ff.begins(ff.literal(period), ff.property("dateAttr")); builder.visit(filter, null); }
Example #14
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testBeforeFilter() throws ParseException { Date date1 = dateFormat.parse("1970-07-19T01:02:03.456Z"); Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1)); org.opengis.filter.temporal.Before filter = ff.before(ff.property("dateAttr"), ff.literal(temporalInstant)); Map<String,Object> expected = ImmutableMap.of("range", ImmutableMap.of("dateAttr", ImmutableMap.of("lt", "1970-07-19T01:02:03.456Z"))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #15
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testAfterFilterPeriodSwapped() throws ParseException { Date date1 = dateFormat.parse("1970-07-19T01:02:03.456Z"); Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1)); Date date2 = dateFormat.parse("1970-07-19T07:08:09.101Z"); Instant temporalInstant2 = new DefaultInstant(new DefaultPosition(date2)); Period period = new DefaultPeriod(temporalInstant, temporalInstant2); After filter = ff.after(ff.literal(period), ff.property("dateAttr")); Map<String,Object> expected = ImmutableMap.of("range", ImmutableMap.of("dateAttr", ImmutableMap.of("lt", "1970-07-19T01:02:03.456Z"))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #16
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testAfterFilterPeriod() throws ParseException { Date date1 = dateFormat.parse("1970-07-19T01:02:03.456Z"); Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1)); Date date2 = dateFormat.parse("1970-07-19T07:08:09.101Z"); Instant temporalInstant2 = new DefaultInstant(new DefaultPosition(date2)); Period period = new DefaultPeriod(temporalInstant, temporalInstant2); After filter = ff.after(ff.property("dateAttr"), ff.literal(period)); Map<String,Object> expected = ImmutableMap.of("range", ImmutableMap.of("dateAttr", ImmutableMap.of("gt", "1970-07-19T07:08:09.101Z"))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #17
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testAfterFilterSwapped() throws ParseException { dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); Date date1 = dateFormat.parse("1970-07-19T01:02:03.456-0100"); Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1)); After filter = ff.after(ff.literal(temporalInstant), ff.property("dateAttr")); Map<String,Object> expected = ImmutableMap.of("range", ImmutableMap.of("dateAttr", ImmutableMap.of("lt", "1970-07-19T02:02:03.456Z"))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #18
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testAfterFilter() throws ParseException { dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); Date date1 = dateFormat.parse("1970-07-19T01:02:03.456-0100"); Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1)); After filter = ff.after(ff.property("dateAttr"), ff.literal(temporalInstant)); Map<String,Object> expected = ImmutableMap.of("range", ImmutableMap.of("dateAttr", ImmutableMap.of("gt", "1970-07-19T02:02:03.456Z"))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #19
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testTemporalInstanceLiteralBasicDateTimeFormat() throws ParseException { addDateWithFormatToFeatureType("basic_date_time"); dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); Date date1 = dateFormat.parse("1970-07-19T01:02:03.456-0100"); Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1)); After filter = ff.after(ff.property("dateAttrWithFormat"), ff.literal(temporalInstant)); Map<String,Object> expected = ImmutableMap.of("range", ImmutableMap.of("dateAttrWithFormat", ImmutableMap.of("gt", "19700719T020203.456Z"))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #20
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testTemporalInstanceLiteralExplicitFormat() throws ParseException { addDateWithFormatToFeatureType("yyyy-MM-dd"); dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); Date date1 = dateFormat.parse("1970-07-19T01:02:03.456-0100"); Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1)); After filter = ff.after(ff.property("dateAttrWithFormat"), ff.literal(temporalInstant)); Map<String,Object> expected = ImmutableMap.of("range", ImmutableMap.of("dateAttrWithFormat", ImmutableMap.of("gt", "1970-07-19"))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #21
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testTemporalInstantLiteralDefaultFormat() throws ParseException { dateFormat = new SimpleDateFormat("yyyy-MM-dd"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); Date date1 = dateFormat.parse("1970-07-19"); Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1)); After filter = ff.after(ff.property("dateAttr"), ff.literal(temporalInstant)); Map<String,Object> expected = ImmutableMap.of("range", ImmutableMap.of("dateAttr", ImmutableMap.of("gt", "1970-07-19T00:00:00.000Z"))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #22
Source File: ElasticTestSupport.java From elasticgeo with GNU General Public License v3.0 | 4 votes |
private Instant instant(String d) throws ParseException { return new DefaultInstant(new DefaultPosition(date(d))); }