yeesian / GDALUtils.jl

Convenience utilities for GDAL in Julia
Other
0 stars 1 forks source link

list creation options in display of drivers at the REPL #1

Open yeesian opened 8 years ago

yeesian commented 8 years ago
julia> r = LightXML.parse_string(GU.options(GU.driver("GTiff")))

julia> collect(child_elements(root(r)))
35-element Array{Any,1}:
 <Option name="COMPRESS" type="string-select">       <Value>NONE</Value>
<Value>LZW</Value>       <Value>PACKBITS</Value>       <Value>JPEG</Value>
<Value>CCITTRLE</Value>       <Value>CCITTFAX3</Value>       <Value>CCITTFAX4</Value>
<Value>DEFLATE</Value>   </Option>
 <Option name="PREDICTOR" type="int" description="Predictor Type (1=default, 2=horizontal
differencing, 3=floating point prediction)"/>
[...]

julia> collect(child_elements(root(r)))[3]
<Option name="DISCARD_LSB" type="string" description="Number of least-significant bits to 
set to clear as a single value or comma-separated list of values for per-band values"/>

julia> options = [attribute(child, "name") for child in collect(child_elements(root(r)))]
35-element Array{Union{ASCIIString,UTF8String,Void},1}:
 "COMPRESS"
 "PREDICTOR"
 "DISCARD_LSB"
 "JPEG_QUALITY"
 "JPEGTABLESMODE"
 "ZLEVEL"
 "NUM_THREADS"
 "NBITS"
 "INTERLEAVE"
 "TILED"
 ⋮
 "SOURCE_PRIMARIES_GREEN"
 "SOURCE_PRIMARIES_BLUE"
 "SOURCE_WHITEPOINT"
 "TIFFTAG_TRANSFERFUNCTION_RED"
 "TIFFTAG_TRANSFERFUNCTION_GREEN"
 "TIFFTAG_TRANSFERFUNCTION_BLUE"
 "TIFFTAG_TRANSFERRANGE_BLACK"
 "TIFFTAG_TRANSFERRANGE_WHITE"
 "STREAMABLE_OUTPUT"
 "GEOTIFF_KEYS_FLAVOR"

julia> print(options)
Union{ASCIIString,UTF8String,Void}["COMPRESS","PREDICTOR","DISCARD_LSB","JPEG_QUALITY",
"JPEGTABLESMODE","ZLEVEL","NUM_THREADS","NBITS","INTERLEAVE","TILED","TFW","RPB",
"RPCTXT","BLOCKXSIZE","BLOCKYSIZE","PHOTOMETRIC","SPARSE_OK","ALPHA","PROFILE",
"PIXELTYPE","BIGTIFF","ENDIANNESS","COPY_SRC_OVERVIEWS","SOURCE_ICC_PROFILE",
"SOURCE_PRIMARIES_RED","SOURCE_PRIMARIES_GREEN","SOURCE_PRIMARIES_BLUE",
"SOURCE_WHITEPOINT","TIFFTAG_TRANSFERFUNCTION_RED","TIFFTAG_TRANSFERFUNCTION_GREEN",
"TIFFTAG_TRANSFERFUNCTION_BLUE","TIFFTAG_TRANSFERRANGE_BLACK",
"TIFFTAG_TRANSFERRANGE_WHITE","STREAMABLE_OUTPUT","GEOTIFF_KEYS_FLAVOR"]
yeesian commented 8 years ago

will need a way to decide

  1. which options to display,
  2. how to display possible values and descriptions
  3. what might be the default value (if any)

See http://geoserver.geo-solutions.it/edu/en/raster_data/processing.html#gdalinfo-getting-drivers-capabilities

yeesian commented 8 years ago

Some work by running:

import ArchGDAL; const AG = ArchGDAL
using LightXML

AG.registerdrivers() do
    for i in 0:(AG.ndriver()-1)
        println(AG.getdriver(i))
        xmlstr = AG.options(AG.getdriver(i))
        try
            if xmlstr != ""
                for c in LightXML.child_elements(LightXML.root(LightXML.parse_string(xmlstr)))
                    coption = LightXML.attribute(c, "name")
                    ctype = LightXML.attribute(c, "type")
                    cdesc = LightXML.attribute(c, "description")
                    print("  $coption <$ctype>: ")
                    if cdesc == nothing
                        print("possible values: ")
                        for v in LightXML.child_elements(c)
                            print("$(LightXML.content(v)),")
                        end
                        println()
                    else
                        println(cdesc)
                    end
                end
            end
        catch
            println(xmlstr)
        end
    end
