Skip to content

[BUG]: ST_BestSRID is not returning Lambert Azimuthal Equal Area projection for geometries near the poles #2901

@ThomasDekeyser

Description

@ThomasDekeyser

Expected behavior

For a LineString or any (small) geometry g near the poles, the best SRID returned by should return South/North Pole Lambert Azimuthal Equal Area projection.
As a result, the ST_Buffer(g,..., useSpheroid=true) that is using ST_BestSRID, is also returning wrong results.

int result = Functions.bestSRID(geomFromWKT("LINESTRING (-179.9999994 -82.42408, -157.330902 -85.0511284)", 4326));
assertEquals(Spheroid.EPSG_SOUTH_LAMBERT, result);

Actual behavior

int result = Functions.bestSRID(geomFromWKT("LINESTRING (-179.9999994 -82.42408, -157.330902 -85.0511284)", 4326))
assertEquals(Spheroid.EPSG_WORLD_MERCATOR, result);

Reproducer

src/test/java/org/apache/sedona/common/FunctionsTest2.java

package org.apache.sedona.common;

import org.apache.sedona.common.sphere.Spheroid;
import org.junit.Test;
import org.locationtech.jts.io.ParseException;

import static org.apache.sedona.common.Constructors.geomFromWKT;
import static org.junit.Assert.assertEquals;

public class FunctionsTest2 extends TestBase {

  @Test
  public void testBestSRIDNearSouthPole() throws ParseException {
    int actualEPSG = Functions.bestSRID(geomFromWKT("LINESTRING (-179.9999994 -82.42408, -157.330902 -85.0511284)", 4326));

    assertEquals(
      "Expected South Pole Lambert Azimuthal Equal Area projection near the south pole", Spheroid.EPSG_SOUTH_LAMBERT, actualEPSG);

  }
}

Test fails with:

java.lang.AssertionError: Expected South Pole Lambert Azimuthal Equal Area projection near the south pole 
Expected :3409
Actual   :3395

Environment

  • sedona: reproduced on 1.8.0 but bug is also on 1.8.1, 1.9.0 & master
  • Apache Spark: 3.4.0
  • Scala: 2.12.18
  • Java: ZuluJDK 11
  • OS: MacOS Tahoe 26.4.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions