Skip to content

Commit

Permalink
[SEDONA-561] Fix the examples in the core.showcase package (#1431)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangfengcdt committed May 28, 2024
1 parent 03cb670 commit 6ac48f5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ public Iterator<Point> call(Geometry spatialObject)
throws Exception
{
List<Point> result = new ArrayList<Point>();
if (spatialObject == null) {
throw new Exception("[ShapefileRDD] the object is null");
}
if (spatialObject instanceof MultiPoint) {
MultiPoint multiObjects = (MultiPoint) spatialObject;
for (int i = 0; i < multiObjects.getNumGeometries(); i++) {
Expand Down Expand Up @@ -182,6 +185,9 @@ public Iterator<Polygon> call(Geometry spatialObject)
throws Exception
{
List<Polygon> result = new ArrayList<Polygon>();
if (spatialObject == null) {
throw new Exception("[ShapefileRDD] the object is null");
}
if (spatialObject instanceof MultiPolygon) {
MultiPolygon multiObjects = (MultiPolygon) spatialObject;
for (int i = 0; i < multiObjects.getNumGeometries(); i++) {
Expand Down Expand Up @@ -215,6 +221,9 @@ public Iterator<LineString> call(Geometry spatialObject)
throws Exception
{
List<LineString> result = new ArrayList<LineString>();
if (spatialObject == null) {
throw new Exception("[ShapefileRDD] the object is null");
}
if (spatialObject instanceof MultiLineString) {
MultiLineString multiObjects = (MultiLineString) spatialObject;
for (int i = 0; i < multiObjects.getNumGeometries(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.apache.sedona.common.enums.FileDataSplitter;
import org.apache.sedona.core.enums.GridType;
import org.apache.sedona.core.enums.IndexType;
import org.apache.sedona.core.formatMapper.shapefileParser.ShapefileRDD;
import org.apache.sedona.core.formatMapper.shapefileParser.ShapefileReader;
import org.apache.sedona.core.serde.SedonaKryoRegistrator;
import org.apache.sedona.core.spatialOperator.JoinQuery;
import org.apache.sedona.core.spatialOperator.KNNQuery;
Expand All @@ -40,6 +40,7 @@
import org.locationtech.jts.geom.Envelope;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.Point;
import org.apache.sedona.core.spatialRDD.SpatialRDD;

import java.io.Serializable;
import java.util.List;
Expand Down Expand Up @@ -166,13 +167,13 @@ public static void main(String[] args)
PointRDDSplitter = FileDataSplitter.CSV;
PointRDDIndexType = IndexType.RTREE;
PointRDDNumPartitions = 5;
PointRDDOffset = 0;
PointRDDOffset = 1;

PolygonRDDInputLocation = resourceFolder + "primaryroads-polygon.csv";
PolygonRDDSplitter = FileDataSplitter.CSV;
PolygonRDDNumPartitions = 5;
PolygonRDDStartOffset = 0;
PolygonRDDEndOffset = 8;
PolygonRDDEndOffset = 9;

geometryFactory = new GeometryFactory();
kNNQueryPoint = geometryFactory.createPoint(new Coordinate(-84.01, 34.01));
Expand Down Expand Up @@ -367,8 +368,8 @@ public static void testDistanceJoinQueryUsingIndex()
public static void testLoadShapefileIntoPolygonRDD()
throws Exception
{
ShapefileRDD shapefileRDD = new ShapefileRDD(sc, ShapeFileInputLocation);
PolygonRDD spatialRDD = new PolygonRDD(shapefileRDD.getPolygonRDD());
SpatialRDD shapefileRDD = ShapefileReader.readToGeometryRDD(sc, ShapeFileInputLocation);
PolygonRDD spatialRDD = new PolygonRDD(shapefileRDD.rawSpatialRDD);
try {
RangeQuery.SpatialRangeQuery(spatialRDD, new Envelope(-180, 180, -90, 90), false, false).count();
}
Expand Down

0 comments on commit 6ac48f5

Please sign in to comment.