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

Add support for complex and 64bit integers #327

Merged
merged 2 commits into from
Sep 27, 2022
Merged

Add support for complex and 64bit integers #327

merged 2 commits into from
Sep 27, 2022

Conversation

yeesian
Copy link
Owner

@yeesian yeesian commented Sep 27, 2022

Fixes #326

@yeesian yeesian requested a review from rafaqz September 27, 2022 01:44
@visr
Copy link
Collaborator

visr commented Sep 27, 2022

Nice, also fixes #298

@yeesian yeesian linked an issue Sep 27, 2022 that may be closed by this pull request
Copy link
Collaborator

@rafaqz rafaqz left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

I don't really understand the @convert macro and why we need these two steps of conversion. It feels like this could be a maintenance problem long term?

@yeesian yeesian merged commit 4626113 into master Sep 27, 2022
@yeesian yeesian deleted the b326 branch September 27, 2022 13:11
@yeesian
Copy link
Owner Author

yeesian commented Sep 27, 2022

I don't really understand the @convert macro and why we need these two steps of conversion. It feels like this could be a maintenance problem long term?

Yeah it could be a maintenance problem long term; my guess is that the complexity arises from handling the variety of different expressions (depending on whether it's an enum, cenum, datatype, etc) in

ArchGDAL.jl/src/types.jl

Lines 268 to 590 in 4626113

@convert(
GDALDataType::GDAL.GDALDataType,
GDT_Unknown::GDAL.GDT_Unknown,
GDT_Byte::GDAL.GDT_Byte,
GDT_UInt16::GDAL.GDT_UInt16,
GDT_Int16::GDAL.GDT_Int16,
GDT_UInt32::GDAL.GDT_UInt32,
GDT_Int32::GDAL.GDT_Int32,
GDT_UInt64::GDAL.GDT_UInt64,
GDT_Int64::GDAL.GDT_Int64,
GDT_Float32::GDAL.GDT_Float32,
GDT_Float64::GDAL.GDT_Float64,
GDT_CInt16::GDAL.GDT_CInt16,
GDT_CInt32::GDAL.GDT_CInt32,
GDT_CFloat32::GDAL.GDT_CFloat32,
GDT_CFloat64::GDAL.GDT_CFloat64,
GDT_TypeCount::GDAL.GDT_TypeCount,
)
@convert(
GDALDataType::Normed,
GDT_Byte::N0f8,
GDT_UInt16::N0f16,
GDT_UInt32::N0f32,
)
@convert(
GDALDataType::DataType,
GDT_Unknown::Any,
GDT_Byte::UInt8,
GDT_UInt16::UInt16,
GDT_Int16::Int16,
GDT_UInt32::UInt32,
GDT_Int32::Int32,
GDT_UInt64::UInt64,
GDT_Int64::Int64,
GDT_Float32::Float32,
GDT_Float64::Float64,
GDT_CInt16::Complex{Int16},
GDT_CInt32::Complex{Int32},
GDT_CFloat32::ComplexF32,
GDT_CFloat64::ComplexF64
)
@convert(
OGRFieldType::GDAL.OGRFieldType,
OFTInteger::GDAL.OFTInteger,
OFTIntegerList::GDAL.OFTIntegerList,
OFTReal::GDAL.OFTReal,
OFTRealList::GDAL.OFTRealList,
OFTString::GDAL.OFTString,
OFTStringList::GDAL.OFTStringList,
OFTWideString::GDAL.OFTWideString, # deprecated
OFTWideStringList::GDAL.OFTWideStringList, # deprecated
OFTBinary::GDAL.OFTBinary,
OFTDate::GDAL.OFTDate,
OFTTime::GDAL.OFTTime,
OFTDateTime::GDAL.OFTDateTime,
OFTInteger64::GDAL.OFTInteger64,
OFTInteger64List::GDAL.OFTInteger64List,
)
@convert(
OGRFieldType::DataType,
OFTInteger::Bool,
OFTInteger::UInt8,
OFTInteger::Int8,
OFTInteger::UInt16,
OFTInteger::Int16,
OFTInteger::Int32, # default type comes last
OFTIntegerList::Vector{Int8},
OFTIntegerList::Vector{Int16},
OFTIntegerList::Vector{UInt16},
OFTIntegerList::Vector{Int32}, # default type comes last
OFTReal::Float16,
OFTReal::Float32,
OFTReal::Float64, # default type comes last
OFTRealList::Vector{Float16},
OFTRealList::Vector{Float32},
OFTRealList::Vector{Float64},
OFTString::String,
OFTStringList::Vector{String},
OFTBinary::Vector{UInt8},
OFTDate::Dates.Date,
OFTTime::Dates.Time,
OFTDateTime::Dates.DateTime,
OFTInteger64::UInt32,
OFTInteger64::Int64, # default type comes last
OFTInteger64List::Vector{UInt32},
OFTInteger64List::Vector{Int64},
)
function Base.convert(og::Type{OGRFieldType}, ::Type{<:Enum{T}}) where {T}
return Base.convert(og, T)
end
@convert(
OGRFieldSubType::GDAL.OGRFieldSubType,
OFSTNone::GDAL.OFSTNone,
OFSTBoolean::GDAL.OFSTBoolean,
OFSTInt16::GDAL.OFSTInt16,
OFSTFloat32::GDAL.OFSTFloat32,
OFSTJSON::GDAL.OFSTJSON,
)
@convert(
OGRFieldSubType::DataType,
OFSTBoolean::Vector{Bool},
OFSTBoolean::Bool, # default type comes last
OFSTInt16::UInt8,
OFSTInt16::Int8,
OFSTInt16::Vector{Int8},
OFSTInt16::Vector{Int16},
OFSTInt16::Int16, # default type comes last
OFSTFloat32::Float16,
OFSTFloat32::Vector{Float16},
OFSTFloat32::Vector{Float32},
OFSTFloat32::Float32, # default type comes last
OFSTNone::UInt16,
OFSTNone::Vector{UInt16},
OFSTNone::Int32,
OFSTNone::Vector{Int32},
OFSTNone::Float64,
OFSTNone::Vector{Float64},
OFSTNone::String,
OFSTNone::Vector{String},
OFSTNone::Vector{UInt8},
OFSTNone::Dates.Date,
OFSTNone::Dates.Time,
OFSTNone::Dates.DateTime,
OFSTNone::UInt32,
OFSTNone::Vector{UInt32},
OFSTNone::Int64,
OFSTNone::Vector{Int64},
# Lacking OFSTUUID and OFSTJSON defined in GDAL ≥ v"3.3"
OFSTNone::Nothing, # default type comes last
)
function Base.convert(og::Type{OGRFieldSubType}, ::Type{<:Enum{T}}) where {T}
return Base.convert(og, T)
end
@convert(
OGRJustification::GDAL.OGRJustification,
OJUndefined::GDAL.OJUndefined,
OJLeft::GDAL.OJLeft,
OJRight::GDAL.OJRight,
)
@convert(
GDALRATFieldType::GDAL.GDALRATFieldType,
GFT_Integer::GDAL.GFT_Integer,
GFT_Real::GDAL.GFT_Real,
GFT_String::GDAL.GFT_String,
)
@convert(
GDALRATFieldUsage::GDAL.GDALRATFieldUsage,
GFU_Generic::GDAL.GFU_Generic,
GFU_PixelCount::GDAL.GFU_PixelCount,
GFU_Name::GDAL.GFU_Name,
GFU_Min::GDAL.GFU_Min,
GFU_Max::GDAL.GFU_Max,
GFU_MinMax::GDAL.GFU_MinMax,
GFU_Red::GDAL.GFU_Red,
GFU_Green::GDAL.GFU_Green,
GFU_Blue::GDAL.GFU_Blue,
GFU_Alpha::GDAL.GFU_Alpha,
GFU_RedMin::GDAL.GFU_RedMin,
GFU_GreenMin::GDAL.GFU_GreenMin,
GFU_BlueMin::GDAL.GFU_BlueMin,
GFU_AlphaMin::GDAL.GFU_AlphaMin,
GFU_RedMax::GDAL.GFU_RedMax,
GFU_GreenMax::GDAL.GFU_GreenMax,
GFU_BlueMax::GDAL.GFU_BlueMax,
GFU_AlphaMax::GDAL.GFU_AlphaMax,
GFU_MaxCount::GDAL.GFU_MaxCount,
)
@convert(
GDALAccess::GDAL.GDALAccess,
GA_ReadOnly::GDAL.GA_ReadOnly,
GA_Update::GDAL.GA_Update,
)
@convert(
GDALRWFlag::GDAL.GDALRWFlag,
GF_Read::GDAL.GF_Read,
GF_Write::GDAL.GF_Write,
)
@convert(
GDALPaletteInterp::GDAL.GDALPaletteInterp,
GPI_Gray::GDAL.GPI_Gray,
GPI_RGB::GDAL.GPI_RGB,
GPI_CMYK::GDAL.GPI_CMYK,
GPI_HLS::GDAL.GPI_HLS,
)
@convert(
GDALColorInterp::GDAL.GDALColorInterp,
GCI_Undefined::GDAL.GCI_Undefined,
GCI_GrayIndex::GDAL.GCI_GrayIndex,
GCI_PaletteIndex::GDAL.GCI_PaletteIndex,
GCI_RedBand::GDAL.GCI_RedBand,
GCI_GreenBand::GDAL.GCI_GreenBand,
GCI_BlueBand::GDAL.GCI_BlueBand,
GCI_AlphaBand::GDAL.GCI_AlphaBand,
GCI_HueBand::GDAL.GCI_HueBand,
GCI_SaturationBand::GDAL.GCI_SaturationBand,
GCI_LightnessBand::GDAL.GCI_LightnessBand,
GCI_CyanBand::GDAL.GCI_CyanBand,
GCI_MagentaBand::GDAL.GCI_MagentaBand,
GCI_YellowBand::GDAL.GCI_YellowBand,
GCI_BlackBand::GDAL.GCI_BlackBand,
GCI_YCbCr_YBand::GDAL.GCI_YCbCr_YBand,
GCI_YCbCr_CbBand::GDAL.GCI_YCbCr_CbBand,
GCI_YCbCr_CrBand::GDAL.GCI_YCbCr_CrBand,
)
@convert(
GDALAsyncStatusType::GDAL.GDALAsyncStatusType,
GARIO_PENDING::GDAL.GARIO_PENDING,
GARIO_UPDATE::GDAL.GARIO_UPDATE,
GARIO_ERROR::GDAL.GARIO_ERROR,
GARIO_COMPLETE::GDAL.GARIO_COMPLETE,
GARIO_TypeCount::GDAL.GARIO_TypeCount,
)
@convert(
OGRSTClassId::GDAL.OGRSTClassId,
OGRSTCNone::GDAL.OGRSTCNone,
OGRSTCPen::GDAL.OGRSTCPen,
OGRSTCBrush::GDAL.OGRSTCBrush,
OGRSTCSymbol::GDAL.OGRSTCSymbol,
OGRSTCLabel::GDAL.OGRSTCLabel,
OGRSTCVector::GDAL.OGRSTCVector,
)
@convert(
OGRSTUnitId::GDAL.OGRSTUnitId,
OGRSTUGround::GDAL.OGRSTUGround,
OGRSTUPixel::GDAL.OGRSTUPixel,
OGRSTUPoints::GDAL.OGRSTUPoints,
OGRSTUMM::GDAL.OGRSTUMM,
OGRSTUCM::GDAL.OGRSTUCM,
OGRSTUInches::GDAL.OGRSTUInches,
)
@convert(
OGRwkbGeometryType::GDAL.OGRwkbGeometryType,
wkbUnknown::GDAL.wkbUnknown,
wkbPoint::GDAL.wkbPoint,
wkbLineString::GDAL.wkbLineString,
wkbPolygon::GDAL.wkbPolygon,
wkbMultiPoint::GDAL.wkbMultiPoint,
wkbMultiLineString::GDAL.wkbMultiLineString,
wkbMultiPolygon::GDAL.wkbMultiPolygon,
wkbGeometryCollection::GDAL.wkbGeometryCollection,
wkbCircularString::GDAL.wkbCircularString,
wkbCompoundCurve::GDAL.wkbCompoundCurve,
wkbCurvePolygon::GDAL.wkbCurvePolygon,
wkbMultiCurve::GDAL.wkbMultiCurve,
wkbMultiSurface::GDAL.wkbMultiSurface,
wkbCurve::GDAL.wkbCurve,
wkbSurface::GDAL.wkbSurface,
wkbPolyhedralSurface::GDAL.wkbPolyhedralSurface,
wkbTIN::GDAL.wkbTIN,
wkbTriangle::GDAL.wkbTriangle,
wkbNone::GDAL.wkbNone,
wkbLinearRing::GDAL.wkbLinearRing,
wkbCircularStringZ::GDAL.wkbCircularStringZ,
wkbCompoundCurveZ::GDAL.wkbCompoundCurveZ,
wkbCurvePolygonZ::GDAL.wkbCurvePolygonZ,
wkbMultiCurveZ::GDAL.wkbMultiCurveZ,
wkbMultiSurfaceZ::GDAL.wkbMultiSurfaceZ,
wkbCurveZ::GDAL.wkbCurveZ,
wkbSurfaceZ::GDAL.wkbSurfaceZ,
wkbPolyhedralSurfaceZ::GDAL.wkbPolyhedralSurfaceZ,
wkbTINZ::GDAL.wkbTINZ,
wkbTriangleZ::GDAL.wkbTriangleZ,
wkbPointM::GDAL.wkbPointM,
wkbLineStringM::GDAL.wkbLineStringM,
wkbPolygonM::GDAL.wkbPolygonM,
wkbMultiPointM::GDAL.wkbMultiPointM,
wkbMultiLineStringM::GDAL.wkbMultiLineStringM,
wkbMultiPolygonM::GDAL.wkbMultiPolygonM,
wkbGeometryCollectionM::GDAL.wkbGeometryCollectionM,
wkbCircularStringM::GDAL.wkbCircularStringM,
wkbCompoundCurveM::GDAL.wkbCompoundCurveM,
wkbCurvePolygonM::GDAL.wkbCurvePolygonM,
wkbMultiCurveM::GDAL.wkbMultiCurveM,
wkbMultiSurfaceM::GDAL.wkbMultiSurfaceM,
wkbCurveM::GDAL.wkbCurveM,
wkbSurfaceM::GDAL.wkbSurfaceM,
wkbPolyhedralSurfaceM::GDAL.wkbPolyhedralSurfaceM,
wkbTINM::GDAL.wkbTINM,
wkbTriangleM::GDAL.wkbTriangleM,
wkbPointZM::GDAL.wkbPointZM,
wkbLineStringZM::GDAL.wkbLineStringZM,
wkbPolygonZM::GDAL.wkbPolygonZM,
wkbMultiPointZM::GDAL.wkbMultiPointZM,
wkbMultiLineStringZM::GDAL.wkbMultiLineStringZM,
wkbMultiPolygonZM::GDAL.wkbMultiPolygonZM,
wkbGeometryCollectionZM::GDAL.wkbGeometryCollectionZM,
wkbCircularStringZM::GDAL.wkbCircularStringZM,
wkbCompoundCurveZM::GDAL.wkbCompoundCurveZM,
wkbCurvePolygonZM::GDAL.wkbCurvePolygonZM,
wkbMultiCurveZM::GDAL.wkbMultiCurveZM,
wkbMultiSurfaceZM::GDAL.wkbMultiSurfaceZM,
wkbCurveZM::GDAL.wkbCurveZM,
wkbSurfaceZM::GDAL.wkbSurfaceZM,
wkbPolyhedralSurfaceZM::GDAL.wkbPolyhedralSurfaceZM,
wkbTINZM::GDAL.wkbTINZM,
wkbTriangleZM::GDAL.wkbTriangleZM,
wkbPoint25D::GDAL.wkbPoint25D,
wkbLineString25D::GDAL.wkbLineString25D,
wkbPolygon25D::GDAL.wkbPolygon25D,
wkbMultiPoint25D::GDAL.wkbMultiPoint25D,
wkbMultiLineString25D::GDAL.wkbMultiLineString25D,
wkbMultiPolygon25D::GDAL.wkbMultiPolygon25D,
wkbGeometryCollection25D::GDAL.wkbGeometryCollection25D,
)
.

In the meantime, we can examine the output of that macro using macroexpand like in #326 (comment) for debugging purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants