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
1782102d
Commit
1782102d
authored
Jan 24, 2017
by
Alexey Botchkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-11042 Implement GeoJSON functions.
Typenames made into proper character case.
parent
6cdbf202
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
19 deletions
+24
-19
mysql-test/r/gis-json.result
mysql-test/r/gis-json.result
+7
-7
sql/spatial.cc
sql/spatial.cc
+14
-11
sql/spatial.h
sql/spatial.h
+3
-1
No files found.
mysql-test/r/gis-json.result
View file @
1782102d
select st_asgeojson(geomfromtext('POINT(1 1)'));
st_asgeojson(geomfromtext('POINT(1 1)'))
{"type": "P
OINT
", "coordinates": [1, 1]}
{"type": "P
oint
", "coordinates": [1, 1]}
select st_asgeojson(geomfromtext('LINESTRING(10 10,20 10,20 20,10 20,10 10)'));
st_asgeojson(geomfromtext('LINESTRING(10 10,20 10,20 20,10 20,10 10)'))
{"type": "L
INESTRING
", "coordinates": [[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]}
{"type": "L
ineString
", "coordinates": [[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]}
select st_asgeojson(geomfromtext('POLYGON((10 10,20 10,20 20,10 20,10 10))'));
st_asgeojson(geomfromtext('POLYGON((10 10,20 10,20 20,10 20,10 10))'))
{"type": "P
OLYGON
", "coordinates": [[[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]]}
{"type": "P
olygon
", "coordinates": [[[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]]}
select st_asgeojson(geomfromtext('MULTIPOLYGON(((10 10,20 10,20 20,10 20,10 10)))'));
st_asgeojson(geomfromtext('MULTIPOLYGON(((10 10,20 10,20 20,10 20,10 10)))'))
{"type": "M
ULTIPOLYGON
", "coordinates": [[[[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]]]}
{"type": "M
ultiPolygon
", "coordinates": [[[[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]]]}
select st_asgeojson(geomfromtext('multilinestring((10 10,20 10,20 20,10 20,10 10))'));
st_asgeojson(geomfromtext('multilinestring((10 10,20 10,20 20,10 20,10 10))'))
{"type": "M
ULTILINESTRING
", "coordinates": [[[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]]}
{"type": "M
ultiLineString
", "coordinates": [[[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]]}
select st_asgeojson(geomfromtext('multipoint(10 10,20 10,20 20,10 20,10 10)'));
st_asgeojson(geomfromtext('multipoint(10 10,20 10,20 20,10 20,10 10)'))
{"type": "M
ULTIPOINT
", "coordinates": [[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]}
{"type": "M
ultiPoint
", "coordinates": [[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]}
select st_asgeojson(st_geomfromtext('GEOMETRYCOLLECTION(POINT(100 0),LINESTRING(101 0,102 1))'));
st_asgeojson(st_geomfromtext('GEOMETRYCOLLECTION(POINT(100 0),LINESTRING(101 0,102 1))'))
{"type": "G
EOMETRYCOLLECTION", "geometries": [{"type": "POINT", "coordinates": [100, 0]}, {"type": "LINESTRING
", "coordinates": [[101, 0], [102, 1]]}]}
{"type": "G
eometryCollection", "geometries": [{"type": "Point", "coordinates": [100, 0]}, {"type": "LineString
", "coordinates": [[101, 0], [102, 1]]}]}
SELECT st_astext(st_geomfromgeojson('{"type":"point","coordinates":[1,2]}'));
st_astext(st_geomfromgeojson('{"type":"point","coordinates":[1,2]}'))
POINT(1 2)
...
...
sql/spatial.cc
View file @
1782102d
...
...
@@ -58,12 +58,14 @@ Geometry::Class_info *Geometry::ci_collection[Geometry::wkb_last+1]=
static
Geometry
::
Class_info
**
ci_collection_end
=
Geometry
::
ci_collection
+
Geometry
::
wkb_last
+
1
;
Geometry
::
Class_info
::
Class_info
(
const
char
*
name
,
int
type_id
,
create_geom_t
create_func
)
:
Geometry
::
Class_info
::
Class_info
(
const
char
*
name
,
const
char
*
geojson_name
,
int
type_id
,
create_geom_t
create_func
)
:
m_type_id
(
type_id
),
m_create_func
(
create_func
)
{
m_name
.
str
=
(
char
*
)
name
;
m_name
.
length
=
strlen
(
name
);
m_geojson_name
.
str
=
(
char
*
)
geojson_name
;
m_geojson_name
.
length
=
strlen
(
geojson_name
);
ci_collection
[
type_id
]
=
this
;
}
...
...
@@ -105,26 +107,27 @@ static Geometry *create_geometrycollection(char *buffer)
static
Geometry
::
Class_info
point_class
(
"POINT"
,
static
Geometry
::
Class_info
point_class
(
"POINT"
,
"Point"
,
Geometry
::
wkb_point
,
create_point
);
static
Geometry
::
Class_info
linestring_class
(
"LINESTRING"
,
static
Geometry
::
Class_info
linestring_class
(
"LINESTRING"
,
"LineString"
,
Geometry
::
wkb_linestring
,
create_linestring
);
static
Geometry
::
Class_info
polygon_class
(
"POLYGON"
,
static
Geometry
::
Class_info
polygon_class
(
"POLYGON"
,
"Polygon"
,
Geometry
::
wkb_polygon
,
create_polygon
);
static
Geometry
::
Class_info
multipoint_class
(
"MULTIPOINT"
,
static
Geometry
::
Class_info
multipoint_class
(
"MULTIPOINT"
,
"MultiPoint"
,
Geometry
::
wkb_multipoint
,
create_multipoint
);
static
Geometry
::
Class_info
multilinestring_class
(
"MULTILINESTRING"
,
multilinestring_class
(
"MULTILINESTRING"
,
"MultiLineString"
,
Geometry
::
wkb_multilinestring
,
create_multilinestring
);
static
Geometry
::
Class_info
multipolygon_class
(
"MULTIPOLYGON"
,
static
Geometry
::
Class_info
multipolygon_class
(
"MULTIPOLYGON"
,
"MultiPolygon"
,
Geometry
::
wkb_multipolygon
,
create_multipolygon
);
static
Geometry
::
Class_info
geometrycollection_class
(
"GEOMETRYCOLLECTION"
,
Geometry
::
wkb_geometrycollection
,
geometrycollection_class
(
"GEOMETRYCOLLECTION"
,
"GeometryCollection"
,
Geometry
::
wkb_geometrycollection
,
create_geometrycollection
);
static
void
get_point
(
double
*
x
,
double
*
y
,
const
char
*
data
)
...
...
@@ -251,14 +254,14 @@ static const int feature_coll_type_len= 17;
int
Geometry
::
as_json
(
String
*
wkt
,
uint
max_dec_digits
,
const
char
**
end
)
{
uint32
len
=
(
uint
)
get_class_info
()
->
m_name
.
length
;
uint32
len
=
(
uint
)
get_class_info
()
->
m_
geojson_
name
.
length
;
if
(
wkt
->
reserve
(
4
+
type_keyname_len
+
2
+
len
+
2
+
2
+
coord_keyname_len
+
4
,
512
))
return
1
;
wkt
->
qs_append
(
"{
\"
"
,
2
);
wkt
->
qs_append
((
const
char
*
)
type_keyname
,
type_keyname_len
);
wkt
->
qs_append
(
"
\"
:
\"
"
,
4
);
wkt
->
qs_append
(
get_class_info
()
->
m_name
.
str
,
len
);
wkt
->
qs_append
(
get_class_info
()
->
m_
geojson_
name
.
str
,
len
);
wkt
->
qs_append
(
"
\"
,
\"
"
,
4
);
if
(
get_class_info
()
==
&
geometrycollection_class
)
wkt
->
qs_append
((
const
char
*
)
geometries_keyname
,
geometries_keyname_len
);
...
...
sql/spatial.h
View file @
1782102d
...
...
@@ -265,9 +265,11 @@ class Geometry
{
public:
LEX_STRING
m_name
;
LEX_STRING
m_geojson_name
;
int
m_type_id
;
create_geom_t
m_create_func
;
Class_info
(
const
char
*
name
,
int
type_id
,
create_geom_t
create_func
);
Class_info
(
const
char
*
name
,
const
char
*
gejson_name
,
int
type_id
,
create_geom_t
create_func
);
};
virtual
const
Class_info
*
get_class_info
()
const
=
0
;
...
...
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