-
Notifications
You must be signed in to change notification settings - Fork 693
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from jiayuasu/master
Refactor GeoSpark APIs. Prepare for LineStringRDD and the upcoming re…
- Loading branch information
Showing
93 changed files
with
3,327 additions
and
4,239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/org/datasyslab/geospark/enums/FileDataSplitter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/org/datasyslab/geospark/geometryObjects/Circle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 0 additions & 45 deletions
45
src/main/java/org/datasyslab/geospark/geometryObjects/EnvelopeWithGrid.java
This file was deleted.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
src/main/java/org/datasyslab/geospark/joinJudgement/AllByRectangleJudgementUsingIndex.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* FILE: AllByRectangleJudgementUsingIndex.java | ||
* PATH: org.datasyslab.geospark.joinJudgement.AllByRectangleJudgementUsingIndex.java | ||
* Copyright (c) 2016 Arizona State University Data Systems Lab. | ||
* All rights reserved. | ||
*/ | ||
package org.datasyslab.geospark.joinJudgement; | ||
|
||
import java.io.Serializable; | ||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
import org.apache.spark.api.java.function.PairFlatMapFunction; | ||
|
||
import com.vividsolutions.jts.geom.Envelope; | ||
import com.vividsolutions.jts.geom.Geometry; | ||
import com.vividsolutions.jts.index.SpatialIndex; | ||
import com.vividsolutions.jts.index.quadtree.Quadtree; | ||
import com.vividsolutions.jts.index.strtree.STRtree; | ||
|
||
import scala.Tuple2; | ||
|
||
// TODO: Auto-generated Javadoc | ||
/** | ||
* The Class AllByRectangleJudgementUsingIndex. | ||
*/ | ||
public class AllByRectangleJudgementUsingIndex implements PairFlatMapFunction<Tuple2<Integer, Tuple2<Iterable<Object>, Iterable<Object>>>, Envelope, HashSet<Geometry>>, Serializable{ | ||
|
||
/* (non-Javadoc) | ||
* @see org.apache.spark.api.java.function.PairFlatMapFunction#call(java.lang.Object) | ||
*/ | ||
@Override | ||
public Iterator<Tuple2<Envelope, HashSet<Geometry>>> call(Tuple2<Integer, Tuple2<Iterable<Object>, Iterable<Object>>> cogroup) throws Exception { | ||
HashSet<Tuple2<Envelope, HashSet<Geometry>>> result = new HashSet<Tuple2<Envelope, HashSet<Geometry>>>(); | ||
Iterator<Object> iteratorWindow=cogroup._2()._2().iterator(); | ||
Iterator<Object> iteratorTree=cogroup._2()._1().iterator(); | ||
if(!iteratorTree.hasNext()) | ||
{ | ||
return result.iterator(); | ||
} | ||
SpatialIndex treeIndex = (SpatialIndex) iteratorTree.next(); | ||
if(treeIndex instanceof STRtree) | ||
{ | ||
treeIndex = (STRtree)treeIndex; | ||
} | ||
else | ||
{ | ||
treeIndex = (Quadtree)treeIndex; | ||
} | ||
while(iteratorWindow.hasNext()) { | ||
Envelope window=(Envelope)iteratorWindow.next(); | ||
List<Geometry> queryResult=new ArrayList<Geometry>(); | ||
queryResult=treeIndex.query(window); | ||
HashSet<Geometry> objectHashSet = new HashSet<Geometry>(queryResult); | ||
result.add(new Tuple2<Envelope, HashSet<Geometry>>(window, objectHashSet)); | ||
} | ||
return result.iterator(); | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/org/datasyslab/geospark/joinJudgement/GeometryByPolygonJudgement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* FILE: GeometryByPolygonJudgement.java | ||
* PATH: org.datasyslab.geospark.joinJudgement.GeometryByPolygonJudgement.java | ||
* Copyright (c) 2016 Arizona State University Data Systems Lab. | ||
* All rights reserved. | ||
*/ | ||
package org.datasyslab.geospark.joinJudgement; | ||
|
||
import java.io.Serializable; | ||
import java.util.HashSet; | ||
import java.util.Iterator; | ||
|
||
import org.apache.spark.api.java.function.PairFlatMapFunction; | ||
|
||
import com.vividsolutions.jts.geom.Geometry; | ||
import com.vividsolutions.jts.geom.Polygon; | ||
|
||
import scala.Tuple2; | ||
|
||
// TODO: Auto-generated Javadoc | ||
/** | ||
* The Class GeometryByPolygonJudgement. | ||
*/ | ||
public class GeometryByPolygonJudgement implements PairFlatMapFunction<Tuple2<Integer, Tuple2<Iterable<Object>, Iterable<Object>>>, Polygon, HashSet<Geometry>>, Serializable{ | ||
|
||
/* (non-Javadoc) | ||
* @see org.apache.spark.api.java.function.PairFlatMapFunction#call(java.lang.Object) | ||
*/ | ||
@Override | ||
public Iterator<Tuple2<Polygon, HashSet<Geometry>>> call(Tuple2<Integer, Tuple2<Iterable<Object>, Iterable<Object>>> cogroup) throws Exception { | ||
HashSet<Tuple2<Polygon, HashSet<Geometry>>> result = new HashSet<Tuple2<Polygon, HashSet<Geometry>>>(); | ||
Iterator iteratorWindow=cogroup._2()._2().iterator(); | ||
while(iteratorWindow.hasNext()) { | ||
Polygon window=(Polygon)iteratorWindow.next(); | ||
HashSet<Geometry> resultHashSet = new HashSet<Geometry>(); | ||
Iterator iteratorObject=cogroup._2()._1().iterator(); | ||
while (iteratorObject.hasNext()) { | ||
Geometry object = (Geometry)iteratorObject.next(); | ||
if (window.contains(object)) { | ||
resultHashSet.add(object); | ||
} | ||
} | ||
result.add(new Tuple2<Polygon, HashSet<Geometry>>(window, resultHashSet)); | ||
} | ||
return result.iterator(); | ||
} | ||
|
||
} |
61 changes: 61 additions & 0 deletions
61
...main/java/org/datasyslab/geospark/joinJudgement/GeometryByPolygonJudgementUsingIndex.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* FILE: GeometryByPolygonJudgementUsingIndex.java | ||
* PATH: org.datasyslab.geospark.joinJudgement.GeometryByPolygonJudgementUsingIndex.java | ||
* Copyright (c) 2016 Arizona State University Data Systems Lab. | ||
* All rights reserved. | ||
*/ | ||
package org.datasyslab.geospark.joinJudgement; | ||
|
||
import java.io.Serializable; | ||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
import org.apache.spark.api.java.function.PairFlatMapFunction; | ||
|
||
import com.vividsolutions.jts.geom.Geometry; | ||
import com.vividsolutions.jts.geom.Polygon; | ||
import com.vividsolutions.jts.index.SpatialIndex; | ||
import com.vividsolutions.jts.index.quadtree.Quadtree; | ||
import com.vividsolutions.jts.index.strtree.STRtree; | ||
|
||
import scala.Tuple2; | ||
|
||
// TODO: Auto-generated Javadoc | ||
/** | ||
* The Class GeometryByPolygonJudgementUsingIndex. | ||
*/ | ||
public class GeometryByPolygonJudgementUsingIndex implements PairFlatMapFunction<Tuple2<Integer, Tuple2<Iterable<Object>, Iterable<Object>>>, Polygon, HashSet<Geometry>>, Serializable{ | ||
|
||
/* (non-Javadoc) | ||
* @see org.apache.spark.api.java.function.PairFlatMapFunction#call(java.lang.Object) | ||
*/ | ||
@Override | ||
public Iterator<Tuple2<Polygon, HashSet<Geometry>>> call(Tuple2<Integer, Tuple2<Iterable<Object>, Iterable<Object>>> cogroup) throws Exception { | ||
HashSet<Tuple2<Polygon, HashSet<Geometry>>> result = new HashSet<Tuple2<Polygon, HashSet<Geometry>>>(); | ||
Iterator<Object> iteratorWindow=cogroup._2()._2().iterator(); | ||
Iterator<Object> iteratorTree=cogroup._2()._1().iterator(); | ||
if(!iteratorTree.hasNext()) | ||
{ | ||
return result.iterator(); | ||
} | ||
SpatialIndex treeIndex = (SpatialIndex) iteratorTree.next(); | ||
if(treeIndex instanceof STRtree) | ||
{ | ||
treeIndex = (STRtree)treeIndex; | ||
} | ||
else | ||
{ | ||
treeIndex = (Quadtree)treeIndex; | ||
} | ||
while(iteratorWindow.hasNext()) { | ||
Polygon window=(Polygon)iteratorWindow.next(); | ||
List<Geometry> queryResult=new ArrayList<Geometry>(); | ||
queryResult=treeIndex.query(window.getEnvelopeInternal()); | ||
HashSet<Geometry> objectHashSet = new HashSet<Geometry>(queryResult); | ||
result.add(new Tuple2<Polygon, HashSet<Geometry>>(window, objectHashSet)); | ||
} | ||
return result.iterator(); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/org/datasyslab/geospark/joinJudgement/GeometryByRectangleJudgement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* FILE: GeometryByRectangleJudgement.java | ||
* PATH: org.datasyslab.geospark.joinJudgement.GeometryByRectangleJudgement.java | ||
* Copyright (c) 2016 Arizona State University Data Systems Lab. | ||
* All rights reserved. | ||
*/ | ||
package org.datasyslab.geospark.joinJudgement; | ||
|
||
import java.io.Serializable; | ||
import java.util.HashSet; | ||
import java.util.Iterator; | ||
|
||
import org.apache.spark.api.java.function.PairFlatMapFunction; | ||
|
||
import com.vividsolutions.jts.geom.Envelope; | ||
import com.vividsolutions.jts.geom.Geometry; | ||
|
||
import scala.Tuple2; | ||
|
||
// TODO: Auto-generated Javadoc | ||
/** | ||
* The Class GeometryByRectangleJudgement. | ||
*/ | ||
public class GeometryByRectangleJudgement implements PairFlatMapFunction<Tuple2<Integer, Tuple2<Iterable<Object>, Iterable<Object>>>, Envelope, HashSet<Geometry>>, Serializable{ | ||
|
||
/* (non-Javadoc) | ||
* @see org.apache.spark.api.java.function.PairFlatMapFunction#call(java.lang.Object) | ||
*/ | ||
@Override | ||
public Iterator<Tuple2<Envelope, HashSet<Geometry>>> call(Tuple2<Integer, Tuple2<Iterable<Object>, Iterable<Object>>> cogroup) throws Exception { | ||
HashSet<Tuple2<Envelope, HashSet<Geometry>>> result = new HashSet<Tuple2<Envelope, HashSet<Geometry>>>(); | ||
Iterator iteratorWindow=cogroup._2()._2().iterator(); | ||
while(iteratorWindow.hasNext()) { | ||
Envelope window=(Envelope)iteratorWindow.next(); | ||
HashSet<Geometry> resultHashSet = new HashSet<Geometry>(); | ||
Iterator iteratorObject=cogroup._2()._1().iterator(); | ||
while (iteratorObject.hasNext()) { | ||
Geometry object = (Geometry)iteratorObject.next(); | ||
if (window.contains(object.getEnvelopeInternal())) { | ||
resultHashSet.add(object); | ||
} | ||
} | ||
result.add(new Tuple2<Envelope, HashSet<Geometry>>(window, resultHashSet)); | ||
} | ||
return result.iterator(); | ||
} | ||
|
||
} |
Oops, something went wrong.