Skip to content

Commit

Permalink
Add docstrings (#7)
Browse files Browse the repository at this point in the history
* Add docstrings

* Add docstrings for objects from 'metadata.jl' file

* Update docstrings

* Add docstrings for objects from 'image.jl', 'load.jl', 'save.jl' files

* Add docstrings for objects from 'userutils.jl' file

* [WIP] Add docstring for 'metadata' function

* Add docstring for 'metadata' function

* Update docstrings

* Update docstrings
  • Loading branch information
eliascarv authored Nov 14, 2024
1 parent ac1bbf9 commit fc896e2
Show file tree
Hide file tree
Showing 6 changed files with 391 additions and 13 deletions.
77 changes: 72 additions & 5 deletions src/geokeys.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
# Licensed under the MIT License. See LICENSE in the project root.
# -----------------------------------------------------------------

"""
GeoTIFF.GeoKeyID
Enum of all GeoKey IDs supported by GeoTIFF.
See [Requirements Class GeoKeyDirectoryTag](https://docs.ogc.org/is/19-008r4/19-008r4.html#_requirements_class_geokeydirectorytag)
section of the GeoTIFF specification for more details.
"""
@enum GeoKeyID::UInt16 begin
GTRasterTypeGeoKey = 1025
GTModelTypeGeoKey = 1024
Expand Down Expand Up @@ -50,11 +58,20 @@
ProjScaleAtCenterGeoKey = 3093
end

# Corresponding names in the GeoTIFF specification:
# id - KeyID
# tag - TIFFTagLocation
# count - Count
# value - ValueOffset
"""
GeoTIFF.GeoKey(id, tag, count, value)
GeoKey Entry that is stored in [`GeoKeyDirectory`](@ref).
Corresponding field names in the GeoTIFF specification:
* `id`: KeyID
* `tag`: TIFFTagLocation
* `count`: Count
* `value`: ValueOffset
See [Requirements Class GeoKeyDirectoryTag](https://docs.ogc.org/is/19-008r4/19-008r4.html#_requirements_class_geokeydirectorytag)
section of the GeoTIFF specification for a explanation of each field.
"""
struct GeoKey
id::GeoKeyID
tag::UInt16
Expand All @@ -63,14 +80,64 @@ struct GeoKey
end

# generic values

"""
GeoTIFF.Undefined
GeoKey value that indicate intentionally omitted parameters.
"""
const Undefined = UInt16(0)

"""
GeoTIFF.UserDefined
GeoKey value that indicate user defined parameters.
"""
const UserDefined = UInt16(32767)

# GTRasterTypeGeoKey values

"""
GeoTIFF.PixelIsArea
PixelIsArea raster type, i.e each pixel of the image is a grid element.
"""
const PixelIsArea = UInt16(1)

"""
GeoTIFF.PixelIsPoint
PixelIsPoint raster type, i.e each pixel of the image is a grid vertex.
"""
const PixelIsPoint = UInt16(2)

# GTModelTypeGeoKey values

"""
GeoTIFF.Projected2D
Projected CRS model type.
"""
const Projected2D = UInt16(1)

"""
GeoTIFF.Geographic2D
Geographic 2D CRS model type.
### Notes
* GeoTIFF specification uses the term Geographic2D to mean geodetic latlon coordinates;
"""
const Geographic2D = UInt16(2)

"""
GeoTIFF.Geocentric3D
Geocentric 3D CRS model type.
### Notes
* GeoTIFF specification uses the term Geocentric3D to mean Cartesian 3D coordinates;
"""
const Geocentric3D = UInt16(3)
18 changes: 18 additions & 0 deletions src/image.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,31 @@
# Licensed under the MIT License. See LICENSE in the project root.
# -----------------------------------------------------------------

"""
GeoTIFF.GeoTIFFImage
Image type returned by the [`GeoTIFF.load`](@ref) function.
See the [`GeoTIFF.tiff`](@ref) and [`GeoTIFF.metadata`](@ref) functions
to get the TIFF image and metadata respectively.
"""
struct GeoTIFFImage{T,N,I<:AbstractTIFF{T,N}} <: AbstractArray{T,N}
tiff::I
metadata::Metadata
end

"""
GeoTIFF.tiff(geotiff)
TIFF image of a `geotiff` image.
"""
tiff(geotiff::GeoTIFFImage) = geotiff.tiff

"""
GeoTIFF.metadata(geotiff)
GeoTIFF metadata of a `geotiff` image.
"""
metadata(geotiff::GeoTIFFImage) = geotiff.metadata

# AbstractArray interface
Expand Down
12 changes: 12 additions & 0 deletions src/load.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
# Licensed under the MIT License. See LICENSE in the project root.
# -----------------------------------------------------------------

"""
GeoTIFF.load(fname; kwargs...)
Load a GeoTIFF file returning an image with the processed GeoTIFF metadata.
The keyword arguments are forward to the `TiffImages.load` function.
### Notes
* TIFF files without GeoTIFF metadata are load with default and mandatory metadata:
* [`GeoKeyDirectory`](@ref) without GeoKeys and only with GeoTIFF version.
* [`ModelTransformation`](@ref) with `A` as identity matrix and `b` as vector of zeros.
"""
function load(fname; kwargs...)
tiff = TiffImages.load(fname; kwargs...)
metadata = _getmetadata(tiff)
Expand Down
Loading

0 comments on commit fc896e2

Please sign in to comment.