Search in sources :

Example 1 with CentroidManagerGeoWave

use of org.locationtech.geowave.analytic.clustering.CentroidManagerGeoWave in project geowave by locationtech.

the class DBScanIT method readHulls.

private int readHulls() throws Exception {
    final CentroidManager<SimpleFeature> centroidManager = new CentroidManagerGeoWave<>(dataStorePluginOptions.createDataStore(), dataStorePluginOptions.createIndexStore(), dataStorePluginOptions.createAdapterStore(), new SimpleFeatureItemWrapperFactory(), "concave_hull", dataStorePluginOptions.createInternalAdapterStore().addTypeName("concave_hull"), SpatialDimensionalityTypeProvider.createIndexFromOptions(new SpatialOptions()).getName(), "bx5", 0);
    int count = 0;
    for (final String grp : centroidManager.getAllCentroidGroups()) {
        for (final AnalyticItemWrapper<SimpleFeature> feature : centroidManager.getCentroidsForGroup(grp)) {
            ShapefileTool.writeShape(feature.getName(), new File("./target/test_final_" + feature.getName()), new Geometry[] { feature.getGeometry() });
            count++;
        }
    }
    return count;
}
Also used : SimpleFeatureItemWrapperFactory(org.locationtech.geowave.analytic.SimpleFeatureItemWrapperFactory) CentroidManagerGeoWave(org.locationtech.geowave.analytic.clustering.CentroidManagerGeoWave) SpatialOptions(org.locationtech.geowave.core.geotime.index.SpatialOptions) File(java.io.File) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Point(org.locationtech.jts.geom.Point)

Example 2 with CentroidManagerGeoWave

use of org.locationtech.geowave.analytic.clustering.CentroidManagerGeoWave in project geowave by locationtech.

the class IterationCountCalculateRunner method getIterations.

private int getIterations(final PropertyManagement propertyManagement) throws IOException {
    final CentroidManager<T> centroidManager = new CentroidManagerGeoWave<>(propertyManagement);
    final AtomicInteger resultHolder = new AtomicInteger(0);
    // Must iterate through the worst case.
    centroidManager.processForAllGroups(new CentroidProcessingFn<T>() {

        @Override
        public int processGroup(final String groupID, final List<AnalyticItemWrapper<T>> centroids) {
            resultHolder.set(Math.max(resultHolder.get(), (centroids.size() > 0) ? (int) Math.round(Math.log(maxCost(centroids))) : 0));
            return 0;
        }
    });
    return Math.max(iterationsCount, resultHolder.get());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CentroidManagerGeoWave(org.locationtech.geowave.analytic.clustering.CentroidManagerGeoWave) AnalyticItemWrapper(org.locationtech.geowave.analytic.AnalyticItemWrapper)

Example 3 with CentroidManagerGeoWave

use of org.locationtech.geowave.analytic.clustering.CentroidManagerGeoWave in project geowave by locationtech.

the class GeoWaveKMeansIT method countResults.

private int countResults(final DataStore dataStore, final IndexStore indexStore, final PersistentAdapterStore adapterStore, final InternalAdapterStore internalAdapterStore, final String batchID, final int level, final int expectedParentCount) throws AccumuloException, AccumuloSecurityException, IOException {
    final CentroidManager<SimpleFeature> centroidManager = new CentroidManagerGeoWave<>(dataStore, indexStore, adapterStore, new SimpleFeatureItemWrapperFactory(), "centroid", internalAdapterStore.addTypeName("centroid"), TestUtils.DEFAULT_SPATIAL_INDEX.getName(), batchID, level);
    final CentroidManager<SimpleFeature> hullManager = new CentroidManagerGeoWave<>(dataStore, indexStore, adapterStore, new SimpleFeatureItemWrapperFactory(), "convex_hull", internalAdapterStore.addTypeName("convex_hull"), TestUtils.DEFAULT_SPATIAL_INDEX.getName(), batchID, level);
    int childCount = 0;
    int parentCount = 0;
    for (final String grp : centroidManager.getAllCentroidGroups()) {
        final List<AnalyticItemWrapper<SimpleFeature>> centroids = centroidManager.getCentroidsForGroup(grp);
        final List<AnalyticItemWrapper<SimpleFeature>> hulls = hullManager.getCentroidsForGroup(grp);
        for (final AnalyticItemWrapper<SimpleFeature> centroid : centroids) {
            if (centroid.getAssociationCount() == 0) {
                continue;
            }
            Assert.assertTrue(centroid.getGeometry() != null);
            Assert.assertTrue(centroid.getBatchID() != null);
            boolean found = false;
            final List<SimpleFeature> features = new ArrayList<>();
            for (final AnalyticItemWrapper<SimpleFeature> hull : hulls) {
                found |= (hull.getName().equals(centroid.getName()));
                Assert.assertTrue(hull.getGeometry() != null);
                Assert.assertTrue(hull.getBatchID() != null);
                features.add(hull.getWrappedItem());
            }
            System.out.println(features);
            Assert.assertTrue(grp, found);
            childCount++;
        }
        parentCount++;
    }
    Assert.assertEquals(batchID, expectedParentCount, parentCount);
    return childCount;
}
Also used : SimpleFeatureItemWrapperFactory(org.locationtech.geowave.analytic.SimpleFeatureItemWrapperFactory) ArrayList(java.util.ArrayList) CentroidManagerGeoWave(org.locationtech.geowave.analytic.clustering.CentroidManagerGeoWave) AnalyticItemWrapper(org.locationtech.geowave.analytic.AnalyticItemWrapper) SimpleFeature(org.opengis.feature.simple.SimpleFeature)

Aggregations

CentroidManagerGeoWave (org.locationtech.geowave.analytic.clustering.CentroidManagerGeoWave)3 AnalyticItemWrapper (org.locationtech.geowave.analytic.AnalyticItemWrapper)2 SimpleFeatureItemWrapperFactory (org.locationtech.geowave.analytic.SimpleFeatureItemWrapperFactory)2 SimpleFeature (org.opengis.feature.simple.SimpleFeature)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 SpatialOptions (org.locationtech.geowave.core.geotime.index.SpatialOptions)1 Point (org.locationtech.jts.geom.Point)1