Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgraf committed May 24, 2020
2 parents 34a3c49 + f3dc5c8 commit 717a776
Show file tree
Hide file tree
Showing 7 changed files with 401 additions and 8 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,7 @@ Help is greatly appreciated! You can test and report bugs, fix known [issues](ht

Summed up, dependencies should only go in this direction:
Godot + Geodot -> Processing Library -> External Libraries

## Credits

The provided Linux build ships with libgdal.so, a build of the GDAL library. All credits for this library go to [OSGeo/gdal](https://github.com/OSGeo/gdal/) ([license](https://raw.githubusercontent.com/OSGeo/gdal/master/gdal/LICENSE.TXT)).
379 changes: 379 additions & 0 deletions demo/addons/geodot/x11/gdal_license.txt

Large diffs are not rendered by default.

Binary file added demo/addons/geodot/x11/libRasterTileExtractor.so
Binary file not shown.
Binary file added demo/addons/geodot/x11/libVectorExtractor.so
Binary file not shown.
Binary file added demo/addons/geodot/x11/libgdal.so
Binary file not shown.
Binary file added demo/addons/geodot/x11/libgeodot.so
Binary file not shown.
26 changes: 18 additions & 8 deletions src/raster-tile-extractor/GeoRaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,23 @@ int GeoRaster::get_pixel_size_y() {
uint64_t *GeoRaster::get_histogram() {
// TODO: Make sure this is only called on a GeoRaster with format BYTE
// It doesn't make sense for Float32 and we would need a different method for RGBA
GDALRasterBand *band = data->GetRasterBand(1);
GUIntBig *histogram = new GUIntBig[256];

band->GetHistogram(-0.5, 255.5, 256, histogram, false, true, GDALDummyProgress, nullptr);

// TODO: This breaks the array
return reinterpret_cast<uint64_t *>(histogram);
uint64_t *histogram = new uint64_t[256];

// Initialize array
for (int i = 0; i < 256; i++) {
histogram[i] = 0;
}

uint8_t *array = reinterpret_cast<uint8_t *>(get_as_array());

for (int y = 0; y < get_pixel_size_y(); y++) {
for (int x = 0; x < get_pixel_size_x(); x++) {
int index = array[y * get_pixel_size_x() + x];
histogram[index]++;
}
}

return histogram;
}

GeoRaster::GeoRaster(GDALDataset *data, int interpolation_type)
Expand Down Expand Up @@ -164,7 +174,7 @@ GeoRaster::GeoRaster(GDALDataset *data, int pixel_offset_x, int pixel_offset_y,

int get_index_of_highest_value(const uint64_t *array, int array_size) {
int max_index = 0;
int max_value = 0;
uint64_t max_value = 0;

for (int index = 0; index < array_size; index++) {
if (array[index] > max_value) {
Expand Down

0 comments on commit 717a776

Please sign in to comment.