public SimpleFeatureType getFeatureType() { return state.getFeatureType(); } // getFeatureType end
public MemoryFeatureReader(ContentState state, Query query) throws IOException { featureType = state.getFeatureType(); MemoryEntry entry = (MemoryEntry) state.getEntry(); final List<SimpleFeature> internalCollection = new ArrayList<>(entry.getMemory().values()); iterator = internalCollection.iterator(); }
/** * Helper method for returning the underlying schema of the feature source. This is a non-view * this is the same as calling getSchema(), but in the view case the underlying "true" schema is * returned. */ protected final SimpleFeatureType getAbsoluteSchema() { // load the type from the state shared among feature sources ContentState state = entry.getState(transaction); SimpleFeatureType featureType = state.getFeatureType(); if (featureType == null) { // build and cache it synchronized (state) { if (featureType == null) { try { featureType = buildFeatureType(); } catch (IOException e) { throw new RuntimeException(e); } state.setFeatureType(featureType); } } } return featureType; }
final void initMapper() { // use schema with mapping info if it exists SimpleFeatureType type = entry.getState(null).getFeatureType(); setMapper(type != null ? new MongoSchemaMapper(type) : new MongoInferredMapper()); }
/** * Creates a new instance of {@link JDBCFeatureStore}. * * @see ContentDataStore#createFeatureSource(ContentEntry) */ protected ContentFeatureSource createFeatureSource(ContentEntry entry) throws IOException { // grab the schema, it carries a flag telling us if the feature type is read only SimpleFeatureType schema = entry.getState(Transaction.AUTO_COMMIT).getFeatureType(); if (schema == null) { // if the schema still haven't been computed, force its computation so // that we can decide if the feature type is read only schema = new JDBCFeatureSource(entry, null).buildFeatureType(); entry.getState(Transaction.AUTO_COMMIT).setFeatureType(schema); } Object readOnlyMarker = schema.getUserData().get(JDBC_READ_ONLY); if (Boolean.TRUE.equals(readOnlyMarker)) { return new JDBCFeatureSource(entry, null); } return new JDBCFeatureStore(entry, null); }
contentState.getFeatureType().getCoordinateReferenceSystem());
@Override protected ContentFeatureSource createFeatureSource(ContentEntry entry) throws IOException { ContentState state = entry.getState(null); SimpleFeatureType type = state.getFeatureType(); if (type == null) { type = schemaStore.retrieveSchema(entry.getName()); if (type != null) { state.setFeatureType(type); } } String collectionName = type != null ? collectionNameFromType(type) : entry.getTypeName(); return new MongoFeatureStore(entry, null, dataStoreDB.getCollection(collectionName)); }
@Override public SimpleFeatureType getFeatureType() { return state.getFeatureType(); }
@Override public SimpleFeatureType getFeatureType() { return state.getFeatureType(); }
public SimpleFeatureType getFeatureType() { return (SimpleFeatureType) state.getFeatureType(); }
/** * Helper method for returning the underlying schema of the feature source. * This is a non-view this is the same as calling getSchema(), but in the * view case the underlying "true" schema is returned. */ protected final SimpleFeatureType getAbsoluteSchema() { //load the type from the state shared among feature sources ContentState state = entry.getState(transaction); SimpleFeatureType featureType = state.getFeatureType(); if (featureType == null) { //build and cache it synchronized (state) { if (featureType == null) { try { featureType = buildFeatureType(); } catch (IOException e) { throw new RuntimeException(e); } state.setFeatureType( featureType); } } } return featureType; }
public ElasticFeatureReader(ContentState contentState, List<ElasticHit> hits, Map<String,ElasticAggregation> aggregations, float maxScore) { this.state = contentState; this.featureType = state.getFeatureType(); this.searchHitIterator = hits.iterator(); this.builder = new SimpleFeatureBuilder(featureType); this.parserUtil = new ElasticParserUtil(); this.maxScore = maxScore; this.aggregationIterator = Collections.emptyIterator(); if (aggregations != null && !aggregations.isEmpty()) { String aggregationName = aggregations.keySet().stream().findFirst().orElse(null); if (aggregations.size() > 1) { LOGGER.info("Result has multiple aggregations. Using " + aggregationName); } if (aggregations.get(aggregationName).getBuckets() != null) { this.aggregationIterator = aggregations.get(aggregationName).getBuckets().iterator(); } } if (contentState.getEntry() != null && contentState.getEntry().getDataStore() != null) { final ElasticDataStore dataStore; dataStore = (ElasticDataStore) contentState.getEntry().getDataStore(); this.arrayEncoding = dataStore.getArrayEncoding(); } else { this.arrayEncoding = ArrayEncoding.valueOf((String) ElasticDataStoreFactory.ARRAY_ENCODING.getDefaultValue()); } this.mapper = new ObjectMapper(); }
public CSVFeatureReader(ContentState contentState) throws IOException { this.state = contentState; CSVDataStore csv = (CSVDataStore) contentState.getEntry().getDataStore(); reader = csv.read(); // this may throw an IOException if it could not connect boolean header = reader.readHeaders(); if (! header ){ throw new IOException("Unable to read csv header"); } builder = new SimpleFeatureBuilder( state.getFeatureType() ); geometryFactory = JTSFactoryFinder.getGeometryFactory(null); row = 0; }
@Override public SimpleFeature next() throws IOException { if (dataBuilder == null) { throw new IOException("FeatureWriter has been closed"); } if (this.currentFeature != null) { this.write(); } try { if (!appending) { if (delegate.hasNext()) { this.currentFeature = delegate.next(); return this.currentFeature; } else { this.appending = true; } } SimpleFeatureType featureType = state.getFeatureType(); String fid = featureType.getTypeName() + "." + nextRow; Object values[] = DataUtilities.defaultValues(featureType); this.currentFeature = SimpleFeatureBuilder.build(featureType, values, fid); return this.currentFeature; } catch (IllegalArgumentException invalid) { throw new IOException("Unable to create feature:" + invalid.getMessage(), invalid); } }
/** * Creates a new instance of {@link JDBCFeatureStore}. * * @see ContentDataStore#createFeatureSource(ContentEntry) */ protected ContentFeatureSource createFeatureSource(ContentEntry entry) throws IOException { // grab the schema, it carries a flag telling us if the feature type is read only SimpleFeatureType schema = entry.getState(Transaction.AUTO_COMMIT).getFeatureType(); if (schema == null) { // if the schema still haven't been computed, force its computation so // that we can decide if the feature type is read only schema = new JDBCFeatureSource(entry, null).buildFeatureType(); entry.getState(Transaction.AUTO_COMMIT).setFeatureType(schema); } Object readOnlyMarker = schema.getUserData().get(JDBC_READ_ONLY); if (Boolean.TRUE.equals(readOnlyMarker)) { return new JDBCFeatureSource(entry, null); } return new JDBCFeatureStore(entry, null); }
public GeobufFeatureReader(ContentState state, Query query, int precision, int dimension) throws IOException { this.state = state; this.geobufGeometry = new GeobufGeometry(precision, dimension, JTSFactoryFinder.getGeometryFactory(null)); this.geobufFeature = new GeobufFeature(geobufGeometry); this.featureBuilder = new SimpleFeatureBuilder(state.getFeatureType()); File file; DataStore dataStore = state.getEntry().getDataStore(); if (dataStore instanceof GeobufDirectoryDataStore) { file = ((GeobufDirectoryDataStore) dataStore) .getDataStore(state.getFeatureType().getTypeName()) .getFile(); } else { file = ((GeobufDataStore) dataStore).getFile(); } this.in = new FileInputStream(file); this.data = Geobuf.Data.parseFrom(in); }
public MemoryFeatureWriterWithProvidedFIDSupport(ContentState state, Query query) throws IOException { this.state = state; featureType = state.getFeatureType(); String typeName = featureType.getTypeName(); MemoryDataStoreWithProvidedFIDSupport store = (MemoryDataStoreWithProvidedFIDSupport) state .getEntry().getDataStore(); contents = store.entry(typeName).getMemory(); iterator = contents.values().iterator(); }
public MemoryFeatureWriterWithProvidedFIDSupport(ContentState state, Query query) throws IOException { this.state = state; featureType = state.getFeatureType(); String typeName = featureType.getTypeName(); MemoryDataStoreWithProvidedFIDSupport store = (MemoryDataStoreWithProvidedFIDSupport) state .getEntry().getDataStore(); contents = store.entry(typeName).getMemory(); iterator = contents.values().iterator(); }
contentState.getFeatureType().getCoordinateReferenceSystem());
public GeobufFeatureWriter(ContentState state, Query query, int precision, int dimension) throws IOException { this.state = state; String typeName = query.getTypeName(); DataStore dataStore = state.getEntry().getDataStore(); if (dataStore instanceof GeobufDirectoryDataStore) { this.file = ((GeobufDirectoryDataStore) dataStore).getDataStore(typeName).getFile(); } else { this.file = ((GeobufDataStore) dataStore).getFile(); } File directory = file.getParentFile(); this.temp = File.createTempFile(typeName + System.currentTimeMillis(), "geobuf", directory); this.dataBuilder = Geobuf.Data.newBuilder(); GeobufFeatureType geobufFeatureType = new GeobufFeatureType(); geobufFeatureType.encode(state.getFeatureType(), dataBuilder); dataBuilder.build().writeTo(new FileOutputStream(this.temp)); this.featureCollectionBuilder = Geobuf.Data.FeatureCollection.newBuilder(); this.geobufFeature = new GeobufFeature(new GeobufGeometry(precision, dimension)); this.delegate = new GeobufFeatureReader(state, query, precision, dimension); }