Skip to content

Commit

Permalink
Merge pull request #894 from conveyal/mercator-pixel-center
Browse files Browse the repository at this point in the history
Use pixel centers as points in web Mercator grids
  • Loading branch information
abyrd authored Nov 2, 2023
2 parents 0052049 + 94ae3cc commit 0cc9bdd
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

import static com.conveyal.r5.analyst.Grid.latToPixel;
import static com.conveyal.r5.analyst.Grid.lonToPixel;
import static com.conveyal.r5.analyst.Grid.pixelToCenterLat;
import static com.conveyal.r5.analyst.Grid.pixelToCenterLon;
import static com.conveyal.r5.analyst.Grid.pixelToLat;
import static com.conveyal.r5.analyst.Grid.pixelToLon;
import static com.conveyal.r5.common.GeometryUtils.checkWgsEnvelopeSize;
Expand Down Expand Up @@ -82,14 +84,14 @@ public double sumTotalOpportunities () {

@Override
public double getLat(int i) {
long y = i / extents.width + extents.north;
return pixelToLat(y, extents.zoom);
final int y = i / extents.width + extents.north;
return pixelToCenterLat(y, extents.zoom);
}

@Override
public double getLon(int i) {
long x = i % extents.width + extents.west;
return pixelToLon(x, extents.zoom);
final int x = i % extents.width + extents.west;
return pixelToCenterLon(x, extents.zoom);
}

@Override
Expand Down

0 comments on commit 0cc9bdd

Please sign in to comment.