Skip to content

Commit

Permalink
Merge branch 'master' into getis-ord
Browse files Browse the repository at this point in the history
  • Loading branch information
james-willis authored Oct 28, 2024
2 parents 78b50aa + 3d0d54d commit ffa9270
Show file tree
Hide file tree
Showing 188 changed files with 1,029 additions and 26,420 deletions.
12 changes: 0 additions & 12 deletions .github/workflows/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,6 @@ jobs:
scala: 2.12.15
jdk: '8'
skipTests: ''
- spark: 3.2.3
scala: 2.12.15
jdk: '8'
skipTests: ''
- spark: 3.1.2
scala: 2.12.15
jdk: '8'
skipTests: ''
- spark: 3.0.3
scala: 2.12.15
jdk: '8'
skipTests: ''
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
Expand Down
73 changes: 26 additions & 47 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,57 +41,37 @@ jobs:
- spark: '3.5.0'
scala: '2.12.8'
python: '3.10'
hadoop: '3'
shapely: '1'
- spark: '3.5.0'
scala: '2.12.8'
python: '3.10'
hadoop: '3'
- spark: '3.5.0'
scala: '2.12.8'
python: '3.9'
hadoop: '3'
- spark: '3.5.0'
scala: '2.12.8'
python: '3.8'
hadoop: '3'
- spark: '3.4.0'
scala: '2.12.8'
python: '3.10'
hadoop: '3'
- spark: '3.4.0'
scala: '2.12.8'
python: '3.9'
hadoop: '3'
- spark: '3.4.0'
scala: '2.12.8'
python: '3.8'
hadoop: '3'
- spark: '3.4.0'
scala: '2.12.8'
python: '3.7'
hadoop: '3'
- spark: '3.4.0'
scala: '2.12.8'
python: '3.7'
hadoop: '3'
shapely: '1'
- spark: '3.3.0'
scala: '2.12.8'
python: '3.8'
hadoop: '3'
- spark: '3.2.0'
scala: '2.12.8'
python: '3.7'
hadoop: '2.7'
- spark: '3.1.2'
scala: '2.12.8'
python: '3.7'
hadoop: '2.7'
- spark: '3.0.3'
scala: '2.12.8'
python: '3.7'
hadoop: '2.7'
env:
VENV_PATH: /home/runner/.local/share/virtualenvs/python-${{ matrix.python }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
Expand All @@ -113,18 +93,6 @@ jobs:
run: |
SPARK_COMPAT_VERSION=${SPARK_VERSION:0:3}
mvn -q clean install -DskipTests -Dspark=${SPARK_COMPAT_VERSION} -Dscala=${SCALA_VERSION:0:4} -Dgeotools
- env:
SPARK_VERSION: ${{ matrix.spark }}
HADOOP_VERSION: ${{ matrix.hadoop }}
run: |
wget https://archive.apache.org/dist/spark/spark-${SPARK_VERSION}/spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}.tgz
wget https://repo.osgeo.org/repository/release/javax/media/jai_core/${JAI_CORE_VERSION}/jai_core-${JAI_CORE_VERSION}.jar
wget https://repo.osgeo.org/repository/release/javax/media/jai_codec/${JAI_CODEC_VERSION}/jai_codec-${JAI_CODEC_VERSION}.jar
wget https://repo.osgeo.org/repository/release/javax/media/jai_imageio/${JAI_IMAGEIO_VERSION}/jai_imageio-${JAI_IMAGEIO_VERSION}.jar
tar -xzf spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}.tgz
mv -v jai_core-${JAI_CORE_VERSION}.jar spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}/jars/
mv -v jai_codec-${JAI_CODEC_VERSION}.jar spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}/jars/
mv -v jai_imageio-${JAI_IMAGEIO_VERSION}.jar spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}/jars/
- run: sudo apt-get -y install python3-pip python-dev-is-python3
- run: sudo pip3 install -U setuptools
- run: sudo pip3 install -U wheel
Expand All @@ -141,32 +109,43 @@ jobs:
echo "Patching Pipfile to use Shapely 1.x"
sed -i 's/^shapely.*$/shapely="<2.0.0"/g' Pipfile
fi
export PIPENV_CUSTOM_VENV_NAME=python-${PYTHON_VERSION}
pipenv --python ${PYTHON_VERSION}
pipenv install pyspark==${SPARK_VERSION}
pipenv install --dev
pipenv graph
- env:
SPARK_VERSION: ${{ matrix.spark }}
HADOOP_VERSION: ${{ matrix.hadoop }}
run: find spark-shaded/target -name sedona-*.jar -exec cp {} spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}/jars/ \;
PYTHON_VERSION: ${{ matrix.python }}
run: |
wget --retry-connrefused --waitretry=10 --read-timeout=20 --timeout=15 --tries=5 https://repo.osgeo.org/repository/release/javax/media/jai_core/${JAI_CORE_VERSION}/jai_core-${JAI_CORE_VERSION}.jar
wget --retry-connrefused --waitretry=10 --read-timeout=20 --timeout=15 --tries=5 https://repo.osgeo.org/repository/release/javax/media/jai_codec/${JAI_CODEC_VERSION}/jai_codec-${JAI_CODEC_VERSION}.jar
wget --retry-connrefused --waitretry=10 --read-timeout=20 --timeout=15 --tries=5 https://repo.osgeo.org/repository/release/javax/media/jai_imageio/${JAI_IMAGEIO_VERSION}/jai_imageio-${JAI_IMAGEIO_VERSION}.jar
mv -v jai_core-${JAI_CORE_VERSION}.jar ${VENV_PATH}/lib/python${PYTHON_VERSION}/site-packages/pyspark/jars
mv -v jai_codec-${JAI_CODEC_VERSION}.jar ${VENV_PATH}/lib/python${PYTHON_VERSION}/site-packages/pyspark/jars
mv -v jai_imageio-${JAI_IMAGEIO_VERSION}.jar ${VENV_PATH}/lib/python${PYTHON_VERSION}/site-packages/pyspark/jars
- env:
SPARK_VERSION: ${{ matrix.spark }}
HADOOP_VERSION: ${{ matrix.hadoop }}
run: (export SPARK_HOME=$PWD/spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION};export PYTHONPATH=$SPARK_HOME/python;cd python;pipenv run pytest tests)
PYTHON_VERSION: ${{ matrix.python }}
run: find spark-shaded/target -name sedona-*.jar -exec cp {} ${VENV_PATH}/lib/python${PYTHON_VERSION}/site-packages/pyspark/jars/ \;
- env:
SPARK_VERSION: ${{ matrix.spark }}
HADOOP_VERSION: ${{ matrix.hadoop }}
PYTHON_VERSION: ${{ matrix.python }}
run: |
export SPARK_HOME=${VENV_PATH}/lib/python${PYTHON_VERSION}/site-packages/pyspark
cd python
source ${VENV_PATH}/bin/activate
pytest tests
- env:
PYTHON_VERSION: ${{ matrix.python }}
run: |
if [ ! -f "spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}/sbin/start-connect-server.sh" ]
if [ ! -f "${VENV_PATH}/lib/python${PYTHON_VERSION}/site-packages/pyspark/sbin/start-connect-server.sh" ]
then
echo "Skipping connect tests for Spark $SPARK_VERSION"
exit
fi
export SPARK_HOME=$PWD/spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}
export PYTHONPATH=$SPARK_HOME/python
export SPARK_HOME=${VENV_PATH}/lib/python${PYTHON_VERSION}/site-packages/pyspark
export SPARK_REMOTE=local
cd python
pipenv install "pyspark[connect]==${SPARK_VERSION}"
pipenv run pytest tests/sql/test_dataframe_api.py
source ${VENV_PATH}/bin/activate
pip install "pyspark[connect]==${SPARK_VERSION}"
pytest tests/sql/test_dataframe_api.py
2 changes: 1 addition & 1 deletion .github/workflows/r.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
strategy:
fail-fast: true
matrix:
spark: [3.0.3, 3.1.2, 3.2.1, 3.3.0, 3.4.0, 3.5.0]
spark: [3.3.0, 3.4.0, 3.5.0]
hadoop: [3]
scala: [2.12.15]
r: [oldrel, release]
Expand Down
22 changes: 17 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ repos:
rev: 24.10.0
hooks:
- id: black-jupyter
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
# - repo: https://github.com/pycqa/isort
# rev: 5.13.2
# hooks:
# - id: isort
# name: isort (python)
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.1
hooks:
Expand Down Expand Up @@ -78,6 +78,18 @@ repos:
- id: forbid-submodules
- id: mixed-line-ending
exclude: \.csv$
- id: name-tests-test
args: [--pytest-test-first]
exclude: |
(?x)^(
python/tests/properties/crs_transform\.py|
python/tests/properties/linestring_properties\.py|
python/tests/properties/point_properties\.py|
python/tests/properties/polygon_properties\.py|
python/tests/sql/resource/sample_data\.py|
python/tests/streaming/spark/cases_builder\.py|
python/tests/tools\.py
)$
- id: requirements-txt-fixer
files: ^docker/sedona-spark-jupyterlab/requirements\.txt$
- id: trailing-whitespace
Expand Down
41 changes: 40 additions & 1 deletion common/src/main/java/org/apache/sedona/common/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ public static InscribedCircle maximumInscribedCircle(Geometry geometry) {
// All non-polygonal geometries use LargestEmptyCircle
if (!geometry.getClass().getSimpleName().equals("Polygon")
&& !geometry.getClass().getSimpleName().equals("MultiPolygon")) {
LargestEmptyCircle largestEmptyCircle = new LargestEmptyCircle(geometry, tolerance);
LargestEmptyCircle largestEmptyCircle = new LargestEmptyCircle(geometry, null, tolerance);
center = largestEmptyCircle.getCenter();
nearest = largestEmptyCircle.getRadiusPoint();
radius = largestEmptyCircle.getRadiusLine().getLength();
Expand Down Expand Up @@ -2266,6 +2266,45 @@ public static Geometry points(Geometry geometry) {
return geometry.getFactory().createMultiPointFromCoords(coordinates);
}

public static Geometry scale(Geometry geometry, double scaleX, double scaleY) {
return scaleGeom(geometry, Constructors.point(scaleX, scaleY));
}

public static Geometry scaleGeom(Geometry geometry, Geometry factor) {
return scaleGeom(geometry, factor, null);
}

public static Geometry scaleGeom(Geometry geometry, Geometry factor, Geometry origin) {
if (geometry == null || factor == null || geometry.isEmpty() || factor.isEmpty()) {
return geometry;
}

if (!factor.getGeometryType().equalsIgnoreCase(Geometry.TYPENAME_POINT)) {
throw new IllegalArgumentException("Scale factor geometry should be a Point type.");
}

Geometry resultGeom = null;
AffineTransformation scaleInstance = null;
Coordinate factorCoordinate = factor.getCoordinate();

if (origin == null || origin.isEmpty()) {
scaleInstance =
AffineTransformation.scaleInstance(factorCoordinate.getX(), factorCoordinate.getY());
resultGeom = scaleInstance.transform(geometry);
} else {
Coordinate falseOrigin = origin.getCoordinate();
scaleInstance =
AffineTransformation.scaleInstance(
factorCoordinate.getX(),
factorCoordinate.getY(),
falseOrigin.getX(),
falseOrigin.getY());
resultGeom = scaleInstance.transform(geometry);
}

return resultGeom;
}

public static Geometry rotateX(Geometry geometry, double angle) {
if (GeomUtils.isAnyGeomEmpty(geometry)) {
return geometry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,15 @@ public boolean equals(InscribedCircle other) {
&& this.nearest.equals(other.nearest)
&& Math.abs(this.radius - other.radius) < epsilon;
}

public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj == null || obj.getClass() != this.getClass()) {
return false;
}
InscribedCircle other = (InscribedCircle) obj;
return this.equals(other);
}
}
Loading

0 comments on commit ffa9270

Please sign in to comment.