end

Yields the following list of errors:

Entity: line 1: parser error : Attribute default redefined
fault='GTiff' description='GDAL driver to use for storing tiles' default='GTiff'
                                                                               ^
Entity: line 1: parser error : Attribute default redefined
MPRESS' type='string' default='(GTiff driver) Compression method' default='NONE'
                                                                               ^
Entity: line 1: parser error : Unescaped '<' not allowed in attributes values
on name='WRITE_FEATURE_BOUNDED_BY' type='boolean' description='Whether to write
                                                                               ^
Entity: line 1: parser error : attributes construct error
on name='WRITE_FEATURE_BOUNDED_BY' type='boolean' description='Whether to write
                                                                               ^
Entity: line 1: parser error : Couldn't find end of Start Tag Option line 1
on name='WRITE_FEATURE_BOUNDED_BY' type='boolean' description='Whether to write
                                                                               ^
namespace error : Namespace prefix gml on boundedBy is not defined
_FEATURE_BOUNDED_BY' type='boolean' description='Whether to write <gml:boundedBy
                                                                               ^
Entity: line 1: parser error : Opening and ending tag mismatch: boundedBy line 1 and CreationOptionList
Entity: line 1: parser error : Premature end of data in tag CreationOptionList line 1
Entity: line 1: parser error : Unescaped '<' not allowed in attributes values
TENSIONS' type='boolean' description='Whether to write non-GPX attributes in an
                                                                               ^
Entity: line 1: parser error : attributes construct error
TENSIONS' type='boolean' description='Whether to write non-GPX attributes in an
                                                                               ^
Entity: line 1: parser error : Couldn't find end of Start Tag Option line 1
TENSIONS' type='boolean' description='Whether to write non-GPX attributes in an
                                                                               ^
Entity: line 1: parser error : Opening and ending tag mismatch: extensions line 1 and CreationOptionList
Entity: line 1: parser error : Premature end of data in tag CreationOptionList line 1
Entity: line 1: parser error : Unescaped '<' not allowed in attributes values
TENSIONS' type='boolean' description='Whether to write non-GPX attributes in an
                                                                               ^
Entity: line 1: parser error : attributes construct error
TENSIONS' type='boolean' description='Whether to write non-GPX attributes in an
                                                                               ^
Entity: line 1: parser error : Couldn't find end of Start Tag Option line 1
TENSIONS' type='boolean' description='Whether to write non-GPX attributes in an
                                                                               ^
Entity: line 1: parser error : Unescaped '<' not allowed in attributes values
Option name='NameField' type='string' description='Field to use to fill the KML
                                                                               ^
Entity: line 1: parser error : attributes construct error
Option name='NameField' type='string' description='Field to use to fill the KML
                                                                               ^
Entity: line 1: parser error : Couldn't find end of Start Tag Option line 1
Option name='NameField' type='string' description='Field to use to fill the KML
                                                                               ^
Entity: line 1: parser error : Unescaped '<' not allowed in attributes values
name='DescriptionField' type='string' description='Field to use to fill the KML
                                                                               ^
Entity: line 1: parser error : attributes construct error
name='DescriptionField' type='string' description='Field to use to fill the KML
                                                                               ^
Entity: line 1: parser error : Couldn't find end of Start Tag Option line 1
name='DescriptionField' type='string' description='Field to use to fill the KML
                                                                               ^
Entity: line 1: parser error : Unescaped '<' not allowed in attributes values
'/>  <Option name='AltitudeMode' type='string-select' description='Value of the
                                                                               ^
Entity: line 1: parser error : attributes construct error
'/>  <Option name='AltitudeMode' type='string-select' description='Value of the
                                                                               ^
Entity: line 1: parser error : Couldn't find end of Start Tag Option line 1
'/>  <Option name='AltitudeMode' type='string-select' description='Value of the
                                                                               ^
Entity: line 1: parser error : Opening and ending tag mismatch: AltitudeMode line 1 and Option
/Value>    <Value>relativeToGround</Value>    <Value>absolute</Value>  </Option>
                                                                               ^
