Transforming a Map Coordinate to a Tile Coordinate
Using the information specified in the section Transforming a Pixel to a Map Coordinate, instead, reverse the affine transform and create a transform that goes from map coordinates to pixels. Feed a coordinate in the map's projection into the affine transform and the result is a coordinate in the map's pixel space. Next, apply the steps from the section Transforming a Pixel to a Tile Coordinate to convert the pixels from map space to a tile coordinate.