Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ public static Double angularWidth(Envelope envelope) {
double distance = g.s12; // Distance in meters

// Convert distance to angular width in degrees
Double angularWidth =
Math.toDegrees(distance / (Geodesic.WGS84.EquatorialRadius() * Math.PI / 180));
Double angularWidth = distance / (Geodesic.WGS84.EquatorialRadius() * Math.PI / 180);

return angularWidth;
}
Expand All @@ -213,8 +212,7 @@ public static Double angularHeight(Envelope envelope) {
double distance = g.s12; // Distance in meters

// Convert distance to angular height in degrees
Double angularHeight =
Math.toDegrees(distance / (Geodesic.WGS84.EquatorialRadius() * Math.PI / 180));
Double angularHeight = distance / (Geodesic.WGS84.EquatorialRadius() * Math.PI / 180);

return angularHeight;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3391,10 +3391,10 @@ public void testBufferSpheroidal() throws ParseException {
"POLYGON ((-179.908607846266 24.025403116254306, -177.99876698499668 23.825660822056278, -176.1851748144233 23.267372220454533, -174.54862792786022 22.380090414241554, -173.15522797402008 21.20765453023379, -172.05367901642606 19.803908497939666, -171.27542809803106 18.22850022788734, -170.83670228698406 16.543486102335997, -170.7412636921777 14.811036901560918, -170.9829095910743 13.092142713348924, -171.5471495735382 11.445952123266512, -172.41190582467604 9.929276420592164, -173.54741832839647 8.595821727211286, -174.91577148479777 7.494852554680671, -176.47058207976102 6.669211334615649, -178.157376393358 6.152879352694568, -179.9150124655878 5.968498588196282, 179.9878642700213 5.967715967762297, 178.22454996382154 6.1243064565567416, 176.52190735292885 6.617190677478861, 174.94354089208682 7.427303247307942, 173.5475157235323 8.522934832546376, 172.38432738193248 9.861905503007021, 171.4959038990676 11.393986435009106, 170.9153886431351 13.063103234007537, 170.66721922346738 14.80905645479948, 170.76695775874103 16.568760623485606, 171.22043647400534 18.277247812024235, 172.02203612722943 19.86884329704546, 173.1522881340142 21.278955415388584, 174.5754355707626 22.446796923405344, 176.2379815998183 23.319060447498003, 178.06938085914476 23.854152382752126, 179.98566424517946 24.026184454399257, -179.908607846266 24.025403116254306))");
Geometry expected8 =
geomFromEWKT(
"POLYGON ((179 -15.000873160293315, 178.999824747382 -15.000856382797105, 178.99965622962375 -15.000806695050459, 178.9995009227683 -15.000726006503347, 178.999364795171 -15.000617417938033, 178.99925307813902 -15.000485102312915, 178.9991700648953 -15.000334144403906, 178.99911894559222 -15.00017034540551, 178.9991016847159 -14.999999999999092, 178.9991016847159 14.99999999999908, 178.99911894559222 15.00017034540551, 178.9991700648953 15.000334144403906, 178.99925307813902 15.000485102312902, 178.999364795171 15.000617417938045, 178.9995009227683 15.000726006503333, 178.99965622962375 15.000806695050459, 178.999824747382 15.000856382797105, 179 15.000873160293315, -179.00000000000003 15.000873160293315, -178.99982474738198 15.000856382797105, -178.99965622962375 15.000806695050459, -178.9995009227683 15.000726006503333, -178.99936479517098 15.000617417938045, -178.99925307813902 15.000485102312902, -178.99917006489528 15.000334144403906, -178.9991189455922 15.00017034540551, -178.99910168471592 14.99999999999908, -178.99910168471592 -14.999999999999092, -178.9991189455922 -15.00017034540551, -178.99917006489528 -15.000334144403906, -178.99925307813902 -15.000485102312915, -178.99936479517098 -15.000617417938033, -178.9995009227683 -15.000726006503347, -178.99965622962375 -15.000806695050459, -178.99982474738198 -15.000856382797105, -179.00000000000003 -15.000873160293315, 179 -15.000873160293315))");
"POLYGON ((178.9999957907089 -15.000903596473622, 178.99981605472888 -15.000885740363822, 178.9996432665321 -15.000834429161598, 178.99948395250945 -15.000751600936063, 178.99934413010374 -15.000640384187193, 178.999229080519 -15.000504979676391, 178.99914314924223 -15.00035050175554, 178.99908958191227 -15.000182785188626, 178.99907040173593 -15.000008164763253, 178.99907040173593 15.000008164763253, 178.99908958191227 15.000182785188626, 178.99914314924223 15.00035050175554, 178.999229080519 15.000504979676391, 178.99934413010374 15.000640384187193, 178.99948395250945 15.000751600936063, 178.9996432665321 15.000834429161598, 178.99981605472888 15.000885740363822, 178.9999957907089 15.000903596473622, -178.99999579488448 15.000902045906788, -178.99981328322758 15.000883609256881, -178.9996380712079 15.000830628745314, -178.9994770086097 15.000745175629842, -178.99933639202962 15.000630590654932, -178.99922171871367 15.000491353441594, -178.99913747164914 15.000332907354343, -178.9990869443138 15.000161446693122, -178.9990721119315 14.999983674530355, -178.9990721119315 -14.999983674530355, -178.9990869443138 -15.000161446693122, -178.99913747164914 -15.000332907354343, -178.99922171871367 -15.000491353441594, -178.99933639202962 -15.000630590654932, -178.9994770086097 -15.000745175629842, -178.9996380712079 -15.000830628745314, -178.99981328322758 -15.000883609256881, -178.99999579488448 -15.000902045906788, 178.9999957907089 -15.000903596473622))");
Geometry expected9 =
geomFromEWKT(
"POLYGON ((178 -18.747248844374, 176.24747381949112 -18.582729101204464, 174.5622962372712 -18.0945531116537, 173.0092276827665 -17.29887379200776, 171.64795170955566 -16.222572896097414, 170.53078138987692 -14.903037762363958, 169.70064895259912 -13.387566659631126, 169.18945592174327 -11.73221950803158, 169.01684715880478 -9.999999999999265, 169.01684715880478 9.999999999999238, 169.18945592174327 11.73221950803157, 169.70064895259912 13.387566659631101, 170.53078138987692 14.903037762363944, 171.64795170955566 16.2225728960974, 173.0092276827665 17.298873792007747, 174.5622962372712 18.094553111653685, 176.24747381949112 18.582729101204453, 178 18.747248844373974, -178 18.747248844373974, -176.24747381949115 18.582729101204453, -174.56229623727123 18.094553111653685, -173.00922768276646 17.298873792007747, -171.64795170955566 16.2225728960974, -170.5307813898769 14.903037762363944, -169.70064895259912 13.387566659631101, -169.18945592174325 11.73221950803157, -169.0168471588048 9.999999999999238, -169.0168471588048 -9.999999999999265, -169.18945592174325 -11.73221950803158, -169.70064895259912 -13.387566659631126, -170.5307813898769 -14.903037762363972, -171.64795170955566 -16.222572896097414, -173.00922768276646 -17.29887379200776, -174.56229623727123 -18.0945531116537, -176.24747381949115 -18.582729101204464, -178 -18.747248844374, 178 -18.747248844374))");
"POLYGON ((177.9549995416554 -19.040094935317835, 176.11434781653608 -18.85284309323023, 174.35693335915332 -18.312833546632955, 172.75892069701706 -17.445729285603573, 171.38477758716215 -16.29151182562638, 170.28436137749944 -14.900872725390832, 169.49233786416985 -13.331457888391856, 169.02929359537578 -11.64464082255408, 168.9036172802648 -9.903154239380708, 168.9036172802648 9.903154239380708, 169.02929359537578 11.644640822554088, 169.49233786416985 13.331457888391858, 170.28436137749944 14.900872725390835, 171.38477758716215 16.291511825626383, 172.75892069701706 17.445729285603576, 174.35693335915332 18.31283354663296, 176.11434781653608 18.85284309323023, 177.9549995416554 19.040094935317835, -177.87900985512576 19.007598545952018, -176.03054595864288 18.788450939408023, -174.2789941686595 18.21455302093928, -172.69957660725598 17.31634002547884, -171.35403397135434 16.137635031716854, -170.28849568727753 14.731558908748932, -169.53373124250396 13.156632392026058, -169.1069396813116 11.47370649042299, -169.01406048680477 9.743956042208017, -169.01406048680477 -9.743956042208017, -169.1069396813116 -11.47370649042299, -169.53373124250396 -13.156632392026058, -170.28849568727753 -14.731558908748932, -171.35403397135434 -16.137635031716854, -172.69957660725598 -17.31634002547884, -174.2789941686595 -18.21455302093928, -176.03054595864288 -18.788450939408023, -177.87900985512576 -19.007598545952018, 177.9549995416554 -19.040094935317835))");

