Java源码示例:org.opengis.filter.Id

示例1
@Test
@DirtiesContext // @todo need to check why this is necessary, otherwise next test fails? (GetVectorTileCommandTest)
// probably cause by directly using the command service which has an injected security context
public void createFilterTest() throws Exception {
	SearchFeatureRequest request = new SearchFeatureRequest();
	request.setLayerId(LAYER_ID);
	request.setCrs("EPSG:4326");
	SearchCriterion searchCriterion = new SearchCriterion();
	Filter filter;

	// needs to be FidFilter when equals test on id
	searchCriterion.setAttributeName(ID_ATTRIBUTE);
	searchCriterion.setOperator("=");
	searchCriterion.setValue("'1'");
	request.setCriteria(new SearchCriterion[] {searchCriterion});
	filter = searchFeatureCommand.createFilter(request, LAYER_ID);
	Assert.assertTrue(filter instanceof Id);

	// but *not* when other test
	searchCriterion.setAttributeName(ID_ATTRIBUTE);
	searchCriterion.setOperator("like");
	searchCriterion.setValue("'%a%'");
	request.setCriteria(new SearchCriterion[] {searchCriterion});
	filter = searchFeatureCommand.createFilter(request, LAYER_ID);
	Assert.assertFalse(filter instanceof Id);
}
 
示例2
public ElasticCapabilities() {
    super(new ElasticFilterCapabilities());

    addAll(LOGICAL_OPENGIS);
    addAll(SIMPLE_COMPARISONS_OPENGIS);
    addType(PropertyIsNull.class);
    addType(PropertyIsBetween.class);
    addType(Id.class);
    addType(IncludeFilter.class);
    addType(ExcludeFilter.class);
    addType(PropertyIsLike.class);

    // spatial filters
    addType(BBOX.class);
    addType(Contains.class);
    //addType(Crosses.class);
    addType(Disjoint.class);
    //addType(Equals.class);
    addType(Intersects.class);
    //addType(Overlaps.class);
    //addType(Touches.class);
    addType(Within.class);
    addType(DWithin.class);
    addType(Beyond.class);

    //temporal filters
    addType(After.class);
    addType(Before.class);
    addType(Begins.class);
    addType(BegunBy.class);
    addType(During.class);
    addType(Ends.class);
    addType(EndedBy.class);
    addType(TContains.class);
    addType(TEquals.class);
}
 
示例3
/**
 * Encodes an Id filter
 *
 * @param filter the
 *
 */
public Object visit(Id filter, Object extraData) {
    final List<String> idList = new ArrayList<>();
    for (final Identifier id : filter.getIdentifiers()) {
        idList.add(id.toString());
    }

    queryBuilder = ImmutableMap.of("ids", ImmutableMap.of("values", idList));

    return extraData;
}
 
示例4
@Test
public void testId() {
    final Id filter = ff.id(ff.featureId("id"));
    Map<String,Object> expected = ImmutableMap.of("ids", ImmutableMap.of("values", ImmutableList.of("id")));

    builder.visit(filter, null);
    assertTrue(builder.createCapabilities().fullySupports(filter));
    assertEquals(expected, builder.getQueryBuilder());
}
 
示例5
@Test
public void testGetFeaturesWithIdFilter() throws Exception {
    init();
    FilterFactory ff = dataStore.getFilterFactory();
    Id id = ff.id(new HashSet<>(Arrays.asList(ff.featureId("01"),
            ff.featureId("07"))));
    SimpleFeatureCollection features = featureSource.getFeatures(id);
    assertEquals(2, features.size());
}
 
示例6
@Test
public void tesFid() {
  final FilterFactoryImpl factory = new FilterFactoryImpl();
  final Id f = factory.id(new FeatureIdImpl("123-abc"));
  final String ss = ECQL.toCQL(f);
  System.out.println(ss);
  assertTrue(ss.contains("'123-abc'"));
}
 
示例7
/** {@inheritDoc} */
@Override
public Object visit(Id filter, Object userData) {
	String idName;
	try {
		idName = featureModel.getEntityMetadata().getIdentifierPropertyName();
	} catch (LayerException e) {
		log.warn("Cannot read idName, defaulting to 'id'", e);
		idName = HIBERNATE_ID;
	}
	Collection<?> c = (Collection<?>) castLiteral(filter.getIdentifiers(), idName);
	return Restrictions.in(idName, c);
}
 
示例8
@Test
public void testParseFidFilter() throws GeomajasException {
	Filter f1 = filterService.parseFilter("IN( 1 )");
	Filter f2 = filterService.parseFilter("[email protected] = 1");
	Assert.assertTrue(f1 instanceof Id);
	Assert.assertTrue(f2 instanceof PropertyIsEqualTo);
	PropertyIsEqualTo piet = (PropertyIsEqualTo)f2;
	Assert.assertTrue(piet.getExpression1() instanceof PropertyName);
	Assert.assertEquals("a/@id",((PropertyName)piet.getExpression1()).getPropertyName());
	
}
 
示例9
/**
 * Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigBase#populateField(java.lang.String)}.
 */
@Test
public void testPopulateFieldString() {
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    String expectedLabel = "test label";
    TestFieldConfigBase field =
            new TestFieldConfigBase(
                    new FieldConfigCommonData(
                            String.class, expectedFieldId, expectedLabel, false, false));

    field.populateField("");
    field.setTestValue(expectedFieldId, "");

    field.populateField(42);
    field.setTestValue(expectedFieldId, 42);
    assertEquals(0, field.getIntValue());

    field.populateField(3.142);
    field.setTestValue(expectedFieldId, 3.142);
    assertTrue(Math.abs(field.getDoubleValue()) < 0.0001);

    field.populateField(ZonedDateTime.now());
    field.populateField((ReferencedEnvelope) null);
    field.setTestValue(expectedFieldId, (ReferencedEnvelope) null);
    field.populateField((Id) null);
    field.populateField((TimePeriod) null);
    field.populateField((ProcessFunction) null);
    assertNull(field.getProcessFunction());

    field.populateField(true);
    field.setTestValue(expectedFieldId, true);
    assertEquals(false, field.getBooleanValue());

    field.populateField((ColorMap) null);
    field.setTestValue(expectedFieldId, (ColorMap) null);
    assertNull(field.getColourMap());

    field.populateField((List<FeatureTypeConstraint>) null);
    field.setTestValue(expectedFieldId, (List<FeatureTypeConstraint>) null);
    assertNull(field.getFeatureTypeConstraint());

    field.populateField((Font) null);
    assertNull(field.getFont());

    field.setTestValue(expectedFieldId, (Expression) null);

    assertNull(field.getEnumValue());
}
 
示例10
@Override
public Object visit(final Id filter, final Object data) {
  return new ExtractGeometryFilterVisitorResult(infinity(), null);
}
 
示例11
@Override
public Object visit(final Id filter, final Object data) {
  return new TemporalConstraints();
}
 
示例12
/**
 * Populate field.
 *
 * @param value the value
 */
public void populateField(Id value);
 
示例13
/**
 * Populate string field, overridden if necessary.
 *
 * @param value the value
 */
@Override
public void populateField(Id value) {
    // Do nothing
}