Skip to content

Add TMS (Tile Map Service) support #95

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

Merged
merged 11 commits into from
Apr 1, 2025
Merged

Add TMS (Tile Map Service) support #95

merged 11 commits into from
Apr 1, 2025

Conversation

ronitjadhav
Copy link
Member

@ronitjadhav ronitjadhav commented Mar 10, 2025

Overview

This PR adds support for TMS (Tile Map Service) to the ogc-client library, extending its capabilities beyond WMS, WMTS, WFS, and OGC-API to now include TMS-compliant services according to the Tile Map Service Specification.

Features Added

TMS Endpoint

Implemented TmsEndpoint class with the following methods:

  • getEndpointInfo(): Retrieves basic information about the TMS endpoint, including title, abstract, and keywords
  • getAllTileMaps(): Fetches available tile maps from the TMS service, filtering to a specific tile map if the endpoint points to one
  • getTileMapInfo(href): Retrieves detailed information about a specific tile map by URL

The class handles proper caching of service data through internal methods:

  • Private getServiceData(): Fetches and caches TMS service data
  • Private getFilteredData(): Applies filtering based on the endpoint URL

Utility Functions

  • normalizeUrl(url): Ensures consistent URL formatting with lowercase hostname and trailing slash
  • getParentPath(url): Extracts parent path from versioned TMS URLs
  • fetchXml(url): Fetches XML content with robust error handling for:
    • Network failures
    • Non-XML responses
    • XML with or without declaration

Implementation Details

The implementation closely follows the TMS specification while maintaining consistency with the API design pattern used throughout ogc-client. This ensures a familiar interface for developers already using the library for other OGC services.

Current Limitations

  • Root resource handling as described in the TMS specification is not yet implemented and will be addressed in a future update

Testing

Comprehensive unit tests cover:

  • URL normalization with various edge cases
  • XML fetching with different response types
  • Error handling for network issues and invalid content
  • TmsEndpoint class functionality for retrieving endpoint information and tile maps

Usage Example

import { TmsEndpoint } from '@camptocamp/ogc-client';

// Create a TMS endpoint
const endpoint = new TmsEndpoint('https://ahocevar.com/geoserver/gwc/service/tms/1.0.0/');

// Get endpoint information
const info = await endpoint.tileMapServiceInfo;
console.log(info.title, info.abstract);

// Get all available tile maps
const tileMaps = await endpoint.allTileMaps;

// Get detailed information for a specific tile map
const tileMapDetails = await endpoint.getTileMapInfo(tileMaps[0].href);

@ronitjadhav
Copy link
Member Author

@jahow

I made updates as we had discussed. Here's a summary of the changes:

  • profile and tileSets are now direct properties for TileMapInfo Structure
  • Converted async methods to getters
  • Enhanced component reuse in Vue app
  • Moved getParentPath to shared module and reused it for TMS
  • Improved XML parsing for different server implementations

Copy link
Member

@jahow jahow left a comment

Choose a reason for hiding this comment

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

Thank you, good job! that looks good, I just have a question regarding the bounding box. Please merge when you feel it's ready :)

Comment on lines 96 to 103
return Array.isArray(this.tileMap.boundingBox)
? this.tileMap.boundingBox
: [
this.tileMap.boundingBox?.minx,
this.tileMap.boundingBox?.miny,
this.tileMap.boundingBox?.maxx,
this.tileMap.boundingBox?.maxy,
];
Copy link
Member

Choose a reason for hiding this comment

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

Is that something that application code would be expected to do? IT sounds like the Bbox should always be an array

@ronitjadhav ronitjadhav merged commit b1a75df into main Apr 1, 2025
1 check passed
@ronitjadhav ronitjadhav deleted the TMS branch April 1, 2025 20:48
@jahow jahow mentioned this pull request Jun 19, 2025
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