Java Code Examples for org.geotools.feature.simple.SimpleFeatureTypeBuilder#init()
The following examples show how to use
org.geotools.feature.simple.SimpleFeatureTypeBuilder#init() .
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: FeatureDataUtils.java From geowave with Apache License 2.0 | 6 votes |
public static FeatureDataAdapter cloneFeatureDataAdapter( final DataStorePluginOptions storeOptions, final String originalTypeName, final String newTypeName) { // Get original feature type info final SimpleFeatureType oldType = FeatureDataUtils.getFeatureType(storeOptions, originalTypeName); // Build type using new name final SimpleFeatureTypeBuilder sftBuilder = new SimpleFeatureTypeBuilder(); sftBuilder.init(oldType); sftBuilder.setName(newTypeName); final SimpleFeatureType newType = sftBuilder.buildFeatureType(); // Create new adapter that will use new typename final FeatureDataAdapter newAdapter = new FeatureDataAdapter(newType); return newAdapter; }
Example 2
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 3
Source File: FeatureDataAdapter.java From geowave with Apache License 2.0 | 5 votes |
/** * Sets the namespace of the reprojected feature type associated with this data adapter * * @param namespaceURI - new namespace URI */ @Override public void setNamespace(final String namespaceURI) { final SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.init(reprojectedFeatureType); builder.setNamespaceURI(namespaceURI); reprojectedFeatureType = builder.buildFeatureType(); }
Example 4
Source File: FeatureDataUtils.java From geowave with Apache License 2.0 | 5 votes |
public static SimpleFeatureType decodeType( final String nameSpace, final String typeName, final String typeDescriptor, final String axis) throws SchemaException { SimpleFeatureType featureType = (nameSpace != null) && (nameSpace.length() > 0) ? DataUtilities.createType(nameSpace, typeName, typeDescriptor) : DataUtilities.createType(typeName, typeDescriptor); final String lCaseAxis = axis.toLowerCase(Locale.ENGLISH); final CoordinateReferenceSystem crs = featureType.getCoordinateReferenceSystem(); final String typeAxis = getAxis(crs); // Default for EPSG:4326 is lat/long, If the provided type was // long/lat, then re-establish the order if ((crs != null) && crs.getIdentifiers().toString().contains("EPSG:4326") && !lCaseAxis.equalsIgnoreCase(typeAxis)) { final SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.init(featureType); try { // truely no way to force lat first // but it is the default in later versions of GeoTools. // this all depends on the authority at the time of creation featureType = SimpleFeatureTypeBuilder.retype( featureType, CRS.decode("EPSG:4326", lCaseAxis.equals("east"))); } catch (final FactoryException e) { throw new SchemaException("Cannot decode EPSG:4326", e); } } return featureType; }
Example 5
Source File: BandFeatureIterator.java From geowave with Apache License 2.0 | 5 votes |
/** * Default SimpleFeatureTypeBuilder which provides the Bands schema of a Sentinel2 provider. */ public static SimpleFeatureTypeBuilder defaultBandFeatureTypeBuilder(final String typeName) throws NoSuchAuthorityCodeException, FactoryException { final SimpleFeatureTypeBuilder sceneBuilder = SceneFeatureIterator.defaultSceneFeatureTypeBuilder(typeName); final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); typeBuilder.init(sceneBuilder.buildFeatureType()); typeBuilder.setName(typeName); typeBuilder.setDefaultGeometry(SceneFeatureIterator.SHAPE_ATTRIBUTE_NAME); typeBuilder.minOccurs(1).maxOccurs(1).nillable(false).add(BAND_ATTRIBUTE_NAME, String.class); return typeBuilder; }
Example 6
Source File: BandFeatureIterator.java From geowave with Apache License 2.0 | 5 votes |
public static SimpleFeatureType createFeatureType(final SimpleFeatureType sceneType) { // initialize the feature type final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); typeBuilder.init(sceneType); typeBuilder.setName(BANDS_TYPE_NAME); typeBuilder.add(BAND_ATTRIBUTE_NAME, String.class); typeBuilder.add(SIZE_ATTRIBUTE_NAME, Float.class); typeBuilder.add(BAND_DOWNLOAD_ATTRIBUTE_NAME, String.class); final SimpleFeatureType bandType = typeBuilder.buildFeatureType(); return bandType; }
Example 7
Source File: InLineFeatureModel.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** Adds the new column. */ public void addNewColumn() { if (featureCollection != null) { String attributeName = getUniqueAttributeName(); columnList.add(attributeName); // Populate field names SimpleFeatureTypeBuilder featureTypeBuilder = new SimpleFeatureTypeBuilder(); featureTypeBuilder.init(featureCollection.getSchema()); featureTypeBuilder.add(attributeName, String.class); SimpleFeatureType newFeatureType = featureTypeBuilder.buildFeatureType(); String typeName = userLayer.getInlineFeatureType().getTypeName(); try { SimpleFeatureSource featureSource = userLayer.getInlineFeatureDatastore().getFeatureSource(typeName); SimpleFeatureBuilder sfb = new SimpleFeatureBuilder(newFeatureType); ArrayList<SimpleFeature> featureList = new ArrayList<>(); SimpleFeatureIterator it = featureSource.getFeatures().features(); try { while (it.hasNext()) { SimpleFeature sf = it.next(); sfb.addAll(sf.getAttributes()); sfb.add(new String("")); featureList.add(sfb.buildFeature(null)); } } finally { it.close(); } SimpleFeatureCollection collection = new ListFeatureCollection(newFeatureType, featureList); featureCollection = collection; cachedFeature = null; lastRow = -1; DataStore dataStore = DataUtilities.dataStore(collection); userLayer.setInlineFeatureDatastore(dataStore); userLayer.setInlineFeatureType(newFeatureType); } catch (IOException e) { ConsoleManager.getInstance().exception(this, e); } this.fireTableStructureChanged(); this.fireTableDataChanged(); if (parentObj != null) { parentObj.inlineFeatureUpdated(); } } }
Example 8
Source File: InLineFeatureModel.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Removes the column. * * @param columnName the column name */ public void removeColumn(String columnName) { if (featureCollection != null) { if (columnList.contains(columnName)) { columnList.remove(columnName); // Find field name to remote SimpleFeatureTypeBuilder featureTypeBuilder = new SimpleFeatureTypeBuilder(); featureTypeBuilder.init(featureCollection.getSchema()); featureTypeBuilder.remove(columnName); SimpleFeatureType newFeatureType = featureTypeBuilder.buildFeatureType(); int attributeToRemoveIndex = 0; for (AttributeDescriptor descriptor : newFeatureType.getAttributeDescriptors()) { if (descriptor.getLocalName().compareTo(columnName) == 0) { break; } attributeToRemoveIndex++; } String typeName = userLayer.getInlineFeatureType().getTypeName(); try { SimpleFeatureSource featureSource = userLayer.getInlineFeatureDatastore().getFeatureSource(typeName); SimpleFeatureBuilder sfb = new SimpleFeatureBuilder(newFeatureType); ArrayList<SimpleFeature> featureList = new ArrayList<>(); SimpleFeatureIterator it = featureSource.getFeatures().features(); try { while (it.hasNext()) { SimpleFeature sf = it.next(); List<Object> attributes = sf.getAttributes(); attributes.remove(attributeToRemoveIndex); sfb.addAll(attributes); featureList.add(sfb.buildFeature(null)); } } finally { it.close(); } SimpleFeatureCollection collection = new ListFeatureCollection(newFeatureType, featureList); featureCollection = collection; cachedFeature = null; lastRow = -1; DataStore dataStore = DataUtilities.dataStore(collection); userLayer.setInlineFeatureDatastore(dataStore); userLayer.setInlineFeatureType(newFeatureType); } catch (IOException e) { ConsoleManager.getInstance().exception(this, e); } this.fireTableStructureChanged(); this.fireTableDataChanged(); if (parentObj != null) { parentObj.inlineFeatureUpdated(); } } } }
Example 9
Source File: SLDUtils.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
public static SimpleFeatureType createStyledFeatureType(SimpleFeatureType type) { SimpleFeatureTypeBuilder sftb = new SimpleFeatureTypeBuilder(); sftb.init(type); sftb.add(PlainFeatureFactory.ATTRIB_NAME_STYLE_CSS, String.class); return sftb.buildFeatureType(); }