szehon-ho commented on code in PR #54571: URL: https://github.com/apache/spark/pull/54571#discussion_r2893785314
########## dev/generate_srs_registry.py: ########## @@ -0,0 +1,401 @@ +#!/usr/bin/env python3 + +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +""" +Generate the Spatial Reference System (SRS) registry for Apache Spark. + +Downloads CRS definitions from the PROJ (Cartographic Projections and +Coordinate Transformations Library) GitHub repository and generates a CSV +file used by Spark for geospatial types on both the JVM and Python sides. + +PROJ is a C/C++ library (https://proj.org/) that maintains the authoritative +EPSG and ESRI CRS databases. This script extracts SRID metadata from PROJ's +SQL source files, which contain easily parseable plain-text SRS information. + +The script produces entries from the following PROJ SQL files: + - geodetic_crs.sql (EPSG geodetic CRS: geographic, geocentric, etc.) + - projected_crs.sql (EPSG projected CRS) + - compound_crs.sql (EPSG compound CRS) + - vertical_crs.sql (EPSG vertical CRS) + - engineering_crs.sql (EPSG engineering CRS) + - esri.sql (ESRI geodetic, projected, compound, vertical, engineering CRS) + +Additionally, the following special entries are added: + - SRID 0 -> SRID:0 (Spark convention: Cartesian, no defined SRS) + - SRID 4267 -> OGC:CRS27 (OGC standardization of NAD27) + - SRID 4269 -> OGC:CRS83 (OGC standardization of NAD83) + - SRID 4326 -> OGC:CRS84 (OGC standardization of WGS 84) + +Prerequisites: + Python 3.9+ (no third-party packages required) + +Usage: + # Generate from the default PROJ version: + python dev/generate_srs_registry.py + + # Generate from a specific PROJ version: + python dev/generate_srs_registry.py --proj-version 9.7.1 + + # Verify the generated files: + wc -l sql/api/src/main/resources/org/apache/spark/sql/srs_registry.csv + wc -l python/pyspark/sql/srs_registry.csv + +Upgrade workflow: + 1. Update `DEFAULT_PROJ_VERSION` to the new PROJ release tag. + 2. Run this script using `python dev/generate_srs_registry.py`. + 3. Review the diff to see which SRIDs were added or removed. Review Comment: just curious, is it common SRID is removed? @mkaravel -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
