Commit 0d107a85 authored by Alexey Botchkov's avatar Alexey Botchkov

MDEV-11042 Implement GeoJSON functions.

        ST_AsGeoJSON and ST_GeomFromGeoJSON functions implemented.
parent 1f3ad6a4
select st_asgeojson(geomfromtext('POINT(1 1)'));
st_asgeojson(geomfromtext('POINT(1 1)'))
{"type": "POINT", "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": "LINESTRING", "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": "POLYGON", "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": "MULTIPOLYGON", "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": "MULTILINESTRING", "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": "MULTIPOINT", "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": "GEOMETRYCOLLECTION", "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)
SELECT st_astext(st_geomfromgeojson('{"type":"LineString","coordinates":[[1,2],[4,5],[7,8]]}'));
st_astext(st_geomfromgeojson('{"type":"LineString","coordinates":[[1,2],[4,5],[7,8]]}'))
LINESTRING(1 2,4 5,7 8)
SELECT st_astext(st_geomfromgeojson('{"type": "polygon", "coordinates": [[[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]]}'));
st_astext(st_geomfromgeojson('{"type": "polygon", "coordinates": [[[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]]}'))
POLYGON((10 10,20 10,20 20,10 20,10 10))
SELECT st_astext(st_geomfromgeojson('{"type":"multipoint","coordinates":[[1,2],[4,5],[7,8]]}'));
st_astext(st_geomfromgeojson('{"type":"multipoint","coordinates":[[1,2],[4,5],[7,8]]}'))
MULTIPOINT(1 2,4 5,7 8)
SELECT st_astext(st_geomfromgeojson('{"type": "multilinestring", "coordinates": [[[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]]}'));
st_astext(st_geomfromgeojson('{"type": "multilinestring", "coordinates": [[[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]]}'))
MULTILINESTRING((10 10,20 10,20 20,10 20,10 10))
SELECT st_astext(st_geomfromgeojson('{"type": "multipolygon", "coordinates": [[[[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]]]}'));
st_astext(st_geomfromgeojson('{"type": "multipolygon", "coordinates": [[[[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]]]}'))
MULTIPOLYGON(((10 10,20 10,20 20,10 20,10 10)))
SELECT st_astext(st_geomfromgeojson('{"type": "GeometryCollection", "geometries": [{"type": "Point","coordinates": [100.0, 0.0]}, {"type": "LineString","coordinates": [[101.0, 0.0],[102.0, 1.0]]}]}'));
st_astext(st_geomfromgeojson('{"type": "GeometryCollection", "geometries": [{"type": "Point","coordinates": [100.0, 0.0]}, {"type": "LineString","coordinates": [[101.0, 0.0],[102.0, 1.0]]}]}'))
GEOMETRYCOLLECTION(POINT(100 0),LINESTRING(101 0,102 1))
SELECT st_astext(st_geomfromgeojson('{"type":"point"}'));
st_astext(st_geomfromgeojson('{"type":"point"}'))
NULL
Warnings:
Warning 4048 Incorrect GeoJSON format specified for st_geomfromgeojson function.
SELECT st_astext(st_geomfromgeojson('{"type":"point"'));
st_astext(st_geomfromgeojson('{"type":"point"'))
NULL
Warnings:
Warning 4037 Unexpected end of JSON text in argument 1 to function 'st_geomfromgeojson'
SELECT st_astext(st_geomfromgeojson('{"type""point"}'));
st_astext(st_geomfromgeojson('{"type""point"}'))
NULL
Warnings:
Warning 4038 Syntax error in JSON text in argument 1 to function 'st_geomfromgeojson' at position 7
SELECT st_astext(st_geomfromgeojson('{ "type": "Feature", "geometry": { "type": "Point", "coordinates": [102.0, 0.5] } }'));
st_astext(st_geomfromgeojson('{ "type": "Feature", "geometry": { "type": "Point", "coordinates": [102.0, 0.5] } }'))
POINT(102 0.5)
SELECT st_astext(st_geomfromgeojson('{ "type": "FeatureCollection", "features": [{ "type": "Feature", "geometry": { "type": "Point", "coordinates": [102.0, 0.5] }, "properties": { "prop0": "value0" } }]}'));
st_astext(st_geomfromgeojson('{ "type": "FeatureCollection", "features": [{ "type": "Feature", "geometry": { "type": "Point", "coordinates": [102.0, 0.5] }, "properties": { "prop0": "value0" } }]}'))
GEOMETRYCOLLECTION(POINT(102 0.5))
#
# End of 10.2 tests
#
-- source include/have_geometry.inc
select st_asgeojson(geomfromtext('POINT(1 1)'));
select st_asgeojson(geomfromtext('LINESTRING(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))'));
select st_asgeojson(geomfromtext('MULTIPOLYGON(((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))'));
select st_asgeojson(geomfromtext('multipoint(10 10,20 10,20 20,10 20,10 10)'));
select st_asgeojson(st_geomfromtext('GEOMETRYCOLLECTION(POINT(100 0),LINESTRING(101 0,102 1))'));
SELECT st_astext(st_geomfromgeojson('{"type":"point","coordinates":[1,2]}'));
SELECT st_astext(st_geomfromgeojson('{"type":"LineString","coordinates":[[1,2],[4,5],[7,8]]}'));
SELECT st_astext(st_geomfromgeojson('{"type": "polygon", "coordinates": [[[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]]}'));
SELECT st_astext(st_geomfromgeojson('{"type":"multipoint","coordinates":[[1,2],[4,5],[7,8]]}'));
SELECT st_astext(st_geomfromgeojson('{"type": "multilinestring", "coordinates": [[[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]]}'));
SELECT st_astext(st_geomfromgeojson('{"type": "multipolygon", "coordinates": [[[[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]]]}'));
SELECT st_astext(st_geomfromgeojson('{"type": "GeometryCollection", "geometries": [{"type": "Point","coordinates": [100.0, 0.0]}, {"type": "LineString","coordinates": [[101.0, 0.0],[102.0, 1.0]]}]}'));
SELECT st_astext(st_geomfromgeojson('{"type":"point"}'));
SELECT st_astext(st_geomfromgeojson('{"type":"point"'));
SELECT st_astext(st_geomfromgeojson('{"type""point"}'));
SELECT st_astext(st_geomfromgeojson('{ "type": "Feature", "geometry": { "type": "Point", "coordinates": [102.0, 0.5] } }'));
SELECT st_astext(st_geomfromgeojson('{ "type": "FeatureCollection", "features": [{ "type": "Feature", "geometry": { "type": "Point", "coordinates": [102.0, 0.5] }, "properties": { "prop0": "value0" } }]}'));
--echo #
--echo # End of 10.2 tests
--echo #
......@@ -1261,6 +1261,34 @@ class Create_func_geometry_from_wkb : public Create_native_func
#endif
#ifdef HAVE_SPATIAL
class Create_func_geometry_from_json : public Create_native_func
{
public:
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
static Create_func_geometry_from_json s_singleton;
protected:
Create_func_geometry_from_json() {}
virtual ~Create_func_geometry_from_json() {}
};
class Create_func_as_geojson : public Create_native_func
{
public:
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
static Create_func_as_geojson s_singleton;
protected:
Create_func_as_geojson() {}
virtual ~Create_func_as_geojson() {}
};
#endif /*HAVE_SPATIAL*/
#ifdef HAVE_SPATIAL
class Create_func_geometry_type : public Create_func_arg1
{
......@@ -4532,6 +4560,101 @@ Create_func_geometry_from_wkb::create_native(THD *thd, LEX_STRING name,
#endif
#ifdef HAVE_SPATIAL
Create_func_geometry_from_json Create_func_geometry_from_json::s_singleton;
Item*
Create_func_geometry_from_json::create_native(THD *thd, LEX_STRING name,
List<Item> *item_list)
{
Item *func= NULL;
int arg_count= 0;
if (item_list != NULL)
arg_count= item_list->elements;
switch (arg_count) {
case 1:
{
Item *json= item_list->pop();
func= new (thd->mem_root) Item_func_geometry_from_json(thd, json);
thd->lex->uncacheable(UNCACHEABLE_RAND);
break;
}
case 2:
{
Item *json= item_list->pop();
Item *options= item_list->pop();
func= new (thd->mem_root) Item_func_geometry_from_json(thd, json, options);
break;
}
case 3:
{
Item *json= item_list->pop();
Item *options= item_list->pop();
Item *srid= item_list->pop();
func= new (thd->mem_root) Item_func_geometry_from_json(thd, json, options,
srid);
break;
}
default:
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
break;
}
}
return func;
}
Create_func_as_geojson Create_func_as_geojson::s_singleton;
Item*
Create_func_as_geojson::create_native(THD *thd, LEX_STRING name,
List<Item> *item_list)
{
Item *func= NULL;
int arg_count= 0;
if (item_list != NULL)
arg_count= item_list->elements;
switch (arg_count) {
case 1:
{
Item *geom= item_list->pop();
func= new (thd->mem_root) Item_func_as_geojson(thd, geom);
thd->lex->uncacheable(UNCACHEABLE_RAND);
break;
}
case 2:
{
Item *geom= item_list->pop();
Item *max_dec= item_list->pop();
func= new (thd->mem_root) Item_func_as_geojson(thd, geom, max_dec);
break;
}
case 3:
{
Item *geom= item_list->pop();
Item *max_dec= item_list->pop();
Item *options= item_list->pop();
func= new (thd->mem_root) Item_func_as_geojson(thd, geom, max_dec, options);
break;
}
default:
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
break;
}
}
return func;
}
#endif /*HAVE_SPATIAL*/
#ifdef HAVE_SPATIAL
Create_func_geometry_type Create_func_geometry_type::s_singleton;
......@@ -6723,6 +6846,7 @@ static Native_func_registry func_array[] =
{ { C_STRING_WITH_LEN("STR_TO_DATE") }, BUILDER(Create_func_str_to_date)},
{ { C_STRING_WITH_LEN("ST_AREA") }, GEOM_BUILDER(Create_func_area)},
{ { C_STRING_WITH_LEN("ST_ASBINARY") }, GEOM_BUILDER(Create_func_as_wkb)},
{ { C_STRING_WITH_LEN("ST_ASGEOJSON") }, GEOM_BUILDER(Create_func_as_geojson)},
{ { C_STRING_WITH_LEN("ST_ASTEXT") }, GEOM_BUILDER(Create_func_as_wkt)},
{ { C_STRING_WITH_LEN("ST_ASWKB") }, GEOM_BUILDER(Create_func_as_wkb)},
{ { C_STRING_WITH_LEN("ST_ASWKT") }, GEOM_BUILDER(Create_func_as_wkt)},
......@@ -6748,6 +6872,7 @@ static Native_func_registry func_array[] =
{ { C_STRING_WITH_LEN("ST_GEOMETRYFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
{ { C_STRING_WITH_LEN("ST_GEOMETRYN") }, GEOM_BUILDER(Create_func_geometryn)},
{ { C_STRING_WITH_LEN("ST_GEOMETRYTYPE") }, GEOM_BUILDER(Create_func_geometry_type)},
{ { C_STRING_WITH_LEN("ST_GEOMFROMGEOJSON") }, GEOM_BUILDER(Create_func_geometry_from_json)},
{ { C_STRING_WITH_LEN("ST_GEOMFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
{ { C_STRING_WITH_LEN("ST_GEOMFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
#ifndef DBUG_OFF
......
......@@ -121,6 +121,65 @@ String *Item_func_geometry_from_wkb::val_str(String *str)
}
void report_json_error_ex(String *js, json_engine_t *je,
const char *fname, int n_param,
Sql_condition::enum_warning_level lv);
String *Item_func_geometry_from_json::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
Geometry_buffer buffer;
String *js= args[0]->val_str_ascii(&tmp_js);
uint32 srid= 0;
json_engine_t je;
if ((null_value= args[0]->null_value))
return 0;
if ((arg_count == 2) && !args[1]->null_value)
srid= (uint32)args[1]->val_int();
str->set_charset(&my_charset_bin);
if (str->reserve(SRID_SIZE, 512))
return 0;
str->length(0);
str->q_append(srid);
json_scan_start(&je, js->charset(), (const uchar *) js->ptr(),
(const uchar *) js->end());
if ((null_value= !Geometry::create_from_json(&buffer, &je, str)))
{
int code= 0;
switch (je.s.error)
{
case Geometry::GEOJ_INCORRECT_GEOJSON:
code= ER_GEOJSON_INCORRECT;
break;
case Geometry::GEOJ_TOO_FEW_POINTS:
code= ER_GEOJSON_TOO_FEW_POINTS;
break;
case Geometry::GEOJ_POLYGON_NOT_CLOSED:
code= ER_GEOJSON_NOT_CLOSED;
break;
default:
report_json_error_ex(js, &je, func_name(), 0, Sql_condition::WARN_LEVEL_WARN);
return NULL;
}
if (code)
{
THD *thd= current_thd;
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, code,
ER_THD(thd, code));
}
return 0;
}
return str;
}
String *Item_func_as_wkt::val_str_ascii(String *str)
{
DBUG_ASSERT(fixed == 1);
......@@ -170,6 +229,37 @@ String *Item_func_as_wkb::val_str(String *str)
}
void Item_func_as_geojson::fix_length_and_dec()
{
collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
max_length=MAX_BLOB_WIDTH;
maybe_null= 1;
}
String *Item_func_as_geojson::val_str_ascii(String *str)
{
DBUG_ASSERT(fixed == 1);
String arg_val;
String *swkb= args[0]->val_str(&arg_val);
Geometry_buffer buffer;
Geometry *geom= NULL;
const char *dummy;
if ((null_value=
(args[0]->null_value ||
!(geom= Geometry::construct(&buffer, swkb->ptr(), swkb->length())))))
return 0;
str->length(0);
str->set_charset(&my_charset_latin1);
if ((null_value= geom->as_json(str, FLOATING_POINT_DECIMALS, &dummy)))
return 0;
return str;
}
String *Item_func_geometry_type::val_str_ascii(String *str)
{
DBUG_ASSERT(fixed == 1);
......
......@@ -67,6 +67,23 @@ class Item_func_geometry_from_wkb: public Item_geometry_func
{ return get_item_copy<Item_func_geometry_from_wkb>(thd, mem_root, this); }
};
class Item_func_geometry_from_json: public Item_geometry_func
{
String tmp_js;
public:
Item_func_geometry_from_json(THD *thd, Item *js): Item_geometry_func(thd, js) {}
Item_func_geometry_from_json(THD *thd, Item *js, Item *opt):
Item_geometry_func(thd, js, opt) {}
Item_func_geometry_from_json(THD *thd, Item *js, Item *opt, Item *srid):
Item_geometry_func(thd, js, opt, srid) {}
const char *func_name() const { return "st_geomfromgeojson"; }
String *val_str(String *);
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_geometry_from_json>(thd, mem_root, this); }
};
class Item_func_as_wkt: public Item_str_ascii_func
{
public:
......@@ -89,6 +106,23 @@ class Item_func_as_wkb: public Item_geometry_func
{ return get_item_copy<Item_func_as_wkb>(thd, mem_root, this); }
};
class Item_func_as_geojson: public Item_str_ascii_func
{
public:
Item_func_as_geojson(THD *thd, Item *js): Item_str_ascii_func(thd, js) {}
Item_func_as_geojson(THD *thd, Item *js, Item *max_dec_digits):
Item_str_ascii_func(thd, js, max_dec_digits) {}
Item_func_as_geojson(THD *thd, Item *js, Item *max_dec_digits, Item *opt):
Item_str_ascii_func(thd, js, max_dec_digits, opt) {}
const char *func_name() const { return "st_asgeojson"; }
void fix_length_and_dec();
String *val_str_ascii(String *);
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_as_geojson>(thd, mem_root, this); }
};
class Item_func_geometry_type: public Item_str_ascii_func
{
public:
......
......@@ -117,7 +117,7 @@ static int st_append_escaped(String *s, const String *a)
report_json_error_ex(js, je, func_name(), n_param, \
Sql_condition::WARN_LEVEL_WARN)
static void report_json_error_ex(String *js, json_engine_t *je,
void report_json_error_ex(String *js, json_engine_t *je,
const char *fname, int n_param,
Sql_condition::enum_warning_level lv)
{
......
......@@ -7440,3 +7440,9 @@ ER_JSON_ONE_OR_ALL
eng "Argument 2 to function '%s' must be "one" or "all"."
ER_UNSUPPORT_COMPRESSED_TEMPORARY_TABLE
eng "CREATE TEMPORARY TABLE is not allowed with ROW_FORMAT=COMPRESSED or KEY_BLOCK_SIZE."
ER_GEOJSON_INCORRECT
eng "Incorrect GeoJSON format specified for st_geomfromgeojson function."
ER_GEOJSON_TOO_FEW_POINTS
eng "Incorrect GeoJSON format - too few points for linestring specified."
ER_GEOJSON_NOT_CLOSED
eng "Incorrect GeoJSON format - polygon not closed."
This diff is collapsed.
......@@ -20,6 +20,7 @@
#include "sql_string.h" /* String, LEX_STRING */
#include <my_compiler.h>
#include <json_lib.h>
#ifdef HAVE_SPATIAL
......@@ -249,6 +250,13 @@ class Geometry
wkb_xdr= 0, /* Big Endian */
wkb_ndr= 1 /* Little Endian */
};
enum geojson_errors
{
GEOJ_INCORRECT_GEOJSON= 1,
GEOJ_TOO_FEW_POINTS= 2,
GEOJ_POLYGON_NOT_CLOSED= 3,
};
/** Callback which creates Geometry objects on top of a given placement. */
typedef Geometry *(*create_geom_t)(char *);
......@@ -271,8 +279,11 @@ class Geometry
virtual uint init_from_opresult(String *bin,
const char *opres, uint res_len)
{ return init_from_wkb(opres + 4, UINT_MAX32, wkb_ndr, bin) + 4; }
virtual bool init_from_json(json_engine_t *je, String *wkb) {return true;}
virtual bool get_data_as_wkt(String *txt, const char **end) const=0;
virtual bool get_data_as_json(String *txt, uint max_dec_digits,
const char **end) const=0;
virtual bool get_mbr(MBR *mbr, const char **end) const=0;
virtual bool dimension(uint32 *dim, const char **end) const=0;
virtual int get_x(double *x) const { return -1; }
......@@ -302,9 +313,12 @@ class Geometry
bool init_stream=1);
static Geometry *create_from_wkb(Geometry_buffer *buffer,
const char *wkb, uint32 len, String *res);
static Geometry *create_from_json(Geometry_buffer *buffer,
json_engine_t *je, String *res);
static Geometry *create_from_opresult(Geometry_buffer *g_buf,
String *res, Gcalc_result_receiver &rr);
int as_wkt(String *wkt, const char **end);
int as_json(String *wkt, uint max_dec_digits, const char **end);
inline void set_data_ptr(const char *data, uint32 data_len)
{
......@@ -379,7 +393,10 @@ class Gis_point: public Geometry
uint32 get_data_size() const;
bool init_from_wkt(Gis_read_stream *trs, String *wkb);
uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res);
bool init_from_json(json_engine_t *je, String *wkb);
bool get_data_as_wkt(String *txt, const char **end) const;
bool get_data_as_json(String *txt, uint max_dec_digits,
const char **end) const;
bool get_mbr(MBR *mbr, const char **end) const;
int get_xy(double *x, double *y) const
......@@ -431,7 +448,10 @@ class Gis_line_string: public Geometry
uint32 get_data_size() const;
bool init_from_wkt(Gis_read_stream *trs, String *wkb);
uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res);
bool init_from_json(json_engine_t *je, String *wkb);
bool get_data_as_wkt(String *txt, const char **end) const;
bool get_data_as_json(String *txt, uint max_dec_digits,
const char **end) const;
bool get_mbr(MBR *mbr, const char **end) const;
int geom_length(double *len, const char **end) const;
int area(double *ar, const char **end) const;
......@@ -462,7 +482,10 @@ class Gis_polygon: public Geometry
bool init_from_wkt(Gis_read_stream *trs, String *wkb);
uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res);
uint init_from_opresult(String *bin, const char *opres, uint res_len);
bool init_from_json(json_engine_t *je, String *wkb);
bool get_data_as_wkt(String *txt, const char **end) const;
bool get_data_as_json(String *txt, uint max_dec_digits,
const char **end) const;
bool get_mbr(MBR *mbr, const char **end) const;
int area(double *ar, const char **end) const;
int exterior_ring(String *result) const;
......@@ -496,7 +519,10 @@ class Gis_multi_point: public Geometry
bool init_from_wkt(Gis_read_stream *trs, String *wkb);
uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res);
uint init_from_opresult(String *bin, const char *opres, uint res_len);
bool init_from_json(json_engine_t *je, String *wkb);
bool get_data_as_wkt(String *txt, const char **end) const;
bool get_data_as_json(String *txt, uint max_dec_digits,
const char **end) const;
bool get_mbr(MBR *mbr, const char **end) const;
int num_geometries(uint32 *num) const;
int geometry_n(uint32 num, String *result) const;
......@@ -522,7 +548,10 @@ class Gis_multi_line_string: public Geometry
bool init_from_wkt(Gis_read_stream *trs, String *wkb);
uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res);
uint init_from_opresult(String *bin, const char *opres, uint res_len);
bool init_from_json(json_engine_t *je, String *wkb);
bool get_data_as_wkt(String *txt, const char **end) const;
bool get_data_as_json(String *txt, uint max_dec_digits,
const char **end) const;
bool get_mbr(MBR *mbr, const char **end) const;
int num_geometries(uint32 *num) const;
int geometry_n(uint32 num, String *result) const;
......@@ -549,7 +578,10 @@ class Gis_multi_polygon: public Geometry
uint32 get_data_size() const;
bool init_from_wkt(Gis_read_stream *trs, String *wkb);
uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res);
bool init_from_json(json_engine_t *je, String *wkb);
bool get_data_as_wkt(String *txt, const char **end) const;
bool get_data_as_json(String *txt, uint max_dec_digits,
const char **end) const;
bool get_mbr(MBR *mbr, const char **end) const;
int num_geometries(uint32 *num) const;
int geometry_n(uint32 num, String *result) const;
......@@ -578,7 +610,10 @@ class Gis_geometry_collection: public Geometry
bool init_from_wkt(Gis_read_stream *trs, String *wkb);
uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res);
uint init_from_opresult(String *bin, const char *opres, uint res_len);
bool init_from_json(json_engine_t *je, String *wkb);
bool get_data_as_wkt(String *txt, const char **end) const;
bool get_data_as_json(String *txt, uint max_dec_digits,
const char **end) const;
bool get_mbr(MBR *mbr, const char **end) const;
int area(double *ar, const char **end) const;
int geom_length(double *len, const char **end) const;
......
......@@ -1231,10 +1231,7 @@ int json_key_matches(json_engine_t *je, json_string_t *k)
return 0;
}
if (json_read_string_const_chr(k))
return 1;
return 0;
return json_read_string_const_chr(k);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment