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

feat: add preliminary map tile creation #44

Merged
merged 1 commit into from
May 13, 2024
Merged

Conversation

edparris
Copy link
Contributor

@edparris edparris commented May 10, 2024

This PR gives the tile server the ability to create orthorectified tiles from imagery. New classes have been added to define the common WebMercatorQuad tile set and a new function on the GDALTileFactory can be used to create those tiles directly from an image. This processing uses the sensor model and NumPy to calculate the relationships between the original image and the desired tile then the OpenCV remap function does the heavy lifting of manipulating the pixels. Preliminary performance tests were run by integrating this function into the osml-tile-server and running a load test to exercise the map API. The response time was similar to the the regular tile cutting routines so no unusual performance impacts are expected.

Notes

  • This interface has been flagged as experimental and we may choose to update the public API before the next release.
  • This code adds a new dependency on OpenCV.

Checklist

Before you submit a pull request, please make sure you have the following:

  • Code changes are compact and well-structured to facilitate easy review
  • Changes are documented in the README.md and other relevant documentation pages
  • PR title and description accurately reflect the changes and are detailed enough for historical tracking
  • PR contains tests that cover all new code and the code has been manual tested
  • All new dependencies are declared (if any), and no unnecessary libraries are added
  • Performance impacts (if any) of the changes are evaluated and documented
  • Security implications of the changes (if any) are reviewed and addressed
  • I have read the Contributing Guidelines and agree to follow the Code of Conduct

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

drduhe
drduhe previously approved these changes May 12, 2024
from .sar_complex_imageop import histogram_stretch, quarter_power_image

__all__ = ["GDALTileFactory", "histogram_stretch", "quarter_power_image"]
__all__ = [
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we go back and standardize all our inits to use this all pattern?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The __all__ list in an init.py defines the set of module names that are imported when someone imports *. The imagery toolkit modules are already making use of this as a way to explicitly define what is part of the public library API and what is not.

In this PR if a consumer writes from aws.osml.image_processing import * then they will get the names listed here which deliberately excludes the WebMercatorQuadTileSet implementation of MapTileSet. The idea is that users should create these well known tile sets using the factory / enumerated IDs in WellKnownMapTileSet and never need to import or instantiate the concrete implementations directly.

src/aws/osml/image_processing/gdal_tile_factory.py Outdated Show resolved Hide resolved
:param tile_matrix_set_id: the tile set id
:return: the TileSet or None if not available
"""
if tile_matrix_set_id == WellKnownMapTileSet.WEB_MERCATOR_QUAD.value:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should the tile size me an initialization argument perhaps? Might that change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No; the tile size is specified by the tile set. In this specific instance the "WebMercatorQuad" tile set specifies 256x256 tiles and "WebMercatorQuadx2" is almost identical except each tile is 512x512. In the WebMercatorQuadMapTileSet implementation I made tile size an argument so the same code can work for either but here at the factory when an end user is asking for a specific tile set by ID then the tile size is implied.


# If the image has multiple bands then we can stack the results with the band being the 3rd dimension
# in the array. This aligns to how OpenCV wants to work with imagery. If the image doesn't have multiple
# bands then
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like this comment is incomplete?

src_x = (src_x - src_bbox[0]) / 2**r_level
src_y = (src_y - src_bbox[1]) / 2**r_level

# Create 2D linear interpoloators that map the pixels in the map tile to x and y values in the source image.
Copy link
Collaborator

Choose a reason for hiding this comment

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

interpoloators -> interpolators

@edparris edparris force-pushed the feature/basic-map-tiles branch from 251ab25 to 8f21a4c Compare May 13, 2024 15:21
@edparris edparris merged commit bf47f0b into main May 13, 2024
1 check passed
@edparris edparris deleted the feature/basic-map-tiles branch May 13, 2024 16:34
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.

3 participants