summaryrefslogtreecommitdiff
path: root/sql/spatial.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-04-14 11:35:39 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-04-14 11:35:39 +0300
commit6c3e860cbf36831c118f6ea183acbbeb3c889bed (patch)
tree8585545cc8a95e790c01eb164f74685674f9f23b /sql/spatial.cc
parent9ff737b25edbcb0c74d9d312f6da702e7d993e88 (diff)
parent5008171b05e0d3b8b5f4af312b94a312281e77c7 (diff)
downloadmariadb-git-6c3e860cbf36831c118f6ea183acbbeb3c889bed.tar.gz
Merge 10.4 into 10.5
Diffstat (limited to 'sql/spatial.cc')
-rw-r--r--sql/spatial.cc22
1 files changed, 15 insertions, 7 deletions
diff --git a/sql/spatial.cc b/sql/spatial.cc
index 7a3286dae1c..13fff34df21 100644
--- a/sql/spatial.cc
+++ b/sql/spatial.cc
@@ -1,6 +1,6 @@
/*
Copyright (c) 2002, 2013, Oracle and/or its affiliates.
- Copyright (c) 2011, 2020, MariaDB Corporation.
+ Copyright (c) 2011, 2021, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1075,7 +1075,7 @@ double Gis_point::calculate_haversine(const Geometry *g,
int *error)
{
DBUG_ASSERT(sphere_radius > 0);
- double x1r, x2r, y1r, y2r, dlong, dlat, res;
+ double x1r, x2r, y1r, y2r;
// This check is done only for optimization purposes where we know it will
// be one and only one point in Multipoint
@@ -1092,31 +1092,39 @@ double Gis_point::calculate_haversine(const Geometry *g,
Geometry *gg= Geometry::construct(&gbuff, point_temp, point_size-1);
DBUG_ASSERT(gg);
if (static_cast<Gis_point *>(gg)->get_xy_radian(&x2r, &y2r))
+ {
DBUG_ASSERT(0);
+ return -1;
+ }
}
else
{
if (static_cast<const Gis_point *>(g)->get_xy_radian(&x2r, &y2r))
+ {
DBUG_ASSERT(0);
+ return -1;
+ }
}
if (this->get_xy_radian(&x1r, &y1r))
+ {
DBUG_ASSERT(0);
+ return -1;
+ }
// Check boundary conditions: longitude[-180,180]
if (!((x2r >= -M_PI && x2r <= M_PI) && (x1r >= -M_PI && x1r <= M_PI)))
{
*error=1;
return -1;
}
- // Check boundary conditions: lattitude[-90,90]
+ // Check boundary conditions: latitude[-90,90]
if (!((y2r >= -M_PI/2 && y2r <= M_PI/2) && (y1r >= -M_PI/2 && y1r <= M_PI/2)))
{
*error=-1;
return -1;
}
- dlat= sin((y2r - y1r)/2)*sin((y2r - y1r)/2);
- dlong= sin((x2r - x1r)/2)*sin((x2r - x1r)/2);
- res= 2*sphere_radius*asin((sqrt(dlat + cos(y1r)*cos(y2r)*dlong)));
- return res;
+ double dlat= sin((y2r - y1r)/2)*sin((y2r - y1r)/2);
+ double dlong= sin((x2r - x1r)/2)*sin((x2r - x1r)/2);
+ return 2*sphere_radius*asin((sqrt(dlat + cos(y1r)*cos(y2r)*dlong)));
}