void SbetWriter::write(const PointViewPtr view) { Dimension::IdList dims = fileDimensions(); for (PointId idx = 0; idx < view->size(); ++idx) { for (auto di = dims.begin(); di != dims.end(); ++di) { // If a dimension doesn't exist, write 0. Dimension::Id dim = *di; *m_stream << (view->hasDim(dim) ? view->getFieldAs<double>(dim, idx) : 0.0); } } }
void GeoWaveWriter::write(const PointViewPtr view) { using namespace Dimension; std::ostringstream os; BasicAccumuloOperations accumuloOperations; try { accumuloOperations = java_new<BasicAccumuloOperations>( java_new<String>(m_zookeeperUrl), java_new<String>(m_instanceName), java_new<String>(m_username), java_new<String>(m_password), java_new<String>(m_tableNamespace)); } catch (AccumuloException& e) { log()->get(LogLevel::Error) << "There was a problem establishing a connector. " << e; return; } catch (AccumuloSecurityException& e) { log()->get(LogLevel::Error) << "The credentials passed are invalid. " << e; return; } AccumuloDataStore accumuloDataStore = java_new<AccumuloDataStore>( accumuloOperations); Index index = IndexType_JaceIndexType::createSpatialVectorIndex(); AccumuloIndexWriter accumuloIndexWriter = java_new<AccumuloIndexWriter>( index, accumuloOperations, accumuloDataStore); // treat all types as double os << "location:Point:srid=4326"; for (auto di = m_dims.begin(); di != m_dims.end(); ++di) os << "," << view->dimName(*di) << ":Double"; SimpleFeatureType TYPE = DataUtilities::createType( java_new<String>(m_featureTypeName), java_new<String>(os.str())); String location = java_new<String>("location"); WritableDataAdapter dataAdapter; if (m_useFeatCollDataAdapter) dataAdapter = java_new<FeatureCollectionDataAdapter>( TYPE, m_pointsPerEntry); else dataAdapter = java_new<FeatureDataAdapter>(TYPE); GeometryFactory geometryFactory = JTSFactoryFinder::getGeometryFactory(); SimpleFeatureBuilder builder = java_new<SimpleFeatureBuilder>(TYPE); DefaultFeatureCollection featureCollection = java_new<DefaultFeatureCollection>( UUID::randomUUID().toString(), TYPE); for (PointId idx = 0; idx < view->size(); ++idx) { JDouble X = view->getFieldAs<double>(Id::X, idx); JDouble Y = view->getFieldAs<double>(Id::Y, idx); Point point = geometryFactory.createPoint( java_new<Coordinate>( X, Y)); builder.set(location, point); for (auto di = m_dims.begin(); di != m_dims.end(); ++di) if (view->hasDim(*di)) builder.set(java_new<String>(view->dimName(*di)), java_new<Double>(view->getFieldAs<double>(*di, idx))); SimpleFeature feature = builder.buildFeature(UUID::randomUUID().toString()); if (m_useFeatCollDataAdapter) featureCollection.add(feature); else accumuloIndexWriter.write( dataAdapter, feature); } if (m_useFeatCollDataAdapter) accumuloIndexWriter.write( dataAdapter, featureCollection); accumuloIndexWriter.close(); }