Fixed issue 269. Any touch between two spatial objects are considered an intersection.

git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_lsm_stabilization@1331 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-app/data/spatial/spatialData.json b/asterix-app/data/spatial/spatialData.json
index e2dd151..9c78064 100644
--- a/asterix-app/data/spatial/spatialData.json
+++ b/asterix-app/data/spatial/spatialData.json
@@ -16,4 +16,6 @@
 {"id": 16, "point": point("-2.0,3.0"), "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,35.0 10.0")}
 {"id": 17, "point": point("4.1,7.0"), "kwds": "sign ahead", "line1": line("4.0,7.0 9.0,7.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("0.0,6.0 0.0,0.0 3.0,0.0 4.0,1.0 6.0,1.0 8.0,0.0 12.0,0.0 13.0,2.0 8.0,2.0 8.0,4.0 11.0,4.0 11.0,6.0 6.0,6.0 4.0,3.0 2.0,6.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,51.0 10.0")}
 {"id": 18, "point": point("-2.0,3.0"), "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.0,1.0 7.0,1.0 7.0,4.0 6.0,2.0 5.0,4.0"), "poly2": polygon("6.0,3.0 7.0,5.0 6.0,7.0 5.0,5.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("43.0,45.0 12.0")}
-{"id": 19, "point": point("-2.0,3.0"), "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.0,1.0 7.0,1.0 7.0,4.0 6.0,2.0 5.0,4.0"), "poly2": polygon("6.0,1.0 7.0,5.0 6.0,7.0 5.0,5.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("65.0,2.0 13.0")}
\ No newline at end of file
+{"id": 19, "point": point("-2.0,3.0"), "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.0,1.0 7.0,1.0 7.0,4.0 6.0,2.0 5.0,4.0"), "poly2": polygon("6.0,1.0 7.0,5.0 6.0,7.0 5.0,5.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("65.0,2.0 13.0")}
+{"id": 20, "point": point("4.0,3.0"), "kwds": "sign ahead", "line1": line("20.0,20.0 30.0,40.0"), "line2": line("5.0,8.0 0.0,1.0"), "poly1": polygon("4.0,1.0 4.0,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("50.0,10.0 50.0,40.0 70.0,40.0 70.0,10.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,23.0 12.0")}
+{"id": 21, "point": point("0.0,5.0"), "kwds": "sign ahead", "line1": line("0.0,5.0 0.0,40.0"), "line2": line("5.0,8.0 0.0,1.0"), "poly1": polygon("5.1,5.1 14.0,14.0 22.0,14.0 22.0,10.0"), "poly2": polygon("50.0,10.0 50.0,40.0 70.0,40.0 70.0,10.0"), "rec": rectangle("0.0,0.0 5.1,5.1"), "circle" : circle("1.0,23.0 12.0")}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/circle-intersect-circle.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/circle-intersect-circle.aql
index 6018671..2295947 100644
--- a/asterix-app/src/test/resources/runtimets/queries/spatial/circle-intersect-circle.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/circle-intersect-circle.aql
@@ -15,7 +15,7 @@
 write output to nc1:"rttest/spatial_circle-intersect-circle.adm";
 
 for $o in dataset('MyData')
-where spatial-intersect(create-circle(create-point(0.0,0.0), 5.0), create-circle(create-point(9.9,0.0), 5.0))
+where spatial-intersect(create-circle(create-point(0.0,0.0), 5.0), $o.circle)
 order by $o.id
 return {"id":$o.id}
  
diff --git a/asterix-app/src/test/resources/runtimets/results/dml/scan-insert-rtree-secondary-index.adm b/asterix-app/src/test/resources/runtimets/results/dml/scan-insert-rtree-secondary-index.adm
index 4bd8c19..5f5be7c 100644
--- a/asterix-app/src/test/resources/runtimets/results/dml/scan-insert-rtree-secondary-index.adm
+++ b/asterix-app/src/test/resources/runtimets/results/dml/scan-insert-rtree-secondary-index.adm
@@ -1,2 +1,3 @@
 { "id": 10 }
 { "id": 12 }
+{ "id": 20 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/index-selection/rtree-secondary-index-open.adm b/asterix-app/src/test/resources/runtimets/results/index-selection/rtree-secondary-index-open.adm
index 2ffad7c..d22217a 100644
--- a/asterix-app/src/test/resources/runtimets/results/index-selection/rtree-secondary-index-open.adm
+++ b/asterix-app/src/test/resources/runtimets/results/index-selection/rtree-secondary-index-open.adm
@@ -1 +1,2 @@
-{ "id": 12 }
\ No newline at end of file
+{ "id": 12 }
+{ "id": 20 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/index-selection/rtree-secondary-index.adm b/asterix-app/src/test/resources/runtimets/results/index-selection/rtree-secondary-index.adm
index 2ffad7c..d22217a 100644
--- a/asterix-app/src/test/resources/runtimets/results/index-selection/rtree-secondary-index.adm
+++ b/asterix-app/src/test/resources/runtimets/results/index-selection/rtree-secondary-index.adm
@@ -1 +1,2 @@
-{ "id": 12 }
\ No newline at end of file
+{ "id": 12 }
+{ "id": 20 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/spatial/circle-intersect-circle.adm b/asterix-app/src/test/resources/runtimets/results/spatial/circle-intersect-circle.adm
index c294669..af533e3 100644
--- a/asterix-app/src/test/resources/runtimets/results/spatial/circle-intersect-circle.adm
+++ b/asterix-app/src/test/resources/runtimets/results/spatial/circle-intersect-circle.adm
@@ -1,19 +1,6 @@
 { "id": 1 }
 { "id": 2 }
 { "id": 3 }
-{ "id": 4 }
-{ "id": 5 }
 { "id": 6 }
-{ "id": 7 }
-{ "id": 8 }
 { "id": 9 }
-{ "id": 10 }
-{ "id": 11 }
-{ "id": 12 }
-{ "id": 13 }
-{ "id": 14 }
-{ "id": 15 }
-{ "id": 16 }
-{ "id": 17 }
-{ "id": 18 }
-{ "id": 19 }
\ No newline at end of file
+{ "id": 11 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/spatial/create-rtree-index.adm b/asterix-app/src/test/resources/runtimets/results/spatial/create-rtree-index.adm
index 1778736..6a2a2c6 100644
--- a/asterix-app/src/test/resources/runtimets/results/spatial/create-rtree-index.adm
+++ b/asterix-app/src/test/resources/runtimets/results/spatial/create-rtree-index.adm
@@ -16,4 +16,6 @@
 16
 17
 18
-19
\ No newline at end of file
+19
+20
+21
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/spatial/distance-between-points.adm b/asterix-app/src/test/resources/runtimets/results/spatial/distance-between-points.adm
index 2dc063d..be5e2b4 100644
--- a/asterix-app/src/test/resources/runtimets/results/spatial/distance-between-points.adm
+++ b/asterix-app/src/test/resources/runtimets/results/spatial/distance-between-points.adm
@@ -16,4 +16,6 @@
 { "id": 16, "distance": 3.605551275463989d }
 { "id": 17, "distance": 8.112336284942828d }
 { "id": 18, "distance": 3.605551275463989d }
-{ "id": 19, "distance": 3.605551275463989d }
\ No newline at end of file
+{ "id": 19, "distance": 3.605551275463989d }
+{ "id": 20, "distance": 5.0d }
+{ "id": 21, "distance": 5.0d }
diff --git a/asterix-app/src/test/resources/runtimets/results/spatial/line-intersect-circle.adm b/asterix-app/src/test/resources/runtimets/results/spatial/line-intersect-circle.adm
index b61f96b..3ed757e 100644
--- a/asterix-app/src/test/resources/runtimets/results/spatial/line-intersect-circle.adm
+++ b/asterix-app/src/test/resources/runtimets/results/spatial/line-intersect-circle.adm
@@ -1,5 +1,7 @@
 { "id": 2 }
 { "id": 3 }
+{ "id": 6 }
+{ "id": 7 }
 { "id": 10 }
 { "id": 11 }
 { "id": 12 }
@@ -8,4 +10,5 @@
 { "id": 15 }
 { "id": 16 }
 { "id": 18 }
-{ "id": 19 }
\ No newline at end of file
+{ "id": 19 }
+{ "id": 21 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/spatial/line-intersect-rectangle.adm b/asterix-app/src/test/resources/runtimets/results/spatial/line-intersect-rectangle.adm
index bea5d1d..59506d2 100644
--- a/asterix-app/src/test/resources/runtimets/results/spatial/line-intersect-rectangle.adm
+++ b/asterix-app/src/test/resources/runtimets/results/spatial/line-intersect-rectangle.adm
@@ -10,4 +10,5 @@
 { "id": 15 }
 { "id": 16 }
 { "id": 18 }
-{ "id": 19 }
\ No newline at end of file
+{ "id": 19 }
+{ "id": 21 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/spatial/point-in-circle.adm b/asterix-app/src/test/resources/runtimets/results/spatial/point-in-circle.adm
index ad75861..f8d6259 100644
--- a/asterix-app/src/test/resources/runtimets/results/spatial/point-in-circle.adm
+++ b/asterix-app/src/test/resources/runtimets/results/spatial/point-in-circle.adm
@@ -3,4 +3,6 @@
 { "id": 15 }
 { "id": 16 }
 { "id": 18 }
-{ "id": 19 }
\ No newline at end of file
+{ "id": 19 }
+{ "id": 20 }
+{ "id": 21 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/spatial/point-in-polygon.adm b/asterix-app/src/test/resources/runtimets/results/spatial/point-in-polygon.adm
index 2ffad7c..d22217a 100644
--- a/asterix-app/src/test/resources/runtimets/results/spatial/point-in-polygon.adm
+++ b/asterix-app/src/test/resources/runtimets/results/spatial/point-in-polygon.adm
@@ -1 +1,2 @@
-{ "id": 12 }
\ No newline at end of file
+{ "id": 12 }
+{ "id": 20 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/spatial/point-in-rectangle.adm b/asterix-app/src/test/resources/runtimets/results/spatial/point-in-rectangle.adm
index bc9537a..424f77a 100644
--- a/asterix-app/src/test/resources/runtimets/results/spatial/point-in-rectangle.adm
+++ b/asterix-app/src/test/resources/runtimets/results/spatial/point-in-rectangle.adm
@@ -1,2 +1,4 @@
 { "id": 1 }
-{ "id": 10 }
\ No newline at end of file
+{ "id": 10 }
+{ "id": 20 }
+{ "id": 21 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/spatial/point-on-line.adm b/asterix-app/src/test/resources/runtimets/results/spatial/point-on-line.adm
index d5bf8d4..f737ee8 100644
--- a/asterix-app/src/test/resources/runtimets/results/spatial/point-on-line.adm
+++ b/asterix-app/src/test/resources/runtimets/results/spatial/point-on-line.adm
@@ -1,4 +1,5 @@
 { "id": 1 }
 { "id": 9 }
 { "id": 10 }
-{ "id": 17 }
\ No newline at end of file
+{ "id": 17 }
+{ "id": 21 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/spatial/polygon-intersect-circle.adm b/asterix-app/src/test/resources/runtimets/results/spatial/polygon-intersect-circle.adm
index e5293c9..bb9a070 100644
--- a/asterix-app/src/test/resources/runtimets/results/spatial/polygon-intersect-circle.adm
+++ b/asterix-app/src/test/resources/runtimets/results/spatial/polygon-intersect-circle.adm
@@ -7,4 +7,5 @@
 { "id": 16 }
 { "id": 17 }
 { "id": 18 }
-{ "id": 19 }
\ No newline at end of file
+{ "id": 19 }
+{ "id": 20 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/spatial/polygon-intersect-rectangle.adm b/asterix-app/src/test/resources/runtimets/results/spatial/polygon-intersect-rectangle.adm
index a602b8d..aa83a89 100644
--- a/asterix-app/src/test/resources/runtimets/results/spatial/polygon-intersect-rectangle.adm
+++ b/asterix-app/src/test/resources/runtimets/results/spatial/polygon-intersect-rectangle.adm
@@ -5,4 +5,6 @@
 { "id": 6 }
 { "id": 9 }
 { "id": 12 }
-{ "id": 17 }
\ No newline at end of file
+{ "id": 17 }
+{ "id": 20 }
+{ "id": 21 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/spatial/rectangle-intersect-circle.adm b/asterix-app/src/test/resources/runtimets/results/spatial/rectangle-intersect-circle.adm
index 62f32d0..260b1bf 100644
--- a/asterix-app/src/test/resources/runtimets/results/spatial/rectangle-intersect-circle.adm
+++ b/asterix-app/src/test/resources/runtimets/results/spatial/rectangle-intersect-circle.adm
@@ -16,3 +16,5 @@
 { "id": 17 }
 { "id": 18 }
 { "id": 19 }
+{ "id": 20 }
+{ "id": 21 }
diff --git a/asterix-app/src/test/resources/runtimets/results/spatial/rectangle-intersect-rectangle.adm b/asterix-app/src/test/resources/runtimets/results/spatial/rectangle-intersect-rectangle.adm
index e18550c..fed2dc7 100644
--- a/asterix-app/src/test/resources/runtimets/results/spatial/rectangle-intersect-rectangle.adm
+++ b/asterix-app/src/test/resources/runtimets/results/spatial/rectangle-intersect-rectangle.adm
@@ -1,2 +1,3 @@
 { "id": 1 }
-{ "id": 7 }
\ No newline at end of file
+{ "id": 7 }
+{ "id": 21 }
\ No newline at end of file
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SpatialIntersectDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SpatialIntersectDescriptor.java
index bd3aef5..415e44f 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SpatialIntersectDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/SpatialIntersectDescriptor.java
@@ -66,25 +66,11 @@
                     private final DoubleArray trianglesX1 = new DoubleArray();
                     private final DoubleArray trianglesY1 = new DoubleArray();
 
-                    private boolean pointOnLine(byte[] bytes0, byte[] bytes1) throws HyracksDataException {
-                        double startX = ADoubleSerializerDeserializer.getDouble(bytes0,
-                                ALineSerializerDeserializer.getStartPointCoordinateOffset(Coordinate.X));
-                        double startY = ADoubleSerializerDeserializer.getDouble(bytes0,
-                                ALineSerializerDeserializer.getStartPointCoordinateOffset(Coordinate.Y));
-                        double endX = ADoubleSerializerDeserializer.getDouble(bytes0,
-                                ALineSerializerDeserializer.getEndPointCoordinateOffset(Coordinate.X));
-                        double endY = ADoubleSerializerDeserializer.getDouble(bytes0,
-                                ALineSerializerDeserializer.getEndPointCoordinateOffset(Coordinate.Y));
-
-                        double pX = ADoubleSerializerDeserializer.getDouble(bytes1,
-                                APointSerializerDeserializer.getCoordinateOffset(Coordinate.X));
-                        double pY = ADoubleSerializerDeserializer.getDouble(bytes1,
-                                APointSerializerDeserializer.getCoordinateOffset(Coordinate.Y));
-
+                    private boolean pointOnLine(double pX, double pY, double startX, double startY, double endX,
+                            double endY) throws HyracksDataException {
                         double crossProduct = SpatialUtils.crossProduct(pY - startY, pX - startX, endY - startY, endX
                                 - startX);
-                        if (Math.abs(crossProduct) > SpatialUtils.doubleEpsilon()) { // crossProduct
-                            // != 0
+                        if (Math.abs(crossProduct) > SpatialUtils.doubleEpsilon()) { // crossProduct != 0
                             return false;
                         }
 
@@ -101,8 +87,7 @@
                         return true;
                     }
 
-                    private boolean pointInPolygon(byte[] bytes0, byte[] bytes1) throws HyracksDataException { // ray
-                        // casting
+                    private boolean pointInPolygon(byte[] bytes0, byte[] bytes1) throws HyracksDataException { // ray casting
 
                         double pX = ADoubleSerializerDeserializer.getDouble(bytes0,
                                 APointSerializerDeserializer.getCoordinateOffset(Coordinate.X));
@@ -135,13 +120,16 @@
                                 y2 = ADoubleSerializerDeserializer.getDouble(bytes1,
                                         APolygonSerializerDeserializer.getCoordinateOffset(i, Coordinate.Y));
                             }
-                            if (pY > Math.min(y1, y2)) {
-                                if (pY <= Math.max(y1, y2)) {
-                                    if (pX <= Math.max(x1, x2)) {
-                                        if (y1 != y2) {
-                                            xInters = (pY - y1) * (x2 - x1) / (y2 - y1) + x1;
-                                            if (x1 == x2 || pX <= xInters) {
-                                                counter++;
+
+                            if (!pointOnLine(pX, pY, x1, y1, x2, y2)) {
+                                if (pY > Math.min(y1, y2)) {
+                                    if (pY <= Math.max(y1, y2)) {
+                                        if (pX <= Math.max(x1, x2)) {
+                                            if (y1 != y2) {
+                                                xInters = (pY - y1) * (x2 - x1) / (y2 - y1) + x1;
+                                                if (x1 == x2 || pX <= xInters) {
+                                                    counter++;
+                                                }
                                             }
                                         }
                                     }
@@ -170,7 +158,7 @@
                         double radius = ADoubleSerializerDeserializer.getDouble(bytes1,
                                 ACircleSerializerDeserializer.getRadiusOffset());
 
-                        if ((x - cX) * (x - cX) + (y - cY) * (y - cY) < (radius * radius)) {
+                        if ((x - cX) * (x - cX) + (y - cY) * (y - cY) <= (radius * radius)) {
                             return true;
                         }
                         return false;
@@ -187,9 +175,7 @@
                         double C2 = A2 * startX2 + B2 * startY2;
 
                         double det = (A1 * B2) - (A2 * B1);
-                        if (Math.abs(det) > SpatialUtils.doubleEpsilon()) { // det
-                                                                            // !=
-                                                                            // 0
+                        if (Math.abs(det) > SpatialUtils.doubleEpsilon()) { // det != 0
                             double x = (B2 * C1 - B1 * C2) / det;
                             double y = (A1 * C2 - A2 * C1) / det;
 
@@ -309,7 +295,7 @@
                         dx = (startX + t * (endX - startX)) - cX;
                         dy = (startY + t * (endY - startY)) - cY;
                         double rt = (dx * dx) + (dy * dy);
-                        if (rt < (radius * radius)) {
+                        if (rt <= (radius * radius)) {
                             return true;
                         }
                         return false;
@@ -358,8 +344,7 @@
 
                     private int triangulatePolygon(byte[] bytes, int numOfPoints, IntArray pointsOffsets,
                             DoubleArray trianglesX, DoubleArray trianglesY, int triangleId,
-                            int nonSimplePolygonDetection, int middleVertex) throws HyracksDataException { // Ear
-                                                                                                           // clipping
+                            int nonSimplePolygonDetection, int middleVertex) throws HyracksDataException { // Ear clipping
 
                         if (numOfPoints < 3) {
                             return -1;
@@ -426,8 +411,7 @@
 
                     private boolean triangleTriangleIntersection(DoubleArray trianglesX0, DoubleArray trianglesY0,
                             int triangleId0, DoubleArray trianglesX1, DoubleArray trianglesY1, int triangleId1)
-                            throws HyracksDataException { // separating axis
-                                                          // theorem
+                            throws HyracksDataException { // separating axis theorem
 
                         for (int side = 0; side < 3; side++) {
                             spatialUtils.findNormals(trianglesX0, trianglesY0, triangleId0, side);
@@ -447,10 +431,8 @@
                         return true;
                     }
 
-                    private final boolean pointInsideTriangle(double x1, double y1, double x2, double y2, double x3,
-                            double y3, double pX, double pY)
-
-                    {
+                    private boolean pointInsideTriangle(double x1, double y1, double x2, double y2, double x3,
+                            double y3, double pX, double pY) {
                         return pointsOnSameSide(pX, pY, x1, y1, x2, y2, x3, y3)
                                 && pointsOnSameSide(pX, pY, x2, y2, x1, y1, x3, y3)
                                 && pointsOnSameSide(pX, pY, x3, y3, x1, y1, x2, y2);
@@ -464,9 +446,7 @@
                     }
 
                     private boolean circleTriangleIntersection(byte[] bytes0, DoubleArray trianglesX,
-                            DoubleArray trianglesY, int triangleId) throws HyracksDataException { // separating
-                                                                                                  // axis
-                                                                                                  // theorem
+                            DoubleArray trianglesY, int triangleId) throws HyracksDataException { // separating axis theorem
 
                         double cX = ADoubleSerializerDeserializer.getDouble(bytes0,
                                 ACircleSerializerDeserializer.getCenterPointCoordinateOffset(Coordinate.X));
@@ -772,7 +752,27 @@
                                             }
                                             break;
                                         case LINE:
-                                            res = pointOnLine(outInput1.getByteArray(), outInput0.getByteArray());
+                                            double pX = ADoubleSerializerDeserializer.getDouble(
+                                                    outInput0.getByteArray(),
+                                                    APointSerializerDeserializer.getCoordinateOffset(Coordinate.X));
+                                            double pY = ADoubleSerializerDeserializer.getDouble(
+                                                    outInput0.getByteArray(),
+                                                    APointSerializerDeserializer.getCoordinateOffset(Coordinate.Y));
+
+                                            double startX = ADoubleSerializerDeserializer.getDouble(outInput1
+                                                    .getByteArray(), ALineSerializerDeserializer
+                                                    .getStartPointCoordinateOffset(Coordinate.X));
+                                            double startY = ADoubleSerializerDeserializer.getDouble(outInput1
+                                                    .getByteArray(), ALineSerializerDeserializer
+                                                    .getStartPointCoordinateOffset(Coordinate.Y));
+                                            double endX = ADoubleSerializerDeserializer.getDouble(outInput1
+                                                    .getByteArray(), ALineSerializerDeserializer
+                                                    .getEndPointCoordinateOffset(Coordinate.X));
+                                            double endY = ADoubleSerializerDeserializer.getDouble(outInput1
+                                                    .getByteArray(), ALineSerializerDeserializer
+                                                    .getEndPointCoordinateOffset(Coordinate.Y));
+
+                                            res = pointOnLine(pX, pY, startX, startY, endX, endY);
                                             break;
                                         case POLYGON:
                                             res = pointInPolygon(outInput0.getByteArray(), outInput1.getByteArray());
@@ -796,7 +796,27 @@
                                 case LINE:
                                     switch (tag1) {
                                         case POINT:
-                                            res = pointOnLine(outInput0.getByteArray(), outInput1.getByteArray());
+                                            double pX = ADoubleSerializerDeserializer.getDouble(
+                                                    outInput1.getByteArray(),
+                                                    APointSerializerDeserializer.getCoordinateOffset(Coordinate.X));
+                                            double pY = ADoubleSerializerDeserializer.getDouble(
+                                                    outInput1.getByteArray(),
+                                                    APointSerializerDeserializer.getCoordinateOffset(Coordinate.Y));
+
+                                            double startX = ADoubleSerializerDeserializer.getDouble(outInput0
+                                                    .getByteArray(), ALineSerializerDeserializer
+                                                    .getStartPointCoordinateOffset(Coordinate.X));
+                                            double startY = ADoubleSerializerDeserializer.getDouble(outInput0
+                                                    .getByteArray(), ALineSerializerDeserializer
+                                                    .getStartPointCoordinateOffset(Coordinate.Y));
+                                            double endX = ADoubleSerializerDeserializer.getDouble(outInput0
+                                                    .getByteArray(), ALineSerializerDeserializer
+                                                    .getEndPointCoordinateOffset(Coordinate.X));
+                                            double endY = ADoubleSerializerDeserializer.getDouble(outInput0
+                                                    .getByteArray(), ALineSerializerDeserializer
+                                                    .getEndPointCoordinateOffset(Coordinate.Y));
+
+                                            res = pointOnLine(pX, pY, startX, startY, endX, endY);
                                             break;
                                         case LINE:
                                             double startX1 = ADoubleSerializerDeserializer.getDouble(outInput0
@@ -1059,5 +1079,4 @@
     public FunctionIdentifier getIdentifier() {
         return AsterixBuiltinFunctions.SPATIAL_INTERSECT;
     }
-
 }
\ No newline at end of file