Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Breaking] Maintain a closed environment of GDAL-compatible types #179

Merged
merged 174 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
174 commits
Select commit Hold shift + click to select a range
928e88b
ignore .DS_Store files
yeesian Apr 18, 2021
fd95b3f
Return errors for unknown datatypes when looking up gdaltypes
yeesian Apr 18, 2021
52a183a
bugfix for looking up julia datatypes when given a gdaldatatype
yeesian Apr 18, 2021
95fb4db
throw informative error message for unknown field types
yeesian Apr 18, 2021
d09334d
Add instructions for managing dependencies
yeesian Apr 18, 2021
d317029
remove cenum dependency
yeesian Apr 18, 2021
de98ada
[Breaking change] Maintain our own OGRFieldType
yeesian Apr 18, 2021
36085e9
[stylistic] Require explicit return statements and enforce maxcolumnw…
yeesian Apr 19, 2021
9bb0304
Update the types in the API to be based on julia types (rather than C…
yeesian Apr 19, 2021
aa380f3
[Breaking change] Introduce types for wkbGeometryType
yeesian Apr 19, 2021
d9ea813
Encapsulate the tests in their own testsets for better organization o…
yeesian Apr 19, 2021
912cb88
Refactor src/types.jl
yeesian Apr 19, 2021
91a6af5
annotate function signatures with return types
yeesian Apr 19, 2021
1175f14
[Breaking] copywholeraster -> copywholeraster!
yeesian Apr 24, 2021
1411c79
annotate with return types
yeesian Apr 25, 2021
cc82bf3
[Breaking] Deprecate serializeJSON
yeesian Apr 25, 2021
0a6755d
[Breaking] _dataset_type -> pixeltype
yeesian Apr 25, 2021
8e7c37d
Annotate with return types
yeesian Apr 25, 2021
f96f2c2
Fix the implementation of src/tables.jl
yeesian Apr 25, 2021
cea217f
Annotate with return types
yeesian Apr 25, 2021
7a785d4
tighten the return type
yeesian Apr 25, 2021
62ccf75
white spacing
yeesian Apr 25, 2021
ec757bf
use isnothing()
yeesian Apr 25, 2021
d5c1512
whitespacing
yeesian Apr 25, 2021
cf950a2
Array -> Vector
yeesian Apr 25, 2021
2811f95
Introduce enums for WKBByteOrder
yeesian Apr 25, 2021
fca9536
remove pointer definitions in constants.jl
yeesian Apr 25, 2021
cb4a13a
[Breaking] Provide proper support for all GDAL enums
yeesian Apr 25, 2021
2e4cecc
improve test coverage for drivers
yeesian Apr 25, 2021
b782646
Remove unnecessary imports of GDAL in the tests
yeesian Apr 25, 2021
cd4ac78
Add tests for geotransforms
yeesian Apr 25, 2021
1758d84
whitespacing
yeesian Apr 25, 2021
eca39b5
[Breaking] Update implementation of GeoInterface.coordinates()
yeesian Apr 25, 2021
126ced0
LinearRings have the strange property of being treated like linestrings
yeesian Apr 25, 2021
2e168dd
Implement a basetype() method
yeesian Apr 25, 2021
d1d8156
Remove nextnamedtuple() from tables.jl
yeesian Apr 25, 2021
3dc7eb7
Add tests for tables.jl
yeesian Apr 25, 2021
b13e5db
Add tests for rasterio!(...)
yeesian Apr 26, 2021
26cd97a
Add tests for raster/array.jl
yeesian Apr 26, 2021
63c6eb4
[Breaking] Remove untested method for addfielddefn()
yeesian Apr 26, 2021
987fe10
Add tests for displays of different objects
yeesian Apr 26, 2021
1d0b365
Add test for unsafe_getgeom(feature)
yeesian Apr 26, 2021
a4eb87e
Improve test coverage for raster/array.jl
yeesian Apr 26, 2021
4446f22
add tests for tables.jl
yeesian Apr 26, 2021
f93587d
add prefix
yeesian Apr 26, 2021
83bec76
Remove obsolete function
yeesian Apr 26, 2021
340d431
Add support for displaying color tables
yeesian Apr 26, 2021
d557d0a
got missed in the previous commit
yeesian Apr 26, 2021
c8aaeb8
Delete obsolete function
yeesian Apr 26, 2021
8b499d6
Whitespacing
yeesian Apr 26, 2021
8c720e7
Add test for reproject in the case of a no-op
yeesian Apr 26, 2021
3221556
Add test for copywholeraster!
yeesian Apr 26, 2021
d19f53e
Add test for unsafe_getgeom(feature, name)
yeesian Apr 26, 2021
e73d91c
Add test for unsafe_copy(layer)
yeesian Apr 26, 2021
9765462
Add tests for cloning null geometries
yeesian Apr 26, 2021
f5ee120
Update the documentation for working with the tables interface
yeesian Apr 26, 2021
37ad420
Update API reference for geotransfromations
yeesian Apr 26, 2021
c840bb2
Add README for building the documentation
yeesian Apr 26, 2021
f0ecc60
Merge branch 'master' into type-error-messages
yeesian Apr 28, 2021
d7a67df
Fix command for activating the environment
yeesian Apr 28, 2021
dfe9652
Update macro name to reflect its usage and provide a docstring
yeesian May 1, 2021
f9e028c
Add support for images
yeesian May 1, 2021
d3c3ad2
Add the return keyword
yeesian May 1, 2021
1f74057
Add support for YCbCr
yeesian May 1, 2021
979bc60
[Breaking] Delete unneeded ColorTable methods
yeesian May 1, 2021
eca12eb
Add tests for uncovered methods of features
yeesian May 1, 2021
3d00197
Add support for options in toJSON
yeesian May 1, 2021
c3f7d55
Increase test coverage for NULL geometries
yeesian May 1, 2021
b75d0d4
Add support for kwargs in lineargeom
yeesian May 1, 2021
7871cff
[Breaking] Remove initialize!(stylemanager, feature)
yeesian May 1, 2021
21e4772
Use summarize(io, rasterband) for NULL bands
yeesian May 1, 2021
513a98e
remove obsolete comment
yeesian May 1, 2021
2dbd579
Update README.md
yeesian May 1, 2021
2aee418
Add tests for raster attribute tables and color tables
yeesian May 1, 2021
83e1024
Add tests for ColorTable <-> RAT
yeesian May 1, 2021
c5ef729
Add test for cloning raster attribute tables
yeesian May 1, 2021
5da6c4b
Fix flakey test
yeesian May 1, 2021
72ea24c
Add tests for conversion errors
yeesian May 1, 2021
a1339ec
Add test to exercise `macro ogrerr(code, message)`
yeesian May 1, 2021
0b477e1
Add test to exercise `macro cplerr(code, message)`
yeesian May 1, 2021
e8e990c
Add tests for imread
yeesian May 1, 2021
73d12f5
Add tests for axisorder when importing CRS
yeesian May 1, 2021
e4a65aa
Add tests for CRS conversion
yeesian May 1, 2021
d24e781
whitespacing
yeesian May 1, 2021
f0d1ec9
[Breaking] Remove destroy(driver)
yeesian May 1, 2021
7023b39
Replace tabs with spaces
yeesian May 1, 2021
5ba0075
Add tests for images
yeesian May 2, 2021
c49c4bc
Remove untested code for HSL
yeesian May 2, 2021
3a7287a
Test for error cases
yeesian May 2, 2021
58aa862
Add test for gray colortable
yeesian May 2, 2021
4e2a30a
Add test cases for NULL SpatialRefs
yeesian May 2, 2021
5cc0c9a
Add test for color relief
yeesian May 2, 2021
1346154
Add test for conversion error
yeesian May 2, 2021
f47104f
Add test for displaying dataset with many feature layers
yeesian May 2, 2021
221f3f0
Use format from JuliaFormatter
yeesian May 2, 2021
4ac6184
Add github workflow for running JuliaFormatter
yeesian May 2, 2021
582d026
Add format configurations
yeesian May 9, 2021
cc9b1a1
Add a format checker for PRs
yeesian May 9, 2021
befe918
Update the README with the style guide
yeesian May 9, 2021
594976a
Restrict the format checker to just the src/ directory for now.
yeesian May 9, 2021
9debf2f
Update README.md
yeesian May 9, 2021
dbef00a
tweak phrasing
yeesian May 9, 2021
08505ee
Include Julialang in the statement of support
yeesian May 9, 2021
405fb7f
provide a README.md for the tests
yeesian May 10, 2021
f2531ab
Fix the return type
yeesian May 15, 2021
ab775a3
fix format
yeesian May 15, 2021
d3570e0
Tweak README
yeesian May 15, 2021
3d025fe
Add functionality and documentation for raster images
yeesian May 15, 2021
ca1ecc3
Fix file formatting
yeesian May 15, 2021
52af364
Allow to use interactive Datasets in unsafe_gdal functions in utiliti…
felixcremer May 15, 2021
ddc62bf
Replace Pkg.PlatformEngine --> Custom download & verify
zerefwayne May 15, 2021
86ee7ec
Move importing of Downloads and SHA to remotefiles.jl
yeesian May 15, 2021
88a9fa5
Add contributor's guide
yeesian May 15, 2021
130fb4e
Update for geometry type hints in Schema
yeesian May 21, 2021
ebe90bf
Ran JuliaFormatter
yeesian May 21, 2021
c3926c2
Fix tables example
yeesian May 21, 2021
917f792
ArchGDAL.getgeomdefn -> getgeomdefn
yeesian May 21, 2021
a83a33f
add a section about the compat entries
yeesian May 22, 2021
fcaba40
add compat entries for ColorTypes and ImageCore
yeesian May 22, 2021
72d05cc
Merge branch 'type-error-messages' of https://github.com/yeesian/Arch…
yeesian May 22, 2021
6f79b64
Add badges
yeesian May 22, 2021
307f0f2
rearrange badges for color
yeesian May 22, 2021
3a0b3a8
fix for table geometry v.s. field ordering
yeesian May 22, 2021
0ca1a7d
Add conversion for geometries to wkbUnknown
yeesian May 22, 2021
309d598
ran JuliaFormatter
yeesian May 22, 2021
3c94ec2
Revamp implementation of imread() to be on-par with read()
yeesian May 22, 2021
ff3d2eb
Add tests for images
yeesian May 22, 2021
421cac0
Ran JuliaFormatter
yeesian May 22, 2021
1234d6b
remove obsolete code
yeesian May 22, 2021
fb25d5a
Fix the description for updating compatibility
yeesian May 22, 2021
bf6be50
Removing the forecast checker from PRs
yeesian May 30, 2021
ac50e17
Re-enable test for gdal warp
yeesian May 31, 2021
b98940b
Use JuliaFormatter
yeesian May 31, 2021
2a31683
Use links instead of URLs
yeesian May 31, 2021
90b8646
Use `=== nothing` instead of isnothing() for performance
yeesian May 31, 2021
4f7058c
Future-proof the url to use the latest 1.* version.
yeesian May 31, 2021
52ed391
Use the project environment for the docs
yeesian May 31, 2021
e86beac
Format test cases that take up too much vertical whitespace
yeesian May 31, 2021
a665f34
Bugfix to write out the file before reading it.
yeesian May 31, 2021
dadfa12
Remove unnecessary `Table{T<:AbstractFeatureLayer}` type.
yeesian May 31, 2021
a20203a
Merge branch 'master' into type-error-messages
yeesian May 31, 2021
d2ae1bd
Undo replacement of empty geometry column names with "geometry".
yeesian May 31, 2021
37cb501
Tweak wording
yeesian May 31, 2021
4bfaa01
format file
yeesian May 31, 2021
a8f831e
fix typo and use https where possible
yeesian May 31, 2021
5107fe5
use abstract input types and fix indentation for multiline strings
yeesian May 31, 2021
3895551
remove conventions.md
yeesian May 31, 2021
83b7025
Return missing rather than -1 or nothing if no matching field is found.
yeesian May 31, 2021
7351750
Added discussion on tables interface
yeesian May 31, 2021
9c7069c
Add discussion of enum values between base enums and cenums
yeesian May 31, 2021
abe94cd
Updating getnodatavalueband to return missing rather than nothing
yeesian May 31, 2021
e720366
Capture the discussion on colors and images
yeesian May 31, 2021
cff9913
Ran juliaformatter
yeesian May 31, 2021
d5a5885
Add docstrings for enum conversions
yeesian May 31, 2021
ab2b929
annotate return types
yeesian May 31, 2021
38cbd06
Update test-specific dependencies
yeesian May 31, 2021
17301f9
Fix doc builds
yeesian May 31, 2021
bba88d6
ignore tif files
yeesian May 31, 2021
06b2885
Be consistent in using module names as prefixes
yeesian May 31, 2021
1939d11
add GDAL as dependency for docs
yeesian May 31, 2021
29c4a94
Update instructions for formatting code.
yeesian Jun 1, 2021
4faa979
Add details on AbstractDataset potentially having multiple tables
yeesian Jun 5, 2021
2fd5aee
Add a note about (lack of) support for spatialite
yeesian Jun 5, 2021
26a8010
Add an instruction for starting julia
yeesian Jun 5, 2021
b53179d
Add note that tables are only for OGR features and geometries
yeesian Jun 5, 2021
aecd4d8
rewrite if-else to have a single return
yeesian Jun 5, 2021
c615a99
Update show methods to return nothing
yeesian Jun 5, 2021
fa7f005
run JuliaFormatter
yeesian Jun 20, 2021
317272f
Add support for GPI_RGB with GCI_PaletteIndex
yeesian Jun 20, 2021
174e2d6
looser ImageCore and ColorTypes deps (#207)
rafaqz Jun 21, 2021
800bf2c
Switch from `missing` to `nothing`
yeesian Jun 21, 2021
1b40beb
Merge branch 'type-error-messages' of https://github.com/yeesian/Arch…
yeesian Jun 21, 2021
36c5969
Return `nothing` rather than `missing` when no matching field is found
yeesian Jun 21, 2021
eedf3d4
formatting
yeesian Jun 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Configuration file for JuliaFormatter.jl
# For more information, see: https://domluna.github.io/JuliaFormatter.jl/stable/config/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope we can someday put all these config things into the Project.toml, would clean up nicely.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that'll be nice :)


always_for_in = true
always_use_return = true
margin = 80
remove_extra_newlines = true
short_to_long_function_def = true
30 changes: 30 additions & 0 deletions .github/workflows/format_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: format-pr
yeesian marked this conversation as resolved.
Show resolved Hide resolved
on:
schedule:
- cron: '0 0 * * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install JuliaFormatter and format
run: |
julia -e 'import Pkg; Pkg.add("JuliaFormatter")'
julia -e 'using JuliaFormatter; format(".")'

# https://github.com/marketplace/actions/create-pull-request
# https://github.com/peter-evans/create-pull-request#reference-example
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Format .jl files
title: 'Automatic JuliaFormatter.jl run'
branch: auto-juliaformatter-pr
delete-branch: true
labels: formatting, automated pr, no changelog
- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ test/gdalworkshop/
test/ospy/
test/pyrasterio/
test/spatialite/
.DS_Store
Manifest.toml
*.tif
13 changes: 4 additions & 9 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,21 @@ desc = "A high level API for GDAL - Geospatial Data Abstraction Library"
version = "0.6.0"

[deps]
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DiskArrays = "3c3547ce-8d99-4f5e-a174-61eb10b00ae3"
GDAL = "add2ef01-049f-52c4-9ee2-e494f65e021a"
GeoFormatTypes = "68eda718-8dee-11e9-39e7-89f7f65f511f"
GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
yeesian marked this conversation as resolved.
Show resolved Hide resolved
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"

[compat]
ColorTypes = "0.10, 0.11"
DiskArrays = "0.2.4"
GDAL = "1.1.3"
GeoFormatTypes = "0.3"
GeoInterface = "0.4, 0.5"
ImageCore = "0.8, 0.9"
Tables = "1"
julia = "1.3"

[extras]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Dates", "Pkg", "Statistics", "Test"]
78 changes: 77 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# ArchGDAL
[![CI](https://github.com/yeesian/ArchGDAL.jl/workflows/CI/badge.svg)](https://github.com/yeesian/ArchGDAL.jl/actions?query=workflow%3ACI)
[![Coverage Status](https://coveralls.io/repos/github/yeesian/ArchGDAL.jl/badge.svg?branch=master)](https://coveralls.io/github/yeesian/ArchGDAL.jl?branch=master)
[![version](https://juliahub.com/docs/ArchGDAL/version.svg)](https://juliahub.com/ui/Packages/ArchGDAL/MCIiB)
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://yeesian.com/ArchGDAL.jl/stable)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://yeesian.com/ArchGDAL.jl/dev)
[![deps](https://juliahub.com/docs/ArchGDAL/deps.svg)](https://juliahub.com/ui/Packages/ArchGDAL/MCIiB?t=2)
[![ColPrac: Contributor's Guide](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac)

[GDAL](http://gdal.org/) is a translator library for raster and vector geospatial data formats that is released under an [X/MIT](https://trac.osgeo.org/gdal/wiki/FAQGeneral#WhatlicensedoesGDALOGRuse) license by the [Open Source Geospatial Foundation](http://www.osgeo.org/). As a library, it presents an abstract data model to drivers for various [raster](http://www.gdal.org/formats_list.html) and [vector](http://www.gdal.org/ogr_formats.html) formats.

This package aims to be a complete solution for working with GDAL in Julia, similar in scope to [the SWIG bindings for Python](https://pypi.python.org/pypi/GDAL/). It builds on top of [GDAL.jl](https://github.com/JuliaGeo/GDAL.jl), and provides a high level API for GDAL, espousing the following principles.
This package aims to be a complete solution for working with GDAL in Julia, similar in scope to [the SWIG bindings for Python](https://pypi.python.org/pypi/GDAL/) and the user-friendliness of [Fiona](https://github.com/Toblerity/Fiona) and [Rasterio](https://github.com/mapbox/rasterio). It builds on top of [GDAL.jl](https://github.com/JuliaGeo/GDAL.jl), and provides a high level API for GDAL, espousing the following principles.

## Principles (The Arch Way)
(adapted from: https://wiki.archlinux.org/index.php/Arch_Linux#Principles)
Expand All @@ -29,3 +32,76 @@ To test if it is installed correctly,
```julia
pkg> test ArchGDAL
```

## Getting Involved

### Community

This package will not be possible without [JuliaLang](https://julialang.org/), [GDAL](https://github.com/OSGeo/gdal) and [GDAL.jl](https://github.com/JuliaGeo/GDAL.jl). They are maintained by https://julialang.org/community/, https://www.osgeo.org/ and https://juliageo.org/ respectively. In case of any contention for support and involvement, we encourage participation and contributions to those projects and communities over this package.

### Style Guide

ArchGDAL.jl uses [JuliaFormatter.jl](https://github.com/domluna/JuliaFormatter.jl) as
an autoformatting tool, and uses the options in [`.JuliaFormatter.toml`](https://github.com/yeesian/ArchGDAL.jl/blob/master/.JuliaFormatter.toml).

If you wish to format code, `cd` to the ArchGDAL.jl directory, then run:
```julia
] add JuliaFormatter
using JuliaFormatter
format(".")
```

### Dependencies
To manage the dependencies of this package, we work with [environments](https://pkgdocs.julialang.org/v1/environments/):

1. Navigate to the directory corresponding to the package:

```julia
$ cd /Users/yeesian/.julia/dev/ArchGDAL
/Users/yeesian/.julia/dev/ArchGDAL
```

2. Start a session:

```shell
$ julia --project
```

3. Activate the environment corresponding to `Project.toml`):

```julia
(@v1.6) pkg> activate .
Activating environment at `~/.julia/environments/v1.6/Project.toml`
```

4. Manage the dependencies using Pkg in https://pkgdocs.julialang.org/v1.6/managing-packages/, e.g.

```julia
(ArchGDAL) pkg> st
Project ArchGDAL v0.6.0
Status `~/.julia/dev/ArchGDAL/Project.toml`
[3c3547ce] DiskArrays
[add2ef01] GDAL
[68eda718] GeoFormatTypes
[cf35fbd7] GeoInterface
[bd369af6] Tables
[ade2ca70] Dates

(ArchGDAL) pkg> add CEnum
Resolving package versions...
Updating `~/.julia/dev/ArchGDAL/Project.toml`
[fa961155] + CEnum v0.4.1
[3c3547ce] + DiskArrays v0.2.7
[add2ef01] + GDAL v1.2.1
[68eda718] + GeoFormatTypes v0.3.0
[cf35fbd7] + GeoInterface v0.5.5
[bd369af6] + Tables v1.4.2
```
yeesian marked this conversation as resolved.
Show resolved Hide resolved

5. Update the `[compat]` section of `Project.toml` so that julia can resolve the versions, e.g.

```
[compat]
...
CEnum = "0.4"
```
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DiskArrays = "3c3547ce-8d99-4f5e-a174-61eb10b00ae3"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
GDAL = "add2ef01-049f-52c4-9ee2-e494f65e021a"

[compat]
Documenter = "0.26.2"
9 changes: 9 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ArchGDAL.jl documentation

The latest stable version of the documentation can be viewed at https://yeesian.com/ArchGDAL.jl/stable/. To build a local version of the documentation, navigate to this directory and run the following command:

```shell
$ julia --project make.jl
```

It should create files in a subdirectory named `build/`. If it builds successfully, you should be able to preview the documentation in a browser by opening `build/index.html` in a browser.
13 changes: 11 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
using Documenter, ArchGDAL

DocMeta.setdocmeta!(
ArchGDAL,
:DocTestSetup,
:(using ArchGDAL, GDAL);
recursive = true,
)

# make sure you have run the tests before such that the test files are present
makedocs(
modules = [ArchGDAL],
Expand All @@ -17,15 +24,17 @@ makedocs(
"GDAL Datasets" => "datasets.md",
"Feature Data" => "features.md",
"Raster Data" => "rasters.md",
"Working with Images" => "images.md",
"Tables Interface" => "tables.md",
"Geometric Operations" => "geometries.md",
"Spatial Projections" => "projections.md",
# TODO: Uncomment the following line once we support Spatialite
# See https://github.com/JuliaGeo/GDAL.jl/issues/65#issuecomment-493890448.
# "Working with Spatialite" => "spatialite.md",
yeesian marked this conversation as resolved.
Show resolved Hide resolved
"Interactive versus Scoped Objects" => "memory.md",
"Design Considerations" => "considerations.md",
"API Reference" => "reference.md",
# "Naming Conventions" => "conventions.md", # table between GDAL, GDAL.jl, and ArchGDAL.jl
]
],
)

deploydocs(; repo = "github.com/yeesian/ArchGDAL.jl.git")
81 changes: 81 additions & 0 deletions docs/src/considerations.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,84 @@ Here's a collection of references for developers who are interested:
- [https://github.com/mapbox/rasterio/pull/665](https://github.com/mapbox/rasterio/pull/665)
- [https://github.com/mapbox/rasterio/issues/875](https://github.com/mapbox/rasterio/issues/875)
- [https://rasterio.readthedocs.io/en/latest/topics/configuration.html](https://rasterio.readthedocs.io/en/latest/topics/configuration.html)

## GDAL Enum Values

[GDAL.jl](https://github.com/JuliaGeo/GDAL.jl) uses [CEnum.jl](https://github.com/JuliaInterop/CEnum.jl), which is a C-compatible enum, this is the default in [Clang.jl](https://github.com/JuliaInterop/Clang.jl). This is useful when the underlying values are of interest, for example the following snippets from [`src/types.jl`](https://github.com/yeesian/ArchGDAL.jl/blob/master/src/types.jl):

```julia
import Base.|

for T in (GDALOpenFlag, FieldValidation)
eval(quote
|(x::$T, y::UInt8) = UInt8(x) | y
|(x::UInt8, y::$T) = x | UInt8(y)
|(x::$T, y::$T) = UInt8(x) | UInt8(y)
end)
end
```

and

```julia
function basetype(gt::OGRwkbGeometryType)::OGRwkbGeometryType
wkbGeomType = convert(GDAL.OGRwkbGeometryType, gt)
wkbGeomType &= (~0x80000000) # Remove 2.5D flag.
wkbGeomType %= 1000 # Normalize Z, M, and ZM types.
return GDAL.OGRwkbGeometryType(wkbGeomType)
end
```

However, the use of CEnum.jl allows for multiple enums to have the same underlying value, resulting in unintuitive behavior if they are used as keys in a dictionary. For example, in the following code:

```julia
julia> Dict(GDAL.GCI_YCbCr_CrBand => "a", GDAL.GCI_Max => "b")
Dict{GDAL.GDALColorInterp, String} with 1 entry:
GCI_YCbCr_CrBand => "b"
```

the entry for `GDAL.GCI_YCbCr_CrBand => "a"` got overwritten by `GDAL.GCI_Max => "b"` because both `GDAL.GCI_YCbCr_CrBand` and `GDAL.GCI_Max` corresponded to the same value.

To avoid such forms of behavior, this package uses [`Base.Enums`](https://docs.julialang.org/en/v1/base/base/#Base.Enums.Enum) instead, so the above example would result in the following behavior:


```julia
julia> Dict(ArchGDAL.GCI_YCbCr_CrBand => "a", ArchGDAL.GCI_Max => "b")
Dict{ArchGDAL.GDALColorInterp, String} with 2 entries:
GCI_YCbCr_CrBand => "a"
GCI_Max => "b"
```

To maintain parity with GDAL behavior, ArchGDAL.jl provides conversion methods to map from the enums in ArchGDAL to the corresponding cenums from GDAL.jl when calling the corresponding GDAL functions.

## Colors

Rather than encouraging [operations on colortables](https://gdal.org/python/osgeo.gdal.ColorTable-class.html) (with very limited functionality from GDAL), users are better served by arrays of [ColorTypes](https://github.com/JuliaGraphics/ColorTypes.jl) using [Colors.jl](https://github.com/JuliaGraphics/Colors.jl), [for example](http://juliagraphics.github.io/Colors.jl/stable/colormapsandcolorscales/#Generating-a-range-of-colors)

```julia
range(startcolor, stop=endcolor, length=15)
```

instead of

```julia
createcolorramp!(colortable, startindex, startcolor, startindex+15, endcolor)
```

## Images

To differentiate 2d arrays of colors from 3d arrays with band as the third dimension:

* For 2D arrays (a single rasterband), if they have a color interpretation, we use the color interpretation. If they don't have a color interpretation, ArchGDAL.jl defaults to "Grey".
* For >2D arrays (multiple rasterbands), if they have a palette interpretation (or combination of color interpretations) that resolves to a valid colortype, ArchGDAL.jl uses the palette interpretation. If they don't have a palette interpretation, we throw an error.

In general, `read()` will return `Array{UInt8}`, and `imread()` will return `Array{<:Colorant}`.

## Tables.jl Interface

The interface is implemented in [`src/tables.jl`](https://github.com/yeesian/ArchGDAL.jl/blob/master/src/tables.jl), and is only for feature and geometries in OGR (and not for images and rasters). The current API from GDAL makes it row-based in the conventions of Tables.jl. Therefore,

* `ArchGDAL.Feature` meets the criteria for an [`AbstractRow`](https://tables.juliadata.org/dev/#Tables.AbstractRow-1) based on https://github.com/yeesian/ArchGDAL.jl/blob/a665f3407930b8221269f8949c246db022c3a85c/src/tables.jl#L31-L58.
* `ArchGDAL.FeatureLayer` meets the criteria for an `AbstractRow`-iterator based on the previous bullet and meeting the criteria for [`Iteration`](https://docs.julialang.org/en/v1/manual/interfaces/#man-interface-iteration) in [`base/iterators.jl`](https://github.com/yeesian/ArchGDAL.jl/blob/a665f3407930b8221269f8949c246db022c3a85c/src/base/iterators.jl#L1-L18).
* `ArchGDAL.AbstractDataset` might contain multiple layers, and might correspond to multiple tables. The way to construct tables would be to get the layers before forming the corresponding tables.

Empty file removed docs/src/conventions.md
Empty file.
53 changes: 26 additions & 27 deletions docs/src/geometries.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

```@setup geometries
using ArchGDAL
const AG = ArchGDAL
```

In this section, we consider some of the common kinds of geometries that arises in applications. These include `Point`, `LineString`, `Polygon`, `GeometryCollection`, `MultiPolygon`, `MultiPoint`, and `MultiLineString`. For brevity in the examples, we will use the prefix `const AG = ArchGDAL`.
Expand All @@ -11,53 +10,53 @@ In this section, we consider some of the common kinds of geometries that arises
To create geometries of different types,

```@example geometries
point = AG.createpoint(1.0, 2.0)
linestring = AG.createlinestring([(i,i+1) for i in 1.0:3.0])
linearring = AG.createlinearring([(0.,0.), (0.,1.), (1.,1.)])
simplepolygon = AG.createpolygon([(0.,0.), (0.,1.), (1.,1.)])
complexpolygon = AG.createpolygon([[(0.,0.), (0.,j), (j,j)] for j in 1.0:-0.1:0.9])
multipoint = AG.createlinearring([(0.,0.), (0.,1.), (1.,1.)])
multilinestring = AG.createmultilinestring([[(i,i+1) for i in j:j+3] for j in 1.0:5.0:6.0])
multipolygon = AG.createmultipolygon([[[(0.,0.), (0.,j), (j,j)]] for j in 1.0:-0.1:0.9])
point = ArchGDAL.createpoint(1.0, 2.0)
linestring = ArchGDAL.createlinestring([(i,i+1) for i in 1.0:3.0])
linearring = ArchGDAL.createlinearring([(0.,0.), (0.,1.), (1.,1.)])
simplepolygon = ArchGDAL.createpolygon([(0.,0.), (0.,1.), (1.,1.)])
complexpolygon = ArchGDAL.createpolygon([[(0.,0.), (0.,j), (j,j)] for j in 1.0:-0.1:0.9])
multipoint = ArchGDAL.createlinearring([(0.,0.), (0.,1.), (1.,1.)])
multilinestring = ArchGDAL.createmultilinestring([[(i,i+1) for i in j:j+3] for j in 1.0:5.0:6.0])
multipolygon = ArchGDAL.createmultipolygon([[[(0.,0.), (0.,j), (j,j)]] for j in 1.0:-0.1:0.9])
```

Alternatively, they can be assembled from their components.
```@example geometries
point = AG.createpoint()
AG.addpoint!(point, 1.0, 2.0)
point = ArchGDAL.createpoint()
ArchGDAL.addpoint!(point, 1.0, 2.0)

linestring = AG.createlinestring()
linestring = ArchGDAL.createlinestring()
for i in 1.0:3.0
AG.addpoint!(linestring, i, i+1)
ArchGDAL.addpoint!(linestring, i, i+1)
end

linearring = AG.createlinearring()
linearring = ArchGDAL.createlinearring()
for i in 1.0:3.0
AG.addpoint!(linearring, i, i+1)
ArchGDAL.addpoint!(linearring, i, i+1)
end

polygon = AG.createpolygon()
polygon = ArchGDAL.createpolygon()
for j in 1.0:-0.1:0.9
ring = AG.createlinearring([(0.,0.), (0.,j), (j,j)])
AG.addgeom!(polygon, ring)
ring = ArchGDAL.createlinearring([(0.,0.), (0.,j), (j,j)])
ArchGDAL.addgeom!(polygon, ring)
end

multipoint = AG.createmultipoint()
multipoint = ArchGDAL.createmultipoint()
for i in 1.0:3.0
pt = AG.createpoint(i, i+1)
AG.addgeom!(multipoint, pt)
pt = ArchGDAL.createpoint(i, i+1)
ArchGDAL.addgeom!(multipoint, pt)
end

multilinestring = AG.createmultilinestring()
multilinestring = ArchGDAL.createmultilinestring()
for j in 1.0:5.0:6.0
line = AG.createlinestring([(i,i+1) for i in j:j+3])
AG.addgeom!(multilinestring, line)
line = ArchGDAL.createlinestring([(i,i+1) for i in j:j+3])
ArchGDAL.addgeom!(multilinestring, line)
end

multipolygon = AG.createmultipolygon()
multipolygon = ArchGDAL.createmultipolygon()
for j in 1.0:-0.1:0.9
poly = AG.createpolygon([(0.,0.), (0.,j), (j,j)])
AG.addgeom!(multipolygon, poly)
poly = ArchGDAL.createpolygon([(0.,0.), (0.,j), (j,j)])
ArchGDAL.addgeom!(multipolygon, poly)
end
```

Expand Down
Loading