jiayuasu commented on code in PR #2658:
URL: https://github.com/apache/sedona/pull/2658#discussion_r2824650239


##########
common/src/main/java/org/apache/sedona/common/FunctionsProj4.java:
##########
@@ -62,6 +67,93 @@ public class FunctionsProj4 {
   private static final Pattern EPSG_PATTERN =
       Pattern.compile("^EPSG:(\\d+)$", Pattern.CASE_INSENSITIVE);
 
+  /** Name used for the registered URL CRS provider. */
+  private static final String URL_CRS_PROVIDER_NAME = "sedona-url-crs";
+
+  /**
+   * Tracks the currently registered URL CRS provider config (baseUrl + "|" + 
pathTemplate + "|" +
+   * format). Null means no provider registered yet. Uses AtomicReference for 
thread-safe lazy
+   * initialization on executors.
+   */
+  private static final AtomicReference<String> registeredUrlCrsConfig = new 
AtomicReference<>(null);
+
+  /**
+   * Register a URL-based CRS provider with proj4sedona's Defs registry. This 
provider will be
+   * consulted before the built-in provider when resolving EPSG codes.
+   *
+   * <p>This method is safe to call concurrently from multiple threads — it 
uses double-checked
+   * locking so the fast path (already registered with the same config) is 
lock-free, and the
+   * synchronized slow path executes at most once per JVM (or once per config 
change).
+   *
+   * @param baseUrl The base URL of the CRS definition server
+   * @param pathTemplate The URL path template (e.g., 
"/{authority}/{code}.json")
+   * @param format The expected response format: "projjson", "proj", "wkt1", 
or "wkt2"
+   */
+  public static void registerUrlCrsProvider(String baseUrl, String 
pathTemplate, String format) {
+    if (baseUrl == null || baseUrl.isEmpty()) {

Review Comment:
   won't fix because of lock contention



-- 
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]

Reply via email to