Java Code Examples for org.geotools.feature.AttributeTypeBuilder#buildDescriptor()
The following examples show how to use
org.geotools.feature.AttributeTypeBuilder#buildDescriptor() .
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 | 5 votes |
private void addDateWithFormatToFeatureType(String format) { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); typeBuilder.init(featureType); AttributeDescriptor dateAtt; AttributeTypeBuilder dateAttBuilder = new AttributeTypeBuilder(); dateAttBuilder.setName("dateAttrWithFormat"); dateAttBuilder.setBinding(Date.class); dateAtt = dateAttBuilder.buildDescriptor("dateAttrWithFormat", dateAttBuilder.buildType()); dateAtt.getUserData().put(DATE_FORMAT, format); typeBuilder.add(dateAtt); featureType = typeBuilder.buildFeatureType(); setFilterBuilder(); }
Example 2
Source File: FeatureExtender.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * @param oldFeatureType the {@link FeatureType} of the existing features. * @param fieldArray the list of the names of new fields. * @param classesArray the list of classes of the new fields. * @throws FactoryRegistryException * @throws SchemaException */ public FeatureExtender( SimpleFeatureType oldFeatureType, String[] fieldArray, Class<?>[] classesArray ) throws FactoryRegistryException, SchemaException { List<AttributeDescriptor> oldAttributeDescriptors = oldFeatureType .getAttributeDescriptors(); List<AttributeDescriptor> addedAttributeDescriptors = new ArrayList<AttributeDescriptor>(); for( int i = 0; i < fieldArray.length; i++ ) { AttributeTypeBuilder build = new AttributeTypeBuilder(); build.setNillable(true); build.setBinding(classesArray[i]); AttributeDescriptor descriptor = build.buildDescriptor(fieldArray[i]); addedAttributeDescriptors.add(descriptor); } List<AttributeDescriptor> newAttributesTypesList = new ArrayList<AttributeDescriptor>(); for( AttributeDescriptor attributeDescriptor : oldAttributeDescriptors ) { newAttributesTypesList.add(attributeDescriptor); } newAttributesTypesList.addAll(addedAttributeDescriptors); // create the feature type SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); b.setName(oldFeatureType.getName()); b.setCRS(oldFeatureType.getCoordinateReferenceSystem()); b.addAll(newAttributesTypesList); newFeatureType = b.buildFeatureType(); }
Example 3
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 4 votes |
@Before public void setUp() { ff = CommonFactoryFinder.getFilterFactory2(); SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); typeBuilder.setName("test"); typeBuilder.add("stringAttr", String.class); typeBuilder.add("integerAttr", Integer.class); typeBuilder.add("longAttr", Long.class); typeBuilder.add("booleanAttr", Boolean.class); typeBuilder.add("doubleAttr", Double.class); typeBuilder.add("floatAttr", Float.class); typeBuilder.add("dateAttr", Date.class); AttributeDescriptor geoPointAtt; AttributeTypeBuilder geoPointAttBuilder = new AttributeTypeBuilder(); geoPointAttBuilder.setName("geo_point"); geoPointAttBuilder.setBinding(Point.class); geoPointAtt = geoPointAttBuilder.buildDescriptor("geo_point", geoPointAttBuilder.buildType()); geoPointAtt.getUserData().put(GEOMETRY_TYPE, ElasticGeometryType.GEO_POINT); typeBuilder.add(geoPointAtt); AttributeDescriptor geoShapeAtt; AttributeTypeBuilder geoShapeAttBuilder = new AttributeTypeBuilder(); geoShapeAttBuilder.setName("geom"); geoShapeAttBuilder.setBinding(Geometry.class); geoShapeAtt = geoShapeAttBuilder.buildDescriptor("geom", geoShapeAttBuilder.buildType()); geoShapeAtt.getUserData().put(GEOMETRY_TYPE, ElasticGeometryType.GEO_SHAPE); typeBuilder.add(geoShapeAtt); AttributeDescriptor analyzedAtt; AttributeTypeBuilder analyzedAttBuilder = new AttributeTypeBuilder(); analyzedAttBuilder.setName("analyzed"); analyzedAttBuilder.setBinding(String.class); analyzedAtt = analyzedAttBuilder.buildDescriptor("analyzed", analyzedAttBuilder.buildType()); analyzedAtt.getUserData().put(ANALYZED, true); typeBuilder.add(analyzedAtt); AttributeDescriptor netsedAtt; AttributeTypeBuilder nestedAttBuilder = new AttributeTypeBuilder(); nestedAttBuilder.setName("nested.hej"); nestedAttBuilder.setBinding(String.class); netsedAtt = nestedAttBuilder.buildDescriptor("nested.hej", nestedAttBuilder.buildType()); netsedAtt.getUserData().put(NESTED, true); netsedAtt.getUserData().put(ANALYZED, true); typeBuilder.add(netsedAtt); AttributeDescriptor netsedDateAtt; AttributeTypeBuilder nestedDateAttBuilder = new AttributeTypeBuilder(); nestedDateAttBuilder.setName("nested.datehej"); nestedDateAttBuilder.setBinding(Date.class); netsedDateAtt = nestedDateAttBuilder.buildDescriptor("nested.datehej", nestedDateAttBuilder.buildType()); netsedDateAtt.getUserData().put(NESTED, true); typeBuilder.add(netsedDateAtt); featureType = typeBuilder.buildFeatureType(); setFilterBuilder(); parameters = new HashMap<>(); final Hints hints = new Hints(); hints.put(Hints.VIRTUAL_TABLE_PARAMETERS, parameters); query = new Query(); query.setHints(hints); dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); gf = new GeometryFactory(); }