fixed dependencies
This commit is contained in:
47
vendor/github.com/airbusgeo/godal/CONTRIBUTING.md
generated
vendored
Normal file
47
vendor/github.com/airbusgeo/godal/CONTRIBUTING.md
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
# How to contribute #
|
||||
|
||||
Thank you for stopping by. Please read these few small guidelines before
|
||||
creating an issue or a pull request on godal.
|
||||
|
||||
|
||||
## Reporting issues ##
|
||||
|
||||
Bugs, feature requests, and development-related questions should be directed to
|
||||
our [GitHub issue tracker](https://github.com/airbusgeo/godal/issues). If
|
||||
reporting a bug, please try and provide as much context as possible such as
|
||||
your Go version, GDAL version and anything else that might be relevant to
|
||||
the bug. For feature requests, please explain what you're trying to do, and
|
||||
how the requested feature would help you do that.
|
||||
|
||||
## Submitting a patch ##
|
||||
|
||||
1. Patches are to be submitted through pull-requests: https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request
|
||||
|
||||
1. Make sure each group of changes be done in distinct branches in order to
|
||||
ensure that a pull request only includes code related to that bug or feature.
|
||||
|
||||
1. Always run `go fmt` on your code before committing it.
|
||||
|
||||
1. Do not squash / force-push your commits inside the pull request branch as
|
||||
these tend to mess up the review comments.
|
||||
|
||||
1. As far as possible, the public API exposed by godal should remain backwards
|
||||
compatible, meaning that existing code using godal should compile correctly
|
||||
when using a newer godal version, and that the resulting behavior of the
|
||||
compiled program should be unchanged. godal makes heavy use of
|
||||
[optional parameters](https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis)
|
||||
in its exposed API in order to allow this.
|
||||
|
||||
1. Any changes should almost always be accompanied by tests. Look at some of
|
||||
the existing tests if you're unsure how to go about it. Tests should ensure
|
||||
that the godal wrapper itself is working correctly, not the underlying GDAL
|
||||
library (e.g. the test could check that a particular option has been taken
|
||||
into account by gdal, not that gdal has produced correct output for all
|
||||
possible option values)
|
||||
|
||||
1. Pull requests will be automatically tested, vetted and checked for test
|
||||
coverage. You can run the following tools locally before submitting your
|
||||
changes to ensure the checks will pass:
|
||||
* `go test ./... -cover`
|
||||
* `golangci-lint run --skip-files doc_test.go`
|
||||
|
||||
191
vendor/github.com/airbusgeo/godal/LICENSE
generated
vendored
Normal file
191
vendor/github.com/airbusgeo/godal/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
// Copyright 2021 Airbus Defence and Space
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
95
vendor/github.com/airbusgeo/godal/README.md
generated
vendored
Normal file
95
vendor/github.com/airbusgeo/godal/README.md
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
# Golang bindings for GDAL
|
||||
[](https://pkg.go.dev/github.com/airbusgeo/godal)
|
||||
[](https://github.com/airbusgeo/godal/blob/main/LICENSE)
|
||||
[](https://github.com/airbusgeo/godal/actions?query=workflow%3Agodal+event%3Apush+branch%3Amain)
|
||||
[](https://coveralls.io/github/airbusgeo/godal?branch=main)
|
||||
[](https://goreportcard.com/report/github.com/airbusgeo/godal)
|
||||
|
||||
|
||||
|
||||
### Goals
|
||||
|
||||
Godal aims at providing an idiomatic go wrapper around the <img src="https://gdal.org/_static/gdalicon.png" width="25" height="25">
|
||||
[GDAL](https://gdal.org) library:
|
||||
|
||||
* Function calls return a result and an error. The result will be valid if
|
||||
no error was returned. The error message will contain the root cause of why
|
||||
the error happened.
|
||||
* Calls between go and native libraries incur some overhead. As such godal does
|
||||
not strictly expose GDAL's API, but groups often-used calls in a single cgo function
|
||||
to reduce this overhead. For example, C code like
|
||||
```c++
|
||||
hDS = GDALOpen(filename, GA_Readonly)
|
||||
if (hDS == NULL) exit(1);
|
||||
int sx = GDALGetRasterXSize(hDS);
|
||||
int sy = GDALGetRasterYSize(hDS);
|
||||
int nBands = GDALGetRasterCount(hDS);
|
||||
printf("dataset size: %dx%dx%d\n",sx,sy,nBands);
|
||||
for (int i=1; i<=nBands; i++) {
|
||||
hBand = GDALGetRasterBand(hDS,i);
|
||||
int ovrCount = GDALGetOverviewCount(hBand)
|
||||
for(int o=0; o<=ovrCount; o++) {
|
||||
GDALRasterBandH oBand = GDALGetOverview(hBand,o);
|
||||
int osx = GDALGetRasterBandXSize(oBand);
|
||||
int osy = GDALGetRasterBandYSize(oBand);
|
||||
printf("overview %d size: %dx%d\n",o,osx,osy);
|
||||
}
|
||||
}
|
||||
```
|
||||
will be written as
|
||||
```go
|
||||
hDS,err := godal.Open(filename)
|
||||
if err!=nil {
|
||||
panic(err)
|
||||
}
|
||||
structure := hDS.Structure()
|
||||
fmt.Printf("dataset size: %dx%dx%d\n", structure.SizeX,structure.SizeY,structure.NBands)
|
||||
for _,band := range hDS.Bands() {
|
||||
for o,ovr := range band.Overviews() {
|
||||
bstruct := ovr.Structure()
|
||||
fmt.Printf("overview %d size: %dx%d\n",o,bstruct.SizeX,bstruct.SizeY)
|
||||
}
|
||||
}
|
||||
```
|
||||
* Unfrequently used or non-default parameters are passed as options:
|
||||
```go
|
||||
ds,err := godal.Open(filename) //read-only
|
||||
ds,err := godal.Open(filename, Update()) //read-write
|
||||
```
|
||||
* Godal exposes a VSI handler that can easily allow you to expose an
|
||||
[io.ReaderAt](https://golang.org/pkg/io/#ReaderAt) as a filename that can be
|
||||
opened by GDAL. A handler for opening `gs://` google cloud storage URIs is
|
||||
provided through https://github.com/airbusgeo/osio
|
||||
|
||||
### Documentation
|
||||
|
||||
[](https://pkg.go.dev/github.com/airbusgeo/godal)
|
||||
contains the API reference and example code to get you started. The
|
||||
`*_test.go` files can also be used as reference.
|
||||
|
||||
|
||||
### Status
|
||||
|
||||
Godal is not feature complete. The raster side is nearing completion and
|
||||
should remain stable. The vector and spatial-referencing sides are far from
|
||||
complete, meaning that the API might evolve in backwards incompatible ways
|
||||
until essential functionality is covered.
|
||||
|
||||
### Contributing
|
||||
|
||||
Contributions are welcome. Please read the [contribution guidelines](CONTRIBUTING.md)
|
||||
before submitting fixes or enhancements.
|
||||
|
||||
### Installation
|
||||
|
||||
Godal requires a GDAL version greater than 3.0. Make sure the GDAL headers
|
||||
are installed on the system used for compiling go+godal code. If using a GDAL
|
||||
installation in a non standard location, you can set your `PKG_CONFIG_PATH`
|
||||
environment variable, e.g. `export PKG_CONFIG_PATH=/opt/include/pkgconfig`.
|
||||
|
||||
### Licensing
|
||||
Godal is licensed under the Apache License, Version 2.0. See
|
||||
[LICENSE](https://github.com/airbusgeo/godal/blob/main/LICENSE) for the full
|
||||
license text.
|
||||
|
||||
|
||||
158
vendor/github.com/airbusgeo/godal/driver.go
generated
vendored
Normal file
158
vendor/github.com/airbusgeo/godal/driver.go
generated
vendored
Normal file
@@ -0,0 +1,158 @@
|
||||
// Copyright 2021 Airbus Defence and Space
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package godal
|
||||
|
||||
//DriverName is GDAL driver
|
||||
type DriverName string
|
||||
|
||||
const (
|
||||
//GTiff GeoTIFF
|
||||
GTiff DriverName = "GTiff"
|
||||
//GeoJSON RFCxxxx geojson
|
||||
GeoJSON DriverName = "GeoJSON"
|
||||
//Memory in memory driver
|
||||
Memory DriverName = "Memory"
|
||||
//VRT is a VRT
|
||||
VRT DriverName = "VRT"
|
||||
//Shapefile is an ESRI Shapefile
|
||||
Shapefile DriverName = "ESRI Shapefile"
|
||||
//GeoPackage is a geo-package
|
||||
GeoPackage DriverName = "GPKG"
|
||||
//JP2KAK is a Kakadu Jpeg2000
|
||||
JP2KAK DriverName = "JP2KAK"
|
||||
//OpenJPEG is an OpenJPEG JPEG2000
|
||||
OpenJPEG DriverName = "OpenJPEG"
|
||||
//DIMAP is a Dimap
|
||||
DIMAP DriverName = "DIMAP"
|
||||
//HFA is an erdas img
|
||||
HFA DriverName = "HFA"
|
||||
//Mitab is a mapinfo mif/tab file
|
||||
Mitab DriverName = "Mitab"
|
||||
//CSV comma-separated values driver
|
||||
CSV DriverName = "CSV"
|
||||
)
|
||||
|
||||
type driverMapping struct {
|
||||
rasterName string
|
||||
vectorName string
|
||||
rasterRegister string
|
||||
vectorRegister string
|
||||
}
|
||||
|
||||
var driverMappings = map[DriverName]driverMapping{
|
||||
GTiff: {
|
||||
rasterName: "GTiff",
|
||||
rasterRegister: "GDALRegister_GTiff",
|
||||
},
|
||||
Memory: {
|
||||
rasterName: "MEM",
|
||||
vectorName: "Memory",
|
||||
rasterRegister: "GDALRegister_MEM",
|
||||
vectorRegister: "RegisterOGRMEM",
|
||||
},
|
||||
GeoJSON: {
|
||||
vectorName: "GeoJSON",
|
||||
vectorRegister: "RegisterOGRGeoJSON",
|
||||
},
|
||||
VRT: {
|
||||
rasterName: "VRT",
|
||||
vectorName: "OGR_VRT",
|
||||
rasterRegister: "GDALRegister_VRT",
|
||||
vectorRegister: "RegisterOGRVRT",
|
||||
},
|
||||
Shapefile: {
|
||||
vectorName: "ESRI Shapefile",
|
||||
vectorRegister: "RegisterOGRShape",
|
||||
},
|
||||
GeoPackage: {
|
||||
rasterName: "GPKG",
|
||||
vectorName: "GPKG",
|
||||
rasterRegister: "RegisterOGRGeoPackage",
|
||||
vectorRegister: "RegisterOGRGeoPackage",
|
||||
},
|
||||
JP2KAK: {
|
||||
rasterName: "JP2KAK",
|
||||
rasterRegister: "GDALRegister_JP2KAK",
|
||||
},
|
||||
OpenJPEG: {
|
||||
rasterName: "OpenJPEG",
|
||||
rasterRegister: "GDALRegister_JP2OpenJPEG",
|
||||
},
|
||||
DIMAP: {
|
||||
rasterName: "DIMAP",
|
||||
rasterRegister: "GDALRegister_DIMAP",
|
||||
},
|
||||
HFA: {
|
||||
rasterName: "HFA",
|
||||
rasterRegister: "GDALRegister_HFA",
|
||||
},
|
||||
Mitab: {
|
||||
vectorName: "Mapinfo File",
|
||||
vectorRegister: "RegisterOGRTAB",
|
||||
},
|
||||
CSV: {
|
||||
vectorName: "CSV",
|
||||
vectorRegister: "RegisterOGRCSV",
|
||||
},
|
||||
}
|
||||
|
||||
func (dn DriverName) setDatasetVectorTranslateOpt(to *dsVectorTranslateOpts) {
|
||||
to.driver = dn
|
||||
}
|
||||
|
||||
func (dn DriverName) setDatasetTranslateOpt(to *dsTranslateOpts) {
|
||||
to.driver = dn
|
||||
}
|
||||
|
||||
func (dn DriverName) setDatasetWarpOpt(to *dsWarpOpts) {
|
||||
to.driver = dn
|
||||
}
|
||||
|
||||
func (dn DriverName) setRasterizeOpt(to *rasterizeOpts) {
|
||||
to.driver = dn
|
||||
}
|
||||
|
||||
type driversOpt struct {
|
||||
drivers []string
|
||||
}
|
||||
|
||||
//Drivers specifies the list of drivers that are allowed to try opening the dataset
|
||||
func Drivers(drivers ...string) interface {
|
||||
OpenOption
|
||||
} {
|
||||
return driversOpt{drivers}
|
||||
}
|
||||
func (do driversOpt) setOpenOpt(oo *openOpts) {
|
||||
oo.drivers = append(oo.drivers, do.drivers...)
|
||||
}
|
||||
|
||||
type driverOpenOption struct {
|
||||
oo []string
|
||||
}
|
||||
|
||||
//DriverOpenOption adds a list of Open Options (-oo switch) to the open command. Each keyval must
|
||||
//be provided in a "KEY=value" format
|
||||
func DriverOpenOption(keyval ...string) interface {
|
||||
OpenOption
|
||||
BuildVRTOption
|
||||
} {
|
||||
return driverOpenOption{keyval}
|
||||
}
|
||||
func (doo driverOpenOption) setOpenOpt(oo *openOpts) {
|
||||
oo.options = append(oo.options, doo.oo...)
|
||||
}
|
||||
func (doo driverOpenOption) setBuildVRTOpt(bvo *buildVRTOpts) {
|
||||
bvo.openOptions = append(bvo.openOptions, doo.oo...)
|
||||
}
|
||||
461
vendor/github.com/airbusgeo/godal/errors.go
generated
vendored
Normal file
461
vendor/github.com/airbusgeo/godal/errors.go
generated
vendored
Normal file
@@ -0,0 +1,461 @@
|
||||
// Copyright 2021 Airbus Defence and Space
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package godal
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var errorHandlerMu sync.Mutex
|
||||
var errorHandlerIndex int
|
||||
|
||||
// ErrorHandler is a function that can be used to override godal's default behavior
|
||||
// of treating all messages with severity >= CE_Warning as errors. When an ErrorHandler
|
||||
// is passed as an option to a godal function, all logs/errors emitted by gdal will be passed
|
||||
// to this function, which can decide wether the parameters correspond to an actual error
|
||||
// or not.
|
||||
//
|
||||
// If the ErrorHandler returns nil, the parent function will not return an error. It is up
|
||||
// to the ErrorHandler to log the message if needed.
|
||||
//
|
||||
// If the ErrorHandler returns an error, that error will be returned as-is to the caller
|
||||
// of the parent function
|
||||
type ErrorHandler func(ec ErrorCategory, code int, msg string) error
|
||||
|
||||
type errorHandlerWrapper struct {
|
||||
fn ErrorHandler
|
||||
err error
|
||||
}
|
||||
|
||||
var errorHandlers = make(map[int]*errorHandlerWrapper)
|
||||
|
||||
func registerErrorHandler(fn ErrorHandler) int {
|
||||
errorHandlerMu.Lock()
|
||||
defer errorHandlerMu.Unlock()
|
||||
for errorHandlerIndex == 0 || errorHandlers[errorHandlerIndex] != nil {
|
||||
errorHandlerIndex++
|
||||
}
|
||||
errorHandlers[errorHandlerIndex] = &errorHandlerWrapper{fn: fn}
|
||||
return errorHandlerIndex
|
||||
}
|
||||
|
||||
func getErrorHandler(i int) *errorHandlerWrapper {
|
||||
errorHandlerMu.Lock()
|
||||
defer errorHandlerMu.Unlock()
|
||||
return errorHandlers[i]
|
||||
}
|
||||
|
||||
func unregisterErrorHandler(i int) {
|
||||
errorHandlerMu.Lock()
|
||||
defer errorHandlerMu.Unlock()
|
||||
delete(errorHandlers, i)
|
||||
}
|
||||
|
||||
type errorAndLoggingOpts struct {
|
||||
eh ErrorHandler
|
||||
config []string
|
||||
}
|
||||
|
||||
type errorCallback struct {
|
||||
fn ErrorHandler
|
||||
}
|
||||
|
||||
type errorAndLoggingOption interface {
|
||||
setErrorAndLoggingOpt(elo *errorAndLoggingOpts)
|
||||
}
|
||||
|
||||
// ErrLogger is an option to override default error handling.
|
||||
//
|
||||
// See ErrorHandler.
|
||||
func ErrLogger(fn ErrorHandler) interface {
|
||||
errorAndLoggingOption
|
||||
AddGeometryOption
|
||||
BandCreateMaskOption
|
||||
BandIOOption
|
||||
BoundsOption
|
||||
BufferOption
|
||||
BuildOverviewsOption
|
||||
BuildVRTOption
|
||||
ClearOverviewsOption
|
||||
CloseOption
|
||||
CopyLayerOption
|
||||
CreateFeatureOption
|
||||
CreateLayerOption
|
||||
CreateSpatialRefOption
|
||||
DatasetCreateMaskOption
|
||||
DatasetCreateOption
|
||||
DatasetIOOption
|
||||
DatasetTranslateOption
|
||||
DatasetVectorTranslateOption
|
||||
DatasetWarpIntoOption
|
||||
DatasetWarpOption
|
||||
DeleteFeatureOption
|
||||
DifferenceOption
|
||||
FeatureCountOption
|
||||
FillBandOption
|
||||
FillNoDataOption
|
||||
GeoJSONOption
|
||||
GeometryTransformOption
|
||||
GeometryReprojectOption
|
||||
GeometryWKBOption
|
||||
GeometryWKTOption
|
||||
GetGeoTransformOption
|
||||
GMLExportOption
|
||||
HistogramOption
|
||||
IntersectsOption
|
||||
IntersectionOption
|
||||
MetadataOption
|
||||
NewFeatureOption
|
||||
NewGeometryOption
|
||||
OpenOption
|
||||
PolygonizeOption
|
||||
RasterizeGeometryOption
|
||||
RasterizeOption
|
||||
RasterizeIntoOption
|
||||
SetColorInterpOption
|
||||
SetColorTableOption
|
||||
SetDescriptionOption
|
||||
SetGeometryOption
|
||||
SetFieldValueOption
|
||||
SetNoDataOption
|
||||
SetScaleOffsetOption
|
||||
SetGeoTransformOption
|
||||
SetGeometryColumnNameOption
|
||||
SetProjectionOption
|
||||
SetSpatialRefOption
|
||||
SieveFilterOption
|
||||
SimplifyOption
|
||||
SpatialRefValidateOption
|
||||
SubGeometryOption
|
||||
TransformOption
|
||||
UnionOption
|
||||
UpdateFeatureOption
|
||||
VSIHandlerOption
|
||||
VSIOpenOption
|
||||
VSIUnlinkOption
|
||||
WKTExportOption
|
||||
StatisticsOption
|
||||
SetStatisticsOption
|
||||
ClearStatisticsOption
|
||||
GridOption
|
||||
NearblackOption
|
||||
DemOption
|
||||
SetGCPsOption
|
||||
GCPsToGeoTransformOption
|
||||
RegisterPluginOption
|
||||
} {
|
||||
return errorCallback{fn}
|
||||
}
|
||||
|
||||
func (ec errorCallback) setErrorAndLoggingOpt(elo *errorAndLoggingOpts) {
|
||||
elo.eh = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setAddGeometryOpt(ao *addGeometryOpts) {
|
||||
ao.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setBandCreateMaskOpt(o *bandCreateMaskOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setBandIOOpt(o *bandIOOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setBoundsOpt(o *boundsOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setBufferOpt(o *bufferOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setBuildOverviewsOpt(o *buildOvrOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setBuildVRTOpt(o *buildVRTOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setClearOverviewsOpt(o *clearOvrOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setCloseOpt(o *closeOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setCopyLayerOpt(o *copyLayerOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setCreateFeatureOpt(cfo *createFeatureOpts) {
|
||||
cfo.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setCreateLayerOpt(o *createLayerOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setCreateSpatialRefOpt(o *createSpatialRefOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setDatasetCreateMaskOpt(o *dsCreateMaskOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setDatasetCreateOpt(o *dsCreateOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setDatasetIOOpt(o *datasetIOOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setDatasetTranslateOpt(o *dsTranslateOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setDatasetVectorTranslateOpt(o *dsVectorTranslateOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setDatasetWarpIntoOpt(o *dsWarpIntoOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setDatasetWarpOpt(o *dsWarpOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setDeleteFeatureOpt(o *deleteFeatureOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setDifferenceOpt(do *differenceOpts) {
|
||||
do.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setFeatureCountOpt(o *featureCountOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setFillBandOpt(o *fillBandOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setFillnodataOpt(o *fillnodataOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setGeojsonOpt(o *geojsonOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setGeometryColumnNameOpt(o *setGeometryColumnNameOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setGeometryTransformOpt(o *geometryTransformOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setGeometryReprojectOpt(o *geometryReprojectOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setGeometryWKBOpt(o *geometryWKBOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setGeometryWKTOpt(o *geometryWKTOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setGetGeoTransformOpt(o *getGeoTransformOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setGMLExportOpt(o *gmlExportOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setHistogramOpt(o *histogramOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setIntersectsOpt(o *intersectsOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setIntersectionOpt(o *intersectionOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setMetadataOpt(o *metadataOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setDescriptionOpt(o *setDescriptionOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setNewFeatureOpt(o *newFeatureOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setNewGeometryOpt(o *newGeometryOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setOpenOpt(oo *openOpts) {
|
||||
oo.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setPolygonizeOpt(o *polygonizeOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setRasterizeGeometryOpt(o *rasterizeGeometryOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setRasterizeOpt(o *rasterizeOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setRasterizeIntoOpt(o *rasterizeIntoOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setSetColorInterpOpt(ndo *setColorInterpOpts) {
|
||||
ndo.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setSetColorTableOpt(ndo *setColorTableOpts) {
|
||||
ndo.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setSetGeometryOpt(o *setGeometryOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setSetFieldValueOpt(o *setFieldValueOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setSetGeoTransformOpt(o *setGeoTransformOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setSetProjectionOpt(o *setProjectionOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setSetNoDataOpt(ndo *setNodataOpts) {
|
||||
ndo.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setSetScaleOffsetOpt(soo *setScaleOffsetOpts) {
|
||||
soo.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setSetSpatialRefOpt(ndo *setSpatialRefOpts) {
|
||||
ndo.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setSieveFilterOpt(sfo *sieveFilterOpts) {
|
||||
sfo.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setSimplifyOpt(o *simplifyOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setSpatialRefValidateOpt(o *spatialRefValidateOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setSubGeometryOpt(so *subGeometryOpts) {
|
||||
so.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setTransformOpt(o *trnOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setUnionOpt(uo *unionOpts) {
|
||||
uo.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setUpdateFeatureOpt(o *updateFeatureOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setVSIHandlerOpt(o *vsiHandlerOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setVSIOpenOpt(o *vsiOpenOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setVSIUnlinkOpt(o *vsiUnlinkOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setWKTExportOpt(o *srWKTOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
|
||||
func (ec errorCallback) setStatisticsOpt(o *statisticsOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
|
||||
func (ec errorCallback) setSetStatisticsOpt(o *setStatisticsOpt) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
|
||||
func (ec errorCallback) setClearStatisticsOpt(o *clearStatisticsOpt) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setGridCreateOpt(o *gridCreateOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setGridOpt(o *gridOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setNearblackOpt(o *nearBlackOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setDemOpt(o *demOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setSetGCPsOpt(o *setGCPsOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setGCPsToGeoTransformOpts(o *gcpsToGeoTransformOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
func (ec errorCallback) setRegisterPluginOpt(o *registerPluginOpts) {
|
||||
o.errorHandler = ec.fn
|
||||
}
|
||||
|
||||
type multiError struct {
|
||||
errs []error
|
||||
}
|
||||
|
||||
// Error is the standard error interface
|
||||
func (me *multiError) Error() string {
|
||||
w := bytes.NewBufferString(me.errs[0].Error())
|
||||
for i := 1; i < len(me.errs); i++ {
|
||||
w.WriteByte('\n')
|
||||
w.WriteString(me.errs[i].Error())
|
||||
}
|
||||
return w.String()
|
||||
}
|
||||
|
||||
// As is the standard error wrapping interface
|
||||
func (me *multiError) As(target interface{}) bool {
|
||||
for _, err := range me.errs {
|
||||
if errors.As(err, target) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Is is the standard error wrapping interface
|
||||
func (me *multiError) Is(target error) bool {
|
||||
for _, err := range me.errs {
|
||||
if errors.Is(err, target) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func combine(e1, e2 error) error {
|
||||
switch {
|
||||
case e1 == nil:
|
||||
return e2
|
||||
case e2 == nil:
|
||||
return e1
|
||||
}
|
||||
if me1, ok := e1.(*multiError); ok {
|
||||
if me2, ok := e2.(*multiError); ok {
|
||||
me1.errs = append(me1.errs, me2.errs...)
|
||||
} else {
|
||||
me1.errs = append(me1.errs, e2)
|
||||
}
|
||||
return me1
|
||||
} else if me2, ok := e2.(*multiError); ok {
|
||||
me := &multiError{}
|
||||
me.errs = make([]error, 1, len(me2.errs)+1)
|
||||
me.errs[0] = e1
|
||||
me.errs = append(me.errs, me2.errs...)
|
||||
return me
|
||||
} else {
|
||||
return &multiError{errs: []error{e1, e2}}
|
||||
}
|
||||
}
|
||||
|
||||
var SkipWarnings = ErrLogger(
|
||||
func(ec ErrorCategory, code int, message string) error {
|
||||
if ec > CE_Warning {
|
||||
return errors.New(message)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
1916
vendor/github.com/airbusgeo/godal/godal.cpp
generated
vendored
Normal file
1916
vendor/github.com/airbusgeo/godal/godal.cpp
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4221
vendor/github.com/airbusgeo/godal/godal.go
generated
vendored
Normal file
4221
vendor/github.com/airbusgeo/godal/godal.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
188
vendor/github.com/airbusgeo/godal/godal.h
generated
vendored
Normal file
188
vendor/github.com/airbusgeo/godal/godal.h
generated
vendored
Normal file
@@ -0,0 +1,188 @@
|
||||
// Copyright 2021 Airbus Defence and Space
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _GODAL_H_
|
||||
#define _GODAL_H_
|
||||
|
||||
#define _GNU_SOURCE 1
|
||||
#include <gdal.h>
|
||||
#include <gdal_alg.h>
|
||||
#include <ogr_srs_api.h>
|
||||
#include <cpl_conv.h>
|
||||
#include "cpl_port.h"
|
||||
#include <gdal_frmts.h>
|
||||
|
||||
#if GDAL_VERSION_NUM < 3000000
|
||||
#error "this code is only compatible with gdal version >= 3.0"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
typedef struct {
|
||||
char *errMessage;
|
||||
int handlerIdx;
|
||||
int failed;
|
||||
char **configOptions;
|
||||
} cctx;
|
||||
void godalSetMetadataItem(cctx *ctx, GDALMajorObjectH mo, char *ckey, char *cval, char *cdom);
|
||||
void godalSetDescription(cctx *ctx, GDALMajorObjectH mo, char *desc);
|
||||
void godalClearMetadata(cctx *ctx, GDALMajorObjectH mo, char *cdom);
|
||||
GDALDatasetH godalOpen(cctx *ctx, const char *name, unsigned int nOpenFlags, const char *const *papszAllowedDrivers,
|
||||
const char *const *papszOpenOptions, const char *const *papszSiblingFiles);
|
||||
|
||||
GDALDatasetH godalCreate(cctx *ctx, GDALDriverH drv, const char *name, int width, int height, int nbands,
|
||||
GDALDataType dtype, char **creationOption);
|
||||
|
||||
void godalClose(cctx *ctx, GDALDatasetH ds);
|
||||
int godalRegisterDriver(const char *funcname);
|
||||
void godalRegisterPlugins();
|
||||
void godalRegisterPlugin(cctx *ctx, const char *name);
|
||||
void godalRasterSize(GDALDatasetH ds, int *xsize, int *ysize);
|
||||
|
||||
//returns a null terminated list of bands. the caller must free the returned list
|
||||
GDALRasterBandH *godalRasterBands(GDALDatasetH ds);
|
||||
OGRLayerH *godalVectorLayers(GDALDatasetH ds);
|
||||
|
||||
GDALRasterBandH* godalBandOverviews(GDALRasterBandH bnd);
|
||||
|
||||
void godalSetRasterNoDataValue(cctx *ctx, GDALRasterBandH bnd, double nd);
|
||||
void godalSetDatasetNoDataValue(cctx *ctx, GDALDatasetH bnd, double nd);
|
||||
void godalDeleteRasterNoDataValue(cctx *ctx, GDALRasterBandH bnd);
|
||||
void godalSetRasterScaleOffset(cctx *ctx, GDALRasterBandH bnd, double scale, double offset);
|
||||
void godalSetDatasetScaleOffset(cctx *ctx, GDALDatasetH bnd, double scale, double offset);
|
||||
void godalSetRasterColorInterpretation(cctx *ctx, GDALRasterBandH bnd, GDALColorInterp ci);
|
||||
GDALRasterBandH godalCreateMaskBand(cctx *ctx, GDALRasterBandH bnd, int flags);
|
||||
GDALRasterBandH godalCreateDatasetMaskBand(cctx *ctx, GDALDatasetH ds, int flags);
|
||||
OGRSpatialReferenceH godalCreateUserSpatialRef(cctx *ctx, char *userInput);
|
||||
OGRSpatialReferenceH godalCreateWKTSpatialRef(cctx *ctx, char *wkt);
|
||||
OGRSpatialReferenceH godalCreateProj4SpatialRef(cctx *ctx, char *proj);
|
||||
OGRSpatialReferenceH godalCreateEPSGSpatialRef(cctx *ctx, int epsgCode);
|
||||
void godalValidateSpatialRef(cctx *ctx, OGRSpatialReferenceH sr);
|
||||
char* godalExportToWKT(cctx *ctx, OGRSpatialReferenceH sr);
|
||||
OGRCoordinateTransformationH godalNewCoordinateTransformation(cctx *ctx, OGRSpatialReferenceH src, OGRSpatialReferenceH dst);
|
||||
void godalDatasetSetSpatialRef(cctx *ctx, GDALDatasetH ds, OGRSpatialReferenceH sr);
|
||||
void godalSetGeoTransform(cctx *ctx, GDALDatasetH ds, double *gt);
|
||||
void godalGetGeoTransform(cctx *ctx, GDALDatasetH ds, double *gt);
|
||||
void godalSetProjection(cctx *ctx, GDALDatasetH ds, char *wkt);
|
||||
|
||||
GDALDatasetH godalTranslate(cctx *ctx, char *dstName, GDALDatasetH ds, char **switches);
|
||||
GDALDatasetH godalDatasetWarp(cctx *ctx, char *dstName, int nSrcCount, GDALDatasetH *srcDS, char **switches);
|
||||
void godalDatasetWarpInto(cctx *ctx, GDALDatasetH dstDs, int nSrcCount, GDALDatasetH *srcDS, char **switches);
|
||||
GDALDatasetH godalDatasetVectorTranslate(cctx *ctx, char *dstName, GDALDatasetH ds, char **switches);
|
||||
GDALDatasetH godalRasterize(cctx *ctx, char *dstName, GDALDatasetH dstDS, GDALDatasetH ds, char **switches);
|
||||
void godalRasterizeGeometry(cctx *ctx, GDALDatasetH ds, OGRGeometryH geom, int *bands, int nBands, double *vals, int allTouched);
|
||||
void godalBuildOverviews(cctx *ctx, GDALDatasetH ds, const char *resampling, int nLevels, int *levels, int nBands, int *bands);
|
||||
void godalClearOverviews(cctx *ctx, GDALDatasetH ds);
|
||||
|
||||
void godalDatasetStructure(GDALDatasetH ds, int *sx, int *sy, int *bsx, int *bsy, double *scale, double *offset, int *bandCount, int *dtype);
|
||||
void godalBandStructure(GDALRasterBandH bnd, int *sx, int *sy, int *bsx, int *bsy, double *scale, double *offset, int *dtype);
|
||||
void godalDatasetRasterIO(cctx *ctx, GDALDatasetH ds, GDALRWFlag rw, int nDSXOff, int nDSYOff, int nDSXSize, int nDSYSize, void *pBuffer,
|
||||
int nBXSize, int nBYSize, GDALDataType eBDataType, int nBandCount, int *panBandCount,
|
||||
int nPixelSpace, int nLineSpace, int nBandSpace, GDALRIOResampleAlg alg);
|
||||
void godalBandRasterIO(cctx *ctx, GDALRasterBandH bnd, GDALRWFlag rw, int nDSXOff, int nDSYOff, int nDSXSize, int nDSYSize, void *pBuffer,
|
||||
int nBXSize, int nBYSize, GDALDataType eBDataType, int nPixelSpace, int nLineSpace, GDALRIOResampleAlg alg);
|
||||
void godalFillRaster(cctx *ctx, GDALRasterBandH bnd, double real, double imag);
|
||||
void godalPolygonize(cctx *ctx, GDALRasterBandH in, GDALRasterBandH mask, OGRLayerH layer, int fieldIndex, char **opts);
|
||||
void godalFillNoData(cctx *ctx, GDALRasterBandH in, GDALRasterBandH mask, int maxDistance, int iterations, char **opts);
|
||||
void godalSieveFilter(cctx *ctx, GDALRasterBandH bnd, GDALRasterBandH mask, GDALRasterBandH dst, int sizeThreshold, int connectedNess);
|
||||
|
||||
void godalLayerGetExtent(cctx *ctx, OGRLayerH layer, OGREnvelope *envelope);
|
||||
void godalLayerFeatureCount(cctx *ctx, OGRLayerH layer, int *count);
|
||||
void godalLayerSetFeature(cctx *ctx, OGRLayerH layer, OGRFeatureH feat);
|
||||
void godalLayerCreateFeature(cctx *ctx, OGRLayerH layer, OGRFeatureH feat);
|
||||
OGRFeatureH godalLayerNewFeature(cctx *ctx, OGRLayerH layer, OGRGeometryH geom);
|
||||
void godalLayerDeleteFeature(cctx *ctx, OGRLayerH layer, OGRFeatureH feat);
|
||||
void godalLayerSetGeometryColumnName(cctx *ctx, OGRLayerH layer, char *name);
|
||||
void godalFeatureSetGeometryColumnName(cctx *ctx, OGRFeatureH feat, char *name);
|
||||
void godalFeatureSetGeometry(cctx *ctx, OGRFeatureH feat, OGRGeometryH geom);
|
||||
void godalFeatureSetFieldInteger(cctx *ctx, OGRFeatureH feat, int fieldIndex, int value);
|
||||
void godalFeatureSetFieldInteger64(cctx *ctx, OGRFeatureH feat, int fieldIndex, long long value);
|
||||
void godalFeatureSetFieldDouble(cctx *ctx, OGRFeatureH feat, int fieldIndex, double value);
|
||||
void godalFeatureSetFieldString(cctx *ctx, OGRFeatureH feat, int fieldIndex, char *value);
|
||||
void godalFeatureSetFieldDateTime(cctx *ctx, OGRFeatureH feat, int fieldIndex, int year, int month, int day, int hour, int minute, int second, int tzFlag);
|
||||
void godalFeatureSetFieldIntegerList(cctx *ctx, OGRFeatureH feat, int fieldIndex, int nbValues, int *values);
|
||||
void godalFeatureSetFieldInteger64List(cctx *ctx, OGRFeatureH feat, int fieldIndex, int nbValues, long long *values);
|
||||
void godalFeatureSetFieldDoubleList(cctx *ctx, OGRFeatureH feat, int fieldIndex, int nbValues, double *values);
|
||||
void godalFeatureSetFieldStringList(cctx *ctx, OGRFeatureH feat, int fieldIndex, char **values);
|
||||
void godalFeatureSetFieldBinary(cctx *ctx, OGRFeatureH feat, int fieldIndex, int nbBytes, void *value);
|
||||
OGRLayerH godalCreateLayer(cctx *ctx, GDALDatasetH ds, char *name, OGRSpatialReferenceH sr, OGRwkbGeometryType gtype);
|
||||
OGRLayerH godalCopyLayer(cctx *ctx, GDALDatasetH ds, OGRLayerH layer, char *name);
|
||||
void VSIInstallGoHandler(cctx *ctx, const char *pszPrefix, size_t bufferSize, size_t cacheSize);
|
||||
|
||||
void godalGetColorTable(GDALRasterBandH bnd, GDALPaletteInterp *interp, int *nEntries, short **entries);
|
||||
void godalSetColorTable(cctx *ctx, GDALRasterBandH bnd, GDALPaletteInterp interp, int nEntries, short *entries);
|
||||
void godalRasterHistogram(cctx *ctx, GDALRasterBandH bnd, double *min, double *max, int *buckets,
|
||||
unsigned long long **values, int bIncludeOutOfRange, int bApproxOK);
|
||||
|
||||
VSILFILE *godalVSIOpen(cctx *ctx, const char *name);
|
||||
void godalVSIUnlink(cctx *ctx, const char *name);
|
||||
char* godalVSIClose(VSILFILE *f);
|
||||
size_t godalVSIRead(VSILFILE *f, void *buf, int len, char **errmsg);
|
||||
void godal_OGR_G_AddGeometry(cctx *ctx, OGRGeometryH geom, OGRGeometryH subGeom);
|
||||
OGRGeometryH godal_OGR_G_Simplify(cctx *ctx, OGRGeometryH in, double tolerance);
|
||||
OGRGeometryH godal_OGR_G_Buffer(cctx *ctx, OGRGeometryH in, double tolerance, int segments);
|
||||
OGRGeometryH godal_OGR_G_Difference(cctx *ctx, OGRGeometryH geom1, OGRGeometryH geom2);
|
||||
OGRGeometryH godal_OGR_G_GetGeometryRef(cctx *ctx, OGRGeometryH in, int subGeomIndex);
|
||||
int godal_OGR_G_Intersects(cctx *ctx, OGRGeometryH geom1, OGRGeometryH geom2);
|
||||
OGRGeometryH godal_OGR_G_Intersection(cctx *ctx, OGRGeometryH geom1, OGRGeometryH geom2);
|
||||
OGRGeometryH godal_OGR_G_Union(cctx *ctx, OGRGeometryH geom1, OGRGeometryH geom2);
|
||||
OGRGeometryH godalNewGeometryFromGeoJSON(cctx *ctx, char *geoJSON);
|
||||
OGRGeometryH godalNewGeometryFromWKT(cctx *ctx, char *wkt, OGRSpatialReferenceH sr);
|
||||
OGRGeometryH godalNewGeometryFromWKB(cctx *ctx, void *wkb, int wkbLen,OGRSpatialReferenceH sr);
|
||||
char* godalExportGeometryWKT(cctx *ctx, OGRGeometryH in);
|
||||
char* godalExportGeometryGeoJSON(cctx *ctx, OGRGeometryH in, int precision);
|
||||
char* godalExportGeometryGML(cctx *ctx, OGRGeometryH in, char **switches);
|
||||
void godalExportGeometryWKB(cctx *ctx, void **wkb, int *wkbLen, OGRGeometryH in);
|
||||
void godalGeometryTransformTo(cctx *ctx, OGRGeometryH geom, OGRSpatialReferenceH sr);
|
||||
void godalGeometryTransform(cctx *ctx, OGRGeometryH geom, OGRCoordinateTransformationH trn, OGRSpatialReferenceH dst);
|
||||
|
||||
GDALDatasetH godalBuildVRT(cctx *ctx, char *dstname, char **sources, char **switches);
|
||||
|
||||
void test_godal_error_handling(cctx *ctx);
|
||||
void godalClearRasterStatistics(cctx *ctx, GDALDatasetH ds);
|
||||
void godalComputeRasterStatistics(cctx *ctx, GDALRasterBandH bnd, int bApproxOK, double *pdfMin, double *pdfMax, double *pdfMean, double *pdfStdDev);
|
||||
int godalGetRasterStatistics(cctx *ctx, GDALRasterBandH bnd, int bApproxOK, double *pdfMin, double *pdfMax, double *pdfMean, double *pdfStdDev);
|
||||
void godalSetRasterStatistics(cctx *ctx, GDALRasterBandH bnd, double dfMin, double dfMax, double dfMean, double dfStdDev);
|
||||
void godalGridCreate(cctx *ctx, char *pszAlgorithm, GDALGridAlgorithm eAlgorithm, GUInt32 nPoints, const double *padfX, const double *padfY, const double *padfZ, double dfXMin, double dfXMax, double dfYMin, double dfYMax, GUInt32 nXSize, GUInt32 nYSize, GDALDataType eType, void *pData);
|
||||
GDALDatasetH godalGrid(cctx *ctx, const char *pszDest, GDALDatasetH hSrcDS, char **switches);
|
||||
GDALDatasetH godalNearblack(cctx *ctx, const char *pszDest, GDALDatasetH hDstDS, GDALDatasetH hSrcDS, char **switches);
|
||||
GDALDatasetH godalDem(cctx *ctx, const char *pszDest, const char *pszProcessing, const char *pszColorFilename, GDALDatasetH hSrcDS, char **switches);
|
||||
|
||||
typedef struct {
|
||||
const GDAL_GCP *gcpList;
|
||||
int numGCPs;
|
||||
} GCPsAndCount;
|
||||
typedef struct {
|
||||
char **pszIds;
|
||||
char **pszInfos;
|
||||
double *dfGCPPixels;
|
||||
double *dfGCPLines;
|
||||
double *dfGCPXs;
|
||||
double *dfGCPYs;
|
||||
double *dfGCPZs;
|
||||
} goGCPList;
|
||||
OGRSpatialReferenceH godalGetGCPSpatialRef(GDALDatasetH hSrcDS);
|
||||
const GCPsAndCount godalGetGCPs(GDALDatasetH hSrcDS);
|
||||
const char *godalGetGCPProjection(GDALDatasetH hSrcDS);
|
||||
void godalSetGCPs(cctx *ctx, GDALDatasetH hSrcDS, int numGCPs, goGCPList GCPList, const char *pszGCPProjection);
|
||||
void godalSetGCPs2(cctx *ctx, GDALDatasetH hSrcDS, int numGCPs, goGCPList GCPList, OGRSpatialReferenceH hSRS);
|
||||
GDAL_GCP *goGCPListToGDALGCP(goGCPList GCPList, int numGCPs);
|
||||
void godalGCPListToGeoTransform(cctx *ctx, goGCPList GCPList, int numGCPs, double *gt);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // GO_GDAL_H_
|
||||
110
vendor/github.com/airbusgeo/godal/histogram.go
generated
vendored
Normal file
110
vendor/github.com/airbusgeo/godal/histogram.go
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
// Copyright 2021 Airbus Defence and Space
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package godal
|
||||
|
||||
// Histogram is a band's histogram.
|
||||
type Histogram struct {
|
||||
min, max float64
|
||||
counts []uint64
|
||||
}
|
||||
|
||||
// Bucket is a histogram entry. It spans [Min,Max] and contains Count entries.
|
||||
type Bucket struct {
|
||||
Min, Max float64
|
||||
Count uint64
|
||||
}
|
||||
|
||||
//Len returns the number of buckets contained in the histogram
|
||||
func (h Histogram) Len() int {
|
||||
return len(h.counts)
|
||||
}
|
||||
|
||||
//Bucket returns the i'th bucket in the histogram. i must be between 0 and Len()-1.
|
||||
func (h Histogram) Bucket(i int) Bucket {
|
||||
width := (h.max - h.min) / float64(len(h.counts))
|
||||
return Bucket{
|
||||
Min: h.min + width*float64(i),
|
||||
Max: h.min + width*float64(i+1),
|
||||
Count: h.counts[i],
|
||||
}
|
||||
}
|
||||
|
||||
type histogramOpts struct {
|
||||
approx int
|
||||
includeOutside int
|
||||
min, max float64
|
||||
buckets int32
|
||||
errorHandler ErrorHandler
|
||||
}
|
||||
|
||||
// HistogramOption is an option that can be passed to Band.Histogram()
|
||||
//
|
||||
// Available HistogramOptions are:
|
||||
// - Approximate() to allow the algorithm to operate on a subset of the full resolution data
|
||||
// - Intervals(count int, min,max float64) to compute a histogram with count buckets, spanning [min,max].
|
||||
// Each bucket will be (max-min)/count wide. If not provided, the default histogram will be returned.
|
||||
// - IncludeOutOfRange() to populate the first and last bucket with values under/over the specified min/max
|
||||
// when used in conjuntion with Intervals()
|
||||
// - ErrLogger
|
||||
type HistogramOption interface {
|
||||
setHistogramOpt(ho *histogramOpts)
|
||||
}
|
||||
|
||||
type includeOutsideOpt struct{}
|
||||
|
||||
func (ioo includeOutsideOpt) setHistogramOpt(ho *histogramOpts) {
|
||||
ho.includeOutside = 1
|
||||
}
|
||||
|
||||
// IncludeOutOfRange populates the first and last bucket with values under/over the specified min/max
|
||||
// when used in conjuntion with Intervals()
|
||||
func IncludeOutOfRange() interface {
|
||||
HistogramOption
|
||||
} {
|
||||
return includeOutsideOpt{}
|
||||
}
|
||||
|
||||
type approximateOkOption struct{}
|
||||
|
||||
func (aoo approximateOkOption) setHistogramOpt(ho *histogramOpts) {
|
||||
ho.approx = 1
|
||||
}
|
||||
|
||||
// Approximate allows the histogram algorithm to operate on a subset of the full resolution data
|
||||
func Approximate() interface {
|
||||
HistogramOption
|
||||
StatisticsOption
|
||||
} {
|
||||
return approximateOkOption{}
|
||||
}
|
||||
|
||||
type intervalsOption struct {
|
||||
min, max float64
|
||||
buckets int32
|
||||
}
|
||||
|
||||
func (io intervalsOption) setHistogramOpt(ho *histogramOpts) {
|
||||
ho.min = io.min
|
||||
ho.max = io.max
|
||||
ho.buckets = io.buckets
|
||||
}
|
||||
|
||||
// Intervals computes a histogram with count buckets, spanning [min,max].
|
||||
// Each bucket will be (max-min)/count wide. If not provided, the default histogram will be returned.
|
||||
func Intervals(count int, min, max float64) interface {
|
||||
HistogramOption
|
||||
} {
|
||||
return intervalsOption{min: min, max: max, buckets: int32(count)}
|
||||
}
|
||||
1530
vendor/github.com/airbusgeo/godal/options.go
generated
vendored
Normal file
1530
vendor/github.com/airbusgeo/godal/options.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
106
vendor/github.com/airbusgeo/godal/srs.go
generated
vendored
Normal file
106
vendor/github.com/airbusgeo/godal/srs.go
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
// Copyright 2021 Airbus Defence and Space
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package godal
|
||||
|
||||
import "fmt"
|
||||
|
||||
type srWKTOpts struct {
|
||||
errorHandler ErrorHandler
|
||||
}
|
||||
|
||||
//WKTExportOption is an option that can be passed to SpatialRef.WKT()
|
||||
//
|
||||
// Available WKTExportOptions are:
|
||||
// - ErrLogger
|
||||
type WKTExportOption interface {
|
||||
setWKTExportOpt(sro *srWKTOpts)
|
||||
}
|
||||
|
||||
type trnOpts struct {
|
||||
errorHandler ErrorHandler
|
||||
}
|
||||
|
||||
// TransformOption is an option that can be passed to NewTransform
|
||||
//
|
||||
// Available TransformOptions are:
|
||||
// - ErrLogger
|
||||
type TransformOption interface {
|
||||
setTransformOpt(o *trnOpts)
|
||||
}
|
||||
|
||||
func (sr *SpatialRef) setBoundsOpt(o *boundsOpts) {
|
||||
o.sr = sr
|
||||
}
|
||||
|
||||
type boundsOpts struct {
|
||||
sr *SpatialRef
|
||||
errorHandler ErrorHandler
|
||||
}
|
||||
|
||||
// BoundsOption is an option that can be passed to Dataset.Bounds or Geometry.Bounds
|
||||
//
|
||||
// Available options are:
|
||||
// - *SpatialRef
|
||||
// - ErrLogger
|
||||
type BoundsOption interface {
|
||||
setBoundsOpt(o *boundsOpts)
|
||||
}
|
||||
|
||||
type createSpatialRefOpts struct {
|
||||
errorHandler ErrorHandler
|
||||
}
|
||||
|
||||
// CreateSpatialRefOption is an option that can be passed when creating a new spatial
|
||||
// reference object
|
||||
//
|
||||
// Available options are:
|
||||
// - ErrLogger
|
||||
type CreateSpatialRefOption interface {
|
||||
setCreateSpatialRefOpt(so *createSpatialRefOpts)
|
||||
}
|
||||
|
||||
func reprojectBounds(bnds [4]float64, src, dst *SpatialRef) ([4]float64, error) {
|
||||
var ret [4]float64
|
||||
trn, err := NewTransform(src, dst)
|
||||
if err != nil {
|
||||
return ret, fmt.Errorf("create coordinate transform: %w", err)
|
||||
}
|
||||
defer trn.Close()
|
||||
x := []float64{bnds[0], bnds[0], bnds[2], bnds[2]}
|
||||
y := []float64{bnds[1], bnds[3], bnds[3], bnds[1]}
|
||||
err = trn.TransformEx(x, y, nil, nil)
|
||||
if err != nil {
|
||||
return ret, fmt.Errorf("reproject bounds: %w", err)
|
||||
}
|
||||
ret[0] = x[0]
|
||||
ret[1] = y[0]
|
||||
ret[2] = x[0]
|
||||
ret[3] = y[0]
|
||||
for i := 1; i < 4; i++ {
|
||||
if x[i] < ret[0] {
|
||||
ret[0] = x[i]
|
||||
}
|
||||
if x[i] > ret[2] {
|
||||
ret[2] = x[i]
|
||||
}
|
||||
if y[i] < ret[1] {
|
||||
ret[1] = y[i]
|
||||
}
|
||||
if y[i] > ret[3] {
|
||||
ret[3] = y[i]
|
||||
}
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
61
vendor/github.com/airbusgeo/godal/statistics.go
generated
vendored
Normal file
61
vendor/github.com/airbusgeo/godal/statistics.go
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
// Copyright 2021 Airbus Defence and Space
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package godal
|
||||
|
||||
// Statisitics on a given band.
|
||||
type Statistics struct {
|
||||
Min, Max, Mean, Std float64
|
||||
Approximate bool
|
||||
}
|
||||
|
||||
type statisticsOpts struct {
|
||||
approx int
|
||||
errorHandler ErrorHandler
|
||||
}
|
||||
|
||||
//StatisticsOption is an option that can be passed to Band.Statistics
|
||||
//
|
||||
//Available Statistics options are:
|
||||
// - Aproximate() to allow the satistics to be computed on overviews or a subset of all tiles.
|
||||
// - ErrLogger
|
||||
type StatisticsOption interface {
|
||||
setStatisticsOpt(so *statisticsOpts)
|
||||
}
|
||||
|
||||
func (aoo approximateOkOption) setStatisticsOpt(so *statisticsOpts) {
|
||||
so.approx = 1
|
||||
}
|
||||
|
||||
//SetStatistics is an option that can passed to Band.SetStatistics()
|
||||
//Available options are:
|
||||
// -ErrLogger
|
||||
type SetStatisticsOption interface {
|
||||
setSetStatisticsOpt(sts *setStatisticsOpt)
|
||||
}
|
||||
|
||||
type setStatisticsOpt struct {
|
||||
errorHandler ErrorHandler
|
||||
}
|
||||
|
||||
//ClearStatistics is an option passed to Dataset.ClearStatistics
|
||||
//Available options are:
|
||||
// -ErrLogger
|
||||
type ClearStatisticsOption interface {
|
||||
setClearStatisticsOpt(sts *clearStatisticsOpt)
|
||||
}
|
||||
|
||||
type clearStatisticsOpt struct {
|
||||
errorHandler ErrorHandler
|
||||
}
|
||||
114
vendor/github.com/airbusgeo/godal/structure.go
generated
vendored
Normal file
114
vendor/github.com/airbusgeo/godal/structure.go
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
// Copyright 2021 Airbus Defence and Space
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package godal
|
||||
|
||||
// Block is a window inside a dataset, starting at pixel X0,Y0 and spanning
|
||||
// W,H pixels.
|
||||
type Block struct {
|
||||
X0, Y0 int
|
||||
W, H int
|
||||
bw, bh int //block size
|
||||
sx, sy int //img size
|
||||
nx, ny int //num blocks
|
||||
i, j int //cur
|
||||
}
|
||||
|
||||
// Next returns the following block in scanline order. It returns Block{},false
|
||||
// when there are no more blocks in the scanlines
|
||||
func (b Block) Next() (Block, bool) {
|
||||
nb := b
|
||||
nb.i++
|
||||
if nb.i >= nb.nx {
|
||||
nb.i = 0
|
||||
nb.j++
|
||||
}
|
||||
if nb.j >= nb.ny {
|
||||
return Block{}, false
|
||||
}
|
||||
nb.X0 = nb.i * nb.bw
|
||||
nb.Y0 = nb.j * nb.bh
|
||||
nb.W, nb.H = actualBlockSize(nb.sx, nb.sy, nb.bw, nb.bh, nb.i, nb.j)
|
||||
|
||||
return nb, true
|
||||
}
|
||||
|
||||
// BlockIterator returns the blocks covering a sizeX,sizeY dataset.
|
||||
// All sizes must be strictly positive.
|
||||
func BlockIterator(sizeX, sizeY int, blockSizeX, blockSizeY int) Block {
|
||||
bl := Block{
|
||||
X0: 0,
|
||||
Y0: 0,
|
||||
i: 0,
|
||||
j: 0,
|
||||
bw: blockSizeX,
|
||||
bh: blockSizeY,
|
||||
sx: sizeX,
|
||||
sy: sizeY,
|
||||
}
|
||||
bl.nx, bl.ny = (sizeX+blockSizeX-1)/blockSizeX,
|
||||
(sizeY+blockSizeY-1)/blockSizeY
|
||||
bl.W, bl.H = actualBlockSize(sizeX, sizeY, blockSizeX, blockSizeY, 0, 0)
|
||||
return bl
|
||||
}
|
||||
|
||||
// BandStructure implements Structure for a Band
|
||||
type BandStructure struct {
|
||||
SizeX, SizeY int
|
||||
BlockSizeX, BlockSizeY int
|
||||
Scale, Offset float64
|
||||
DataType DataType
|
||||
}
|
||||
|
||||
// DatasetStructure implements Structure for a Dataset
|
||||
type DatasetStructure struct {
|
||||
BandStructure
|
||||
NBands int
|
||||
}
|
||||
|
||||
// FirstBlock returns the topleft block definition
|
||||
func (is BandStructure) FirstBlock() Block {
|
||||
return BlockIterator(is.SizeX, is.SizeY, is.BlockSizeX, is.BlockSizeY)
|
||||
}
|
||||
|
||||
// BlockCount returns the number of blocks in the x and y dimensions
|
||||
func (is BandStructure) BlockCount() (int, int) {
|
||||
return (is.SizeX + is.BlockSizeX - 1) / is.BlockSizeX,
|
||||
(is.SizeY + is.BlockSizeY - 1) / is.BlockSizeY
|
||||
}
|
||||
|
||||
// ActualBlockSize returns the number of pixels in the x and y dimensions
|
||||
// that actually contain data for the given x,y block
|
||||
func (is BandStructure) ActualBlockSize(blockX, blockY int) (int, int) {
|
||||
return actualBlockSize(is.SizeX, is.SizeY, is.BlockSizeX, is.BlockSizeY, blockX, blockY)
|
||||
}
|
||||
|
||||
func actualBlockSize(sizeX, sizeY int, blockSizeX, blockSizeY int, blockX, blockY int) (int, int) {
|
||||
cx, cy := (sizeX+blockSizeX-1)/blockSizeX,
|
||||
(sizeY+blockSizeY-1)/blockSizeY
|
||||
if blockX < 0 || blockY < 0 || blockX >= cx || blockY >= cy {
|
||||
return 0, 0
|
||||
}
|
||||
retx := blockSizeX
|
||||
rety := blockSizeY
|
||||
if blockX == cx-1 {
|
||||
nXPixelOff := blockX * blockSizeX
|
||||
retx = sizeX - nXPixelOff
|
||||
}
|
||||
if blockY == cy-1 {
|
||||
nYPixelOff := blockY * blockSizeY
|
||||
rety = sizeY - nYPixelOff
|
||||
}
|
||||
return retx, rety
|
||||
}
|
||||
Reference in New Issue
Block a user