CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-fiona

Fiona reads and writes spatial data files

88

1.10x
Overview
Eval results
Files

task.mdevals/scenario-6/

Coordinate Reference System Converter

Build a command-line utility that converts coordinate reference system (CRS) definitions between different formats commonly used in GIS applications.

Requirements

The utility should accept CRS definitions in multiple input formats and convert them to a specified output format. It must handle the following conversions:

Input Formats

  • EPSG codes (e.g., "EPSG:4326")
  • Well-Known Text (WKT) strings
  • PROJ strings
  • Authority strings (e.g., "EPSG:3857")

Output Formats

  • Well-Known Text (WKT)
  • PROJ string representation

Functionality

The program should:

  1. Parse CRS definitions from various input formats
  2. Convert parsed CRS to Well-Known Text (WKT) format
  3. Convert parsed CRS to PROJ string format
  4. Identify whether a CRS is geographic or projected
  5. Handle invalid input gracefully with appropriate error messages

Implementation

@generates

API

def parse_crs(crs_string: str):
    """
    Parse a CRS definition string and return a CRS object.

    Args:
        crs_string: A string representing a CRS in various formats
                   (EPSG code, WKT, PROJ, or authority string)

    Returns:
        A CRS object representing the parsed coordinate reference system

    Raises:
        ValueError: If the CRS string cannot be parsed
    """
    pass

def convert_to_wkt(crs_obj) -> str:
    """
    Convert a CRS object to Well-Known Text format.

    Args:
        crs_obj: A CRS object

    Returns:
        WKT string representation of the CRS
    """
    pass

def convert_to_proj(crs_obj) -> str:
    """
    Convert a CRS object to PROJ string format.

    Args:
        crs_obj: A CRS object

    Returns:
        PROJ string representation of the CRS
    """
    pass

def get_crs_type(crs_obj) -> str:
    """
    Determine if a CRS is geographic or projected.

    Args:
        crs_obj: A CRS object

    Returns:
        'geographic' if the CRS is geographic, 'projected' if projected,
        or 'unknown' if type cannot be determined
    """
    pass

Test Cases

Parses EPSG code

  • Given "EPSG:4326", parse_crs returns a valid CRS object @test

Converts EPSG to WKT

  • Given a CRS created from "EPSG:4326", convert_to_wkt returns a WKT string containing "WGS 84" @test

Identifies geographic CRS

  • Given a CRS created from "EPSG:4326", get_crs_type returns "geographic" @test

Identifies projected CRS

  • Given a CRS created from "EPSG:3857", get_crs_type returns "projected" @test

Handles invalid CRS string

  • Given an invalid string "INVALID:9999", parse_crs raises ValueError @test

Dependencies { .dependencies }

fiona { .dependency }

Provides coordinate reference system handling capabilities.

Install with Tessl CLI

npx tessl i tessl/pypi-fiona

tile.json