Geometry postgis_result1 =
geomFromEWKT(
Expand Down Expand Up @@ -3567,6 +3567,18 @@ public void testBestSRID() throws ParseException {
"Expected World Mercator projection for wide range geometry", expectedEPSG, actualEPSG);
}

@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
public void nRingsUnsupported() {
LineString lineString =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* 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.
*/
package org.apache.sedona.common.sphere;

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

import org.junit.Test;
import org.locationtech.jts.geom.Envelope;
import org.locationtech.jts.io.ParseException;

public class SpheroidTest {

@Test
public void testAngularHeight() throws ParseException {
Double actual =
Spheroid.angularHeight(geomFromWKT("LINESTRING (0 90, 0 -90)", 4326).getEnvelopeInternal());

assertEquals(180.0, actual, 0.5);
}

@Test
public void testAngularWidth() throws ParseException {
Double actual =
Spheroid.angularWidth(geomFromWKT("LINESTRING (-90 0, 90 0)", 4326).getEnvelopeInternal());

assertEquals(180.0, actual, 0.5);
}

@Test
public void testAngularWidthAndHeightNearPolesAndAntiMeridian() throws ParseException {
Envelope env =
geomFromWKT("LINESTRING (-179.9999994 -82.42408, -157.330902 -85.0511284)", 4326)
.getEnvelopeInternal();
Double actualAngularHeight = Spheroid.angularHeight(env);
Double actualAngularWidth = Spheroid.angularWidth(env);

assertEquals(2.63, actualAngularHeight, 0.01);
assertEquals(2.46, actualAngularWidth, 0.01);
}
}
2 changes: 1 addition & 1 deletion python/tests/sql/test_dataframe_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
),
(stf.ST_AsText, ("point",), "point_geom", "", "POINT (0 1)"),
(stf.ST_Azimuth, ("a", "b"), "two_points", "geom * 180.0 / pi()", 90.0),
(stf.ST_BestSRID, ("geom",), "triangle_geom", "", 3395),
(stf.ST_BestSRID, ("geom",), "triangle_geom", "", 32631),
(
stf.ST_Boundary,
("geom",),
Expand Down
2 changes: 1 addition & 1 deletion python/tests/sql/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def test_st_bestsrid(self):
)
function_df.show()
actual = function_df.take(1)[0][0]
assert actual == 3395
assert actual == 32614

def test_st_shiftlongitude(self):
function_df = self.spark.sql(
Expand Down
Loading