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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
d2b0d3fa
Commit
d2b0d3fa
authored
Feb 26, 2003
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added num_geometries() and geometry_n() methods for MultiX geometry objects.
parent
c20de066
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
114 additions
and
3 deletions
+114
-3
sql/spatial.cc
sql/spatial.cc
+107
-0
sql/spatial.h
sql/spatial.h
+7
-3
No files found.
sql/spatial.cc
View file @
d2b0d3fa
...
...
@@ -845,6 +845,30 @@ int GMultiPoint::get_mbr(MBR *mbr) const
return
0
;
}
int
GMultiPoint
::
num_geometries
(
uint32
*
num
)
const
{
*
num
=
uint4korr
(
m_data
);
return
0
;
}
int
GMultiPoint
::
geometry_n
(
uint32
num
,
String
*
result
)
const
{
const
char
*
data
=
m_data
;
uint32
n_points
;
if
(
no_data
(
data
,
4
))
return
1
;
n_points
=
uint4korr
(
data
);
data
+=
4
;
if
((
num
>
n_points
)
||
(
num
<
1
))
return
-
1
;
data
+=
(
num
-
1
)
*
(
WKB_HEADER_SIZE
+
POINT_DATA_SIZE
);
if
(
result
->
reserve
(
WKB_HEADER_SIZE
+
POINT_DATA_SIZE
))
return
1
;
result
->
q_append
(
data
,
WKB_HEADER_SIZE
+
POINT_DATA_SIZE
);
return
0
;
}
/***************************** MultiLineString *******************************/
size_t
GMultiLineString
::
get_data_size
()
const
...
...
@@ -970,6 +994,44 @@ int GMultiLineString::get_mbr(MBR *mbr) const
return
0
;
}
int
GMultiLineString
::
num_geometries
(
uint32
*
num
)
const
{
*
num
=
uint4korr
(
m_data
);
return
0
;
}
int
GMultiLineString
::
geometry_n
(
uint32
num
,
String
*
result
)
const
{
uint32
n_line_strings
;
const
char
*
data
=
m_data
;
if
(
no_data
(
data
,
4
))
return
1
;
n_line_strings
=
uint4korr
(
data
);
data
+=
4
;
if
((
num
>
n_line_strings
)
||
(
num
<
1
))
return
-
1
;
for
(;
num
>
0
;
--
num
)
{
if
(
no_data
(
data
,
WKB_HEADER_SIZE
+
4
))
return
1
;
uint32
n_points
=
uint4korr
(
data
+
WKB_HEADER_SIZE
);
if
(
num
==
1
)
{
if
(
result
->
reserve
(
WKB_HEADER_SIZE
+
4
+
POINT_DATA_SIZE
*
n_points
))
return
1
;
result
->
q_append
(
data
,
WKB_HEADER_SIZE
+
4
+
POINT_DATA_SIZE
*
n_points
);
break
;
}
else
{
data
+=
WKB_HEADER_SIZE
+
4
+
POINT_DATA_SIZE
*
n_points
;
}
}
return
0
;
}
int
GMultiLineString
::
length
(
double
*
len
)
const
{
uint32
n_line_strings
;
...
...
@@ -1164,6 +1226,51 @@ int GMultiPolygon::get_mbr(MBR *mbr) const
return
0
;
}
int
GMultiPolygon
::
num_geometries
(
uint32
*
num
)
const
{
*
num
=
uint4korr
(
m_data
);
return
0
;
}
int
GMultiPolygon
::
geometry_n
(
uint32
num
,
String
*
result
)
const
{
uint32
n_polygons
;
const
char
*
data
=
m_data
,
*
polygon_n
;
LINT_INIT
(
polygon_n
);
if
(
no_data
(
data
,
4
))
return
1
;
n_polygons
=
uint4korr
(
data
);
data
+=
4
;
if
((
num
>
n_polygons
)
||
(
num
<
1
))
return
-
1
;
for
(;
num
>
0
;
--
num
)
{
if
(
no_data
(
data
,
WKB_HEADER_SIZE
+
4
))
return
1
;
uint32
n_linear_rings
=
uint4korr
(
data
+
WKB_HEADER_SIZE
);
if
(
num
==
1
)
polygon_n
=
data
;
data
+=
WKB_HEADER_SIZE
+
4
;
for
(;
n_linear_rings
>
0
;
--
n_linear_rings
)
{
if
(
no_data
(
data
,
4
))
return
1
;
uint32
n_points
=
uint4korr
(
data
);
data
+=
4
+
POINT_DATA_SIZE
*
n_points
;
}
if
(
num
==
1
)
{
if
(
result
->
reserve
(
data
-
polygon_n
))
return
-
1
;
result
->
q_append
(
polygon_n
,
data
-
polygon_n
);
break
;
}
}
return
0
;
}
int
GMultiPolygon
::
area
(
double
*
ar
)
const
{
...
...
sql/spatial.h
View file @
d2b0d3fa
...
...
@@ -413,7 +413,6 @@ public:
int
end_point
(
String
*
point
)
const
;
int
point_n
(
uint32
n
,
String
*
result
)
const
;
int
dimension
(
uint32
*
dim
)
const
{
*
dim
=
1
;
return
0
;
}
// IsRing
};
/***************************** Polygon *******************************/
...
...
@@ -433,7 +432,6 @@ public:
int
centroid_xy
(
double
*
x
,
double
*
y
)
const
;
int
centroid
(
String
*
result
)
const
;
int
dimension
(
uint32
*
dim
)
const
{
*
dim
=
2
;
return
0
;
}
// PointOnSurface
};
/***************************** MultiPoint *******************************/
...
...
@@ -445,6 +443,9 @@ public:
int
init_from_text
(
GTextReadStream
*
trs
,
String
*
wkb
);
int
get_data_as_text
(
String
*
txt
)
const
;
int
get_mbr
(
MBR
*
mbr
)
const
;
int
num_geometries
(
uint32
*
num
)
const
;
int
geometry_n
(
uint32
num
,
String
*
result
)
const
;
int
dimension
(
uint32
*
dim
)
const
{
*
dim
=
0
;
return
0
;
}
};
...
...
@@ -458,6 +459,8 @@ public:
int
get_data_as_text
(
String
*
txt
)
const
;
int
get_mbr
(
MBR
*
mbr
)
const
;
int
num_geometries
(
uint32
*
num
)
const
;
int
geometry_n
(
uint32
num
,
String
*
result
)
const
;
int
length
(
double
*
len
)
const
;
int
is_closed
(
int
*
closed
)
const
;
int
dimension
(
uint32
*
dim
)
const
{
*
dim
=
1
;
return
0
;
}
...
...
@@ -473,10 +476,11 @@ public:
int
get_data_as_text
(
String
*
txt
)
const
;
int
get_mbr
(
MBR
*
mbr
)
const
;
int
num_geometries
(
uint32
*
num
)
const
;
int
geometry_n
(
uint32
num
,
String
*
result
)
const
;
int
area
(
double
*
ar
)
const
;
int
centroid
(
String
*
result
)
const
;
int
dimension
(
uint32
*
dim
)
const
{
*
dim
=
2
;
return
0
;
}
// PointOnSurface
};
/***************************** GeometryCollection *******************************/
...
...
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