ffi-gdal 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +15 -0
- data/.github/workflows/codacy.yml +1 -1
- data/.github/workflows/dependency-review.yml +1 -1
- data/.github/workflows/specs-in-docker.yml +3 -1
- data/.prettierrc.yml +4 -0
- data/.rubocop.yml +9 -5
- data/.rubocop_todo.yml +5 -11
- data/.solargraph.yml +13 -0
- data/Changelog-0.x.md +229 -174
- data/Changelog.md +20 -4
- data/Dockerfile.gdal2 +2 -85
- data/Gemfile +12 -2
- data/LICENSE.txt +1 -1
- data/README.md +14 -16
- data/Rakefile +6 -6
- data/bin/bundle +12 -12
- data/bin/rake +6 -6
- data/bin/rspec +6 -6
- data/bin/rubocop +6 -6
- data/examples/extract_and_colorize.rb +15 -15
- data/examples/geometries.rb +12 -12
- data/examples/gridding.rb +17 -17
- data/examples/ogr_layer_to_layer.rb +3 -3
- data/examples/raster_erasing.rb +9 -9
- data/examples/remove_small_polygons.rb +11 -11
- data/examples/testing_gdal.rb +20 -20
- data/examples/warping.rb +13 -13
- data/ffi-gdal.gemspec +16 -27
- data/lib/ext/ffi_library_function_checks.rb +3 -3
- data/lib/ext/narray_ext.rb +1 -1
- data/lib/ext/to_bool.rb +2 -2
- data/lib/ffi/cpl/conv.rb +2 -2
- data/lib/ffi/cpl/error.rb +1 -1
- data/lib/ffi/cpl/hash_set.rb +2 -2
- data/lib/ffi/cpl/http.rb +3 -3
- data/lib/ffi/cpl/http_result.rb +2 -2
- data/lib/ffi/cpl/list.rb +1 -1
- data/lib/ffi/cpl/mime_part.rb +1 -1
- data/lib/ffi/cpl/minixml.rb +2 -2
- data/lib/ffi/cpl/port.rb +1 -1
- data/lib/ffi/cpl/progress.rb +2 -2
- data/lib/ffi/cpl/quad_tree.rb +3 -3
- data/lib/ffi/cpl/rect_obj.rb +1 -1
- data/lib/ffi/cpl/string.rb +1 -1
- data/lib/ffi/cpl/vsi.rb +2 -2
- data/lib/ffi/cpl/xml_node.rb +1 -1
- data/lib/ffi/cpl.rb +11 -11
- data/lib/ffi/extensions/gdal/extensions/all.rb +2 -2
- data/lib/ffi/extensions/gdal/extensions.rb +2 -2
- data/lib/ffi/extensions/rttopo/gbox.rb +1 -1
- data/lib/ffi/extensions/rttopo/geom.rb +2 -2
- data/lib/ffi/extensions/rttopo.rb +3 -3
- data/lib/ffi/gdal/alg.rb +2 -2
- data/lib/ffi/gdal/color_entry.rb +1 -1
- data/lib/ffi/gdal/gcp.rb +1 -1
- data/lib/ffi/gdal/gdal.rb +3 -3
- data/lib/ffi/gdal/grid.rb +2 -2
- data/lib/ffi/gdal/grid_data_metrics_options.rb +1 -1
- data/lib/ffi/gdal/grid_inverse_distance_to_a_power_options.rb +1 -1
- data/lib/ffi/gdal/grid_moving_average_options.rb +1 -1
- data/lib/ffi/gdal/grid_nearest_neighbor_options.rb +1 -1
- data/lib/ffi/gdal/matching.rb +2 -2
- data/lib/ffi/gdal/rpc_info.rb +1 -1
- data/lib/ffi/gdal/transformer_info.rb +1 -1
- data/lib/ffi/gdal/version.rb +1 -1
- data/lib/ffi/gdal/vrt.rb +2 -2
- data/lib/ffi/gdal/warp_options.rb +1 -1
- data/lib/ffi/gdal/warper.rb +2 -2
- data/lib/ffi/gdal.rb +22 -22
- data/lib/ffi/ogr/api.rb +3 -3
- data/lib/ffi/ogr/contour_writer_info.rb +1 -1
- data/lib/ffi/ogr/core.rb +9 -9
- data/lib/ffi/ogr/envelope.rb +1 -1
- data/lib/ffi/ogr/envelope_3d.rb +1 -1
- data/lib/ffi/ogr/featurestyle.rb +1 -1
- data/lib/ffi/ogr/field.rb +1 -1
- data/lib/ffi/ogr/geocoding.rb +2 -2
- data/lib/ffi/ogr/srs_api.rb +63 -63
- data/lib/ffi/ogr/style_param.rb +2 -2
- data/lib/ffi/ogr/style_value.rb +1 -1
- data/lib/ffi/ogr.rb +11 -11
- data/lib/ffi-gdal.rb +8 -8
- data/lib/gdal/color_table.rb +6 -6
- data/lib/gdal/dataset/accessors.rb +101 -0
- data/lib/gdal/{dataset_mixins → dataset}/algorithm_methods.rb +1 -1
- data/lib/gdal/dataset/class_methods.rb +69 -0
- data/lib/gdal/dataset/internal_functions.rb +22 -0
- data/lib/gdal/{dataset_mixins → dataset}/matching.rb +1 -1
- data/lib/gdal/dataset/raster_band_methods.rb +181 -0
- data/lib/gdal/{dataset_mixins → dataset}/warp_methods.rb +1 -1
- data/lib/gdal/dataset.rb +21 -359
- data/lib/gdal/driver.rb +10 -10
- data/lib/gdal/environment_methods.rb +1 -1
- data/lib/gdal/extensions/all.rb +1 -1
- data/lib/gdal/extensions/color_entry/extensions.rb +2 -2
- data/lib/gdal/extensions/color_table/extensions.rb +2 -2
- data/lib/gdal/extensions/dataset/extensions.rb +11 -11
- data/lib/gdal/extensions/driver/extensions.rb +7 -7
- data/lib/gdal/extensions/geo_transform/extensions.rb +2 -2
- data/lib/gdal/extensions/gridder.rb +8 -8
- data/lib/gdal/extensions/gridder_options.rb +6 -6
- data/lib/gdal/extensions/raster_attribute_table/extensions.rb +1 -1
- data/lib/gdal/extensions/raster_band/algorithm_extensions.rb +4 -4
- data/lib/gdal/extensions/raster_band/coloring_extensions.rb +1 -1
- data/lib/gdal/extensions/raster_band/extensions.rb +3 -3
- data/lib/gdal/extensions/raster_band/io_extensions.rb +4 -4
- data/lib/gdal/extensions/raster_band_classifier.rb +3 -3
- data/lib/gdal/geo_transform.rb +1 -1
- data/lib/gdal/grid.rb +6 -6
- data/lib/gdal/grid_algorithms/metric_average_distance.rb +1 -1
- data/lib/gdal/grid_algorithms/metric_average_distance_pts.rb +1 -1
- data/lib/gdal/grid_algorithms/metric_count.rb +1 -1
- data/lib/gdal/grid_algorithms/metric_maximum.rb +1 -1
- data/lib/gdal/grid_algorithms/metric_minimum.rb +1 -1
- data/lib/gdal/grid_algorithms/metric_range.rb +1 -1
- data/lib/gdal/grid_algorithms.rb +9 -9
- data/lib/gdal/internal_helpers.rb +3 -3
- data/lib/gdal/logger.rb +1 -1
- data/lib/gdal/major_object.rb +6 -6
- data/lib/gdal/options.rb +2 -2
- data/lib/gdal/raster_attribute_table.rb +5 -5
- data/lib/gdal/raster_band.rb +24 -24
- data/lib/gdal/rpc_info.rb +2 -2
- data/lib/gdal/transformer.rb +1 -1
- data/lib/gdal/transformers/general_image_projection_transformer.rb +1 -1
- data/lib/gdal/transformers/general_image_projection_transformer2.rb +1 -1
- data/lib/gdal/transformers/general_image_projection_transformer3.rb +1 -1
- data/lib/gdal/version_info.rb +9 -9
- data/lib/gdal/virtual_dataset.rb +4 -4
- data/lib/gdal/warp_operation.rb +2 -2
- data/lib/gdal/warp_options.rb +2 -2
- data/lib/gdal.rb +17 -17
- data/lib/ogr/coordinate_transformation.rb +5 -5
- data/lib/ogr/data_source.rb +9 -9
- data/lib/ogr/driver.rb +9 -9
- data/lib/ogr/envelope.rb +1 -1
- data/lib/ogr/error_handling.rb +1 -1
- data/lib/ogr/extensions/all.rb +1 -1
- data/lib/ogr/extensions/data_source/capability_methods.rb +4 -4
- data/lib/ogr/extensions/data_source/data_source_extensions.rb +1 -1
- data/lib/ogr/extensions/driver/capability_methods.rb +3 -3
- data/lib/ogr/extensions/envelope/extensions.rb +1 -1
- data/lib/ogr/extensions/feature/extensions.rb +1 -1
- data/lib/ogr/extensions/feature_definition/extensions.rb +1 -1
- data/lib/ogr/extensions/geometries/point/extensions.rb +1 -1
- data/lib/ogr/extensions/geometry/container_mixins.rb +10 -10
- data/lib/ogr/extensions/geometry/ewkb_io_extensions.rb +3 -3
- data/lib/ogr/extensions/geometry/ewkb_record.rb +4 -4
- data/lib/ogr/extensions/geometry/extensions.rb +4 -7
- data/lib/ogr/extensions/geometry/rttopo_extensions.rb +2 -2
- data/lib/ogr/extensions/geometry/wkb_record.rb +3 -3
- data/lib/ogr/extensions/geometry_types/curve/extensions.rb +2 -2
- data/lib/ogr/extensions/layer/capability_methods.rb +17 -17
- data/lib/ogr/extensions/layer/extensions.rb +1 -1
- data/lib/ogr/extensions/spatial_reference/extensions.rb +1 -1
- data/lib/ogr/extensions/spatial_reference/initializers.rb +2 -2
- data/lib/ogr/extensions/style_table/extensions.rb +1 -1
- data/lib/ogr/feature.rb +15 -15
- data/lib/ogr/feature_definition.rb +2 -2
- data/lib/ogr/field.rb +5 -5
- data/lib/ogr/field_definition.rb +1 -1
- data/lib/ogr/geocoder.rb +1 -1
- data/lib/ogr/geometries/geometry_collection.rb +2 -2
- data/lib/ogr/geometries/geometry_collection_25d.rb +1 -1
- data/lib/ogr/geometries/line_string.rb +1 -1
- data/lib/ogr/geometries/line_string_25d.rb +1 -1
- data/lib/ogr/geometries/linear_ring.rb +2 -2
- data/lib/ogr/geometries/multi_line_string.rb +2 -2
- data/lib/ogr/geometries/multi_line_string_25d.rb +1 -1
- data/lib/ogr/geometries/multi_point.rb +1 -1
- data/lib/ogr/geometries/multi_point_25d.rb +1 -1
- data/lib/ogr/geometries/multi_polygon.rb +2 -2
- data/lib/ogr/geometries/multi_polygon_25d.rb +1 -1
- data/lib/ogr/geometries/point_25d.rb +1 -1
- data/lib/ogr/geometries/polygon.rb +2 -2
- data/lib/ogr/geometries/polygon_25d.rb +1 -1
- data/lib/ogr/geometry.rb +11 -11
- data/lib/ogr/geometry_types/container.rb +1 -1
- data/lib/ogr/geometry_types/curve.rb +1 -1
- data/lib/ogr/internal_helpers.rb +4 -4
- data/lib/ogr/layer.rb +8 -8
- data/lib/ogr/layer_mixins/ogr_feature_methods.rb +9 -9
- data/lib/ogr/layer_mixins/ogr_field_methods.rb +15 -15
- data/lib/ogr/layer_mixins/ogr_sql_methods.rb +2 -2
- data/lib/ogr/spatial_reference.rb +19 -19
- data/lib/ogr/spatial_reference_mixins/coordinate_system_getter_setters.rb +4 -4
- data/lib/ogr/spatial_reference_mixins/exporters.rb +9 -9
- data/lib/ogr/spatial_reference_mixins/importers.rb +2 -2
- data/lib/ogr/spatial_reference_mixins/morphers.rb +2 -2
- data/lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb +1 -1
- data/lib/ogr/style_table.rb +3 -3
- data/lib/ogr/style_tool.rb +1 -1
- data/lib/ogr.rb +33 -33
- data/rakelib/docker.rake +2 -2
- metadata +14 -150
- data/bitbucket-pipelines.yml +0 -16
- data/tilt/gdal2.yml +0 -22
- data/tilt/gdal3.yml +0 -22
data/Changelog.md
CHANGED
@@ -2,17 +2,33 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
-
adheres to
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to
|
7
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
8
|
+
|
9
|
+
## [1.0.3] - 2023-01-27
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
|
13
|
+
- Fix nil return value from `OGR::GeometryMixins::Extensions#utm_zone` when
|
14
|
+
spatial_reference is not 4326.
|
15
|
+
|
16
|
+
## [1.0.2] - 2023-01-13
|
17
|
+
|
18
|
+
### Fixed
|
19
|
+
|
20
|
+
- Fix requires for lib/\*/extensions/all.rb.
|
7
21
|
|
8
22
|
## [1.0.1] - 2023-01-13
|
9
23
|
|
10
24
|
### Fixed
|
11
25
|
|
12
|
-
- Fix NoMethodError in `OGR::GeometryMixins::Extensions#utm_zone` when geometry
|
26
|
+
- Fix NoMethodError in `OGR::GeometryMixins::Extensions#utm_zone` when geometry
|
27
|
+
is invalid.
|
13
28
|
|
14
29
|
## [1.0.0] — 2023-01-06
|
15
30
|
|
16
|
-
Changes for all releases leading up to 1.0.0 can be found in
|
31
|
+
Changes for all releases leading up to 1.0.0 can be found in
|
32
|
+
[Changelog-0.x](/Changelog-0.x.md).
|
17
33
|
|
18
34
|
- Happy birthday!
|
data/Dockerfile.gdal2
CHANGED
@@ -1,93 +1,10 @@
|
|
1
1
|
# syntax=docker/dockerfile:1
|
2
|
-
FROM ruby:3.
|
3
|
-
|
4
|
-
#------------------------------------------------------------------------------
|
5
|
-
# GDAL setup
|
6
|
-
# We don't need much for ffi-gdal...
|
7
|
-
# https://trac.osgeo.org/gdal/wiki/BuildingOnUnixWithMinimizedDrivers
|
8
|
-
#------------------------------------------------------------------------------
|
9
|
-
FROM base as gdal_builder
|
10
|
-
|
11
|
-
ARG GDAL_VERSION="2.4.4"
|
12
|
-
ARG GDAL_TARBALL="gdal-${GDAL_VERSION}.tar.gz"
|
13
|
-
|
14
|
-
WORKDIR /tmp
|
15
|
-
|
16
|
-
RUN apt-get update -yqq \
|
17
|
-
&& apt-get upgrade -yqq \
|
18
|
-
&& apt-get install -yqq --no-install-recommends \
|
19
|
-
build-essential \
|
20
|
-
ca-certificates \
|
21
|
-
curl \
|
22
|
-
libgeos-dev \
|
23
|
-
libproj-dev \
|
24
|
-
librttopo-dev \
|
25
|
-
&& rm -rf /var/lib/apt/lists/* \
|
26
|
-
&& curl -sSf -L -O "https://github.com/OSGeo/gdal/releases/download/v${GDAL_VERSION}/${GDAL_TARBALL}" \
|
27
|
-
&& curl -sSf -L -O "https://github.com/OSGeo/gdal/releases/download/v${GDAL_VERSION}/${GDAL_TARBALL}.md5" \
|
28
|
-
&& md5sum --strict --check "${GDAL_TARBALL}.md5" \
|
29
|
-
&& mkdir gdal \
|
30
|
-
&& tar -zxvf $GDAL_TARBALL -C /tmp/gdal --strip-components=1 \
|
31
|
-
&& rm ${GDAL_TARBALL} "${GDAL_TARBALL}.md5" \
|
32
|
-
&& cd /tmp/gdal \
|
33
|
-
&& ./configure \
|
34
|
-
--with-geos \
|
35
|
-
--with-geotiff=internal \
|
36
|
-
--with-libtiff=internal \
|
37
|
-
--with-libz=internal \
|
38
|
-
--with-threads \
|
39
|
-
--without-bsb \
|
40
|
-
--without-cfitsio \
|
41
|
-
--without-cryptopp \
|
42
|
-
--without-curl \
|
43
|
-
--without-ecw \
|
44
|
-
--without-expat \
|
45
|
-
--without-fme \
|
46
|
-
--without-freexl \
|
47
|
-
--without-gif \
|
48
|
-
--without-gnm \
|
49
|
-
--without-grass \
|
50
|
-
--without-grib \
|
51
|
-
--without-hdf4 \
|
52
|
-
--without-hdf5 \
|
53
|
-
--without-idb \
|
54
|
-
--without-ingres \
|
55
|
-
--without-jasper \
|
56
|
-
--without-jp2mrsid \
|
57
|
-
--without-jpeg \
|
58
|
-
--without-kakadu \
|
59
|
-
--without-libgrass \
|
60
|
-
--without-libkml \
|
61
|
-
--without-libtool \
|
62
|
-
--without-mrf \
|
63
|
-
--without-mrsid \
|
64
|
-
--without-mysql \
|
65
|
-
--without-netcdf \
|
66
|
-
--without-odbc \
|
67
|
-
--without-ogdi \
|
68
|
-
--without-openjpeg \
|
69
|
-
--without-pcidsk \
|
70
|
-
--without-pcraster \
|
71
|
-
--without-pcre \
|
72
|
-
--without-perl \
|
73
|
-
--without-pg \
|
74
|
-
--without-png \
|
75
|
-
--without-python \
|
76
|
-
--without-qhull \
|
77
|
-
--without-sde \
|
78
|
-
--without-sqlite3 \
|
79
|
-
--without-webp \
|
80
|
-
--without-xerces \
|
81
|
-
--without-xml2 \
|
82
|
-
&& make \
|
83
|
-
&& make install \
|
84
|
-
&& cd /tmp \
|
85
|
-
&& rm -rf gdal
|
2
|
+
FROM ghcr.io/telus-agcg/ruby-gdal:3.2.0-2.4.4 as base
|
86
3
|
|
87
4
|
#------------------------------------------------------------------------------
|
88
5
|
# Dev setup 1
|
89
6
|
#------------------------------------------------------------------------------
|
90
|
-
FROM
|
7
|
+
FROM base as dev_builder
|
91
8
|
|
92
9
|
RUN gem update --system \
|
93
10
|
&& gem install bundler
|
data/Gemfile
CHANGED
@@ -1,8 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in ffi-gdal.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem
|
8
|
+
gem "bundler"
|
9
|
+
gem "byebug"
|
10
|
+
gem "climate_control"
|
11
|
+
gem "fakefs"
|
12
|
+
gem "rake"
|
13
|
+
gem "rspec", "~> 3.0"
|
14
|
+
gem "rspec-github"
|
15
|
+
gem "rubocop", ">= 1.0"
|
16
|
+
gem "rubocop-performance"
|
17
|
+
gem "simplecov", "~> 0.9"
|
18
|
+
gem "thor"
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -4,10 +4,6 @@ Ruby wrapper around GDAL, using FFI, along with some helper methods.
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
For Ubuntu you need to install libgdal-dev via:
|
8
|
-
|
9
|
-
sudo apt-get install libgdal-dev
|
10
|
-
|
11
7
|
Add this line to your application's Gemfile:
|
12
8
|
|
13
9
|
gem 'ffi-gdal'
|
@@ -20,14 +16,17 @@ Or install it yourself as:
|
|
20
16
|
|
21
17
|
$ gem install ffi-gdal
|
22
18
|
|
19
|
+
Note that this requires you to have `libgdal` installed on your system and
|
20
|
+
accessible in your `PATH`.
|
21
|
+
|
23
22
|
## Usage
|
24
23
|
|
25
|
-
ffi-gdal provides two interfaces, really: the direct FFI wrapper around GDAL's
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
ffi-gdal provides two interfaces, really: the direct FFI wrapper around GDAL's C
|
25
|
+
API, and a Ruby-fied interface that uses the FFI wrapper to make use more like
|
26
|
+
using an object-oriented library instead of a functional one. Most likely you'll
|
27
|
+
just want to use the Ruby-fied library, but if for some reason that doesn't get
|
28
|
+
you what you want, direct access to the FFI wrapper (which is really just direct
|
29
|
+
access to the C API) is available.
|
31
30
|
|
32
31
|
### The Ruby-fied Library
|
33
32
|
|
@@ -45,19 +44,18 @@ For classes that are enabled with logging capabilities, you can turn logging on
|
|
45
44
|
and off like `GDAL::RasterBand.logging_enabled = true`. If you're using ffi-gdal
|
46
45
|
in Rails, you can `GDAL::Logger.logger = Rails.logger`.
|
47
46
|
|
48
|
-
## Additional Libraries
|
49
|
-
|
50
|
-
[ffi-gdal-extensions](https://github.com/agrian-inc/ffi-gdal-extensions) provides
|
51
|
-
additional functionality, not provided in this core, GDAL-wrapper library.
|
52
|
-
|
53
47
|
## Contributing
|
54
48
|
|
55
|
-
1. Fork it ( https://github.com/
|
49
|
+
1. Fork it ( https://github.com/telus-agcg/ffi-gdal/fork )
|
56
50
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
57
51
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
58
52
|
4. Push to the branch (`git push origin my-new-feature`)
|
59
53
|
5. Create a new Pull Request
|
60
54
|
|
55
|
+
Please consider adhering to
|
56
|
+
[Conventional Commits v1.0.0](https://www.conventionalcommits.org/en/v1.0.0/)
|
57
|
+
with your commit messages.
|
58
|
+
|
61
59
|
### Docker
|
62
60
|
|
63
61
|
There are a couple `Dockerfile`s that allow doing development/testing against
|
data/Rakefile
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
5
|
|
6
6
|
namespace :spec do
|
7
7
|
RSpec::Core::RakeTask.new(:unit) do |t|
|
8
|
-
t.pattern =
|
8
|
+
t.pattern = "spec/unit/**/*_spec.rb"
|
9
9
|
end
|
10
10
|
|
11
11
|
RSpec::Core::RakeTask.new(:integration) do |t|
|
12
|
-
t.pattern =
|
12
|
+
t.pattern = "spec/integration/**/*_spec.rb"
|
13
13
|
end
|
14
14
|
|
15
|
-
desc
|
15
|
+
desc "Run specs with valgrind"
|
16
16
|
task :valgrind do
|
17
17
|
valgrind_options = %w[
|
18
18
|
--num-callers=50
|
@@ -22,7 +22,7 @@ namespace :spec do
|
|
22
22
|
--show-leak-kinds=all
|
23
23
|
--trace-children=yes
|
24
24
|
--log-file=valgrind_output.log
|
25
|
-
].join(
|
25
|
+
].join(" ")
|
26
26
|
|
27
27
|
cmd = %(valgrind #{valgrind_options} bundle exec rake spec SPEC_OPTS="--format documentation")
|
28
28
|
puts cmd
|
data/bin/bundle
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
# this file is here to facilitate running it.
|
9
9
|
#
|
10
10
|
|
11
|
-
require
|
11
|
+
require "rubygems"
|
12
12
|
|
13
13
|
m = Module.new do
|
14
14
|
module_function
|
@@ -18,12 +18,12 @@ m = Module.new do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def env_var_version
|
21
|
-
ENV.fetch(
|
21
|
+
ENV.fetch("BUNDLER_VERSION", nil)
|
22
22
|
end
|
23
23
|
|
24
24
|
def cli_arg_version
|
25
25
|
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
-
return unless
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
27
|
|
28
28
|
bundler_version = nil
|
29
29
|
update_index = nil
|
@@ -38,16 +38,16 @@ m = Module.new do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def gemfile
|
41
|
-
gemfile = ENV.fetch(
|
41
|
+
gemfile = ENV.fetch("BUNDLE_GEMFILE", nil)
|
42
42
|
return gemfile if gemfile && !gemfile.empty?
|
43
43
|
|
44
|
-
File.expand_path(
|
44
|
+
File.expand_path("../Gemfile", __dir__)
|
45
45
|
end
|
46
46
|
|
47
47
|
def lockfile
|
48
48
|
lockfile =
|
49
49
|
case File.basename(gemfile)
|
50
|
-
when
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
|
51
51
|
else "#{gemfile}.lock"
|
52
52
|
end
|
53
53
|
File.expand_path(lockfile)
|
@@ -75,27 +75,27 @@ m = Module.new do
|
|
75
75
|
|
76
76
|
requirement = bundler_gem_version.approximate_recommendation
|
77
77
|
|
78
|
-
return requirement unless Gem.rubygems_version < Gem::Version.new(
|
78
|
+
return requirement unless Gem.rubygems_version < Gem::Version.new("2.7.0")
|
79
79
|
|
80
|
-
requirement +=
|
80
|
+
requirement += ".a" if bundler_gem_version.prerelease?
|
81
81
|
|
82
82
|
requirement
|
83
83
|
end
|
84
84
|
|
85
85
|
def load_bundler!
|
86
|
-
ENV[
|
86
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
87
87
|
|
88
88
|
activate_bundler
|
89
89
|
end
|
90
90
|
|
91
91
|
def activate_bundler
|
92
92
|
gem_error = activation_error_handling do
|
93
|
-
gem
|
93
|
+
gem "bundler", bundler_requirement
|
94
94
|
end
|
95
95
|
return if gem_error.nil?
|
96
96
|
|
97
97
|
require_error = activation_error_handling do
|
98
|
-
require
|
98
|
+
require "bundler/version"
|
99
99
|
end
|
100
100
|
if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
101
101
|
return
|
@@ -120,4 +120,4 @@ end
|
|
120
120
|
|
121
121
|
m.load_bundler!
|
122
122
|
|
123
|
-
load Gem.bin_path(
|
123
|
+
load Gem.bin_path("bundler", "bundle") if m.invoked_as_script?
|
data/bin/rake
CHANGED
@@ -8,11 +8,11 @@
|
|
8
8
|
# this file is here to facilitate running it.
|
9
9
|
#
|
10
10
|
|
11
|
-
require
|
12
|
-
ENV[
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
13
|
Pathname.new(__FILE__).realpath)
|
14
14
|
|
15
|
-
bundle_binstub = File.expand_path(
|
15
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
16
16
|
|
17
17
|
if File.file?(bundle_binstub)
|
18
18
|
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
|
@@ -23,7 +23,7 @@ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
require
|
27
|
-
require
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
28
|
|
29
|
-
load Gem.bin_path(
|
29
|
+
load Gem.bin_path("rake", "rake")
|
data/bin/rspec
CHANGED
@@ -8,11 +8,11 @@
|
|
8
8
|
# this file is here to facilitate running it.
|
9
9
|
#
|
10
10
|
|
11
|
-
require
|
12
|
-
ENV[
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
13
|
Pathname.new(__FILE__).realpath)
|
14
14
|
|
15
|
-
bundle_binstub = File.expand_path(
|
15
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
16
16
|
|
17
17
|
if File.file?(bundle_binstub)
|
18
18
|
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
|
@@ -23,7 +23,7 @@ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
require
|
27
|
-
require
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
28
|
|
29
|
-
load Gem.bin_path(
|
29
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/bin/rubocop
CHANGED
@@ -8,11 +8,11 @@
|
|
8
8
|
# this file is here to facilitate running it.
|
9
9
|
#
|
10
10
|
|
11
|
-
require
|
12
|
-
ENV[
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
13
|
Pathname.new(__FILE__).realpath)
|
14
14
|
|
15
|
-
bundle_binstub = File.expand_path(
|
15
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
16
16
|
|
17
17
|
if File.file?(bundle_binstub)
|
18
18
|
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
|
@@ -23,7 +23,7 @@ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
require
|
27
|
-
require
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
28
|
|
29
|
-
load Gem.bin_path(
|
29
|
+
load Gem.bin_path("rubocop", "rubocop")
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ffi-gdal"
|
5
5
|
|
6
6
|
GDAL::Logger.logging_enabled = true
|
7
7
|
|
@@ -9,56 +9,56 @@ colors = %w[644d1e 745924 856728 95742b a5812d b69930 c8b22d d8cb3c e8e65a
|
|
9
9
|
f4ee79 e0e457 c8da42 afd135 97b73c 7e993c 657e36 4b612c 314441 23295e
|
10
10
|
282973]
|
11
11
|
|
12
|
-
floyd_path = File.join(__dir__,
|
13
|
-
floyd = GDAL::Dataset.open(floyd_path,
|
12
|
+
floyd_path = File.join(__dir__, "../spec/support/images/Floyd/Floyd_1058_20140612_NRGB.tif")
|
13
|
+
floyd = GDAL::Dataset.open(floyd_path, "r")
|
14
14
|
|
15
15
|
#---
|
16
16
|
# Extracting...
|
17
17
|
#---
|
18
18
|
|
19
19
|
# NIR
|
20
|
-
floyd.extract_nir(
|
20
|
+
floyd.extract_nir("nir.tif", 1).close
|
21
21
|
|
22
22
|
# Natural Color
|
23
|
-
floyd.extract_natural_color(
|
23
|
+
floyd.extract_natural_color("nc.tif", band_order: %i[nir red green blue]).close
|
24
24
|
|
25
25
|
# NDVI as Float32
|
26
|
-
floyd.extract_ndvi(
|
26
|
+
floyd.extract_ndvi("ndvi_float.tif", band_order: %i[nir red green blue],
|
27
27
|
data_type: :GDT_Float32,
|
28
28
|
remove_negatives: true).close
|
29
29
|
|
30
30
|
# NDVI as Byte
|
31
|
-
floyd.extract_ndvi(
|
31
|
+
floyd.extract_ndvi("ndvi_byte.tif", band_order: %i[nir red green blue],
|
32
32
|
data_type: :GDT_Byte,
|
33
33
|
remove_negatives: true,
|
34
|
-
photometric:
|
34
|
+
photometric: "PALETTE").close
|
35
35
|
|
36
36
|
# NDVI as UInt16
|
37
|
-
floyd.extract_ndvi(
|
37
|
+
floyd.extract_ndvi("ndvi_uint16.tif", band_order: %i[nir red green blue],
|
38
38
|
data_type: :GDT_UInt16,
|
39
39
|
remove_negatives: true,
|
40
|
-
photometric:
|
40
|
+
photometric: "PALETTE").close
|
41
41
|
|
42
42
|
#---
|
43
43
|
# Colorize after extraction...
|
44
44
|
#---
|
45
45
|
|
46
|
-
byte_dataset = GDAL::Dataset.open(
|
46
|
+
byte_dataset = GDAL::Dataset.open("ndvi_byte.tif", "w")
|
47
47
|
byte_band = byte_dataset.raster_band(1)
|
48
48
|
byte_band.colorize!(*colors)
|
49
49
|
byte_dataset.close
|
50
50
|
|
51
|
-
uint16_dataset = GDAL::Dataset.open(
|
51
|
+
uint16_dataset = GDAL::Dataset.open("ndvi_uint16.tif", "w")
|
52
52
|
uint16_band = uint16_dataset.raster_band(1)
|
53
53
|
uint16_band.colorize!(*colors)
|
54
54
|
uint16_dataset.close
|
55
55
|
|
56
|
-
g_byte_dataset = GDAL::Dataset.open(
|
56
|
+
g_byte_dataset = GDAL::Dataset.open("gndvi_byte.tif", "w")
|
57
57
|
g_byte_band = g_byte_dataset.raster_band(1)
|
58
58
|
g_byte_band.colorize!(*colors)
|
59
59
|
g_byte_dataset.close
|
60
60
|
|
61
|
-
g_uint16_dataset = GDAL::Dataset.open(
|
61
|
+
g_uint16_dataset = GDAL::Dataset.open("gndvi_uint16.tif", "w")
|
62
62
|
g_uint16_band = g_uint16_dataset.raster_band(1)
|
63
63
|
g_uint16_band.colorize!(*colors)
|
64
64
|
g_uint16_dataset.close
|
data/examples/geometries.rb
CHANGED
@@ -1,30 +1,30 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ffi-gdal"
|
5
|
+
require "ogr"
|
6
6
|
|
7
|
-
_data_source = OGR::DataSource.open(
|
7
|
+
_data_source = OGR::DataSource.open("spec/support/shapefiles/states_21basic/states.shp", "r")
|
8
8
|
|
9
|
-
point_wkt =
|
9
|
+
point_wkt = "POINT (1 2)"
|
10
10
|
_point = OGR::Geometry.create_from_wkt(point_wkt)
|
11
|
-
_other_point_wkt =
|
11
|
+
_other_point_wkt = "POINT (1 2)"
|
12
12
|
_other_point = OGR::Geometry.create_from_wkt(point_wkt)
|
13
13
|
|
14
|
-
line_string_wkt =
|
14
|
+
line_string_wkt = "LINESTRING (1 2, 10 30, 40 40, 1 2)"
|
15
15
|
_line_string = OGR::Geometry.create_from_wkt(line_string_wkt)
|
16
|
-
other_line_string_wkt =
|
16
|
+
other_line_string_wkt = "LINESTRING (10 10, 0 30, 40 10)"
|
17
17
|
_other_line_string = OGR::Geometry.create_from_wkt(other_line_string_wkt)
|
18
18
|
|
19
|
-
polygon_wkt =
|
19
|
+
polygon_wkt = "POLYGON ((0 0,4 0,4 4,0 4,0 0), (1 1, 2 1, 2 2, 1 1))"
|
20
20
|
_polygon = OGR::Geometry.create_from_wkt(polygon_wkt)
|
21
|
-
other_polygon_wkt =
|
21
|
+
other_polygon_wkt = "POLYGON ((1 1,5 1,5 5,1 5,1 1), (10 10, 20 10, 20 20, 10 10))"
|
22
22
|
_other_polygon = OGR::Geometry.create_from_wkt(other_polygon_wkt)
|
23
23
|
|
24
|
-
multi_point_wkt =
|
24
|
+
multi_point_wkt = "MULTIPOINT ((10 40), (40 30), (20 20), (30 10))"
|
25
25
|
_multi_point = OGR::Geometry.create_from_wkt(multi_point_wkt)
|
26
26
|
|
27
|
-
multi_line_string_wkt =
|
27
|
+
multi_line_string_wkt = "MULTILINESTRING ((10 10, 20 20, 10 40), (40 40, 30 30, 40 20, 30 10))"
|
28
28
|
_multi_line_string = OGR::Geometry.create_from_wkt(multi_line_string_wkt)
|
29
29
|
|
30
30
|
multi_polygon_wkt = <<-WKT
|
data/examples/gridding.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ffi-gdal"
|
5
|
+
require "gdal/gridder"
|
6
|
+
require "ogr/data_source"
|
7
|
+
require "ogr/spatial_reference"
|
8
8
|
|
9
9
|
GDAL::Logger.logging_enabled = true
|
10
10
|
|
@@ -24,7 +24,7 @@ module Examples
|
|
24
24
|
gridder_options.algorithm_options[:radius2] = 15
|
25
25
|
gridder_options.algorithm_options[:smoothing] = 5
|
26
26
|
|
27
|
-
[gridder_options,
|
27
|
+
[gridder_options, "gridded-idtap.tif"]
|
28
28
|
end
|
29
29
|
|
30
30
|
def make_moving_average_options
|
@@ -36,7 +36,7 @@ module Examples
|
|
36
36
|
gridder_options.algorithm_options[:radius1] = 20
|
37
37
|
gridder_options.algorithm_options[:radius2] = 51
|
38
38
|
|
39
|
-
[gridder_options,
|
39
|
+
[gridder_options, "gridded-ma.tif"]
|
40
40
|
end
|
41
41
|
|
42
42
|
def make_nearest_neighbor_options
|
@@ -47,7 +47,7 @@ module Examples
|
|
47
47
|
gridder_options.algorithm_options[:radius1] = 20
|
48
48
|
gridder_options.algorithm_options[:radius2] = 15
|
49
49
|
|
50
|
-
[gridder_options,
|
50
|
+
[gridder_options, "gridded-nn.tif"]
|
51
51
|
end
|
52
52
|
|
53
53
|
def make_metric_range_options
|
@@ -58,7 +58,7 @@ module Examples
|
|
58
58
|
gridder_options.algorithm_options[:radius1] = 20
|
59
59
|
gridder_options.algorithm_options[:radius2] = 15
|
60
60
|
|
61
|
-
[gridder_options,
|
61
|
+
[gridder_options, "gridded-metric-range.tif"]
|
62
62
|
end
|
63
63
|
|
64
64
|
def make_file(source_layer, file_name, gridder_options)
|
@@ -69,14 +69,14 @@ module Examples
|
|
69
69
|
true
|
70
70
|
end
|
71
71
|
|
72
|
-
gridder_options.input_field_name =
|
72
|
+
gridder_options.input_field_name = "STATE_FIPS"
|
73
73
|
gridder_options.progress_formatter = output_formatter
|
74
74
|
gridder_options.output_size = { width: 1600, height: 1480 }
|
75
75
|
|
76
76
|
gridder = GDAL::Gridder.new(source_layer, file_name, gridder_options)
|
77
77
|
gridder.grid!
|
78
78
|
|
79
|
-
puts
|
79
|
+
puts ""
|
80
80
|
puts "Duration for #{file_name}: #{Time.now - start}"
|
81
81
|
end
|
82
82
|
end
|
@@ -84,26 +84,26 @@ module Examples
|
|
84
84
|
end
|
85
85
|
|
86
86
|
if $PROGRAM_NAME == __FILE__
|
87
|
-
shp_path =
|
88
|
-
ds = OGR::DataSource.open(shp_path,
|
87
|
+
shp_path = "./spec/support/shapefiles/states_21basic"
|
88
|
+
ds = OGR::DataSource.open(shp_path, "r")
|
89
89
|
|
90
90
|
# Inverse Distance To A Power
|
91
91
|
gridder_options, output_file_name = Examples::Gridding.make_idtap_options
|
92
|
-
puts
|
92
|
+
puts ""
|
93
93
|
Examples::Gridding.make_file(ds.layer(0), output_file_name, gridder_options)
|
94
94
|
|
95
95
|
# Moving Average
|
96
96
|
gridder_options, output_file_name = Examples::Gridding.make_moving_average_options
|
97
|
-
puts
|
97
|
+
puts ""
|
98
98
|
Examples::Gridding.make_file(ds.layer(0), output_file_name, gridder_options)
|
99
99
|
|
100
100
|
# Nearest Neighbor
|
101
101
|
gridder_options, output_file_name = Examples::Gridding.make_nearest_neighbor_options
|
102
|
-
puts
|
102
|
+
puts ""
|
103
103
|
Examples::Gridding.make_file(ds.layer(0), output_file_name, gridder_options)
|
104
104
|
|
105
105
|
# Metric Range
|
106
106
|
gridder_options, output_file_name = Examples::Gridding.make_metric_range_options
|
107
|
-
puts
|
107
|
+
puts ""
|
108
108
|
Examples::Gridding.make_file(ds.layer(0), output_file_name, gridder_options)
|
109
109
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ffi-gdal"
|
5
5
|
|
6
6
|
include GDAL::Logger # rubocop:disable Style/MixinUsage
|
7
7
|
GDAL::Logger.logging_enabled = true
|
@@ -9,7 +9,7 @@ GDAL::Logger.logging_enabled = true
|
|
9
9
|
# http://pcjericks.github.io/py-gdalogr-cookbook/vector_layers.html#create-a-new-layer-from-the-extent-of-an-existing-layer
|
10
10
|
|
11
11
|
# Get a Layer's Extent
|
12
|
-
data_source = OGR::DataSource.open(
|
12
|
+
data_source = OGR::DataSource.open("../spec/support/shapefiles/states_21basic/states.shp", "r")
|
13
13
|
layer = data_source.layer(0)
|
14
14
|
extent = layer.extent
|
15
15
|
|