-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose GDAL Metadata API, expose RasterSources Metadata API #216
Expose GDAL Metadata API, expose RasterSources Metadata API #216
Conversation
b1b3f85
to
3620ca4
Compare
vlm/src/main/scala/geotrellis/contrib/vlm/RasterSourceMetadata.scala
Outdated
Show resolved
Hide resolved
vlm/src/main/scala/geotrellis/contrib/vlm/RasterSourceMetadata.scala
Outdated
Show resolved
Hide resolved
3620ca4
to
fe6a5ba
Compare
3e3fb55
to
0cef544
Compare
0cef544
to
c3f4a5d
Compare
@@ -42,41 +42,11 @@ import java.util.ServiceLoader | |||
* @groupdesc reproject Functions to resample raster data in target projection. | |||
* @groupprio reproject 2 | |||
*/ | |||
trait RasterSource extends CellGrid[Long] with Serializable { | |||
trait RasterSource extends CellGrid[Long] with RasterSourceMetadata with Serializable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mixin makes any sense? CellGrid[Long] with RasterSourceMetadata
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question.... what is gained by having it subclass CellGrid[Long]
. Should RasterSourceMetadata
be the one to extend it? At least at a superficial level, both feel a bit like responsibility leakage into RasterSource
.
There's an argument that the relationship between RasterSource
and RasterSourceMetadata
should be a "has a" relationship and not an "is a" one. I tend to lean toward smaller, multiply nested types (more "has a"), but that can get annoying to traverse. If I were implementing this I would probably have RasterSource
extend neither (or keep CellGrid
if it's already depended upon), and then have a method metadata: RasterSourceMetadata
that the user hits to get the deets. And then add convenience forwarding methods as needed for a subset of fields such as crs
, bandCount
, etc. It's an approach emphasizing separation of concerns over convenience, which, like anything, can be taken too far. I think my main argument would be that it's easier to add things later than to take them away if the abstraction isn't quite right.
3daef0d
to
e4c4db6
Compare
@echeipesh I am not sure does the commit pomadchin@ec533ea makes things better or not :/ need a pair of fresh eyes here. I even decided to roll it back, since I don't like it. However I put it into a separate branch for the history / review purposes. |
vlm/src/main/scala/geotrellis/contrib/vlm/avro/GeoTrellisMetadata.scala
Outdated
Show resolved
Hide resolved
e4c4db6
to
69b5562
Compare
vlm/src/test/scala/geotrellis/contrib/vlm/avro/GeotrellisRasterSourceSpec.scala
Outdated
Show resolved
Hide resolved
ec533ea
to
cffb32a
Compare
cffb32a
to
783068b
Compare
import com.azavea.gdal.GDALWarp | ||
|
||
case class GDALDataset(token: Long) extends AnyVal { | ||
def getAllMetadataFlatten(dataset: Int): Map[String, String] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
|
||
/** https://github.com/OSGeo/gdal/blob/b1c9c12ad373e40b955162b45d704070d4ebf7b0/gdal/doc/source/development/rfc/rfc43_getmetadatadomainlist.rst */ | ||
def getMetadataDomainList(dataset: Int, band: Int): List[String] = { | ||
val arr = Array.ofDim[Byte](100, 1 << 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said before, I think this is half the cause of the performance issues (triggering lots of copies to happen around the JNI boundary). Hoping this signature is considered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@metasim I need to benchmark @jamesmcclain bindings; I think it is a completely separate issue now, as probably requires some investigation time
|
||
new String(arr, "UTF-8").trim | ||
} | ||
|
||
def getProjection: Option[String] = getProjection(GDALWarp.WARPED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you document something about the (expected) returned string format? If it's guaranteed to be a well-formed/parseable structure, should we type-tag it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or mb even opaque types (https://github.com/estatico/scala-newtype); but it is not a part of this PR
@@ -42,41 +42,11 @@ import java.util.ServiceLoader | |||
* @groupdesc reproject Functions to resample raster data in target projection. | |||
* @groupprio reproject 2 | |||
*/ | |||
trait RasterSource extends CellGrid[Long] with Serializable { | |||
trait RasterSource extends CellGrid[Long] with RasterSourceMetadata with Serializable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question.... what is gained by having it subclass CellGrid[Long]
. Should RasterSourceMetadata
be the one to extend it? At least at a superficial level, both feel a bit like responsibility leakage into RasterSource
.
There's an argument that the relationship between RasterSource
and RasterSourceMetadata
should be a "has a" relationship and not an "is a" one. I tend to lean toward smaller, multiply nested types (more "has a"), but that can get annoying to traverse. If I were implementing this I would probably have RasterSource
extend neither (or keep CellGrid
if it's already depended upon), and then have a method metadata: RasterSourceMetadata
that the user hits to get the deets. And then add convenience forwarding methods as needed for a subset of fields such as crs
, bandCount
, etc. It's an approach emphasizing separation of concerns over convenience, which, like anything, can be taken too far. I think my main argument would be that it's easier to add things later than to take them away if the abstraction isn't quite right.
gdal/src/main/scala/geotrellis/contrib/vlm/gdal/GDALMetadata.scala
Outdated
Show resolved
Hide resolved
f31ddd5
to
ce1e404
Compare
dataset.getMetadata(GDALWarp.SOURCE, domains, 0), | ||
(1 until dataset.bandCount).toList.map(dataset.getMetadata(GDALWarp.SOURCE, domains, _)) | ||
) | ||
case FullDomainList => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mb it should be AllMetadataDomainsList
? Or smth like that.
Travis is down for some reason :/ in my fork it passes tests https://travis-ci.org/pomadchin/geotrellis-contrib/jobs/566145813 |
…etadata collection, simplify the metadata concept.
ce1e404
to
a93ab9e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 after GDALWarp.WARPED
becomes an ADT and GDALMetadataDomainList
gets deleted in favor of GDALRasterSource.metadataForAllDomains
49978c4
to
35b1167
Compare
35b1167
to
fade0f4
Compare
Overview
This PR exposes the metadata that is not covered by the RasterSources API, such as tiff tags / extra metadata that can be interpreted as a string.
In terms of this PR we've tried to look how other GIS libraries collect imagery metadata, and it looks like there is no a standard interface to work with rather than a
Map[String, String]
.Checklist
Closes #181