Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fractional-Pixel Polygon Rasterizer #1873

Merged

Conversation

jamesmcclain
Copy link
Member

@jamesmcclain jamesmcclain commented Dec 5, 2016

In this changeset, a polygon rasterizer which reports partial pixels and the respective fractions of those pixels that are covered by the polygon is presented. The approach used seems to be the most efficient that is practical if sub-pixel geometries are to be supported.

  • Bresenham or similar for generating partial pixels

This resource recommends the same method for volumetric calculation as we are envisioning. I have not found any contradictory resources.

@jamesmcclain jamesmcclain force-pushed the feature/fractional-rasterizer branch from 92d3842 to 94aed1d Compare December 6, 2016 20:34
@jamesmcclain jamesmcclain changed the title [WIP] Fractional-Pixel Polygon Rasterizer Fractional-Pixel Polygon Rasterizer Dec 6, 2016
val option = Rasterizer.Options(includePartial = false, sampleType = PixelIsArea)

polygonToEdges(poly, re)
.par
Copy link
Member

Choose a reason for hiding this comment

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

We keep parallelization out of core geotrellis, since we promote parallelization via other means (e.g. spark). It's unclear if that's definitely the right choice, but that's the choice the rest of the library has made.

Perhaps there should be an option that defaulted to false for parallelization?

def foreachCellByPolygon(
poly: Polygon,
re: RasterExtent
)(fn: FractionCallback): Unit = {
Copy link
Member

Choose a reason for hiding this comment

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

We should use a trait instead of Function3, because Function3 isn't specialized. The way we get around this for tile methods is via macros. We would eventually want to macroize this as well, but that can be a TODO.

): Unit = {
// Screen coordinates
val (x0, y0, x1, y1) = edge
val xmin = min(x0, x1)
Copy link
Member

Choose a reason for hiding this comment

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

why call these screen coordinates? The convention in the library is that these are "grid coordinates", and we represent them with col, row, rowMin, etc. This differentiates them from x, y, xmin etc which represent map coordinates.

@jamesmcclain jamesmcclain force-pushed the feature/fractional-rasterizer branch from 94aed1d to e54601e Compare December 6, 2016 23:01
@jamesmcclain jamesmcclain force-pushed the feature/fractional-rasterizer branch from e54601e to 30af5a3 Compare December 7, 2016 02:05
@lossyrob lossyrob merged commit 180e220 into locationtech:master Dec 7, 2016
@jamesmcclain jamesmcclain deleted the feature/fractional-rasterizer branch December 7, 2016 16:33
@lossyrob lossyrob added this to the 1.1 milestone Mar 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants