Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
72e79eaa
Commit
72e79eaa
authored
Oct 25, 2022
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: put casts in a separate statement
remove useless if()
parent
1ff476b4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
20 deletions
+18
-20
sql/item_geofunc.cc
sql/item_geofunc.cc
+18
-20
No files found.
sql/item_geofunc.cc
View file @
72e79eaa
...
...
@@ -2601,51 +2601,53 @@ double Item_func_sphere_distance::spherical_distance_points(Geometry *g1,
switch
(
g2
->
get_class_info
()
->
m_type_id
)
{
case
Geometry
:
:
wkb_point
:
// Optimization for point-point case
{
Gis_point
*
g2p
=
static_cast
<
Gis_point
*>
(
g2
);
// Optimization for point-point case
if
(
g1
->
get_class_info
()
->
m_type_id
==
Geometry
::
wkb_point
)
{
res
=
static_cast
<
Gis_point
*>
(
g2
)
->
calculate_haversine
(
g1
,
r
,
&
error
);
res
=
g2p
->
calculate_haversine
(
g1
,
r
,
&
error
);
}
else
{
// Optimization for single point in Multipoint
if
(
g1
->
get_data_size
()
==
len
)
{
res
=
static_cast
<
Gis_point
*>
(
g2
)
->
calculate_haversine
(
g1
,
r
,
&
error
);
res
=
g2p
->
calculate_haversine
(
g1
,
r
,
&
error
);
}
else
{
// There are multipoints in g1
// g1 is MultiPoint and calculate MP.sphericaldistance from g2 Point
if
(
g1
->
get_data_size
()
!=
GET_SIZE_ERROR
)
static_cast
<
Gis_point
*>
(
g2
)
->
spherical_distance_multipoints
(
(
Gis_multi_point
*
)
g1
,
r
,
&
res
,
&
error
);
g2p
->
spherical_distance_multipoints
(
g1
,
r
,
&
res
,
&
error
);
}
}
break
;
}
case
Geometry
:
:
wkb_multipoint
:
// Optimization for point-point case
if
(
g1
->
get_class_info
()
->
m_type_id
==
Geometry
::
wkb_point
)
{
Gis_point
*
g1p
=
static_cast
<
Gis_point
*>
(
g1
);
// Optimization for single point in Multipoint g2
if
(
g2
->
get_data_size
()
==
len
)
{
res
=
static_cast
<
Gis_point
*>
(
g1
)
->
calculate_haversine
(
g2
,
r
,
&
error
);
res
=
g1p
->
calculate_haversine
(
g2
,
r
,
&
error
);
}
else
{
if
(
g2
->
get_data_size
()
!=
GET_SIZE_ERROR
)
// g1 is a point (casted to multi_point) and g2 multipoint
static_cast
<
Gis_point
*>
(
g1
)
->
spherical_distance_multipoints
(
(
Gis_multi_point
*
)
g2
,
r
,
&
res
,
&
error
);
g1p
->
spherical_distance_multipoints
(
g2
,
r
,
&
res
,
&
error
);
}
}
else
{
Gis_multi_point
*
g1mp
=
static_cast
<
Gis_multi_point
*>
(
g1
);
// Multipoints in g1 and g2 - no optimization
static_cast
<
Gis_multi_point
*>
(
g1
)
->
spherical_distance_multipoints
(
(
Gis_multi_point
*
)
g2
,
r
,
&
res
,
&
error
);
g1mp
->
spherical_distance_multipoints
(
g2
,
r
,
&
res
,
&
error
);
}
break
;
...
...
@@ -2654,16 +2656,12 @@ double Item_func_sphere_distance::spherical_distance_points(Geometry *g1,
break
;
}
if
(
res
<
0
)
goto
handle_error
;
handle_error:
if
(
error
>
0
)
my_error
(
ER_STD_OUT_OF_RANGE_ERROR
,
MYF
(
0
),
"Longitude should be [-180,180]"
,
"ST_Distance_Sphere"
);
else
if
(
error
<
0
)
my_error
(
ER_STD_OUT_OF_RANGE_ERROR
,
MYF
(
0
),
"Latitude should be [-90,90]"
,
"ST_Distance_Sphere"
);
if
(
error
>
0
)
my_error
(
ER_STD_OUT_OF_RANGE_ERROR
,
MYF
(
0
),
"Longitude should be [-180,180]"
,
"ST_Distance_Sphere"
);
else
if
(
error
<
0
)
my_error
(
ER_STD_OUT_OF_RANGE_ERROR
,
MYF
(
0
),
"Latitude should be [-90,90]"
,
"ST_Distance_Sphere"
);
return
res
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment