C Creating and Using Raster Tile Service for Web Application
This appendix describes the raster tile service for web applications with examples.
In modern web mapping and geospatial applications, large raster datasets are commonly served through web URLs as smaller and manageable pieces called raster tiles. This tiling approach allows efficient access and web-based delivery of imagery and raster data at various levels of detail, which also reduces the complexity of web application development. With the GeoRaster database, you can serve any imagery and raster data to the web using this tiling approach. For example, through this raster tile service, users can stream imagery and DEM rasters to the web for further processing and 3D visualizations. In the background, each raster tile in the service is built and served natively in the database from one or more GeoRaster objects, regardless of the underlying raster storage format.
A raster dataset is split into a grid of square tiles (commonly 256x256
pixels) across multiple zoom levels, each zoom level (z) increases the number of tiles
exponentially following a 2^z x 2^z pattern. At zoom level zero, one
tile covers the entire world. Given that the standard tiles are 256x256 pixels, the
resolution of a pixel on the equator can be calculated by dividing the Earth's
equatorial circumference by the tile's pixel dimension size. The resolution at zoom
level zero is approximately 156,534 meters. At zoom level 22, the resolution of a pixel
is approximately 3.7 centimeters per pixel.
In the Web Mercator projection, the resolution changes with latitude. The position of each tile within this grid is specified by its horizontal (x) and vertical (y) indices at the given zoom level. This addressing system, often referred to as the XYZ scheme (see OGC WebMercatorQuad at 17-083r4 specification document), enables users or applications to request only the specific tile needed for a particular map view and zoom setting.
For example, at zoom level 2 the raster is divided into 16 tiles (4 columns
by 4 rows). A request for tile x=1, y=2, z=2, retrieves a specific
section of the raster at the resolution with zoom level two. This approach greatly
improves the performance and scalability of web mapping applications by optimizing image
retrieval and display.
The SDO_GEOR_UTL.get_rasterTile function in Oracle AI Database can
retrieve a specific raster tile from a virtual mosaic of one or more GeoRaster objects.
Additionally, a REST endpoint can be created to retrieve that raster tile by specifying
the zoom level (z) and the tile coordinates (x and
y). This is particularly useful for displaying rasters stored in a
database on an interactive map.
To implement the preceding functionality, Oracle REST Data Services (ORDS) can be used to create a REST endpoint to render raster tiles from GeoRaster objects stored in an Oracle AI Database.
For instance, consider the following REST endpoint created by ORDS:
GET /ords/scott/service1/vegetation/{z}/{x}/{y}
This endpoint internally calls the SDO_GEOR_UTL.get_rasterTile function.
When you provision an Autonomous AI Database instance, by default Oracle REST Data Services (ORDS) is preconfigured and available for the instance. Additionally, you can configure Autonomous AI Database to use ORDS running in a customer managed environment, where you are responsible for configuration, patching, and maintenance. See Installing and Configuring Customer Managed ORDS on Autonomous Database for more information.
If the endpoints created for the tiling services require authentication, you can use one of the following authentication methods supported by ORDS:
- OAuth authentication: Secure the endpoint using OAuth 2.0 client
credentials. Create ORDS roles and privileges, assign them to OAuth clients, and
obtain an access token to send bearer requests. Ensure tokens are transmitted only
over secure channels.
- See ORDS PL/SQL Package Reference for more information on creating roles and privileges.
- See OAUTH PL/SQL Package Reference for more information on creating clients (applicable to all environments, including Autonomous AI Database).
- See ORDS: Build Powerful, Secure, RESTful ORDS APIs for Your Oracle Autonomous Database for Autonomous AI Database.
- Basic authentication with ORDS users: Use ORDS user credentials
for simple access control. To add this authentication method, create ORDS roles and
privileges using the ORDS PL/SQL package procedures and assign them to an ORDS user.
- See ORDS PL/SQL Package Reference for more information on creating roles and privileges.
- See Installing and Configuring Oracle REST Data Services for more information on creating users.
Note: This ORDS authentication method is not supported in Oracle Cloud Console. For Autonomous AI Database, you must install and configure ORDS in a customer-managed environment.
- Custom authentication using pre-hooks: Implement custom
authentication logic by creating a PL/SQL function which is invoked before the
endpoint is called. For additional guidance, see Overview of Pre-hook
Functions.
Note: This ORDS authentication method is not supported on Oracle Cloud Console. For Autonomous AI Database, you must install and configure ORDS in a customer-managed environment.
Regardless of the authentication method you choose, the GIS system must be configured to send the required credentials or access token when calling the secured endpoint. For example, with MapLibre, you can provide the credentials or access token as a header. See RequestParameters - MapLibre GL JS for more information.
Also, ensure that the chosen method complies with your organization's security policies and guidelines.
The following two examples describe the tiling service using ORDS. Each example creates an endpoint that retrieves a virtual mosaic of multiple GeoRaster objects on a tile-by-tile basis. The created endpoints for these tiling services can be further used to setup raster layers in web applications using MapLibre or any other GIS systems that support a raster tile source.
Before proceeding, ensure that you meet following prerequisites:
- ORDS is installed and configured. See Installing and Configuring Oracle REST Data Services for more information.
- Raster data is stored as SDO_GEORASTER objects in a database table.
- Raster tile services are supported only if Oracle Java is enabled on your Oracle Autonomous AI Database Serverless deployments. To enable Oracle Java, see Enable Oracle Java for more information.