Entity: line 1: parser error : Opening and ending tag mismatch: description line 1 and CreationOptionList
Entity: line 1: parser error : Premature end of data in tag name line 1
Entity: line 1: parser error : Premature end of data in tag extensions line 1
Entity: line 1: parser error : Premature end of data in tag CreationOptionList line 1
Entity: line 1: parser error : Unescaped '<' not allowed in attributes values
me='HEADER' type='string' description='XML content that will be put between the
                                                                               ^
Entity: line 1: parser error : attributes construct error
me='HEADER' type='string' description='XML content that will be put between the
                                                                               ^
Entity: line 1: parser error : Couldn't find end of Start Tag Option line 1
me='HEADER' type='string' description='XML content that will be put between the
                                                                               ^
Entity: line 1: parser error : Unescaped '<' not allowed in attributes values
ptions'/>  <Option name='TITLE' type='string' description='value put inside the
                                                                               ^
Entity: line 1: parser error : attributes construct error
ptions'/>  <Option name='TITLE' type='string' description='value put inside the
                                                                               ^
Entity: line 1: parser error : Couldn't find end of Start Tag Option line 1
ptions'/>  <Option name='TITLE' type='string' description='value put inside the
                                                                               ^
Entity: line 1: parser error : Unescaped '<' not allowed in attributes values
n name='DESCRIPTION' type='string' description='(RSS only) value put inside the
                                                                               ^
Entity: line 1: parser error : attributes construct error
n name='DESCRIPTION' type='string' description='(RSS only) value put inside the
                                                                               ^
Entity: line 1: parser error : Couldn't find end of Start Tag Option line 1
n name='DESCRIPTION' type='string' description='(RSS only) value put inside the
                                                                               ^
Entity: line 1: parser error : Unescaped '<' not allowed in attributes values
 <Option name='LINK' type='string' description='(RSS only) value put inside the
                                                                               ^
Entity: line 1: parser error : attributes construct error
 <Option name='LINK' type='string' description='(RSS only) value put inside the
                                                                               ^
Entity: line 1: parser error : Couldn't find end of Start Tag Option line 1
 <Option name='LINK' type='string' description='(RSS only) value put inside the
                                                                               ^
Entity: line 1: parser error : Unescaped '<' not allowed in attributes values
ption name='UPDATED' type='string' description='(RSS only) value put inside the
                                                                               ^
Entity: line 1: parser error : attributes construct error
ption name='UPDATED' type='string' description='(RSS only) value put inside the
                                                                               ^
Entity: line 1: parser error : Couldn't find end of Start Tag Option line 1
ption name='UPDATED' type='string' description='(RSS only) value put inside the
                                                                               ^
Entity: line 1: parser error : Unescaped '<' not allowed in attributes values
 name='AUTHOR_NAME' type='string' description='(ATOM only) value put inside the
                                                                               ^
Entity: line 1: parser error : attributes construct error
 name='AUTHOR_NAME' type='string' description='(ATOM only) value put inside the
                                                                               ^
Entity: line 1: parser error : Couldn't find end of Start Tag Option line 1
 name='AUTHOR_NAME' type='string' description='(ATOM only) value put inside the
                                                                               ^
Entity: line 1: parser error : Unescaped '<' not allowed in attributes values
  <Option name='ID' type='string' description='(ATOM only) value put inside the
                                                                               ^
Entity: line 1: parser error : attributes construct error
  <Option name='ID' type='string' description='(ATOM only) value put inside the
                                                                               ^
Entity: line 1: parser error : Couldn't find end of Start Tag Option line 1
  <Option name='ID' type='string' description='(ATOM only) value put inside the
                                                                               ^
Entity: line 1: parser error : Opening and ending tag mismatch: id line 1 and CreationOptionList
Entity: line 1: parser error : Premature end of data in tag name line 1
Entity: line 1: parser error : Premature end of data in tag author line 1
Entity: line 1: parser error : Premature end of data in tag updated line 1
Entity: line 1: parser error : Premature end of data in tag link line 1
Entity: line 1: parser error : Premature end of data in tag description line 1
Entity: line 1: parser error : Premature end of data in tag title line 1
Entity: line 1: parser error : Premature end of data in tag entry line 1
Entity: line 1: parser error : Premature end of data in tag item line 1
Entity: line 1: parser error : Premature end of data in tag channel line 1
Entity: line 1: parser error : Premature end of data in tag CreationOptionList line 1

See the generated result over at https://gist.github.com/yeesian/9468a9100fb1f08ec64a21c20dcc4af9.