diff --git a/gen/doc.jl b/gen/doc.jl new file mode 100644 index 0000000..bb1ace0 --- /dev/null +++ b/gen/doc.jl @@ -0,0 +1,144 @@ +# this file is included by wrap.jl and provides several functions for building docstrings + +"Build docstring for a function from a Doxygen XML node" +function build_function(node::EzXML.Node) + io = IOBuffer() + + # code block with function definition + print(io, " ", text(node, "name"), "(") + nspace = position(io) + params = findall(node, "param") + if isempty(params) + print(io, ")") + end + for param in params + param !== first(params) && print(io, " "^nspace) # align + islast = param === last(params) + print(io, text(param, "type")) + # declname not always present (with void) + lastchar = islast ? ")" : ",\n" + if !isempty(findall("declname", param)) + print(io, " ", text(param, "declname"), lastchar) + else + print(io, lastchar) + end + end + println(io, " -> ", text(node, "type")) + + # brief description, always 1 present, sometimes only whitespace + desc = strip(nodecontent(findfirst("briefdescription", node))) + if !isempty(desc) + println(io, "\n", text(node, "briefdescription")) + end + + # parameters + params = findall("detaileddescription/para/parameterlist/parameteritem", node) + if !isempty(params) + println(io, "\n### Parameters") + for param in params + print(io, "* **", text(param, "parameternamelist"), "**: ") + println(io, text(param, "parameterdescription")) + end + end + + # returns + return_elems = findall("detaileddescription/para/simplesect[@kind='return']", node) + if !isempty(return_elems) + println(io, "\n### Returns") + println(io, text(return_elems[1], "para")) + end + + String(take!(io)) +end + +"Build a one line docstring consisting of only the brief description from an XML node" +function brief_description(node::EzXML.Node) + # brief description, always 1 present, sometimes only whitespace + strip(nodecontent(findfirst("briefdescription", node))) +end + +"Compose a Markdown docstring based on a Doxygen XML element" +function build_docstring(node::EzXML.Node) + kind = node["kind"] + if kind == "function" + build_function(node) + elseif kind in ("enum", "define", "typedef") + brief_description(node) + else + # "friend" and "variable" kinds remain + # but we leave them out, not needed + "" + end +end + +"Return the text of a subelement `el` of `node`" +function text(node::EzXML.Node, el::AbstractString) + s = findfirst(el, node) + s === nothing ? "" : strip(nodecontent(s)) +end + +"Wrap the one or multiline docstring in appropriate quotes" +function addquotes(docstr::AbstractString) + if '\n' in docstr + string("\"\"\"\n", docstr, "\"\"\"") + else + # one line docstring + repr(rstrip(docstr, '.')) + end +end + +"Get the C name out of a expression" +function cname(ex) + if @capture(ex, function f_(args__) ccall((a_, b_), xs__) end) + String(eval(a)) + else + # TODO make MacroTools.namify work for structs and macros + if MacroTools.isexpr(ex) && ex.head === :struct + String(ex.args[2]) + elseif MacroTools.isexpr(ex) && ex.head === :macrocall + # if the enum has a type specified + String(ex.args[3].args[1]) + else + String(namify(ex)) + end + end +end + +"Based on a name, find the best XML node to generate docs from" +function findnode(name::String, doc::EzXML.Document) + # Names are not unique. We know that kind='friend' (not sure what it is) + # does not give good docs and is never the only one, so we skip those. + # First we use XPath to find all nodes with this name and not kind='friend'. + memberdef = "/doxygen/compounddef/sectiondef/memberdef" + nofriend = "not(@kind='friend')" # :-( + nodes = findall("$memberdef[name='$name' and $nofriend]", doc) + + if length(nodes) == 0 + return nothing + elseif length(nodes) == 1 + return first(nodes) + else + # If we get multiple nodes back, we have to select the best one. + # Looking at the documentation, sometimes there are two similar docstrings, + # but one comes from a .cpp file, as seen in location's file attribute, + # and the other comes from a .h file (.c is the third option). + # Even though this is a C binding, the .cpp node includes the argument names + # which makes for an easier to read docstring, since they can be referenced + # to the argument names in the parameters list. + # Therefore if .cpp is one of the options, go for that. + + # ExXML uses libxml2 which only supports XPath 1.0, meaning + # ends-with(@file,'.cpp') is not available, but according to + # https://stackoverflow.com/a/11857166/2875964 we can rewrite this as + cpp = "'.cpp' = substring(@file, string-length(@file) - string-length('.cpp') +1)" + + for node in nodes + cppnode = findfirst("location[$cpp]/..", node) + if cppnode !== nothing + return cppnode + end + end + # .cpp not present, just pick the first + return first(nodes) + end +end diff --git a/gen/wrap_proj.jl b/gen/wrap_proj.jl index 33741f4..4355484 100644 --- a/gen/wrap_proj.jl +++ b/gen/wrap_proj.jl @@ -9,21 +9,106 @@ So when updating the PROJBuilder provided version, also rerun this wrapper. This way we ensure that the provided library has the same functions available as the wrapped one. Furthermore this makes sure constants in `proj_common.jl` like `PROJ_VERSION_PATCH`, which are just literals, are correct. + +Several custom transformations are applied that should make using this package more convenient. +- docstrings are added, created from PROJ Doxygen XML output +- functions that return a Cstring are wrapped in unsafe_string to return a String +- functions that return a Ptr{Cstring} are wrapped in unsafe_loadstringlist to return a Vector{String} + +These transformations are based on the code developed for GDAL.jl, see +https://github.com/JuliaGeo/GDAL.jl/blob/master/gen/README.md for more information +on how to construct the PROJ Doxygen XML file needed here. =# using Clang +using MacroTools +using EzXML + +const xmlpath = joinpath(@__DIR__, "doxygen.xml") + +# several functions for building docstrings +include(joinpath(@__DIR__, "doc.jl")) + + +""" +Custom rewriter for Clang.jl's C wrapper + +Gets called with all expressions in a header file, or all expressiong in a common file. +If available, it adds docstrings before every expression, such that Clang.jl prints them +on top of the expression. The expressions themselves get sent to `rewriter(::Expr)`` for +further treatment. +""" +function rewriter(xs::Vector) + rewritten = Any[] + for x in xs + # Clang.jl inserts strings like "# Skipping MacroDefinition: X" + # keep these to get a sense of what we are missing + if x isa String + push!(rewritten, x) + continue + end + @assert x isa Expr + name = cname(x) + node = findnode(name, doc) + docstr = node === nothing ? "" : build_docstring(node) + isempty(docstr) || push!(rewritten, addquotes(docstr)) + x2 = rewriter(x) + push!(rewritten, x2) + end + rewritten +end + +"Rewrite expressions in the ways listed at the top of this file." +function rewriter(x::Expr) + if @capture(x, + function f_(fargs__) + ccall(fname_, rettype_, argtypes_, argvalues__) + end + ) + # it is a function wrapper around a ccall + + # bind the ccall such that we can easily wrap it + cc = :(ccall($fname, $rettype, $argtypes, $(argvalues...))) + + cc′ = if rettype == :Cstring + :(unsafe_string($cc)) + elseif rettype == :(Ptr{Cstring}) + :(unsafe_loadstringlist($cc)) + else + cc + end + + # stitch the modified function expression back together + :(function $f($(fargs...)) + $cc′ + end) |> prettify + else + # do not modify expressions that are no ccall function wrappers + x + end +end + +# parse GDAL's Doxygen XML file +const doc = readxml(xmlpath) + +# should be here if you pkg> build Proj4 includedir = normpath(joinpath(@__DIR__, "..", "deps", "usr", "include")) headerfiles = [joinpath(includedir, "proj.h")] wc = init(; headers = headerfiles, - output_file = joinpath(@__DIR__, "proj_c.jl"), - common_file = joinpath(@__DIR__, "proj_common.jl"), + output_file = joinpath(@__DIR__, "..", "src", "proj_c.jl"), + common_file = joinpath(@__DIR__, "..", "src", "proj_common.jl"), clang_includes = [includedir, CLANG_INCLUDE], clang_args = ["-I", includedir], header_wrapped = (root, current) -> root == current, header_library = x -> "libproj", clang_diagnostics = true, - ) + rewriter = rewriter, +) run(wc) + +# delete Clang.jl helper files +rm(joinpath(@__DIR__, "..", "src", "LibTemplate.jl")) +rm(joinpath(@__DIR__, "..", "src", "ctypes.jl")) diff --git a/src/Proj4.jl b/src/Proj4.jl index 6a4fb41..38a4f6f 100644 --- a/src/Proj4.jl +++ b/src/Proj4.jl @@ -48,4 +48,23 @@ include("proj_functions.jl") # user-facing proj functions "Get a global error string in human readable form" error_message() = _strerrno() +""" +Load a null-terminated list of strings + +It takes a `PROJ_STRING_LIST`, which is a `Ptr{Cstring}`, and returns a `Vector{String}`. +""" +function unsafe_loadstringlist(ptr::Ptr{Cstring}) + strings = Vector{String}() + (ptr == C_NULL) && return strings + i = 1 + cstring = unsafe_load(ptr, i) + while cstring != C_NULL + push!(strings, unsafe_string(cstring)) + i += 1 + cstring = unsafe_load(ptr, i) + end + strings +end + + end # module diff --git a/src/proj_c.jl b/src/proj_c.jl index ba326bc..77ce6c8 100644 --- a/src/proj_c.jl +++ b/src/proj_c.jl @@ -26,6 +26,19 @@ function proj_context_get_use_proj4_init_rules(ctx, from_legacy_code_path) ccall((:proj_context_get_use_proj4_init_rules, libproj), Cint, (Ptr{PJ_CONTEXT}, Cint), ctx, from_legacy_code_path) end +""" + proj_create(PJ_CONTEXT * ctx, + const char * text) -> PJ * + +Instantiate an object from a WKT string, PROJ string or object code (like "EPSG:4326", "urn:ogc:def:crs:EPSG::4326", "urn:ogc:def:coordinateOperation:EPSG::1671"). + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **text**: String (must not be NULL) + +### Returns +Object that must be unreferenced with proj_destroy(), or NULL in case of error. +""" function proj_create(ctx, definition) ccall((:proj_create, libproj), Ptr{PJ}, (Ptr{PJ_CONTEXT}, Cstring), ctx, definition) end @@ -38,6 +51,19 @@ function proj_create_crs_to_crs(ctx, source_crs, target_crs, area) ccall((:proj_create_crs_to_crs, libproj), Ptr{PJ}, (Ptr{PJ_CONTEXT}, Cstring, Cstring, Ptr{PJ_AREA}), ctx, source_crs, target_crs, area) end +""" + proj_normalize_for_visualization(PJ_CONTEXT * ctx, + const PJ * obj) -> PJ * + +Returns a PJ* object whose axis order is the one expected for visualization purposes. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **obj**: Object of type CoordinateOperation, created with proj_create_crs_to_crs() (must not be NULL) + +### Returns +a new PJ* object to free with proj_destroy() in case of success, or nullptr in case of error +""" function proj_normalize_for_visualization(ctx, obj) ccall((:proj_normalize_for_visualization, libproj), Ptr{PJ}, (Ptr{PJ_CONTEXT}, Ptr{PJ}), ctx, obj) end @@ -127,7 +153,7 @@ function proj_errno_restore(P, err) end function proj_errno_string(err) - ccall((:proj_errno_string, libproj), Cstring, (Cint,), err) + unsafe_string(ccall((:proj_errno_string, libproj), Cstring, (Cint,), err)) end function proj_log_level(ctx, log_level) @@ -191,277 +217,1253 @@ function proj_dmstor(is, rs) end function proj_rtodms(s, r, pos, neg) - ccall((:proj_rtodms, libproj), Cstring, (Cstring, Cdouble, Cint, Cint), s, r, pos, neg) + unsafe_string(ccall((:proj_rtodms, libproj), Cstring, (Cstring, Cdouble, Cint, Cint), s, r, pos, neg)) end +""" + proj_string_list_destroy(PROJ_STRING_LIST list) -> void +""" function proj_string_list_destroy(list) ccall((:proj_string_list_destroy, libproj), Cvoid, (PROJ_STRING_LIST,), list) end +""" + proj_context_set_database_path(PJ_CONTEXT * ctx, + const char * dbPath, + const char *const * auxDbPaths, + const char *const * options) -> int + +Explicitly point to the main PROJ CRS and coordinate operation definition database ("proj.db"), and potentially auxiliary databases with same structure. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **dbPath**: Path to main database, or NULL for default. +* **auxDbPaths**: NULL-terminated list of auxiliary database filenames, or NULL. +* **options**: should be set to NULL for now + +### Returns +TRUE in case of success +""" function proj_context_set_database_path(ctx, dbPath, auxDbPaths, options) ccall((:proj_context_set_database_path, libproj), Cint, (Ptr{PJ_CONTEXT}, Cstring, Ptr{Cstring}, Ptr{Cstring}), ctx, dbPath, auxDbPaths, options) end +""" + proj_context_get_database_path(PJ_CONTEXT * ctx) -> const char * + +Returns the path to the database. + +### Parameters +* **ctx**: PROJ context, or NULL for default context + +### Returns +path, or nullptr +""" function proj_context_get_database_path(ctx) - ccall((:proj_context_get_database_path, libproj), Cstring, (Ptr{PJ_CONTEXT},), ctx) + unsafe_string(ccall((:proj_context_get_database_path, libproj), Cstring, (Ptr{PJ_CONTEXT},), ctx)) end +""" + proj_context_get_database_metadata(PJ_CONTEXT * ctx, + const char * key) -> const char * + +Return a metadata from the database. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **key**: Metadata key. Must not be NULL + +### Returns +value, or nullptr +""" function proj_context_get_database_metadata(ctx, key) - ccall((:proj_context_get_database_metadata, libproj), Cstring, (Ptr{PJ_CONTEXT}, Cstring), ctx, key) + unsafe_string(ccall((:proj_context_get_database_metadata, libproj), Cstring, (Ptr{PJ_CONTEXT}, Cstring), ctx, key)) end +""" + proj_context_guess_wkt_dialect(PJ_CONTEXT * ctx, + const char * wkt) -> PJ_GUESSED_WKT_DIALECT + +Guess the "dialect" of the WKT string. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **wkt**: String (must not be NULL) +""" function proj_context_guess_wkt_dialect(ctx, wkt) ccall((:proj_context_guess_wkt_dialect, libproj), PJ_GUESSED_WKT_DIALECT, (Ptr{PJ_CONTEXT}, Cstring), ctx, wkt) end +""" + proj_create_from_wkt(PJ_CONTEXT * ctx, + const char * wkt, + const char *const * options, + PROJ_STRING_LIST * out_warnings, + PROJ_STRING_LIST * out_grammar_errors) -> PJ * + +Instantiate an object from a WKT string. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **wkt**: WKT string (must not be NULL) +* **options**: null-terminated list of options, or NULL. Currently supported options are: + +STRICT=YES/NO. Defaults to NO. When set to YES, strict validation will be enabled. +* **out_warnings**: Pointer to a PROJ_STRING_LIST object, or NULL. If provided, *out_warnings will contain a list of warnings, typically for non recognized projection method or parameters. It must be freed with proj_string_list_destroy(). +* **out_grammar_errors**: Pointer to a PROJ_STRING_LIST object, or NULL. If provided, *out_grammar_errors will contain a list of errors regarding the WKT grammaer. It must be freed with proj_string_list_destroy(). + +### Returns +Object that must be unreferenced with proj_destroy(), or NULL in case of error. +""" function proj_create_from_wkt(ctx, wkt, options, out_warnings, out_grammar_errors) ccall((:proj_create_from_wkt, libproj), Ptr{PJ}, (Ptr{PJ_CONTEXT}, Cstring, Ptr{Cstring}, Ptr{PROJ_STRING_LIST}, Ptr{PROJ_STRING_LIST}), ctx, wkt, options, out_warnings, out_grammar_errors) end +""" + proj_create_from_database(PJ_CONTEXT * ctx, + const char * auth_name, + const char * code, + PJ_CATEGORY category, + int usePROJAlternativeGridNames, + const char *const * options) -> PJ * + +Instantiate an object from a database lookup. + +### Parameters +* **ctx**: Context, or NULL for default context. +* **auth_name**: Authority name (must not be NULL) +* **code**: Object code (must not be NULL) +* **category**: Object category +* **usePROJAlternativeGridNames**: Whether PROJ alternative grid names should be substituted to the official grid names. Only used on transformations +* **options**: should be set to NULL for now + +### Returns +Object that must be unreferenced with proj_destroy(), or NULL in case of error. +""" function proj_create_from_database(ctx, auth_name, code, category, usePROJAlternativeGridNames, options) ccall((:proj_create_from_database, libproj), Ptr{PJ}, (Ptr{PJ_CONTEXT}, Cstring, Cstring, PJ_CATEGORY, Cint, Ptr{Cstring}), ctx, auth_name, code, category, usePROJAlternativeGridNames, options) end +""" + proj_uom_get_info_from_database(PJ_CONTEXT * ctx, + const char * auth_name, + const char * code, + const char ** out_name, + double * out_conv_factor, + const char ** out_category) -> int + +Get information for a unit of measure from a database lookup. + +### Parameters +* **ctx**: Context, or NULL for default context. +* **auth_name**: Authority name (must not be NULL) +* **code**: Unit of measure code (must not be NULL) +* **out_name**: Pointer to a string value to store the parameter name. or NULL. This value remains valid until the next call to proj_uom_get_info_from_database() or the context destruction. +* **out_conv_factor**: Pointer to a value to store the conversion factor of the prime meridian longitude unit to radian. or NULL +* **out_category**: Pointer to a string value to store the parameter name. or NULL. This value might be "unknown", "none", "linear", "angular", "scale", "time" or "parametric"; + +### Returns +TRUE in case of success +""" function proj_uom_get_info_from_database(ctx, auth_name, code, out_name, out_conv_factor, out_category) ccall((:proj_uom_get_info_from_database, libproj), Cint, (Ptr{PJ_CONTEXT}, Cstring, Cstring, Ptr{Cstring}, Ptr{Cdouble}, Ptr{Cstring}), ctx, auth_name, code, out_name, out_conv_factor, out_category) end +""" + proj_clone(PJ_CONTEXT * ctx, + const PJ * obj) -> PJ * + +"Clone" an object. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **obj**: Object to clone. Must not be NULL. + +### Returns +Object that must be unreferenced with proj_destroy(), or NULL in case of error. +""" function proj_clone(ctx, obj) ccall((:proj_clone, libproj), Ptr{PJ}, (Ptr{PJ_CONTEXT}, Ptr{PJ}), ctx, obj) end +""" + proj_create_from_name(PJ_CONTEXT * ctx, + const char * auth_name, + const char * searchedName, + const PJ_TYPE * types, + size_t typesCount, + int approximateMatch, + size_t limitResultCount, + const char *const * options) -> PJ_OBJ_LIST * + +Return a list of objects by their name. + +### Parameters +* **ctx**: Context, or NULL for default context. +* **auth_name**: Authority name, used to restrict the search. Or NULL for all authorities. +* **searchedName**: Searched name. Must be at least 2 character long. +* **types**: List of object types into which to search. If NULL, all object types will be searched. +* **typesCount**: Number of elements in types, or 0 if types is NULL +* **approximateMatch**: Whether approximate name identification is allowed. +* **limitResultCount**: Maximum number of results to return. Or 0 for unlimited. +* **options**: should be set to NULL for now + +### Returns +a result set that must be unreferenced with proj_list_destroy(), or NULL in case of error. +""" function proj_create_from_name(ctx, auth_name, searchedName, types, typesCount, approximateMatch, limitResultCount, options) ccall((:proj_create_from_name, libproj), Ptr{PJ_OBJ_LIST}, (Ptr{PJ_CONTEXT}, Cstring, Cstring, Ptr{PJ_TYPE}, Csize_t, Cint, Csize_t, Ptr{Cstring}), ctx, auth_name, searchedName, types, typesCount, approximateMatch, limitResultCount, options) end +""" + proj_get_type(const PJ * obj) -> PJ_TYPE + +Return the type of an object. + +### Parameters +* **obj**: Object (must not be NULL) + +### Returns +its type. +""" function proj_get_type(obj) ccall((:proj_get_type, libproj), PJ_TYPE, (Ptr{PJ},), obj) end +""" + proj_is_deprecated(const PJ * obj) -> int + +Return whether an object is deprecated. + +### Parameters +* **obj**: Object (must not be NULL) + +### Returns +TRUE if it is deprecated, FALSE otherwise +""" function proj_is_deprecated(obj) ccall((:proj_is_deprecated, libproj), Cint, (Ptr{PJ},), obj) end +""" + proj_get_non_deprecated(PJ_CONTEXT * ctx, + const PJ * obj) -> PJ_OBJ_LIST * + +Return a list of non-deprecated objects related to the passed one. + +### Parameters +* **ctx**: Context, or NULL for default context. +* **obj**: Object (of type CRS for now) for which non-deprecated objects must be searched. Must not be NULL + +### Returns +a result set that must be unreferenced with proj_list_destroy(), or NULL in case of error. +""" function proj_get_non_deprecated(ctx, obj) ccall((:proj_get_non_deprecated, libproj), Ptr{PJ_OBJ_LIST}, (Ptr{PJ_CONTEXT}, Ptr{PJ}), ctx, obj) end +""" + proj_is_equivalent_to(const PJ * obj, + const PJ * other, + PJ_COMPARISON_CRITERION criterion) -> int + +Return whether two objects are equivalent. + +### Parameters +* **obj**: Object (must not be NULL) +* **other**: Other object (must not be NULL) +* **criterion**: Comparison criterion + +### Returns +TRUE if they are equivalent +""" function proj_is_equivalent_to(obj, other, criterion) ccall((:proj_is_equivalent_to, libproj), Cint, (Ptr{PJ}, Ptr{PJ}, PJ_COMPARISON_CRITERION), obj, other, criterion) end +""" + proj_is_crs(const PJ * obj) -> int + +Return whether an object is a CRS. + +### Parameters +* **obj**: Object (must not be NULL) +""" function proj_is_crs(obj) ccall((:proj_is_crs, libproj), Cint, (Ptr{PJ},), obj) end +""" + proj_get_name(const PJ * obj) -> const char * + +Get the name of an object. + +### Parameters +* **obj**: Object (must not be NULL) + +### Returns +a string, or NULL in case of error or missing name. +""" function proj_get_name(obj) - ccall((:proj_get_name, libproj), Cstring, (Ptr{PJ},), obj) + unsafe_string(ccall((:proj_get_name, libproj), Cstring, (Ptr{PJ},), obj)) end +""" + proj_get_id_auth_name(const PJ * obj, + int index) -> const char * + +Get the authority name / codespace of an identifier of an object. + +### Parameters +* **obj**: Object (must not be NULL) +* **index**: Index of the identifier. 0 = first identifier + +### Returns +a string, or NULL in case of error or missing name. +""" function proj_get_id_auth_name(obj, index) - ccall((:proj_get_id_auth_name, libproj), Cstring, (Ptr{PJ}, Cint), obj, index) + unsafe_string(ccall((:proj_get_id_auth_name, libproj), Cstring, (Ptr{PJ}, Cint), obj, index)) end -function proj_get_id_code(obj, index) - ccall((:proj_get_id_code, libproj), Cstring, (Ptr{PJ}, Cint), obj, index) -end +""" + proj_get_id_code(const PJ * obj, + int index) -> const char * + +Get the code of an identifier of an object. +### Parameters +* **obj**: Object (must not be NULL) +* **index**: Index of the identifier. 0 = first identifier + +### Returns +a string, or NULL in case of error or missing name. +""" +function proj_get_id_code(obj, index) + unsafe_string(ccall((:proj_get_id_code, libproj), Cstring, (Ptr{PJ}, Cint), obj, index)) +end + +""" + proj_get_area_of_use(PJ_CONTEXT * ctx, + const PJ * obj, + double * out_west_lon_degree, + double * out_south_lat_degree, + double * out_east_lon_degree, + double * out_north_lat_degree, + const char ** out_area_name) -> int + +Return the area of use of an object. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **obj**: Object (must not be NULL) +* **out_west_lon_degree**: Pointer to a double to receive the west longitude (in degrees). Or NULL. If the returned value is -1000, the bounding box is unknown. +* **out_south_lat_degree**: Pointer to a double to receive the south latitude (in degrees). Or NULL. If the returned value is -1000, the bounding box is unknown. +* **out_east_lon_degree**: Pointer to a double to receive the east longitude (in degrees). Or NULL. If the returned value is -1000, the bounding box is unknown. +* **out_north_lat_degree**: Pointer to a double to receive the north latitude (in degrees). Or NULL. If the returned value is -1000, the bounding box is unknown. +* **out_area_name**: Pointer to a string to receive the name of the area of use. Or NULL. *p_area_name is valid while obj is valid itself. + +### Returns +TRUE in case of success, FALSE in case of error or if the area of use is unknown. +""" function proj_get_area_of_use(ctx, obj, out_west_lon_degree, out_south_lat_degree, out_east_lon_degree, out_north_lat_degree, out_area_name) ccall((:proj_get_area_of_use, libproj), Cint, (Ptr{PJ_CONTEXT}, Ptr{PJ}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cstring}), ctx, obj, out_west_lon_degree, out_south_lat_degree, out_east_lon_degree, out_north_lat_degree, out_area_name) end +""" + proj_as_wkt(PJ_CONTEXT * ctx, + const PJ * obj, + PJ_WKT_TYPE type, + const char *const * options) -> const char * + +Get a WKT representation of an object. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **obj**: Object (must not be NULL) +* **type**: WKT version. +* **options**: null-terminated list of options, or NULL. Currently supported options are: + +MULTILINE=YES/NO. Defaults to YES, except for WKT1_ESRI + + +INDENTATION_WIDTH=number. Defauls to 4 (when multiline output is on). + + +OUTPUT_AXIS=AUTO/YES/NO. In AUTO mode, axis will be output for WKT2 variants, for WKT1_GDAL for ProjectedCRS with easting/northing ordering (otherwise stripped), but not for WKT1_ESRI. Setting to YES will output them unconditionally, and to NO will omit them unconditionally. + +### Returns +a string, or NULL in case of error. +""" function proj_as_wkt(ctx, obj, type, options) - ccall((:proj_as_wkt, libproj), Cstring, (Ptr{PJ_CONTEXT}, Ptr{PJ}, PJ_WKT_TYPE, Ptr{Cstring}), ctx, obj, type, options) + unsafe_string(ccall((:proj_as_wkt, libproj), Cstring, (Ptr{PJ_CONTEXT}, Ptr{PJ}, PJ_WKT_TYPE, Ptr{Cstring}), ctx, obj, type, options)) end +""" + proj_as_proj_string(PJ_CONTEXT * ctx, + const PJ * obj, + PJ_PROJ_STRING_TYPE type, + const char *const * options) -> const char * + +Get a PROJ string representation of an object. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **obj**: Object (must not be NULL) +* **type**: PROJ String version. +* **options**: NULL-terminated list of strings with "KEY=VALUE" format. or NULL. The currently recognized option is USE_APPROX_TMERC=YES to add the +approx flag to +proj=tmerc or +proj=utm + +### Returns +a string, or NULL in case of error. +""" function proj_as_proj_string(ctx, obj, type, options) - ccall((:proj_as_proj_string, libproj), Cstring, (Ptr{PJ_CONTEXT}, Ptr{PJ}, PJ_PROJ_STRING_TYPE, Ptr{Cstring}), ctx, obj, type, options) + unsafe_string(ccall((:proj_as_proj_string, libproj), Cstring, (Ptr{PJ_CONTEXT}, Ptr{PJ}, PJ_PROJ_STRING_TYPE, Ptr{Cstring}), ctx, obj, type, options)) end +""" + proj_get_source_crs(PJ_CONTEXT * ctx, + const PJ * obj) -> PJ * + +Return the base CRS of a BoundCRS or a DerivedCRS/ProjectedCRS, or the source CRS of a CoordinateOperation. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **obj**: Object of type BoundCRS or CoordinateOperation (must not be NULL) + +### Returns +Object that must be unreferenced with proj_destroy(), or NULL in case of error, or missing source CRS. +""" function proj_get_source_crs(ctx, obj) ccall((:proj_get_source_crs, libproj), Ptr{PJ}, (Ptr{PJ_CONTEXT}, Ptr{PJ}), ctx, obj) end +""" + proj_get_target_crs(PJ_CONTEXT * ctx, + const PJ * obj) -> PJ * + +Return the hub CRS of a BoundCRS or the target CRS of a CoordinateOperation. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **obj**: Object of type BoundCRS or CoordinateOperation (must not be NULL) + +### Returns +Object that must be unreferenced with proj_destroy(), or NULL in case of error, or missing target CRS. +""" function proj_get_target_crs(ctx, obj) ccall((:proj_get_target_crs, libproj), Ptr{PJ}, (Ptr{PJ_CONTEXT}, Ptr{PJ}), ctx, obj) end +""" + proj_identify(PJ_CONTEXT * ctx, + const PJ * obj, + const char * auth_name, + const char *const * options, + int ** out_confidence) -> PJ_OBJ_LIST * + +Identify the CRS with reference CRSs. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **obj**: Object of type CRS. Must not be NULL +* **auth_name**: Authority name, or NULL for all authorities +* **options**: Placeholder for future options. Should be set to NULL. +* **out_confidence**: Output parameter. Pointer to an array of integers that will be allocated by the function and filled with the confidence values (0-100). There are as many elements in this array as proj_list_get_count() returns on the return value of this function. *confidence should be released with proj_int_list_destroy(). + +### Returns +a list of matching reference CRS, or nullptr in case of error. +""" function proj_identify(ctx, obj, auth_name, options, out_confidence) ccall((:proj_identify, libproj), Ptr{PJ_OBJ_LIST}, (Ptr{PJ_CONTEXT}, Ptr{PJ}, Cstring, Ptr{Cstring}, Ptr{Ptr{Cint}}), ctx, obj, auth_name, options, out_confidence) end +""" + proj_int_list_destroy(int * list) -> void + +Free an array of integer. +""" function proj_int_list_destroy(list) ccall((:proj_int_list_destroy, libproj), Cvoid, (Ptr{Cint},), list) end +""" + proj_get_authorities_from_database(PJ_CONTEXT * ctx) -> PROJ_STRING_LIST + +Return the list of authorities used in the database. + +### Parameters +* **ctx**: PROJ context, or NULL for default context + +### Returns +a NULL terminated list of NUL-terminated strings that must be freed with proj_string_list_destroy(), or NULL in case of error. +""" function proj_get_authorities_from_database(ctx) ccall((:proj_get_authorities_from_database, libproj), PROJ_STRING_LIST, (Ptr{PJ_CONTEXT},), ctx) end +""" + proj_get_codes_from_database(PJ_CONTEXT * ctx, + const char * auth_name, + PJ_TYPE type, + int allow_deprecated) -> PROJ_STRING_LIST + +Returns the set of authority codes of the given object type. + +### Parameters +* **ctx**: PROJ context, or NULL for default context. +* **auth_name**: Authority name (must not be NULL) +* **type**: Object type. +* **allow_deprecated**: whether we should return deprecated objects as well. + +### Returns +a NULL terminated list of NUL-terminated strings that must be freed with proj_string_list_destroy(), or NULL in case of error. +""" function proj_get_codes_from_database(ctx, auth_name, type, allow_deprecated) ccall((:proj_get_codes_from_database, libproj), PROJ_STRING_LIST, (Ptr{PJ_CONTEXT}, Cstring, PJ_TYPE, Cint), ctx, auth_name, type, allow_deprecated) end +""" + proj_get_crs_list_parameters_create() -> PROJ_CRS_LIST_PARAMETERS * + +Instantiate a default set of parameters to be used by proj_get_crs_list(). + +### Returns +a new object to free with proj_get_crs_list_parameters_destroy() +""" function proj_get_crs_list_parameters_create() ccall((:proj_get_crs_list_parameters_create, libproj), Ptr{PROJ_CRS_LIST_PARAMETERS}, ()) end +""" + proj_get_crs_list_parameters_destroy(PROJ_CRS_LIST_PARAMETERS * params) -> void + +Destroy an object returned by proj_get_crs_list_parameters_create() +""" function proj_get_crs_list_parameters_destroy(params) ccall((:proj_get_crs_list_parameters_destroy, libproj), Cvoid, (Ptr{PROJ_CRS_LIST_PARAMETERS},), params) end +""" + proj_get_crs_info_list_from_database(PJ_CONTEXT * ctx, + const char * auth_name, + const PROJ_CRS_LIST_PARAMETERS * params, + int * out_result_count) -> PROJ_CRS_INFO ** + +Enumerate CRS objects from the database, taking into account various criteria. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **auth_name**: Authority name, used to restrict the search. Or NULL for all authorities. +* **params**: Additional criteria, or NULL. If not-NULL, params SHOULD have been allocated by proj_get_crs_list_parameters_create(), as the PROJ_CRS_LIST_PARAMETERS structure might grow over time. +* **out_result_count**: Output parameter pointing to an integer to receive the size of the result list. Might be NULL + +### Returns +an array of PROJ_CRS_INFO* pointers to be freed with proj_crs_info_list_destroy(), or NULL in case of error. +""" function proj_get_crs_info_list_from_database(ctx, auth_name, params, out_result_count) ccall((:proj_get_crs_info_list_from_database, libproj), Ptr{Ptr{PROJ_CRS_INFO}}, (Ptr{PJ_CONTEXT}, Cstring, Ptr{PROJ_CRS_LIST_PARAMETERS}, Ptr{Cint}), ctx, auth_name, params, out_result_count) end +""" + proj_crs_info_list_destroy(PROJ_CRS_INFO ** list) -> void + +Destroy the result returned by proj_get_crs_info_list_from_database(). +""" function proj_crs_info_list_destroy(list) ccall((:proj_crs_info_list_destroy, libproj), Cvoid, (Ptr{Ptr{PROJ_CRS_INFO}},), list) end +""" + proj_create_operation_factory_context(PJ_CONTEXT * ctx, + const char * authority) -> PJ_OPERATION_FACTORY_CONTEXT * + +Instantiate a context for building coordinate operations between two CRS. + +### Parameters +* **ctx**: Context, or NULL for default context. +* **authority**: Name of authority to which to restrict the search of candidate operations. + +### Returns +Object that must be unreferenced with proj_operation_factory_context_destroy(), or NULL in case of error. +""" function proj_create_operation_factory_context(ctx, authority) ccall((:proj_create_operation_factory_context, libproj), Ptr{PJ_OPERATION_FACTORY_CONTEXT}, (Ptr{PJ_CONTEXT}, Cstring), ctx, authority) end +""" + proj_operation_factory_context_destroy(PJ_OPERATION_FACTORY_CONTEXT * ctx) -> void + +Drops a reference on an object. + +### Parameters +* **ctx**: Object, or NULL. +""" function proj_operation_factory_context_destroy(ctx) ccall((:proj_operation_factory_context_destroy, libproj), Cvoid, (Ptr{PJ_OPERATION_FACTORY_CONTEXT},), ctx) end +""" + proj_operation_factory_context_set_desired_accuracy(PJ_CONTEXT * ctx, + PJ_OPERATION_FACTORY_CONTEXT * factory_ctx, + double accuracy) -> void + +Set the desired accuracy of the resulting coordinate transformations. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **factory_ctx**: Operation factory context. must not be NULL +* **accuracy**: Accuracy in meter (or 0 to disable the filter). +""" function proj_operation_factory_context_set_desired_accuracy(ctx, factory_ctx, accuracy) ccall((:proj_operation_factory_context_set_desired_accuracy, libproj), Cvoid, (Ptr{PJ_CONTEXT}, Ptr{PJ_OPERATION_FACTORY_CONTEXT}, Cdouble), ctx, factory_ctx, accuracy) end +""" + proj_operation_factory_context_set_area_of_interest(PJ_CONTEXT * ctx, + PJ_OPERATION_FACTORY_CONTEXT * factory_ctx, + double west_lon_degree, + double south_lat_degree, + double east_lon_degree, + double north_lat_degree) -> void + +Set the desired area of interest for the resulting coordinate transformations. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **factory_ctx**: Operation factory context. must not be NULL +* **west_lon_degree**: West longitude (in degrees). +* **south_lat_degree**: South latitude (in degrees). +* **east_lon_degree**: East longitude (in degrees). +* **north_lat_degree**: North latitude (in degrees). +""" function proj_operation_factory_context_set_area_of_interest(ctx, factory_ctx, west_lon_degree, south_lat_degree, east_lon_degree, north_lat_degree) ccall((:proj_operation_factory_context_set_area_of_interest, libproj), Cvoid, (Ptr{PJ_CONTEXT}, Ptr{PJ_OPERATION_FACTORY_CONTEXT}, Cdouble, Cdouble, Cdouble, Cdouble), ctx, factory_ctx, west_lon_degree, south_lat_degree, east_lon_degree, north_lat_degree) end +""" + proj_operation_factory_context_set_crs_extent_use(PJ_CONTEXT * ctx, + PJ_OPERATION_FACTORY_CONTEXT * factory_ctx, + PROJ_CRS_EXTENT_USE use) -> void + +Set how source and target CRS extent should be used when considering if a transformation can be used (only takes effect if no area of interest is explicitly defined). + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **factory_ctx**: Operation factory context. must not be NULL +* **use**: How source and target CRS extent should be used. +""" function proj_operation_factory_context_set_crs_extent_use(ctx, factory_ctx, use) ccall((:proj_operation_factory_context_set_crs_extent_use, libproj), Cvoid, (Ptr{PJ_CONTEXT}, Ptr{PJ_OPERATION_FACTORY_CONTEXT}, PROJ_CRS_EXTENT_USE), ctx, factory_ctx, use) end +""" + proj_operation_factory_context_set_spatial_criterion(PJ_CONTEXT * ctx, + PJ_OPERATION_FACTORY_CONTEXT * factory_ctx, + PROJ_SPATIAL_CRITERION criterion) -> void + +Set the spatial criterion to use when comparing the area of validity of coordinate operations with the area of interest / area of validity of source and target CRS. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **factory_ctx**: Operation factory context. must not be NULL +* **criterion**: patial criterion to use +""" function proj_operation_factory_context_set_spatial_criterion(ctx, factory_ctx, criterion) ccall((:proj_operation_factory_context_set_spatial_criterion, libproj), Cvoid, (Ptr{PJ_CONTEXT}, Ptr{PJ_OPERATION_FACTORY_CONTEXT}, PROJ_SPATIAL_CRITERION), ctx, factory_ctx, criterion) end +""" + proj_operation_factory_context_set_grid_availability_use(PJ_CONTEXT * ctx, + PJ_OPERATION_FACTORY_CONTEXT * factory_ctx, + PROJ_GRID_AVAILABILITY_USE use) -> void + +Set how grid availability is used. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **factory_ctx**: Operation factory context. must not be NULL +* **use**: how grid availability is used. +""" function proj_operation_factory_context_set_grid_availability_use(ctx, factory_ctx, use) ccall((:proj_operation_factory_context_set_grid_availability_use, libproj), Cvoid, (Ptr{PJ_CONTEXT}, Ptr{PJ_OPERATION_FACTORY_CONTEXT}, PROJ_GRID_AVAILABILITY_USE), ctx, factory_ctx, use) end +""" + proj_operation_factory_context_set_use_proj_alternative_grid_names(PJ_CONTEXT * ctx, + PJ_OPERATION_FACTORY_CONTEXT * factory_ctx, + int usePROJNames) -> void + +Set whether PROJ alternative grid names should be substituted to the official authority names. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **factory_ctx**: Operation factory context. must not be NULL +* **usePROJNames**: whether PROJ alternative grid names should be used +""" function proj_operation_factory_context_set_use_proj_alternative_grid_names(ctx, factory_ctx, usePROJNames) ccall((:proj_operation_factory_context_set_use_proj_alternative_grid_names, libproj), Cvoid, (Ptr{PJ_CONTEXT}, Ptr{PJ_OPERATION_FACTORY_CONTEXT}, Cint), ctx, factory_ctx, usePROJNames) end +""" + proj_operation_factory_context_set_allow_use_intermediate_crs(PJ_CONTEXT * ctx, + PJ_OPERATION_FACTORY_CONTEXT * factory_ctx, + PROJ_INTERMEDIATE_CRS_USE use) -> void + +Set whether an intermediate pivot CRS can be used for researching coordinate operations between a source and target CRS. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **factory_ctx**: Operation factory context. must not be NULL +* **use**: whether and how intermediate CRS may be used. +""" function proj_operation_factory_context_set_allow_use_intermediate_crs(ctx, factory_ctx, use) ccall((:proj_operation_factory_context_set_allow_use_intermediate_crs, libproj), Cvoid, (Ptr{PJ_CONTEXT}, Ptr{PJ_OPERATION_FACTORY_CONTEXT}, PROJ_INTERMEDIATE_CRS_USE), ctx, factory_ctx, use) end +""" + proj_operation_factory_context_set_allowed_intermediate_crs(PJ_CONTEXT * ctx, + PJ_OPERATION_FACTORY_CONTEXT * factory_ctx, + const char *const * list_of_auth_name_codes) -> void + +Restrict the potential pivot CRSs that can be used when trying to build a coordinate operation between two CRS that have no direct operation. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **factory_ctx**: Operation factory context. must not be NULL +* **list_of_auth_name_codes**: an array of strings NLL terminated, with the format { "auth_name1", "code1", "auth_name2", "code2", ... NULL } +""" function proj_operation_factory_context_set_allowed_intermediate_crs(ctx, factory_ctx, list_of_auth_name_codes) ccall((:proj_operation_factory_context_set_allowed_intermediate_crs, libproj), Cvoid, (Ptr{PJ_CONTEXT}, Ptr{PJ_OPERATION_FACTORY_CONTEXT}, Ptr{Cstring}), ctx, factory_ctx, list_of_auth_name_codes) end +""" + proj_create_operations(PJ_CONTEXT * ctx, + const PJ * source_crs, + const PJ * target_crs, + const PJ_OPERATION_FACTORY_CONTEXT * operationContext) -> PJ_OBJ_LIST * + +Find a list of CoordinateOperation from source_crs to target_crs. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **source_crs**: source CRS. Must not be NULL. +* **target_crs**: source CRS. Must not be NULL. +* **operationContext**: Search context. Must not be NULL. + +### Returns +a result set that must be unreferenced with proj_list_destroy(), or NULL in case of error. +""" function proj_create_operations(ctx, source_crs, target_crs, operationContext) ccall((:proj_create_operations, libproj), Ptr{PJ_OBJ_LIST}, (Ptr{PJ_CONTEXT}, Ptr{PJ}, Ptr{PJ}, Ptr{PJ_OPERATION_FACTORY_CONTEXT}), ctx, source_crs, target_crs, operationContext) end +""" + proj_list_get_count(const PJ_OBJ_LIST * result) -> int + +Return the number of objects in the result set. + +### Parameters +* **result**: Object of type PJ_OBJ_LIST (must not be NULL) +""" function proj_list_get_count(result) ccall((:proj_list_get_count, libproj), Cint, (Ptr{PJ_OBJ_LIST},), result) end +""" + proj_list_get(PJ_CONTEXT * ctx, + const PJ_OBJ_LIST * result, + int index) -> PJ * + +Return an object from the result set. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **result**: Object of type PJ_OBJ_LIST (must not be NULL) +* **index**: Index + +### Returns +a new object that must be unreferenced with proj_destroy(), or nullptr in case of error. +""" function proj_list_get(ctx, result, index) ccall((:proj_list_get, libproj), Ptr{PJ}, (Ptr{PJ_CONTEXT}, Ptr{PJ_OBJ_LIST}, Cint), ctx, result, index) end +""" + proj_list_destroy(PJ_OBJ_LIST * result) -> void + +Drops a reference on the result set. + +### Parameters +* **result**: Object, or NULL. +""" function proj_list_destroy(result) ccall((:proj_list_destroy, libproj), Cvoid, (Ptr{PJ_OBJ_LIST},), result) end +""" + proj_crs_get_geodetic_crs(PJ_CONTEXT * ctx, + const PJ * crs) -> PJ * + +Get the geodeticCRS / geographicCRS from a CRS. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **crs**: Object of type CRS (must not be NULL) + +### Returns +Object that must be unreferenced with proj_destroy(), or NULL in case of error. +""" function proj_crs_get_geodetic_crs(ctx, crs) ccall((:proj_crs_get_geodetic_crs, libproj), Ptr{PJ}, (Ptr{PJ_CONTEXT}, Ptr{PJ}), ctx, crs) end +""" + proj_crs_get_horizontal_datum(PJ_CONTEXT * ctx, + const PJ * crs) -> PJ * + +Get the horizontal datum from a CRS. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **crs**: Object of type CRS (must not be NULL) + +### Returns +Object that must be unreferenced with proj_destroy(), or NULL in case of error. +""" function proj_crs_get_horizontal_datum(ctx, crs) ccall((:proj_crs_get_horizontal_datum, libproj), Ptr{PJ}, (Ptr{PJ_CONTEXT}, Ptr{PJ}), ctx, crs) end +""" + proj_crs_get_sub_crs(PJ_CONTEXT * ctx, + const PJ * crs, + int index) -> PJ * + +Get a CRS component from a CompoundCRS. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **crs**: Object of type CRS (must not be NULL) +* **index**: Index of the CRS component (typically 0 = horizontal, 1 = vertical) + +### Returns +Object that must be unreferenced with proj_destroy(), or NULL in case of error. +""" function proj_crs_get_sub_crs(ctx, crs, index) ccall((:proj_crs_get_sub_crs, libproj), Ptr{PJ}, (Ptr{PJ_CONTEXT}, Ptr{PJ}, Cint), ctx, crs, index) end +""" + proj_crs_get_datum(PJ_CONTEXT * ctx, + const PJ * crs) -> PJ * + +Returns the datum of a SingleCRS. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **crs**: Object of type SingleCRS (must not be NULL) + +### Returns +Object that must be unreferenced with proj_destroy(), or NULL in case of error (or if there is no datum) +""" function proj_crs_get_datum(ctx, crs) ccall((:proj_crs_get_datum, libproj), Ptr{PJ}, (Ptr{PJ_CONTEXT}, Ptr{PJ}), ctx, crs) end +""" + proj_crs_get_coordinate_system(PJ_CONTEXT * ctx, + const PJ * crs) -> PJ * + +Returns the coordinate system of a SingleCRS. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **crs**: Object of type SingleCRS (must not be NULL) + +### Returns +Object that must be unreferenced with proj_destroy(), or NULL in case of error. +""" function proj_crs_get_coordinate_system(ctx, crs) ccall((:proj_crs_get_coordinate_system, libproj), Ptr{PJ}, (Ptr{PJ_CONTEXT}, Ptr{PJ}), ctx, crs) end +""" + proj_cs_get_type(PJ_CONTEXT * ctx, + const PJ * cs) -> PJ_COORDINATE_SYSTEM_TYPE + +Returns the type of the coordinate system. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **cs**: Object of type CoordinateSystem (must not be NULL) + +### Returns +type, or PJ_CS_TYPE_UNKNOWN in case of error. +""" function proj_cs_get_type(ctx, cs) ccall((:proj_cs_get_type, libproj), PJ_COORDINATE_SYSTEM_TYPE, (Ptr{PJ_CONTEXT}, Ptr{PJ}), ctx, cs) end +""" + proj_cs_get_axis_count(PJ_CONTEXT * ctx, + const PJ * cs) -> int + +Returns the number of axis of the coordinate system. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **cs**: Object of type CoordinateSystem (must not be NULL) + +### Returns +number of axis, or -1 in case of error. +""" function proj_cs_get_axis_count(ctx, cs) ccall((:proj_cs_get_axis_count, libproj), Cint, (Ptr{PJ_CONTEXT}, Ptr{PJ}), ctx, cs) end +""" + proj_cs_get_axis_info(PJ_CONTEXT * ctx, + const PJ * cs, + int index, + const char ** out_name, + const char ** out_abbrev, + const char ** out_direction, + double * out_unit_conv_factor, + const char ** out_unit_name, + const char ** out_unit_auth_name, + const char ** out_unit_code) -> int + +Returns information on an axis. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **cs**: Object of type CoordinateSystem (must not be NULL) +* **index**: Index of the coordinate system (between 0 and proj_cs_get_axis_count() - 1) +* **out_name**: Pointer to a string value to store the axis name. or NULL +* **out_abbrev**: Pointer to a string value to store the axis abbreviation. or NULL +* **out_direction**: Pointer to a string value to store the axis direction. or NULL +* **out_unit_conv_factor**: Pointer to a double value to store the axis unit conversion factor. or NULL +* **out_unit_name**: Pointer to a string value to store the axis unit name. or NULL +* **out_unit_auth_name**: Pointer to a string value to store the axis unit authority name. or NULL +* **out_unit_code**: Pointer to a string value to store the axis unit code. or NULL + +### Returns +TRUE in case of success +""" function proj_cs_get_axis_info(ctx, cs, index, out_name, out_abbrev, out_direction, out_unit_conv_factor, out_unit_name, out_unit_auth_name, out_unit_code) ccall((:proj_cs_get_axis_info, libproj), Cint, (Ptr{PJ_CONTEXT}, Ptr{PJ}, Cint, Ptr{Cstring}, Ptr{Cstring}, Ptr{Cstring}, Ptr{Cdouble}, Ptr{Cstring}, Ptr{Cstring}, Ptr{Cstring}), ctx, cs, index, out_name, out_abbrev, out_direction, out_unit_conv_factor, out_unit_name, out_unit_auth_name, out_unit_code) end +""" + proj_get_ellipsoid(PJ_CONTEXT * ctx, + const PJ * obj) -> PJ * + +Get the ellipsoid from a CRS or a GeodeticReferenceFrame. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **obj**: Object of type CRS or GeodeticReferenceFrame (must not be NULL) + +### Returns +Object that must be unreferenced with proj_destroy(), or NULL in case of error. +""" function proj_get_ellipsoid(ctx, obj) ccall((:proj_get_ellipsoid, libproj), Ptr{PJ}, (Ptr{PJ_CONTEXT}, Ptr{PJ}), ctx, obj) end +""" + proj_ellipsoid_get_parameters(PJ_CONTEXT * ctx, + const PJ * ellipsoid, + double * out_semi_major_metre, + double * out_semi_minor_metre, + int * out_is_semi_minor_computed, + double * out_inv_flattening) -> int + +Return ellipsoid parameters. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **ellipsoid**: Object of type Ellipsoid (must not be NULL) +* **out_semi_major_metre**: Pointer to a value to store the semi-major axis in metre. or NULL +* **out_semi_minor_metre**: Pointer to a value to store the semi-minor axis in metre. or NULL +* **out_is_semi_minor_computed**: Pointer to a boolean value to indicate if the semi-minor value was computed. If FALSE, its value comes from the definition. or NULL +* **out_inv_flattening**: Pointer to a value to store the inverse flattening. or NULL + +### Returns +TRUE in case of success. +""" function proj_ellipsoid_get_parameters(ctx, ellipsoid, out_semi_major_metre, out_semi_minor_metre, out_is_semi_minor_computed, out_inv_flattening) ccall((:proj_ellipsoid_get_parameters, libproj), Cint, (Ptr{PJ_CONTEXT}, Ptr{PJ}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cint}, Ptr{Cdouble}), ctx, ellipsoid, out_semi_major_metre, out_semi_minor_metre, out_is_semi_minor_computed, out_inv_flattening) end +""" + proj_get_prime_meridian(PJ_CONTEXT * ctx, + const PJ * obj) -> PJ * + +Get the prime meridian of a CRS or a GeodeticReferenceFrame. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **obj**: Object of type CRS or GeodeticReferenceFrame (must not be NULL) + +### Returns +Object that must be unreferenced with proj_destroy(), or NULL in case of error. +""" function proj_get_prime_meridian(ctx, obj) ccall((:proj_get_prime_meridian, libproj), Ptr{PJ}, (Ptr{PJ_CONTEXT}, Ptr{PJ}), ctx, obj) end +""" + proj_prime_meridian_get_parameters(PJ_CONTEXT * ctx, + const PJ * prime_meridian, + double * out_longitude, + double * out_unit_conv_factor, + const char ** out_unit_name) -> int + +Return prime meridian parameters. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **prime_meridian**: Object of type PrimeMeridian (must not be NULL) +* **out_longitude**: Pointer to a value to store the longitude of the prime meridian, in its native unit. or NULL +* **out_unit_conv_factor**: Pointer to a value to store the conversion factor of the prime meridian longitude unit to radian. or NULL +* **out_unit_name**: Pointer to a string value to store the unit name. or NULL + +### Returns +TRUE in case of success. +""" function proj_prime_meridian_get_parameters(ctx, prime_meridian, out_longitude, out_unit_conv_factor, out_unit_name) ccall((:proj_prime_meridian_get_parameters, libproj), Cint, (Ptr{PJ_CONTEXT}, Ptr{PJ}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cstring}), ctx, prime_meridian, out_longitude, out_unit_conv_factor, out_unit_name) end +""" + proj_crs_get_coordoperation(PJ_CONTEXT * ctx, + const PJ * crs) -> PJ * + +Return the Conversion of a DerivedCRS (such as a ProjectedCRS), or the Transformation from the baseCRS to the hubCRS of a BoundCRS. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **crs**: Object of type DerivedCRS or BoundCRSs (must not be NULL) + +### Returns +Object of type SingleOperation that must be unreferenced with proj_destroy(), or NULL in case of error. +""" function proj_crs_get_coordoperation(ctx, crs) ccall((:proj_crs_get_coordoperation, libproj), Ptr{PJ}, (Ptr{PJ_CONTEXT}, Ptr{PJ}), ctx, crs) end +""" + proj_coordoperation_get_method_info(PJ_CONTEXT * ctx, + const PJ * coordoperation, + const char ** out_method_name, + const char ** out_method_auth_name, + const char ** out_method_code) -> int + +Return information on the operation method of the SingleOperation. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **coordoperation**: Object of type SingleOperation (typically a Conversion or Transformation) (must not be NULL) +* **out_method_name**: Pointer to a string value to store the method (projection) name. or NULL +* **out_method_auth_name**: Pointer to a string value to store the method authority name. or NULL +* **out_method_code**: Pointer to a string value to store the method code. or NULL + +### Returns +TRUE in case of success. +""" function proj_coordoperation_get_method_info(ctx, coordoperation, out_method_name, out_method_auth_name, out_method_code) ccall((:proj_coordoperation_get_method_info, libproj), Cint, (Ptr{PJ_CONTEXT}, Ptr{PJ}, Ptr{Cstring}, Ptr{Cstring}, Ptr{Cstring}), ctx, coordoperation, out_method_name, out_method_auth_name, out_method_code) end +""" + proj_coordoperation_is_instantiable(PJ_CONTEXT * ctx, + const PJ * coordoperation) -> int + +Return whether a coordinate operation can be instantiated as a PROJ pipeline, checking in particular that referenced grids are available. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **coordoperation**: Object of type CoordinateOperation or derived classes (must not be NULL) + +### Returns +TRUE or FALSE. +""" function proj_coordoperation_is_instantiable(ctx, coordoperation) ccall((:proj_coordoperation_is_instantiable, libproj), Cint, (Ptr{PJ_CONTEXT}, Ptr{PJ}), ctx, coordoperation) end +""" + proj_coordoperation_has_ballpark_transformation(PJ_CONTEXT * ctx, + const PJ * coordoperation) -> int + +Return whether a coordinate operation has a "ballpark" transformation, that is a very approximate one, due to lack of more accurate transformations. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **coordoperation**: Object of type CoordinateOperation or derived classes (must not be NULL) + +### Returns +TRUE or FALSE. +""" function proj_coordoperation_has_ballpark_transformation(ctx, coordoperation) ccall((:proj_coordoperation_has_ballpark_transformation, libproj), Cint, (Ptr{PJ_CONTEXT}, Ptr{PJ}), ctx, coordoperation) end +""" + proj_coordoperation_get_param_count(PJ_CONTEXT * ctx, + const PJ * coordoperation) -> int + +Return the number of parameters of a SingleOperation. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **coordoperation**: Object of type SingleOperation or derived classes (must not be NULL) +""" function proj_coordoperation_get_param_count(ctx, coordoperation) ccall((:proj_coordoperation_get_param_count, libproj), Cint, (Ptr{PJ_CONTEXT}, Ptr{PJ}), ctx, coordoperation) end +""" + proj_coordoperation_get_param_index(PJ_CONTEXT * ctx, + const PJ * coordoperation, + const char * name) -> int + +Return the index of a parameter of a SingleOperation. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **coordoperation**: Object of type SingleOperation or derived classes (must not be NULL) +* **name**: Parameter name. Must not be NULL + +### Returns +index (>=0), or -1 in case of error. +""" function proj_coordoperation_get_param_index(ctx, coordoperation, name) ccall((:proj_coordoperation_get_param_index, libproj), Cint, (Ptr{PJ_CONTEXT}, Ptr{PJ}, Cstring), ctx, coordoperation, name) end +""" + proj_coordoperation_get_param(PJ_CONTEXT * ctx, + const PJ * coordoperation, + int index, + const char ** out_name, + const char ** out_auth_name, + const char ** out_code, + double * out_value, + const char ** out_value_string, + double * out_unit_conv_factor, + const char ** out_unit_name, + const char ** out_unit_auth_name, + const char ** out_unit_code, + const char ** out_unit_category) -> int + +Return a parameter of a SingleOperation. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **coordoperation**: Object of type SingleOperation or derived classes (must not be NULL) +* **index**: Parameter index. +* **out_name**: Pointer to a string value to store the parameter name. or NULL +* **out_auth_name**: Pointer to a string value to store the parameter authority name. or NULL +* **out_code**: Pointer to a string value to store the parameter code. or NULL +* **out_value**: Pointer to a double value to store the parameter value (if numeric). or NULL +* **out_value_string**: Pointer to a string value to store the parameter value (if of type string). or NULL +* **out_unit_conv_factor**: Pointer to a double value to store the parameter unit conversion factor. or NULL +* **out_unit_name**: Pointer to a string value to store the parameter unit name. or NULL +* **out_unit_auth_name**: Pointer to a string value to store the unit authority name. or NULL +* **out_unit_code**: Pointer to a string value to store the unit code. or NULL +* **out_unit_category**: Pointer to a string value to store the parameter name. or NULL. This value might be "unknown", "none", "linear", "angular", "scale", "time" or "parametric"; + +### Returns +TRUE in case of success. +""" function proj_coordoperation_get_param(ctx, coordoperation, index, out_name, out_auth_name, out_code, out_value, out_value_string, out_unit_conv_factor, out_unit_name, out_unit_auth_name, out_unit_code, out_unit_category) ccall((:proj_coordoperation_get_param, libproj), Cint, (Ptr{PJ_CONTEXT}, Ptr{PJ}, Cint, Ptr{Cstring}, Ptr{Cstring}, Ptr{Cstring}, Ptr{Cdouble}, Ptr{Cstring}, Ptr{Cdouble}, Ptr{Cstring}, Ptr{Cstring}, Ptr{Cstring}, Ptr{Cstring}), ctx, coordoperation, index, out_name, out_auth_name, out_code, out_value, out_value_string, out_unit_conv_factor, out_unit_name, out_unit_auth_name, out_unit_code, out_unit_category) end +""" + proj_coordoperation_get_grid_used_count(PJ_CONTEXT * ctx, + const PJ * coordoperation) -> int + +Return the number of grids used by a CoordinateOperation. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **coordoperation**: Object of type CoordinateOperation or derived classes (must not be NULL) +""" function proj_coordoperation_get_grid_used_count(ctx, coordoperation) ccall((:proj_coordoperation_get_grid_used_count, libproj), Cint, (Ptr{PJ_CONTEXT}, Ptr{PJ}), ctx, coordoperation) end +""" + proj_coordoperation_get_grid_used(PJ_CONTEXT * ctx, + const PJ * coordoperation, + int index, + const char ** out_short_name, + const char ** out_full_name, + const char ** out_package_name, + const char ** out_url, + int * out_direct_download, + int * out_open_license, + int * out_available) -> int + +Return a parameter of a SingleOperation. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **coordoperation**: Object of type SingleOperation or derived classes (must not be NULL) +* **index**: Parameter index. +* **out_short_name**: Pointer to a string value to store the grid short name. or NULL +* **out_full_name**: Pointer to a string value to store the grid full filename. or NULL +* **out_package_name**: Pointer to a string value to store the package name where the grid might be found. or NULL +* **out_url**: Pointer to a string value to store the grid URL or the package URL where the grid might be found. or NULL +* **out_direct_download**: Pointer to a int (boolean) value to store whether *out_url can be downloaded directly. or NULL +* **out_open_license**: Pointer to a int (boolean) value to store whether the grid is released with an open license. or NULL +* **out_available**: Pointer to a int (boolean) value to store whether the grid is available at runtime. or NULL + +### Returns +TRUE in case of success. +""" function proj_coordoperation_get_grid_used(ctx, coordoperation, index, out_short_name, out_full_name, out_package_name, out_url, out_direct_download, out_open_license, out_available) ccall((:proj_coordoperation_get_grid_used, libproj), Cint, (Ptr{PJ_CONTEXT}, Ptr{PJ}, Cint, Ptr{Cstring}, Ptr{Cstring}, Ptr{Cstring}, Ptr{Cstring}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}), ctx, coordoperation, index, out_short_name, out_full_name, out_package_name, out_url, out_direct_download, out_open_license, out_available) end +""" + proj_coordoperation_get_accuracy(PJ_CONTEXT * ctx, + const PJ * coordoperation) -> double + +Return the accuracy (in metre) of a coordinate operation. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **coordoperation**: Coordinate operation. Must not be NULL. + +### Returns +the accuracy, or a negative value if unknown or in case of error. +""" function proj_coordoperation_get_accuracy(ctx, obj) ccall((:proj_coordoperation_get_accuracy, libproj), Cdouble, (Ptr{PJ_CONTEXT}, Ptr{PJ}), ctx, obj) end +""" + proj_coordoperation_get_towgs84_values(PJ_CONTEXT * ctx, + const PJ * coordoperation, + double * out_values, + int value_count, + int emit_error_if_incompatible) -> int + +Return the parameters of a Helmert transformation as WKT1 TOWGS84 values. + +### Parameters +* **ctx**: PROJ context, or NULL for default context +* **coordoperation**: Object of type Transformation, that can be represented as a WKT1 TOWGS84 node (must not be NULL) +* **out_values**: Pointer to an array of value_count double values. +* **value_count**: Size of out_values array. The suggested size is 7 to get translation, rotation and scale difference parameters. Rotation and scale difference terms might be zero if the transformation only includes translation parameters. In that case, value_count could be set to 3. +* **emit_error_if_incompatible**: Boolean to inicate if an error must be logged if coordoperation is not compatible with a WKT1 TOWGS84 representation. + +### Returns +TRUE in case of success, or FALSE if coordoperation is not compatible with a WKT1 TOWGS84 representation. +""" function proj_coordoperation_get_towgs84_values(ctx, coordoperation, out_values, value_count, emit_error_if_incompatible) ccall((:proj_coordoperation_get_towgs84_values, libproj), Cint, (Ptr{PJ_CONTEXT}, Ptr{PJ}, Ptr{Cdouble}, Cint, Cint), ctx, coordoperation, out_values, value_count, emit_error_if_incompatible) end diff --git a/src/proj_common.jl b/src/proj_common.jl index 9830e21..2ac176a 100644 --- a/src/proj_common.jl +++ b/src/proj_common.jl @@ -194,8 +194,10 @@ const proj_file_finder = Ptr{Cvoid} end +"Type representing a NULL terminated list of NULL-terminate strings" const PROJ_STRING_LIST = Ptr{Cstring} +"Guessed WKT \"dialect\"" @cenum PJ_GUESSED_WKT_DIALECT::UInt32 begin PJ_GUESSED_WKT2_2018 = 0 PJ_GUESSED_WKT2_2015 = 1 @@ -204,6 +206,8 @@ const PROJ_STRING_LIST = Ptr{Cstring} PJ_GUESSED_NOT_WKT = 4 end + +"Object category" @cenum PJ_CATEGORY::UInt32 begin PJ_CATEGORY_ELLIPSOID = 0 PJ_CATEGORY_PRIME_MERIDIAN = 1 @@ -212,6 +216,8 @@ end PJ_CATEGORY_COORDINATE_OPERATION = 4 end + +"Object type" @cenum PJ_TYPE::UInt32 begin PJ_TYPE_UNKNOWN = 0 PJ_TYPE_ELLIPSOID = 1 @@ -246,6 +252,8 @@ end PJ_COMP_EQUIVALENT_EXCEPT_AXIS_ORDER_GEOGCRS = 2 end + +"WKT version" @cenum PJ_WKT_TYPE::UInt32 begin PJ_WKT2_2015 = 0 PJ_WKT2_2015_SIMPLIFIED = 1 @@ -268,6 +276,8 @@ end PROJ_GRID_AVAILABILITY_IGNORED = 2 end + +"PROJ string version" @cenum PJ_PROJ_STRING_TYPE::UInt32 begin PJ_PROJ_5 = 0 PJ_PROJ_4 = 1